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