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:AAIDAAAAAAAAACsIARIECgIICBIDCgEIEgMKAQgSBAoCCAgSBAoCCAgSBQoDCAgBEgQKAggIAAAABwEAAAANdHJ5R2V0SW50ZWdlcgAAAAEAAAADa2V5BAAAAAN2YWwEAAAAByRtYXRjaDAJAAQaAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAANJbnQEAAAAAWIFAAAAByRtYXRjaDAFAAAAAWIAAAAAAAAAAAAFAAAAA3ZhbAEAAAAMdHJ5R2V0U3RyaW5nAAAAAQAAAANrZXkEAAAAA3ZhbAQAAAAHJG1hdGNoMAkABB0AAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAABlN0cmluZwQAAAABYgUAAAAHJG1hdGNoMAUAAAABYgIAAAAABQAAAAN2YWwBAAAAB2lzT3duZXIAAAABAAAAB2FkZHJlc3MJAAAAAAAAAgUAAAAHYWRkcmVzcwUAAAAEdGhpcwEAAAAIZ2V0R3JvdXAAAAAABAAAAAN2YWwEAAAAByRtYXRjaDAJAAQ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BQAAAAp0ZW1wbGF0ZUlkAgAAAAtfYXBwbGljYW50XwUAAAAJYXBwbGljYW50AgAAAAZfc2NvcmUEAAAACXRlYW1TY29yZQkBAAAADXRyeUdldEludGVnZXIAAAABBQAAABJ0ZWFtU2NvcmVBbW91bnRLZXkDCQAAZgAAAAIFAAAACXRlYW1TY29yZQAAAAAAAAAAAAYJAAACAAAAAQkAASwAAAACAgAAACVub3QgZW5vdWdoIHZvdGVzIHRvIG1ha2UgZGVjaXNpb24gb24gBQAAAAlhcHBsaWNhbnQDCQEAAAABIQAAAAEJAQAAABZpc0FwcGxpY2FudFZvdGVkRW5vdWdoAAAAAgUAAAAKdGVtcGxhdGVJZAUAAAAJYXBwbGljYW50CQAAAgAAAAECAAAALW5vdCBlbm91Z2ggZXhwZXJ0cyB2b3RlZCB0byBpc3N1ZSBjZXJ0aWZpY2F0ZQkBAAAACFdyaXRlU2V0AAAAAQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkAASwAAAACCQABLAAAAAIJAAEsAAAAAgkAASwAAAACAgAAAAl0ZW1wbGF0ZV8FAAAACnRlbXBsYXRlSWQCAAAAC19hcHBsaWNhbnRfBQAAAAlhcHBsaWNhbnQCAAAAB19zdGF0dXMCAAAACGFwcHJvdmVkBQAAAANuaWwAAAAAqnfs6g==", "height": 1262639, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 7tqrM6xgyEoeCbryov3MnNUWd8v48UmGUwPpJvYPSpoC Next: Hku3UNMeQaGQ4pZdTnXnr5schyymfJB55eAfUeVMsiUQ Diff:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let QUORUM = 50 | |
5 | - | ||
6 | 4 | func tryGetInteger (key) = { | |
7 | 5 | let val = match getInteger(this, key) { | |
8 | 6 | case b: Int => | |
14 | 12 | } | |
15 | 13 | ||
16 | 14 | ||
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 | + | ||
17 | 26 | func isOwner (address) = (address == this) | |
18 | 27 | ||
19 | 28 | ||
20 | 29 | func getGroup () = { | |
21 | - | let val = match getString(this, "working_ | |
30 | + | let val = match getString(this, "working_group") { | |
22 | 31 | case b: String => | |
23 | 32 | b | |
24 | 33 | case _ => | |
39 | 48 | } | |
40 | 49 | ||
41 | 50 | ||
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) | |
50 | 57 | } | |
51 | 58 | ||
52 | 59 | ||
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 | - | ||
59 | 60 | @Callable(i) | |
60 | - | func addDAOMember (memberAddress) = if (!(isOwner(i.caller))) | |
61 | + | func addDAOMember (memberAddress,centerAddress) = if (!(isOwner(i.caller))) | |
61 | 62 | then throw("access only to the DAO owner") | |
62 | 63 | else { | |
63 | 64 | let group = getMembers() | |
64 | 65 | let newGroup = ((group + ";") + memberAddress) | |
65 | 66 | let groupSize = tryGetInteger("dao_size") | |
66 | 67 | let newGroupSize = (groupSize + 1) | |
67 | - | WriteSet([DataEntry("dao_members", newGroup), DataEntry("dao_size", newGroupSize), DataEntry(((" | |
68 | + | WriteSet([DataEntry("dao_members", newGroup), DataEntry("dao_size", newGroupSize), DataEntry(((("center_" + centerAddress) + "_member_") + memberAddress), 1)]) | |
68 | 69 | } | |
69 | 70 | ||
70 | 71 | ||
75 | 76 | else { | |
76 | 77 | let group = getGroup() | |
77 | 78 | let newGroup = ((group + ";") + memberAddress) | |
78 | - | let groupSize = tryGetInteger("working_size") | |
79 | + | let groupSize = tryGetInteger("working_group_size") | |
79 | 80 | let newGroupSize = (groupSize + 1) | |
80 | - | WriteSet([DataEntry("working_ | |
81 | + | WriteSet([DataEntry("working_group", newGroup), DataEntry("working_group_size", newGroupSize), DataEntry(("group_member_" + memberAddress), 1)]) | |
81 | 82 | } | |
82 | 83 | ||
83 | 84 | ||
84 | 85 | ||
85 | 86 | @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))]) | |
94 | 88 | ||
95 | 89 | ||
96 | 90 | ||
111 | 105 | "" | |
112 | 106 | } | |
113 | 107 | 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)])) | |
115 | 109 | } | |
116 | 110 | ||
117 | 111 | ||
147 | 141 | let teamScore = tryGetInteger(teamScoreAmountKey) | |
148 | 142 | if ((teamScore > 0)) | |
149 | 143 | then true | |
150 | - | else throw("not enough votes to make decision") | |
144 | + | else throw(("not enough votes to make decision on " + applicant)) | |
151 | 145 | } | |
152 | 146 | ||
153 | 147 | if (!(isApplicantVotedEnough(templateId, applicant))) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let QUORUM = 50 | |
5 | - | ||
6 | 4 | func tryGetInteger (key) = { | |
7 | 5 | let val = match getInteger(this, key) { | |
8 | 6 | case b: Int => | |
9 | 7 | b | |
10 | 8 | case _ => | |
11 | 9 | 0 | |
12 | 10 | } | |
13 | 11 | val | |
14 | 12 | } | |
15 | 13 | ||
16 | 14 | ||
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 | + | ||
17 | 26 | func isOwner (address) = (address == this) | |
18 | 27 | ||
19 | 28 | ||
20 | 29 | func getGroup () = { | |
21 | - | let val = match getString(this, "working_ | |
30 | + | let val = match getString(this, "working_group") { | |
22 | 31 | case b: String => | |
23 | 32 | b | |
24 | 33 | case _ => | |
25 | 34 | "" | |
26 | 35 | } | |
27 | 36 | val | |
28 | 37 | } | |
29 | 38 | ||
30 | 39 | ||
31 | 40 | func getMembers () = { | |
32 | 41 | let val = match getString(this, "dao_members") { | |
33 | 42 | case b: String => | |
34 | 43 | b | |
35 | 44 | case _ => | |
36 | 45 | "" | |
37 | 46 | } | |
38 | 47 | val | |
39 | 48 | } | |
40 | 49 | ||
41 | 50 | ||
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) | |
50 | 57 | } | |
51 | 58 | ||
52 | 59 | ||
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 | - | ||
59 | 60 | @Callable(i) | |
60 | - | func addDAOMember (memberAddress) = if (!(isOwner(i.caller))) | |
61 | + | func addDAOMember (memberAddress,centerAddress) = if (!(isOwner(i.caller))) | |
61 | 62 | then throw("access only to the DAO owner") | |
62 | 63 | else { | |
63 | 64 | let group = getMembers() | |
64 | 65 | let newGroup = ((group + ";") + memberAddress) | |
65 | 66 | let groupSize = tryGetInteger("dao_size") | |
66 | 67 | let newGroupSize = (groupSize + 1) | |
67 | - | WriteSet([DataEntry("dao_members", newGroup), DataEntry("dao_size", newGroupSize), DataEntry(((" | |
68 | + | WriteSet([DataEntry("dao_members", newGroup), DataEntry("dao_size", newGroupSize), DataEntry(((("center_" + centerAddress) + "_member_") + memberAddress), 1)]) | |
68 | 69 | } | |
69 | 70 | ||
70 | 71 | ||
71 | 72 | ||
72 | 73 | @Callable(i) | |
73 | 74 | func addGroupMember (memberAddress) = if (!(isOwner(i.caller))) | |
74 | 75 | then throw("access only to the DAO owner") | |
75 | 76 | else { | |
76 | 77 | let group = getGroup() | |
77 | 78 | let newGroup = ((group + ";") + memberAddress) | |
78 | - | let groupSize = tryGetInteger("working_size") | |
79 | + | let groupSize = tryGetInteger("working_group_size") | |
79 | 80 | let newGroupSize = (groupSize + 1) | |
80 | - | WriteSet([DataEntry("working_ | |
81 | + | WriteSet([DataEntry("working_group", newGroup), DataEntry("working_group_size", newGroupSize), DataEntry(("group_member_" + memberAddress), 1)]) | |
81 | 82 | } | |
82 | 83 | ||
83 | 84 | ||
84 | 85 | ||
85 | 86 | @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))]) | |
94 | 88 | ||
95 | 89 | ||
96 | 90 | ||
97 | 91 | @Callable(i) | |
98 | 92 | func acceptTemplate (templateId,certifier) = if (!(isGroupMember(i.caller))) | |
99 | 93 | then throw("government working group access only") | |
100 | 94 | else WriteSet([DataEntry((("template_" + templateId) + "_center"), certifier), DataEntry((("template_" + templateId) + "_status"), "accepted")]) | |
101 | 95 | ||
102 | 96 | ||
103 | 97 | ||
104 | 98 | @Callable(i) | |
105 | 99 | func requestCertificate (templateId,details) = { | |
106 | 100 | let listKey = (("template_" + templateId) + "_applicants") | |
107 | 101 | let currentApplicantsList = match getString(this, listKey) { | |
108 | 102 | case b: String => | |
109 | 103 | b | |
110 | 104 | case _ => | |
111 | 105 | "" | |
112 | 106 | } | |
113 | 107 | 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)])) | |
115 | 109 | } | |
116 | 110 | ||
117 | 111 | ||
118 | 112 | ||
119 | 113 | @Callable(i) | |
120 | 114 | func voteForApplicant (templateId,applicant,voteValue) = if (if ((voteValue != -1)) | |
121 | 115 | then (voteValue != 1) | |
122 | 116 | else false) | |
123 | 117 | then throw("vote value needs to be 1 or -1") | |
124 | 118 | else if (!(canMemberVote(i, templateId))) | |
125 | 119 | then throw("this member is not certified to vote") | |
126 | 120 | else { | |
127 | 121 | let voteKey = ((((("template_" + templateId) + "_applicant_") + applicant) + "_vote_") + toString(i.caller)) | |
128 | 122 | let vote = tryGetInteger(voteKey) | |
129 | 123 | if ((vote != 0)) | |
130 | 124 | then throw("this member has already voted on this applicant") | |
131 | 125 | else { | |
132 | 126 | let teamVotesAmountKey = (((("template_" + templateId) + "_applicant_") + applicant) + "_votes") | |
133 | 127 | let teamScoreKey = (((("template_" + templateId) + "_applicant_") + applicant) + "_score") | |
134 | 128 | let teamVotesAmount = (1 + tryGetInteger(teamVotesAmountKey)) | |
135 | 129 | let newTeamScore = (voteValue + tryGetInteger(teamScoreKey)) | |
136 | 130 | WriteSet([DataEntry(voteKey, voteValue), DataEntry(teamScoreKey, newTeamScore)]) | |
137 | 131 | } | |
138 | 132 | } | |
139 | 133 | ||
140 | 134 | ||
141 | 135 | ||
142 | 136 | @Callable(i) | |
143 | 137 | func finishApplicantVoting (templateId,applicant) = { | |
144 | 138 | func isApplicantVotedEnough (templateId,applicant) = { | |
145 | 139 | let templateMinimumScore = (("template_" + templateId) + "_min_score") | |
146 | 140 | let teamScoreAmountKey = (((("template_" + templateId) + "_applicant_") + applicant) + "_score") | |
147 | 141 | let teamScore = tryGetInteger(teamScoreAmountKey) | |
148 | 142 | if ((teamScore > 0)) | |
149 | 143 | then true | |
150 | - | else throw("not enough votes to make decision") | |
144 | + | else throw(("not enough votes to make decision on " + applicant)) | |
151 | 145 | } | |
152 | 146 | ||
153 | 147 | if (!(isApplicantVotedEnough(templateId, applicant))) | |
154 | 148 | then throw("not enough experts voted to issue certificate") | |
155 | 149 | else WriteSet([DataEntry((((("template_" + templateId) + "_applicant_") + applicant) + "_status"), "approved")]) | |
156 | 150 | } | |
157 | 151 | ||
158 | 152 |
github/deemru/w8io/169f3d6 50.09 ms ◑