tx · 89M6nn5Tu9uL2j6m7rJFuEGPoRLmtP8FMeCiMK9PY5WQ 3MriS1yLhFcKRAM51jDyNAdusa6bCWrTCYj: -0.05000000 Waves 2024.02.08 12:40 [2967105] smart account 3MriS1yLhFcKRAM51jDyNAdusa6bCWrTCYj > SELF 0.00000000 Waves
{ "type": 13, "id": "89M6nn5Tu9uL2j6m7rJFuEGPoRLmtP8FMeCiMK9PY5WQ", "fee": 5000000, "feeAssetId": null, "timestamp": 1707385233592, "version": 2, "chainId": 84, "sender": "3MriS1yLhFcKRAM51jDyNAdusa6bCWrTCYj", "senderPublicKey": "CgjXoHPsstPW1WBAcTeBgjKtLSNFmLbQ7pLJ19JzkCy9", "proofs": [ "2obyu9YGvPb3QoDtsDbmafEaRtbQR4BHnJPGdS2fsuYDBpvwWU1V3tBZTUznHwMvAHmGggJbeVSniT1RxWUJnYE4" ], "script": "base64:AAIFAAAAAAAAABgIAhIFCgMICAgSAwoBCBIDCgEIEgMKAQgAAAAGAAAAAA9tYWluREFPQ29udHJhY3QJAQAAABFAZXh0ck5hdGl2ZSgxMDYyKQAAAAECAAAAIzNOOXRLaXh6cVRZV25FWFF4ckRRNXBCVEd2UWQ2c0Zzdm1WAAAAABV2b3RlSW5pdGlhdGVUaHJlc2hvbGQAAAAAAAX14QABAAAAEmdldFZvdGVzRnJvbUNhbGxlcgAAAAEAAAAJcHVibGljS2V5BAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAAD21haW5EQU9Db250cmFjdAkAASwAAAACAgAAAAlkYW9fdXNlcl8FAAAACXB1YmxpY0tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFpBQAAAAckbWF0Y2gwBQAAAAFpAP//////////AQAAAA9nZXRBbHJlYWR5Vm90ZWQAAAACAAAABnZvdGVJZAAAAAlwdWJsaWNLZXkEAAAAByRtYXRjaDAJAAQbAAAAAgUAAAAEdGhpcwkAASwAAAACCQABLAAAAAIJAAEsAAAAAgUAAAAGdm90ZUl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5AAAAAAkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAIBQAAAAJ0eAAAAA9zZW5kZXJQdWJsaWNLZXlgRR0I", "height": 2967105, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 9WTWmrDj3xHekfa78f7sHmGLo7nPf5iyLiRKqVCabkvy Next: HgNctPLGZ5HWN36sGXcU1XAVqvrvHiUDjCYBosZ6zt6p Diff:
Old | New | Differences | |
---|---|---|---|
45 | 45 | let votingPower = getVotesFromCaller(callerPublicKey) | |
46 | 46 | if ((voteInitiateThreshold > votingPower)) | |
47 | 47 | then throw("User has not been active enough on the platform!") | |
48 | - | else [IntegerEntry((voteId + "_endHeight"), endBlock), StringEntry((voteId + "_title"), title), StringEntry((voteId + "_description"), desc), StringEntry((voteId + "_link"), link), IntegerEntry((voteId + "_yes"), 0), IntegerEntry((voteId + "_no"), 0)] | |
48 | + | else [IntegerEntry((voteId + "_endHeight"), endBlock), StringEntry((voteId + "_title"), title), StringEntry((voteId + "_description"), desc), StringEntry((voteId + "_link"), link), StringEntry((voteId + "_initiator"), callerPublicKey), IntegerEntry((voteId + "_yes"), 0), IntegerEntry((voteId + "_no"), 0)] | |
49 | 49 | } | |
50 | 50 | ||
51 | 51 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let mainDAOContract = addressFromStringValue("3N9tKixzqTYWnEXQxrDQ5pBTGvQd6sFsvmV") | |
5 | 5 | ||
6 | 6 | let voteInitiateThreshold = 100000000 | |
7 | 7 | ||
8 | 8 | func getVotesFromCaller (publicKey) = match getInteger(mainDAOContract, ("dao_user_" + publicKey)) { | |
9 | 9 | case i: Int => | |
10 | 10 | i | |
11 | 11 | case _ => | |
12 | 12 | -1 | |
13 | 13 | } | |
14 | 14 | ||
15 | 15 | ||
16 | 16 | func getAlreadyVoted (voteId,publicKey) = match getBoolean(this, (((voteId + "_") + publicKey) + "_voted")) { | |
17 | 17 | case b: Boolean => | |
18 | 18 | b | |
19 | 19 | case _ => | |
20 | 20 | false | |
21 | 21 | } | |
22 | 22 | ||
23 | 23 | ||
24 | 24 | func getCurrentYesVotesForId (voteId) = match getInteger(this, (voteId + "_yes")) { | |
25 | 25 | case i: Int => | |
26 | 26 | i | |
27 | 27 | case _ => | |
28 | 28 | -1 | |
29 | 29 | } | |
30 | 30 | ||
31 | 31 | ||
32 | 32 | func getCurrentNoVotesForId (voteId) = match getInteger(this, (voteId + "_no")) { | |
33 | 33 | case i: Int => | |
34 | 34 | i | |
35 | 35 | case _ => | |
36 | 36 | -1 | |
37 | 37 | } | |
38 | 38 | ||
39 | 39 | ||
40 | 40 | @Callable(i) | |
41 | 41 | func registerVote (title,desc,link) = { | |
42 | 42 | let callerPublicKey = toBase58String(i.callerPublicKey) | |
43 | 43 | let voteId = toBase58String(i.transactionId) | |
44 | 44 | let endBlock = (height + 7200) | |
45 | 45 | let votingPower = getVotesFromCaller(callerPublicKey) | |
46 | 46 | if ((voteInitiateThreshold > votingPower)) | |
47 | 47 | then throw("User has not been active enough on the platform!") | |
48 | - | else [IntegerEntry((voteId + "_endHeight"), endBlock), StringEntry((voteId + "_title"), title), StringEntry((voteId + "_description"), desc), StringEntry((voteId + "_link"), link), IntegerEntry((voteId + "_yes"), 0), IntegerEntry((voteId + "_no"), 0)] | |
48 | + | else [IntegerEntry((voteId + "_endHeight"), endBlock), StringEntry((voteId + "_title"), title), StringEntry((voteId + "_description"), desc), StringEntry((voteId + "_link"), link), StringEntry((voteId + "_initiator"), callerPublicKey), IntegerEntry((voteId + "_yes"), 0), IntegerEntry((voteId + "_no"), 0)] | |
49 | 49 | } | |
50 | 50 | ||
51 | 51 | ||
52 | 52 | ||
53 | 53 | @Callable(i) | |
54 | 54 | func yes (voteId) = { | |
55 | 55 | let callerPublicKey = toBase58String(i.callerPublicKey) | |
56 | 56 | let currentYesVotes = getCurrentYesVotesForId(voteId) | |
57 | 57 | let votesFromCaller = getVotesFromCaller(callerPublicKey) | |
58 | 58 | let alreadyVoted = getAlreadyVoted(voteId, callerPublicKey) | |
59 | 59 | if ((currentYesVotes == -1)) | |
60 | 60 | then throw("Vote not found!") | |
61 | 61 | else if (alreadyVoted) | |
62 | 62 | then throw("Address already voted!") | |
63 | 63 | else [IntegerEntry((voteId + "_yes"), (currentYesVotes + votesFromCaller)), IntegerEntry((((voteId + "_") + callerPublicKey) + "_yes"), votesFromCaller), BooleanEntry((((voteId + "_") + callerPublicKey) + "_voted"), true)] | |
64 | 64 | } | |
65 | 65 | ||
66 | 66 | ||
67 | 67 | ||
68 | 68 | @Callable(i) | |
69 | 69 | func no (voteId) = { | |
70 | 70 | let callerPublicKey = toBase58String(i.callerPublicKey) | |
71 | 71 | let currentNoVotes = getCurrentNoVotesForId(voteId) | |
72 | 72 | let votesFromCaller = getVotesFromCaller(callerPublicKey) | |
73 | 73 | let alreadyVoted = getAlreadyVoted(voteId, callerPublicKey) | |
74 | 74 | if ((currentNoVotes == -1)) | |
75 | 75 | then throw("Vote not found!") | |
76 | 76 | else if (alreadyVoted) | |
77 | 77 | then throw("Address already voted!") | |
78 | 78 | else [IntegerEntry((voteId + "_no"), (currentNoVotes + votesFromCaller)), IntegerEntry((((voteId + "_") + callerPublicKey) + "_no"), votesFromCaller), BooleanEntry((((voteId + "_") + callerPublicKey) + "_voted"), true)] | |
79 | 79 | } | |
80 | 80 | ||
81 | 81 | ||
82 | 82 | ||
83 | 83 | @Callable(i) | |
84 | 84 | func retractVote (voteId) = { | |
85 | 85 | let callerPublicKey = toBase58String(i.callerPublicKey) | |
86 | 86 | let currentNoVotes = getCurrentNoVotesForId(voteId) | |
87 | 87 | let currentYesVotes = getCurrentYesVotesForId(voteId) | |
88 | 88 | let noVotesFromCaller = match getInteger(this, (((voteId + "_") + callerPublicKey) + "_no")) { | |
89 | 89 | case n: Int => | |
90 | 90 | n | |
91 | 91 | case _ => | |
92 | 92 | 0 | |
93 | 93 | } | |
94 | 94 | let yesVotesFromCaller = match getInteger(this, (((voteId + "_") + callerPublicKey) + "_yes")) { | |
95 | 95 | case n: Int => | |
96 | 96 | n | |
97 | 97 | case _ => | |
98 | 98 | 0 | |
99 | 99 | } | |
100 | 100 | if (if ((currentYesVotes == -1)) | |
101 | 101 | then true | |
102 | 102 | else (currentNoVotes == -1)) | |
103 | 103 | then throw("No active vote for this vote id!") | |
104 | 104 | else [IntegerEntry((voteId + "_no"), (currentNoVotes - noVotesFromCaller)), IntegerEntry((voteId + "_yes"), (currentYesVotes - yesVotesFromCaller)), IntegerEntry((((voteId + "_") + callerPublicKey) + "_no"), 0), IntegerEntry((((voteId + "_") + callerPublicKey) + "_yes"), 0), BooleanEntry((((voteId + "_") + callerPublicKey) + "_voted"), false)] | |
105 | 105 | } | |
106 | 106 | ||
107 | 107 | ||
108 | 108 | @Verifier(tx) | |
109 | 109 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
110 | 110 |
github/deemru/w8io/169f3d6 84.07 ms ◑