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