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