tx · CsHX5iLp8QwrQtzxyHrUtArQJ1qjrEaXKhaNh5oCLuiF

3Mvbw1Sx9xtM6akJrBPorkPpp4B3sJRFPFX:  -0.10000000 Waves

2020.11.13 00:09 [1262639] smart account 3Mvbw1Sx9xtM6akJrBPorkPpp4B3sJRFPFX > SELF 0.00000000 Waves

{ "type": 13, "id": "CsHX5iLp8QwrQtzxyHrUtArQJ1qjrEaXKhaNh5oCLuiF", "fee": 10000000, "feeAssetId": null, "timestamp": 1605215429114, "version": 2, "chainId": 84, "sender": "3Mvbw1Sx9xtM6akJrBPorkPpp4B3sJRFPFX", "senderPublicKey": "EFfb2ZQ2kJQnnQeHgudF4Fu2ksNzAhonmzpG5RvJdKE4", "proofs": [ "aT8NgDicAkUsDthS7GJKnkfA1x97AhDY44sUc7q2jghwhXFXSk4PnnhCvWkxPic6BvS9zopbft3zSQf33HxruGu" ], "script": "base64:AAIDAAAAAAAAACsIARIECgIICBIDCgEIEgMKAQgSBAoCCAgSBAoCCAgSBQoDCAgBEgQKAggIAAAABwEAAAANdHJ5R2V0SW50ZWdlcgAAAAEAAAADa2V5BAAAAAN2YWwEAAAAByRtYXRjaDAJAAQaAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAANJbnQEAAAAAWIFAAAAByRtYXRjaDAFAAAAAWIAAAAAAAAAAAAFAAAAA3ZhbAEAAAAMdHJ5R2V0U3RyaW5nAAAAAQAAAANrZXkEAAAAA3ZhbAQAAAAHJG1hdGNoMAkABB0AAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAABlN0cmluZwQAAAABYgUAAAAHJG1hdGNoMAUAAAABYgIAAAAABQAAAAN2YWwBAAAAB2lzT3duZXIAAAABAAAAB2FkZHJlc3MJAAAAAAAAAgUAAAAHYWRkcmVzcwUAAAAEdGhpcwEAAAAIZ2V0R3JvdXAAAAAABAAAAAN2YWwEAAAAByRtYXRjaDAJAA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fBQAAAAp0ZW1wbGF0ZUlkAgAAAAtfYXBwbGljYW50XwUAAAAJYXBwbGljYW50AgAAAAZfc2NvcmUEAAAACXRlYW1TY29yZQkBAAAADXRyeUdldEludGVnZXIAAAABBQAAABJ0ZWFtU2NvcmVBbW91bnRLZXkDCQAAZgAAAAIFAAAACXRlYW1TY29yZQAAAAAAAAAAAAYJAAACAAAAAQkAASwAAAACAgAAACVub3QgZW5vdWdoIHZvdGVzIHRvIG1ha2UgZGVjaXNpb24gb24gBQAAAAlhcHBsaWNhbnQDCQEAAAABIQAAAAEJAQAAABZpc0FwcGxpY2FudFZvdGVkRW5vdWdoAAAAAgUAAAAKdGVtcGxhdGVJZAUAAAAJYXBwbGljYW50CQAAAgAAAAECAAAALW5vdCBlbm91Z2ggZXhwZXJ0cyB2b3RlZCB0byBpc3N1ZSBjZXJ0aWZpY2F0ZQkBAAAACFdyaXRlU2V0AAAAAQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkAASwAAAACCQABLAAAAAIJAAEsAAAAAgkAASwAAAACAgAAAAl0ZW1wbGF0ZV8FAAAACnRlbXBsYXRlSWQCAAAAC19hcHBsaWNhbnRfBQAAAAlhcHBsaWNhbnQCAAAAB19zdGF0dXMCAAAACGFwcHJvdmVkBQAAAANuaWwAAAAAqnfs6g==", "height": 1262639, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 7tqrM6xgyEoeCbryov3MnNUWd8v48UmGUwPpJvYPSpoC Next: Hku3UNMeQaGQ4pZdTnXnr5schyymfJB55eAfUeVMsiUQ Diff:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let QUORUM = 50
5-
64 func tryGetInteger (key) = {
75 let val = match getInteger(this, key) {
86 case b: Int =>
1412 }
1513
1614
15+func tryGetString (key) = {
16+ let val = match getString(this, key) {
17+ case b: String =>
18+ b
19+ case _ =>
20+ ""
21+ }
22+ val
23+ }
24+
25+
1726 func isOwner (address) = (address == this)
1827
1928
2029 func getGroup () = {
21- let val = match getString(this, "working_members") {
30+ let val = match getString(this, "working_group") {
2231 case b: String =>
2332 b
2433 case _ =>
3948 }
4049
4150
42-func isAuthor (a,templateId) = {
43- let val = match getString(this, (("template_" + templateId) + "_proposed")) {
44- case b: String =>
45- b
46- case _ =>
47- ""
48- }
49- (val == toString(a))
51+func isGroupMember (a) = (tryGetInteger(("group_member_" + toString(a))) > 0)
52+
53+
54+func canMemberVote (i,templateId) = {
55+ let centerAddress = tryGetString((("template_" + templateId) + "_center"))
56+ (tryGetInteger(((("center_" + centerAddress) + "_member_") + toString(i.caller))) > 0)
5057 }
5158
5259
53-func isGroupMember (a) = (tryGetInteger((("working_member_" + toString(a)) + "_weight")) > 0)
54-
55-
56-func canMemberVote (i,templateId) = (tryGetInteger((("dao_member_" + toString(i.caller)) + "_weight")) > 0)
57-
58-
5960 @Callable(i)
60-func addDAOMember (memberAddress) = if (!(isOwner(i.caller)))
61+func addDAOMember (memberAddress,centerAddress) = if (!(isOwner(i.caller)))
6162 then throw("access only to the DAO owner")
6263 else {
6364 let group = getMembers()
6465 let newGroup = ((group + ";") + memberAddress)
6566 let groupSize = tryGetInteger("dao_size")
6667 let newGroupSize = (groupSize + 1)
67- WriteSet([DataEntry("dao_members", newGroup), DataEntry("dao_size", newGroupSize), DataEntry((("dao_member_" + memberAddress) + "_weight"), 1)])
68+ WriteSet([DataEntry("dao_members", newGroup), DataEntry("dao_size", newGroupSize), DataEntry(((("center_" + centerAddress) + "_member_") + memberAddress), 1)])
6869 }
6970
7071
7576 else {
7677 let group = getGroup()
7778 let newGroup = ((group + ";") + memberAddress)
78- let groupSize = tryGetInteger("working_size")
79+ let groupSize = tryGetInteger("working_group_size")
7980 let newGroupSize = (groupSize + 1)
80- WriteSet([DataEntry("working_members", newGroup), DataEntry("working_size", newGroupSize), DataEntry((("working_member_" + memberAddress) + "_weight"), 1)])
81+ WriteSet([DataEntry("working_group", newGroup), DataEntry("working_group_size", newGroupSize), DataEntry(("group_member_" + memberAddress), 1)])
8182 }
8283
8384
8485
8586 @Callable(i)
86-func proposeTemplate (title) = WriteSet([DataEntry((("template_" + toBase58String(i.transactionId)) + "_title"), title), DataEntry((("template_" + toBase58String(i.transactionId)) + "_proposed"), toString(i.caller)), DataEntry((("template_" + toBase58String(i.transactionId)) + "_status"), "proposed")])
87-
88-
89-
90-@Callable(i)
91-func addTemplateDetails (templateId,description,author,company,link) = if (!(isAuthor(i.caller, templateId)))
92- then throw("author access only")
93- else WriteSet([DataEntry((("template_" + templateId) + "_description"), description), DataEntry((("template_" + templateId) + "_author"), author), DataEntry((("template_" + templateId) + "_company"), company), DataEntry((("template_" + templateId) + "_link"), link)])
87+func proposeTemplate (title) = WriteSet([DataEntry((("template_" + toBase58String(i.transactionId)) + "_title"), title), DataEntry((("template_" + toBase58String(i.transactionId)) + "_status"), "proposed"), DataEntry((("template_" + toBase58String(i.transactionId)) + "_proposed_by"), toString(i.caller))])
9488
9589
9690
111105 ""
112106 }
113107 let newApplicantsList = ((currentApplicantsList + ";") + toString(i.caller))
114- WriteSet([DataEntry((((("template_" + templateId) + "_applicant_") + toString(i.caller)) + "_status"), "requested"), DataEntry((((("template_" + templateId) + "_applicant_") + toString(i.caller)) + "_details"), details), DataEntry(listKey, newApplicantsList)])
108+ ScriptResult(WriteSet([DataEntry((((("template_" + templateId) + "_applicant_") + toString(i.caller)) + "_status"), "requested"), DataEntry((((("template_" + templateId) + "_applicant_") + toString(i.caller)) + "_details"), details), DataEntry(listKey, newApplicantsList)]), TransferSet([ScriptTransfer(i.caller, 500000, unit)]))
115109 }
116110
117111
147141 let teamScore = tryGetInteger(teamScoreAmountKey)
148142 if ((teamScore > 0))
149143 then true
150- else throw("not enough votes to make decision")
144+ else throw(("not enough votes to make decision on " + applicant))
151145 }
152146
153147 if (!(isApplicantVotedEnough(templateId, applicant)))
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let QUORUM = 50
5-
64 func tryGetInteger (key) = {
75 let val = match getInteger(this, key) {
86 case b: Int =>
97 b
108 case _ =>
119 0
1210 }
1311 val
1412 }
1513
1614
15+func tryGetString (key) = {
16+ let val = match getString(this, key) {
17+ case b: String =>
18+ b
19+ case _ =>
20+ ""
21+ }
22+ val
23+ }
24+
25+
1726 func isOwner (address) = (address == this)
1827
1928
2029 func getGroup () = {
21- let val = match getString(this, "working_members") {
30+ let val = match getString(this, "working_group") {
2231 case b: String =>
2332 b
2433 case _ =>
2534 ""
2635 }
2736 val
2837 }
2938
3039
3140 func getMembers () = {
3241 let val = match getString(this, "dao_members") {
3342 case b: String =>
3443 b
3544 case _ =>
3645 ""
3746 }
3847 val
3948 }
4049
4150
42-func isAuthor (a,templateId) = {
43- let val = match getString(this, (("template_" + templateId) + "_proposed")) {
44- case b: String =>
45- b
46- case _ =>
47- ""
48- }
49- (val == toString(a))
51+func isGroupMember (a) = (tryGetInteger(("group_member_" + toString(a))) > 0)
52+
53+
54+func canMemberVote (i,templateId) = {
55+ let centerAddress = tryGetString((("template_" + templateId) + "_center"))
56+ (tryGetInteger(((("center_" + centerAddress) + "_member_") + toString(i.caller))) > 0)
5057 }
5158
5259
53-func isGroupMember (a) = (tryGetInteger((("working_member_" + toString(a)) + "_weight")) > 0)
54-
55-
56-func canMemberVote (i,templateId) = (tryGetInteger((("dao_member_" + toString(i.caller)) + "_weight")) > 0)
57-
58-
5960 @Callable(i)
60-func addDAOMember (memberAddress) = if (!(isOwner(i.caller)))
61+func addDAOMember (memberAddress,centerAddress) = if (!(isOwner(i.caller)))
6162 then throw("access only to the DAO owner")
6263 else {
6364 let group = getMembers()
6465 let newGroup = ((group + ";") + memberAddress)
6566 let groupSize = tryGetInteger("dao_size")
6667 let newGroupSize = (groupSize + 1)
67- WriteSet([DataEntry("dao_members", newGroup), DataEntry("dao_size", newGroupSize), DataEntry((("dao_member_" + memberAddress) + "_weight"), 1)])
68+ WriteSet([DataEntry("dao_members", newGroup), DataEntry("dao_size", newGroupSize), DataEntry(((("center_" + centerAddress) + "_member_") + memberAddress), 1)])
6869 }
6970
7071
7172
7273 @Callable(i)
7374 func addGroupMember (memberAddress) = if (!(isOwner(i.caller)))
7475 then throw("access only to the DAO owner")
7576 else {
7677 let group = getGroup()
7778 let newGroup = ((group + ";") + memberAddress)
78- let groupSize = tryGetInteger("working_size")
79+ let groupSize = tryGetInteger("working_group_size")
7980 let newGroupSize = (groupSize + 1)
80- WriteSet([DataEntry("working_members", newGroup), DataEntry("working_size", newGroupSize), DataEntry((("working_member_" + memberAddress) + "_weight"), 1)])
81+ WriteSet([DataEntry("working_group", newGroup), DataEntry("working_group_size", newGroupSize), DataEntry(("group_member_" + memberAddress), 1)])
8182 }
8283
8384
8485
8586 @Callable(i)
86-func proposeTemplate (title) = WriteSet([DataEntry((("template_" + toBase58String(i.transactionId)) + "_title"), title), DataEntry((("template_" + toBase58String(i.transactionId)) + "_proposed"), toString(i.caller)), DataEntry((("template_" + toBase58String(i.transactionId)) + "_status"), "proposed")])
87-
88-
89-
90-@Callable(i)
91-func addTemplateDetails (templateId,description,author,company,link) = if (!(isAuthor(i.caller, templateId)))
92- then throw("author access only")
93- else WriteSet([DataEntry((("template_" + templateId) + "_description"), description), DataEntry((("template_" + templateId) + "_author"), author), DataEntry((("template_" + templateId) + "_company"), company), DataEntry((("template_" + templateId) + "_link"), link)])
87+func proposeTemplate (title) = WriteSet([DataEntry((("template_" + toBase58String(i.transactionId)) + "_title"), title), DataEntry((("template_" + toBase58String(i.transactionId)) + "_status"), "proposed"), DataEntry((("template_" + toBase58String(i.transactionId)) + "_proposed_by"), toString(i.caller))])
9488
9589
9690
9791 @Callable(i)
9892 func acceptTemplate (templateId,certifier) = if (!(isGroupMember(i.caller)))
9993 then throw("government working group access only")
10094 else WriteSet([DataEntry((("template_" + templateId) + "_center"), certifier), DataEntry((("template_" + templateId) + "_status"), "accepted")])
10195
10296
10397
10498 @Callable(i)
10599 func requestCertificate (templateId,details) = {
106100 let listKey = (("template_" + templateId) + "_applicants")
107101 let currentApplicantsList = match getString(this, listKey) {
108102 case b: String =>
109103 b
110104 case _ =>
111105 ""
112106 }
113107 let newApplicantsList = ((currentApplicantsList + ";") + toString(i.caller))
114- WriteSet([DataEntry((((("template_" + templateId) + "_applicant_") + toString(i.caller)) + "_status"), "requested"), DataEntry((((("template_" + templateId) + "_applicant_") + toString(i.caller)) + "_details"), details), DataEntry(listKey, newApplicantsList)])
108+ ScriptResult(WriteSet([DataEntry((((("template_" + templateId) + "_applicant_") + toString(i.caller)) + "_status"), "requested"), DataEntry((((("template_" + templateId) + "_applicant_") + toString(i.caller)) + "_details"), details), DataEntry(listKey, newApplicantsList)]), TransferSet([ScriptTransfer(i.caller, 500000, unit)]))
115109 }
116110
117111
118112
119113 @Callable(i)
120114 func voteForApplicant (templateId,applicant,voteValue) = if (if ((voteValue != -1))
121115 then (voteValue != 1)
122116 else false)
123117 then throw("vote value needs to be 1 or -1")
124118 else if (!(canMemberVote(i, templateId)))
125119 then throw("this member is not certified to vote")
126120 else {
127121 let voteKey = ((((("template_" + templateId) + "_applicant_") + applicant) + "_vote_") + toString(i.caller))
128122 let vote = tryGetInteger(voteKey)
129123 if ((vote != 0))
130124 then throw("this member has already voted on this applicant")
131125 else {
132126 let teamVotesAmountKey = (((("template_" + templateId) + "_applicant_") + applicant) + "_votes")
133127 let teamScoreKey = (((("template_" + templateId) + "_applicant_") + applicant) + "_score")
134128 let teamVotesAmount = (1 + tryGetInteger(teamVotesAmountKey))
135129 let newTeamScore = (voteValue + tryGetInteger(teamScoreKey))
136130 WriteSet([DataEntry(voteKey, voteValue), DataEntry(teamScoreKey, newTeamScore)])
137131 }
138132 }
139133
140134
141135
142136 @Callable(i)
143137 func finishApplicantVoting (templateId,applicant) = {
144138 func isApplicantVotedEnough (templateId,applicant) = {
145139 let templateMinimumScore = (("template_" + templateId) + "_min_score")
146140 let teamScoreAmountKey = (((("template_" + templateId) + "_applicant_") + applicant) + "_score")
147141 let teamScore = tryGetInteger(teamScoreAmountKey)
148142 if ((teamScore > 0))
149143 then true
150- else throw("not enough votes to make decision")
144+ else throw(("not enough votes to make decision on " + applicant))
151145 }
152146
153147 if (!(isApplicantVotedEnough(templateId, applicant)))
154148 then throw("not enough experts voted to issue certificate")
155149 else WriteSet([DataEntry((((("template_" + templateId) + "_applicant_") + applicant) + "_status"), "approved")])
156150 }
157151
158152

github/deemru/w8io/169f3d6 
50.09 ms