tx · HT51z3nKsamB2FFah6M3oPYw6Rc52jZcAdLNXbFMYBXb 3N2BZgaSNSoSbv7EpQ14Q7SiirXkZyF2anW: -0.01000000 Waves 2019.11.26 19:06 [782450] smart account 3N2BZgaSNSoSbv7EpQ14Q7SiirXkZyF2anW > SELF 0.00000000 Waves
{ "type": 13, "id": "HT51z3nKsamB2FFah6M3oPYw6Rc52jZcAdLNXbFMYBXb", "fee": 1000000, "feeAssetId": null, "timestamp": 1574784359563, "version": 1, "sender": "3N2BZgaSNSoSbv7EpQ14Q7SiirXkZyF2anW", "senderPublicKey": "CNbc1JJBPbnTDihvZeUVT9DyKRBoNTAKnRjmuwfuwDM5", "proofs": [ "tuHCtCMoSumutbbDtZQ9Co1HuSP6JQjwrBtnmMmKRVekYTjxRLCQSq6mtMmiqJsaHWRiwK64xYAJopvqFfQbGBe" ], "script": "base64:AAIDAAAAAAAAAB0IARIFCgMIAQgSAwoBCBIAEgQKAggIEgUKAwgICAAAAB0AAAAABE5PTkUCAAAABG5vbmUAAAAABlZPVEVSUwAAAAAAAAAAAwAAAAAGUVVPUlVNAAAAAAAAAAACAAAAAAZWT1RJTkcCAAAABnZvdGluZwAAAAAGUkVWRUFMAgAAAAZyZXZlYWwAAAAACEZFQVRVUkVEAgAAAAhmZWF0dXJlZAAAAAAIREVMSVNURUQCAAAACGRlbGlzdGVkAQAAAA5nZXROdW1iZXJCeUtleQAAAAEAAAADa2V5BAAAAANudW0EAAAAByRtYXRjaDAJAAQaAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAANJbnQEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEAAAAAAAAAAAAFAAAAA251bQEAAAALZ2V0U3RyQnlLZXkAAAABAAAAA2tleQQAAAADc3RyBAAAAAckbWF0Y2gwCQAEHQAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAGU3RyaW5nBAAAAAFhBQAAA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udHJ5AAAAAgkBAAAAD2dldEtleVZvdGVDb3VudAAAAAIFAAAABGl0ZW0FAAAABHZvdGUFAAAADG5ld1ZvdGVDb3VudAkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkBAAAAEGdldEtleUl0ZW1TdGF0dXMAAAABBQAAAARpdGVtAwkAAGcAAAACBQAAAAxuZXdWb3RlQ291bnQFAAAABlFVT1JVTQUAAAAEdm90ZQUAAAAGUkVWRUFMBQAAAANuaWwAAAAAQ1CUtg==", "chainId": 84, "height": 782450, "spentComplexity": 0 } View: original | compacted Prev: none Next: D8ygFZAdkbk1rS3hBpxbDFTSYmP9ZHL3i6YN8KHwPqNf 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 | + | func getNumberByKey (key) = { | |
19 | + | let num = match getInteger(this, key) { | |
20 | + | case a: Int => | |
21 | + | a | |
22 | + | case _ => | |
23 | + | 0 | |
24 | + | } | |
25 | + | num | |
26 | + | } | |
27 | + | ||
28 | + | ||
29 | + | func getStrByKey (key) = { | |
30 | + | let str = match getString(this, key) { | |
31 | + | case a: String => | |
32 | + | a | |
33 | + | case _ => | |
34 | + | NONE | |
35 | + | } | |
36 | + | str | |
37 | + | } | |
38 | + | ||
39 | + | ||
40 | + | func getKeyItemPrice (item) = (item + "_price") | |
41 | + | ||
42 | + | ||
43 | + | func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item)) | |
44 | + | ||
45 | + | ||
46 | + | func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt") | |
47 | + | ||
48 | + | ||
49 | + | func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item)) | |
50 | + | ||
51 | + | ||
52 | + | func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title))))) | |
53 | + | ||
54 | + | ||
55 | + | func getKeyItemData (item) = (item + "_data") | |
56 | + | ||
57 | + | ||
58 | + | func getKeyItemSupplier (item) = (item + "_owner") | |
59 | + | ||
60 | + | ||
61 | + | func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item)) | |
62 | + | ||
63 | + | ||
64 | + | func getKeyBalanceSupplier (account) = (account + "_balance") | |
65 | + | ||
66 | + | ||
67 | + | func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account)) | |
68 | + | ||
69 | + | ||
70 | + | func getKeyCommit (item,user) = (((item + "_") + user) + "_commit") | |
71 | + | ||
72 | + | ||
73 | + | func getValueCommit (item,user) = getStrByKey(getKeyCommit(item, user)) | |
74 | + | ||
75 | + | ||
76 | + | func getKeyCommitsCount (item) = (item + "_comctn") | |
77 | + | ||
78 | + | ||
79 | + | func getValueCommitsCount (item) = getNumberByKey(getKeyCommitsCount(item)) | |
80 | + | ||
81 | + | ||
82 | + | func getKeyReveal (item,user) = (((item + "_") + user) + "_reveal") | |
83 | + | ||
84 | + | ||
85 | + | func getValueReveal (item,user) = getStrByKey(getKeyReveal(item, user)) | |
86 | + | ||
87 | + | ||
88 | + | func getKeyItemStatus (item) = (item + "_status") | |
89 | + | ||
90 | + | ||
91 | + | func getValueItemStatus (item) = getStrByKey(getKeyItemStatus(item)) | |
92 | + | ||
93 | + | ||
94 | + | func getKeyVoteCount (item,vote) = ((item + "_res:") + vote) | |
95 | + | ||
96 | + | ||
97 | + | func getValueVoteCount (item,vote) = getNumberByKey(getKeyVoteCount(item, vote)) | |
98 | + | ||
99 | + | ||
100 | + | @Callable(i) | |
101 | + | func addItem (title,price,data) = { | |
102 | + | let supplierAddress = toBase58String(i.caller.bytes) | |
103 | + | let item = getKeyItem(supplierAddress, title) | |
104 | + | if ((0 >= price)) | |
105 | + | then throw("purchase amount cannot be less than item price") | |
106 | + | else if ((getValueItemSupplier(item) != NONE)) | |
107 | + | then throw("an item is already exist") | |
108 | + | else WriteSet([DataEntry(getKeyItemSupplier(item), supplierAddress), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data)]) | |
109 | + | } | |
110 | + | ||
111 | + | ||
112 | + | ||
113 | + | @Callable(i) | |
114 | + | func purchase (item) = { | |
115 | + | let pmt = extract(i.payment) | |
116 | + | if (isDefined(pmt.assetId)) | |
117 | + | then throw("WAVES tokens only at the moment") | |
118 | + | else { | |
119 | + | let userAddress = toBase58String(i.caller.bytes) | |
120 | + | let price = getValueItemPrice(item) | |
121 | + | let supplierAddress = getValueItemSupplier(item) | |
122 | + | if ((price > pmt.amount)) | |
123 | + | then throw("purchase amount cannot be less than item price") | |
124 | + | else if ((pmt.amount > price)) | |
125 | + | then throw("purchase amount cannot be higher than item price") | |
126 | + | else if ((supplierAddress == NONE)) | |
127 | + | then throw("supplier does not exist") | |
128 | + | else WriteSet([DataEntry(getKeyUserItemCounter(userAddress, item), (getValueUserItemCounter(userAddress, item) + 1)), DataEntry(getKeyBalanceSupplier(supplierAddress), (getValueBalanceSupplier(supplierAddress) + pmt.amount))]) | |
129 | + | } | |
130 | + | } | |
131 | + | ||
132 | + | ||
133 | + | ||
134 | + | @Callable(i) | |
135 | + | func withdraw () = { | |
136 | + | let supplierAddress = toBase58String(i.caller.bytes) | |
137 | + | let balance = getValueBalanceSupplier(supplierAddress) | |
138 | + | if ((0 >= balance)) | |
139 | + | then throw("insufficient balbance") | |
140 | + | else ScriptResult(WriteSet([DataEntry(getKeyBalanceSupplier(supplierAddress), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(supplierAddress), balance, unit)])) | |
141 | + | } | |
142 | + | ||
143 | + | ||
144 | + | ||
145 | + | @Callable(i) | |
146 | + | func voteCommit (item,hash) = { | |
147 | + | let user = toBase58String(i.caller.bytes) | |
148 | + | let commits = getValueCommitsCount(item) | |
149 | + | let status = getValueItemStatus(item) | |
150 | + | if ((commits >= VOTERS)) | |
151 | + | then throw("reached max num of voters") | |
152 | + | else if ((getValueCommit(item, user) != NONE)) | |
153 | + | then throw("user has already participated") | |
154 | + | else if ((getKeyItemSupplier(item) == NONE)) | |
155 | + | then throw("item does not exist") | |
156 | + | else if (if ((status != NONE)) | |
157 | + | then (status != VOTING) | |
158 | + | else false) | |
159 | + | then throw("voting is not possible") | |
160 | + | else WriteSet([DataEntry(getKeyCommit(item, user), hash), DataEntry(getKeyCommitsCount(item), (commits + 1)), DataEntry(getKeyItemStatus(item), if ((commits == VOTERS)) | |
161 | + | then REVEAL | |
162 | + | else VOTING)]) | |
163 | + | } | |
164 | + | ||
165 | + | ||
166 | + | ||
167 | + | @Callable(i) | |
168 | + | func voteReveal (item,vote,salt) = { | |
169 | + | let user = toBase58String(i.caller.bytes) | |
170 | + | let status = getValueItemStatus(item) | |
171 | + | let newVoteCount = (getValueVoteCount(item, vote) + 1) | |
172 | + | if ((vote != getValueCommit(item, user))) | |
173 | + | then throw("reveal data is not valid") | |
174 | + | else if ((VOTERS > getValueCommitsCount(item))) | |
175 | + | then throw("max num of voters hasn-t reached yet") | |
176 | + | else if ((getValueReveal(item, user) != NONE)) | |
177 | + | then throw("user has already participated") | |
178 | + | else if (if ((status != VOTING)) | |
179 | + | then (status != REVEAL) | |
180 | + | else false) | |
181 | + | then throw("wrong status") | |
182 | + | else if (if ((vote != FEATURED)) | |
183 | + | then (vote != DELISTED) | |
184 | + | else false) | |
185 | + | then throw("wrong vote") | |
186 | + | else if (if ((status == FEATURED)) | |
187 | + | then true | |
188 | + | else (status == DELISTED)) | |
189 | + | then throw("vote has finished") | |
190 | + | else WriteSet([DataEntry(getKeyReveal(item, user), vote), DataEntry(getKeyVoteCount(item, vote), newVoteCount), DataEntry(getKeyItemStatus(item), if ((newVoteCount >= QUORUM)) | |
191 | + | then vote | |
192 | + | else REVEAL)]) | |
193 | + | } | |
194 | + | ||
195 | + |
github/deemru/w8io/026f985 15.82 ms ◑