tx · CmKoM8vE1qmNRMSTWR2mUaJP3wb5EF1kEdnpcZPfeGrj 3MyJoBjw9nC4uhgWULVJUaEZEL6z9As7Yfq: -0.00400000 Waves 2022.07.06 20:26 [2128125] smart account 3MyJoBjw9nC4uhgWULVJUaEZEL6z9As7Yfq > SELF 0.00000000 Waves
{ "type": 13, "id": "CmKoM8vE1qmNRMSTWR2mUaJP3wb5EF1kEdnpcZPfeGrj", "fee": 400000, "feeAssetId": null, "timestamp": 1657128435675, "version": 2, "chainId": 84, "sender": "3MyJoBjw9nC4uhgWULVJUaEZEL6z9As7Yfq", "senderPublicKey": "6E1saVK6whrqLsuLBQRGg6smask3XK5nkfiAWyGd3pEm", "proofs": [ "5bowUoPMrvpwUDGKBhLPFSiedd8hpY1ZfvPEETPmkunMQWHUjyQu3BNfvfpquyZmUsZae99v9DDExYt2F1mP3vQn" ], "script": "base64:AAIFAAAAAAAAABcIAhIDCgEIEgMKAQgSAwoBCBIECgIICAAAABIAAAAADVZPVElOR19CTE9DS1MAAAAAAAAAAAoAAAAAC1ZPVEVfQ0xPU0VEAgAAAAZDTE9TRUQAAAAAC1ZPVEVfT1BFTkVEAgAAAARPUEVOAAAAAAxEWVpfQVNTRVRfSUQCAAAALEcyUGI3Q016dHBzN1hFVkdDaVV1SmtMaVMzWkNvNjlBUFFOYkpzMm56MjFqAAAAAA5NSU5fRFlaX0FNT1VOVAAAAAAABfXhAAAAAAAPc3RhdHVzS2V5UHJlZml4AgAAAAdzdGF0dXNfAAAAAA1vcGVuS2V5UHJlZml4AgAAAAVvcGVuXwAAAAAOdG90YWxZZXNTdWZmaXgCAAAACl90b3RhbF95ZXMAAAAADXRvdGFsTm9TdWZmaXgCAAAACV90b3RhbF9ubwAAAAAPcmVwYXltZW50UHJlZml4AgAAAApyZXBheW1lbnRfAQAAAAxnZXRTdGF0dXNLZXkAAAABAAAAAmlkCQABLAAAAAIFAAAAD3N0YXR1c0tleVByZWZpeAUAAAACaWQBAAAACmdldE9wZW5LZXk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AUAAAABYQAAAAAAAAAAAAQAAAAKbmV3Tm9Wb3RlcwkAAGQAAAACBQAAAAxub1ZvdGVzU29GYXIAAAAAAAAAAAEJAARMAAAAAgkBAAAADEludGVnZXJFbnRyeQAAAAIFAAAACW5vVm90ZUtleQUAAAAKbmV3Tm9Wb3RlcwkABEwAAAACCQEAAAAMSW50ZWdlckVudHJ5AAAAAgUAAAAMcmVwYXltZW50S2V5BQAAAAZhbW91bnQFAAAAA25pbAUAAAADbmlsBQAAAAhuZXdFbnRyeQAAAAEAAAACdHgBAAAABnZlcmlmeQAAAAAJAAH0AAAAAwgFAAAAAnR4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAACAUAAAACdHgAAAAPc2VuZGVyUHVibGljS2V5aKGxhg==", "height": 2128125, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: EDbRyRmyHhQuHNhtAJkUtKvMKiqSSUfgxYq7MRBiwqLb Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 5 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let VOTING_BLOCKS = 10 | |
5 | + | ||
6 | + | let VOTE_CLOSED = "CLOSED" | |
7 | + | ||
8 | + | let VOTE_OPENED = "OPEN" | |
9 | + | ||
10 | + | let DYZ_ASSET_ID = "G2Pb7CMztps7XEVGCiUuJkLiS3ZCo69APQNbJs2nz21j" | |
11 | + | ||
12 | + | let MIN_DYZ_AMOUNT = 100000000 | |
13 | + | ||
14 | + | let statusKeyPrefix = "status_" | |
15 | + | ||
16 | + | let openKeyPrefix = "open_" | |
17 | + | ||
18 | + | let totalYesSuffix = "_total_yes" | |
19 | + | ||
20 | + | let totalNoSuffix = "_total_no" | |
21 | + | ||
22 | + | let repaymentPrefix = "repayment_" | |
23 | + | ||
24 | + | func getStatusKey (id) = (statusKeyPrefix + id) | |
25 | + | ||
26 | + | ||
27 | + | func getOpenKey (id) = (openKeyPrefix + id) | |
28 | + | ||
29 | + | ||
30 | + | func getTotalYesKey (id) = (id + totalYesSuffix) | |
31 | + | ||
32 | + | ||
33 | + | func getTotalNoKey (id) = (id + totalYesSuffix) | |
34 | + | ||
35 | + | ||
36 | + | func getVoteStatus (id) = { | |
37 | + | let statusKey = getStatusKey(id) | |
38 | + | let status = getString(this, statusKey) | |
39 | + | status | |
40 | + | } | |
41 | + | ||
42 | + | ||
43 | + | func getRepaymentKey (id,address) = (((repaymentPrefix + id) + "_") + toString(address)) | |
44 | + | ||
45 | + | ||
46 | + | func getStartHeight (id) = { | |
47 | + | let result = match getInteger(this, getOpenKey(id)) { | |
48 | + | case n: Int => | |
49 | + | n | |
50 | + | case _ => | |
51 | + | -1 | |
52 | + | } | |
53 | + | result | |
54 | + | } | |
55 | + | ||
56 | + | ||
57 | + | func getRefundAmount (id,address) = { | |
58 | + | let repaymentKey = getRepaymentKey(id, address) | |
59 | + | let result = match getInteger(this, repaymentKey) { | |
60 | + | case n: Int => | |
61 | + | n | |
62 | + | case _ => | |
63 | + | -1 | |
64 | + | } | |
65 | + | result | |
66 | + | } | |
67 | + | ||
68 | + | ||
69 | + | @Callable(i) | |
70 | + | func openVote (id) = { | |
71 | + | let startHeightKey = getOpenKey(id) | |
72 | + | let statusKey = getStatusKey(id) | |
73 | + | [StringEntry(statusKey, VOTE_OPENED), IntegerEntry(startHeightKey, height)] | |
74 | + | } | |
75 | + | ||
76 | + | ||
77 | + | ||
78 | + | @Callable(i) | |
79 | + | func closeVote (id) = { | |
80 | + | let statusKey = getStatusKey(id) | |
81 | + | [StringEntry(statusKey, VOTE_CLOSED)] | |
82 | + | } | |
83 | + | ||
84 | + | ||
85 | + | ||
86 | + | @Callable(i) | |
87 | + | func claim (id) = { | |
88 | + | let startHeight = getStartHeight(id) | |
89 | + | if ((startHeight == -1)) | |
90 | + | then throw("No vote started for this id!") | |
91 | + | else if (((startHeight + VOTING_BLOCKS) >= height)) | |
92 | + | then throw("You can only claim after vote ends!") | |
93 | + | else { | |
94 | + | let caller = i.caller | |
95 | + | let repayAmount = getRefundAmount(id, caller) | |
96 | + | let statusKey = getStatusKey(id) | |
97 | + | let repaymentKey = getRepaymentKey(id, caller) | |
98 | + | if ((repayAmount > 0)) | |
99 | + | then [ScriptTransfer(caller, repayAmount, toBytes(DYZ_ASSET_ID)), StringEntry(statusKey, VOTE_CLOSED), IntegerEntry(repaymentKey, 0)] | |
100 | + | else throw("Nothing to claim!") | |
101 | + | } | |
102 | + | } | |
103 | + | ||
104 | + | ||
105 | + | ||
106 | + | @Callable(i) | |
107 | + | func vote (id,vote) = { | |
108 | + | let payment = value(i.payments[0]) | |
109 | + | let caller = i.caller | |
110 | + | let amount = payment.amount | |
111 | + | let assetId = toBase58String(value(payment.assetId)) | |
112 | + | if ((assetId != DYZ_ASSET_ID)) | |
113 | + | then throw("payment in DZY necessary!") | |
114 | + | else if ((amount != MIN_DYZ_AMOUNT)) | |
115 | + | then throw("payment amount wrong!") | |
116 | + | else { | |
117 | + | let repaymentKey = getRepaymentKey(id, caller) | |
118 | + | let voteStatus = getVoteStatus(id) | |
119 | + | if ((voteStatus == VOTE_CLOSED)) | |
120 | + | then throw("vote closed!") | |
121 | + | else { | |
122 | + | let openHeight = match getInteger(getOpenKey(id)) { | |
123 | + | case n: Int => | |
124 | + | n | |
125 | + | case _ => | |
126 | + | 0 | |
127 | + | } | |
128 | + | if ((height > (openHeight + VOTING_BLOCKS))) | |
129 | + | then throw("voting ended!") | |
130 | + | else { | |
131 | + | let newEntry = if ((vote == "yes")) | |
132 | + | then { | |
133 | + | let yesVoteKey = getTotalYesKey(id) | |
134 | + | let yesVotesSoFar = match getInteger(this, yesVoteKey) { | |
135 | + | case a: Int => | |
136 | + | a | |
137 | + | case _ => | |
138 | + | 0 | |
139 | + | } | |
140 | + | let newYesVotes = (yesVotesSoFar + 1) | |
141 | + | [IntegerEntry(yesVoteKey, newYesVotes), IntegerEntry(repaymentKey, amount)] | |
142 | + | } | |
143 | + | else if ((vote == "no")) | |
144 | + | then { | |
145 | + | let noVoteKey = getTotalNoKey(id) | |
146 | + | let noVotesSoFar = match getInteger(this, noVoteKey) { | |
147 | + | case a: Int => | |
148 | + | a | |
149 | + | case _ => | |
150 | + | 0 | |
151 | + | } | |
152 | + | let newNoVotes = (noVotesSoFar + 1) | |
153 | + | [IntegerEntry(noVoteKey, newNoVotes), IntegerEntry(repaymentKey, amount)] | |
154 | + | } | |
155 | + | else nil | |
156 | + | newEntry | |
157 | + | } | |
158 | + | } | |
159 | + | } | |
160 | + | } | |
161 | + | ||
162 | + | ||
163 | + | @Verifier(tx) | |
164 | + | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
165 | + |
github/deemru/w8io/169f3d6 41.76 ms ◑