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:BgIICAISBAoCAgELAANTRVACAl9fABBjb250cmFjdEZpbGVuYW1lAhNwcm94eV90cmVhc3VyeS5yaWRlAQd3cmFwRXJyAQFzCQCsAgIJAKwCAgUQY29udHJhY3RGaWxlbmFtZQICOiAFAXMBCHRocm93RXJyAQFzCQACAQkBB3dyYXBFcnIBBQFzARFrZXlGYWN0b3J5QWRkcmVzcwAJALkJAgkAzAgCAgIlcwkAzAgCAgdmYWN0b3J5BQNuaWwFA1NFUAETa2V5TWFuYWdlclB1YmxpY0tleQAJALkJAgkAzAgCAgIlcwkAzAgCAhBtYW5hZ2VyUHVibGljS2V5BQNuaWwFA1NFUAAUZmFjdG9yeUFkZHJlc3NPcHRpb24EByRtYXRjaDAJAJ0IAgUEdGhpcwkBEWtleUZhY3RvcnlBZGRyZXNzAAMJAAECBQckbWF0Y2gwAgZTdHJpbmcEAXMFByRtYXRjaDAJAKYIAQUBcwMJAAECBQckbWF0Y2gwAgRVbml0BQR1bml0CQACAQILTWF0Y2ggZXJyb3IAFGZhY3RvcnlBZGRyZXNzT3JGYWlsCQETdmFsdWVPckVycm9yTWVzc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84, "height": 2651279, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 3aL4sNQtRDQm5cYR4wgada7tYxwLWQ97aXGFP2qoo9H8 Next: none Diff:
OldNewDifferences
33 {-# CONTENT_TYPE DAPP #-}
44 let SEP = "__"
55
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"
137
148 func wrapErr (s) = ((contractFilename + ": ") + s)
159
1711 func throwErr (s) = throw(wrapErr(s))
1812
1913
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-
2914 func keyFactoryAddress () = makeString(["%s", "factory"], SEP)
3015
3116
32-func keyAllowedTxId () = makeString(["%s", "txId"], SEP)
17+func keyManagerPublicKey () = makeString(["%s", "managerPublicKey"], SEP)
3318
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"))
5419
5520 let factoryAddressOption = match getString(this, keyFactoryAddress()) {
5621 case s: String =>
6328
6429 let factoryAddressOrFail = valueOrErrorMessage(factoryAddressOption, wrapErr("invalid factory address"))
6530
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-
8431 func onlyAddress (i,address) = if ((i.caller == address))
8532 then true
8633 else throwErr("permission denied")
8936 func onlyFactory (i) = onlyAddress(i, factoryAddressOrFail)
9037
9138
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+ }
10147 case _ =>
102- nil
48+ unit
10349 }
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- }
19950
20051
20152 @Callable(i)
20758 }
20859
20960
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
22768 }
228-
69+ sigVerify(tx.bodyBytes, tx.proofs[0], publicKey)
70+ }
22971
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let SEP = "__"
55
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"
137
148 func wrapErr (s) = ((contractFilename + ": ") + s)
159
1610
1711 func throwErr (s) = throw(wrapErr(s))
1812
1913
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-
2914 func keyFactoryAddress () = makeString(["%s", "factory"], SEP)
3015
3116
32-func keyAllowedTxId () = makeString(["%s", "txId"], SEP)
17+func keyManagerPublicKey () = makeString(["%s", "managerPublicKey"], SEP)
3318
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"))
5419
5520 let factoryAddressOption = match getString(this, keyFactoryAddress()) {
5621 case s: String =>
5722 addressFromString(s)
5823 case _: Unit =>
5924 unit
6025 case _ =>
6126 throw("Match error")
6227 }
6328
6429 let factoryAddressOrFail = valueOrErrorMessage(factoryAddressOption, wrapErr("invalid factory address"))
6530
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-
8431 func onlyAddress (i,address) = if ((i.caller == address))
8532 then true
8633 else throwErr("permission denied")
8734
8835
8936 func onlyFactory (i) = onlyAddress(i, factoryAddressOrFail)
9037
9138
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+ }
10147 case _ =>
102- nil
48+ unit
10349 }
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- }
19950
20051
20152 @Callable(i)
20253 func transferWaves (recipientBytes,amount) = {
20354 let checkCaller = onlyFactory(i)
20455 if ((checkCaller == checkCaller))
20556 then [ScriptTransfer(Address(recipientBytes), amount, unit)]
20657 else throw("Strict value is not equal to itself.")
20758 }
20859
20960
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
22768 }
228-
69+ sigVerify(tx.bodyBytes, tx.proofs[0], publicKey)
70+ }
22971

github/deemru/w8io/026f985 
24.88 ms