tx · FDPpxPPdueCYML14qes544JqGwPcPSJLeD4TnXptmcQM

3N4ziXSMRverXyxHDUKKMR9MHXnB3TyU3Yh:  -0.01400000 Waves

2023.05.17 10:19 [2581647] smart account 3N4ziXSMRverXyxHDUKKMR9MHXnB3TyU3Yh > SELF 0.00000000 Waves

{ "type": 13, "id": "FDPpxPPdueCYML14qes544JqGwPcPSJLeD4TnXptmcQM", "fee": 1400000, "feeAssetId": null, "timestamp": 1684307982771, "version": 2, "chainId": 84, "sender": "3N4ziXSMRverXyxHDUKKMR9MHXnB3TyU3Yh", "senderPublicKey": "EU9obW1yVhR8qug3EmXPeew3DMagvJFQzY5Ku8bmcsU7", "proofs": [ "4k72uXnbaEoFAAW5bDrVVbQHBKKWkk1aoptV8vctnUCLqRP17FQ1Z4XXHEgsBdXjdHakvTCc1d3mdXGbwdFKa9XD" ], "script": null, "height": 2581647, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: A6sTKhNUTqP25qpY3ZPPWi9siUF7KqaHvctGjiWXWn3Q Next: 47nzm6AAKnKAJasEPmtWrWoz35E9SfLvbWT3s1Na8xmQ 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 () = split(valueOrElse(getString(this, keyAdminAddressList()), ""), SEP)
72-
73-
74-func isInAdminList (address) = containsElement(getAdminsList(), address)
75-
76-
77-func genVotesKeysHelper (a,adminAddress) = {
78- let $t021982222 = a
79- let result = $t021982222._1
80- let prefix = $t021982222._2
81- $Tuple2((result :+ keyFullAdminVote(prefix, adminAddress)), prefix)
82- }
83-
84-
85-func genVotesKeys (keyPrefix) = {
86- let adminList = keyAdminAddressList()
87- let $l = getAdminsList()
88- let $s = size($l)
89- let $acc0 = $Tuple2(nil, keyPrefix)
90- func $f0_1 ($a,$i) = if (($i >= $s))
91- then $a
92- else genVotesKeysHelper($a, $l[$i])
93-
94- func $f0_2 ($a,$i) = if (($i >= $s))
95- then $a
96- else throw("List size exceeds 20")
97-
98- $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)
99- }
100-
101-
102-func countVotesHelper (result,voteKey) = (result + valueOrElse(getInteger(voteKey), 0))
103-
104-
105-func countVotes (prefix) = {
106- let votes = genVotesKeys(prefix)._1
107- let $l = votes
108- let $s = size($l)
109- let $acc0 = 0
110- func $f0_1 ($a,$i) = if (($i >= $s))
111- then $a
112- else countVotesHelper($a, $l[$i])
113-
114- func $f0_2 ($a,$i) = if (($i >= $s))
115- then $a
116- else throw("List size exceeds 20")
117-
118- $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)
119- }
120-
121-
122-func clearVotesHelper (result,key) = (result :+ DeleteEntry(key))
123-
124-
125-func getClearVoteEntries (prefix) = {
126- let votes = genVotesKeys(prefix)._1
127- let $l = votes
128- let $s = size($l)
129- let $acc0 = nil
130- func $f0_1 ($a,$i) = if (($i >= $s))
131- then $a
132- else clearVotesHelper($a, $l[$i])
133-
134- func $f0_2 ($a,$i) = if (($i >= $s))
135- then $a
136- else throw("List size exceeds 20")
137-
138- $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)
139- }
140-
141-
142-func voteINTERNAL (callerAddressString,keyPrefix,minVotes,voteResult) = {
143- let voteKey = keyFullAdminVote(keyPrefix, callerAddressString)
144- let adminCurrentVote = getAdminVote(keyPrefix, callerAddressString)
145- let err = if (!(isInAdminList(callerAddressString)))
146- then throwErr((("Address: " + callerAddressString) + " not in Admin list"))
147- else if ((adminCurrentVote == 1))
148- then throwErr((voteKey + " you already voted"))
149- else unit
150- if ((err == err))
151- then {
152- let votes = countVotes(keyPrefix)
153- if (((votes + 1) >= minVotes))
154- then {
155- let clearVoteEntries = getClearVoteEntries(keyPrefix)
156- (clearVoteEntries ++ voteResult)
157- }
158- else [IntegerEntry(voteKey, 1)]
159- }
160- else throw("Strict value is not equal to itself.")
161- }
162-
163-
164-@Callable(i)
165-func confirmManager () = {
166- let pm = pendingManagerPublicKeyOrUnit()
167- let hasPM = if (isDefined(pm))
168- then true
169- else throwErr("no pending manager")
170- if ((hasPM == hasPM))
171- then {
172- let checkPM = if ((i.callerPublicKey == value(pm)))
173- then true
174- else throwErr("you are not pending manager")
175- if ((checkPM == checkPM))
176- then [StringEntry(keyCurrentManagerPublicKey(), toBase58String(value(pm))), StringEntry(keyActiveManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())]
177- else throw("Strict value is not equal to itself.")
178- }
179- else throw("Strict value is not equal to itself.")
180- }
181-
182-
183-
184-@Callable(i)
185-func voteForNewManager (newManagerPublicKey) = {
186- let callerAddressString = toBase58String(i.caller.bytes)
187- let keyPrefix = keySetNewManagerVotePrefix(newManagerPublicKey)
188- let quorum = 2
189- let result = [StringEntry(keyPendingManagerPublicKey(), newManagerPublicKey)]
190- voteINTERNAL(callerAddressString, keyPrefix, quorum, result)
191- }
192-
193-
194-
195-@Callable(i)
196-func deactivateManager () = {
197- let callerAddressString = toBase58String(i.caller.bytes)
198- let keyPrefix = keyDeactivateManagerVotePrefix()
199- let quorum = 1
200- let result = [StringEntry(keyActiveManagerPublicKey(), "disabled")]
201- voteINTERNAL(callerAddressString, keyPrefix, quorum, result)
202- }
203-
204-
205-
206-@Callable(i)
207-func activateManager () = {
208- let callerAddressString = toBase58String(i.caller.bytes)
209- let keyPrefix = keyActivateManagerVotePrefix()
210- let quorum = 2
211- let currentManagerString = getStringValue(keyCurrentManagerPublicKey())
212- let result = [StringEntry(keyActiveManagerPublicKey(), currentManagerString)]
213- voteINTERNAL(callerAddressString, keyPrefix, quorum, result)
214- }
215-
216-
217-
218-@Callable(i)
219-func addNewAdmin (newAdminAddress) = {
220- let callerAddressString = toBase58String(i.caller.bytes)
221- let keyPrefix = keyAddNewAdminVotePrefix(newAdminAddress)
222- let quorum = 2
223- let currentAdminList = getAdminsList()
224- let err = if ((size(currentAdminList) >= MAX_ADMIN_LIST_SIZE))
225- then throwErr((("MAX_ADMIN_LIST_SIZE (" + toString(MAX_ADMIN_LIST_SIZE)) + ") is exceeded"))
226- else if ((size(fromBase58String(newAdminAddress)) != ADDRESS_BYTES_LENGTH))
227- then throwErr((newAdminAddress + " is not valid Address"))
228- else unit
229- if ((err == err))
230- then match indexOf(currentAdminList, newAdminAddress) {
231- case a: Int =>
232- throwErr((newAdminAddress + " already in Admin List"))
233- case _ =>
234- let newAdminList = (currentAdminList :+ newAdminAddress)
235- let result = [StringEntry(keyAdminAddressList(), makeString(newAdminList, SEP))]
236- voteINTERNAL(callerAddressString, keyPrefix, quorum, result)
237- }
238- else throw("Strict value is not equal to itself.")
239- }
240-
241-
242-
243-@Callable(i)
244-func removeAdmin (removeCandidate) = {
245- let callerAddressString = toBase58String(i.caller.bytes)
246- let keyPrefix = keyRemoveAdminVotePrefix(removeCandidate)
247- let quorum = 2
248- let currentAdminList = getAdminsList()
249- match indexOf(currentAdminList, removeCandidate) {
250- case index: Int =>
251- let newAdminList = removeByIndex(currentAdminList, index)
252- let result = [StringEntry(keyAdminAddressList(), makeString(newAdminList, SEP))]
253- voteINTERNAL(callerAddressString, keyPrefix, quorum, result)
254- case _ =>
255- throwErr((removeCandidate + " not found in Admin List"))
256- }
257- }
258-
259-
260-
261-@Callable(i)
262-func voteForTxId (txId) = {
263- let callerAddressString = toBase58String(i.caller.bytes)
264- let keyPrefix = keyAllowedTxIdVotePrefix(txId)
265- let quorum = 2
266- let result = [StringEntry(keyAllowedTxId(), txId)]
267- let err = if ((size(fromBase58String(txId)) != TXID_BYTES_LENGTH))
268- then throwErr((txId + " not valid txId"))
269- else unit
270- if ((err == err))
271- then voteINTERNAL(callerAddressString, keyPrefix, quorum, result)
272- else throw("Strict value is not equal to itself.")
273- }
274-
275-
276-@Verifier(tx)
277-func verify () = {
278- let allowedTxId = fromBase58String(getStringValue(keyAllowedTxId()))
279- match tx {
280- case t: SetScriptTransaction =>
281- sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
282- case t: DataTransaction =>
283- sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
284- case _ =>
285- let currentAdminList = getAdminsList()
286- if ((size(currentAdminList) >= MIN_ADMIN_LIST_SIZE))
287- then (tx.id == allowedTxId)
288- else sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
289- }
290- }
291-
1+# no script

github/deemru/w8io/026f985 
23.93 ms