tx · FgEHQC1TkXNuxcVn68sMh5V1of9pKRoi5zA711RjDNsi

3MsdfK4j8fgA65zhEyr7yMqYFZaZaDHQ1Q7:  -0.00500000 Waves

2022.08.01 15:22 [2165428] smart account 3MsdfK4j8fgA65zhEyr7yMqYFZaZaDHQ1Q7 > SELF 0.00000000 Waves

{ "type": 13, "id": "FgEHQC1TkXNuxcVn68sMh5V1of9pKRoi5zA711RjDNsi", "fee": 500000, "feeAssetId": null, "timestamp": 1659356575271, "version": 2, "chainId": 84, "sender": "3MsdfK4j8fgA65zhEyr7yMqYFZaZaDHQ1Q7", "senderPublicKey": "WHz6KMz8NXiDY3SdJVcJnL6oFNzbL3sivL4dhb3E4em", "proofs": [ "5NYQSw6yx26h4WXHgwc6PfKNyUYLyfGDDkYAd9eLp2pdoe9PZEm25wwSkQrpBYLD96W7y6GK5YP2jCwnV1E5maCc" ], "script": "base64:AAIFAAAAAAAAABcIAhIDCgEIEgMKAQgSAwoBCBIECgIIBAAAABUAAAAADERZWl9BU1NFVF9JRAEAAAAg3zps0tw/jE/1UGNUg8jPjkHKkKTlI05ittGCsjg0jKYAAAAAFFZFUklGSUNBVElPTl9TVE9SQUdFAQAAABoBV0LwPIS9tu4jlC9qgesdlrDqqabpgJIR2gAAAAAOTUlOX0RZWl9BTU9VTlQAAAAAAAX14QAAAAAADVZPVElOR19CTE9DS1MAAAAAAAAAAGQAAAAAC1ZPVEVfQ0xPU0VEAgAAAAZDTE9TRUQAAAAAC1ZPVEVfT1BFTkVEAgAAAARPUEVOAAAAAA9zdGF0dXNLZXlQcmVmaXgCAAAAB3N0YXR1c18AAAAADW9wZW5LZXlQcmVmaXgCAAAABW9wZW5fAAAAAA50b3RhbFllc1N1ZmZpeAIAAAAKX3RvdGFsX3llcwAAAAANdG90YWxOb1N1ZmZpeAIAAAAJX3RvdGFsX25vAAAAAA9yZXBheW1lbnRQcmVmaXgCAAAACnJlcGF5bWVudF8AAAAAEGFsbG93ZWRLZXlTdWZmaXgCAAAACF9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AAByRtYXRjaDAJAAQaAAAAAgUAAAAEdGhpcwUAAAAJbm9Wb3RlS2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAANJbnQEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEAAAAAAAAAAAAEAAAACm5ld05vVm90ZXMJAABkAAAAAgUAAAAMbm9Wb3Rlc1NvRmFyAAAAAAAAAAABCQAETAAAAAIJAQAAAAxJbnRlZ2VyRW50cnkAAAACBQAAAAlub1ZvdGVLZXkFAAAACm5ld05vVm90ZXMJAARMAAAAAgkBAAAADEludGVnZXJFbnRyeQAAAAIFAAAADHJlcGF5bWVudEtleQUAAAAGYW1vdW50BQAAAANuaWwFAAAAA25pbAUAAAAIbmV3RW50cnkAAAABAAAAAnR4AQAAAAZ2ZXJpZnkAAAAACQAB9AAAAAMIBQAAAAJ0eAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAAnR4AAAABnByb29mcwAAAAAAAAAAAAgFAAAAAnR4AAAAD3NlbmRlclB1YmxpY0tleUTyN8k=", "height": 2165428, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: 5divqDQeqFc7iw6u73i8qH4AEBw7DML5czvWYUeqokgD Full:
OldNewDifferences
1-# no script
1+{-# STDLIB_VERSION 5 #-}
2+{-# SCRIPT_TYPE ACCOUNT #-}
3+{-# CONTENT_TYPE DAPP #-}
4+let DYZ_ASSET_ID = base58'G2Pb7CMztps7XEVGCiUuJkLiS3ZCo69APQNbJs2nz21j'
5+
6+let VERIFICATION_STORAGE = base58'3P82q7po2rw6A4wuK4TRyA9GKTH1LwL7FnH'
7+
8+let MIN_DYZ_AMOUNT = 100000000
9+
10+let VOTING_BLOCKS = 100
11+
12+let VOTE_CLOSED = "CLOSED"
13+
14+let VOTE_OPENED = "OPEN"
15+
16+let statusKeyPrefix = "status_"
17+
18+let openKeyPrefix = "open_"
19+
20+let totalYesSuffix = "_total_yes"
21+
22+let totalNoSuffix = "_total_no"
23+
24+let repaymentPrefix = "repayment_"
25+
26+let allowedKeySuffix = "_allowed"
27+
28+func getStatusKey (id) = (statusKeyPrefix + id)
29+
30+
31+func getOpenKey (id) = (openKeyPrefix + id)
32+
33+
34+func getTotalYesKey (id) = (id + totalYesSuffix)
35+
36+
37+func getTotalNoKey (id) = (id + totalNoSuffix)
38+
39+
40+func getVoteStatus (id) = getString(this, getStatusKey(id))
41+
42+
43+func getRepaymentKey (id,address) = (((repaymentPrefix + id) + "_") + toString(address))
44+
45+
46+func getStartHeight (id) = match getInteger(this, getOpenKey(id)) {
47+ case n: Int =>
48+ n
49+ case _ =>
50+ -1
51+}
52+
53+
54+func getRefundAmount (repaymentKey) = match getInteger(this, repaymentKey) {
55+ case n: Int =>
56+ n
57+ case _ =>
58+ -1
59+}
60+
61+
62+func isAllowed (address) = match getBoolean(Address(VERIFICATION_STORAGE), (toString(address) + allowedKeySuffix)) {
63+ case b: Boolean =>
64+ b
65+ case _ =>
66+ false
67+}
68+
69+
70+@Callable(i)
71+func openVote (id) = {
72+ let startHeightKey = getOpenKey(id)
73+ let alreadyVoting = getStartHeight(id)
74+ if ((alreadyVoting != -1))
75+ then throw("Vote already ongoing for id!")
76+ else {
77+ let statusKey = getStatusKey(id)
78+[StringEntry(statusKey, VOTE_OPENED), IntegerEntry(startHeightKey, height)]
79+ }
80+ }
81+
82+
83+
84+@Callable(i)
85+func closeVote (id) = {
86+ let currentStartHeight = getStartHeight(id)
87+ if ((currentStartHeight == -1))
88+ then throw("No vote found for id!")
89+ else if (((currentStartHeight + VOTING_BLOCKS) > height))
90+ then throw("Vote can not be closed yet!")
91+ else {
92+ let statusKey = getStatusKey(id)
93+[StringEntry(statusKey, VOTE_CLOSED)]
94+ }
95+ }
96+
97+
98+
99+@Callable(i)
100+func claim (id) = {
101+ let startHeight = getStartHeight(id)
102+ if ((startHeight == -1))
103+ then throw("No vote started for this id!")
104+ else if (((startHeight + VOTING_BLOCKS) >= height))
105+ then throw("You can only claim after vote ends!")
106+ else {
107+ let caller = i.caller
108+ let repaymentKey = getRepaymentKey(id, caller)
109+ let repayAmount = getRefundAmount(repaymentKey)
110+ let statusKey = getStatusKey(id)
111+ if ((repayAmount > 0))
112+ then [ScriptTransfer(caller, repayAmount, DYZ_ASSET_ID), StringEntry(statusKey, VOTE_CLOSED), IntegerEntry(repaymentKey, 0)]
113+ else throw("Nothing to claim!")
114+ }
115+ }
116+
117+
118+
119+@Callable(i)
120+func vote (id,vote) = if ((size(i.payments) != 1))
121+ then throw("One payment in DZY needs to be attached")
122+ else {
123+ let payment = value(i.payments[0])
124+ let caller = i.caller
125+ if (!(isAllowed(caller)))
126+ then throw("Address not allowed to vote!")
127+ else {
128+ let amount = payment.amount
129+ if (!(isDefined(payment.assetId)))
130+ then throw("Payment in Waves not allowed!")
131+ else {
132+ let assetId = toBase58String(value(payment.assetId))
133+ let repaymentKey = getRepaymentKey(id, caller)
134+ let refundAmount = getRefundAmount(repaymentKey)
135+ if ((refundAmount != -1))
136+ then throw("Only one vote per id per address!")
137+ else if ((assetId != toBase58String(DYZ_ASSET_ID)))
138+ then throw("payment in DZY necessary!")
139+ else if ((amount != MIN_DYZ_AMOUNT))
140+ then throw("payment amount wrong!")
141+ else {
142+ let voteStatus = getVoteStatus(id)
143+ if ((voteStatus == VOTE_CLOSED))
144+ then throw("vote closed!")
145+ else {
146+ let openHeight = match getInteger(this, getOpenKey(id)) {
147+ case a: Int =>
148+ a
149+ case _ =>
150+ 0
151+ }
152+ if ((height > (openHeight + VOTING_BLOCKS)))
153+ then throw("voting ended!")
154+ else {
155+ let newEntry = if ((vote == true))
156+ then {
157+ let yesVoteKey = getTotalYesKey(id)
158+ let yesVotesSoFar = match getInteger(this, yesVoteKey) {
159+ case a: Int =>
160+ a
161+ case _ =>
162+ 0
163+ }
164+ let newYesVotes = (yesVotesSoFar + 1)
165+[IntegerEntry(yesVoteKey, newYesVotes), IntegerEntry(repaymentKey, amount)]
166+ }
167+ else if ((vote == false))
168+ then {
169+ let noVoteKey = getTotalNoKey(id)
170+ let noVotesSoFar = match getInteger(this, noVoteKey) {
171+ case a: Int =>
172+ a
173+ case _ =>
174+ 0
175+ }
176+ let newNoVotes = (noVotesSoFar + 1)
177+[IntegerEntry(noVoteKey, newNoVotes), IntegerEntry(repaymentKey, amount)]
178+ }
179+ else nil
180+ newEntry
181+ }
182+ }
183+ }
184+ }
185+ }
186+ }
187+
188+
189+@Verifier(tx)
190+func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
191+

github/deemru/w8io/169f3d6 
22.70 ms