tx · 69aZUGK8n7HLhDH8Wc5BHayM6rLQwLsBWsJcGitz9jd6

3N85L4q2CSfY88d3xArVHd1SSwhQHD5CsKk:  -0.00500000 Waves

2023.03.20 11:16 [2498080] smart account 3N85L4q2CSfY88d3xArVHd1SSwhQHD5CsKk > SELF 0.00000000 Waves

{ "type": 13, "id": "69aZUGK8n7HLhDH8Wc5BHayM6rLQwLsBWsJcGitz9jd6", "fee": 500000, "feeAssetId": null, "timestamp": 1679300209879, "version": 2, "chainId": 84, "sender": "3N85L4q2CSfY88d3xArVHd1SSwhQHD5CsKk", "senderPublicKey": "EfQnrofVeCxCeK3g9SfX4jnSB6XgqKyq8XupMFCSVPfP", "proofs": [ "5311nu7hPLemXuwoTp4VpyqPWhTZmqLbbyJfxtt4uqqEs8xCwKremxLf4Lfjtu7Y5H7G7riD5hj5ti3DMy7PJw63" ], "script": null, "height": 2498080, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 7hoHLFZMHB6ah5ogwrsJwiqJXVjSFpqPADdkLvi1gts6 Next: none Full:
OldNewDifferences
1-{-# STDLIB_VERSION 6 #-}
2-{-# SCRIPT_TYPE ACCOUNT #-}
3-{-# CONTENT_TYPE DAPP #-}
4-let SEP = "__"
5-
6-func keyManagerPublicKey () = "%s__managerPublicpKey"
7-
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 keyProposalInfo (number) = makeString(["%s%d", "proposalInfo", toString(number)], SEP)
28-
29-
30-func keyUserVoteOnProposal (number,user) = makeString(["%s%d%s", "userVoteOnProposal", toString(number), user], SEP)
31-
32-
33-func getCurrentIndex () = getIntegerValue(this, keyCurrentIndex())
34-
35-
36-func formatProposalInfo (name,description,end,quorumNumber,positiveVotes,negativeVotes) = makeString(["%d%d%d%d%d%d", name, description, end, quorumNumber, positiveVotes, negativeVotes], SEP)
37-
38-
39-func formatUserVoteOnProposal (vote,gwxNumber) = makeString(["%d%d", vote, gwxNumber], SEP)
40-
41-
42-func asInt (val) = match val {
43- case valInt: Int =>
44- valInt
45- case _ =>
46- throw("fail to cast into Int")
47-}
48-
49-
50-func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) {
51- case s: String =>
52- fromBase58String(s)
53- case _: Unit =>
54- unit
55- case _ =>
56- throw("Match error")
57-}
58-
59-
60-func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) {
61- case s: String =>
62- fromBase58String(s)
63- case _: Unit =>
64- unit
65- case _ =>
66- throw("Match error")
67-}
68-
69-
70-func isManager (i) = match managerPublicKeyOrUnit() {
71- case pk: ByteVector =>
72- (i.callerPublicKey == pk)
73- case _: Unit =>
74- (i.caller == this)
75- case _ =>
76- throw("Match error")
77-}
78-
79-
80-func mustManager (i) = if (isManager(i))
81- then true
82- else throw("permission denied")
83-
84-
85-@Callable(i)
86-func startNewVote (name,description,expirationHeight,quorumNumber) = {
87- let checks = [mustManager(i)]
88- if ((checks == checks))
89- then {
90- let theIndex = getCurrentIndex()
91-[IntegerEntry(keyCurrentIndex(), (theIndex + 1)), StringEntry(keyProposalInfo(theIndex), formatProposalInfo(name, description, toString((lastBlock.height + expirationHeight)), toString(quorumNumber), "0", "0"))]
92- }
93- else throw("Strict value is not equal to itself.")
94- }
95-
96-
97-
98-@Callable(i)
99-func voteFor (proposalIndex,choice) = {
100- let EMPTY = "EMPTY"
101- let voteInfo = valueOrElse(getString(this, keyProposalInfo(proposalIndex)), EMPTY)
102- let voteInfoArray = split(voteInfo, SEP)
103- let userVoteInfo = valueOrElse(getString(this, keyUserVoteOnProposal(proposalIndex, toString(i.caller))), EMPTY)
104- let checks = [if ((voteInfo != EMPTY))
105- then true
106- else throw("No such vote"), if ((value(parseInt(voteInfoArray[3])) > lastBlock.height))
107- then true
108- else blockHeightError(), if ((userVoteInfo == EMPTY))
109- then true
110- else alreadyVoteError()]
111- if ((checks == checks))
112- then {
113- let gwxNumber = asInt(invoke(addressFromStringValue(getStringValue(gwxContractAddress())), "getUserGwxAmountAtHeightREADONLY", [toString(i.caller), value(parseInt(voteInfoArray[3]))], nil))
114- let $t034674595 = if (choice)
115- then {
116- let action1 = StringEntry(keyProposalInfo(proposalIndex), formatProposalInfo(voteInfoArray[1], voteInfoArray[2], voteInfoArray[3], voteInfoArray[4], toString((value(parseInt(voteInfoArray[5])) + gwxNumber)), voteInfoArray[6]))
117- let action2 = StringEntry(keyUserVoteOnProposal(proposalIndex, toString(i.caller)), formatUserVoteOnProposal("1", toString(gwxNumber)))
118- $Tuple2(action1, action2)
119- }
120- else {
121- let action1 = StringEntry(keyProposalInfo(proposalIndex), formatProposalInfo(voteInfoArray[1], voteInfoArray[2], voteInfoArray[3], voteInfoArray[4], voteInfoArray[5], toString((value(parseInt(voteInfoArray[6])) + gwxNumber))))
122- let action2 = StringEntry(keyUserVoteOnProposal(proposalIndex, toString(i.caller)), formatUserVoteOnProposal("0", toString(gwxNumber)))
123- $Tuple2(action1, action2)
124- }
125- let action1 = $t034674595._1
126- let action2 = $t034674595._2
127-[action1, action2]
128- }
129- else throw("Strict value is not equal to itself.")
130- }
131-
132-
133-
134-@Callable(i)
135-func deleteVote (proposalIndex) = {
136- let EMPTY = "EMPTY"
137- let voteInfo = valueOrElse(getString(this, keyProposalInfo(proposalIndex)), EMPTY)
138- let voteInfoArray = split(voteInfo, SEP)
139- let userVoteInfo = valueOrElse(getString(this, keyUserVoteOnProposal(proposalIndex, toString(i.caller))), EMPTY)
140- let userVoteInfoArray = split(userVoteInfo, SEP)
141- let checks = [if ((voteInfo != EMPTY))
142- then true
143- else throw("No such vote"), if ((value(parseInt(voteInfoArray[3])) > lastBlock.height))
144- then true
145- else blockHeightError(), if ((userVoteInfo != EMPTY))
146- then true
147- else noVoteError()]
148- if ((checks == checks))
149- then {
150- let action = if ((userVoteInfoArray[1] == "1"))
151- then StringEntry(keyProposalInfo(proposalIndex), formatProposalInfo(voteInfoArray[1], voteInfoArray[2], voteInfoArray[3], voteInfoArray[4], toString((value(parseInt(voteInfoArray[5])) - value(parseInt(userVoteInfoArray[2])))), voteInfoArray[6]))
152- else StringEntry(keyProposalInfo(proposalIndex), formatProposalInfo(voteInfoArray[1], voteInfoArray[2], voteInfoArray[3], voteInfoArray[4], voteInfoArray[5], toString((value(parseInt(voteInfoArray[6])) - value(parseInt(userVoteInfoArray[2]))))))
153-[action, DeleteEntry(keyUserVoteOnProposal(proposalIndex, toString(i.caller)))]
154- }
155- else throw("Strict value is not equal to itself.")
156- }
157-
158-
159-
160-@Callable(i)
161-func changeVote (proposalIndex,choice) = {
162- let EMPTY = "EMPTY"
163- let voteInfo = valueOrElse(getString(this, keyProposalInfo(proposalIndex)), EMPTY)
164- let voteInfoArray = split(voteInfo, SEP)
165- let userVoteInfo = valueOrElse(getString(this, keyUserVoteOnProposal(proposalIndex, toString(i.caller))), EMPTY)
166- let userVoteInfoArray = split(userVoteInfo, SEP)
167- let checks = [if ((voteInfo != EMPTY))
168- then true
169- else throw("No such vote"), if ((value(parseInt(voteInfoArray[3])) > lastBlock.height))
170- then true
171- else blockHeightError(), if ((userVoteInfo != EMPTY))
172- then true
173- else noVoteError()]
174- if ((checks == checks))
175- then {
176- let gwxNumber = asInt(invoke(addressFromStringValue(getStringValue(gwxContractAddress())), "getUserGwxAmountAtHeightREADONLY", [toString(i.caller), value(parseInt(voteInfoArray[3]))], nil))
177- let $t068867235 = if (choice)
178- then {
179- let forNumber = gwxNumber
180- let againstNumber = 0
181- let choiceInteger = 1
182- $Tuple3(forNumber, againstNumber, choiceInteger)
183- }
184- else {
185- let forNumber = 0
186- let againstNumber = gwxNumber
187- let choiceInteger = 0
188- $Tuple3(forNumber, againstNumber, choiceInteger)
189- }
190- let userPowerFor = $t068867235._1
191- let userPowerAgainst = $t068867235._2
192- let choiceInt = $t068867235._3
193- let action = if ((userVoteInfoArray[1] == "1"))
194- then StringEntry(keyProposalInfo(proposalIndex), formatProposalInfo(voteInfoArray[1], voteInfoArray[2], voteInfoArray[3], voteInfoArray[4], toString(((value(parseInt(voteInfoArray[5])) - value(parseInt(userVoteInfoArray[2]))) + userPowerFor)), toString((value(parseInt(voteInfoArray[6])) + userPowerAgainst))))
195- else StringEntry(keyProposalInfo(proposalIndex), formatProposalInfo(voteInfoArray[1], voteInfoArray[2], voteInfoArray[3], voteInfoArray[4], toString((value(parseInt(voteInfoArray[5])) + userPowerFor)), toString(((value(parseInt(voteInfoArray[6])) - value(parseInt(userVoteInfoArray[2]))) + userPowerAgainst))))
196-[action, StringEntry(keyUserVoteOnProposal(proposalIndex, toString(i.caller)), formatUserVoteOnProposal(toString(choiceInt), toString(gwxNumber)))]
197- }
198- else throw("Strict value is not equal to itself.")
199- }
200-
201-
202-
203-@Callable(i)
204-func getResultREADONLY (proposalIndex) = {
205- let EMPTY = "EMPTY"
206- let voteInfo = valueOrElse(getString(this, keyProposalInfo(proposalIndex)), EMPTY)
207- let voteInfoArray = split(voteInfo, SEP)
208- let checks = [if ((voteInfo != EMPTY))
209- then true
210- else throw("No such vote")]
211- if ((checks == checks))
212- then {
213- let positiveVotes = voteInfoArray[5]
214- let negativeVotes = voteInfoArray[6]
215- let quorumNumber = voteInfoArray[4]
216- $Tuple2(nil, [positiveVotes, negativeVotes, quorumNumber])
217- }
218- else throw("Strict value is not equal to itself.")
219- }
220-
221-
222-
223-@Callable(i)
224-func setManager (pendingManagerPublicKey) = {
225- let checkCaller = mustManager(i)
226- if ((checkCaller == checkCaller))
227- then {
228- let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey)
229- if ((checkManagerPublicKey == checkManagerPublicKey))
230- then [StringEntry(keyPendingManagerPublicKey(), pendingManagerPublicKey)]
231- else throw("Strict value is not equal to itself.")
232- }
233- else throw("Strict value is not equal to itself.")
234- }
235-
236-
237-
238-@Callable(i)
239-func confirmManager () = {
240- let pm = pendingManagerPublicKeyOrUnit()
241- let hasPM = if (isDefined(pm))
242- then true
243- else throw("no pending manager")
244- if ((hasPM == hasPM))
245- then {
246- let checkPM = if ((i.callerPublicKey == value(pm)))
247- then true
248- else throw("you are not pending manager")
249- if ((checkPM == checkPM))
250- then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())]
251- else throw("Strict value is not equal to itself.")
252- }
253- else throw("Strict value is not equal to itself.")
254- }
255-
256-
257-@Verifier(tx)
258-func verify () = {
259- let targetPublicKey = match managerPublicKeyOrUnit() {
260- case pk: ByteVector =>
261- pk
262- case _: Unit =>
263- tx.senderPublicKey
264- case _ =>
265- throw("Match error")
266- }
267- sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
268- }
269-
1+# no script

github/deemru/w8io/026f985 
24.44 ms