tx · DyeEnGvQ9VF7asVeY3wWvAuTENpD9D2JcKqepC3MopT3 3N86AryjXNvAuNs3mV9xKPTjXnAYQimiHDF: -0.01000000 Waves 2023.09.18 17:06 [2760926] smart account 3N86AryjXNvAuNs3mV9xKPTjXnAYQimiHDF > SELF 0.00000000 Waves
{ "type": 13, "id": "DyeEnGvQ9VF7asVeY3wWvAuTENpD9D2JcKqepC3MopT3", "fee": 1000000, "feeAssetId": null, "timestamp": 1695046024662, "version": 2, "chainId": 84, "sender": "3N86AryjXNvAuNs3mV9xKPTjXnAYQimiHDF", "senderPublicKey": "7Zo8C4qkZishvcPg5SUixQPySKeM49Jeui21Tih7iPr9", "proofs": [ "2Qf6BS1js7wXoMTexMMAg3EC2SVzmmJTyTMUeQhQJ3tjGjfTBSxyuFmCHnAR7J9Rm3g5unqaTpzUsozUWDueJbUd" ], "script": "base64:BgIbCAISABIDCgEBEgQKAgICEgQKAggIEgQKAgEEGAADU0VQAgJfXwAPcmVwdXRhdGlvbkFzc2V0ASBp6x+DcpBVAG0dTZ5QIAuA7CaS8wuiEOK6KQOBSERbTgAMcHJvcG9zYWxUaW1lCQBoAgkAaAIJAGgCCQBoAgDoBwA8ADwAGAADAQtwcm9wb3NhbEtleQECaWQJALkJAgkAzAgCAgFwCQDMCAIJAKQDAQUCaWQFA25pbAUDU0VQAQtzZXRQcm9wb3NhbAcCaWQHY3JlYXRvcgV0aXRsZQR0ZXh0EXRpbWVzdGFtcENyZWF0aW9uDWNvdW50Vm90ZXNGb3IRQ291bnRWb3Rlc0FnYWluc3QJAQtTdHJpbmdFbnRyeQIJAQtwcm9wb3NhbEtleQEFAmlkCQC5CQIJAMwIAgkA3AQBCAUHY3JlYXRvcgVieXRlcwkAzAgCBQV0aXRsZQkAzAgCBQR0ZXh0CQDMCAIJAKQDAQURdGltZXN0YW1wQ3JlYXRpb24JAMwIAgkApAMBBQ1jb3VudFZvdGVzRm9yCQDMCAIJAKQDAQURQ291bnRWb3Rlc0FnYWluc3QFA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5AggIBQFpBmNhbGxlcgVieXRlcwUCaWQFBHZvdGUJAMwIAgkBDEludGVnZXJFbnRyeQIJARh1c2VyUHJvcG9zYWxWb3RlUG93ZXJLZXkCCAgFAWkGY2FsbGVyBWJ5dGVzBQJpZAkBFmJhbGFuY2VSZXB1dGF0aW9uQXNzZXQBCAgFAWkGY2FsbGVyBWJ5dGVzBQNuaWwJAMwIAgkBDEludGVnZXJFbnRyeQIJARxwcm9wb3NhbENvdW50Vm90ZXNBZ2FpbnN0S2V5AQUCaWQJAGQCCQERY291bnRWb3Rlc0FnYWluc3QBBQJpZAkBFmJhbGFuY2VSZXB1dGF0aW9uQXNzZXQBCAgFAWkGY2FsbGVyBWJ5dGVzCQDMCAIJAQxJbnRlZ2VyRW50cnkCCQESdW5sb2NrVGltZXN0YW1wS2V5AQgIBQFpBmNhbGxlcgVieXRlcwUKdW5sb2NrVGltZQkAzAgCCQEMQm9vbGVhbkVudHJ5AgkBE3VzZXJQcm9wb3NhbFZvdGVLZXkCCAgFAWkGY2FsbGVyBWJ5dGVzBQJpZAUEdm90ZQkAzAgCCQEMSW50ZWdlckVudHJ5AgkBGHVzZXJQcm9wb3NhbFZvdGVQb3dlcktleQIICAUBaQZjYWxsZXIFYnl0ZXMFAmlkCQEWYmFsYW5jZVJlcHV0YXRpb25Bc3NldAEICAUBaQZjYWxsZXIFYnl0ZXMFA25pbAkAAgECEHByb3Bvc2FsTm90QWxpdmUBAnR4AQZ2ZXJpZnkACQD0AwMIBQJ0eAlib2R5Qnl0ZXMJAJEDAggFAnR4BnByb29mcwAACAUCdHgPc2VuZGVyUHVibGljS2V5H7keHw==", "height": 2760926, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 3b6YjoVMye43yA3vMbLB12odXsBhdWNVAD7fze31aWNR Next: 3qRuZm73k9JML2bntUPa6WPBXHhYd51VoCJRFCuZ6iDj Diff:
Old | New | Differences | |
---|---|---|---|
10 | 10 | func proposalKey (id) = makeString(["p", toString(id)], SEP) | |
11 | 11 | ||
12 | 12 | ||
13 | - | func setProposal (id,creator,title,text,timestampCreation,countVotesFor,CountVotesAgainst) = StringEntry(proposalKey(id), makeString([ | |
13 | + | func setProposal (id,creator,title,text,timestampCreation,countVotesFor,CountVotesAgainst) = StringEntry(proposalKey(id), makeString([toBase16String(creator.bytes), title, text, toString(timestampCreation), toString(countVotesFor), toString(CountVotesAgainst)], SEP)) | |
14 | 14 | ||
15 | 15 | ||
16 | 16 | func getProposal (id) = { | |
20 | 20 | case _ => | |
21 | 21 | throw("proposal not found") | |
22 | 22 | }, SEP) | |
23 | - | $Tuple6( | |
23 | + | $Tuple6(fromBase16String(savedString[0]), savedString[1], savedString[2], parseInt(savedString[3]), parseInt(savedString[4]), parseInt(savedString[5])) | |
24 | 24 | } | |
25 | 25 | ||
26 | 26 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let SEP = "__" | |
5 | 5 | ||
6 | 6 | let reputationAsset = base58'88Tkdpqchhiqc9tNNG3SWQ2gfhZB4rBJKhMNS5Xmxhqw' | |
7 | 7 | ||
8 | 8 | let proposalTime = ((((1000 * 60) * 60) * 24) * 3) | |
9 | 9 | ||
10 | 10 | func proposalKey (id) = makeString(["p", toString(id)], SEP) | |
11 | 11 | ||
12 | 12 | ||
13 | - | func setProposal (id,creator,title,text,timestampCreation,countVotesFor,CountVotesAgainst) = StringEntry(proposalKey(id), makeString([ | |
13 | + | func setProposal (id,creator,title,text,timestampCreation,countVotesFor,CountVotesAgainst) = StringEntry(proposalKey(id), makeString([toBase16String(creator.bytes), title, text, toString(timestampCreation), toString(countVotesFor), toString(CountVotesAgainst)], SEP)) | |
14 | 14 | ||
15 | 15 | ||
16 | 16 | func getProposal (id) = { | |
17 | 17 | let savedString = split( match getString(this, proposalKey(id)) { | |
18 | 18 | case s: String => | |
19 | 19 | s | |
20 | 20 | case _ => | |
21 | 21 | throw("proposal not found") | |
22 | 22 | }, SEP) | |
23 | - | $Tuple6( | |
23 | + | $Tuple6(fromBase16String(savedString[0]), savedString[1], savedString[2], parseInt(savedString[3]), parseInt(savedString[4]), parseInt(savedString[5])) | |
24 | 24 | } | |
25 | 25 | ||
26 | 26 | ||
27 | 27 | func unlockTimestampKey (address) = makeString(["ut", toBase58String(address)], SEP) | |
28 | 28 | ||
29 | 29 | ||
30 | 30 | func countProposalsKey () = "cp" | |
31 | 31 | ||
32 | 32 | ||
33 | 33 | func proposalTitleKey (id) = makeString(["pti", toString(id)], SEP) | |
34 | 34 | ||
35 | 35 | ||
36 | 36 | func proposalTextKey (id) = makeString(["pte", toString(id)], SEP) | |
37 | 37 | ||
38 | 38 | ||
39 | 39 | func proposalTimestampCreationKey (id) = makeString(["ptc", toString(id)], SEP) | |
40 | 40 | ||
41 | 41 | ||
42 | 42 | func proposalCountVotesForKey (id) = makeString(["pcvf", toString(id)], SEP) | |
43 | 43 | ||
44 | 44 | ||
45 | 45 | func proposalCountVotesAgainstKey (id) = makeString(["pcva", toString(id)], SEP) | |
46 | 46 | ||
47 | 47 | ||
48 | 48 | func userProposalVoteKey (address,id) = makeString(["upv", toString(id), toBase58String(address)], SEP) | |
49 | 49 | ||
50 | 50 | ||
51 | 51 | func userProposalVotePowerKey (address,id) = makeString(["upvp", toString(id), toBase58String(address)], SEP) | |
52 | 52 | ||
53 | 53 | ||
54 | 54 | func pmtReputationAsset (i) = if ((size(i.payments) == 1)) | |
55 | 55 | then if ((i.payments[0].assetId == reputationAsset)) | |
56 | 56 | then true | |
57 | 57 | else throw("only reputation assets") | |
58 | 58 | else throw("only 1 payment") | |
59 | 59 | ||
60 | 60 | ||
61 | 61 | func getUnlockTimestamp (address) = match getInteger(this, unlockTimestampKey(address)) { | |
62 | 62 | case a: Int => | |
63 | 63 | a | |
64 | 64 | case _ => | |
65 | 65 | 0 | |
66 | 66 | } | |
67 | 67 | ||
68 | 68 | ||
69 | 69 | func countProposals () = match getInteger(this, countProposalsKey()) { | |
70 | 70 | case a: Int => | |
71 | 71 | a | |
72 | 72 | case _ => | |
73 | 73 | 0 | |
74 | 74 | } | |
75 | 75 | ||
76 | 76 | ||
77 | 77 | func countVotesFor (id) = match getInteger(this, proposalCountVotesForKey(id)) { | |
78 | 78 | case a: Int => | |
79 | 79 | a | |
80 | 80 | case _ => | |
81 | 81 | 0 | |
82 | 82 | } | |
83 | 83 | ||
84 | 84 | ||
85 | 85 | func countVotesAgainst (id) = match getInteger(this, proposalCountVotesAgainstKey(id)) { | |
86 | 86 | case a: Int => | |
87 | 87 | a | |
88 | 88 | case _ => | |
89 | 89 | 0 | |
90 | 90 | } | |
91 | 91 | ||
92 | 92 | ||
93 | 93 | func countVotesUser (address,id) = match getInteger(this, userProposalVotePowerKey(address, id)) { | |
94 | 94 | case a: Int => | |
95 | 95 | a | |
96 | 96 | case _ => | |
97 | 97 | 0 | |
98 | 98 | } | |
99 | 99 | ||
100 | 100 | ||
101 | 101 | func balanceReputationAsset (address) = match getInteger(this, toBase58String(address)) { | |
102 | 102 | case a: Int => | |
103 | 103 | a | |
104 | 104 | case _ => | |
105 | 105 | 0 | |
106 | 106 | } | |
107 | 107 | ||
108 | 108 | ||
109 | 109 | func proposalTimestampCreation (id) = match getInteger(this, proposalTimestampCreationKey(id)) { | |
110 | 110 | case a: Int => | |
111 | 111 | a | |
112 | 112 | case _ => | |
113 | 113 | throw("proposal not created") | |
114 | 114 | } | |
115 | 115 | ||
116 | 116 | ||
117 | 117 | func isProposalAlive (id) = if (if ((countProposals() > id)) | |
118 | 118 | then ((proposalTimestampCreation(id) + proposalTime) > lastBlock.timestamp) | |
119 | 119 | else false) | |
120 | 120 | then true | |
121 | 121 | else throw("proposalNotAlive") | |
122 | 122 | ||
123 | 123 | ||
124 | 124 | @Callable(i) | |
125 | 125 | func deposit () = { | |
126 | 126 | let checks = [pmtReputationAsset(i)] | |
127 | 127 | if ((checks == checks)) | |
128 | 128 | then { | |
129 | 129 | let currentKey = toBase58String(i.caller.bytes) | |
130 | 130 | let currentAmount = balanceReputationAsset(i.caller.bytes) | |
131 | 131 | let newAmount = (currentAmount + i.payments[0].amount) | |
132 | 132 | [IntegerEntry(currentKey, newAmount)] | |
133 | 133 | } | |
134 | 134 | else throw("onlyReputationAsset") | |
135 | 135 | } | |
136 | 136 | ||
137 | 137 | ||
138 | 138 | ||
139 | 139 | @Callable(i) | |
140 | 140 | func withdraw (amount) = { | |
141 | 141 | let currentKey = toBase58String(i.caller.bytes) | |
142 | 142 | let currentAmount = match getInteger(this, currentKey) { | |
143 | 143 | case a: Int => | |
144 | 144 | a | |
145 | 145 | case _ => | |
146 | 146 | 0 | |
147 | 147 | } | |
148 | 148 | let newAmount = (currentAmount - amount) | |
149 | 149 | if ((0 > amount)) | |
150 | 150 | then throw("Can't withdraw negative amount") | |
151 | 151 | else if ((getUnlockTimestamp(i.caller.bytes) > lastBlock.timestamp)) | |
152 | 152 | then throw("Locked") | |
153 | 153 | else if ((0 > newAmount)) | |
154 | 154 | then throw("Not enough balance") | |
155 | 155 | else [IntegerEntry(currentKey, newAmount), ScriptTransfer(i.caller, amount, reputationAsset)] | |
156 | 156 | } | |
157 | 157 | ||
158 | 158 | ||
159 | 159 | ||
160 | 160 | @Callable(i) | |
161 | 161 | func createProposalNew (title,text) = { | |
162 | 162 | let count = countProposals() | |
163 | 163 | [setProposal(count, i.caller, toBase16String(title), toBase16String(text), lastBlock.timestamp, 0, 0)] | |
164 | 164 | } | |
165 | 165 | ||
166 | 166 | ||
167 | 167 | ||
168 | 168 | @Callable(i) | |
169 | 169 | func createProposal (title,text) = { | |
170 | 170 | let count = countProposals() | |
171 | 171 | [StringEntry(proposalTitleKey(count), title), StringEntry(proposalTextKey(count), text), IntegerEntry(proposalTimestampCreationKey(count), lastBlock.timestamp), IntegerEntry(countProposalsKey(), (count + 1))] | |
172 | 172 | } | |
173 | 173 | ||
174 | 174 | ||
175 | 175 | ||
176 | 176 | @Callable(i) | |
177 | 177 | func vote (id,vote) = if (isProposalAlive(id)) | |
178 | 178 | then { | |
179 | 179 | let unlockTime = max([(proposalTimestampCreation(id) + proposalTime), getUnlockTimestamp(i.caller.bytes)]) | |
180 | 180 | let u = match getBoolean(this, userProposalVoteKey(i.caller.bytes, id)) { | |
181 | 181 | case a: Boolean => | |
182 | 182 | if (a) | |
183 | 183 | then IntegerEntry(proposalCountVotesForKey(id), (countVotesFor(id) - countVotesUser(i.caller.bytes, id))) | |
184 | 184 | else IntegerEntry(proposalCountVotesAgainstKey(id), (countVotesFor(id) - countVotesUser(i.caller.bytes, id))) | |
185 | 185 | case _ => | |
186 | 186 | unit | |
187 | 187 | } | |
188 | 188 | if ((vote == true)) | |
189 | 189 | then [IntegerEntry(proposalCountVotesForKey(id), (countVotesFor(id) + balanceReputationAsset(i.caller.bytes))), IntegerEntry(unlockTimestampKey(i.caller.bytes), unlockTime), BooleanEntry(userProposalVoteKey(i.caller.bytes, id), vote), IntegerEntry(userProposalVotePowerKey(i.caller.bytes, id), balanceReputationAsset(i.caller.bytes))] | |
190 | 190 | else [IntegerEntry(proposalCountVotesAgainstKey(id), (countVotesAgainst(id) + balanceReputationAsset(i.caller.bytes))), IntegerEntry(unlockTimestampKey(i.caller.bytes), unlockTime), BooleanEntry(userProposalVoteKey(i.caller.bytes, id), vote), IntegerEntry(userProposalVotePowerKey(i.caller.bytes, id), balanceReputationAsset(i.caller.bytes))] | |
191 | 191 | } | |
192 | 192 | else throw("proposalNotAlive") | |
193 | 193 | ||
194 | 194 | ||
195 | 195 | @Verifier(tx) | |
196 | 196 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
197 | 197 |
github/deemru/w8io/026f985 31.90 ms ◑