tx · 4Hmn2grc5F1cqKpGswkYJkRsSrEW9fdY3DAX9ZZz8DCb

3MuKEDU6qPggcs65swNH6JcUbS7hB6jVzrA:  -0.01000000 Waves

2023.09.18 18:54 [2761033] smart account 3MuKEDU6qPggcs65swNH6JcUbS7hB6jVzrA > SELF 0.00000000 Waves

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

github/deemru/w8io/169f3d6 
18.26 ms