tx · 3Vczk9k5BYTDuyMTMvwkxEu2p5BXdTavJ1FoUaKU2VHk 3MqZkBUDKbXPKEq2sMtxtSahzX5n8AVDTyT: -0.01600000 Waves 2021.05.20 14:18 [1533932] smart account 3MqZkBUDKbXPKEq2sMtxtSahzX5n8AVDTyT > SELF 0.00000000 Waves
{ "type": 13, "id": "3Vczk9k5BYTDuyMTMvwkxEu2p5BXdTavJ1FoUaKU2VHk", "fee": 1600000, "feeAssetId": null, "timestamp": 1621509507573, "version": 2, "chainId": 84, "sender": "3MqZkBUDKbXPKEq2sMtxtSahzX5n8AVDTyT", "senderPublicKey": "5CSJYiEQvEGm3vH52UCQRkmhw7TV5ZzRhWptXi2hjM7T", "proofs": [ "3WF2mT25YVKhPLNM3Ve5sTcRNsPhLZ23KbNGVzmjzXWs5tpAjmhXqyzx8HUnbj5qrxSkbaPeyUNZUPAFyEaPDHAT" ], "script": "base64:AAIDAAAAAAAAACEIARIDCgEIEgMKAQgSAwoBCBIDCgEIEgMKAQgSBAoCCAgAAAAHAQAAAAx0cnlHZXRTdHJpbmcAAAABAAAAA2tleQQAAAADdmFsBAAAAAckbWF0Y2gwCQAEHQAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAGU3RyaW5nBAAAAAFiBQAAAAckbWF0Y2gwBQAAAAFiAgAAAAAFAAAAA3ZhbAEAAAAJaXNNYW5hZ2VyAAAAAQAAAAdhZGRyZXNzCQAAAAAAAAIFAAAAB2FkZHJlc3MFAAAABHRoaXMBAAAADXRyeUdldEludGVnZXIAAAABAAAAA2tleQQAAAADdmFsBAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFiBQAAAAckbWF0Y2gwBQAAAAFiAAAAAAAAAAAABQAAAAN2YWwBAAAADmlzV29ya2luZ0dyb3VwAAAAAQAAAAFhCQAAAAAAAAIJAQAAAAx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ZXdWb3RpbmdTdGF0ZQkAAGQAAAACBQAAAAt2b3RpbmdTdGF0ZQUAAAAMdm90ZVZhbHVlSW50BAAAAAxtd2dTdGF0dXNWYWwJAQAAAAx0cnlHZXRTdHJpbmcAAAABCQABLAAAAAIJAAEsAAAAAgIAAAAPZGFvX213Z19tZW1iZXJfBQAAAAZjYWxsZXICAAAAB19zdGF0dXMDCQAAAAAAAAIFAAAADG13Z1N0YXR1c1ZhbAIAAAAIYXBwcm92ZWQDCQAAZgAAAAIJAQAAAA10cnlHZXRJbnRlZ2VyAAAAAQkAASwAAAACCQABLAAAAAIJAAEsAAAAAgIAAAALZGFvX21lbWJlcl8FAAAAEGNhbmRpZGF0ZUFkZHJlc3MCAAAAB192b3Rlc18FAAAABmNhbGxlcgAAAAAAAAAAAAkAAAIAAAABCQABLAAAAAICAAAAH1lvdSBoYXZlIGFscmVhZHkgdm90ZWQuIENhbGxlciAFAAAABmNhbGxlcgkBAAAACFdyaXRlU2V0AAAAAQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgUAAAAJdm90aW5nS2V5BQAAAA5uZXdWb3RpbmdTdGF0ZQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgUAAAAIdm90ZWRLZXkFAAAAC25ld1ZvdGVkVmFsCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACBQAAAAh2b3Rlc0tleQUAAAAMdm90ZVZhbHVlSW50BQAAAANuaWwJAAACAAAAAQkAASwAAAACAgAAABtZb3UgaGF2ZSBubyByaWdodHMuIENhbGxlciAFAAAABmNhbGxlcgAAAACnqGtt", "height": 1533932, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: Qi6YjdcN5N9KcyLFrL2wXvGrTmR5wczeWNH2e1BhcT7 Next: 45wYiWKPL6oEZ4bkbGpGGM5VuAwxqJPAJ9nJeNqCQK2Y Diff:
Old | New | Differences | |
---|---|---|---|
30 | 30 | ||
31 | 31 | ||
32 | 32 | func isDAOMember (a) = (tryGetString((("dao_member_" + toString(a)) + "_status")) == "approved") | |
33 | - | ||
34 | - | ||
35 | - | func isMembershipVotedForCandidate (membershipAddress,candidateAddress) = (tryGetInteger(((membershipAddress + "_voted_") + candidateAddress)) > 0) | |
36 | 33 | ||
37 | 34 | ||
38 | 35 | func getDAOMember () = { | |
129 | 126 | let voteValueInt = getVoteValue(voteValue) | |
130 | 127 | let votingKey = (("dao_member_" + candidateAddress) + "_vote") | |
131 | 128 | let votedKey = (("dao_member_" + candidateAddress) + "_voted") | |
129 | + | let votesKey = ((("dao_member_" + candidateAddress) + "_votes_") + caller) | |
132 | 130 | let votedVal = match getString(this, votedKey) { | |
133 | 131 | case b: String => | |
134 | 132 | b | |
140 | 138 | let newVotingState = (votingState + voteValueInt) | |
141 | 139 | let mwgStatusVal = tryGetString((("dao_mwg_member_" + caller) + "_status")) | |
142 | 140 | if ((mwgStatusVal == "approved")) | |
143 | - | then if ( | |
141 | + | then if ((tryGetInteger(((("dao_member_" + candidateAddress) + "_votes_") + caller)) > 0)) | |
144 | 142 | then throw(("You have already voted. Caller " + caller)) | |
145 | - | else WriteSet([DataEntry( | |
143 | + | else WriteSet([DataEntry(votingKey, newVotingState), DataEntry(votedKey, newVotedVal), DataEntry(votesKey, voteValueInt)]) | |
146 | 144 | else throw(("You have no rights. Caller " + caller)) | |
147 | 145 | } | |
148 | 146 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | func tryGetString (key) = { | |
5 | 5 | let val = match getString(this, key) { | |
6 | 6 | case b: String => | |
7 | 7 | b | |
8 | 8 | case _ => | |
9 | 9 | "" | |
10 | 10 | } | |
11 | 11 | val | |
12 | 12 | } | |
13 | 13 | ||
14 | 14 | ||
15 | 15 | func isManager (address) = (address == this) | |
16 | 16 | ||
17 | 17 | ||
18 | 18 | func tryGetInteger (key) = { | |
19 | 19 | let val = match getInteger(this, key) { | |
20 | 20 | case b: Int => | |
21 | 21 | b | |
22 | 22 | case _ => | |
23 | 23 | 0 | |
24 | 24 | } | |
25 | 25 | val | |
26 | 26 | } | |
27 | 27 | ||
28 | 28 | ||
29 | 29 | func isWorkingGroup (a) = (tryGetString((("working_group_" + toString(a)) + "_status")) == "approved") | |
30 | 30 | ||
31 | 31 | ||
32 | 32 | func isDAOMember (a) = (tryGetString((("dao_member_" + toString(a)) + "_status")) == "approved") | |
33 | - | ||
34 | - | ||
35 | - | func isMembershipVotedForCandidate (membershipAddress,candidateAddress) = (tryGetInteger(((membershipAddress + "_voted_") + candidateAddress)) > 0) | |
36 | 33 | ||
37 | 34 | ||
38 | 35 | func getDAOMember () = { | |
39 | 36 | let val = match getString(this, "dao_members") { | |
40 | 37 | case b: String => | |
41 | 38 | b | |
42 | 39 | case _ => | |
43 | 40 | "" | |
44 | 41 | } | |
45 | 42 | val | |
46 | 43 | } | |
47 | 44 | ||
48 | 45 | ||
49 | 46 | func getVoteValue (s) = if ((s == "like")) | |
50 | 47 | then 1 | |
51 | 48 | else if ((s == "dislike")) | |
52 | 49 | then -1 | |
53 | 50 | else throw(("You need to vote with 'like' or 'dislike' value. You specified:" + s)) | |
54 | 51 | ||
55 | 52 | ||
56 | 53 | @Callable(i) | |
57 | 54 | func aProposeCandidateForDAOMember (address) = if ((tryGetInteger((("member_" + address) + "_voting_state")) != 0)) | |
58 | 55 | then throw("This user already exists") | |
59 | 56 | else { | |
60 | 57 | let group = getDAOMember() | |
61 | 58 | let newGroup = ((group + ";") + address) | |
62 | 59 | let groupSize = tryGetInteger("dao_members_size") | |
63 | 60 | let newGroupSize = (groupSize + 1) | |
64 | 61 | WriteSet([DataEntry((("dao_member_" + address) + "_status"), "propose"), DataEntry("dao_members", newGroup), DataEntry("dao_members_size", newGroupSize)]) | |
65 | 62 | } | |
66 | 63 | ||
67 | 64 | ||
68 | 65 | ||
69 | 66 | @Callable(i) | |
70 | 67 | func mRejectDAOMember (address) = if (!(isManager(i.caller))) | |
71 | 68 | then throw("access only to the DAO Manager") | |
72 | 69 | else WriteSet([DataEntry((("dao_member_" + address) + "_status"), "rejected")]) | |
73 | 70 | ||
74 | 71 | ||
75 | 72 | ||
76 | 73 | @Callable(i) | |
77 | 74 | func mAddDAOMember (address) = if (!(isManager(i.caller))) | |
78 | 75 | then throw("access only to the DAO Manager") | |
79 | 76 | else { | |
80 | 77 | let group = getDAOMember() | |
81 | 78 | let newGroup = ((group + ";") + address) | |
82 | 79 | let groupSize = tryGetInteger("dao_members_size") | |
83 | 80 | let newGroupSize = (groupSize + 1) | |
84 | 81 | WriteSet([DataEntry((("dao_member_" + address) + "_status"), "approved"), DataEntry("dao_members", newGroup), DataEntry("dao_members_size", newGroupSize)]) | |
85 | 82 | } | |
86 | 83 | ||
87 | 84 | ||
88 | 85 | ||
89 | 86 | @Callable(i) | |
90 | 87 | func mAddWorkingGroup (address) = if (!(isManager(i.caller))) | |
91 | 88 | then throw("access only to the DAO Manager") | |
92 | 89 | else { | |
93 | 90 | let group = match getString(this, "dao_wg_members") { | |
94 | 91 | case b: String => | |
95 | 92 | b | |
96 | 93 | case _ => | |
97 | 94 | "" | |
98 | 95 | } | |
99 | 96 | let newGroup = ((group + ";") + address) | |
100 | 97 | let groupSize = tryGetInteger("dao_wg_size") | |
101 | 98 | let newGroupSize = (groupSize + 1) | |
102 | 99 | WriteSet([DataEntry((("dao_wg_member_" + address) + "_status"), "approved"), DataEntry("dao_wg_members", newGroup), DataEntry("dao_wg_size", newGroupSize)]) | |
103 | 100 | } | |
104 | 101 | ||
105 | 102 | ||
106 | 103 | ||
107 | 104 | @Callable(i) | |
108 | 105 | func mAddMembershipWorkingGroup (address) = if (!(isManager(i.caller))) | |
109 | 106 | then throw("access only to the DAO Manager") | |
110 | 107 | else { | |
111 | 108 | let group = match getString(this, "dao_mwg_members") { | |
112 | 109 | case b: String => | |
113 | 110 | b | |
114 | 111 | case _ => | |
115 | 112 | "" | |
116 | 113 | } | |
117 | 114 | let newGroup = ((group + ";") + address) | |
118 | 115 | let groupSize = tryGetInteger("dao_mwg_size") | |
119 | 116 | let newGroupSize = (groupSize + 1) | |
120 | 117 | WriteSet([DataEntry((("dao_mwg_member_" + address) + "_status"), "approved"), DataEntry("dao_mwg_members", newGroup), DataEntry("dao_mwg_size", newGroupSize)]) | |
121 | 118 | } | |
122 | 119 | ||
123 | 120 | ||
124 | 121 | ||
125 | 122 | @Callable(i) | |
126 | 123 | func wmgMembershipVoteForDAOMember (candidateAddress,voteValue) = { | |
127 | 124 | let caller = toString(i.caller) | |
128 | 125 | let membershipAddress = toString(i.caller) | |
129 | 126 | let voteValueInt = getVoteValue(voteValue) | |
130 | 127 | let votingKey = (("dao_member_" + candidateAddress) + "_vote") | |
131 | 128 | let votedKey = (("dao_member_" + candidateAddress) + "_voted") | |
129 | + | let votesKey = ((("dao_member_" + candidateAddress) + "_votes_") + caller) | |
132 | 130 | let votedVal = match getString(this, votedKey) { | |
133 | 131 | case b: String => | |
134 | 132 | b | |
135 | 133 | case _ => | |
136 | 134 | "" | |
137 | 135 | } | |
138 | 136 | let newVotedVal = ((caller + ";") + votedVal) | |
139 | 137 | let votingState = tryGetInteger(votingKey) | |
140 | 138 | let newVotingState = (votingState + voteValueInt) | |
141 | 139 | let mwgStatusVal = tryGetString((("dao_mwg_member_" + caller) + "_status")) | |
142 | 140 | if ((mwgStatusVal == "approved")) | |
143 | - | then if ( | |
141 | + | then if ((tryGetInteger(((("dao_member_" + candidateAddress) + "_votes_") + caller)) > 0)) | |
144 | 142 | then throw(("You have already voted. Caller " + caller)) | |
145 | - | else WriteSet([DataEntry( | |
143 | + | else WriteSet([DataEntry(votingKey, newVotingState), DataEntry(votedKey, newVotedVal), DataEntry(votesKey, voteValueInt)]) | |
146 | 144 | else throw(("You have no rights. Caller " + caller)) | |
147 | 145 | } | |
148 | 146 | ||
149 | 147 |
github/deemru/w8io/026f985 33.51 ms ◑