tx · 4qw8tjoqJaegrwwqaA516zMpnay7MycZwN4ABMFvt6wv

3NBYw8rxLmTvyEdsvaYor8nHG6GJ4NjB2Aw:  -0.01000000 Waves

2023.02.06 14:29 [2437695] smart account 3NBYw8rxLmTvyEdsvaYor8nHG6GJ4NjB2Aw > SELF 0.00000000 Waves

{ "type": 13, "id": "4qw8tjoqJaegrwwqaA516zMpnay7MycZwN4ABMFvt6wv", "fee": 1000000, "feeAssetId": null, "timestamp": 1675683088641, "version": 2, "chainId": 84, "sender": "3NBYw8rxLmTvyEdsvaYor8nHG6GJ4NjB2Aw", "senderPublicKey": "4NDsd3dGKXuKLCoSbYvcWCX276K9ShP75cs9HTBMLJEN", "proofs": [ "3EqNur8dCRPVa41raiiWHfT8xoSBwCxKjrHwawmyh3Kkoo3uHne7YkwmmrL3d7PG2pQ1GrRgjdyd7cYyZ13kfEpm" ], "script": "base64:BgIqCAISABIJCgcICAgICAgIEgQKAggIEgMKAQgSBAoCCAgSAwoBCBIDCgEIDwAMbWFpbkNvbnRyYWN0CQERQGV4dHJOYXRpdmUoMTA2MikBAiMzTjk3aWFjUmFwYktRTXdEeG9iY3dBdk5rOFdTYjNUUHdqeAAGUVVPUlVNAB4BDXRyeUdldEludGVnZXIBA2tleQQDdmFsBAckbWF0Y2gwCQCaCAIFBHRoaXMFA2tleQMJAAECBQckbWF0Y2gwAgNJbnQEAWIFByRtYXRjaDAFAWIAAAUDdmFsAQx0cnlHZXRTdHJpbmcBA2tleQQDdmFsBAckbWF0Y2gwCQCdCAIFBHRoaXMFA2tleQMJAAECBQckbWF0Y2gwAgZTdHJpbmcEAWIFByRtYXRjaDAFAWICAAUDdmFsAQdpc093bmVyAQdhZGRyZXNzCQAAAgUHYWRkcmVzcwUEdGhpcwEIZ2V0R3JvdXAABAN2YWwEByRtYXRjaDAJAJ0IAgUMbWFpbkNvbnRyYWN0AhV3b3JraW5nX2dyb3VwX21lbWJlcnMDCQABAgUHJG1hdGNoMAIGU3RyaW5nBAFiBQ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kArAICCQCsAgICBnRhc2tzXwUGdGFza0lkAgdfc3RhdHVzAghyZWplY3RlZAUDbmlsCQACAQIgZ3JhbnRzIHdvcmtpbmcgZ3JvdXAgYWNjZXNzIG9ubHkApaHyWA==", "height": 2437695, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 4QQS8K1rJGtzaZbHznVwyV5redYku5y5mLbW722jpScC Next: AoVZ8LDStQZLbxfqXhSRKaEpDWwbvqDZCegR2MTtmd86 Diff:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4+let mainContract = addressFromStringValue("3N97iacRapbKQMwDxobcwAvNk8WSb3TPwjx")
5+
6+let QUORUM = 30
7+
48 func tryGetInteger (key) = {
59 let val = match getInteger(this, key) {
610 case b: Int =>
2731
2832
2933 func getGroup () = {
30- let val = match getString(this, "working_group_members") {
34+ let val = match getString(mainContract, "working_group_members") {
3135 case b: String =>
3236 b
3337 case _ =>
3842
3943
4044 func getMembers () = {
41- let val = match getString(this, "dao_members") {
45+ let val = match getString(mainContract, "dao_members") {
4246 case b: String =>
4347 b
4448 case _ =>
4852 }
4953
5054
51-func isGroupMember (a) = (tryGetInteger((("working_group_member_" + toString(a)) + "_weight")) > 0)
55+func getDAOSize () = {
56+ let val = match getInteger(mainContract, "dao_size") {
57+ case b: Int =>
58+ b
59+ case _ =>
60+ 0
61+ }
62+ val
63+ }
5264
5365
54-func canMemberVote (i) = (tryGetInteger((("dao_member_" + toString(i.caller)) + "_weight")) > 0)
66+func isGroupMember (a) = {
67+ let val = match getInteger(mainContract, (("working_group_member_" + toString(a)) + "_weight")) {
68+ case b: Int =>
69+ b
70+ case _ =>
71+ 0
72+ }
73+ (val > 0)
74+ }
75+
76+
77+func canMemberVote (address) = {
78+ let val = match getInteger(mainContract, (("dao_member_" + toString(address)) + "_weight")) {
79+ case b: Int =>
80+ b
81+ case _ =>
82+ 0
83+ }
84+ (val > 0)
85+ }
86+
87+
88+func getVoteValue (s) = if ((s == "like"))
89+ then 1
90+ else if ((s == "dislike"))
91+ then -1
92+ else throw("you need to vote with 'like' or 'dislike' value")
93+
94+
95+func addTaskConditions (address) = if (!(isGroupMember(address)))
96+ then throw("grants working group access only")
97+ else true
98+
99+
100+func addRewardConditions (address,taskId) = if (!(isGroupMember(address)))
101+ then throw("grants working group access only")
102+ else if ((tryGetString((("tasks_" + taskId) + "_status")) != ""))
103+ then throw("grant isn`t new")
104+ else true
105+
106+
107+func voteForTaskProposalConditions (address,taskId) = if (!(canMemberVote(address)))
108+ then throw("you can't vote")
109+ else if ((tryGetString((("tasks_" + taskId) + "_status")) != "proposed"))
110+ then throw("voting is closed or not started")
111+ else if ((tryGetInteger(((("tasks_" + taskId) + "_voted_") + toString(address))) != 0))
112+ then throw("you have already voted")
113+ else true
114+
115+
116+func finishTaskProposalVotingConditions (address,taskId) = if (!(isGroupMember(address)))
117+ then throw("grants working group access only")
118+ else if ((tryGetString((("tasks_" + taskId) + "_status")) != "proposed"))
119+ then throw("voting is not active")
120+ else if ((QUORUM > ((tryGetInteger((("tasks_" + taskId) + "_voting_amount")) * 100) / getDAOSize())))
121+ then throw((("more than " + toString(QUORUM)) + "% members have to vote before finishing the voting"))
122+ else true
55123
56124
57125 @Callable(i)
58-func addDAOMember (memberAddress) = if (!(isOwner(i.caller)))
59- then throw("access only to the DAO owner")
60- else if ((tryGetInteger((("dao_member_" + memberAddress) + "_weight")) == 1))
61- then throw("This user already exists")
62- else {
63- let group = getMembers()
64- let newGroup = ((group + ";") + memberAddress)
65- let groupSize = tryGetInteger("dao_size")
66- let newGroupSize = (groupSize + 1)
67-[StringEntry("dao_members", newGroup), IntegerEntry("dao_size", newGroupSize), IntegerEntry((("dao_member_" + memberAddress) + "_weight"), 1)]
68- }
126+func initContract () = [StringEntry("data_provider_description_<en>", "Waves Association DAO"), StringEntry("data_provider_email", "[email protected]"), StringEntry("data_provider_lang_list", "en"), StringEntry("data_provider_link", "https://dao.wavesassociation.org"), StringEntry("data_provider_name", "Waves Association DAO"), IntegerEntry("data_provider_version", 0), BooleanEntry("inited", true)]
69127
70128
71129
72130 @Callable(i)
73-func addGroupMember (memberAddress) = if (!(isOwner(i.caller)))
74- then throw("access only to the DAO owner")
75- else if ((tryGetInteger((("working_group_member_" + memberAddress) + "_weight")) == 1))
76- then throw("This user already exists")
77- else {
78- let group = getGroup()
79- let newGroup = ((group + ";") + memberAddress)
80- let groupSize = tryGetInteger("working_group_size")
81- let newGroupSize = (groupSize + 1)
82-[StringEntry("working_group_members", newGroup), IntegerEntry("working_group_size", newGroupSize), IntegerEntry((("working_group_member_" + memberAddress) + "_weight"), 1)]
83- }
131+func addProposal (tokenId,description,email,link,logo,ticker,hash) = if (addTaskConditions(i.caller))
132+ then [StringEntry((("description_<en>_<" + tokenId) + ">"), description), StringEntry((("email_<" + tokenId) + ">"), email), StringEntry((("logo_<" + tokenId) + ">"), logo), StringEntry((("ticker_<" + tokenId) + ">"), ticker), StringEntry((("link_<" + tokenId) + ">"), link), StringEntry((("tasks_" + tokenId) + "_hash"), hash), IntegerEntry((("version_<" + tokenId) + ">"), 0), IntegerEntry((("status_<" + tokenId) + ">"), 0), StringEntry((("tasks_" + tokenId) + "_status"), "proposed")]
133+ else throw("checks are not passed")
84134
85135
86-@Verifier(tx)
87-func standardVerifier () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
136+
137+@Callable(i)
138+func resetHash (taskId,hash) = [StringEntry((("tasks_" + taskId) + "_hash"), hash)]
139+
140+
141+
142+@Callable(i)
143+func hideTask (taskId) = [StringEntry((("tasks_" + taskId) + "_status"), "hide")]
144+
145+
146+
147+@Callable(i)
148+func voteForTaskProposal (taskId,voteValue) = if (voteForTaskProposalConditions(i.caller, taskId))
149+ then {
150+ let voteKey = ((("tasks_" + taskId) + "_voted_") + toString(i.caller))
151+ let voteValueInt = getVoteValue(voteValue)
152+ let votingKey = (("tasks_" + taskId) + "_voting_state")
153+ let votingState = tryGetInteger(votingKey)
154+ let votesAmountKey = (("tasks_" + taskId) + "_voting_amount")
155+ let votesAmountState = (tryGetInteger(votesAmountKey) + 1)
156+ let newVotingState = (votingState + voteValueInt)
157+[IntegerEntry(votingKey, newVotingState), IntegerEntry(voteKey, voteValueInt), IntegerEntry(votesAmountKey, votesAmountState)]
158+ }
159+ else throw("checks are not passed")
160+
161+
162+
163+@Callable(i)
164+func finishTaskProposalVoting (taskId) = if (finishTaskProposalVotingConditions(i.caller, taskId))
165+ then {
166+ let votingKey = (("tasks_" + taskId) + "_voting_state")
167+[StringEntry((("tasks_" + taskId) + "_status"), if ((tryGetInteger(votingKey) > 0))
168+ then "approved"
169+ else "rejected"), IntegerEntry((("status_<" + taskId) + ">"), if ((tryGetInteger(votingKey) > 0))
170+ then 2
171+ else 0)]
172+ }
173+ else throw("checks are not passed")
174+
175+
176+
177+@Callable(i)
178+func rejectTask (taskId) = if (isGroupMember(i.caller))
179+ then [StringEntry((("tasks_" + taskId) + "_status"), "rejected")]
180+ else throw("grants working group access only")
181+
88182
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4+let mainContract = addressFromStringValue("3N97iacRapbKQMwDxobcwAvNk8WSb3TPwjx")
5+
6+let QUORUM = 30
7+
48 func tryGetInteger (key) = {
59 let val = match getInteger(this, key) {
610 case b: Int =>
711 b
812 case _ =>
913 0
1014 }
1115 val
1216 }
1317
1418
1519 func tryGetString (key) = {
1620 let val = match getString(this, key) {
1721 case b: String =>
1822 b
1923 case _ =>
2024 ""
2125 }
2226 val
2327 }
2428
2529
2630 func isOwner (address) = (address == this)
2731
2832
2933 func getGroup () = {
30- let val = match getString(this, "working_group_members") {
34+ let val = match getString(mainContract, "working_group_members") {
3135 case b: String =>
3236 b
3337 case _ =>
3438 ""
3539 }
3640 val
3741 }
3842
3943
4044 func getMembers () = {
41- let val = match getString(this, "dao_members") {
45+ let val = match getString(mainContract, "dao_members") {
4246 case b: String =>
4347 b
4448 case _ =>
4549 ""
4650 }
4751 val
4852 }
4953
5054
51-func isGroupMember (a) = (tryGetInteger((("working_group_member_" + toString(a)) + "_weight")) > 0)
55+func getDAOSize () = {
56+ let val = match getInteger(mainContract, "dao_size") {
57+ case b: Int =>
58+ b
59+ case _ =>
60+ 0
61+ }
62+ val
63+ }
5264
5365
54-func canMemberVote (i) = (tryGetInteger((("dao_member_" + toString(i.caller)) + "_weight")) > 0)
66+func isGroupMember (a) = {
67+ let val = match getInteger(mainContract, (("working_group_member_" + toString(a)) + "_weight")) {
68+ case b: Int =>
69+ b
70+ case _ =>
71+ 0
72+ }
73+ (val > 0)
74+ }
75+
76+
77+func canMemberVote (address) = {
78+ let val = match getInteger(mainContract, (("dao_member_" + toString(address)) + "_weight")) {
79+ case b: Int =>
80+ b
81+ case _ =>
82+ 0
83+ }
84+ (val > 0)
85+ }
86+
87+
88+func getVoteValue (s) = if ((s == "like"))
89+ then 1
90+ else if ((s == "dislike"))
91+ then -1
92+ else throw("you need to vote with 'like' or 'dislike' value")
93+
94+
95+func addTaskConditions (address) = if (!(isGroupMember(address)))
96+ then throw("grants working group access only")
97+ else true
98+
99+
100+func addRewardConditions (address,taskId) = if (!(isGroupMember(address)))
101+ then throw("grants working group access only")
102+ else if ((tryGetString((("tasks_" + taskId) + "_status")) != ""))
103+ then throw("grant isn`t new")
104+ else true
105+
106+
107+func voteForTaskProposalConditions (address,taskId) = if (!(canMemberVote(address)))
108+ then throw("you can't vote")
109+ else if ((tryGetString((("tasks_" + taskId) + "_status")) != "proposed"))
110+ then throw("voting is closed or not started")
111+ else if ((tryGetInteger(((("tasks_" + taskId) + "_voted_") + toString(address))) != 0))
112+ then throw("you have already voted")
113+ else true
114+
115+
116+func finishTaskProposalVotingConditions (address,taskId) = if (!(isGroupMember(address)))
117+ then throw("grants working group access only")
118+ else if ((tryGetString((("tasks_" + taskId) + "_status")) != "proposed"))
119+ then throw("voting is not active")
120+ else if ((QUORUM > ((tryGetInteger((("tasks_" + taskId) + "_voting_amount")) * 100) / getDAOSize())))
121+ then throw((("more than " + toString(QUORUM)) + "% members have to vote before finishing the voting"))
122+ else true
55123
56124
57125 @Callable(i)
58-func addDAOMember (memberAddress) = if (!(isOwner(i.caller)))
59- then throw("access only to the DAO owner")
60- else if ((tryGetInteger((("dao_member_" + memberAddress) + "_weight")) == 1))
61- then throw("This user already exists")
62- else {
63- let group = getMembers()
64- let newGroup = ((group + ";") + memberAddress)
65- let groupSize = tryGetInteger("dao_size")
66- let newGroupSize = (groupSize + 1)
67-[StringEntry("dao_members", newGroup), IntegerEntry("dao_size", newGroupSize), IntegerEntry((("dao_member_" + memberAddress) + "_weight"), 1)]
68- }
126+func initContract () = [StringEntry("data_provider_description_<en>", "Waves Association DAO"), StringEntry("data_provider_email", "[email protected]"), StringEntry("data_provider_lang_list", "en"), StringEntry("data_provider_link", "https://dao.wavesassociation.org"), StringEntry("data_provider_name", "Waves Association DAO"), IntegerEntry("data_provider_version", 0), BooleanEntry("inited", true)]
69127
70128
71129
72130 @Callable(i)
73-func addGroupMember (memberAddress) = if (!(isOwner(i.caller)))
74- then throw("access only to the DAO owner")
75- else if ((tryGetInteger((("working_group_member_" + memberAddress) + "_weight")) == 1))
76- then throw("This user already exists")
77- else {
78- let group = getGroup()
79- let newGroup = ((group + ";") + memberAddress)
80- let groupSize = tryGetInteger("working_group_size")
81- let newGroupSize = (groupSize + 1)
82-[StringEntry("working_group_members", newGroup), IntegerEntry("working_group_size", newGroupSize), IntegerEntry((("working_group_member_" + memberAddress) + "_weight"), 1)]
83- }
131+func addProposal (tokenId,description,email,link,logo,ticker,hash) = if (addTaskConditions(i.caller))
132+ then [StringEntry((("description_<en>_<" + tokenId) + ">"), description), StringEntry((("email_<" + tokenId) + ">"), email), StringEntry((("logo_<" + tokenId) + ">"), logo), StringEntry((("ticker_<" + tokenId) + ">"), ticker), StringEntry((("link_<" + tokenId) + ">"), link), StringEntry((("tasks_" + tokenId) + "_hash"), hash), IntegerEntry((("version_<" + tokenId) + ">"), 0), IntegerEntry((("status_<" + tokenId) + ">"), 0), StringEntry((("tasks_" + tokenId) + "_status"), "proposed")]
133+ else throw("checks are not passed")
84134
85135
86-@Verifier(tx)
87-func standardVerifier () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
136+
137+@Callable(i)
138+func resetHash (taskId,hash) = [StringEntry((("tasks_" + taskId) + "_hash"), hash)]
139+
140+
141+
142+@Callable(i)
143+func hideTask (taskId) = [StringEntry((("tasks_" + taskId) + "_status"), "hide")]
144+
145+
146+
147+@Callable(i)
148+func voteForTaskProposal (taskId,voteValue) = if (voteForTaskProposalConditions(i.caller, taskId))
149+ then {
150+ let voteKey = ((("tasks_" + taskId) + "_voted_") + toString(i.caller))
151+ let voteValueInt = getVoteValue(voteValue)
152+ let votingKey = (("tasks_" + taskId) + "_voting_state")
153+ let votingState = tryGetInteger(votingKey)
154+ let votesAmountKey = (("tasks_" + taskId) + "_voting_amount")
155+ let votesAmountState = (tryGetInteger(votesAmountKey) + 1)
156+ let newVotingState = (votingState + voteValueInt)
157+[IntegerEntry(votingKey, newVotingState), IntegerEntry(voteKey, voteValueInt), IntegerEntry(votesAmountKey, votesAmountState)]
158+ }
159+ else throw("checks are not passed")
160+
161+
162+
163+@Callable(i)
164+func finishTaskProposalVoting (taskId) = if (finishTaskProposalVotingConditions(i.caller, taskId))
165+ then {
166+ let votingKey = (("tasks_" + taskId) + "_voting_state")
167+[StringEntry((("tasks_" + taskId) + "_status"), if ((tryGetInteger(votingKey) > 0))
168+ then "approved"
169+ else "rejected"), IntegerEntry((("status_<" + taskId) + ">"), if ((tryGetInteger(votingKey) > 0))
170+ then 2
171+ else 0)]
172+ }
173+ else throw("checks are not passed")
174+
175+
176+
177+@Callable(i)
178+func rejectTask (taskId) = if (isGroupMember(i.caller))
179+ then [StringEntry((("tasks_" + taskId) + "_status"), "rejected")]
180+ else throw("grants working group access only")
181+
88182

github/deemru/w8io/169f3d6 
42.35 ms