tx · 3Np9XXsZAAF6myzAQ6XNZwDBDyzkgeJkFxcQXxu5GNrr 3NAnrRUttuM8z2xyQdcZDZ9siKDcExnMD7h: -0.01400000 Waves 2022.12.06 12:44 [2348319] smart account 3NAnrRUttuM8z2xyQdcZDZ9siKDcExnMD7h > SELF 0.00000000 Waves
{ "type": 13, "id": "3Np9XXsZAAF6myzAQ6XNZwDBDyzkgeJkFxcQXxu5GNrr", "fee": 1400000, "feeAssetId": null, "timestamp": 1670319607205, "version": 2, "chainId": 84, "sender": "3NAnrRUttuM8z2xyQdcZDZ9siKDcExnMD7h", "senderPublicKey": "9N3y4L5Mhfn5nsh2J2sfe2wNG7t8TFXQVHJb1mXXSahb", "proofs": [ "4Mcdk2muKo9JX3PXkuSrHn8CpGnpRmWgHheqeUqXWFm8uQMTbcdCuPC5MbH62ubM979XrSdna7twCHuFrbmJzeV7" ], "script": "base64:BgIjCAISBAoCGAESAwoBCBIDCgEIEgMKAQESBAoCCAgSBAoCCAgIAAlTRVBBUkFUT1ICAl9fAAxLRVlfTVVMVElTSUcCCE1VTFRJU0lHAA9LRVlfUFVCTElDX0tFWVMCC1BVQkxJQ19LRVlTAApLRVlfUVVPUlVNAgZRVU9SVU0AC0tFWV9DT05GSVJNAgdDT05GSVJNAApLRVlfU1RBVFVTAgZTVEFUVVMBEF92YWxpZGF0ZUFkZHJlc3MBCGFkZHJlc3NfBAckbWF0Y2gwCQCmCAEFCGFkZHJlc3NfAwkAAQIFByRtYXRjaDACB0FkZHJlc3MEAWEFByRtYXRjaDAGBwEOX3ZhbGlkYXRlT3duZXICBGFjY18FZWxlbV8DCQAAAgUFZWxlbV8CAAkAAgECDWludmFsaWQgb3duZXIDCQECIT0CCQDIAQEJANkEAQUFZWxlbV8AIAkAAgECGGludmFsaWQgb3duZXIgcHVibGljIGtleQUEYWNjXwYBaQEEaW5pdAIHb3duZXJzXwdxdW9ydW1fBANlcnIDCQEJaXNEZWZpbmVkAQkAoggBBQxLRVlfTVVMVElTSUcJ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Jvb2xlYW5FbnRyeQIFCXN0YXR1c0tleQkAZwIFEmNvbmZpcm1hdGlvbnNDb3VudAUGcXVvcnVtBQNuaWwFBHVuaXQJAAIBAiRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4BAnR4AQZ2ZXJpZnkABAckbWF0Y2gwCQCiCAEFDEtFWV9NVUxUSVNJRwMJAAECBQckbWF0Y2gwAgZTdHJpbmcECG11bHRpc2lnBQckbWF0Y2gwCQELdmFsdWVPckVsc2UCCQCbCAIJARFAZXh0ck5hdGl2ZSgxMDYyKQEFCG11bHRpc2lnCQC5CQIJAMwIAgUKS0VZX1NUQVRVUwkAzAgCCQClCAEFBHRoaXMJAMwIAgkA2AQBCAUCdHgCaWQFA25pbAUJU0VQQVJBVE9SBwkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAAgFAnR4D3NlbmRlclB1YmxpY0tledsxC/w=", "height": 2348319, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: BufGtpBmQXbwF79168vLrt8gUWLdKH8HH6NdQkT3Vtah Next: none Diff:
Old | New | Differences | |
---|---|---|---|
77 | 77 | let publicKeysList = split(publicKeys, SEPARATOR) | |
78 | 78 | if ((i.caller != this)) | |
79 | 79 | then throw("addOwner: not allowed") | |
80 | - | else if ((_validateOwner(0, publicKey_) | |
80 | + | else if ((_validateOwner(0, publicKey_) != 0)) | |
81 | 81 | then throw("addOwner: invalid public key") | |
82 | - | else if ((size(publicKeysList) == 10)) | |
83 | - | then throw("addOwner: too many owners") | |
84 | - | else { | |
85 | - | let publicKeysListUpdated = (publicKeysList :+ publicKey_) | |
86 | - | let publicKeysUpdated = [StringEntry(KEY_PUBLIC_KEYS, makeString(publicKeysListUpdated, SEPARATOR))] | |
87 | - | $Tuple2(publicKeysUpdated, unit) | |
88 | - | } | |
82 | + | else if (containsElement(publicKeysList, publicKey_)) | |
83 | + | then throw("addOwner: public key already added") | |
84 | + | else if ((size(publicKeysList) == 10)) | |
85 | + | then throw("addOwner: too many owners") | |
86 | + | else { | |
87 | + | let publicKeysListUpdated = (publicKeysList :+ publicKey_) | |
88 | + | let publicKeysUpdated = [StringEntry(KEY_PUBLIC_KEYS, makeString(publicKeysListUpdated, SEPARATOR))] | |
89 | + | $Tuple2(publicKeysUpdated, unit) | |
90 | + | } | |
89 | 91 | } | |
90 | 92 | ||
91 | 93 |
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_MULTISIG = "MULTISIG" | |
7 | 7 | ||
8 | 8 | let KEY_PUBLIC_KEYS = "PUBLIC_KEYS" | |
9 | 9 | ||
10 | 10 | let KEY_QUORUM = "QUORUM" | |
11 | 11 | ||
12 | 12 | let KEY_CONFIRM = "CONFIRM" | |
13 | 13 | ||
14 | 14 | let KEY_STATUS = "STATUS" | |
15 | 15 | ||
16 | 16 | func _validateAddress (address_) = match addressFromString(address_) { | |
17 | 17 | case a: Address => | |
18 | 18 | true | |
19 | 19 | case _ => | |
20 | 20 | false | |
21 | 21 | } | |
22 | 22 | ||
23 | 23 | ||
24 | 24 | func _validateOwner (acc_,elem_) = if ((elem_ == "")) | |
25 | 25 | then throw("invalid owner") | |
26 | 26 | else if ((size(fromBase58String(elem_)) != 32)) | |
27 | 27 | then throw("invalid owner public key") | |
28 | 28 | else acc_ | |
29 | 29 | ||
30 | 30 | ||
31 | 31 | @Callable(i) | |
32 | 32 | func init (owners_,quorum_) = { | |
33 | 33 | let err = if (isDefined(getString(KEY_MULTISIG))) | |
34 | 34 | then throw("init: already initialized") | |
35 | 35 | else unit | |
36 | 36 | if ((err == err)) | |
37 | 37 | then { | |
38 | 38 | let err1 = if (if ((0 >= size(owners_))) | |
39 | 39 | then true | |
40 | 40 | else (size(owners_) > 10)) | |
41 | 41 | then throw("init: invalid owners") | |
42 | 42 | else if (if ((0 >= quorum_)) | |
43 | 43 | then true | |
44 | 44 | else (quorum_ > size(owners_))) | |
45 | 45 | then throw("init: invalid quorum") | |
46 | 46 | else unit | |
47 | 47 | if ((err1 == err1)) | |
48 | 48 | then { | |
49 | 49 | let err2 = { | |
50 | 50 | let $l = owners_ | |
51 | 51 | let $s = size($l) | |
52 | 52 | let $acc0 = 0 | |
53 | 53 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
54 | 54 | then $a | |
55 | 55 | else _validateOwner($a, $l[$i]) | |
56 | 56 | ||
57 | 57 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
58 | 58 | then $a | |
59 | 59 | else throw("List size exceeds 10") | |
60 | 60 | ||
61 | 61 | $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) | |
62 | 62 | } | |
63 | 63 | if ((err2 == err2)) | |
64 | 64 | then $Tuple2([StringEntry(KEY_MULTISIG, toString(this)), StringEntry(KEY_PUBLIC_KEYS, makeString(owners_, SEPARATOR)), IntegerEntry(KEY_QUORUM, quorum_)], unit) | |
65 | 65 | else throw("Strict value is not equal to itself.") | |
66 | 66 | } | |
67 | 67 | else throw("Strict value is not equal to itself.") | |
68 | 68 | } | |
69 | 69 | else throw("Strict value is not equal to itself.") | |
70 | 70 | } | |
71 | 71 | ||
72 | 72 | ||
73 | 73 | ||
74 | 74 | @Callable(i) | |
75 | 75 | func addOwner (publicKey_) = { | |
76 | 76 | let publicKeys = getStringValue(KEY_PUBLIC_KEYS) | |
77 | 77 | let publicKeysList = split(publicKeys, SEPARATOR) | |
78 | 78 | if ((i.caller != this)) | |
79 | 79 | then throw("addOwner: not allowed") | |
80 | - | else if ((_validateOwner(0, publicKey_) | |
80 | + | else if ((_validateOwner(0, publicKey_) != 0)) | |
81 | 81 | then throw("addOwner: invalid public key") | |
82 | - | else if ((size(publicKeysList) == 10)) | |
83 | - | then throw("addOwner: too many owners") | |
84 | - | else { | |
85 | - | let publicKeysListUpdated = (publicKeysList :+ publicKey_) | |
86 | - | let publicKeysUpdated = [StringEntry(KEY_PUBLIC_KEYS, makeString(publicKeysListUpdated, SEPARATOR))] | |
87 | - | $Tuple2(publicKeysUpdated, unit) | |
88 | - | } | |
82 | + | else if (containsElement(publicKeysList, publicKey_)) | |
83 | + | then throw("addOwner: public key already added") | |
84 | + | else if ((size(publicKeysList) == 10)) | |
85 | + | then throw("addOwner: too many owners") | |
86 | + | else { | |
87 | + | let publicKeysListUpdated = (publicKeysList :+ publicKey_) | |
88 | + | let publicKeysUpdated = [StringEntry(KEY_PUBLIC_KEYS, makeString(publicKeysListUpdated, SEPARATOR))] | |
89 | + | $Tuple2(publicKeysUpdated, unit) | |
90 | + | } | |
89 | 91 | } | |
90 | 92 | ||
91 | 93 | ||
92 | 94 | ||
93 | 95 | @Callable(i) | |
94 | 96 | func removeOwner (publicKey_) = { | |
95 | 97 | let quorum = getIntegerValue(KEY_QUORUM) | |
96 | 98 | let publicKeys = getStringValue(KEY_PUBLIC_KEYS) | |
97 | 99 | let publicKeysList = split(publicKeys, SEPARATOR) | |
98 | 100 | if ((i.caller != this)) | |
99 | 101 | then throw("removeOwner: not allowed") | |
100 | 102 | else if ((publicKey_ == "")) | |
101 | 103 | then throw("removeOwner: invalid public key") | |
102 | 104 | else if ((size(publicKeysList) == 1)) | |
103 | 105 | then throw("removeOwner: too few owners") | |
104 | 106 | else { | |
105 | 107 | let index = match indexOf(publicKeysList, publicKey_) { | |
106 | 108 | case a: Int => | |
107 | 109 | a | |
108 | 110 | case _ => | |
109 | 111 | throw("removeOwner: no such owner") | |
110 | 112 | } | |
111 | 113 | let publicKeysListUpdated = removeByIndex(publicKeysList, index) | |
112 | 114 | let publicKeysUpdated = [StringEntry(KEY_PUBLIC_KEYS, makeString(publicKeysListUpdated, SEPARATOR))] | |
113 | 115 | let quorumUpdated = if ((quorum > size(publicKeysListUpdated))) | |
114 | 116 | then [IntegerEntry(KEY_QUORUM, size(publicKeysListUpdated))] | |
115 | 117 | else nil | |
116 | 118 | $Tuple2((publicKeysUpdated ++ quorumUpdated), unit) | |
117 | 119 | } | |
118 | 120 | } | |
119 | 121 | ||
120 | 122 | ||
121 | 123 | ||
122 | 124 | @Callable(i) | |
123 | 125 | func setQuorum (quorum_) = { | |
124 | 126 | let publicKeys = getStringValue(KEY_PUBLIC_KEYS) | |
125 | 127 | let publicKeysList = split(publicKeys, SEPARATOR) | |
126 | 128 | if ((i.caller != this)) | |
127 | 129 | then throw("setQuorum: not allowed") | |
128 | 130 | else if (if ((0 >= quorum_)) | |
129 | 131 | then true | |
130 | 132 | else (quorum_ > size(publicKeysList))) | |
131 | 133 | then throw("setQuorum: invalid quorum") | |
132 | 134 | else $Tuple2([IntegerEntry(KEY_QUORUM, quorum_)], unit) | |
133 | 135 | } | |
134 | 136 | ||
135 | 137 | ||
136 | 138 | ||
137 | 139 | @Callable(i) | |
138 | 140 | func confirmTransaction (dapp_,txId_) = { | |
139 | 141 | let callerPublicKey = toBase58String(i.callerPublicKey) | |
140 | 142 | let quorum = getIntegerValue(KEY_QUORUM) | |
141 | 143 | let publicKeys = getStringValue(KEY_PUBLIC_KEYS) | |
142 | 144 | let publicKeysList = split(publicKeys, SEPARATOR) | |
143 | 145 | let confirmationsKey = makeString([KEY_CONFIRM, dapp_, txId_], SEPARATOR) | |
144 | 146 | let confirmations = valueOrElse(getString(confirmationsKey), "") | |
145 | 147 | let statusKey = makeString([KEY_STATUS, dapp_, txId_], SEPARATOR) | |
146 | 148 | let err = if (!(containsElement(publicKeysList, callerPublicKey))) | |
147 | 149 | then throw("confirmTransaction: only admin") | |
148 | 150 | else if ((size(fromBase58String(txId_)) != 32)) | |
149 | 151 | then throw("confirmTransaction: invalid txId") | |
150 | 152 | else if (!(_validateAddress(dapp_))) | |
151 | 153 | then throw("confirmTransaction: invalid dapp address") | |
152 | 154 | else if (contains(confirmations, callerPublicKey)) | |
153 | 155 | then throw("confirmTransaction: already confirmed") | |
154 | 156 | else unit | |
155 | 157 | if ((err == err)) | |
156 | 158 | then { | |
157 | 159 | let confirmationsCount = (1 + (if ((confirmations == "")) | |
158 | 160 | then 0 | |
159 | 161 | else size(split(confirmations, SEPARATOR)))) | |
160 | 162 | let confirmationsUpdated = if ((confirmations == "")) | |
161 | 163 | then callerPublicKey | |
162 | 164 | else ((confirmations + SEPARATOR) + callerPublicKey) | |
163 | 165 | $Tuple2([StringEntry(confirmationsKey, confirmationsUpdated), BooleanEntry(statusKey, (confirmationsCount >= quorum))], unit) | |
164 | 166 | } | |
165 | 167 | else throw("Strict value is not equal to itself.") | |
166 | 168 | } | |
167 | 169 | ||
168 | 170 | ||
169 | 171 | ||
170 | 172 | @Callable(i) | |
171 | 173 | func revokeConfirmation (dapp_,txId_) = { | |
172 | 174 | let callerPublicKey = toBase58String(i.callerPublicKey) | |
173 | 175 | let quorum = getIntegerValue(KEY_QUORUM) | |
174 | 176 | let publicKeys = getStringValue(KEY_PUBLIC_KEYS) | |
175 | 177 | let publicKeysList = split(publicKeys, SEPARATOR) | |
176 | 178 | let confirmationsKey = makeString([KEY_CONFIRM, dapp_, txId_], SEPARATOR) | |
177 | 179 | let confirmations = valueOrElse(getString(confirmationsKey), "") | |
178 | 180 | let confirmationsList = split(confirmations, SEPARATOR) | |
179 | 181 | let statusKey = makeString([KEY_STATUS, dapp_, txId_], SEPARATOR) | |
180 | 182 | let status = valueOrElse(getBoolean(statusKey), false) | |
181 | 183 | let err = if (!(containsElement(publicKeysList, callerPublicKey))) | |
182 | 184 | then throw("revokeConfirmation: only admin") | |
183 | 185 | else if ((size(fromBase58String(txId_)) != 32)) | |
184 | 186 | then throw("revokeConfirmation: invalid txId") | |
185 | 187 | else if (!(_validateAddress(dapp_))) | |
186 | 188 | then throw("revokeConfirmation: invalid dapp address") | |
187 | 189 | else if (!(containsElement(confirmationsList, callerPublicKey))) | |
188 | 190 | then throw("revokeConfirmation: not confirmed") | |
189 | 191 | else if (status) | |
190 | 192 | then throw("revokeConfirmation: quorum already reached") | |
191 | 193 | else unit | |
192 | 194 | if ((err == err)) | |
193 | 195 | then { | |
194 | 196 | let confirmationsListUpdated = removeByIndex(confirmationsList, value(indexOf(confirmationsList, callerPublicKey))) | |
195 | 197 | let confirmationsCount = size(confirmationsListUpdated) | |
196 | 198 | $Tuple2([StringEntry(confirmationsKey, makeString(confirmationsListUpdated, SEPARATOR)), BooleanEntry(statusKey, (confirmationsCount >= quorum))], unit) | |
197 | 199 | } | |
198 | 200 | else throw("Strict value is not equal to itself.") | |
199 | 201 | } | |
200 | 202 | ||
201 | 203 | ||
202 | 204 | @Verifier(tx) | |
203 | 205 | func verify () = match getString(KEY_MULTISIG) { | |
204 | 206 | case multisig: String => | |
205 | 207 | valueOrElse(getBoolean(addressFromStringValue(multisig), makeString([KEY_STATUS, toString(this), toBase58String(tx.id)], SEPARATOR)), false) | |
206 | 208 | case _ => | |
207 | 209 | sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
208 | 210 | } | |
209 | 211 |
github/deemru/w8io/026f985 30.26 ms ◑