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