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:BgIHCAISAwoBCBwAA1NFUAICX18AEGNvbnRyYWN0RmlsZW5hbWUCDXRyZWFzdXJ5LnJpZGUAD0FETUlOX0xJU1RfU0laRQAFAAZRVU9SVU0AAwARVFhJRF9CWVRFU19MRU5HVEgAIAEHd3JhcEVycgEBcwkArAICCQCsAgIFEGNvbnRyYWN0RmlsZW5hbWUCAjogBQFzAQh0aHJvd0VycgEBcwkAAgEJAQd3cmFwRXJyAQUBcwEYa2V5QWxsb3dlZFR4SWRWb3RlUHJlZml4AQR0eElkCQC5CQIJAMwIAgIGJXMlcyVzCQDMCAICCWFsbG93VHhJZAkAzAgCBQR0eElkBQNuaWwFA1NFUAEQa2V5RnVsbEFkbWluVm90ZQIGcHJlZml4DGFkbWluQWRkcmVzcwkAuQkCCQDMCAIFBnByZWZpeAkAzAgCBQxhZG1pbkFkZHJlc3MFA25pbAUDU0VQARNrZXlBZG1pbkFkZHJlc3NMaXN0AAkAuQkCCQDMCAICAiVzCQDMCAICEGFkbWluQWRkcmVzc0xpc3QFA25pbAUDU0VQAQ5rZXlBbGxvd2VkVHhJ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WNLZXkDAwkBAiE9AgUTY29uZmlnQWRkcmVzc09wdGlvbgUEdW5pdAkAAAIJAJADAQUQY3VycmVudEFkbWluTGlzdAUPQURNSU5fTElTVF9TSVpFBwMDCQECIT0CBRp2b3RpbmdSZXN1bHRDb250cmFjdE9wdGlvbgUEdW5pdAUKYnlQcm9wb3NhbAcGBQhieUFkbWlucwUHYnlPd25lcu4IJF8=", "height": 2594655, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 7nKtt6LMW7JhHVgixQoGwfZcUu98oj3tUCCPjdEiA7Q9 Next: CjjNZaF6NBzY6jPPSGaMUTTnThRM8tJFKE2z8xxJKM6P Full:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let SEP = "__" | |
5 | 5 | ||
6 | 6 | let contractFilename = "treasury.ride" | |
7 | 7 | ||
8 | 8 | let ADMIN_LIST_SIZE = 5 | |
9 | 9 | ||
10 | 10 | let QUORUM = 3 | |
11 | 11 | ||
12 | 12 | let TXID_BYTES_LENGTH = 32 | |
13 | 13 | ||
14 | 14 | func wrapErr (s) = ((contractFilename + ": ") + s) | |
15 | 15 | ||
16 | 16 | ||
17 | 17 | func throwErr (s) = throw(wrapErr(s)) | |
18 | 18 | ||
19 | 19 | ||
20 | 20 | func keyAllowedTxIdVotePrefix (txId) = makeString(["%s%s%s", "allowTxId", txId], SEP) | |
21 | 21 | ||
22 | 22 | ||
23 | 23 | func keyFullAdminVote (prefix,adminAddress) = makeString([prefix, adminAddress], SEP) | |
24 | 24 | ||
25 | 25 | ||
26 | 26 | func keyAdminAddressList () = makeString(["%s", "adminAddressList"], SEP) | |
27 | 27 | ||
28 | 28 | ||
29 | 29 | func keyAllowedTxId () = makeString(["%s", "txId"], SEP) | |
30 | 30 | ||
31 | 31 | ||
32 | 32 | func keyConfigAddress () = "%s__config" | |
33 | 33 | ||
34 | 34 | ||
35 | 35 | func keyVotingResultAddress () = "contract_voting_result" | |
36 | 36 | ||
37 | 37 | ||
38 | 38 | func keyProposalAllowBroadcast (address,txId) = ((("proposal_allow_broadcast_" + toString(address)) + "_") + toBase58String(txId)) | |
39 | 39 | ||
40 | 40 | ||
41 | 41 | let configAddressOption = match getString(this, keyConfigAddress()) { | |
42 | 42 | case s: String => | |
43 | 43 | addressFromString(s) | |
44 | 44 | case _: Unit => | |
45 | 45 | unit | |
46 | 46 | case _ => | |
47 | 47 | throw("Match error") | |
48 | 48 | } | |
49 | 49 | ||
50 | 50 | let configAddress = valueOrErrorMessage(configAddressOption, wrapErr("invalid config address")) | |
51 | 51 | ||
52 | 52 | let votingResultContractOption = match configAddressOption { | |
53 | 53 | case a: Address => | |
54 | 54 | match getString(a, keyVotingResultAddress()) { | |
55 | 55 | case s: String => | |
56 | 56 | addressFromString(s) | |
57 | 57 | case _: Unit => | |
58 | 58 | unit | |
59 | 59 | case _ => | |
60 | 60 | throw("Match error") | |
61 | 61 | } | |
62 | 62 | case _: Unit => | |
63 | 63 | unit | |
64 | 64 | case _ => | |
65 | 65 | throw("Match error") | |
66 | 66 | } | |
67 | 67 | ||
68 | 68 | let votingResultContract = valueOrErrorMessage(votingResultContractOption, wrapErr("invalid voting result address")) | |
69 | 69 | ||
70 | 70 | func getAdminVote (prefix,admin) = { | |
71 | 71 | let voteKey = keyFullAdminVote(prefix, admin) | |
72 | 72 | valueOrElse(getInteger(voteKey), 0) | |
73 | 73 | } | |
74 | 74 | ||
75 | 75 | ||
76 | 76 | func getAdminsList () = match getString(this, keyAdminAddressList()) { | |
77 | 77 | case s: String => | |
78 | 78 | split(s, SEP) | |
79 | 79 | case _ => | |
80 | 80 | nil | |
81 | 81 | } | |
82 | 82 | ||
83 | 83 | ||
84 | 84 | func isInAdminList (address) = containsElement(getAdminsList(), address) | |
85 | 85 | ||
86 | 86 | ||
87 | 87 | func genVotesKeysHelper (a,adminAddress) = { | |
88 | 88 | let $t020202044 = a | |
89 | 89 | let result = $t020202044._1 | |
90 | 90 | let prefix = $t020202044._2 | |
91 | 91 | $Tuple2((result :+ keyFullAdminVote(prefix, adminAddress)), prefix) | |
92 | 92 | } | |
93 | 93 | ||
94 | 94 | ||
95 | 95 | func genVotesKeys (keyPrefix) = { | |
96 | 96 | let adminList = keyAdminAddressList() | |
97 | 97 | let $t021912275 = { | |
98 | 98 | let $l = getAdminsList() | |
99 | 99 | let $s = size($l) | |
100 | 100 | let $acc0 = $Tuple2(nil, keyPrefix) | |
101 | 101 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
102 | 102 | then $a | |
103 | 103 | else genVotesKeysHelper($a, $l[$i]) | |
104 | 104 | ||
105 | 105 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
106 | 106 | then $a | |
107 | 107 | else throw("List size exceeds 5") | |
108 | 108 | ||
109 | 109 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
110 | 110 | } | |
111 | 111 | let result = $t021912275._1 | |
112 | 112 | let prefix = $t021912275._2 | |
113 | 113 | result | |
114 | 114 | } | |
115 | 115 | ||
116 | 116 | ||
117 | 117 | func countVotesHelper (result,voteKey) = (result + valueOrElse(getInteger(voteKey), 0)) | |
118 | 118 | ||
119 | 119 | ||
120 | 120 | func countVotes (prefix) = { | |
121 | 121 | let votes = genVotesKeys(prefix) | |
122 | 122 | let $l = votes | |
123 | 123 | let $s = size($l) | |
124 | 124 | let $acc0 = 0 | |
125 | 125 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
126 | 126 | then $a | |
127 | 127 | else countVotesHelper($a, $l[$i]) | |
128 | 128 | ||
129 | 129 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
130 | 130 | then $a | |
131 | 131 | else throw("List size exceeds 5") | |
132 | 132 | ||
133 | 133 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
134 | 134 | } | |
135 | 135 | ||
136 | 136 | ||
137 | 137 | func clearVotesHelper (result,key) = (result :+ DeleteEntry(key)) | |
138 | 138 | ||
139 | 139 | ||
140 | 140 | func getClearVoteEntries (prefix) = { | |
141 | 141 | let votes = genVotesKeys(prefix) | |
142 | 142 | let $l = votes | |
143 | 143 | let $s = size($l) | |
144 | 144 | let $acc0 = nil | |
145 | 145 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
146 | 146 | then $a | |
147 | 147 | else clearVotesHelper($a, $l[$i]) | |
148 | 148 | ||
149 | 149 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
150 | 150 | then $a | |
151 | 151 | else throw("List size exceeds 5") | |
152 | 152 | ||
153 | 153 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
154 | 154 | } | |
155 | 155 | ||
156 | 156 | ||
157 | 157 | func voteINTERNAL (callerAddressString,keyPrefix,minVotes,voteResult) = { | |
158 | 158 | let voteKey = keyFullAdminVote(keyPrefix, callerAddressString) | |
159 | 159 | let adminCurrentVote = getAdminVote(keyPrefix, callerAddressString) | |
160 | 160 | let err = if (!(isInAdminList(callerAddressString))) | |
161 | 161 | then throwErr((("Address: " + callerAddressString) + " not in Admin list")) | |
162 | 162 | else if ((adminCurrentVote == 1)) | |
163 | 163 | then throwErr((voteKey + " you already voted")) | |
164 | 164 | else unit | |
165 | 165 | if ((err == err)) | |
166 | 166 | then { | |
167 | 167 | let votes = countVotes(keyPrefix) | |
168 | 168 | if (((votes + 1) >= minVotes)) | |
169 | 169 | then { | |
170 | 170 | let clearVoteEntries = getClearVoteEntries(keyPrefix) | |
171 | 171 | (clearVoteEntries ++ voteResult) | |
172 | 172 | } | |
173 | 173 | else [IntegerEntry(voteKey, 1)] | |
174 | 174 | } | |
175 | 175 | else throw("Strict value is not equal to itself.") | |
176 | 176 | } | |
177 | 177 | ||
178 | 178 | ||
179 | 179 | @Callable(i) | |
180 | 180 | func voteForTxId (txId) = { | |
181 | 181 | let callerAddressString = toBase58String(i.caller.bytes) | |
182 | 182 | let keyPrefix = keyAllowedTxIdVotePrefix(txId) | |
183 | 183 | let result = [StringEntry(keyAllowedTxId(), txId)] | |
184 | 184 | let allowedTxIdOption = getString(this, keyAllowedTxId()) | |
185 | 185 | let err = [if ((size(fromBase58String(txId)) == TXID_BYTES_LENGTH)) | |
186 | 186 | then true | |
187 | 187 | else throwErr((txId + " is not valid txId")), if (if ((allowedTxIdOption == unit)) | |
188 | 188 | then true | |
189 | 189 | else (value(allowedTxIdOption) != txId)) | |
190 | 190 | then true | |
191 | 191 | else throwErr((txId + " is already allowed"))] | |
192 | 192 | if ((err == err)) | |
193 | 193 | then voteINTERNAL(callerAddressString, keyPrefix, QUORUM, result) | |
194 | 194 | else throw("Strict value is not equal to itself.") | |
195 | 195 | } | |
196 | 196 | ||
197 | 197 | ||
198 | 198 | @Verifier(tx) | |
199 | 199 | func verify () = { | |
200 | 200 | let allowedTxIdStringOption = getString(keyAllowedTxId()) | |
201 | 201 | let currentAdminList = getAdminsList() | |
202 | 202 | let byProposal = valueOrElse(getBoolean(votingResultContract, keyProposalAllowBroadcast(this, tx.id)), false) | |
203 | 203 | let byAdmins = if ((allowedTxIdStringOption != unit)) | |
204 | 204 | then (tx.id == fromBase58String(value(allowedTxIdStringOption))) | |
205 | 205 | else false | |
206 | 206 | let byOwner = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
207 | 207 | if (if ((configAddressOption != unit)) | |
208 | 208 | then (size(currentAdminList) == ADMIN_LIST_SIZE) | |
209 | 209 | else false) | |
210 | 210 | then if (if ((votingResultContractOption != unit)) | |
211 | 211 | then byProposal | |
212 | 212 | else false) | |
213 | 213 | then true | |
214 | 214 | else byAdmins | |
215 | 215 | else byOwner | |
216 | 216 | } | |
217 | 217 |
github/deemru/w8io/169f3d6 31.96 ms ◑