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