tx · 2cxeufEfDo26pBgDD9H1zWupNDqKM3WmKUifJBjbPUup 3N3KwUURbhUVm8HEKKHNNFT9jV5f7cMF61k: -0.01000000 Waves 2023.10.24 15:54 [2812732] smart account 3N3KwUURbhUVm8HEKKHNNFT9jV5f7cMF61k > SELF 0.00000000 Waves
{ "type": 13, "id": "2cxeufEfDo26pBgDD9H1zWupNDqKM3WmKUifJBjbPUup", "fee": 1000000, "feeAssetId": null, "timestamp": 1698152073228, "version": 2, "chainId": 84, "sender": "3N3KwUURbhUVm8HEKKHNNFT9jV5f7cMF61k", "senderPublicKey": "8dMNP9AZeA56P1ySRwbKMmQFV5aYcYkujW312HQJP2ed", "proofs": [ "E1dmXHgUPRmhmsPZbaJR5pCvZNFKiJS4PyySfjUQEpAmjt318wv1UnPYXCEbWxWP16pEgtUQo68LudhhrKkZAPR" ], "script": "base64:BgITCAISBQoDCBgYEggKBggBAQgIASIACVNFUEFSQVRPUgICX18ABVdBVkVTAgV3YXZlcwANSU5ERVhfTElTVF8xMAkAzAgCAAAJAMwIAgABCQDMCAIAAgkAzAgCAAMJAMwIAgAECQDMCAIABQkAzAgCAAYJAMwIAgAHCQDMCAIACAkAzAgCAAkFA25pbAAMS0VZX01VTFRJU0lHAghNVUxUSVNJRwAKS0VZX1NUQVRVUwIGU1RBVFVTAAhLRVlfSU5JVAIESU5JVAAcS0VZX0NST1NTQ0hBSU5fU1dBUF9DT05UUkFDVAIYQ1JPU1NDSEFJTl9TV0FQX0NPTlRSQUNUABNLRVlfQlJJREdFX0NPTlRSQUNUAg9CUklER0VfQ09OVFJBQ1QACktFWV9BU1NFVFMCBkFTU0VUUwANRlVOQ19XSVRIRFJBVwIId2l0aGRyYXcAEEZVTkNfQlVSTl9UT0tFTlMCDGJ1cm5Ub2tlbnNWMgEQX3ZhbGlkYXRlQWRkcmVzcwIIYWRkcmVzc18EZXJyXwQHJG1hdGNoMAkApggBBQhhZGRyZXNzXwMJAAECBQckbWF0Y2gwAgdBZGRyZXNzBA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Full:
Old | New | Differences | |
---|---|---|---|
1 | - | {-# STDLIB_VERSION | |
1 | + | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 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_)]) | |
4 | 200 | ||
5 | 201 | ||
6 | 202 | @Callable(i) | |
7 | - | func call () = { | |
8 | - | let asset = Issue("Asset", "", 1, 0, true, unit, 0) | |
9 | - | let assetId = calculateAssetId(asset) | |
10 | - | [BinaryEntry("bin", base58''), BooleanEntry("bool", true), IntegerEntry("int", 1), StringEntry("str", ""), DeleteEntry("str"), asset, Reissue(assetId, 1, false), Burn(assetId, 1), ScriptTransfer(i.caller, 1, assetId)] | |
203 | + | func init (crosschainSwapContract_,assetIds_,bridgeContracts_) = { | |
204 | + | let err = if (if (if (if (if (_onlyThisContract(i.caller)) | |
205 | + | then _whenNotInitialized() | |
206 | + | else false) | |
207 | + | then _validateAddress(crosschainSwapContract_, "init: invalid crosschainSwapContract") | |
208 | + | else false) | |
209 | + | then _validateIntEquals(size(bridgeContracts_), size(assetIds_), "init: invalid arr length") | |
210 | + | else false) | |
211 | + | then _validateAssets(assetIds_, "init: invalid assetIds") | |
212 | + | else false) | |
213 | + | then _validateAddresses(bridgeContracts_, "init: invalid bridgeContracts") | |
214 | + | else false | |
215 | + | if ((err == err)) | |
216 | + | then $Tuple2(((_saveInit(true) ++ _saveCrosschainSwapContract(addressFromStringValue(crosschainSwapContract_))) ++ _saveBridgeContracts(assetIds_, bridgeContracts_)), unit) | |
217 | + | else throw("Strict value is not equal to itself.") | |
218 | + | } | |
219 | + | ||
220 | + | ||
221 | + | ||
222 | + | @Callable(i) | |
223 | + | func withdraw (targetAssetId_,minTargetAmount_,executionChainId_,recipient_,referrer_,gaslessReward_) = { | |
224 | + | let err = if (if (_whenInitialized()) | |
225 | + | then _validateIntEquals(size(i.payments), 1, "withdraw: incorrect payment") | |
226 | + | else false) | |
227 | + | then _validateListContains(_getAssets(), targetAssetId_, "withdraw: invalid target asset") | |
228 | + | else false | |
229 | + | if ((err == err)) | |
230 | + | then { | |
231 | + | let targetAsset = fromBase58String(targetAssetId_) | |
232 | + | let balanceBefore = assetBalance(this, targetAsset) | |
233 | + | if ((balanceBefore == balanceBefore)) | |
234 | + | then { | |
235 | + | let result1 = _invokeWithdraw(valueOrErrorMessage(i.payments[0].assetId, "withdraw: no payment asset"), i.payments[0].amount, targetAssetId_, minTargetAmount_) | |
236 | + | if ((result1 == result1)) | |
237 | + | then { | |
238 | + | let balance = (assetBalance(this, targetAsset) - balanceBefore) | |
239 | + | let result2 = _invokeBurnTokens(targetAsset, balance, executionChainId_, recipient_, referrer_, gaslessReward_) | |
240 | + | if ((result2 == result2)) | |
241 | + | then $Tuple2(nil, unit) | |
242 | + | else throw("Strict value is not equal to itself.") | |
243 | + | } | |
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.") | |
11 | 249 | } | |
12 | 250 | ||
13 | 251 | ||
14 | 252 | @Verifier(tx) | |
15 | - | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
253 | + | func verify () = match getString(KEY_MULTISIG) { | |
254 | + | case multisig: String => | |
255 | + | valueOrElse(getBoolean(addressFromStringValue(multisig), makeString([KEY_STATUS, toString(this), toBase58String(tx.id)], SEPARATOR)), false) | |
256 | + | case _ => | |
257 | + | sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
258 | + | } | |
16 | 259 |
github/deemru/w8io/169f3d6 31.71 ms ◑