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