tx · BaZxw7bLZWbahEXoQFFcwySNApzY3t3msNy36935wLeF 3N935A8AAp2u1isbYYqX3Kp9prZmHF6kNps: -0.01400000 Waves 2023.03.14 17:42 [2489852] smart account 3N935A8AAp2u1isbYYqX3Kp9prZmHF6kNps > SELF 0.00000000 Waves
{ "type": 13, "id": "BaZxw7bLZWbahEXoQFFcwySNApzY3t3msNy36935wLeF", "fee": 1400000, "feeAssetId": null, "timestamp": 1678804883277, "version": 2, "chainId": 84, "sender": "3N935A8AAp2u1isbYYqX3Kp9prZmHF6kNps", "senderPublicKey": "AV1pqMh4X8GxWM1ZonBqM9qXi5moX8jeAvDDkpaCxQq5", "proofs": [ "4WsHbjn4APkG5TAVLCPNtvjSrRU6rd3ZfnAsJ5T5tRnZRDxQWJqKcaUMa51rosDottwxh2j3NKweWBr4PTqmKyey" ], "script": "base64:BgIqCAISBQoDCAEIEgoKCAgIGAEBAQgIEgUKAwgICBIAEgASAwoBCBIDCgEIIgAJU0VQQVJBVE9SAgJfXwAIS0VZX0lOSVQCBElOSVQADEtFWV9NVUxUSVNJRwIITVVMVElTSUcACktFWV9TVEFUVVMCBlNUQVRVUwAKS0VZX1BBVVNFRAIGUEFVU0VEAApLRVlfUEFVU0VSAgZQQVVTRVIADEtFWV9DSEFJTl9JRAIIQ0hBSU5fSUQAFUtFWV9TSUdORVJfUFVCTElDX0tFWQIRU0lHTkVSX1BVQkxJQ19LRVkADUtFWV9EQVRBX0hBU0gCCURBVEFfSEFTSAAHTUFYX0lOVAD//////////38BEF92YWxpZGF0ZUFkZHJlc3MCCGFkZHJlc3NfBGVycl8EByRtYXRjaDAJAKYIAQUIYWRkcmVzc18DCQABAgUHJG1hdGNoMAIHQWRkcmVzcwQBYQUHJG1hdGNoMAYJAAIBBQRlcnJfARJfdmFsaWRhdGVQdWJsaWNLZXkCCnB1YmxpY0tleV8EZXJyXwMJAQIhPQIJAMgBAQkA2QQBBQpwdWJsaWNLZXlfACAJAAIBBQRlcnJfBgEMX3ZhbG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BANlcnIDCQERX29ubHlUaGlzQ29udHJhY3QBCAUBaQZjYWxsZXIJARBfdmFsaWRhdGVBZGRyZXNzAgUJbXVsdGlzaWdfAiVzZXRNdWx0aXNpZzogaW52YWxpZCBtdWx0aXNpZyBhZGRyZXNzBwMJAAACBQNlcnIFA2VycgkAlAoCCQENX3NhdmVNdWx0aXNpZwEJARFAZXh0ck5hdGl2ZSgxMDYyKQEFCW11bHRpc2lnXwUEdW5pdAkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgECdHgBBnZlcmlmeQAEByRtYXRjaDAJAKIIAQUMS0VZX01VTFRJU0lHAwkAAQIFByRtYXRjaDACBlN0cmluZwQIbXVsdGlzaWcFByRtYXRjaDAJAQt2YWx1ZU9yRWxzZQIJAJsIAgkBEUBleHRyTmF0aXZlKDEwNjIpAQUIbXVsdGlzaWcJALkJAgkAzAgCBQpLRVlfU1RBVFVTCQDMCAIJAKUIAQUEdGhpcwkAzAgCCQDYBAEIBQJ0eAJpZAUDbmlsBQlTRVBBUkFUT1IHCQD0AwMIBQJ0eAlib2R5Qnl0ZXMJAJEDAggFAnR4BnByb29mcwAACAUCdHgPc2VuZGVyUHVibGljS2V5pavHcw==", "height": 2489852, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 58YnAiCMipdPPEx2iZoHuyEpxYnzTpiFVPxMm5xtLS3t Next: none Diff:
Old | New | Differences | |
---|---|---|---|
175 | 175 | ||
176 | 176 | @Callable(i) | |
177 | 177 | func execute (contract_,functionName_,functionArgs_,callerChainId_,executionChainId_,nonce_,txHash_,signature_) = { | |
178 | - | let err = if (if (if (_whenInitialized()) | |
178 | + | let argsSize = size(functionArgs_) | |
179 | + | let err = if (if (if (if (_whenInitialized()) | |
179 | 180 | then _whenNotPaused() | |
180 | 181 | else false) | |
181 | 182 | then _validateAddress(contract_, "execute: invalid contract") | |
183 | + | else false) | |
184 | + | then _validateInt(argsSize, 0, 22, "execute: invalid args size") | |
182 | 185 | else false) | |
183 | 186 | then if ((_loadChainId() != executionChainId_)) | |
184 | 187 | then throw("execute: invalid execution chain id") | |
186 | 189 | else false | |
187 | 190 | if ((err == err)) | |
188 | 191 | then { | |
189 | - | func foldFunc (acc,elem) = (acc + toBytes(elem)) | |
192 | + | func foldFunc (acc,elem) = ((acc + toBytes(size(elem))) + toBytes(elem)) | |
190 | 193 | ||
191 | 194 | let argsBytes = { | |
192 | 195 | let $l = functionArgs_ | |
202 | 205 | ||
203 | 206 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($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), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20), 21), 22) | |
204 | 207 | } | |
205 | - | let data = ((((((toBytes(callerChainId_) + toBytes(executionChainId_)) + toBytes(nonce_)) + toBytes(txHash_)) + fromBase58String(contract_)) + toBytes(functionName_)) + argsBytes) | |
208 | + | let data = (((((((((toBytes(callerChainId_) + toBytes(executionChainId_)) + toBytes(nonce_)) + toBytes(size(txHash_))) + toBytes(txHash_)) + fromBase58String(contract_)) + toBytes(size(functionName_))) + toBytes(functionName_)) + toBytes(argsSize)) + argsBytes) | |
206 | 209 | let dataHash = keccak256_32Kb(data) | |
207 | 210 | let err1 = if (!(sigVerify(dataHash, fromBase58String(signature_), _loadSignerPublicKey()))) | |
208 | 211 | then throw("execute: invalid signature") |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let SEPARATOR = "__" | |
5 | 5 | ||
6 | 6 | let KEY_INIT = "INIT" | |
7 | 7 | ||
8 | 8 | let KEY_MULTISIG = "MULTISIG" | |
9 | 9 | ||
10 | 10 | let KEY_STATUS = "STATUS" | |
11 | 11 | ||
12 | 12 | let KEY_PAUSED = "PAUSED" | |
13 | 13 | ||
14 | 14 | let KEY_PAUSER = "PAUSER" | |
15 | 15 | ||
16 | 16 | let KEY_CHAIN_ID = "CHAIN_ID" | |
17 | 17 | ||
18 | 18 | let KEY_SIGNER_PUBLIC_KEY = "SIGNER_PUBLIC_KEY" | |
19 | 19 | ||
20 | 20 | let KEY_DATA_HASH = "DATA_HASH" | |
21 | 21 | ||
22 | 22 | let MAX_INT = 9223372036854775807 | |
23 | 23 | ||
24 | 24 | func _validateAddress (address_,err_) = match addressFromString(address_) { | |
25 | 25 | case a: Address => | |
26 | 26 | true | |
27 | 27 | case _ => | |
28 | 28 | throw(err_) | |
29 | 29 | } | |
30 | 30 | ||
31 | 31 | ||
32 | 32 | func _validatePublicKey (publicKey_,err_) = if ((size(fromBase58String(publicKey_)) != 32)) | |
33 | 33 | then throw(err_) | |
34 | 34 | else true | |
35 | 35 | ||
36 | 36 | ||
37 | 37 | func _validateInt (val_,lowerBoundary_,upperBoundary_,err_) = if (if ((lowerBoundary_ > val_)) | |
38 | 38 | then true | |
39 | 39 | else (val_ > upperBoundary_)) | |
40 | 40 | then throw(err_) | |
41 | 41 | else true | |
42 | 42 | ||
43 | 43 | ||
44 | 44 | func _loadInit () = match getBoolean(KEY_INIT) { | |
45 | 45 | case a: Boolean => | |
46 | 46 | a | |
47 | 47 | case _ => | |
48 | 48 | false | |
49 | 49 | } | |
50 | 50 | ||
51 | 51 | ||
52 | 52 | func _saveInit (isInit_) = [BooleanEntry(KEY_INIT, isInit_)] | |
53 | 53 | ||
54 | 54 | ||
55 | 55 | func _loadPause () = match getBoolean(KEY_PAUSED) { | |
56 | 56 | case a: Boolean => | |
57 | 57 | a | |
58 | 58 | case _ => | |
59 | 59 | false | |
60 | 60 | } | |
61 | 61 | ||
62 | 62 | ||
63 | 63 | func _savePause (isPaused_) = [BooleanEntry(KEY_PAUSED, isPaused_)] | |
64 | 64 | ||
65 | 65 | ||
66 | 66 | func _loadPauser () = match getString(KEY_PAUSER) { | |
67 | 67 | case a: String => | |
68 | 68 | addressFromStringValue(a) | |
69 | 69 | case _ => | |
70 | 70 | Address(base58'') | |
71 | 71 | } | |
72 | 72 | ||
73 | 73 | ||
74 | 74 | func _savePauser (pauser_) = [StringEntry(KEY_PAUSER, toString(pauser_))] | |
75 | 75 | ||
76 | 76 | ||
77 | 77 | func _loadMultisig () = match getString(KEY_MULTISIG) { | |
78 | 78 | case a: String => | |
79 | 79 | addressFromStringValue(a) | |
80 | 80 | case _ => | |
81 | 81 | Address(base58'') | |
82 | 82 | } | |
83 | 83 | ||
84 | 84 | ||
85 | 85 | func _saveMultisig (multisig_) = [StringEntry(KEY_MULTISIG, toString(multisig_))] | |
86 | 86 | ||
87 | 87 | ||
88 | 88 | func _loadChainId () = match getInteger(KEY_CHAIN_ID) { | |
89 | 89 | case a: Int => | |
90 | 90 | a | |
91 | 91 | case _ => | |
92 | 92 | 0 | |
93 | 93 | } | |
94 | 94 | ||
95 | 95 | ||
96 | 96 | func _saveChainId (chainId_) = [IntegerEntry(KEY_CHAIN_ID, chainId_)] | |
97 | 97 | ||
98 | 98 | ||
99 | 99 | func _loadSignerPublicKey () = match getString(KEY_SIGNER_PUBLIC_KEY) { | |
100 | 100 | case a: String => | |
101 | 101 | fromBase58String(a) | |
102 | 102 | case _ => | |
103 | 103 | base58'' | |
104 | 104 | } | |
105 | 105 | ||
106 | 106 | ||
107 | 107 | func _saveSignerPublicKey (signerPublicKey_) = [StringEntry(KEY_SIGNER_PUBLIC_KEY, toBase58String(signerPublicKey_))] | |
108 | 108 | ||
109 | 109 | ||
110 | 110 | func _loadDataHash (dataHash_) = match getInteger(makeString([KEY_DATA_HASH, toBase58String(dataHash_)], SEPARATOR)) { | |
111 | 111 | case a: Int => | |
112 | 112 | a | |
113 | 113 | case _ => | |
114 | 114 | 0 | |
115 | 115 | } | |
116 | 116 | ||
117 | 117 | ||
118 | 118 | func _saveDataHash (dataHash_,height_) = [IntegerEntry(makeString([KEY_DATA_HASH, toBase58String(dataHash_)], SEPARATOR), height_)] | |
119 | 119 | ||
120 | 120 | ||
121 | 121 | func _onlyThisContract (caller_) = if ((caller_ != this)) | |
122 | 122 | then throw("_onlyThisContract: revert") | |
123 | 123 | else true | |
124 | 124 | ||
125 | 125 | ||
126 | 126 | func _whenMultisigSet () = if ((_loadMultisig() == Address(base58''))) | |
127 | 127 | then throw("_whenMultisigSet: revert") | |
128 | 128 | else true | |
129 | 129 | ||
130 | 130 | ||
131 | 131 | func _whenNotInitialized () = if (_loadInit()) | |
132 | 132 | then throw("_whenNotInitialized: revert") | |
133 | 133 | else true | |
134 | 134 | ||
135 | 135 | ||
136 | 136 | func _whenInitialized () = if (!(_loadInit())) | |
137 | 137 | then throw("_whenInitialized: revert") | |
138 | 138 | else true | |
139 | 139 | ||
140 | 140 | ||
141 | 141 | func _whenNotPaused () = if (_loadPause()) | |
142 | 142 | then throw("_whenNotPaused: revert") | |
143 | 143 | else true | |
144 | 144 | ||
145 | 145 | ||
146 | 146 | func _whenPaused () = if (!(_loadPause())) | |
147 | 147 | then throw("_whenPaused: revert") | |
148 | 148 | else true | |
149 | 149 | ||
150 | 150 | ||
151 | 151 | func _onlyPauser (caller_) = if ((caller_ != _loadPauser())) | |
152 | 152 | then throw("_onlyPauser: revert") | |
153 | 153 | else true | |
154 | 154 | ||
155 | 155 | ||
156 | 156 | @Callable(i) | |
157 | 157 | func init (pauser_,chainId_,signerPublicKey_) = { | |
158 | 158 | let err = if (if (if (if (if (_onlyThisContract(i.caller)) | |
159 | 159 | then _whenNotInitialized() | |
160 | 160 | else false) | |
161 | 161 | then _whenMultisigSet() | |
162 | 162 | else false) | |
163 | 163 | then _validateAddress(pauser_, "init: invalid pauser") | |
164 | 164 | else false) | |
165 | 165 | then _validateInt(chainId_, 0, MAX_INT, "init: invalid chain id") | |
166 | 166 | else false) | |
167 | 167 | then _validatePublicKey(signerPublicKey_, "init: invalid signer public key") | |
168 | 168 | else false | |
169 | 169 | if ((err == err)) | |
170 | 170 | then $Tuple2((((_saveInit(true) ++ _savePauser(addressFromStringValue(pauser_))) ++ _saveChainId(chainId_)) ++ _saveSignerPublicKey(fromBase58String(signerPublicKey_))), unit) | |
171 | 171 | else throw("Strict value is not equal to itself.") | |
172 | 172 | } | |
173 | 173 | ||
174 | 174 | ||
175 | 175 | ||
176 | 176 | @Callable(i) | |
177 | 177 | func execute (contract_,functionName_,functionArgs_,callerChainId_,executionChainId_,nonce_,txHash_,signature_) = { | |
178 | - | let err = if (if (if (_whenInitialized()) | |
178 | + | let argsSize = size(functionArgs_) | |
179 | + | let err = if (if (if (if (_whenInitialized()) | |
179 | 180 | then _whenNotPaused() | |
180 | 181 | else false) | |
181 | 182 | then _validateAddress(contract_, "execute: invalid contract") | |
183 | + | else false) | |
184 | + | then _validateInt(argsSize, 0, 22, "execute: invalid args size") | |
182 | 185 | else false) | |
183 | 186 | then if ((_loadChainId() != executionChainId_)) | |
184 | 187 | then throw("execute: invalid execution chain id") | |
185 | 188 | else true | |
186 | 189 | else false | |
187 | 190 | if ((err == err)) | |
188 | 191 | then { | |
189 | - | func foldFunc (acc,elem) = (acc + toBytes(elem)) | |
192 | + | func foldFunc (acc,elem) = ((acc + toBytes(size(elem))) + toBytes(elem)) | |
190 | 193 | ||
191 | 194 | let argsBytes = { | |
192 | 195 | let $l = functionArgs_ | |
193 | 196 | let $s = size($l) | |
194 | 197 | let $acc0 = base58'' | |
195 | 198 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
196 | 199 | then $a | |
197 | 200 | else foldFunc($a, $l[$i]) | |
198 | 201 | ||
199 | 202 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
200 | 203 | then $a | |
201 | 204 | else throw("List size exceeds 22") | |
202 | 205 | ||
203 | 206 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($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), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20), 21), 22) | |
204 | 207 | } | |
205 | - | let data = ((((((toBytes(callerChainId_) + toBytes(executionChainId_)) + toBytes(nonce_)) + toBytes(txHash_)) + fromBase58String(contract_)) + toBytes(functionName_)) + argsBytes) | |
208 | + | let data = (((((((((toBytes(callerChainId_) + toBytes(executionChainId_)) + toBytes(nonce_)) + toBytes(size(txHash_))) + toBytes(txHash_)) + fromBase58String(contract_)) + toBytes(size(functionName_))) + toBytes(functionName_)) + toBytes(argsSize)) + argsBytes) | |
206 | 209 | let dataHash = keccak256_32Kb(data) | |
207 | 210 | let err1 = if (!(sigVerify(dataHash, fromBase58String(signature_), _loadSignerPublicKey()))) | |
208 | 211 | then throw("execute: invalid signature") | |
209 | 212 | else if ((_loadDataHash(dataHash) > 0)) | |
210 | 213 | then throw("execute: duplicate data") | |
211 | 214 | else unit | |
212 | 215 | if ((err1 == err1)) | |
213 | 216 | then { | |
214 | 217 | let invocation = invoke(addressFromStringValue(contract_), functionName_, functionArgs_, nil) | |
215 | 218 | if ((invocation == invocation)) | |
216 | 219 | then $Tuple2(_saveDataHash(dataHash, height), unit) | |
217 | 220 | else throw("Strict value is not equal to itself.") | |
218 | 221 | } | |
219 | 222 | else throw("Strict value is not equal to itself.") | |
220 | 223 | } | |
221 | 224 | else throw("Strict value is not equal to itself.") | |
222 | 225 | } | |
223 | 226 | ||
224 | 227 | ||
225 | 228 | ||
226 | 229 | @Callable(i) | |
227 | 230 | func updateSigner (newSignerPublicKey_,oldSignature_,newSignature_) = { | |
228 | 231 | let err = if (if (_onlyThisContract(i.caller)) | |
229 | 232 | then _whenInitialized() | |
230 | 233 | else false) | |
231 | 234 | then _validatePublicKey(newSignerPublicKey_, "updateSigner: invalid signer public key") | |
232 | 235 | else false | |
233 | 236 | if ((err == err)) | |
234 | 237 | then { | |
235 | 238 | let oldSignerPublicKey = _loadSignerPublicKey() | |
236 | 239 | let oldData = ((toBytes("<<<PUBLIC--KEY--MIGRATION--ALLOWED>>>") + oldSignerPublicKey) + fromBase58String(newSignerPublicKey_)) | |
237 | 240 | let newSignerPublicKey = fromBase58String(newSignerPublicKey_) | |
238 | 241 | let newData = ((toBytes("<<<PUBLIC--KEY--MIGRATION--CONFIRMED>>>") + oldSignerPublicKey) + fromBase58String(newSignerPublicKey_)) | |
239 | 242 | let err1 = if (!(sigVerify_8Kb(oldData, fromBase58String(oldSignature_), oldSignerPublicKey))) | |
240 | 243 | then throw("updateSigner: invalid old signature") | |
241 | 244 | else if (!(sigVerify_8Kb(newData, fromBase58String(newSignature_), newSignerPublicKey))) | |
242 | 245 | then throw("updateSigner: invalid new signature") | |
243 | 246 | else unit | |
244 | 247 | if ((err1 == err1)) | |
245 | 248 | then $Tuple2(_saveSignerPublicKey(newSignerPublicKey), unit) | |
246 | 249 | else throw("Strict value is not equal to itself.") | |
247 | 250 | } | |
248 | 251 | else throw("Strict value is not equal to itself.") | |
249 | 252 | } | |
250 | 253 | ||
251 | 254 | ||
252 | 255 | ||
253 | 256 | @Callable(i) | |
254 | 257 | func pause () = { | |
255 | 258 | let err = if (if (_onlyPauser(i.caller)) | |
256 | 259 | then _whenInitialized() | |
257 | 260 | else false) | |
258 | 261 | then _whenNotPaused() | |
259 | 262 | else false | |
260 | 263 | if ((err == err)) | |
261 | 264 | then $Tuple2(_savePause(true), unit) | |
262 | 265 | else throw("Strict value is not equal to itself.") | |
263 | 266 | } | |
264 | 267 | ||
265 | 268 | ||
266 | 269 | ||
267 | 270 | @Callable(i) | |
268 | 271 | func unpause () = { | |
269 | 272 | let err = if (if (_onlyPauser(i.caller)) | |
270 | 273 | then _whenInitialized() | |
271 | 274 | else false) | |
272 | 275 | then _whenPaused() | |
273 | 276 | else false | |
274 | 277 | if ((err == err)) | |
275 | 278 | then $Tuple2(_savePause(false), unit) | |
276 | 279 | else throw("Strict value is not equal to itself.") | |
277 | 280 | } | |
278 | 281 | ||
279 | 282 | ||
280 | 283 | ||
281 | 284 | @Callable(i) | |
282 | 285 | func updatePauser (pauser_) = { | |
283 | 286 | let err = if (if (_onlyThisContract(i.caller)) | |
284 | 287 | then _whenInitialized() | |
285 | 288 | else false) | |
286 | 289 | then _validateAddress(pauser_, "init: invalid pauser") | |
287 | 290 | else false | |
288 | 291 | if ((err == err)) | |
289 | 292 | then $Tuple2(_savePauser(addressFromStringValue(pauser_)), unit) | |
290 | 293 | else throw("Strict value is not equal to itself.") | |
291 | 294 | } | |
292 | 295 | ||
293 | 296 | ||
294 | 297 | ||
295 | 298 | @Callable(i) | |
296 | 299 | func setMultisig (multisig_) = { | |
297 | 300 | let err = if (_onlyThisContract(i.caller)) | |
298 | 301 | then _validateAddress(multisig_, "setMultisig: invalid multisig address") | |
299 | 302 | else false | |
300 | 303 | if ((err == err)) | |
301 | 304 | then $Tuple2(_saveMultisig(addressFromStringValue(multisig_)), unit) | |
302 | 305 | else throw("Strict value is not equal to itself.") | |
303 | 306 | } | |
304 | 307 | ||
305 | 308 | ||
306 | 309 | @Verifier(tx) | |
307 | 310 | func verify () = match getString(KEY_MULTISIG) { | |
308 | 311 | case multisig: String => | |
309 | 312 | valueOrElse(getBoolean(addressFromStringValue(multisig), makeString([KEY_STATUS, toString(this), toBase58String(tx.id)], SEPARATOR)), false) | |
310 | 313 | case _ => | |
311 | 314 | sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
312 | 315 | } | |
313 | 316 |
github/deemru/w8io/026f985 36.74 ms ◑