tx · 4R2A1w6dQDq8bB7qynnNFLEDp4oXo4F5do9D6YUnisRZ 3N5VwnYrNqyfyHzTVYscDTT8svAHujRLLXV: -0.01000000 Waves 2021.07.19 17:28 [1620617] smart account 3N5VwnYrNqyfyHzTVYscDTT8svAHujRLLXV > SELF 0.00000000 Waves
{ "type": 13, "id": "4R2A1w6dQDq8bB7qynnNFLEDp4oXo4F5do9D6YUnisRZ", "fee": 1000000, "feeAssetId": null, "timestamp": 1626704896111, "version": 2, "chainId": 84, "sender": "3N5VwnYrNqyfyHzTVYscDTT8svAHujRLLXV", "senderPublicKey": "3KSveC7ZDPJrz8Cx7Rbj434TF6s5oNuXKTLRxy1sjywF", "proofs": [ "3qr1QRGN9eqNjsFEh8qmeBwn3e3mPnep3h8gpZaSf811sWCvJR7T5EknunuMwcKFJ5bmbJqYUxsFZJ4siWuuWmFd" ], "script": "base64:AAIFAAAAAAAABHMIAhIFCgMIAQgSAwoBCBIAEgQKAggIEgUKAwgICBoKCgJhMRIETk9ORRoUCgJhMhIOZ2V0TnVtYmVyQnlLZXkaCQoCYTMSA2tleRoJCgJhNBIDbnVtGg0KAmE1EgckbWF0Y2gwGgcKAmE2EgFhGhEKAmE3EgtnZXRTdHJCeUtleRoJCgJhOBIDc3RyGhUKAmE5Eg9nZXRLZXlJdGVtUHJpY2UaCgoCYjESBGl0ZW0aFwoCYjISEWdldFZhbHVlSXRlbVByaWNlGhsKAmIzEhVnZXRLZXlVc2VySXRlbUNvdW50ZXIaCgoCYjQSBHVzZXIaHQoCYjUSF2dldFZhbHVlVXNlckl0ZW1Db3VudGVyGhAKAmI2EgpnZXRLZXlJdGVtGg4KAmI3EghzdXBwbGllchoLCgJiOBIFdGl0bGUaFAoCYjkSDmdldEtleUl0ZW1EYXRhGhgKAmMxEhJnZXRLZXlJdGVtU3VwcGxpZXIaGgoCYzISFGdldFZhbHVlSXRlbVN1cHBsaWVyGhsKAmMzEhVnZXRLZXlCYWxhbmNlU3VwcGxpZXIaDQoCYzQ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AEsAAAAAgUAAAACZTMFAAAAAmczCQEAAAACZDQAAAACBQAAAAJiMQUAAAACYjQJAAACAAAAAQIAAAAYUmV2ZWFsIGRhdGEgaXMgbm90IHZhbGlkAwkAAGYAAAACBQAAAAJjNgkBAAAAAmQ2AAAAAQUAAAACYjEJAAACAAAAAQIAAAAjbWF4IG51bSBvZiB2b3RlcnMgaGFzbnQgcmVhY2hlZCB5ZXQDCQEAAAACIT0AAAACCQEAAAACZDgAAAACBQAAAAJiMQUAAAACYjQFAAAAAmExCQAAAgAAAAECAAAAHXVzZXIgaGFzIGFscmVhZHkgcGFydGljaXBhdGVkAwMJAQAAAAIhPQAAAAIFAAAAAmcyBQAAAAJjOAkBAAAAAiE9AAAAAgUAAAACZzIFAAAAAmM5BwkAAAIAAAABAgAAAAx3cm9uZyBzdGF0dXMDAwkBAAAAAiE9AAAAAgUAAAACZTMFAAAAAmQxCQEAAAACIT0AAAACBQAAAAJlMwUAAAACZDIHCQAAAgAAAAECAAAACndyb25nIHZvdGUDAwkAAAAAAAACBQAAAAJnMgUAAAACZDEGCQAAAAAAAAIFAAAAAmcyBQAAAAJkMgkAAAIAAAABAgAAABF2b3RlIGhhcyBmaW5pc2hlZAkABEwAAAACCQEAAAALU3RyaW5nRW50cnkAAAACCQEAAAACZDcAAAACBQAAAAJiMQUAAAACYjQFAAAAAmUzCQAETAAAAAIJAQAAAAxJbnRlZ2VyRW50cnkAAAACCQEAAAACZTIAAAACBQAAAAJiMQUAAAACZTMFAAAAAmc0CQAETAAAAAIJAQAAAAtTdHJpbmdFbnRyeQAAAAIJAQAAAAJkOQAAAAEFAAAAAmIxAwkAAGcAAAACBQAAAAJnNAUAAAACYzcFAAAAAmUzBQAAAAJjOQUAAAADbmlsAAAAABqVcT0=", "height": 1620617, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: 3Pqoo3iC4kP1pZBAGnSvzu1tLGieMSwx8ti7tbsUuEif Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 5 #-} | |
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 () = value(addressFromString("3MsbiyFyy8B3aN3kF8ntda474SPn4YMVkiq")) | |
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 already exists") | |
128 | + | else if ((supplierWhiteList == BLACKLISTED)) | |
129 | + | then throw("supplier's account has been blacklisted") | |
130 | + | else [StringEntry(getKeyItemSupplier(item), supplierAddress), IntegerEntry(getKeyItemPrice(item), price), StringEntry(getKeyItemData(item), data), StringEntry(getExtKeyItemWhiteListStatus(supplierAddress), supplierWhiteList)] | |
131 | + | } | |
132 | + | ||
133 | + | ||
134 | + | ||
135 | + | @Callable(i) | |
136 | + | func purchase (item) = { | |
137 | + | let pmt = i.payments[0] | |
138 | + | if (isDefined(pmt.assetId)) | |
139 | + | then throw("WAVES ONLY HHEUAWHEUAS") | |
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 ((supplierAddress == NONE)) | |
147 | + | then throw("Supplier does not exist") | |
148 | + | else [IntegerEntry(getKeyUserItemCounter(userAddress, item), (getValueUserItemCounter(userAddress, item) + 1)), IntegerEntry(getKeyBalanceSupplier(supplierAddress), (getValueBalanceSupplier(supplierAddress) + pmt.amount))] | |
149 | + | } | |
150 | + | } | |
151 | + | ||
152 | + | ||
153 | + | ||
154 | + | @Callable(i) | |
155 | + | func withdraw () = { | |
156 | + | let supplierAddress = toBase58String(i.caller.bytes) | |
157 | + | let balance = getValueBalanceSupplier(supplierAddress) | |
158 | + | if ((0 >= balance)) | |
159 | + | then throw("insuficient balance") | |
160 | + | else [IntegerEntry(getKeyBalanceSupplier(supplierAddress), 0), ScriptTransfer(addressFromStringValue(supplierAddress), balance, unit)] | |
161 | + | } | |
162 | + | ||
163 | + | ||
164 | + | ||
165 | + | @Callable(i) | |
166 | + | func voteCommit (item,hash) = { | |
167 | + | let user = toBase58String(i.caller.bytes) | |
168 | + | let commits = getValueCommitsCount(item) | |
169 | + | let status = getValueItemStatus(item) | |
170 | + | if ((commits >= VOTERS)) | |
171 | + | then throw("Reached max num of voters") | |
172 | + | else if ((getValueCommit(item, user) != NONE)) | |
173 | + | then throw("b1") | |
174 | + | else if ((getKeyItemSupplier(item) == NONE)) | |
175 | + | then throw("b2") | |
176 | + | else if (if ((status != NONE)) | |
177 | + | then (status != VOTING) | |
178 | + | else false) | |
179 | + | then throw("b3") | |
180 | + | else [StringEntry(getKeyCommit(item, user), hash), IntegerEntry(getKeyCommitsCount(item), (commits + 1)), StringEntry(getKeyItemStatus(item), if ((commits == VOTERS)) | |
181 | + | then REVEAL | |
182 | + | else VOTING)] | |
183 | + | } | |
184 | + | ||
185 | + | ||
186 | + | ||
187 | + | @Callable(i) | |
188 | + | func voteReveal (item,vote,salt) = { | |
189 | + | let user = toBase58String(i.caller.bytes) | |
190 | + | let status = getValueItemStatus(item) | |
191 | + | let newVoteCount = (getValueVoteCount(item, vote) + 1) | |
192 | + | if ((toBase58String(sha256(toBytes((vote + salt)))) != getValueCommit(item, user))) | |
193 | + | then throw("Reveal data is not valid") | |
194 | + | else if ((VOTERS > getValueCommitsCount(item))) | |
195 | + | then throw("max num of voters hasnt reached yet") | |
196 | + | else if ((getValueReveal(item, user) != NONE)) | |
197 | + | then throw("user has already participated") | |
198 | + | else if (if ((status != VOTING)) | |
199 | + | then (status != REVEAL) | |
200 | + | else false) | |
201 | + | then throw("wrong status") | |
202 | + | else if (if ((vote != FEATURED)) | |
203 | + | then (vote != DELISTED) | |
204 | + | else false) | |
205 | + | then throw("wrong vote") | |
206 | + | else if (if ((status == FEATURED)) | |
207 | + | then true | |
208 | + | else (status == DELISTED)) | |
209 | + | then throw("vote has finished") | |
210 | + | else [StringEntry(getKeyReveal(item, user), vote), IntegerEntry(getKeyVoteCount(item, vote), newVoteCount), StringEntry(getKeyItemStatus(item), if ((newVoteCount >= QUORUM)) | |
211 | + | then vote | |
212 | + | else REVEAL)] | |
213 | + | } | |
214 | + | ||
215 | + |
github/deemru/w8io/026f985 19.29 ms ◑