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