tx · AuvzskD8MwFkKqx5bFQTZaNAUMMDWoN3veyxzVpJpS9o 3N4ziXSMRverXyxHDUKKMR9MHXnB3TyU3Yh: -0.01000000 Waves 2023.04.19 10:18 [2541137] smart account 3N4ziXSMRverXyxHDUKKMR9MHXnB3TyU3Yh > SELF 0.00000000 Waves
{ "type": 13, "id": "AuvzskD8MwFkKqx5bFQTZaNAUMMDWoN3veyxzVpJpS9o", "fee": 1000000, "feeAssetId": null, "timestamp": 1681888774830, "version": 2, "chainId": 84, "sender": "3N4ziXSMRverXyxHDUKKMR9MHXnB3TyU3Yh", "senderPublicKey": "EU9obW1yVhR8qug3EmXPeew3DMagvJFQzY5Ku8bmcsU7", "proofs": [ "62xc84XBLFBdCJbR8iaurtXJLRz8RtTjofK3LRw76CSNcouAv7DRLhrb9K3Cwv1H7BjBduYPGJUJJ6N7Rhuqw9qR" ], "script": "base64:BgISCAISABIDCgEIEgASABIDCgEIHAADU0VQAgJfXwAQY29udHJhY3RGaWxlbmFtZQISbWFuYWdlcl92YXVsdC5yaWRlAQh0aHJvd0VycgEBcwkAAgEJAKwCAgkArAICBRBjb250cmFjdEZpbGVuYW1lAgI6IAUBcwEZa2V5QWN0aXZlTWFuYWdlclB1YmxpY0tleQAJALkJAgkAzAgCAgIlcwkAzAgCAhBtYW5hZ2VyUHVibGljS2V5BQNuaWwFA1NFUAEaa2V5UGVuZGluZ01hbmFnZXJQdWJsaWNLZXkACQC5CQIJAMwIAgICJXMJAMwIAgIXcGVuZGluZ01hbmFnZXJQdWJsaWNLZXkFA25pbAUDU0VQARprZXlTZXROZXdNYW5hZ2VyVm90ZVByZWZpeAEQbWFuYWdlclB1YmxpY0tleQkAuQkCCQDMCAICBiVzJXMlcwkAzAgCAgpzZXRNYW5hZ2VyCQDMCAIFEG1hbmFnZXJQdWJsaWNLZXkFA25pbAUDU0VQARRrZXlTZXROZXdNYW5hZ2VyVm90ZQIQbWFuYWdlclB1YmxpY0tleQVhZG1pbgkAuQkCCQDMCAIJAR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pbmdFbnRyeQIJARlrZXlBY3RpdmVNYW5hZ2VyUHVibGljS2V5AAUUcGVuZGluZ01hbmFnZXJTdHJpbmcFA25pbAkBDHZvdGVJTlRFUk5BTAUFE2NhbGxlckFkZHJlc3NTdHJpbmcFEGFkbWluQ3VycmVudFZvdGUFCWtleVByZWZpeAUIbWluVm90ZXMFBnJlc3VsdAFpAQthZGROZXdBZG1pbgEPbmV3QWRtaW5BZGRyZXNzBBNjYWxsZXJBZGRyZXNzU3RyaW5nCQDYBAEICAUBaQZjYWxsZXIFYnl0ZXMECWtleVByZWZpeAkBGGtleUFkZE5ld0FkbWluVm90ZVByZWZpeAEFD25ld0FkbWluQWRkcmVzcwQQYWRtaW5DdXJyZW50Vm90ZQkBEmdldEFkZE5ld0FkbWluVm90ZQIFD25ld0FkbWluQWRkcmVzcwUTY2FsbGVyQWRkcmVzc1N0cmluZwQIbWluVm90ZXMAAgQQY3VycmVudEFkbWluTGlzdAkBDWdldEFkbWluc0xpc3QAAwkAAAIFEGN1cnJlbnRBZG1pbkxpc3QFEGN1cnJlbnRBZG1pbkxpc3QEDG5ld0FkbWluTGlzdAkAzQgCBRBjdXJyZW50QWRtaW5MaXN0BQ9uZXdBZG1pbkFkZHJlc3MEBnJlc3VsdAkAzAgCCQELU3RyaW5nRW50cnkCCQETa2V5QWRtaW5BZGRyZXNzTGlzdAAJALkJAgUMbmV3QWRtaW5MaXN0BQNTRVAFA25pbAkBDHZvdGVJTlRFUk5BTAUFE2NhbGxlckFkZHJlc3NTdHJpbmcFEGFkbWluQ3VycmVudFZvdGUFCWtleVByZWZpeAUIbWluVm90ZXMFBnJlc3VsdAkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgDljlSb", "height": 2541137, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 4e9cB1djkmziMs3DjQ2dypH3YCvNrXtjWbwAA1eggF29 Next: DcHiV3kYZomWmkQ9UsFEBFQPKqDpHrkXwYrfSkd472FG Diff:
Old | New | Differences | |
---|---|---|---|
41 | 41 | func getActivateManagerVote (admin) = valueOrElse(getInteger(keyActivateManagerVote(admin)), 0) | |
42 | 42 | ||
43 | 43 | ||
44 | - | func keyAdminAdressList () = makeString(["%s", "adminAddressList"], SEP) | |
44 | + | func keyAddNewAdminVotePrefix (newAdmin) = makeString(["%s%s%s", "addAdmin", newAdmin], SEP) | |
45 | + | ||
46 | + | ||
47 | + | func keyAddNewAdminVote (newAdmin,admin) = makeString([keyAddNewAdminVotePrefix(newAdmin), admin], SEP) | |
48 | + | ||
49 | + | ||
50 | + | func getAddNewAdminVote (newAdmin,admin) = valueOrElse(getInteger(keySetNewManagerVote(newAdmin, admin)), 0) | |
51 | + | ||
52 | + | ||
53 | + | func keyAdminAddressList () = makeString(["%s", "adminAddressList"], SEP) | |
45 | 54 | ||
46 | 55 | ||
47 | 56 | func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) { | |
54 | 63 | } | |
55 | 64 | ||
56 | 65 | ||
57 | - | func getAdminsList () = split(valueOrElse(getString(this, | |
66 | + | func getAdminsList () = split(valueOrElse(getString(this, keyAdminAddressList()), ""), SEP) | |
58 | 67 | ||
59 | 68 | ||
60 | 69 | func isInAdminList (address) = match indexOf(getAdminsList(), address) { | |
66 | 75 | ||
67 | 76 | ||
68 | 77 | func genVotesKeysHelper (a,adminAddress) = { | |
69 | - | let $ | |
70 | - | let result = $ | |
71 | - | let prefix = $ | |
78 | + | let $t024972521 = a | |
79 | + | let result = $t024972521._1 | |
80 | + | let prefix = $t024972521._2 | |
72 | 81 | $Tuple2((result :+ makeString([prefix, adminAddress], SEP)), prefix) | |
73 | 82 | } | |
74 | 83 | ||
75 | 84 | ||
76 | 85 | func genVotesKeys (keyPrefix) = { | |
77 | - | let adminList = | |
86 | + | let adminList = keyAdminAddressList() | |
78 | 87 | let $l = getAdminsList() | |
79 | 88 | let $s = size($l) | |
80 | 89 | let $acc0 = $Tuple2(nil, keyPrefix) | |
204 | 213 | } | |
205 | 214 | ||
206 | 215 | ||
216 | + | ||
217 | + | @Callable(i) | |
218 | + | func addNewAdmin (newAdminAddress) = { | |
219 | + | let callerAddressString = toBase58String(i.caller.bytes) | |
220 | + | let keyPrefix = keyAddNewAdminVotePrefix(newAdminAddress) | |
221 | + | let adminCurrentVote = getAddNewAdminVote(newAdminAddress, callerAddressString) | |
222 | + | let minVotes = 2 | |
223 | + | let currentAdminList = getAdminsList() | |
224 | + | if ((currentAdminList == currentAdminList)) | |
225 | + | then { | |
226 | + | let newAdminList = (currentAdminList :+ newAdminAddress) | |
227 | + | let result = [StringEntry(keyAdminAddressList(), makeString(newAdminList, SEP))] | |
228 | + | voteINTERNAL(callerAddressString, adminCurrentVote, keyPrefix, minVotes, result) | |
229 | + | } | |
230 | + | else throw("Strict value is not equal to itself.") | |
231 | + | } | |
232 | + | ||
233 | + |
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 contractFilename = "manager_vault.ride" | |
7 | 7 | ||
8 | 8 | func throwErr (s) = throw(((contractFilename + ": ") + s)) | |
9 | 9 | ||
10 | 10 | ||
11 | 11 | func keyActiveManagerPublicKey () = makeString(["%s", "managerPublicKey"], SEP) | |
12 | 12 | ||
13 | 13 | ||
14 | 14 | func keyPendingManagerPublicKey () = makeString(["%s", "pendingManagerPublicKey"], SEP) | |
15 | 15 | ||
16 | 16 | ||
17 | 17 | func keySetNewManagerVotePrefix (managerPublicKey) = makeString(["%s%s%s", "setManager", managerPublicKey], SEP) | |
18 | 18 | ||
19 | 19 | ||
20 | 20 | func keySetNewManagerVote (managerPublicKey,admin) = makeString([keySetNewManagerVotePrefix(managerPublicKey), admin], SEP) | |
21 | 21 | ||
22 | 22 | ||
23 | 23 | func getSetNewManagerVote (managerPublicKey,admin) = valueOrElse(getInteger(keySetNewManagerVote(managerPublicKey, admin)), 0) | |
24 | 24 | ||
25 | 25 | ||
26 | 26 | func keyDeactivateManagerVotePrefix () = makeString(["%s%s", "deactivateManager"], SEP) | |
27 | 27 | ||
28 | 28 | ||
29 | 29 | func keyDeactivateManagerVote (admin) = makeString([keyDeactivateManagerVotePrefix(), admin], SEP) | |
30 | 30 | ||
31 | 31 | ||
32 | 32 | func getDeactivateManagerVote (admin) = valueOrElse(getInteger(keyDeactivateManagerVote(admin)), 0) | |
33 | 33 | ||
34 | 34 | ||
35 | 35 | func keyActivateManagerVotePrefix () = makeString(["%s%s", "activateManager"], SEP) | |
36 | 36 | ||
37 | 37 | ||
38 | 38 | func keyActivateManagerVote (admin) = makeString([keyActivateManagerVotePrefix(), admin], SEP) | |
39 | 39 | ||
40 | 40 | ||
41 | 41 | func getActivateManagerVote (admin) = valueOrElse(getInteger(keyActivateManagerVote(admin)), 0) | |
42 | 42 | ||
43 | 43 | ||
44 | - | func keyAdminAdressList () = makeString(["%s", "adminAddressList"], SEP) | |
44 | + | func keyAddNewAdminVotePrefix (newAdmin) = makeString(["%s%s%s", "addAdmin", newAdmin], SEP) | |
45 | + | ||
46 | + | ||
47 | + | func keyAddNewAdminVote (newAdmin,admin) = makeString([keyAddNewAdminVotePrefix(newAdmin), admin], SEP) | |
48 | + | ||
49 | + | ||
50 | + | func getAddNewAdminVote (newAdmin,admin) = valueOrElse(getInteger(keySetNewManagerVote(newAdmin, admin)), 0) | |
51 | + | ||
52 | + | ||
53 | + | func keyAdminAddressList () = makeString(["%s", "adminAddressList"], SEP) | |
45 | 54 | ||
46 | 55 | ||
47 | 56 | func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) { | |
48 | 57 | case s: String => | |
49 | 58 | fromBase58String(s) | |
50 | 59 | case _: Unit => | |
51 | 60 | unit | |
52 | 61 | case _ => | |
53 | 62 | throw("Match error") | |
54 | 63 | } | |
55 | 64 | ||
56 | 65 | ||
57 | - | func getAdminsList () = split(valueOrElse(getString(this, | |
66 | + | func getAdminsList () = split(valueOrElse(getString(this, keyAdminAddressList()), ""), SEP) | |
58 | 67 | ||
59 | 68 | ||
60 | 69 | func isInAdminList (address) = match indexOf(getAdminsList(), address) { | |
61 | 70 | case t: Int => | |
62 | 71 | true | |
63 | 72 | case _ => | |
64 | 73 | false | |
65 | 74 | } | |
66 | 75 | ||
67 | 76 | ||
68 | 77 | func genVotesKeysHelper (a,adminAddress) = { | |
69 | - | let $ | |
70 | - | let result = $ | |
71 | - | let prefix = $ | |
78 | + | let $t024972521 = a | |
79 | + | let result = $t024972521._1 | |
80 | + | let prefix = $t024972521._2 | |
72 | 81 | $Tuple2((result :+ makeString([prefix, adminAddress], SEP)), prefix) | |
73 | 82 | } | |
74 | 83 | ||
75 | 84 | ||
76 | 85 | func genVotesKeys (keyPrefix) = { | |
77 | - | let adminList = | |
86 | + | let adminList = keyAdminAddressList() | |
78 | 87 | let $l = getAdminsList() | |
79 | 88 | let $s = size($l) | |
80 | 89 | let $acc0 = $Tuple2(nil, keyPrefix) | |
81 | 90 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
82 | 91 | then $a | |
83 | 92 | else genVotesKeysHelper($a, $l[$i]) | |
84 | 93 | ||
85 | 94 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
86 | 95 | then $a | |
87 | 96 | else throw("List size exceeds 10") | |
88 | 97 | ||
89 | 98 | $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) | |
90 | 99 | } | |
91 | 100 | ||
92 | 101 | ||
93 | 102 | func countVotesHelper (result,voteKey) = (result + valueOrElse(getInteger(voteKey), 0)) | |
94 | 103 | ||
95 | 104 | ||
96 | 105 | func countVotes (prefix) = { | |
97 | 106 | let votes = genVotesKeys(prefix)._1 | |
98 | 107 | let $l = votes | |
99 | 108 | let $s = size($l) | |
100 | 109 | let $acc0 = 0 | |
101 | 110 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
102 | 111 | then $a | |
103 | 112 | else countVotesHelper($a, $l[$i]) | |
104 | 113 | ||
105 | 114 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
106 | 115 | then $a | |
107 | 116 | else throw("List size exceeds 10") | |
108 | 117 | ||
109 | 118 | $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) | |
110 | 119 | } | |
111 | 120 | ||
112 | 121 | ||
113 | 122 | func clearVotesHelper (result,key) = (result :+ DeleteEntry(key)) | |
114 | 123 | ||
115 | 124 | ||
116 | 125 | func getClearVotesEntries (prefix) = { | |
117 | 126 | let votes = genVotesKeys(prefix)._1 | |
118 | 127 | let $l = votes | |
119 | 128 | let $s = size($l) | |
120 | 129 | let $acc0 = nil | |
121 | 130 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
122 | 131 | then $a | |
123 | 132 | else clearVotesHelper($a, $l[$i]) | |
124 | 133 | ||
125 | 134 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
126 | 135 | then $a | |
127 | 136 | else throw("List size exceeds 10") | |
128 | 137 | ||
129 | 138 | $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) | |
130 | 139 | } | |
131 | 140 | ||
132 | 141 | ||
133 | 142 | func voteINTERNAL (callerAddressString,adminCurrentVote,keyPrefix,minVotes,voteResult) = { | |
134 | 143 | let voteKey = makeString([keyPrefix, callerAddressString], SEP) | |
135 | 144 | if (isInAdminList(callerAddressString)) | |
136 | 145 | then if ((adminCurrentVote == 1)) | |
137 | 146 | then throwErr((voteKey + " you already voted")) | |
138 | 147 | else { | |
139 | 148 | let votes = countVotes(keyPrefix) | |
140 | 149 | if (((votes + 1) >= minVotes)) | |
141 | 150 | then { | |
142 | 151 | let clearVotesEntries = getClearVotesEntries(keyPrefix) | |
143 | 152 | (clearVotesEntries ++ voteResult) | |
144 | 153 | } | |
145 | 154 | else [IntegerEntry(voteKey, 1)] | |
146 | 155 | } | |
147 | 156 | else throwErr((("Address: " + callerAddressString) + " not in Admin list")) | |
148 | 157 | } | |
149 | 158 | ||
150 | 159 | ||
151 | 160 | @Callable(i) | |
152 | 161 | func confirmManager () = { | |
153 | 162 | let pm = pendingManagerPublicKeyOrUnit() | |
154 | 163 | let hasPM = if (isDefined(pm)) | |
155 | 164 | then true | |
156 | 165 | else throwErr("no pending manager") | |
157 | 166 | if ((hasPM == hasPM)) | |
158 | 167 | then { | |
159 | 168 | let checkPM = if ((i.callerPublicKey == value(pm))) | |
160 | 169 | then true | |
161 | 170 | else throwErr("you are not pending manager") | |
162 | 171 | if ((checkPM == checkPM)) | |
163 | 172 | then [StringEntry(keyActiveManagerPublicKey(), toBase58String(value(pm)))] | |
164 | 173 | else throw("Strict value is not equal to itself.") | |
165 | 174 | } | |
166 | 175 | else throw("Strict value is not equal to itself.") | |
167 | 176 | } | |
168 | 177 | ||
169 | 178 | ||
170 | 179 | ||
171 | 180 | @Callable(i) | |
172 | 181 | func voteForNewManger (newManagerPublicKey) = { | |
173 | 182 | let callerAddressString = toBase58String(i.caller.bytes) | |
174 | 183 | let keyPrefix = keySetNewManagerVotePrefix(newManagerPublicKey) | |
175 | 184 | let adminCurrentVote = getSetNewManagerVote(newManagerPublicKey, callerAddressString) | |
176 | 185 | let minVotes = 2 | |
177 | 186 | let result = [StringEntry(keyPendingManagerPublicKey(), newManagerPublicKey)] | |
178 | 187 | voteINTERNAL(callerAddressString, adminCurrentVote, keyPrefix, minVotes, result) | |
179 | 188 | } | |
180 | 189 | ||
181 | 190 | ||
182 | 191 | ||
183 | 192 | @Callable(i) | |
184 | 193 | func deactivateManager () = { | |
185 | 194 | let callerAddressString = toBase58String(i.caller.bytes) | |
186 | 195 | let keyPrefix = keyDeactivateManagerVotePrefix() | |
187 | 196 | let adminCurrentVote = getDeactivateManagerVote(callerAddressString) | |
188 | 197 | let minVotes = 1 | |
189 | 198 | let result = [DeleteEntry(keyActiveManagerPublicKey())] | |
190 | 199 | voteINTERNAL(callerAddressString, adminCurrentVote, keyPrefix, minVotes, result) | |
191 | 200 | } | |
192 | 201 | ||
193 | 202 | ||
194 | 203 | ||
195 | 204 | @Callable(i) | |
196 | 205 | func activateManager () = { | |
197 | 206 | let callerAddressString = toBase58String(i.caller.bytes) | |
198 | 207 | let keyPrefix = keyActivateManagerVotePrefix() | |
199 | 208 | let adminCurrentVote = getActivateManagerVote(callerAddressString) | |
200 | 209 | let minVotes = 2 | |
201 | 210 | let pendingManagerString = getStringValue(keyPendingManagerPublicKey()) | |
202 | 211 | let result = [StringEntry(keyActiveManagerPublicKey(), pendingManagerString)] | |
203 | 212 | voteINTERNAL(callerAddressString, adminCurrentVote, keyPrefix, minVotes, result) | |
204 | 213 | } | |
205 | 214 | ||
206 | 215 | ||
216 | + | ||
217 | + | @Callable(i) | |
218 | + | func addNewAdmin (newAdminAddress) = { | |
219 | + | let callerAddressString = toBase58String(i.caller.bytes) | |
220 | + | let keyPrefix = keyAddNewAdminVotePrefix(newAdminAddress) | |
221 | + | let adminCurrentVote = getAddNewAdminVote(newAdminAddress, callerAddressString) | |
222 | + | let minVotes = 2 | |
223 | + | let currentAdminList = getAdminsList() | |
224 | + | if ((currentAdminList == currentAdminList)) | |
225 | + | then { | |
226 | + | let newAdminList = (currentAdminList :+ newAdminAddress) | |
227 | + | let result = [StringEntry(keyAdminAddressList(), makeString(newAdminList, SEP))] | |
228 | + | voteINTERNAL(callerAddressString, adminCurrentVote, keyPrefix, minVotes, result) | |
229 | + | } | |
230 | + | else throw("Strict value is not equal to itself.") | |
231 | + | } | |
232 | + | ||
233 | + |
github/deemru/w8io/026f985 35.41 ms ◑