tx · BvNwgwS3jEHUgi2xvESfPiMeXYCt9gn1KA8fg2UrLhie 3MtAXTWSXS6t1NBYfKhknbkN9wR6VuE3Q99: -0.01100000 Waves 2023.11.02 17:27 [2825834] smart account 3MtAXTWSXS6t1NBYfKhknbkN9wR6VuE3Q99 > SELF 0.00000000 Waves
{ "type": 13, "id": "BvNwgwS3jEHUgi2xvESfPiMeXYCt9gn1KA8fg2UrLhie", "fee": 1100000, "feeAssetId": null, "timestamp": 1698935262522, "version": 2, "chainId": 84, "sender": "3MtAXTWSXS6t1NBYfKhknbkN9wR6VuE3Q99", "senderPublicKey": "EsiNjdPTvu9JAqnvZqo1pYZ2kj4F9rcDKc8KET7zRzR", "proofs": [ "5S3mxKXgdanG4hjfZmyzo95dKa34tWFRU8nCMZ11GwpTBB2JwC3DsscfS6B2uNK3PrHmmcA2JV6MZ6LQUtwcKJ69" ], "script": "base64:BgIYCAISBQoDCBgYEggKBggBAQgIARIDCgEIIgAJU0VQQVJBVE9SAgJfXwAFV0FWRVMCBXdhdmVzAA1JTkRFWF9MSVNUXzEwCQDMCAIAAAkAzAgCAAEJAMwIAgACCQDMCAIAAwkAzAgCAAQJAMwIAgAFCQDMCAIABgkAzAgCAAcJAMwIAgAICQDMCAIACQUDbmlsAAxLRVlfTVVMVElTSUcCCE1VTFRJU0lHAApLRVlfU1RBVFVTAgZTVEFUVVMACEtFWV9JTklUAgRJTklUABxLRVlfQ1JPU1NDSEFJTl9TV0FQX0NPTlRSQUNUAhhDUk9TU0NIQUlOX1NXQVBfQ09OVFJBQ1QAE0tFWV9CUklER0VfQ09OVFJBQ1QCD0JSSURHRV9DT05UUkFDVAAKS0VZX0FTU0VUUwIGQVNTRVRTAA1GVU5DX1dJVEhEUkFXAgh3aXRoZHJhdwAQRlVOQ19CVVJOX1RPS0VOUwIMYnVyblRva2Vuc1YyARBfdmFsaWRhdGVBZGRyZXNzAghhZGRyZXNzXwRlcnJfBAckbWF0Y2gwCQCmCAEFCGFkZHJlc3NfAw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lN0cmluZwQIbXVsdGlzaWcFByRtYXRjaDAJAQt2YWx1ZU9yRWxzZQIJAJsIAgkBEUBleHRyTmF0aXZlKDEwNjIpAQUIbXVsdGlzaWcJALkJAgkAzAgCBQpLRVlfU1RBVFVTCQDMCAIJAKUIAQUEdGhpcwkAzAgCCQDYBAEIBQJ0eAJpZAUDbmlsBQlTRVBBUkFUT1IHCQD0AwMIBQJ0eAlib2R5Qnl0ZXMJAJEDAggFAnR4BnByb29mcwAACAUCdHgPc2VuZGVyUHVibGljS2V54k1xwg==", "height": 2825834, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: none Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 6 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let SEPARATOR = "__" | |
5 | + | ||
6 | + | let WAVES = "waves" | |
7 | + | ||
8 | + | let INDEX_LIST_10 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] | |
9 | + | ||
10 | + | let KEY_MULTISIG = "MULTISIG" | |
11 | + | ||
12 | + | let KEY_STATUS = "STATUS" | |
13 | + | ||
14 | + | let KEY_INIT = "INIT" | |
15 | + | ||
16 | + | let KEY_CROSSCHAIN_SWAP_CONTRACT = "CROSSCHAIN_SWAP_CONTRACT" | |
17 | + | ||
18 | + | let KEY_BRIDGE_CONTRACT = "BRIDGE_CONTRACT" | |
19 | + | ||
20 | + | let KEY_ASSETS = "ASSETS" | |
21 | + | ||
22 | + | let FUNC_WITHDRAW = "withdraw" | |
23 | + | ||
24 | + | let FUNC_BURN_TOKENS = "burnTokensV2" | |
25 | + | ||
26 | + | func _validateAddress (address_,err_) = match addressFromString(address_) { | |
27 | + | case a: Address => | |
28 | + | true | |
29 | + | case _ => | |
30 | + | throw(err_) | |
31 | + | } | |
32 | + | ||
33 | + | ||
34 | + | func _validateAsset (assetId_,err_) = if ((assetId_ == WAVES)) | |
35 | + | then true | |
36 | + | else match assetInfo(fromBase58String(assetId_)) { | |
37 | + | case a: Asset => | |
38 | + | true | |
39 | + | case _ => | |
40 | + | throw(err_) | |
41 | + | } | |
42 | + | ||
43 | + | ||
44 | + | func _validateInt (val_,lowerBoundary_,upperBoundary_,err_) = if (if ((lowerBoundary_ > val_)) | |
45 | + | then true | |
46 | + | else (val_ > upperBoundary_)) | |
47 | + | then throw(err_) | |
48 | + | else true | |
49 | + | ||
50 | + | ||
51 | + | func _validateIntEquals (val1_,val2_,err_) = if ((val1_ != val2_)) | |
52 | + | then throw(err_) | |
53 | + | else true | |
54 | + | ||
55 | + | ||
56 | + | func _validateAddresses (addresses_,err_) = { | |
57 | + | func foldFunc (acc,elem) = if (acc) | |
58 | + | then _validateAddress(elem, err_) | |
59 | + | else false | |
60 | + | ||
61 | + | let $l = addresses_ | |
62 | + | let $s = size($l) | |
63 | + | let $acc0 = true | |
64 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
65 | + | then $a | |
66 | + | else foldFunc($a, $l[$i]) | |
67 | + | ||
68 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
69 | + | then $a | |
70 | + | else throw("List size exceeds 10") | |
71 | + | ||
72 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
73 | + | } | |
74 | + | ||
75 | + | ||
76 | + | func _validateAssets (assets_,err_) = { | |
77 | + | func foldFunc (acc,elem) = if (acc) | |
78 | + | then _validateAsset(elem, err_) | |
79 | + | else false | |
80 | + | ||
81 | + | let $l = assets_ | |
82 | + | let $s = size($l) | |
83 | + | let $acc0 = true | |
84 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
85 | + | then $a | |
86 | + | else foldFunc($a, $l[$i]) | |
87 | + | ||
88 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
89 | + | then $a | |
90 | + | else throw("List size exceeds 10") | |
91 | + | ||
92 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
93 | + | } | |
94 | + | ||
95 | + | ||
96 | + | func _validateListContains (list_,val_,err_) = if (!(containsElement(list_, val_))) | |
97 | + | then throw(err_) | |
98 | + | else true | |
99 | + | ||
100 | + | ||
101 | + | func _loadInit () = match getBoolean(KEY_INIT) { | |
102 | + | case a: Boolean => | |
103 | + | a | |
104 | + | case _ => | |
105 | + | false | |
106 | + | } | |
107 | + | ||
108 | + | ||
109 | + | func _saveInit (val_) = [BooleanEntry(KEY_INIT, val_)] | |
110 | + | ||
111 | + | ||
112 | + | func _loadMultisig () = match getString(KEY_MULTISIG) { | |
113 | + | case a: String => | |
114 | + | addressFromStringValue(a) | |
115 | + | case _ => | |
116 | + | Address(base58'') | |
117 | + | } | |
118 | + | ||
119 | + | ||
120 | + | func _saveMultisig (multisig_) = [StringEntry(KEY_MULTISIG, toString(multisig_))] | |
121 | + | ||
122 | + | ||
123 | + | func _loadCrosschainSwapContract () = match getString(KEY_CROSSCHAIN_SWAP_CONTRACT) { | |
124 | + | case a: String => | |
125 | + | addressFromStringValue(a) | |
126 | + | case _ => | |
127 | + | Address(base58'') | |
128 | + | } | |
129 | + | ||
130 | + | ||
131 | + | func _saveCrosschainSwapContract (contract_) = [StringEntry(KEY_CROSSCHAIN_SWAP_CONTRACT, toString(contract_))] | |
132 | + | ||
133 | + | ||
134 | + | func _loadBridgeContract (assetId_) = match getString(makeString([KEY_BRIDGE_CONTRACT, assetId_], SEPARATOR)) { | |
135 | + | case a: String => | |
136 | + | addressFromStringValue(a) | |
137 | + | case _ => | |
138 | + | Address(base58'') | |
139 | + | } | |
140 | + | ||
141 | + | ||
142 | + | func _saveBridgeContract (assetId_,contract_) = [StringEntry(makeString([KEY_BRIDGE_CONTRACT, assetId_], SEPARATOR), toString(contract_))] | |
143 | + | ||
144 | + | ||
145 | + | func _saveBridgeContracts (assetIds_,bridgeContracts_) = { | |
146 | + | let maxSize = size(assetIds_) | |
147 | + | func foldFunc (acc,index) = if ((index >= maxSize)) | |
148 | + | then acc | |
149 | + | else (acc ++ _saveBridgeContract(assetIds_[index], addressFromStringValue(bridgeContracts_[index]))) | |
150 | + | ||
151 | + | let $l = INDEX_LIST_10 | |
152 | + | let $s = size($l) | |
153 | + | let $acc0 = nil | |
154 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
155 | + | then $a | |
156 | + | else foldFunc($a, $l[$i]) | |
157 | + | ||
158 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
159 | + | then $a | |
160 | + | else throw("List size exceeds 10") | |
161 | + | ||
162 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
163 | + | } | |
164 | + | ||
165 | + | ||
166 | + | func _onlyThisContract (caller_) = if ((caller_ != this)) | |
167 | + | then throw("_onlyThisContract: revert") | |
168 | + | else true | |
169 | + | ||
170 | + | ||
171 | + | func _whenMultisigSet () = if ((_loadMultisig() == Address(base58''))) | |
172 | + | then throw("_whenMultisigSet: revert") | |
173 | + | else true | |
174 | + | ||
175 | + | ||
176 | + | func _whenNotInitialized () = if (_loadInit()) | |
177 | + | then throw("_whenNotInitialized: revert") | |
178 | + | else true | |
179 | + | ||
180 | + | ||
181 | + | func _whenInitialized () = if (!(_loadInit())) | |
182 | + | then throw("_whenInitialized: revert") | |
183 | + | else true | |
184 | + | ||
185 | + | ||
186 | + | func _getAssets () = match getString(_loadCrosschainSwapContract(), KEY_ASSETS) { | |
187 | + | case a: String => | |
188 | + | if ((size(a) > 0)) | |
189 | + | then split_51C(a, SEPARATOR) | |
190 | + | else nil | |
191 | + | case _ => | |
192 | + | nil | |
193 | + | } | |
194 | + | ||
195 | + | ||
196 | + | func _invokeWithdraw (sourceAssetId_,sourceAmount_,targetAssetId_,minTargetAmount_) = invoke(_loadCrosschainSwapContract(), FUNC_WITHDRAW, [targetAssetId_, minTargetAmount_], [AttachedPayment(sourceAssetId_, sourceAmount_)]) | |
197 | + | ||
198 | + | ||
199 | + | func _invokeBurnTokens (sourceAssetId_,sourceAmount_,executionChainId_,recipient_,referrer_,gaslessReward_) = invoke(_loadBridgeContract(toBase58String(sourceAssetId_)), FUNC_BURN_TOKENS, [executionChainId_, recipient_, referrer_, gaslessReward_], [AttachedPayment(sourceAssetId_, sourceAmount_)]) | |
200 | + | ||
201 | + | ||
202 | + | @Callable(i) | |
203 | + | func init (crosschainSwapContract_,assetIds_,bridgeContracts_) = { | |
204 | + | let err = if (if (if (if (if (if (_onlyThisContract(i.caller)) | |
205 | + | then _whenNotInitialized() | |
206 | + | else false) | |
207 | + | then _whenMultisigSet() | |
208 | + | else false) | |
209 | + | then _validateAddress(crosschainSwapContract_, "init: invalid crosschainSwapContract") | |
210 | + | else false) | |
211 | + | then _validateIntEquals(size(bridgeContracts_), size(assetIds_), "init: invalid arr length") | |
212 | + | else false) | |
213 | + | then _validateAssets(assetIds_, "init: invalid assetIds") | |
214 | + | else false) | |
215 | + | then _validateAddresses(bridgeContracts_, "init: invalid bridgeContracts") | |
216 | + | else false | |
217 | + | if ((err == err)) | |
218 | + | then $Tuple2(((_saveInit(true) ++ _saveCrosschainSwapContract(addressFromStringValue(crosschainSwapContract_))) ++ _saveBridgeContracts(assetIds_, bridgeContracts_)), unit) | |
219 | + | else throw("Strict value is not equal to itself.") | |
220 | + | } | |
221 | + | ||
222 | + | ||
223 | + | ||
224 | + | @Callable(i) | |
225 | + | func withdraw (targetAssetId_,minTargetAmount_,executionChainId_,recipient_,referrer_,gaslessReward_) = { | |
226 | + | let err = if (if (_whenInitialized()) | |
227 | + | then _validateIntEquals(size(i.payments), 1, "withdraw: incorrect payment") | |
228 | + | else false) | |
229 | + | then _validateListContains(_getAssets(), targetAssetId_, "withdraw: invalid target asset") | |
230 | + | else false | |
231 | + | if ((err == err)) | |
232 | + | then { | |
233 | + | let targetAsset = fromBase58String(targetAssetId_) | |
234 | + | let balanceBefore = assetBalance(this, targetAsset) | |
235 | + | if ((balanceBefore == balanceBefore)) | |
236 | + | then { | |
237 | + | let result1 = _invokeWithdraw(valueOrErrorMessage(i.payments[0].assetId, "withdraw: no payment asset"), i.payments[0].amount, targetAssetId_, minTargetAmount_) | |
238 | + | if ((result1 == result1)) | |
239 | + | then { | |
240 | + | let balance = (assetBalance(this, targetAsset) - balanceBefore) | |
241 | + | let result2 = _invokeBurnTokens(targetAsset, balance, executionChainId_, recipient_, referrer_, gaslessReward_) | |
242 | + | if ((result2 == result2)) | |
243 | + | then $Tuple2(nil, unit) | |
244 | + | else throw("Strict value is not equal to itself.") | |
245 | + | } | |
246 | + | else throw("Strict value is not equal to itself.") | |
247 | + | } | |
248 | + | else throw("Strict value is not equal to itself.") | |
249 | + | } | |
250 | + | else throw("Strict value is not equal to itself.") | |
251 | + | } | |
252 | + | ||
253 | + | ||
254 | + | ||
255 | + | @Callable(i) | |
256 | + | func setMultisig (multisig_) = { | |
257 | + | let err = if (_onlyThisContract(i.caller)) | |
258 | + | then _validateAddress(multisig_, "setMultisig: invalid multisig") | |
259 | + | else false | |
260 | + | if ((err == err)) | |
261 | + | then $Tuple2(_saveMultisig(addressFromStringValue(multisig_)), unit) | |
262 | + | else throw("Strict value is not equal to itself.") | |
263 | + | } | |
264 | + | ||
265 | + | ||
266 | + | @Verifier(tx) | |
267 | + | func verify () = match getString(KEY_MULTISIG) { | |
268 | + | case multisig: String => | |
269 | + | valueOrElse(getBoolean(addressFromStringValue(multisig), makeString([KEY_STATUS, toString(this), toBase58String(tx.id)], SEPARATOR)), false) | |
270 | + | case _ => | |
271 | + | sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
272 | + | } | |
273 | + |
github/deemru/w8io/026f985 19.28 ms ◑