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