tx · 4kBQnopoWoyeYsSEPVj562Vm1cWBuo8CnwnPT1DaW2Dk 3N9Bq6ehBWayLFrrPtCfeKYwxrnvBSUvVZn: -0.01400000 Waves 2019.07.03 06:39 [568703] smart account 3N9Bq6ehBWayLFrrPtCfeKYwxrnvBSUvVZn > SELF 0.00000000 Waves
{ "type": 13, "id": "4kBQnopoWoyeYsSEPVj562Vm1cWBuo8CnwnPT1DaW2Dk", "fee": 1400000, "feeAssetId": null, "timestamp": 1562125195851, "version": 1, "sender": "3N9Bq6ehBWayLFrrPtCfeKYwxrnvBSUvVZn", "senderPublicKey": "Aj6Jw3K8mBtJbF6HDthARZ1qTozo2mZAMZDMnWCYVhCY", "proofs": [ "436jYRJtofpZLpkJJLGweu6ky14NHMQhjEDXmYQ4Hkxex1NeNWdQbehQE6heKxsoV5ZkKdTNXspDLqxWhp6zD2YA" ], "script": "base64:AAIDAAAAAAAAAAAAAAAhAAAAAAROT05FAgAAAARub25lAQAAAA5nZXROdW1iZXJCeUtleQAAAAEAAAADa2V5BAAAAANudW0EAAAAByRtYXRjaDAJAAQaAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAANJbnQEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEAAAAAAAAAAAAFAAAAA251bQEAAAALZ2V0U3RyQnlLZXkAAAABAAAAA2tleQQAAAADc3RyBAAAAAckbWF0Y2gwCQAEHQAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAGU3RyaW5nBAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhBQAAAAROT05FBQAAAANzdHIBAAAAD2dldEtleUl0ZW1QcmljZQAAAAEAAAAEaXRlbQkAASwAAAACBQAAAARpdGVtAgAAAAZfcHJpY2UBAAAAEWdldFZhbHVlSXRlbVByaWNlAAAAAQAAAARpdGVtCQEAAAAOZ2V0TnVtYmVyQnlLZXkAAAABCQEAAAAPZ2V0S2V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AAAMbmV3Vm90ZUNvdW50CQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQEAAAAQZ2V0S2V5SXRlbVN0YXR1cwAAAAEFAAAABGl0ZW0DCQAAZwAAAAIFAAAADG5ld1ZvdGVDb3VudAUAAAAGUVVPUlVNBQAAAAR2b3RlBQAAAAZSRVZFQUwFAAAAA25pbAAAAADxpm41", "chainId": 84, "height": 568703, "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 NONE = "none" | |
5 | + | ||
6 | + | func getNumberByKey (key) = { | |
7 | + | let num = match getInteger(this, key) { | |
8 | + | case a: Int => | |
9 | + | a | |
10 | + | case _ => | |
11 | + | 0 | |
12 | + | } | |
13 | + | num | |
14 | + | } | |
15 | + | ||
16 | + | ||
17 | + | func getStrByKey (key) = { | |
18 | + | let str = match getString(this, key) { | |
19 | + | case a: String => | |
20 | + | a | |
21 | + | case _ => | |
22 | + | NONE | |
23 | + | } | |
24 | + | str | |
25 | + | } | |
26 | + | ||
27 | + | ||
28 | + | func getKeyItemPrice (item) = (item + "_price") | |
29 | + | ||
30 | + | ||
31 | + | func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item)) | |
32 | + | ||
33 | + | ||
34 | + | func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt") | |
35 | + | ||
36 | + | ||
37 | + | func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item)) | |
38 | + | ||
39 | + | ||
40 | + | func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title))))) | |
41 | + | ||
42 | + | ||
43 | + | func getKeyItemData (item) = (item + "_data") | |
44 | + | ||
45 | + | ||
46 | + | func getKeyItemSupplier (item) = (item + "_owner") | |
47 | + | ||
48 | + | ||
49 | + | func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item)) | |
50 | + | ||
51 | + | ||
52 | + | func getKeyBalanceSupplier (account) = (account + "_balance") | |
53 | + | ||
54 | + | ||
55 | + | func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account)) | |
56 | + | ||
57 | + | ||
58 | + | let VOTERS = 3 | |
59 | + | ||
60 | + | let QUORUM = 2 | |
61 | + | ||
62 | + | let VOTING = "voting" | |
63 | + | ||
64 | + | let REVEAL = "reveal" | |
65 | + | ||
66 | + | let FEATURED = "featured" | |
67 | + | ||
68 | + | let DELISTED = "delisted" | |
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 + "_comcnt") | |
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 | + | func getExtAddressOracle () = extract(addressFromString("3Mx9qgMyMhHt7WUZr6PsaXNfmydxMG7YMxv")) | |
101 | + | ||
102 | + | ||
103 | + | let BLACKLISTED = "blacklist" | |
104 | + | ||
105 | + | func getExtKeyItemWhiteListStatus (account) = (account + "_verifier_status") | |
106 | + | ||
107 | + | ||
108 | + | func getExtValueItemWhiteListStatus (oracle,account) = { | |
109 | + | let str = match getString(oracle, getExtKeyItemWhiteListStatus(account)) { | |
110 | + | case a: String => | |
111 | + | a | |
112 | + | case _ => | |
113 | + | NONE | |
114 | + | } | |
115 | + | str | |
116 | + | } | |
117 | + | ||
118 | + | ||
119 | + | @Callable(i) | |
120 | + | func addItem (title,price,data) = { | |
121 | + | let supplierAddress = toBase58String(i.caller.bytes) | |
122 | + | let item = getKeyItem(supplierAddress, title) | |
123 | + | let supplierWhiteList = getExtValueItemWhiteListStatus(getExtAddressOracle(), supplierAddress) | |
124 | + | if ((0 >= price)) | |
125 | + | then throw("purchase amount cannot be less than item price") | |
126 | + | else if ((getValueItemSupplier(item) != NONE)) | |
127 | + | then throw("an item is already exist") | |
128 | + | else if ((supplierWhiteList == BLACKLISTED)) | |
129 | + | then throw("supplier's account has been blacklisted") | |
130 | + | else WriteSet([DataEntry(getKeyItemSupplier(item), supplierAddress), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data), DataEntry(getExtKeyItemWhiteListStatus(supplierAddress), supplierWhiteList)]) | |
131 | + | } | |
132 | + | ||
133 | + | ||
134 | + | ||
135 | + | @Callable(i) | |
136 | + | func purchase (item) = { | |
137 | + | let pmt = extract(i.payment) | |
138 | + | if (isDefined(pmt.assetId)) | |
139 | + | then throw("WAVES tokens only at the moment") | |
140 | + | else { | |
141 | + | let userAddress = toBase58String(i.caller.bytes) | |
142 | + | let price = getValueItemPrice(item) | |
143 | + | let supplierAddress = getValueItemSupplier(item) | |
144 | + | if ((price > pmt.amount)) | |
145 | + | then throw("purchase amount cannot be less than item price") | |
146 | + | else if ((pmt.amount > price)) | |
147 | + | then throw("purchase amount cannot be higher than item price") | |
148 | + | else if ((supplierAddress == NONE)) | |
149 | + | then throw("supplier does not exist") | |
150 | + | else WriteSet([DataEntry(getKeyUserItemCounter(userAddress, item), (getValueUserItemCounter(userAddress, item) + 1)), DataEntry(getKeyBalanceSupplier(supplierAddress), (getValueBalanceSupplier(supplierAddress) + pmt.amount))]) | |
151 | + | } | |
152 | + | } | |
153 | + | ||
154 | + | ||
155 | + | ||
156 | + | @Callable(i) | |
157 | + | func withdraw () = { | |
158 | + | let supplierAddress = toBase58String(i.caller.bytes) | |
159 | + | let balance = getValueBalanceSupplier(supplierAddress) | |
160 | + | if ((0 >= balance)) | |
161 | + | then throw("insufficient balance") | |
162 | + | else ScriptResult(WriteSet([DataEntry(getKeyBalanceSupplier(supplierAddress), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(supplierAddress), balance, unit)])) | |
163 | + | } | |
164 | + | ||
165 | + | ||
166 | + | ||
167 | + | @Callable(i) | |
168 | + | func voteCommit (item,hash) = { | |
169 | + | let user = toBase58String(i.caller.bytes) | |
170 | + | let commits = getValueCommitsCount(item) | |
171 | + | let status = getValueItemStatus(item) | |
172 | + | if ((commits >= VOTERS)) | |
173 | + | then throw("reached max num of voters") | |
174 | + | else if ((getValueCommit(item, user) != NONE)) | |
175 | + | then throw("user has already participated") | |
176 | + | else if ((getKeyItemSupplier(item) == NONE)) | |
177 | + | then throw("item does not exist") | |
178 | + | else if (if ((status != NONE)) | |
179 | + | then (status != VOTING) | |
180 | + | else false) | |
181 | + | then throw("voting is not possible") | |
182 | + | else WriteSet([DataEntry(getKeyCommit(item, user), hash), DataEntry(getKeyCommitsCount(item), (commits + 1)), DataEntry(getKeyItemStatus(item), if ((commits == VOTERS)) | |
183 | + | then REVEAL | |
184 | + | else VOTING)]) | |
185 | + | } | |
186 | + | ||
187 | + | ||
188 | + | ||
189 | + | @Callable(i) | |
190 | + | func voteReveal (item,vote,salt) = { | |
191 | + | let user = toBase58String(i.caller.bytes) | |
192 | + | let status = getValueItemStatus(item) | |
193 | + | let newVoteCount = getValueVoteCount(item, vote) | |
194 | + | if ((toBase58String(sha256(toBytes((vote + salt)))) != getValueCommit(item, user))) | |
195 | + | then throw("reveal data is not valid") | |
196 | + | else if ((VOTERS > getValueCommitsCount(item))) | |
197 | + | then throw("max num of voters hasn't reached yet") | |
198 | + | else if ((getValueReveal(item, user) != NONE)) | |
199 | + | then throw("user has already participated") | |
200 | + | else if (if ((status != VOTING)) | |
201 | + | then (status != REVEAL) | |
202 | + | else false) | |
203 | + | then throw("wrong status") | |
204 | + | else if (if ((vote != FEATURED)) | |
205 | + | then (vote != DELISTED) | |
206 | + | else false) | |
207 | + | then throw("wrong vote") | |
208 | + | else if (if ((status == FEATURED)) | |
209 | + | then true | |
210 | + | else (status == DELISTED)) | |
211 | + | then throw("vote has finished") | |
212 | + | else WriteSet([DataEntry(getKeyReveal(item, user), vote), DataEntry(getKeyVoteCount(item, vote), newVoteCount), DataEntry(getKeyItemStatus(item), if ((newVoteCount >= QUORUM)) | |
213 | + | then vote | |
214 | + | else REVEAL)]) | |
215 | + | } | |
216 | + | ||
217 | + |
github/deemru/w8io/026f985 24.36 ms ◑