tx · GV8k3CX1XcvyhKysWv58Wxgr6vb5Fo9j8CyW4L3BSedL 3MvJGRwAHk6nULAUgXQRzM3eeqEgnWcuQ33: -0.01000000 Waves 2020.06.17 19:30 [1047777] smart account 3MvJGRwAHk6nULAUgXQRzM3eeqEgnWcuQ33 > SELF 0.00000000 Waves
{ "type": 13, "id": "GV8k3CX1XcvyhKysWv58Wxgr6vb5Fo9j8CyW4L3BSedL", "fee": 1000000, "feeAssetId": null, "timestamp": 1592411492672, "version": 1, "sender": "3MvJGRwAHk6nULAUgXQRzM3eeqEgnWcuQ33", "senderPublicKey": "8VLrnJUSn15GVsiwJGB1RV5z7B4J6RowfNie6SpuMFgR", "proofs": [ "2u58qEx3fbmMuYZ2KtUgLj1pxD9FaCastV9RpQAmA8btgJYi6RBfDscZrjovpFZtr2Hs7k8oAeXiT8DsT6aWSYzm" ], "script": "base64:AAIDAAAAAAAAAAgIARIECgIICAAAABEAAAAAC2FkZHJlc3NCb29rCQEAAAAHQWRkcmVzcwAAAAEBAAAAGgFUVoHUeTQTO77iaMaO0CyN+LlydsBXbwHeAAAAABN3aGl0ZWxpc3RBZGRyZXNzS2V5AgAAABB3aGl0ZWxpc3RBZGRyZXNzAAAAABdkQXBwV2hpdGVsaXN0QWRkcmVzc0tleQIAAAAUZEFwcFdoaXRlbGlzdEFkZHJlc3MAAAAADnRvdGFsV2VpZ2h0S2V5AgAAAAt0b3RhbFdlaWdodAAAAAARbWluVG90YWxXZWlnaHRLZXkCAAAADm1pblRvdGFsV2VpZ2h0AAAAAAlzdGFydFRpbWUAAAAAAF7p25AAAAAAB2VuZFRpbWUAAAAAAF77N1AAAAAAA3ZlcgIAAAAFNS4wLjEAAAAACnZhbGlkU3RhdGUAAAAAAAAAA+gAAAAADmdldEN1cnJlbnRUaW1lCQAAaQAAAAIIBQAAAAlsYXN0QmxvY2sAAAAJdGltZXN0YW1wAAAAAAAAAAPoAQAAAApoYXNTdGFydGVkAAAAAAkAAGcAAAACBQAAAA5nZXRD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AAAJaXNEZWZpbmVkAAAAAQkABBoAAAACBQAAAAlwQWRkcmVzczMFAAAABHR4SWQAAAAAAAAAAAEAAAAAAAAAAAAEAAAAC3BLZXk0U2lnbmVkAwkBAAAACWlzRGVmaW5lZAAAAAEJAAQaAAAAAgUAAAAJcEFkZHJlc3M0BQAAAAR0eElkAAAAAAAAAAABAAAAAAAAAAAABAAAAAtwS2V5NVNpZ25lZAMJAQAAAAlpc0RlZmluZWQAAAABCQAEGgAAAAIFAAAACXBBZGRyZXNzNQUAAAAEdHhJZAAAAAAAAAAAAQAAAAAAAAAAAAQAAAALcEtleTZTaWduZWQDCQEAAAAJaXNEZWZpbmVkAAAAAQkABBoAAAACBQAAAAlwQWRkcmVzczYFAAAABHR4SWQAAAAAAAAAAAEAAAAAAAAAAAAEAAAAC3BLZXk3U2lnbmVkAwkBAAAACWlzRGVmaW5lZAAAAAEJAAQaAAAAAgUAAAAJcEFkZHJlc3M3BQAAAAR0eElkAAAAAAAAAAABAAAAAAAAAAAABAAAAAtwS2V5OFNpZ25lZAMJAQAAAAlpc0RlZmluZWQAAAABCQAEGgAAAAIFAAAACXBBZGRyZXNzOAUAAAAEdHhJZAAAAAAAAAAAAQAAAAAAAAAAAAkAAGcAAAACCQAAZAAAAAIJAABkAAAAAgkAAGQAAAACCQAAZAAAAAIJAABkAAAAAgkAAGQAAAACCQAAZAAAAAIFAAAAC3BLZXkxU2lnbmVkBQAAAAtwS2V5MlNpZ25lZAUAAAALcEtleTNTaWduZWQFAAAAC3BLZXk0U2lnbmVkBQAAAAtwS2V5NVNpZ25lZAUAAAALcEtleTZTaWduZWQFAAAAC3BLZXk3U2lnbmVkBQAAAAtwS2V5OFNpZ25lZAAAAAAAAAAAAwfLek5X", "chainId": 84, "height": 1047777, "spentComplexity": 0 } View: original | compacted Prev: none Next: none Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 3 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let addressBook = Address(base58'3MwoVRAPfC2NKuuYJKHVAVtUFhq8MyTEfQh') | |
5 | + | ||
6 | + | let whitelistAddressKey = "whitelistAddress" | |
7 | + | ||
8 | + | let dAppWhitelistAddressKey = "dAppWhitelistAddress" | |
9 | + | ||
10 | + | let totalWeightKey = "totalWeight" | |
11 | + | ||
12 | + | let minTotalWeightKey = "minTotalWeight" | |
13 | + | ||
14 | + | let startTime = 1592384400 | |
15 | + | ||
16 | + | let endTime = 1593522000 | |
17 | + | ||
18 | + | let ver = "5.0.1" | |
19 | + | ||
20 | + | let validState = 1000 | |
21 | + | ||
22 | + | let getCurrentTime = (lastBlock.timestamp / 1000) | |
23 | + | ||
24 | + | func hasStarted () = (getCurrentTime >= startTime) | |
25 | + | ||
26 | + | ||
27 | + | func hasEnded () = (getCurrentTime > endTime) | |
28 | + | ||
29 | + | ||
30 | + | func getAddressFromBook (key) = match getString(addressBook, key) { | |
31 | + | case a: String => | |
32 | + | Address(fromBase58String(a)) | |
33 | + | case _ => | |
34 | + | throw("no key") | |
35 | + | } | |
36 | + | ||
37 | + | ||
38 | + | func checkAddress (account) = { | |
39 | + | let isAccountAllow = match getInteger(getAddressFromBook(whitelistAddressKey), account) { | |
40 | + | case a: Int => | |
41 | + | a | |
42 | + | case _ => | |
43 | + | -255 | |
44 | + | } | |
45 | + | (isAccountAllow == validState) | |
46 | + | } | |
47 | + | ||
48 | + | ||
49 | + | func getAmount (key) = match getInteger(this, key) { | |
50 | + | case a: Int => | |
51 | + | a | |
52 | + | case _ => | |
53 | + | 0 | |
54 | + | } | |
55 | + | ||
56 | + | ||
57 | + | func isVoted (key) = match getBoolean(this, key) { | |
58 | + | case a: Boolean => | |
59 | + | a | |
60 | + | case _ => | |
61 | + | false | |
62 | + | } | |
63 | + | ||
64 | + | ||
65 | + | func getQuestionAnswerKey (question,answer) = ((("question_" + question) + "_answer_") + answer) | |
66 | + | ||
67 | + | ||
68 | + | @Callable(i) | |
69 | + | func vote (question,answer) = { | |
70 | + | let dAppStatus = match getInteger(getAddressFromBook(dAppWhitelistAddressKey), toString(this)) { | |
71 | + | case a: Int => | |
72 | + | a | |
73 | + | case _ => | |
74 | + | 0 | |
75 | + | } | |
76 | + | let callerAddress = toString(i.caller) | |
77 | + | let callerCheck = checkAddress(callerAddress) | |
78 | + | let questionKey = ((("address_" + callerAddress) + "_question_") + question) | |
79 | + | let addressVotedKey = (("address_" + callerAddress) + "_voted") | |
80 | + | let addressWeightKey = (("address_" + callerAddress) + "_weight") | |
81 | + | let questionTotalWeightKey = (("question_" + question) + "_totalWeight") | |
82 | + | let callerWeight = getAmount(addressWeightKey) | |
83 | + | let callerVoted = isVoted(addressVotedKey) | |
84 | + | let callerVotedOnQuestion = match getString(this, questionKey) { | |
85 | + | case a: String => | |
86 | + | true | |
87 | + | case _ => | |
88 | + | false | |
89 | + | } | |
90 | + | if ((dAppStatus != 1)) | |
91 | + | then throw("#001 Dealer dApp is not active") | |
92 | + | else if (!(hasStarted())) | |
93 | + | then throw("#002 The Vote not start") | |
94 | + | else if (hasEnded()) | |
95 | + | then throw("#003 The Vote already completed") | |
96 | + | else if (!(callerCheck)) | |
97 | + | then throw("#004 This account has no right to vote.") | |
98 | + | else if ((callerWeight == 0)) | |
99 | + | then throw("#005 This account has no weight to vote.") | |
100 | + | else if ((callerVotedOnQuestion == true)) | |
101 | + | then throw("#006 This account has already voted on this question.") | |
102 | + | else { | |
103 | + | let answers = split(answer, ",") | |
104 | + | func foldFunc (acc,e) = { | |
105 | + | let key = getQuestionAnswerKey(question, e) | |
106 | + | let currentWeight = valueOrErrorMessage(getInteger(this, key), "#007 Wrong answer") | |
107 | + | DataEntry(key, (callerWeight + currentWeight)) :: acc | |
108 | + | } | |
109 | + | ||
110 | + | let accum = { | |
111 | + | let $list33083339 = answers | |
112 | + | let $size33083339 = size($list33083339) | |
113 | + | let $acc033083339 = nil | |
114 | + | if (($size33083339 == 0)) | |
115 | + | then $acc033083339 | |
116 | + | else { | |
117 | + | let $acc133083339 = foldFunc($acc033083339, $list33083339[0]) | |
118 | + | if (($size33083339 == 1)) | |
119 | + | then $acc133083339 | |
120 | + | else { | |
121 | + | let $acc233083339 = foldFunc($acc133083339, $list33083339[1]) | |
122 | + | if (($size33083339 == 2)) | |
123 | + | then $acc233083339 | |
124 | + | else { | |
125 | + | let $acc333083339 = foldFunc($acc233083339, $list33083339[2]) | |
126 | + | if (($size33083339 == 3)) | |
127 | + | then $acc333083339 | |
128 | + | else { | |
129 | + | let $acc433083339 = foldFunc($acc333083339, $list33083339[3]) | |
130 | + | if (($size33083339 == 4)) | |
131 | + | then $acc433083339 | |
132 | + | else { | |
133 | + | let $acc533083339 = foldFunc($acc433083339, $list33083339[4]) | |
134 | + | if (($size33083339 == 5)) | |
135 | + | then $acc533083339 | |
136 | + | else { | |
137 | + | let $acc633083339 = foldFunc($acc533083339, $list33083339[5]) | |
138 | + | if (($size33083339 == 6)) | |
139 | + | then $acc633083339 | |
140 | + | else { | |
141 | + | let $acc733083339 = foldFunc($acc633083339, $list33083339[6]) | |
142 | + | if (($size33083339 == 7)) | |
143 | + | then $acc733083339 | |
144 | + | else { | |
145 | + | let $acc833083339 = foldFunc($acc733083339, $list33083339[7]) | |
146 | + | if (($size33083339 == 8)) | |
147 | + | then $acc833083339 | |
148 | + | else { | |
149 | + | let $acc933083339 = foldFunc($acc833083339, $list33083339[8]) | |
150 | + | if (($size33083339 == 9)) | |
151 | + | then $acc933083339 | |
152 | + | else { | |
153 | + | let $acc1033083339 = foldFunc($acc933083339, $list33083339[9]) | |
154 | + | if (($size33083339 == 10)) | |
155 | + | then $acc1033083339 | |
156 | + | else { | |
157 | + | let $acc1133083339 = foldFunc($acc1033083339, $list33083339[10]) | |
158 | + | throw("List size exceed 10") | |
159 | + | } | |
160 | + | } | |
161 | + | } | |
162 | + | } | |
163 | + | } | |
164 | + | } | |
165 | + | } | |
166 | + | } | |
167 | + | } | |
168 | + | } | |
169 | + | } | |
170 | + | } | |
171 | + | let res = DataEntry(questionKey, answer) :: accum | |
172 | + | let resWithQuestionTotalWeight = DataEntry(questionTotalWeightKey, (getAmount(questionTotalWeightKey) + callerWeight)) :: res | |
173 | + | if ((callerVoted == true)) | |
174 | + | then WriteSet(resWithQuestionTotalWeight) | |
175 | + | else { | |
176 | + | let resWithFlag = DataEntry(totalWeightKey, (getAmount(totalWeightKey) + callerWeight)) :: resWithQuestionTotalWeight | |
177 | + | WriteSet(DataEntry(addressVotedKey, true) :: resWithFlag) | |
178 | + | } | |
179 | + | } | |
180 | + | } | |
181 | + | ||
182 | + | ||
183 | + | @Verifier(tx) | |
184 | + | func verify () = match tx { | |
185 | + | case tx: SetScriptTransaction => | |
186 | + | let txId = toBase58String(tx.id) | |
187 | + | let pAddress1 = getAddressFromBook("pAddress1") | |
188 | + | let pAddress2 = getAddressFromBook("pAddress2") | |
189 | + | let pAddress3 = getAddressFromBook("pAddress3") | |
190 | + | let pAddress4 = getAddressFromBook("pAddress4") | |
191 | + | let pAddress5 = getAddressFromBook("pAddress5") | |
192 | + | let pAddress6 = getAddressFromBook("pAddress6") | |
193 | + | let pAddress7 = getAddressFromBook("pAddress7") | |
194 | + | let pAddress8 = getAddressFromBook("pAddress8") | |
195 | + | let pKey1Signed = if (isDefined(getInteger(pAddress1, txId))) | |
196 | + | then 1 | |
197 | + | else 0 | |
198 | + | let pKey2Signed = if (isDefined(getInteger(pAddress2, txId))) | |
199 | + | then 1 | |
200 | + | else 0 | |
201 | + | let pKey3Signed = if (isDefined(getInteger(pAddress3, txId))) | |
202 | + | then 1 | |
203 | + | else 0 | |
204 | + | let pKey4Signed = if (isDefined(getInteger(pAddress4, txId))) | |
205 | + | then 1 | |
206 | + | else 0 | |
207 | + | let pKey5Signed = if (isDefined(getInteger(pAddress5, txId))) | |
208 | + | then 1 | |
209 | + | else 0 | |
210 | + | let pKey6Signed = if (isDefined(getInteger(pAddress6, txId))) | |
211 | + | then 1 | |
212 | + | else 0 | |
213 | + | let pKey7Signed = if (isDefined(getInteger(pAddress7, txId))) | |
214 | + | then 1 | |
215 | + | else 0 | |
216 | + | let pKey8Signed = if (isDefined(getInteger(pAddress8, txId))) | |
217 | + | then 1 | |
218 | + | else 0 | |
219 | + | ((((((((pKey1Signed + pKey2Signed) + pKey3Signed) + pKey4Signed) + pKey5Signed) + pKey6Signed) + pKey7Signed) + pKey8Signed) >= 3) | |
220 | + | case _ => | |
221 | + | false | |
222 | + | } | |
223 | + |
github/deemru/w8io/026f985 20.53 ms ◑