tx · FjE5JJbWxMTsPpPz76mLSwg6ZpbRrPLEsu3XBXiGvTnq 3MuKEDU6qPggcs65swNH6JcUbS7hB6jVzrA: -0.01000000 Waves 2023.09.18 21:43 [2761212] smart account 3MuKEDU6qPggcs65swNH6JcUbS7hB6jVzrA > SELF 0.00000000 Waves
{ "type": 13, "id": "FjE5JJbWxMTsPpPz76mLSwg6ZpbRrPLEsu3XBXiGvTnq", "fee": 1000000, "feeAssetId": null, "timestamp": 1695062652392, "version": 2, "chainId": 84, "sender": "3MuKEDU6qPggcs65swNH6JcUbS7hB6jVzrA", "senderPublicKey": "GkZtgtQPEtE9JoxK1tzKc1t7uw12vz6aqKhDcBi136yV", "proofs": [ "58SnxVtjHfxvV7wfdLa9REG15htkU9p2wY1CsjbU5cD3HkU34b8GP2iN3Hz1YuAdefZDSiS6YwbXnV827drsgdGz" ], "script": "base64:BgIVCAISABIDCgEBEgQKAgICEgQKAgEEEQADU0VQAgJfXwAPcmVwdXRhdGlvbkFzc2V0ASBp6x+DcpBVAG0dTZ5QIAuA7CaS8wuiEOK6KQOBSERbTgAMcHJvcG9zYWxUaW1lCQBoAgkAaAIJAGgCCQBoAgDoBwA8ADwAGAADARFjb3VudFByb3Bvc2Fsc0tleQACAmNwAQtwcm9wb3NhbEtleQEKcHJvcG9zYWxJZAkAuQkCCQDMCAICAXAJAMwIAgkApAMBBQpwcm9wb3NhbElkBQNuaWwFA1NFUAESdW5sb2NrVGltZXN0YW1wS2V5AQR1c2VyCQC5CQIJAMwIAgICdXQJAMwIAgkA2AQBCAUEdXNlcgVieXRlcwUDbmlsBQNTRVABEHVzZXJEZXBvc2l0ZWRLZXkBBHVzZXIJALkJAgkAzAgCAgJ1ZAkAzAgCCQDYBAEIBQR1c2VyBWJ5dGVzBQNuaWwFA1NFUAETdXNlclByb3Bvc2FsVm90ZUtleQIKcHJvcG9zYWxJZAR1c2VyCQC5CQIJAMwIAgICdXAJAMwIAgkApAMBBQpwcm9wb3NhbElkCQDMCAIJANg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UHJvcG9zYWxzS2V5AAkAZAIFBWNvdW50AAEFA25pbAFpAQR2b3RlAgJpZAR2b3RlAwkBASEBCQEPaXNQcm9wb3NhbEFsaXZlAQUCaWQJAAIBAhBwcm9wb3NhbE5vdEFsaXZlBAhwcm9wb3NhbAkBC2dldFByb3Bvc2FsAQUCaWQECnVubG9ja1RpbWUJAJYDAQkAzAgCCQBkAggFCHByb3Bvc2FsAl80BQxwcm9wb3NhbFRpbWUJAMwIAgkBEmdldFVubG9ja1RpbWVzdGFtcAEIBQFpBmNhbGxlcgUDbmlsBAtwcmV2aXVzVm90ZQkBC2dldFVzZXJWb3RlAgUCaWQIBQFpBmNhbGxlcgQJdm90ZVBvd2VyCQEcdXNlckRlcG9zaXRlZFJlcHV0YXRpb25Bc3NldAEIBQFpBmNhbGxlcgkAzAgCCQELc2V0UHJvcG9zYWwHBQJpZAgFCHByb3Bvc2FsAl8xCAUIcHJvcG9zYWwCXzIIBQhwcm9wb3NhbAJfMwgFCHByb3Bvc2FsAl80CQBlAggFCHByb3Bvc2FsAl81AwkAZgIFC3ByZXZpdXNWb3RlAAAFC3ByZXZpdXNWb3RlCQBkAgAAAwUEdm90ZQUJdm90ZVBvd2VyAAAJAGUCCAUIcHJvcG9zYWwCXzYDCQBmAgAABQtwcmV2aXVzVm90ZQULcHJldml1c1ZvdGUJAGQCAAADBQR2b3RlAAAFCXZvdGVQb3dlcgUDbmlsAQJ0eAEGdmVyaWZ5AAkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAAgFAnR4D3NlbmRlclB1YmxpY0tleQDvb2c=", "height": 2761212, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 59gAqqiQUDxnxCFaQLR6hVhyrHyZDRQXqPqFVZq4QmC7 Next: 6RZpiTJPRtkgsntoX7mnj6h8jSZ92mrgRgEWx6AqnC6v Diff:
Old | New | Differences | |
---|---|---|---|
43 | 43 | case _ => | |
44 | 44 | throw("proposal not found") | |
45 | 45 | }, SEP) | |
46 | - | $Tuple6( | |
46 | + | $Tuple6(Address(fromBase16String(savedString[0])), savedString[1], savedString[2], parseIntValue(savedString[3]), parseIntValue(savedString[4]), parseIntValue(savedString[5])) | |
47 | 47 | } | |
48 | 48 | ||
49 | 49 |
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 countProposalsKey () = "cp" | |
11 | 11 | ||
12 | 12 | ||
13 | 13 | func proposalKey (proposalId) = makeString(["p", toString(proposalId)], SEP) | |
14 | 14 | ||
15 | 15 | ||
16 | 16 | func unlockTimestampKey (user) = makeString(["ut", toBase58String(user.bytes)], SEP) | |
17 | 17 | ||
18 | 18 | ||
19 | 19 | func userDepositedKey (user) = makeString(["ud", toBase58String(user.bytes)], SEP) | |
20 | 20 | ||
21 | 21 | ||
22 | 22 | func userProposalVoteKey (proposalId,user) = makeString(["up", toString(proposalId), toBase58String(user.bytes)], SEP) | |
23 | 23 | ||
24 | 24 | ||
25 | 25 | func setUserVote (proposalId,user,votePower) = StringEntry(userProposalVoteKey(proposalId, user), toString(votePower)) | |
26 | 26 | ||
27 | 27 | ||
28 | 28 | func getUserVote (proposalId,user) = match getInteger(userProposalVoteKey(proposalId, user)) { | |
29 | 29 | case i: Int => | |
30 | 30 | i | |
31 | 31 | case _ => | |
32 | 32 | 0 | |
33 | 33 | } | |
34 | 34 | ||
35 | 35 | ||
36 | 36 | func setProposal (id,creator,title,text,timestampCreation,countVotesFor,CountVotesAgainst) = StringEntry(proposalKey(id), makeString_11C([toBase16String(creator.bytes), title, text, toString(timestampCreation), toString(countVotesFor), toString(CountVotesAgainst)], SEP)) | |
37 | 37 | ||
38 | 38 | ||
39 | 39 | func getProposal (id) = { | |
40 | 40 | let savedString = split( match getString(this, proposalKey(id)) { | |
41 | 41 | case s: String => | |
42 | 42 | s | |
43 | 43 | case _ => | |
44 | 44 | throw("proposal not found") | |
45 | 45 | }, SEP) | |
46 | - | $Tuple6( | |
46 | + | $Tuple6(Address(fromBase16String(savedString[0])), savedString[1], savedString[2], parseIntValue(savedString[3]), parseIntValue(savedString[4]), parseIntValue(savedString[5])) | |
47 | 47 | } | |
48 | 48 | ||
49 | 49 | ||
50 | 50 | func isPayReputationAsset (i) = if ((size(i.payments) == 1)) | |
51 | 51 | then if ((i.payments[0].assetId == reputationAsset)) | |
52 | 52 | then true | |
53 | 53 | else throw("only reputation assets") | |
54 | 54 | else throw("only 1 payment") | |
55 | 55 | ||
56 | 56 | ||
57 | 57 | func getUnlockTimestamp (user) = match getInteger(this, unlockTimestampKey(user)) { | |
58 | 58 | case a: Int => | |
59 | 59 | a | |
60 | 60 | case _ => | |
61 | 61 | 0 | |
62 | 62 | } | |
63 | 63 | ||
64 | 64 | ||
65 | 65 | func countProposals () = match getInteger(this, countProposalsKey()) { | |
66 | 66 | case a: Int => | |
67 | 67 | a | |
68 | 68 | case _ => | |
69 | 69 | 0 | |
70 | 70 | } | |
71 | 71 | ||
72 | 72 | ||
73 | 73 | func userDepositedReputationAsset (user) = match getInteger(this, userDepositedKey(user)) { | |
74 | 74 | case a: Int => | |
75 | 75 | a | |
76 | 76 | case _ => | |
77 | 77 | 0 | |
78 | 78 | } | |
79 | 79 | ||
80 | 80 | ||
81 | 81 | func isProposalAlive (id) = if (if ((countProposals() > id)) | |
82 | 82 | then ((getProposal(id)._4 + proposalTime) > lastBlock.timestamp) | |
83 | 83 | else false) | |
84 | 84 | then true | |
85 | 85 | else throw("proposal not alive") | |
86 | 86 | ||
87 | 87 | ||
88 | 88 | @Callable(i) | |
89 | 89 | func deposit () = { | |
90 | 90 | let checks = [isPayReputationAsset(i)] | |
91 | 91 | if ((checks == checks)) | |
92 | 92 | then { | |
93 | 93 | let currentKey = toBase58String(i.caller.bytes) | |
94 | 94 | let currentAmount = userDepositedReputationAsset(i.caller) | |
95 | 95 | let newAmount = (currentAmount + i.payments[0].amount) | |
96 | 96 | [IntegerEntry(currentKey, newAmount)] | |
97 | 97 | } | |
98 | 98 | else throw("onlyReputationAsset") | |
99 | 99 | } | |
100 | 100 | ||
101 | 101 | ||
102 | 102 | ||
103 | 103 | @Callable(i) | |
104 | 104 | func withdraw (amount) = { | |
105 | 105 | let currentKey = toBase58String(i.caller.bytes) | |
106 | 106 | let currentAmount = match getInteger(this, currentKey) { | |
107 | 107 | case a: Int => | |
108 | 108 | a | |
109 | 109 | case _ => | |
110 | 110 | 0 | |
111 | 111 | } | |
112 | 112 | let newAmount = (currentAmount - amount) | |
113 | 113 | if ((0 > amount)) | |
114 | 114 | then throw("Can't withdraw negative amount") | |
115 | 115 | else if ((getUnlockTimestamp(i.caller) > lastBlock.timestamp)) | |
116 | 116 | then throw("Locked") | |
117 | 117 | else if ((0 > newAmount)) | |
118 | 118 | then throw("Not enough balance") | |
119 | 119 | else [IntegerEntry(currentKey, newAmount), ScriptTransfer(i.caller, amount, reputationAsset)] | |
120 | 120 | } | |
121 | 121 | ||
122 | 122 | ||
123 | 123 | ||
124 | 124 | @Callable(i) | |
125 | 125 | func createProposal (title,text) = { | |
126 | 126 | let count = countProposals() | |
127 | 127 | [setProposal(count, i.caller, toBase16String(title), toBase16String(text), lastBlock.timestamp, 0, 0), IntegerEntry(countProposalsKey(), (count + 1))] | |
128 | 128 | } | |
129 | 129 | ||
130 | 130 | ||
131 | 131 | ||
132 | 132 | @Callable(i) | |
133 | 133 | func vote (id,vote) = if (!(isProposalAlive(id))) | |
134 | 134 | then throw("proposalNotAlive") | |
135 | 135 | else { | |
136 | 136 | let proposal = getProposal(id) | |
137 | 137 | let unlockTime = max([(proposal._4 + proposalTime), getUnlockTimestamp(i.caller)]) | |
138 | 138 | let previusVote = getUserVote(id, i.caller) | |
139 | 139 | let votePower = userDepositedReputationAsset(i.caller) | |
140 | 140 | [setProposal(id, proposal._1, proposal._2, proposal._3, proposal._4, (proposal._5 - (if ((previusVote > 0)) | |
141 | 141 | then previusVote | |
142 | 142 | else (0 + (if (vote) | |
143 | 143 | then votePower | |
144 | 144 | else 0)))), (proposal._6 - (if ((0 > previusVote)) | |
145 | 145 | then previusVote | |
146 | 146 | else (0 + (if (vote) | |
147 | 147 | then 0 | |
148 | 148 | else votePower)))))] | |
149 | 149 | } | |
150 | 150 | ||
151 | 151 | ||
152 | 152 | @Verifier(tx) | |
153 | 153 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
154 | 154 |
github/deemru/w8io/026f985 25.92 ms ◑