tx · 7BK5NEpKKb9KsNjL8JqQC8Q3wm6RtTVWUdtHNubdbBHz

3PHdaP2BLUXFacnqZm6WoFjidvzqZZMbb8j:  -0.01000000 Waves

2023.04.25 18:07 [3615825] smart account 3PHdaP2BLUXFacnqZm6WoFjidvzqZZMbb8j > SELF 0.00000000 Waves

{ "type": 13, "id": "7BK5NEpKKb9KsNjL8JqQC8Q3wm6RtTVWUdtHNubdbBHz", "fee": 1000000, "feeAssetId": null, "timestamp": 1682431826589, "version": 2, "chainId": 87, "sender": "3PHdaP2BLUXFacnqZm6WoFjidvzqZZMbb8j", "senderPublicKey": "9LFA81VdbMx4PkgVkqY7mAZt9NqkKxPLH1qdzQbASaC6", "proofs": [ "5RBPexZeQM7ofYzcAKeGxZuL86t6ni2QHqqtt14hMgHJSbpuHsSyXdMaPg5uy5XLzRSq8thw2GMGnXPpXkdmBwgJ" ], "script": null, "height": 3615825, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: FRRYLooEV9h47AkPM6AC3XCdyq4kQeBU1ayVsXfrUuLu Next: 4hGPKytavtwcYhzDSMcNJBxRCTMskwbvK3BLieUMY7sU Full:
OldNewDifferences
1-{-# STDLIB_VERSION 6 #-}
2-{-# SCRIPT_TYPE ACCOUNT #-}
3-{-# CONTENT_TYPE DAPP #-}
4-let SEP = "__"
5-
6-let contractFilename = "manager_vault.ride"
7-
8-let MAX_ADMIN_LIST_SIZE = 10
9-
10-let MIN_ADMIN_LIST_SIZE = 2
11-
12-let ADDRESS_BYTES_LENGTH = 26
13-
14-let TXID_BYTES_LENGTH = 32
15-
16-func throwErr (s) = throw(((contractFilename + ": ") + s))
17-
18-
19-func keyActiveManagerPublicKey () = makeString(["%s", "managerPublicKey"], SEP)
20-
21-
22-func keyPendingManagerPublicKey () = makeString(["%s", "pendingManagerPublicKey"], SEP)
23-
24-
25-func keyCurrentManagerPublicKey () = makeString(["%s", "currentManagerPublicKey"], SEP)
26-
27-
28-func keySetNewManagerVotePrefix (managerPublicKey) = makeString(["%s%s%s", "setManager", managerPublicKey], SEP)
29-
30-
31-func keyDeactivateManagerVotePrefix () = makeString(["%s%s", "deactivateManager"], SEP)
32-
33-
34-func keyActivateManagerVotePrefix () = makeString(["%s%s", "activateManager"], SEP)
35-
36-
37-func keyAddNewAdminVotePrefix (adminCandidate) = makeString(["%s%s%s", "addAdmin", adminCandidate], SEP)
38-
39-
40-func keyRemoveAdminVotePrefix (removeCandidate) = makeString(["%s%s%s", "removeAdmin", removeCandidate], SEP)
41-
42-
43-func keyAllowedTxIdVotePrefix (txId) = makeString(["%s%s%s", "allowTxId", txId], SEP)
44-
45-
46-func keyFullAdminVote (prefix,adminAddress) = makeString([prefix, adminAddress], SEP)
47-
48-
49-func keyAdminAddressList () = makeString(["%s", "adminAddressList"], SEP)
50-
51-
52-func keyAllowedTxId () = makeString(["%s", "TXID"], SEP)
53-
54-
55-func getAdminVote (prefix,admin) = {
56- let voteKey = keyFullAdminVote(prefix, admin)
57- valueOrElse(getInteger(voteKey), 0)
58- }
59-
60-
61-func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) {
62- case s: String =>
63- fromBase58String(s)
64- case _: Unit =>
65- unit
66- case _ =>
67- throw("Match error")
68-}
69-
70-
71-func getAdminsList () = match getString(this, keyAdminAddressList()) {
72- case s: String =>
73- split(s, SEP)
74- case _ =>
75- nil
76-}
77-
78-
79-func isInAdminList (address) = containsElement(getAdminsList(), address)
80-
81-
82-func genVotesKeysHelper (a,adminAddress) = {
83- let $t022422266 = a
84- let result = $t022422266._1
85- let prefix = $t022422266._2
86- $Tuple2((result :+ keyFullAdminVote(prefix, adminAddress)), prefix)
87- }
88-
89-
90-func genVotesKeys (keyPrefix) = {
91- let adminList = keyAdminAddressList()
92- let $l = getAdminsList()
93- let $s = size($l)
94- let $acc0 = $Tuple2(nil, keyPrefix)
95- func $f0_1 ($a,$i) = if (($i >= $s))
96- then $a
97- else genVotesKeysHelper($a, $l[$i])
98-
99- func $f0_2 ($a,$i) = if (($i >= $s))
100- then $a
101- else throw("List size exceeds 20")
102-
103- $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($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), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20)
104- }
105-
106-
107-func countVotesHelper (result,voteKey) = (result + valueOrElse(getInteger(voteKey), 0))
108-
109-
110-func countVotes (prefix) = {
111- let votes = genVotesKeys(prefix)._1
112- let $l = votes
113- let $s = size($l)
114- let $acc0 = 0
115- func $f0_1 ($a,$i) = if (($i >= $s))
116- then $a
117- else countVotesHelper($a, $l[$i])
118-
119- func $f0_2 ($a,$i) = if (($i >= $s))
120- then $a
121- else throw("List size exceeds 20")
122-
123- $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($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), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20)
124- }
125-
126-
127-func clearVotesHelper (result,key) = (result :+ DeleteEntry(key))
128-
129-
130-func getClearVoteEntries (prefix) = {
131- let votes = genVotesKeys(prefix)._1
132- let $l = votes
133- let $s = size($l)
134- let $acc0 = nil
135- func $f0_1 ($a,$i) = if (($i >= $s))
136- then $a
137- else clearVotesHelper($a, $l[$i])
138-
139- func $f0_2 ($a,$i) = if (($i >= $s))
140- then $a
141- else throw("List size exceeds 20")
142-
143- $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($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), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20)
144- }
145-
146-
147-func voteINTERNAL (callerAddressString,keyPrefix,minVotes,voteResult) = {
148- let voteKey = keyFullAdminVote(keyPrefix, callerAddressString)
149- let adminCurrentVote = getAdminVote(keyPrefix, callerAddressString)
150- let err = if (!(isInAdminList(callerAddressString)))
151- then throwErr((("Address: " + callerAddressString) + " not in Admin list"))
152- else if ((adminCurrentVote == 1))
153- then throwErr((voteKey + " you already voted"))
154- else unit
155- if ((err == err))
156- then {
157- let votes = countVotes(keyPrefix)
158- if (((votes + 1) >= minVotes))
159- then {
160- let clearVoteEntries = getClearVoteEntries(keyPrefix)
161- (clearVoteEntries ++ voteResult)
162- }
163- else [IntegerEntry(voteKey, 1)]
164- }
165- else throw("Strict value is not equal to itself.")
166- }
167-
168-
169-@Callable(i)
170-func confirmManager () = {
171- let pm = pendingManagerPublicKeyOrUnit()
172- let hasPM = if (isDefined(pm))
173- then true
174- else throwErr("no pending manager")
175- if ((hasPM == hasPM))
176- then {
177- let checkPM = if ((i.callerPublicKey == value(pm)))
178- then true
179- else throwErr("you are not pending manager")
180- if ((checkPM == checkPM))
181- then [StringEntry(keyCurrentManagerPublicKey(), toBase58String(value(pm))), StringEntry(keyActiveManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())]
182- else throw("Strict value is not equal to itself.")
183- }
184- else throw("Strict value is not equal to itself.")
185- }
186-
187-
188-
189-@Callable(i)
190-func voteForNewManager (newManagerPublicKey) = {
191- let callerAddressString = toBase58String(i.caller.bytes)
192- let keyPrefix = keySetNewManagerVotePrefix(newManagerPublicKey)
193- let quorum = 2
194- let result = [StringEntry(keyPendingManagerPublicKey(), newManagerPublicKey)]
195- voteINTERNAL(callerAddressString, keyPrefix, quorum, result)
196- }
197-
198-
199-
200-@Callable(i)
201-func deactivateManager () = {
202- let callerAddressString = toBase58String(i.caller.bytes)
203- let keyPrefix = keyDeactivateManagerVotePrefix()
204- let quorum = 1
205- let result = [StringEntry(keyActiveManagerPublicKey(), "disabled")]
206- voteINTERNAL(callerAddressString, keyPrefix, quorum, result)
207- }
208-
209-
210-
211-@Callable(i)
212-func activateManager () = {
213- let callerAddressString = toBase58String(i.caller.bytes)
214- let keyPrefix = keyActivateManagerVotePrefix()
215- let quorum = 2
216- let currentManagerString = getStringValue(keyCurrentManagerPublicKey())
217- let result = [StringEntry(keyActiveManagerPublicKey(), currentManagerString)]
218- voteINTERNAL(callerAddressString, keyPrefix, quorum, result)
219- }
220-
221-
222-
223-@Callable(i)
224-func addNewAdmin (newAdminAddress) = {
225- let callerAddressString = toBase58String(i.caller.bytes)
226- let keyPrefix = keyAddNewAdminVotePrefix(newAdminAddress)
227- let quorum = 2
228- let currentAdminList = getAdminsList()
229- let err = if ((size(currentAdminList) >= MAX_ADMIN_LIST_SIZE))
230- then throwErr((("MAX_ADMIN_LIST_SIZE (" + toString(MAX_ADMIN_LIST_SIZE)) + ") is exceeded"))
231- else if ((size(fromBase58String(newAdminAddress)) != ADDRESS_BYTES_LENGTH))
232- then throwErr((newAdminAddress + " is not valid Address"))
233- else unit
234- if ((err == err))
235- then match indexOf(currentAdminList, newAdminAddress) {
236- case a: Int =>
237- throwErr((newAdminAddress + " already in Admin List"))
238- case _ =>
239- let newAdminList = (currentAdminList :+ newAdminAddress)
240- let result = [StringEntry(keyAdminAddressList(), makeString(newAdminList, SEP))]
241- voteINTERNAL(callerAddressString, keyPrefix, quorum, result)
242- }
243- else throw("Strict value is not equal to itself.")
244- }
245-
246-
247-
248-@Callable(i)
249-func removeAdmin (removeCandidate) = {
250- let callerAddressString = toBase58String(i.caller.bytes)
251- let keyPrefix = keyRemoveAdminVotePrefix(removeCandidate)
252- let quorum = 2
253- let currentAdminList = getAdminsList()
254- match indexOf(currentAdminList, removeCandidate) {
255- case index: Int =>
256- let newAdminList = removeByIndex(currentAdminList, index)
257- let result = [StringEntry(keyAdminAddressList(), makeString(newAdminList, SEP))]
258- voteINTERNAL(callerAddressString, keyPrefix, quorum, result)
259- case _ =>
260- throwErr((removeCandidate + " not found in Admin List"))
261- }
262- }
263-
264-
265-
266-@Callable(i)
267-func voteForTxId (txId) = {
268- let callerAddressString = toBase58String(i.caller.bytes)
269- let keyPrefix = keyAllowedTxIdVotePrefix(txId)
270- let quorum = 2
271- let result = [StringEntry(keyAllowedTxId(), txId)]
272- let err = if ((size(fromBase58String(txId)) != TXID_BYTES_LENGTH))
273- then throwErr((txId + " not valid txId"))
274- else unit
275- if ((err == err))
276- then voteINTERNAL(callerAddressString, keyPrefix, quorum, result)
277- else throw("Strict value is not equal to itself.")
278- }
279-
280-
281-@Verifier(tx)
282-func verify () = {
283- let allowedTxId = fromBase58String(getStringValue(keyAllowedTxId()))
284- let currentAdminList = getAdminsList()
285- if ((size(currentAdminList) >= MIN_ADMIN_LIST_SIZE))
286- then (tx.id == allowedTxId)
287- else sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
288- }
289-
1+# no script

github/deemru/w8io/3ef1775 
34.32 ms