tx · 7FbgU7APpeQemGDYYZ9Kgh1xpN6Cahwh9JihgpgAGkBY 3Mzz3QCpMamT89CaFaovqXpnCdiUaKtLZ4D: -0.01400000 Waves 2019.06.22 19:16 [553479] smart account 3Mzz3QCpMamT89CaFaovqXpnCdiUaKtLZ4D > SELF 0.00000000 Waves
{ "type": 13, "id": "7FbgU7APpeQemGDYYZ9Kgh1xpN6Cahwh9JihgpgAGkBY", "fee": 1400000, "feeAssetId": null, "timestamp": 1561220330658, "version": 1, "sender": "3Mzz3QCpMamT89CaFaovqXpnCdiUaKtLZ4D", "senderPublicKey": "BJRaSW2saRv7CcFs3mSYpaVFQSFpZq9rGKnCcRKuKgWv", "proofs": [ "232fg8tm7eg7qwtdtrxEot32Ff3MsKpEU9Nwxvuu491yvcHhv2sAwch2WmYWfpjJ68H6zjJFbSiuPiGTAzTxUfsw" ], "script": "base64:AAIDAAAAAAAAAAAAAAAdAAAAAAROT05FAgAAAARub25lAAAAAAZWT1RFUlMAAAAAAAAAAAMAAAAABlFVT1JVTQAAAAAAAAAAAgAAAAAGVk9USU5HAgAAAAZ2b3RpbmcAAAAABlJFVkVBTAIAAAAGcmV2ZWFsAAAAAAhGRUFUVVJFRAIAAAAIZmVhdHVyZWQAAAAACERFTElTVEVEAgAAAAhkZWxpc3RlZAEAAAAKZ2V0S2V5SXRlbQAAAAIAAAAIc3VwcGxpZXIAAAAFdGl0bGUJAAEsAAAAAgIAAAAFaXRlbV8JAAJYAAAAAQkAAfcAAAABCQABmwAAAAEJAAEsAAAAAgUAAAAIc3VwcGxpZXIFAAAABXRpdGxlAQAAABJnZXRLZXlJdGVtU3VwcGxpZXIAAAABAAAABGl0ZW0JAAEsAAAAAgUAAAAEaXRlbQIAAAAGX293bmVyAQAAABVnZXRLZXlCYWxhbmNlU3VwcGxpZXIAAAABAAAABGl0ZW0JAAEsAAAAAgUAAAAEaXRlbQIAAAAIX2JhbGFuY2UBAAAAD2dldEtleUl0ZW1QcmljZQAAAAEAAAAEaXRl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UAAAAMbmV3Vm90ZUNvdW50CQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQEAAAAQZ2V0S2V5SXRlbVN0YXR1cwAAAAEFAAAABGl0ZW0DCQAAZwAAAAIFAAAADG5ld1ZvdGVDb3VudAUAAAAGUVVPUlVNBQAAAAR2b3RlBQAAAAZSRVZFQUwFAAAAA25pbAAAAACjIqh5", "chainId": 84, "height": 553479, "spentComplexity": 0 } View: original | compacted Prev: C61ebeiM7iWGYJUJUebHmLWEMcbNizcbDkpqYELujFpe Next: AX4ZFqc8VpaZAXghJsh5c6q2b9vEQAqHwE5UWV8dxrr5 Diff:
Old | New | Differences | |
---|---|---|---|
94 | 94 | func getKeyVoteCount (item,vote) = ((item + "_res:") + vote) | |
95 | 95 | ||
96 | 96 | ||
97 | - | func getValueVoteCount (item,vote) = | |
97 | + | func getValueVoteCount (item,vote) = getNumberByKey(getKeyVoteCount(item, vote)) | |
98 | 98 | ||
99 | 99 | ||
100 | 100 | @Callable(i) | |
186 | 186 | } | |
187 | 187 | ||
188 | 188 | ||
189 | + | ||
190 | + | @Callable(i) | |
191 | + | func voteReveal (item,vote,salt) = { | |
192 | + | let user = toBase58String(i.caller.bytes) | |
193 | + | let status = getValueItemStatus(item) | |
194 | + | let newVoteCount = (getValueVoteCount(item, vote) + 1) | |
195 | + | if ((toBase58String(sha256(toBytes((vote + salt)))) != getValueCommit(item, user))) | |
196 | + | then throw("not valid") | |
197 | + | else if ((VOTERS > getValueCommitsCount(item))) | |
198 | + | then throw("max not reached") | |
199 | + | else if ((getValueReveal(item, user) != NONE)) | |
200 | + | then throw("already participated") | |
201 | + | else if (if ((status != VOTING)) | |
202 | + | then (status != REVEAL) | |
203 | + | else false) | |
204 | + | then throw("wrong status") | |
205 | + | else if (if ((vote != FEATURED)) | |
206 | + | then (vote != DELISTED) | |
207 | + | else false) | |
208 | + | then throw("wrong vote") | |
209 | + | else if (if ((status == FEATURED)) | |
210 | + | then true | |
211 | + | else (status == DELISTED)) | |
212 | + | then throw("vote finished") | |
213 | + | else WriteSet([DataEntry(getKeyReveal(item, user), vote), DataEntry(getKeyVoteCount(item, vote), newVoteCount), DataEntry(getKeyItemStatus(item), if ((newVoteCount >= QUORUM)) | |
214 | + | then vote | |
215 | + | else REVEAL)]) | |
216 | + | } | |
217 | + | ||
218 | + |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let NONE = "none" | |
5 | 5 | ||
6 | 6 | let VOTERS = 3 | |
7 | 7 | ||
8 | 8 | let QUORUM = 2 | |
9 | 9 | ||
10 | 10 | let VOTING = "voting" | |
11 | 11 | ||
12 | 12 | let REVEAL = "reveal" | |
13 | 13 | ||
14 | 14 | let FEATURED = "featured" | |
15 | 15 | ||
16 | 16 | let DELISTED = "delisted" | |
17 | 17 | ||
18 | 18 | func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title))))) | |
19 | 19 | ||
20 | 20 | ||
21 | 21 | func getKeyItemSupplier (item) = (item + "_owner") | |
22 | 22 | ||
23 | 23 | ||
24 | 24 | func getKeyBalanceSupplier (item) = (item + "_balance") | |
25 | 25 | ||
26 | 26 | ||
27 | 27 | func getKeyItemPrice (item) = (item + "_price") | |
28 | 28 | ||
29 | 29 | ||
30 | 30 | func getKeyItemData (item) = (item + "_data") | |
31 | 31 | ||
32 | 32 | ||
33 | 33 | func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt") | |
34 | 34 | ||
35 | 35 | ||
36 | 36 | func getStrByKey (key) = { | |
37 | 37 | let str = match getString(this, key) { | |
38 | 38 | case a: String => | |
39 | 39 | a | |
40 | 40 | case _ => | |
41 | 41 | NONE | |
42 | 42 | } | |
43 | 43 | str | |
44 | 44 | } | |
45 | 45 | ||
46 | 46 | ||
47 | 47 | func getNumberByKey (key) = { | |
48 | 48 | let num = match getInteger(this, key) { | |
49 | 49 | case a: Int => | |
50 | 50 | a | |
51 | 51 | case _ => | |
52 | 52 | 0 | |
53 | 53 | } | |
54 | 54 | num | |
55 | 55 | } | |
56 | 56 | ||
57 | 57 | ||
58 | 58 | func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item)) | |
59 | 59 | ||
60 | 60 | ||
61 | 61 | func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item)) | |
62 | 62 | ||
63 | 63 | ||
64 | 64 | func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item)) | |
65 | 65 | ||
66 | 66 | ||
67 | 67 | func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account)) | |
68 | 68 | ||
69 | 69 | ||
70 | 70 | func getKeyCommit (item,user) = (((item + "_") + user) + "_commit") | |
71 | 71 | ||
72 | 72 | ||
73 | 73 | func getValueCommit (item,user) = getStrByKey(getKeyCommit(item, user)) | |
74 | 74 | ||
75 | 75 | ||
76 | 76 | func getKeyCommitsCount (item) = (item + "_comcnt") | |
77 | 77 | ||
78 | 78 | ||
79 | 79 | func getValueCommitsCount (item) = getNumberByKey(getKeyCommitsCount(item)) | |
80 | 80 | ||
81 | 81 | ||
82 | 82 | func getKeyReveal (item,user) = (((item + "_") + user) + "_reveal") | |
83 | 83 | ||
84 | 84 | ||
85 | 85 | func getValueReveal (item,user) = getStrByKey(getKeyCommit(item, user)) | |
86 | 86 | ||
87 | 87 | ||
88 | 88 | func getKeyItemStatus (item) = (item + "_status") | |
89 | 89 | ||
90 | 90 | ||
91 | 91 | func getValueItemStatus (item) = getStrByKey(getKeyItemStatus(item)) | |
92 | 92 | ||
93 | 93 | ||
94 | 94 | func getKeyVoteCount (item,vote) = ((item + "_res:") + vote) | |
95 | 95 | ||
96 | 96 | ||
97 | - | func getValueVoteCount (item,vote) = | |
97 | + | func getValueVoteCount (item,vote) = getNumberByKey(getKeyVoteCount(item, vote)) | |
98 | 98 | ||
99 | 99 | ||
100 | 100 | @Callable(i) | |
101 | 101 | func purchaseOld (type) = { | |
102 | 102 | let pmt = extract(i.payment) | |
103 | 103 | if (isDefined(pmt.assetId)) | |
104 | 104 | then throw("can use WAVES only at the moment") | |
105 | 105 | else { | |
106 | 106 | let customerAddress = toBase58String(i.caller.bytes) | |
107 | 107 | let price = match getInteger(this, (("item_" + type) + "_coupon_price")) { | |
108 | 108 | case a: Int => | |
109 | 109 | a | |
110 | 110 | case _ => | |
111 | 111 | 0 | |
112 | 112 | } | |
113 | 113 | if ((price > pmt.amount)) | |
114 | 114 | then throw("purschase amount cannot be less than item price") | |
115 | 115 | else if ((pmt.amount > price)) | |
116 | 116 | then throw("purchase amount cannot be higher than item price") | |
117 | 117 | else WriteSet([DataEntry(((("status:purchase_item_" + type) + "_customer_") + customerAddress), "confirmed"), DataEntry(((("price:purchase_item_" + type) + "_customer_") + customerAddress), price)]) | |
118 | 118 | } | |
119 | 119 | } | |
120 | 120 | ||
121 | 121 | ||
122 | 122 | ||
123 | 123 | @Callable(i) | |
124 | 124 | func addItem (title,price,data) = { | |
125 | 125 | let supplierAddress = toBase58String(i.caller.bytes) | |
126 | 126 | let item = getKeyItem(supplierAddress, title) | |
127 | 127 | if ((0 >= price)) | |
128 | 128 | then throw("purchase amount cannot be less than item price") | |
129 | 129 | else if ((getValueItemSupplier(item) != NONE)) | |
130 | 130 | then throw("an items is already exist") | |
131 | 131 | else WriteSet([DataEntry(getKeyItemSupplier(item), supplierAddress), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data)]) | |
132 | 132 | } | |
133 | 133 | ||
134 | 134 | ||
135 | 135 | ||
136 | 136 | @Callable(i) | |
137 | 137 | func purchase (item) = { | |
138 | 138 | let pmt = extract(i.payment) | |
139 | 139 | if (isDefined(pmt.assetId)) | |
140 | 140 | then throw("WAVES tokens only at the moment") | |
141 | 141 | else { | |
142 | 142 | let userAddress = toBase58String(i.caller.bytes) | |
143 | 143 | let price = getValueItemPrice(item) | |
144 | 144 | let supplierAddress = getValueItemSupplier(item) | |
145 | 145 | if ((price > pmt.amount)) | |
146 | 146 | then throw("purchase amount cannot be less than item price") | |
147 | 147 | else if ((pmt.amount > price)) | |
148 | 148 | then throw("purchase amount cannot be higher than item price") | |
149 | 149 | else if ((supplierAddress == NONE)) | |
150 | 150 | then throw("supplier does not exist") | |
151 | 151 | else WriteSet([DataEntry(getKeyUserItemCounter(userAddress, item), (getValueUserItemCounter(userAddress, item) + 1)), DataEntry(getKeyBalanceSupplier(supplierAddress), (getValueBalanceSupplier(supplierAddress) + pmt.amount))]) | |
152 | 152 | } | |
153 | 153 | } | |
154 | 154 | ||
155 | 155 | ||
156 | 156 | ||
157 | 157 | @Callable(i) | |
158 | 158 | func withdraw () = { | |
159 | 159 | let supplierAddress = toBase58String(i.caller.bytes) | |
160 | 160 | let balance = getValueBalanceSupplier(supplierAddress) | |
161 | 161 | if ((0 >= balance)) | |
162 | 162 | then throw("insufficient balance") | |
163 | 163 | else ScriptResult(WriteSet([DataEntry(getKeyBalanceSupplier(supplierAddress), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(supplierAddress), balance, unit)])) | |
164 | 164 | } | |
165 | 165 | ||
166 | 166 | ||
167 | 167 | ||
168 | 168 | @Callable(i) | |
169 | 169 | func voteCommit (item,hash) = { | |
170 | 170 | let user = toBase58String(i.caller.bytes) | |
171 | 171 | let commits = getValueCommitsCount(item) | |
172 | 172 | let status = getValueItemStatus(item) | |
173 | 173 | if ((commits >= VOTERS)) | |
174 | 174 | then throw("max votes") | |
175 | 175 | else if ((getValueCommit(item, user) != NONE)) | |
176 | 176 | then throw("already participated") | |
177 | 177 | else if ((getKeyItemSupplier(item) == NONE)) | |
178 | 178 | then throw("not exist") | |
179 | 179 | else if (if ((status != NONE)) | |
180 | 180 | then (status != VOTING) | |
181 | 181 | else false) | |
182 | 182 | then throw("not possible") | |
183 | 183 | else WriteSet([DataEntry(getKeyCommit(item, user), hash), DataEntry(getKeyCommitsCount(item), (commits + 1)), DataEntry(getKeyItemStatus(item), if ((commits == VOTERS)) | |
184 | 184 | then REVEAL | |
185 | 185 | else VOTING)]) | |
186 | 186 | } | |
187 | 187 | ||
188 | 188 | ||
189 | + | ||
190 | + | @Callable(i) | |
191 | + | func voteReveal (item,vote,salt) = { | |
192 | + | let user = toBase58String(i.caller.bytes) | |
193 | + | let status = getValueItemStatus(item) | |
194 | + | let newVoteCount = (getValueVoteCount(item, vote) + 1) | |
195 | + | if ((toBase58String(sha256(toBytes((vote + salt)))) != getValueCommit(item, user))) | |
196 | + | then throw("not valid") | |
197 | + | else if ((VOTERS > getValueCommitsCount(item))) | |
198 | + | then throw("max not reached") | |
199 | + | else if ((getValueReveal(item, user) != NONE)) | |
200 | + | then throw("already participated") | |
201 | + | else if (if ((status != VOTING)) | |
202 | + | then (status != REVEAL) | |
203 | + | else false) | |
204 | + | then throw("wrong status") | |
205 | + | else if (if ((vote != FEATURED)) | |
206 | + | then (vote != DELISTED) | |
207 | + | else false) | |
208 | + | then throw("wrong vote") | |
209 | + | else if (if ((status == FEATURED)) | |
210 | + | then true | |
211 | + | else (status == DELISTED)) | |
212 | + | then throw("vote finished") | |
213 | + | else WriteSet([DataEntry(getKeyReveal(item, user), vote), DataEntry(getKeyVoteCount(item, vote), newVoteCount), DataEntry(getKeyItemStatus(item), if ((newVoteCount >= QUORUM)) | |
214 | + | then vote | |
215 | + | else REVEAL)]) | |
216 | + | } | |
217 | + | ||
218 | + |
github/deemru/w8io/026f985 57.49 ms ◑