tx · 471UNnpoezD352owKf8wpM8tBzK6kwu482dmPbhNgbpR 3MrqFfv385KAzAqqdQyprR7FMLSapeifggB: -0.01300000 Waves 2022.11.22 17:37 [2328455] smart account 3MrqFfv385KAzAqqdQyprR7FMLSapeifggB > SELF 0.00000000 Waves
{ "type": 13, "id": "471UNnpoezD352owKf8wpM8tBzK6kwu482dmPbhNgbpR", "fee": 1300000, "feeAssetId": null, "timestamp": 1669127874586, "version": 1, "sender": "3MrqFfv385KAzAqqdQyprR7FMLSapeifggB", "senderPublicKey": "8Tqc64F7G2nACr6yk8egBWCVAp9ZLxjTeWYdXoyQvMAN", "proofs": [ "4Q4MusDyZu9irQNejDbVXshHiSnzAA19PfVJqjTMkv9NNvRxByaeApLL8sFvkTkADGE51kPfK2bMFFNAiPXErEZu" ], "script": "base64:BgIlCAISAwoBCBIFCgMIAQESBAoCAQQSAwoBARIDCgEBEgMKAQgSABUAA1NFUAICX18BE2tleU1hbmFnZXJQdWJsaWNLZXkAAhQlc19fbWFuYWdlclB1YmxpY0tleQEaa2V5UGVuZGluZ01hbmFnZXJQdWJsaWNLZXkAAhslc19fcGVuZGluZ01hbmFnZXJQdWJsaWNLZXkBEGJsb2NrSGVpZ2h0RXJyb3IACQACAQIvVGhlIGJsb2NrJ3MgaGVpZ2h0IGlzIHRvbyBiaWcgZm9yIHRoaXMgcHJvcG9zYWwBEGFscmVhZHlWb3RlRXJyb3IACQACAQIWWW91IGhhdmUgYWxyZWFkeSB2b3RlZAELbm9Wb3RlRXJyb3IACQACAQIaWW91IGhhdmUgbm90IGFscmVhZHkgdm90ZWQBEmd3eENvbnRyYWN0QWRkcmVzcwAJALkJAgkAzAgCAgIlcwkAzAgCAhJnd3hDb250cmFjdEFkZHJlc3MFA25pbAUDU0VQAQ9rZXlDdXJyZW50SW5kZXgACQC5CQIJAMwIAgICJXMJAMwIAgIMY3VycmVudEluZGV4BQNuaWwFA1NFUAEWa2V5UHJvcG9zYWxEZXNjcmlwdGlvbgEGbnVtY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IGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuAQJ0eAEGdmVyaWZ5AAQPdGFyZ2V0UHVibGljS2V5BAckbWF0Y2gwCQEWbWFuYWdlclB1YmxpY0tleU9yVW5pdAADCQABAgUHJG1hdGNoMAIKQnl0ZVZlY3RvcgQCcGsFByRtYXRjaDAFAnBrAwkAAQIFByRtYXRjaDACBFVuaXQIBQJ0eA9zZW5kZXJQdWJsaWNLZXkJAAIBAgtNYXRjaCBlcnJvcgkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAAUPdGFyZ2V0UHVibGljS2V5yug7CA==", "chainId": 84, "height": 2328455, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: Hk9CR3KMycsvea6strtYtXYiEpz7VqbWEu9NAeuczZr7 Next: 4zE9PNUoRjMANVxkxx79UtZ2ykUrH1sjFYixqXD2ogcF Full:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let SEP = "__" | |
5 | + | ||
6 | + | func keyManagerPublicKey () = "%s__managerPublicKey" | |
4 | 7 | ||
5 | 8 | ||
9 | + | func keyPendingManagerPublicKey () = "%s__pendingManagerPublicKey" | |
10 | + | ||
11 | + | ||
12 | + | func blockHeightError () = throw("The block's height is too big for this proposal") | |
13 | + | ||
14 | + | ||
15 | + | func alreadyVoteError () = throw("You have already voted") | |
16 | + | ||
17 | + | ||
18 | + | func noVoteError () = throw("You have not already voted") | |
19 | + | ||
20 | + | ||
21 | + | func gwxContractAddress () = makeString(["%s", "gwxContractAddress"], SEP) | |
22 | + | ||
23 | + | ||
24 | + | func keyCurrentIndex () = makeString(["%s", "currentIndex"], SEP) | |
25 | + | ||
26 | + | ||
27 | + | func keyProposalDescription (number) = makeString(["%s%d", "proposalDescription", toString(number)], SEP) | |
28 | + | ||
29 | + | ||
30 | + | func keyProposalEnd (number) = makeString(["%s%d", "proposalEnd", toString(number)], SEP) | |
31 | + | ||
32 | + | ||
33 | + | func keyTotalPositiveVoteByProposal (number) = makeString(["%s%d", "proposalTotalPositiveVoteNumber", toString(number)], SEP) | |
34 | + | ||
35 | + | ||
36 | + | func keyTotalNegativeVoteByProposal (number) = makeString(["%s%d", "proposalTotalNegativeVoteNumber", toString(number)], SEP) | |
37 | + | ||
38 | + | ||
39 | + | func keyUserChoice (number,user) = makeString(["%s%d%s", "usersChoicebyProposal", toString(number), user], SEP) | |
40 | + | ||
41 | + | ||
42 | + | func keyUserNumberVotesGwxInProposal (number,user) = makeString(["%s%d%s", "usersGWXbyProposal", toString(number), user], SEP) | |
43 | + | ||
44 | + | ||
45 | + | func keyQuorumQuantity (number) = makeString(["%s%d", "quorumQuantity", toString(number)], SEP) | |
46 | + | ||
47 | + | ||
48 | + | func getCurrentIndex () = getIntegerValue(this, keyCurrentIndex()) | |
49 | + | ||
50 | + | ||
51 | + | func asInt (val) = match val { | |
52 | + | case valInt: Int => | |
53 | + | valInt | |
54 | + | case _ => | |
55 | + | throw("fail to cast into Int") | |
56 | + | } | |
57 | + | ||
58 | + | ||
59 | + | func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) { | |
60 | + | case s: String => | |
61 | + | fromBase58String(s) | |
62 | + | case _: Unit => | |
63 | + | unit | |
64 | + | case _ => | |
65 | + | throw("Match error") | |
66 | + | } | |
67 | + | ||
68 | + | ||
69 | + | func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) { | |
70 | + | case s: String => | |
71 | + | fromBase58String(s) | |
72 | + | case _: Unit => | |
73 | + | unit | |
74 | + | case _ => | |
75 | + | throw("Match error") | |
76 | + | } | |
77 | + | ||
78 | + | ||
79 | + | func isManager (i) = match managerPublicKeyOrUnit() { | |
80 | + | case pk: ByteVector => | |
81 | + | (i.callerPublicKey == pk) | |
82 | + | case _: Unit => | |
83 | + | (i.caller == this) | |
84 | + | case _ => | |
85 | + | throw("Match error") | |
86 | + | } | |
87 | + | ||
88 | + | ||
89 | + | func mustManager (i) = if (isManager(i)) | |
90 | + | then true | |
91 | + | else throw("permission denied") | |
92 | + | ||
93 | + | ||
94 | + | @Callable(i) | |
95 | + | func constructor (gwxContractAddress) = { | |
96 | + | let check = mustManager(i) | |
97 | + | if ((check == check)) | |
98 | + | then [StringEntry(gwxContractAddress(), gwxContractAddress), IntegerEntry(keyCurrentIndex(), 0)] | |
99 | + | else throw("Strict value is not equal to itself.") | |
100 | + | } | |
101 | + | ||
102 | + | ||
103 | + | ||
104 | + | @Callable(i) | |
105 | + | func startNewVote (description,expirationHeight,quorumNumber) = { | |
106 | + | let checks = [mustManager(i)] | |
107 | + | if ((checks == checks)) | |
108 | + | then { | |
109 | + | let theIndex = getCurrentIndex() | |
110 | + | [IntegerEntry(keyCurrentIndex(), (theIndex + 1)), StringEntry(keyProposalDescription(theIndex), description), IntegerEntry(keyProposalEnd(theIndex), (lastBlock.height + expirationHeight)), IntegerEntry(keyTotalPositiveVoteByProposal(theIndex), 0), IntegerEntry(keyTotalNegativeVoteByProposal(theIndex), 0), IntegerEntry(keyQuorumQuantity(theIndex), quorumNumber)] | |
111 | + | } | |
112 | + | else throw("Strict value is not equal to itself.") | |
113 | + | } | |
114 | + | ||
115 | + | ||
116 | + | ||
117 | + | @Callable(i) | |
118 | + | func voteFor (proposalIndex,choice) = { | |
119 | + | let checks = [if ((getIntegerValue(this, keyProposalEnd(proposalIndex)) > lastBlock.height)) | |
120 | + | then true | |
121 | + | else blockHeightError(), if ((getString(this, keyUserNumberVotesGwxInProposal(proposalIndex, toString(i.caller))) == unit)) | |
122 | + | then true | |
123 | + | else alreadyVoteError()] | |
124 | + | if ((checks == checks)) | |
125 | + | then { | |
126 | + | let gwxNumber = asInt(invoke(value(addressFromString(gwxContractAddress())), "calcUserGwxAmountAtHeight", [i.caller, getIntegerValue(keyProposalEnd(proposalIndex))], nil)) | |
127 | + | let $t034063987 = if (choice) | |
128 | + | then { | |
129 | + | let action1 = IntegerEntry(keyUserChoice(proposalIndex, toString(i.caller)), 1) | |
130 | + | let action2 = IntegerEntry(keyTotalPositiveVoteByProposal(proposalIndex), (getIntegerValue(keyTotalPositiveVoteByProposal(proposalIndex)) + gwxNumber)) | |
131 | + | $Tuple2(action1, action2) | |
132 | + | } | |
133 | + | else { | |
134 | + | let action1 = IntegerEntry(keyUserChoice(proposalIndex, toString(i.caller)), 0) | |
135 | + | let action2 = IntegerEntry(keyTotalNegativeVoteByProposal(proposalIndex), (getIntegerValue(keyTotalNegativeVoteByProposal(proposalIndex)) + gwxNumber)) | |
136 | + | $Tuple2(action1, action2) | |
137 | + | } | |
138 | + | let action1 = $t034063987._1 | |
139 | + | let action2 = $t034063987._2 | |
140 | + | [IntegerEntry(keyUserNumberVotesGwxInProposal(proposalIndex, toString(i.caller)), gwxNumber), action1, action2] | |
141 | + | } | |
142 | + | else throw("Strict value is not equal to itself.") | |
143 | + | } | |
144 | + | ||
145 | + | ||
146 | + | ||
147 | + | @Callable(i) | |
148 | + | func deleteVote (proposalIndex) = { | |
149 | + | let checks = [if ((getIntegerValue(this, keyProposalEnd(proposalIndex)) > lastBlock.height)) | |
150 | + | then true | |
151 | + | else blockHeightError(), if ((getInteger(keyUserNumberVotesGwxInProposal(proposalIndex, toString(i.caller))) != unit)) | |
152 | + | then true | |
153 | + | else noVoteError()] | |
154 | + | if ((checks == checks)) | |
155 | + | then { | |
156 | + | let action = if ((getIntegerValue(keyUserChoice(proposalIndex, toString(i.caller))) == 1)) | |
157 | + | then IntegerEntry(keyTotalPositiveVoteByProposal(proposalIndex), (getIntegerValue(keyTotalPositiveVoteByProposal(proposalIndex)) - getIntegerValue(keyUserNumberVotesGwxInProposal(proposalIndex, toString(i.caller))))) | |
158 | + | else IntegerEntry(keyTotalNegativeVoteByProposal(proposalIndex), (getIntegerValue(keyTotalNegativeVoteByProposal(proposalIndex)) - getIntegerValue(keyUserNumberVotesGwxInProposal(proposalIndex, toString(i.caller))))) | |
159 | + | [action, DeleteEntry(keyUserNumberVotesGwxInProposal(proposalIndex, toString(i.caller))), DeleteEntry(keyUserChoice(proposalIndex, toString(i.caller)))] | |
160 | + | } | |
161 | + | else throw("Strict value is not equal to itself.") | |
162 | + | } | |
163 | + | ||
164 | + | ||
165 | + | ||
166 | + | @Callable(i) | |
167 | + | func getResultREADONLY (proposalIndex) = { | |
168 | + | let positiveVotes = getIntegerValue(keyTotalPositiveVoteByProposal(proposalIndex)) | |
169 | + | let negativeVotes = getIntegerValue(keyTotalNegativeVoteByProposal(proposalIndex)) | |
170 | + | $Tuple2(nil, [positiveVotes, negativeVotes]) | |
171 | + | } | |
172 | + | ||
173 | + | ||
174 | + | ||
175 | + | @Callable(i) | |
176 | + | func setManager (pendingManagerPublicKey) = { | |
177 | + | let checkCaller = mustManager(i) | |
178 | + | if ((checkCaller == checkCaller)) | |
179 | + | then { | |
180 | + | let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey) | |
181 | + | if ((checkManagerPublicKey == checkManagerPublicKey)) | |
182 | + | then [StringEntry(keyPendingManagerPublicKey(), pendingManagerPublicKey)] | |
183 | + | else throw("Strict value is not equal to itself.") | |
184 | + | } | |
185 | + | else throw("Strict value is not equal to itself.") | |
186 | + | } | |
187 | + | ||
188 | + | ||
189 | + | ||
190 | + | @Callable(i) | |
191 | + | func confirmManager () = { | |
192 | + | let pm = pendingManagerPublicKeyOrUnit() | |
193 | + | let hasPM = if (isDefined(pm)) | |
194 | + | then true | |
195 | + | else throw("no pending manager") | |
196 | + | if ((hasPM == hasPM)) | |
197 | + | then { | |
198 | + | let checkPM = if ((i.callerPublicKey == value(pm))) | |
199 | + | then true | |
200 | + | else throw("you are not pending manager") | |
201 | + | if ((checkPM == checkPM)) | |
202 | + | then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())] | |
203 | + | else throw("Strict value is not equal to itself.") | |
204 | + | } | |
205 | + | else throw("Strict value is not equal to itself.") | |
206 | + | } | |
207 | + | ||
208 | + | ||
209 | + | @Verifier(tx) | |
210 | + | func verify () = { | |
211 | + | let targetPublicKey = match managerPublicKeyOrUnit() { | |
212 | + | case pk: ByteVector => | |
213 | + | pk | |
214 | + | case _: Unit => | |
215 | + | tx.senderPublicKey | |
216 | + | case _ => | |
217 | + | throw("Match error") | |
218 | + | } | |
219 | + | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
220 | + | } | |
6 | 221 |
github/deemru/w8io/169f3d6 25.19 ms ◑