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:BgINCAISABIDCgEIEgASABkAA1NFUAICX18AEGNvbnRyYWN0RmlsZW5hbWUCEm1hbmFnZXJfdmF1bHQucmlkZQEIdGhyb3dFcnIBAXMJAAIBCQCsAgIJAKwCAgUQY29udHJhY3RGaWxlbmFtZQICOiAFAXMBGWtleUFjdGl2ZU1hbmFnZXJQdWJsaWNLZXkACQC5CQIJAMwIAgICJXMJAMwIAgIQbWFuYWdlclB1YmxpY0tleQUDbmlsBQNTRVABGmtleVBlbmRpbmdNYW5hZ2VyUHVibGljS2V5AAkAuQkCCQDMCAICAiVzCQDMCAICF3BlbmRpbmdNYW5hZ2VyUHVibGljS2V5BQNuaWwFA1NFUAEaa2V5U2V0TmV3TWFuYWdlclZvdGVQcmVmaXgBEG1hbmFnZXJQdWJsaWNLZXkJALkJAgkAzAgCAgYlcyVzJXMJAMwIAgIKc2V0TWFuYWdlcgkAzAgCBRBtYW5hZ2VyUHVibGljS2V5BQNuaWwFA1NFUAEUa2V5U2V0TmV3TWFuYWdlclZvdGUCEG1hbmFnZXJQdWJsaWNLZXkFYWRtaW4JALkJAgkAzAgCCQ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dGVNYW5hZ2VyVm90ZQEFE2NhbGxlckFkZHJlc3NTdHJpbmcECG1pblZvdGVzAAEEBnJlc3VsdAkAzAgCCQELRGVsZXRlRW50cnkBCQEZa2V5QWN0aXZlTWFuYWdlclB1YmxpY0tleQAFA25pbAkBDHZvdGVJTlRFUk5BTAUFE2NhbGxlckFkZHJlc3NTdHJpbmcFEGFkbWluQ3VycmVudFZvdGUFCWtleVByZWZpeAUIbWluVm90ZXMFBnJlc3VsdAFpAQ9hY3RpdmF0ZU1hbmFnZXIABBNjYWxsZXJBZGRyZXNzU3RyaW5nCQDYBAEICAUBaQZjYWxsZXIFYnl0ZXMECWtleVByZWZpeAkBHGtleUFjdGl2YXRlTWFuYWdlclZvdGVQcmVmaXgABBBhZG1pbkN1cnJlbnRWb3RlCQEWZ2V0QWN0aXZhdGVNYW5hZ2VyVm90ZQEFE2NhbGxlckFkZHJlc3NTdHJpbmcECG1pblZvdGVzAAIEFHBlbmRpbmdNYW5hZ2VyU3RyaW5nCQERQGV4dHJOYXRpdmUoMTA1OCkBCQEaa2V5UGVuZGluZ01hbmFnZXJQdWJsaWNLZXkABAZyZXN1bHQJAMwIAgkBC1N0cmluZ0VudHJ5AgkBGWtleUFjdGl2ZU1hbmFnZXJQdWJsaWNLZXkABRRwZW5kaW5nTWFuYWdlclN0cmluZwUDbmlsCQEMdm90ZUlOVEVSTkFMBQUTY2FsbGVyQWRkcmVzc1N0cmluZwUQYWRtaW5DdXJyZW50Vm90ZQUJa2V5UHJlZml4BQhtaW5Wb3RlcwUGcmVzdWx0AKSrpDs=", "height": 2541120, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: CbYhGEjzPX1JjdCuyLLsou7jLwXwBGooHPFCbrykkgar Next: AuvzskD8MwFkKqx5bFQTZaNAUMMDWoN3veyxzVpJpS9o Diff:
OldNewDifferences
6666
6767
6868 func genVotesKeysHelper (a,adminAddress) = {
69- let $t021322156 = a
70- let result = $t021322156._1
71- let prefix = $t021322156._2
69+ let $t021152139 = a
70+ let result = $t021152139._1
71+ let prefix = $t021152139._2
7272 $Tuple2((result :+ makeString([prefix, adminAddress], SEP)), prefix)
7373 }
7474
171171 @Callable(i)
172172 func voteForNewManger (newManagerPublicKey) = {
173173 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)
194174 let keyPrefix = keySetNewManagerVotePrefix(newManagerPublicKey)
195175 let adminCurrentVote = getSetNewManagerVote(newManagerPublicKey, callerAddressString)
196176 let minVotes = 2
203183 @Callable(i)
204184 func deactivateManager () = {
205185 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)
219191 }
220192
221193
223195 @Callable(i)
224196 func activateManager () = {
225197 let callerAddressString = toBase58String(i.caller.bytes)
198+ let keyPrefix = keyActivateManagerVotePrefix()
199+ let adminCurrentVote = getActivateManagerVote(callerAddressString)
200+ let minVotes = 2
226201 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)
240204 }
241205
242206
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let SEP = "__"
55
66 let contractFilename = "manager_vault.ride"
77
88 func throwErr (s) = throw(((contractFilename + ": ") + s))
99
1010
1111 func keyActiveManagerPublicKey () = makeString(["%s", "managerPublicKey"], SEP)
1212
1313
1414 func keyPendingManagerPublicKey () = makeString(["%s", "pendingManagerPublicKey"], SEP)
1515
1616
1717 func keySetNewManagerVotePrefix (managerPublicKey) = makeString(["%s%s%s", "setManager", managerPublicKey], SEP)
1818
1919
2020 func keySetNewManagerVote (managerPublicKey,admin) = makeString([keySetNewManagerVotePrefix(managerPublicKey), admin], SEP)
2121
2222
2323 func getSetNewManagerVote (managerPublicKey,admin) = valueOrElse(getInteger(keySetNewManagerVote(managerPublicKey, admin)), 0)
2424
2525
2626 func keyDeactivateManagerVotePrefix () = makeString(["%s%s", "deactivateManager"], SEP)
2727
2828
2929 func keyDeactivateManagerVote (admin) = makeString([keyDeactivateManagerVotePrefix(), admin], SEP)
3030
3131
3232 func getDeactivateManagerVote (admin) = valueOrElse(getInteger(keyDeactivateManagerVote(admin)), 0)
3333
3434
3535 func keyActivateManagerVotePrefix () = makeString(["%s%s", "activateManager"], SEP)
3636
3737
3838 func keyActivateManagerVote (admin) = makeString([keyActivateManagerVotePrefix(), admin], SEP)
3939
4040
4141 func getActivateManagerVote (admin) = valueOrElse(getInteger(keyActivateManagerVote(admin)), 0)
4242
4343
4444 func keyAdminAdressList () = makeString(["%s", "adminAddressList"], SEP)
4545
4646
4747 func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) {
4848 case s: String =>
4949 fromBase58String(s)
5050 case _: Unit =>
5151 unit
5252 case _ =>
5353 throw("Match error")
5454 }
5555
5656
5757 func getAdminsList () = split(valueOrElse(getString(this, keyAdminAdressList()), ""), SEP)
5858
5959
6060 func isInAdminList (address) = match indexOf(getAdminsList(), address) {
6161 case t: Int =>
6262 true
6363 case _ =>
6464 false
6565 }
6666
6767
6868 func genVotesKeysHelper (a,adminAddress) = {
69- let $t021322156 = a
70- let result = $t021322156._1
71- let prefix = $t021322156._2
69+ let $t021152139 = a
70+ let result = $t021152139._1
71+ let prefix = $t021152139._2
7272 $Tuple2((result :+ makeString([prefix, adminAddress], SEP)), prefix)
7373 }
7474
7575
7676 func genVotesKeys (keyPrefix) = {
7777 let adminList = keyAdminAdressList()
7878 let $l = getAdminsList()
7979 let $s = size($l)
8080 let $acc0 = $Tuple2(nil, keyPrefix)
8181 func $f0_1 ($a,$i) = if (($i >= $s))
8282 then $a
8383 else genVotesKeysHelper($a, $l[$i])
8484
8585 func $f0_2 ($a,$i) = if (($i >= $s))
8686 then $a
8787 else throw("List size exceeds 10")
8888
8989 $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)
9090 }
9191
9292
9393 func countVotesHelper (result,voteKey) = (result + valueOrElse(getInteger(voteKey), 0))
9494
9595
9696 func countVotes (prefix) = {
9797 let votes = genVotesKeys(prefix)._1
9898 let $l = votes
9999 let $s = size($l)
100100 let $acc0 = 0
101101 func $f0_1 ($a,$i) = if (($i >= $s))
102102 then $a
103103 else countVotesHelper($a, $l[$i])
104104
105105 func $f0_2 ($a,$i) = if (($i >= $s))
106106 then $a
107107 else throw("List size exceeds 10")
108108
109109 $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)
110110 }
111111
112112
113113 func clearVotesHelper (result,key) = (result :+ DeleteEntry(key))
114114
115115
116116 func getClearVotesEntries (prefix) = {
117117 let votes = genVotesKeys(prefix)._1
118118 let $l = votes
119119 let $s = size($l)
120120 let $acc0 = nil
121121 func $f0_1 ($a,$i) = if (($i >= $s))
122122 then $a
123123 else clearVotesHelper($a, $l[$i])
124124
125125 func $f0_2 ($a,$i) = if (($i >= $s))
126126 then $a
127127 else throw("List size exceeds 10")
128128
129129 $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)
130130 }
131131
132132
133133 func voteINTERNAL (callerAddressString,adminCurrentVote,keyPrefix,minVotes,voteResult) = {
134134 let voteKey = makeString([keyPrefix, callerAddressString], SEP)
135135 if (isInAdminList(callerAddressString))
136136 then if ((adminCurrentVote == 1))
137137 then throwErr((voteKey + " you already voted"))
138138 else {
139139 let votes = countVotes(keyPrefix)
140140 if (((votes + 1) >= minVotes))
141141 then {
142142 let clearVotesEntries = getClearVotesEntries(keyPrefix)
143143 (clearVotesEntries ++ voteResult)
144144 }
145145 else [IntegerEntry(voteKey, 1)]
146146 }
147147 else throwErr((("Address: " + callerAddressString) + " not in Admin list"))
148148 }
149149
150150
151151 @Callable(i)
152152 func confirmManager () = {
153153 let pm = pendingManagerPublicKeyOrUnit()
154154 let hasPM = if (isDefined(pm))
155155 then true
156156 else throwErr("no pending manager")
157157 if ((hasPM == hasPM))
158158 then {
159159 let checkPM = if ((i.callerPublicKey == value(pm)))
160160 then true
161161 else throwErr("you are not pending manager")
162162 if ((checkPM == checkPM))
163163 then [StringEntry(keyActiveManagerPublicKey(), toBase58String(value(pm)))]
164164 else throw("Strict value is not equal to itself.")
165165 }
166166 else throw("Strict value is not equal to itself.")
167167 }
168168
169169
170170
171171 @Callable(i)
172172 func voteForNewManger (newManagerPublicKey) = {
173173 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)
194174 let keyPrefix = keySetNewManagerVotePrefix(newManagerPublicKey)
195175 let adminCurrentVote = getSetNewManagerVote(newManagerPublicKey, callerAddressString)
196176 let minVotes = 2
197177 let result = [StringEntry(keyPendingManagerPublicKey(), newManagerPublicKey)]
198178 voteINTERNAL(callerAddressString, adminCurrentVote, keyPrefix, minVotes, result)
199179 }
200180
201181
202182
203183 @Callable(i)
204184 func deactivateManager () = {
205185 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)
219191 }
220192
221193
222194
223195 @Callable(i)
224196 func activateManager () = {
225197 let callerAddressString = toBase58String(i.caller.bytes)
198+ let keyPrefix = keyActivateManagerVotePrefix()
199+ let adminCurrentVote = getActivateManagerVote(callerAddressString)
200+ let minVotes = 2
226201 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)
240204 }
241205
242206

github/deemru/w8io/026f985 
31.89 ms