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:BgISCAISABIDCgEIEgASABIDCgEIHAADU0VQAgJfXwAQY29udHJhY3RGaWxlbmFtZQISbWFuYWdlcl92YXVsdC5yaWRlAQh0aHJvd0VycgEBcwkAAgEJAKwCAgkArAICBRBjb250cmFjdEZpbGVuYW1lAgI6IAUBcwEZa2V5QWN0aXZlTWFuYWdlclB1YmxpY0tleQAJALkJAgkAzAgCAgIlcwkAzAgCAhBtYW5hZ2VyUHVibGljS2V5BQNuaWwFA1NFUAEaa2V5UGVuZGluZ01hbmFnZXJQdWJsaWNLZXkACQC5CQIJAMwIAgICJXMJAMwIAgIXcGVuZGluZ01hbmFnZXJQdWJsaWNLZXkFA25pbAUDU0VQARprZXlTZXROZXdNYW5hZ2VyVm90ZVByZWZpeAEQbWFuYWdlclB1YmxpY0tleQkAuQkCCQDMCAICBiVzJXMlcwkAzAgCAgpzZXRNYW5hZ2VyCQDMCAIFEG1hbmFnZXJQdWJsaWNLZXkFA25pbAUDU0VQARRrZXlTZXROZXdNYW5hZ2VyVm90ZQIQbWFuYWdlclB1YmxpY0tleQVhZG1pbgkAuQkCCQDMCAIJ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JpbmdFbnRyeQIJARlrZXlBY3RpdmVNYW5hZ2VyUHVibGljS2V5AAUUcGVuZGluZ01hbmFnZXJTdHJpbmcFA25pbAkBDHZvdGVJTlRFUk5BTAUFE2NhbGxlckFkZHJlc3NTdHJpbmcFEGFkbWluQ3VycmVudFZvdGUFCWtleVByZWZpeAUIbWluVm90ZXMFBnJlc3VsdAFpAQthZGROZXdBZG1pbgEPbmV3QWRtaW5BZGRyZXNzBBNjYWxsZXJBZGRyZXNzU3RyaW5nCQDYBAEICAUBaQZjYWxsZXIFYnl0ZXMECWtleVByZWZpeAkBGGtleUFkZE5ld0FkbWluVm90ZVByZWZpeAEFD25ld0FkbWluQWRkcmVzcwQQYWRtaW5DdXJyZW50Vm90ZQkBEmdldEFkZE5ld0FkbWluVm90ZQIFD25ld0FkbWluQWRkcmVzcwUTY2FsbGVyQWRkcmVzc1N0cmluZwQIbWluVm90ZXMAAgQQY3VycmVudEFkbWluTGlzdAkBDWdldEFkbWluc0xpc3QAAwkAAAIFEGN1cnJlbnRBZG1pbkxpc3QFEGN1cnJlbnRBZG1pbkxpc3QEDG5ld0FkbWluTGlzdAkAzQgCBRBjdXJyZW50QWRtaW5MaXN0BQ9uZXdBZG1pbkFkZHJlc3MEBnJlc3VsdAkAzAgCCQELU3RyaW5nRW50cnkCCQETa2V5QWRtaW5BZGRyZXNzTGlzdAAJALkJAgUMbmV3QWRtaW5MaXN0BQNTRVAFA25pbAkBDHZvdGVJTlRFUk5BTAUFE2NhbGxlckFkZHJlc3NTdHJpbmcFEGFkbWluQ3VycmVudFZvdGUFCWtleVByZWZpeAUIbWluVm90ZXMFBnJlc3VsdAkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgDljlSb", "height": 2541137, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 4e9cB1djkmziMs3DjQ2dypH3YCvNrXtjWbwAA1eggF29 Next: DcHiV3kYZomWmkQ9UsFEBFQPKqDpHrkXwYrfSkd472FG Diff:
OldNewDifferences
4141 func getActivateManagerVote (admin) = valueOrElse(getInteger(keyActivateManagerVote(admin)), 0)
4242
4343
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)
4554
4655
4756 func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) {
5463 }
5564
5665
57-func getAdminsList () = split(valueOrElse(getString(this, keyAdminAdressList()), ""), SEP)
66+func getAdminsList () = split(valueOrElse(getString(this, keyAdminAddressList()), ""), SEP)
5867
5968
6069 func isInAdminList (address) = match indexOf(getAdminsList(), address) {
6675
6776
6877 func genVotesKeysHelper (a,adminAddress) = {
69- let $t021152139 = a
70- let result = $t021152139._1
71- let prefix = $t021152139._2
78+ let $t024972521 = a
79+ let result = $t024972521._1
80+ let prefix = $t024972521._2
7281 $Tuple2((result :+ makeString([prefix, adminAddress], SEP)), prefix)
7382 }
7483
7584
7685 func genVotesKeys (keyPrefix) = {
77- let adminList = keyAdminAdressList()
86+ let adminList = keyAdminAddressList()
7887 let $l = getAdminsList()
7988 let $s = size($l)
8089 let $acc0 = $Tuple2(nil, keyPrefix)
204213 }
205214
206215
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+
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
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)
4554
4655
4756 func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) {
4857 case s: String =>
4958 fromBase58String(s)
5059 case _: Unit =>
5160 unit
5261 case _ =>
5362 throw("Match error")
5463 }
5564
5665
57-func getAdminsList () = split(valueOrElse(getString(this, keyAdminAdressList()), ""), SEP)
66+func getAdminsList () = split(valueOrElse(getString(this, keyAdminAddressList()), ""), SEP)
5867
5968
6069 func isInAdminList (address) = match indexOf(getAdminsList(), address) {
6170 case t: Int =>
6271 true
6372 case _ =>
6473 false
6574 }
6675
6776
6877 func genVotesKeysHelper (a,adminAddress) = {
69- let $t021152139 = a
70- let result = $t021152139._1
71- let prefix = $t021152139._2
78+ let $t024972521 = a
79+ let result = $t024972521._1
80+ let prefix = $t024972521._2
7281 $Tuple2((result :+ makeString([prefix, adminAddress], SEP)), prefix)
7382 }
7483
7584
7685 func genVotesKeys (keyPrefix) = {
77- let adminList = keyAdminAdressList()
86+ let adminList = keyAdminAddressList()
7887 let $l = getAdminsList()
7988 let $s = size($l)
8089 let $acc0 = $Tuple2(nil, keyPrefix)
8190 func $f0_1 ($a,$i) = if (($i >= $s))
8291 then $a
8392 else genVotesKeysHelper($a, $l[$i])
8493
8594 func $f0_2 ($a,$i) = if (($i >= $s))
8695 then $a
8796 else throw("List size exceeds 10")
8897
8998 $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)
9099 }
91100
92101
93102 func countVotesHelper (result,voteKey) = (result + valueOrElse(getInteger(voteKey), 0))
94103
95104
96105 func countVotes (prefix) = {
97106 let votes = genVotesKeys(prefix)._1
98107 let $l = votes
99108 let $s = size($l)
100109 let $acc0 = 0
101110 func $f0_1 ($a,$i) = if (($i >= $s))
102111 then $a
103112 else countVotesHelper($a, $l[$i])
104113
105114 func $f0_2 ($a,$i) = if (($i >= $s))
106115 then $a
107116 else throw("List size exceeds 10")
108117
109118 $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)
110119 }
111120
112121
113122 func clearVotesHelper (result,key) = (result :+ DeleteEntry(key))
114123
115124
116125 func getClearVotesEntries (prefix) = {
117126 let votes = genVotesKeys(prefix)._1
118127 let $l = votes
119128 let $s = size($l)
120129 let $acc0 = nil
121130 func $f0_1 ($a,$i) = if (($i >= $s))
122131 then $a
123132 else clearVotesHelper($a, $l[$i])
124133
125134 func $f0_2 ($a,$i) = if (($i >= $s))
126135 then $a
127136 else throw("List size exceeds 10")
128137
129138 $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)
130139 }
131140
132141
133142 func voteINTERNAL (callerAddressString,adminCurrentVote,keyPrefix,minVotes,voteResult) = {
134143 let voteKey = makeString([keyPrefix, callerAddressString], SEP)
135144 if (isInAdminList(callerAddressString))
136145 then if ((adminCurrentVote == 1))
137146 then throwErr((voteKey + " you already voted"))
138147 else {
139148 let votes = countVotes(keyPrefix)
140149 if (((votes + 1) >= minVotes))
141150 then {
142151 let clearVotesEntries = getClearVotesEntries(keyPrefix)
143152 (clearVotesEntries ++ voteResult)
144153 }
145154 else [IntegerEntry(voteKey, 1)]
146155 }
147156 else throwErr((("Address: " + callerAddressString) + " not in Admin list"))
148157 }
149158
150159
151160 @Callable(i)
152161 func confirmManager () = {
153162 let pm = pendingManagerPublicKeyOrUnit()
154163 let hasPM = if (isDefined(pm))
155164 then true
156165 else throwErr("no pending manager")
157166 if ((hasPM == hasPM))
158167 then {
159168 let checkPM = if ((i.callerPublicKey == value(pm)))
160169 then true
161170 else throwErr("you are not pending manager")
162171 if ((checkPM == checkPM))
163172 then [StringEntry(keyActiveManagerPublicKey(), toBase58String(value(pm)))]
164173 else throw("Strict value is not equal to itself.")
165174 }
166175 else throw("Strict value is not equal to itself.")
167176 }
168177
169178
170179
171180 @Callable(i)
172181 func voteForNewManger (newManagerPublicKey) = {
173182 let callerAddressString = toBase58String(i.caller.bytes)
174183 let keyPrefix = keySetNewManagerVotePrefix(newManagerPublicKey)
175184 let adminCurrentVote = getSetNewManagerVote(newManagerPublicKey, callerAddressString)
176185 let minVotes = 2
177186 let result = [StringEntry(keyPendingManagerPublicKey(), newManagerPublicKey)]
178187 voteINTERNAL(callerAddressString, adminCurrentVote, keyPrefix, minVotes, result)
179188 }
180189
181190
182191
183192 @Callable(i)
184193 func deactivateManager () = {
185194 let callerAddressString = toBase58String(i.caller.bytes)
186195 let keyPrefix = keyDeactivateManagerVotePrefix()
187196 let adminCurrentVote = getDeactivateManagerVote(callerAddressString)
188197 let minVotes = 1
189198 let result = [DeleteEntry(keyActiveManagerPublicKey())]
190199 voteINTERNAL(callerAddressString, adminCurrentVote, keyPrefix, minVotes, result)
191200 }
192201
193202
194203
195204 @Callable(i)
196205 func activateManager () = {
197206 let callerAddressString = toBase58String(i.caller.bytes)
198207 let keyPrefix = keyActivateManagerVotePrefix()
199208 let adminCurrentVote = getActivateManagerVote(callerAddressString)
200209 let minVotes = 2
201210 let pendingManagerString = getStringValue(keyPendingManagerPublicKey())
202211 let result = [StringEntry(keyActiveManagerPublicKey(), pendingManagerString)]
203212 voteINTERNAL(callerAddressString, adminCurrentVote, keyPrefix, minVotes, result)
204213 }
205214
206215
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