tx · 7w3LiekoSYnp9pFo1CHWJfqkGP7bKDQgYTzJHgVC8cC7

3MynXwh1Q3aezKeXaEyg2QfQzVgdwkQGxJ3:  -0.01000000 Waves

2023.05.26 10:40 [2594655] smart account 3MynXwh1Q3aezKeXaEyg2QfQzVgdwkQGxJ3 > SELF 0.00000000 Waves

{ "type": 13, "id": "7w3LiekoSYnp9pFo1CHWJfqkGP7bKDQgYTzJHgVC8cC7", "fee": 1000000, "feeAssetId": null, "timestamp": 1685086717271, "version": 2, "chainId": 84, "sender": "3MynXwh1Q3aezKeXaEyg2QfQzVgdwkQGxJ3", "senderPublicKey": "FZDxiE5t9yzfQeT5bHVJxFwVhvfDGkYjJM8YeZCKn1HF", "proofs": [ "NzECfxfk5XzJzK7teurX7nMiK1d28V1aVEYcKDnfkY3HZtshpt6Lj9DYVpBxSKVvV1hxxaBwNKw1LSPY2a53ZWB" ], "script": "base64:BgIHCAISAwoBCBwAA1NFUAICX18AEGNvbnRyYWN0RmlsZW5hbWUCDXRyZWFzdXJ5LnJpZGUAD0FETUlOX0xJU1RfU0laRQAFAAZRVU9SVU0AAwARVFhJRF9CWVRFU19MRU5HVEgAIAEHd3JhcEVycgEBcwkArAICCQCsAgIFEGNvbnRyYWN0RmlsZW5hbWUCAjogBQFzAQh0aHJvd0VycgEBcwkAAgEJAQd3cmFwRXJyAQUBcwEYa2V5QWxsb3dlZFR4SWRWb3RlUHJlZml4AQR0eElkCQC5CQIJAMwIAgIGJXMlcyVzCQDMCAICCWFsbG93VHhJZAkAzAgCBQR0eElkBQNuaWwFA1NFUAEQa2V5RnVsbEFkbWluVm90ZQIGcHJlZml4DGFkbWluQWRkcmVzcwkAuQkCCQDMCAIFBnByZWZpeAkAzAgCBQxhZG1pbkFkZHJlc3MFA25pbAUDU0VQARNrZXlBZG1pbkFkZHJlc3NMaXN0AAkAuQkCCQDMCAICAiVzCQDMCAICEGFkbWluQWRkcmVzc0xpc3QFA25pbAUDU0VQAQ5rZXlBbGxvd2VkVHh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aWNLZXkDAwkBAiE9AgUTY29uZmlnQWRkcmVzc09wdGlvbgUEdW5pdAkAAAIJAJADAQUQY3VycmVudEFkbWluTGlzdAUPQURNSU5fTElTVF9TSVpFBwMDCQECIT0CBRp2b3RpbmdSZXN1bHRDb250cmFjdE9wdGlvbgUEdW5pdAUKYnlQcm9wb3NhbAcGBQhieUFkbWlucwUHYnlPd25lcu4IJF8=", "height": 2594655, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 7nKtt6LMW7JhHVgixQoGwfZcUu98oj3tUCCPjdEiA7Q9 Next: CjjNZaF6NBzY6jPPSGaMUTTnThRM8tJFKE2z8xxJKM6P Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let SEP = "__"
55
66 let contractFilename = "treasury.ride"
77
88 let ADMIN_LIST_SIZE = 5
99
1010 let QUORUM = 3
1111
1212 let TXID_BYTES_LENGTH = 32
1313
1414 func wrapErr (s) = ((contractFilename + ": ") + s)
1515
1616
1717 func throwErr (s) = throw(wrapErr(s))
1818
1919
2020 func keyAllowedTxIdVotePrefix (txId) = makeString(["%s%s%s", "allowTxId", txId], SEP)
2121
2222
2323 func keyFullAdminVote (prefix,adminAddress) = makeString([prefix, adminAddress], SEP)
2424
2525
2626 func keyAdminAddressList () = makeString(["%s", "adminAddressList"], SEP)
2727
2828
2929 func keyAllowedTxId () = makeString(["%s", "txId"], SEP)
3030
3131
3232 func keyConfigAddress () = "%s__config"
3333
3434
3535 func keyVotingResultAddress () = "contract_voting_result"
3636
3737
3838 func keyProposalAllowBroadcast (address,txId) = ((("proposal_allow_broadcast_" + toString(address)) + "_") + toBase58String(txId))
3939
4040
4141 let configAddressOption = match getString(this, keyConfigAddress()) {
4242 case s: String =>
4343 addressFromString(s)
4444 case _: Unit =>
4545 unit
4646 case _ =>
4747 throw("Match error")
4848 }
4949
5050 let configAddress = valueOrErrorMessage(configAddressOption, wrapErr("invalid config address"))
5151
5252 let votingResultContractOption = match configAddressOption {
5353 case a: Address =>
5454 match getString(a, keyVotingResultAddress()) {
5555 case s: String =>
5656 addressFromString(s)
5757 case _: Unit =>
5858 unit
5959 case _ =>
6060 throw("Match error")
6161 }
6262 case _: Unit =>
6363 unit
6464 case _ =>
6565 throw("Match error")
6666 }
6767
6868 let votingResultContract = valueOrErrorMessage(votingResultContractOption, wrapErr("invalid voting result address"))
6969
7070 func getAdminVote (prefix,admin) = {
7171 let voteKey = keyFullAdminVote(prefix, admin)
7272 valueOrElse(getInteger(voteKey), 0)
7373 }
7474
7575
7676 func getAdminsList () = match getString(this, keyAdminAddressList()) {
7777 case s: String =>
7878 split(s, SEP)
7979 case _ =>
8080 nil
8181 }
8282
8383
8484 func isInAdminList (address) = containsElement(getAdminsList(), address)
8585
8686
8787 func genVotesKeysHelper (a,adminAddress) = {
8888 let $t020202044 = a
8989 let result = $t020202044._1
9090 let prefix = $t020202044._2
9191 $Tuple2((result :+ keyFullAdminVote(prefix, adminAddress)), prefix)
9292 }
9393
9494
9595 func genVotesKeys (keyPrefix) = {
9696 let adminList = keyAdminAddressList()
9797 let $t021912275 = {
9898 let $l = getAdminsList()
9999 let $s = size($l)
100100 let $acc0 = $Tuple2(nil, keyPrefix)
101101 func $f0_1 ($a,$i) = if (($i >= $s))
102102 then $a
103103 else genVotesKeysHelper($a, $l[$i])
104104
105105 func $f0_2 ($a,$i) = if (($i >= $s))
106106 then $a
107107 else throw("List size exceeds 5")
108108
109109 $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5)
110110 }
111111 let result = $t021912275._1
112112 let prefix = $t021912275._2
113113 result
114114 }
115115
116116
117117 func countVotesHelper (result,voteKey) = (result + valueOrElse(getInteger(voteKey), 0))
118118
119119
120120 func countVotes (prefix) = {
121121 let votes = genVotesKeys(prefix)
122122 let $l = votes
123123 let $s = size($l)
124124 let $acc0 = 0
125125 func $f0_1 ($a,$i) = if (($i >= $s))
126126 then $a
127127 else countVotesHelper($a, $l[$i])
128128
129129 func $f0_2 ($a,$i) = if (($i >= $s))
130130 then $a
131131 else throw("List size exceeds 5")
132132
133133 $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5)
134134 }
135135
136136
137137 func clearVotesHelper (result,key) = (result :+ DeleteEntry(key))
138138
139139
140140 func getClearVoteEntries (prefix) = {
141141 let votes = genVotesKeys(prefix)
142142 let $l = votes
143143 let $s = size($l)
144144 let $acc0 = nil
145145 func $f0_1 ($a,$i) = if (($i >= $s))
146146 then $a
147147 else clearVotesHelper($a, $l[$i])
148148
149149 func $f0_2 ($a,$i) = if (($i >= $s))
150150 then $a
151151 else throw("List size exceeds 5")
152152
153153 $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5)
154154 }
155155
156156
157157 func voteINTERNAL (callerAddressString,keyPrefix,minVotes,voteResult) = {
158158 let voteKey = keyFullAdminVote(keyPrefix, callerAddressString)
159159 let adminCurrentVote = getAdminVote(keyPrefix, callerAddressString)
160160 let err = if (!(isInAdminList(callerAddressString)))
161161 then throwErr((("Address: " + callerAddressString) + " not in Admin list"))
162162 else if ((adminCurrentVote == 1))
163163 then throwErr((voteKey + " you already voted"))
164164 else unit
165165 if ((err == err))
166166 then {
167167 let votes = countVotes(keyPrefix)
168168 if (((votes + 1) >= minVotes))
169169 then {
170170 let clearVoteEntries = getClearVoteEntries(keyPrefix)
171171 (clearVoteEntries ++ voteResult)
172172 }
173173 else [IntegerEntry(voteKey, 1)]
174174 }
175175 else throw("Strict value is not equal to itself.")
176176 }
177177
178178
179179 @Callable(i)
180180 func voteForTxId (txId) = {
181181 let callerAddressString = toBase58String(i.caller.bytes)
182182 let keyPrefix = keyAllowedTxIdVotePrefix(txId)
183183 let result = [StringEntry(keyAllowedTxId(), txId)]
184184 let allowedTxIdOption = getString(this, keyAllowedTxId())
185185 let err = [if ((size(fromBase58String(txId)) == TXID_BYTES_LENGTH))
186186 then true
187187 else throwErr((txId + " is not valid txId")), if (if ((allowedTxIdOption == unit))
188188 then true
189189 else (value(allowedTxIdOption) != txId))
190190 then true
191191 else throwErr((txId + " is already allowed"))]
192192 if ((err == err))
193193 then voteINTERNAL(callerAddressString, keyPrefix, QUORUM, result)
194194 else throw("Strict value is not equal to itself.")
195195 }
196196
197197
198198 @Verifier(tx)
199199 func verify () = {
200200 let allowedTxIdStringOption = getString(keyAllowedTxId())
201201 let currentAdminList = getAdminsList()
202202 let byProposal = valueOrElse(getBoolean(votingResultContract, keyProposalAllowBroadcast(this, tx.id)), false)
203203 let byAdmins = if ((allowedTxIdStringOption != unit))
204204 then (tx.id == fromBase58String(value(allowedTxIdStringOption)))
205205 else false
206206 let byOwner = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
207207 if (if ((configAddressOption != unit))
208208 then (size(currentAdminList) == ADMIN_LIST_SIZE)
209209 else false)
210210 then if (if ((votingResultContractOption != unit))
211211 then byProposal
212212 else false)
213213 then true
214214 else byAdmins
215215 else byOwner
216216 }
217217

github/deemru/w8io/169f3d6 
26.42 ms