tx · 6E7AJAL9JMV4gZg7a6XTZ5rDXmhx3wGLr2XpbPSi7f7f 3N6LHjfGb6Fgcy7YsVcNxGyPTj49XbQAijq: -0.01300000 Waves 2023.05.10 13:16 [2571656] smart account 3N6LHjfGb6Fgcy7YsVcNxGyPTj49XbQAijq > SELF 0.00000000 Waves
{ "type": 13, "id": "6E7AJAL9JMV4gZg7a6XTZ5rDXmhx3wGLr2XpbPSi7f7f", "fee": 1300000, "feeAssetId": null, "timestamp": 1683713836970, "version": 2, "chainId": 84, "sender": "3N6LHjfGb6Fgcy7YsVcNxGyPTj49XbQAijq", "senderPublicKey": "2u2wYYcVBQv43Cc71zkhHPPitkqgg6dqTZ3nUMvYJ1uq", "proofs": [ "4H78t2jagw6ozQPfZCkPpd72d1MkKLLTreoHd3mQTtMcMD6UxzGRCtLoQrorjTciHaxBeRxoqF5G5imYSjTeZWwo" ], "script": "base64:BgIQCAISBQoDAQgIEgUKAwEICBcAA1NFUAICX18ACGZlZVNjYWxlCQC2AgEAgMLXLwEPZ2V0U3RyaW5nT3JGYWlsAQNrZXkJARN2YWx1ZU9yRXJyb3JNZXNzYWdlAgkAnQgCBQR0aGlzBQNrZXkJAKwCAgIVTm8gZGF0YSBmb3IgdGhpcy5rZXk9BQNrZXkADHBvb2xEaXNhYmxlZAkAAgECDVBvb2wgZGlzYWJsZWQADHBvb2xOb3RFeGlzdAkAAgECEVBvb2wgaXMgbm90IGV4aXN0AA5zbGlwcGFnZVRvb0JpZwkAAgECE1NsaXBwYWdlIGlzIHRvbyBiaWcBE2tleU1hbmFnZXJQdWJsaWNLZXkAAhQlc19fbWFuYWdlclB1YmxpY0tleQEWa2V5TWFuYWdlclZhdWx0QWRkcmVzcwACFyVzX19tYW5hZ2VyVmF1bHRBZGRyZXNzAQJmYwACEyVzX19mYWN0b3J5Q29udHJhY3QAD2ZhY3RvcnlDb250cmFjdAkBEUBleHRyTmF0aXZlKDEwNjIpAQkBD2dldFN0cmluZ09yRmFpbAEJAQJmYwAB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lmeQAED3RhcmdldFB1YmxpY0tleQQHJG1hdGNoMAkBFm1hbmFnZXJQdWJsaWNLZXlPclVuaXQAAwkAAQIFByRtYXRjaDACCkJ5dGVWZWN0b3IEAnBrBQckbWF0Y2gwBQJwawMJAAECBQckbWF0Y2gwAgRVbml0CAUCdHgPc2VuZGVyUHVibGljS2V5CQACAQILTWF0Y2ggZXJyb3IJAPQDAwgFAnR4CWJvZHlCeXRlcwkAkQMCCAUCdHgGcHJvb2ZzAAAFD3RhcmdldFB1YmxpY0tleQoA0Bo=", "height": 2571656, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 61Ugg3z9sEYP74ELdkP4JTk42NJrLNhnEiq29rFuqaXq Next: iagmBQd5s4ACoPgKuu5dDpiEWRo7oDUQSJ43x9jpEQA Diff:
Old | New | Differences | |
---|---|---|---|
17 | 17 | func keyManagerPublicKey () = "%s__managerPublicKey" | |
18 | 18 | ||
19 | 19 | ||
20 | - | func | |
20 | + | func keyManagerVaultAddress () = "%s__managerVaultAddress" | |
21 | 21 | ||
22 | 22 | ||
23 | 23 | func fc () = "%s__factoryContract" | |
38 | 38 | ||
39 | 39 | let feeCollectorAddress = addressFromStringValue(getStringOrFailFromAddress(factoryContract, keyFeeCollectorAddress)) | |
40 | 40 | ||
41 | + | func getManagerVaultAddressOrThis () = match getString(keyManagerVaultAddress()) { | |
42 | + | case s: String => | |
43 | + | addressFromStringValue(s) | |
44 | + | case _ => | |
45 | + | this | |
46 | + | } | |
47 | + | ||
48 | + | ||
41 | 49 | func asInt (val) = match val { | |
42 | 50 | case valInt: Int => | |
43 | 51 | valInt | |
49 | 57 | func dataMappingPoolAssets (internalAmountAssetStr,internalPriceAssetStr) = makeString(["%d%d", toString(internalAmountAssetStr), toString(internalPriceAssetStr)], SEP) | |
50 | 58 | ||
51 | 59 | ||
52 | - | func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) { | |
53 | - | case s: String => | |
54 | - | fromBase58String(s) | |
55 | - | case _: Unit => | |
56 | - | unit | |
57 | - | case _ => | |
58 | - | throw("Match error") | |
59 | - | } | |
60 | - | ||
61 | - | ||
62 | - | func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) { | |
63 | - | case s: String => | |
64 | - | fromBase58String(s) | |
65 | - | case _: Unit => | |
66 | - | unit | |
67 | - | case _ => | |
68 | - | throw("Match error") | |
69 | - | } | |
60 | + | func managerPublicKeyOrUnit () = { | |
61 | + | let managerVaultAddress = getManagerVaultAddressOrThis() | |
62 | + | match getString(managerVaultAddress, keyManagerPublicKey()) { | |
63 | + | case s: String => | |
64 | + | fromBase58String(s) | |
65 | + | case _: Unit => | |
66 | + | unit | |
67 | + | case _ => | |
68 | + | throw("Match error") | |
69 | + | } | |
70 | + | } | |
70 | 71 | ||
71 | 72 | ||
72 | 73 | func isManager (i) = match managerPublicKeyOrUnit() { | |
102 | 103 | then @ | |
103 | 104 | else unit | |
104 | 105 | } | |
105 | - | let $ | |
106 | + | let $t026163075 = if ((lpNonReverse != unit)) | |
106 | 107 | then { | |
107 | 108 | let pool = { | |
108 | 109 | let @ = invoke(factoryContract, "getPoolAddressFromLpAssetREADONLY", [value(lpNonReverse)], nil) | |
123 | 124 | $Tuple2(true, pool) | |
124 | 125 | } | |
125 | 126 | else poolNotExist | |
126 | - | let isReverse = $ | |
127 | - | let pool = $ | |
127 | + | let isReverse = $t026163075._1 | |
128 | + | let pool = $t026163075._2 | |
128 | 129 | let poolStatus = { | |
129 | 130 | let @ = invoke(factoryContract, "getPoolStatusREADONLY", [pool], nil) | |
130 | 131 | if ($isInstanceOf(@, "Int")) | |
156 | 157 | then toBigInt(1) | |
157 | 158 | else feePoolAmountCalc | |
158 | 159 | let cleanAmountIn = ((toBigInt(amountIn) - feeProtocolAmount) - feePoolAmount) | |
159 | - | let $ | |
160 | - | let poolAdr = $ | |
161 | - | let isReverse = $ | |
160 | + | let $t040634141 = getPoolAddressAndCheckPoolStatus(assetIn, assetOut) | |
161 | + | let poolAdr = $t040634141._1 | |
162 | + | let isReverse = $t040634141._2 | |
162 | 163 | let res = { | |
163 | 164 | let @ = invoke(poolAdr, "calculateAmountOutForSwapREADONLY", [toInt(cleanAmountIn), isReverse, toInt(feePoolAmount)], nil) | |
164 | 165 | if ($isInstanceOf(@, "Int")) | |
196 | 197 | else throw("exactly 1 payment are expected")] | |
197 | 198 | if ((checks == checks)) | |
198 | 199 | then { | |
199 | - | let $ | |
200 | - | let poolAdr = $ | |
201 | - | let isReverse = $ | |
200 | + | let $t053435421 = getPoolAddressAndCheckPoolStatus(assetIn, assetOut) | |
201 | + | let poolAdr = $t053435421._1 | |
202 | + | let isReverse = $t053435421._2 | |
202 | 203 | let assetInAttachedPayment = if ((assetIn == "WAVES")) | |
203 | 204 | then unit | |
204 | 205 | else fromBase58String(assetIn) | |
209 | 210 | else throw(($getType(@) + " couldn't be cast to Int")) | |
210 | 211 | } | |
211 | 212 | $Tuple2([ScriptTransfer(feeCollectorAddress, toInt(feeProtocolAmount), assetInAttachedPayment), ScriptTransfer(poolAdr, toInt(feePoolAmount), assetInAttachedPayment)], totalGetRaw) | |
212 | - | } | |
213 | - | else throw("Strict value is not equal to itself.") | |
214 | - | } | |
215 | - | ||
216 | - | ||
217 | - | ||
218 | - | @Callable(i) | |
219 | - | func setManager (pendingManagerPublicKey) = { | |
220 | - | let checkCaller = mustManager(i) | |
221 | - | if ((checkCaller == checkCaller)) | |
222 | - | then { | |
223 | - | let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey) | |
224 | - | if ((checkManagerPublicKey == checkManagerPublicKey)) | |
225 | - | then [StringEntry(keyPendingManagerPublicKey(), pendingManagerPublicKey)] | |
226 | - | else throw("Strict value is not equal to itself.") | |
227 | - | } | |
228 | - | else throw("Strict value is not equal to itself.") | |
229 | - | } | |
230 | - | ||
231 | - | ||
232 | - | ||
233 | - | @Callable(i) | |
234 | - | func confirmManager () = { | |
235 | - | let pm = pendingManagerPublicKeyOrUnit() | |
236 | - | let hasPM = if (isDefined(pm)) | |
237 | - | then true | |
238 | - | else throw("no pending manager") | |
239 | - | if ((hasPM == hasPM)) | |
240 | - | then { | |
241 | - | let checkPM = if ((i.callerPublicKey == value(pm))) | |
242 | - | then true | |
243 | - | else throw("you are not pending manager") | |
244 | - | if ((checkPM == checkPM)) | |
245 | - | then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())] | |
246 | - | else throw("Strict value is not equal to itself.") | |
247 | 213 | } | |
248 | 214 | else throw("Strict value is not equal to itself.") | |
249 | 215 | } |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let SEP = "__" | |
5 | 5 | ||
6 | 6 | let feeScale = toBigInt(100000000) | |
7 | 7 | ||
8 | 8 | func getStringOrFail (key) = valueOrErrorMessage(getString(this, key), ("No data for this.key=" + key)) | |
9 | 9 | ||
10 | 10 | ||
11 | 11 | let poolDisabled = throw("Pool disabled") | |
12 | 12 | ||
13 | 13 | let poolNotExist = throw("Pool is not exist") | |
14 | 14 | ||
15 | 15 | let slippageTooBig = throw("Slippage is too big") | |
16 | 16 | ||
17 | 17 | func keyManagerPublicKey () = "%s__managerPublicKey" | |
18 | 18 | ||
19 | 19 | ||
20 | - | func | |
20 | + | func keyManagerVaultAddress () = "%s__managerVaultAddress" | |
21 | 21 | ||
22 | 22 | ||
23 | 23 | func fc () = "%s__factoryContract" | |
24 | 24 | ||
25 | 25 | ||
26 | 26 | let factoryContract = addressFromStringValue(getStringOrFail(fc())) | |
27 | 27 | ||
28 | 28 | func protocolFee () = makeString(["%s", "protocolFee"], SEP) | |
29 | 29 | ||
30 | 30 | ||
31 | 31 | func poolFee () = makeString(["%s", "poolFee"], SEP) | |
32 | 32 | ||
33 | 33 | ||
34 | 34 | func getStringOrFailFromAddress (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
35 | 35 | ||
36 | 36 | ||
37 | 37 | let keyFeeCollectorAddress = "%s__feeCollectorAddress" | |
38 | 38 | ||
39 | 39 | let feeCollectorAddress = addressFromStringValue(getStringOrFailFromAddress(factoryContract, keyFeeCollectorAddress)) | |
40 | 40 | ||
41 | + | func getManagerVaultAddressOrThis () = match getString(keyManagerVaultAddress()) { | |
42 | + | case s: String => | |
43 | + | addressFromStringValue(s) | |
44 | + | case _ => | |
45 | + | this | |
46 | + | } | |
47 | + | ||
48 | + | ||
41 | 49 | func asInt (val) = match val { | |
42 | 50 | case valInt: Int => | |
43 | 51 | valInt | |
44 | 52 | case _ => | |
45 | 53 | throw("fail to cast into Int") | |
46 | 54 | } | |
47 | 55 | ||
48 | 56 | ||
49 | 57 | func dataMappingPoolAssets (internalAmountAssetStr,internalPriceAssetStr) = makeString(["%d%d", toString(internalAmountAssetStr), toString(internalPriceAssetStr)], SEP) | |
50 | 58 | ||
51 | 59 | ||
52 | - | func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) { | |
53 | - | case s: String => | |
54 | - | fromBase58String(s) | |
55 | - | case _: Unit => | |
56 | - | unit | |
57 | - | case _ => | |
58 | - | throw("Match error") | |
59 | - | } | |
60 | - | ||
61 | - | ||
62 | - | func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) { | |
63 | - | case s: String => | |
64 | - | fromBase58String(s) | |
65 | - | case _: Unit => | |
66 | - | unit | |
67 | - | case _ => | |
68 | - | throw("Match error") | |
69 | - | } | |
60 | + | func managerPublicKeyOrUnit () = { | |
61 | + | let managerVaultAddress = getManagerVaultAddressOrThis() | |
62 | + | match getString(managerVaultAddress, keyManagerPublicKey()) { | |
63 | + | case s: String => | |
64 | + | fromBase58String(s) | |
65 | + | case _: Unit => | |
66 | + | unit | |
67 | + | case _ => | |
68 | + | throw("Match error") | |
69 | + | } | |
70 | + | } | |
70 | 71 | ||
71 | 72 | ||
72 | 73 | func isManager (i) = match managerPublicKeyOrUnit() { | |
73 | 74 | case pk: ByteVector => | |
74 | 75 | (i.callerPublicKey == pk) | |
75 | 76 | case _: Unit => | |
76 | 77 | (i.caller == this) | |
77 | 78 | case _ => | |
78 | 79 | throw("Match error") | |
79 | 80 | } | |
80 | 81 | ||
81 | 82 | ||
82 | 83 | func mustManager (i) = if (isManager(i)) | |
83 | 84 | then true | |
84 | 85 | else throw("permission denied") | |
85 | 86 | ||
86 | 87 | ||
87 | 88 | func getAccBalance (assetId) = if ((assetId == "WAVES")) | |
88 | 89 | then wavesBalance(this).available | |
89 | 90 | else assetBalance(this, fromBase58String(assetId)) | |
90 | 91 | ||
91 | 92 | ||
92 | 93 | func getPoolAddressAndCheckPoolStatus (assetIn,assetOut) = { | |
93 | 94 | let lpNonReverse = { | |
94 | 95 | let @ = invoke(factoryContract, "getLpAssetFromPoolAssetsREADONLY", [assetIn, assetOut], nil) | |
95 | 96 | if ($isInstanceOf(@, "String")) | |
96 | 97 | then @ | |
97 | 98 | else unit | |
98 | 99 | } | |
99 | 100 | let lpReverse = { | |
100 | 101 | let @ = invoke(factoryContract, "getLpAssetFromPoolAssetsREADONLY", [assetOut, assetIn], nil) | |
101 | 102 | if ($isInstanceOf(@, "String")) | |
102 | 103 | then @ | |
103 | 104 | else unit | |
104 | 105 | } | |
105 | - | let $ | |
106 | + | let $t026163075 = if ((lpNonReverse != unit)) | |
106 | 107 | then { | |
107 | 108 | let pool = { | |
108 | 109 | let @ = invoke(factoryContract, "getPoolAddressFromLpAssetREADONLY", [value(lpNonReverse)], nil) | |
109 | 110 | if ($isInstanceOf(@, "String")) | |
110 | 111 | then @ | |
111 | 112 | else throw(($getType(@) + " couldn't be cast to String")) | |
112 | 113 | } | |
113 | 114 | $Tuple2(false, pool) | |
114 | 115 | } | |
115 | 116 | else if ((lpReverse != unit)) | |
116 | 117 | then { | |
117 | 118 | let pool = { | |
118 | 119 | let @ = invoke(factoryContract, "getPoolAddressFromLpAssetREADONLY", [value(lpReverse)], nil) | |
119 | 120 | if ($isInstanceOf(@, "String")) | |
120 | 121 | then @ | |
121 | 122 | else throw(($getType(@) + " couldn't be cast to String")) | |
122 | 123 | } | |
123 | 124 | $Tuple2(true, pool) | |
124 | 125 | } | |
125 | 126 | else poolNotExist | |
126 | - | let isReverse = $ | |
127 | - | let pool = $ | |
127 | + | let isReverse = $t026163075._1 | |
128 | + | let pool = $t026163075._2 | |
128 | 129 | let poolStatus = { | |
129 | 130 | let @ = invoke(factoryContract, "getPoolStatusREADONLY", [pool], nil) | |
130 | 131 | if ($isInstanceOf(@, "Int")) | |
131 | 132 | then @ | |
132 | 133 | else throw(($getType(@) + " couldn't be cast to Int")) | |
133 | 134 | } | |
134 | 135 | let check = if ((poolStatus == 1)) | |
135 | 136 | then true | |
136 | 137 | else poolDisabled | |
137 | 138 | if ((check == check)) | |
138 | 139 | then { | |
139 | 140 | let poolAdr = addressFromStringValue(valueOrElse(pool, "")) | |
140 | 141 | $Tuple2(poolAdr, isReverse) | |
141 | 142 | } | |
142 | 143 | else throw("Strict value is not equal to itself.") | |
143 | 144 | } | |
144 | 145 | ||
145 | 146 | ||
146 | 147 | @Callable(i) | |
147 | 148 | func swapCalculateREADONLY (amountIn,assetIn,assetOut) = { | |
148 | 149 | let prFee = value(getInteger(protocolFee())) | |
149 | 150 | let feeProtocolAmountCalc = fraction(toBigInt(amountIn), toBigInt(prFee), feeScale) | |
150 | 151 | let plFee = value(getInteger(poolFee())) | |
151 | 152 | let feePoolAmountCalc = fraction(toBigInt(amountIn), toBigInt(plFee), feeScale) | |
152 | 153 | let feeProtocolAmount = if ((toInt(feeProtocolAmountCalc) == 0)) | |
153 | 154 | then toBigInt(1) | |
154 | 155 | else feeProtocolAmountCalc | |
155 | 156 | let feePoolAmount = if ((toInt(feePoolAmountCalc) == 0)) | |
156 | 157 | then toBigInt(1) | |
157 | 158 | else feePoolAmountCalc | |
158 | 159 | let cleanAmountIn = ((toBigInt(amountIn) - feeProtocolAmount) - feePoolAmount) | |
159 | - | let $ | |
160 | - | let poolAdr = $ | |
161 | - | let isReverse = $ | |
160 | + | let $t040634141 = getPoolAddressAndCheckPoolStatus(assetIn, assetOut) | |
161 | + | let poolAdr = $t040634141._1 | |
162 | + | let isReverse = $t040634141._2 | |
162 | 163 | let res = { | |
163 | 164 | let @ = invoke(poolAdr, "calculateAmountOutForSwapREADONLY", [toInt(cleanAmountIn), isReverse, toInt(feePoolAmount)], nil) | |
164 | 165 | if ($isInstanceOf(@, "Int")) | |
165 | 166 | then @ | |
166 | 167 | else throw(($getType(@) + " couldn't be cast to Int")) | |
167 | 168 | } | |
168 | 169 | $Tuple2(nil, res) | |
169 | 170 | } | |
170 | 171 | ||
171 | 172 | ||
172 | 173 | ||
173 | 174 | @Callable(i) | |
174 | 175 | func swap (amountOutMin,assetOutRaw,addressTo) = { | |
175 | 176 | let assetOut = if ((assetOutRaw == "")) | |
176 | 177 | then "WAVES" | |
177 | 178 | else assetOutRaw | |
178 | 179 | let pmt = value(i.payments[0]) | |
179 | 180 | let assetIn = if ((pmt.assetId == unit)) | |
180 | 181 | then "WAVES" | |
181 | 182 | else toBase58String(value(pmt.assetId)) | |
182 | 183 | let amountIn = value(pmt.amount) | |
183 | 184 | let prFee = value(getInteger(protocolFee())) | |
184 | 185 | let feeProtocolAmountCalc = fraction(toBigInt(amountIn), toBigInt(prFee), feeScale) | |
185 | 186 | let plFee = value(getInteger(poolFee())) | |
186 | 187 | let feePoolAmountCalc = fraction(toBigInt(amountIn), toBigInt(plFee), feeScale) | |
187 | 188 | let feeProtocolAmount = if ((toInt(feeProtocolAmountCalc) == 0)) | |
188 | 189 | then toBigInt(1) | |
189 | 190 | else feeProtocolAmountCalc | |
190 | 191 | let feePoolAmount = if ((toInt(feePoolAmountCalc) == 0)) | |
191 | 192 | then toBigInt(1) | |
192 | 193 | else feePoolAmountCalc | |
193 | 194 | let cleanAmountIn = ((toBigInt(amountIn) - feeProtocolAmount) - feePoolAmount) | |
194 | 195 | let checks = [if ((size(i.payments) == 1)) | |
195 | 196 | then true | |
196 | 197 | else throw("exactly 1 payment are expected")] | |
197 | 198 | if ((checks == checks)) | |
198 | 199 | then { | |
199 | - | let $ | |
200 | - | let poolAdr = $ | |
201 | - | let isReverse = $ | |
200 | + | let $t053435421 = getPoolAddressAndCheckPoolStatus(assetIn, assetOut) | |
201 | + | let poolAdr = $t053435421._1 | |
202 | + | let isReverse = $t053435421._2 | |
202 | 203 | let assetInAttachedPayment = if ((assetIn == "WAVES")) | |
203 | 204 | then unit | |
204 | 205 | else fromBase58String(assetIn) | |
205 | 206 | let totalGetRaw = { | |
206 | 207 | let @ = invoke(poolAdr, "calculateAmountOutForSwapAndSendTokens", [toInt(cleanAmountIn), isReverse, amountOutMin, addressTo, toInt(feePoolAmount)], [AttachedPayment(assetInAttachedPayment, toInt(cleanAmountIn))]) | |
207 | 208 | if ($isInstanceOf(@, "Int")) | |
208 | 209 | then @ | |
209 | 210 | else throw(($getType(@) + " couldn't be cast to Int")) | |
210 | 211 | } | |
211 | 212 | $Tuple2([ScriptTransfer(feeCollectorAddress, toInt(feeProtocolAmount), assetInAttachedPayment), ScriptTransfer(poolAdr, toInt(feePoolAmount), assetInAttachedPayment)], totalGetRaw) | |
212 | - | } | |
213 | - | else throw("Strict value is not equal to itself.") | |
214 | - | } | |
215 | - | ||
216 | - | ||
217 | - | ||
218 | - | @Callable(i) | |
219 | - | func setManager (pendingManagerPublicKey) = { | |
220 | - | let checkCaller = mustManager(i) | |
221 | - | if ((checkCaller == checkCaller)) | |
222 | - | then { | |
223 | - | let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey) | |
224 | - | if ((checkManagerPublicKey == checkManagerPublicKey)) | |
225 | - | then [StringEntry(keyPendingManagerPublicKey(), pendingManagerPublicKey)] | |
226 | - | else throw("Strict value is not equal to itself.") | |
227 | - | } | |
228 | - | else throw("Strict value is not equal to itself.") | |
229 | - | } | |
230 | - | ||
231 | - | ||
232 | - | ||
233 | - | @Callable(i) | |
234 | - | func confirmManager () = { | |
235 | - | let pm = pendingManagerPublicKeyOrUnit() | |
236 | - | let hasPM = if (isDefined(pm)) | |
237 | - | then true | |
238 | - | else throw("no pending manager") | |
239 | - | if ((hasPM == hasPM)) | |
240 | - | then { | |
241 | - | let checkPM = if ((i.callerPublicKey == value(pm))) | |
242 | - | then true | |
243 | - | else throw("you are not pending manager") | |
244 | - | if ((checkPM == checkPM)) | |
245 | - | then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())] | |
246 | - | else throw("Strict value is not equal to itself.") | |
247 | 213 | } | |
248 | 214 | else throw("Strict value is not equal to itself.") | |
249 | 215 | } | |
250 | 216 | ||
251 | 217 | ||
252 | 218 | @Verifier(tx) | |
253 | 219 | func verify () = { | |
254 | 220 | let targetPublicKey = match managerPublicKeyOrUnit() { | |
255 | 221 | case pk: ByteVector => | |
256 | 222 | pk | |
257 | 223 | case _: Unit => | |
258 | 224 | tx.senderPublicKey | |
259 | 225 | case _ => | |
260 | 226 | throw("Match error") | |
261 | 227 | } | |
262 | 228 | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
263 | 229 | } | |
264 | 230 |
github/deemru/w8io/169f3d6 37.03 ms ◑