tx · 4y9MxzhhxxJrrjaqBpTpxGgJWmzb9KpVZKqNpBJ1J9c5 3NBNXspdVCrwtfqFKntEyCDZSqpxDWDTE1W: -0.01000000 Waves 2021.07.07 16:36 [1603245] smart account 3NBNXspdVCrwtfqFKntEyCDZSqpxDWDTE1W > SELF 0.00000000 Waves
{ "type": 13, "id": "4y9MxzhhxxJrrjaqBpTpxGgJWmzb9KpVZKqNpBJ1J9c5", "fee": 1000000, "feeAssetId": null, "timestamp": 1625665033462, "version": 2, "chainId": 84, "sender": "3NBNXspdVCrwtfqFKntEyCDZSqpxDWDTE1W", "senderPublicKey": "3Dq1hVruD3fXqLqJwiuaCNFV2ARb5J6Sirz1WrttcEJp", "proofs": [ "2745ocFAEDgtzDCREKVEtQ4u91mAmkDbgZ5xCUcBF44d4N61URBJEiS3bEk8nsWNUmDMw5HuZrLsoBvfAhJhcDyD" ], "script": "base64:AAIFAAAAAAAAA9QIAhIFCgMIAQgSAwoBCBIAEgQKAggIEgUKAwgICBoMCgJhMRIGVk9URVJTGgwKAmEyEgZRVU9SVU0aDAoCYTMSBlZPVElORxoMCgJhNBIGUkVWRUFMGg4KAmE1EghGRUFUVVJFRBoOCgJhNhIIREVMSVNURUQaCgoCYTcSBE5PTkUaFAoCYTgSDmdldE51bWJlckJ5S2V5GgkKAmE5EgNrZXkaCQoCYjESA251bRoNCgJiMhIHJG1hdGNoMBoHCgJiMxIBYRoRCgJiNBILZ2V0U3RyQnlLZXkaCQoCYjUSA3N0choSCgJiNhIMZ2V0S2V5Q29tbWl0GgoKAmI3EgRpdGVtGgoKAmI4EgR1c2VyGhQKAmI5Eg5nZXRWYWx1ZUNvbW1pdBoYCgJjMRISZ2V0S2V5Q29tbWl0c0NvdW50GhoKAmMyEhRnZXRWYWx1ZUNvbW1pdHNDb3VudBoSCgJjMxIMZ2V0S2V5UmV2ZWFsGhQKAmM0Eg5nZXRWYWx1ZVJldmVhbBoWCgJjNRIQZ2V0S2V5SXRlbVN0YXR1cxoYCgJj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jOAUAAAACYTQFAAAAA25pbAAAAADTjgYA", "height": 1603245, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: Gr27S8yWbynpYvFteydUys7vMtNRBHe6F3mjNdKSe2PV Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 5 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let VOTERS = 3 | |
5 | + | ||
6 | + | let QUORUM = 2 | |
7 | + | ||
8 | + | let VOTING = "voting" | |
9 | + | ||
10 | + | let REVEAL = "reveal" | |
11 | + | ||
12 | + | let FEATURED = "featured" | |
13 | + | ||
14 | + | let DELISTED = "delisted" | |
15 | + | ||
16 | + | let NONE = "none" | |
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 getKeyCommit (item,user) = (((item + "_") + user) + "_commit") | |
41 | + | ||
42 | + | ||
43 | + | func getValueCommit (item,user) = getStrByKey(getKeyCommit(item, user)) | |
44 | + | ||
45 | + | ||
46 | + | func getKeyCommitsCount (item) = (item + "_comcnt") | |
47 | + | ||
48 | + | ||
49 | + | func getValueCommitsCount (item) = getNumberByKey(getKeyCommitsCount(item)) | |
50 | + | ||
51 | + | ||
52 | + | func getKeyReveal (item,user) = (((item + "_") + user) + "_reveal") | |
53 | + | ||
54 | + | ||
55 | + | func getValueReveal (item,user) = getStrByKey(getKeyReveal(item, user)) | |
56 | + | ||
57 | + | ||
58 | + | func getKeyItemStatus (item) = (item + "_status") | |
59 | + | ||
60 | + | ||
61 | + | func getValueItemStatus (item) = getStrByKey(getKeyItemStatus(item)) | |
62 | + | ||
63 | + | ||
64 | + | func getKeyVoteCount (item,vote) = ((item + "_res") + vote) | |
65 | + | ||
66 | + | ||
67 | + | func getValueVoteCount (item,vote) = getNumberByKey(getKeyVoteCount(item, vote)) | |
68 | + | ||
69 | + | ||
70 | + | func getKeyItemPrice (item) = (item + "_price") | |
71 | + | ||
72 | + | ||
73 | + | func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item)) | |
74 | + | ||
75 | + | ||
76 | + | func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt") | |
77 | + | ||
78 | + | ||
79 | + | func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item)) | |
80 | + | ||
81 | + | ||
82 | + | func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title))))) | |
83 | + | ||
84 | + | ||
85 | + | func getKeyItemData (item) = (item + "_data") | |
86 | + | ||
87 | + | ||
88 | + | func getKeyItemSupplier (item) = (item + "_owner") | |
89 | + | ||
90 | + | ||
91 | + | func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item)) | |
92 | + | ||
93 | + | ||
94 | + | func getKeyBalanceSupplier (account) = (account + "_balance") | |
95 | + | ||
96 | + | ||
97 | + | func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account)) | |
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 already exists") | |
108 | + | else [StringEntry(getKeyItemSupplier(item), supplierAddress), IntegerEntry(getKeyItemPrice(item), price), StringEntry(getKeyItemData(item), data)] | |
109 | + | } | |
110 | + | ||
111 | + | ||
112 | + | ||
113 | + | @Callable(i) | |
114 | + | func purchase (item) = { | |
115 | + | let pmt = i.payments[0] | |
116 | + | if (isDefined(pmt.assetId)) | |
117 | + | then throw("WAVES tokens only at 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 ((supplierAddress == NONE)) | |
125 | + | then throw("Supplier does not exist") | |
126 | + | else [IntegerEntry(getKeyUserItemCounter(userAddress, item), (getValueUserItemCounter(userAddress, item) + 1)), IntegerEntry(getKeyBalanceSupplier(supplierAddress), (getValueBalanceSupplier(supplierAddress) + pmt.amount))] | |
127 | + | } | |
128 | + | } | |
129 | + | ||
130 | + | ||
131 | + | ||
132 | + | @Callable(i) | |
133 | + | func withdraw () = { | |
134 | + | let supplierAddress = toBase58String(i.caller.bytes) | |
135 | + | let balance = getValueBalanceSupplier(supplierAddress) | |
136 | + | if ((0 >= balance)) | |
137 | + | then throw("insuficient balance") | |
138 | + | else [IntegerEntry(getKeyBalanceSupplier(supplierAddress), 0), ScriptTransfer(addressFromStringValue(supplierAddress), balance, unit)] | |
139 | + | } | |
140 | + | ||
141 | + | ||
142 | + | ||
143 | + | @Callable(i) | |
144 | + | func voteCommit (item,hash) = { | |
145 | + | let user = toBase58String(i.caller.bytes) | |
146 | + | let commits = getValueCommitsCount(item) | |
147 | + | let status = getValueItemStatus(item) | |
148 | + | if ((commits >= VOTERS)) | |
149 | + | then throw("reached max num of voters") | |
150 | + | else if ((getValueCommit(item, user) != NONE)) | |
151 | + | then throw("user has already participated") | |
152 | + | else if ((getKeyItemSupplier(item) == NONE)) | |
153 | + | then throw("item does not exist") | |
154 | + | else if (if ((status != NONE)) | |
155 | + | then (status != VOTING) | |
156 | + | else false) | |
157 | + | then throw("voting is not possible") | |
158 | + | else [StringEntry(getKeyCommit(item, user), hash), IntegerEntry(getKeyCommitsCount(item), (commits + 1)), StringEntry(getKeyItemStatus(item), if ((commits == VOTERS)) | |
159 | + | then REVEAL | |
160 | + | else VOTING)] | |
161 | + | } | |
162 | + | ||
163 | + | ||
164 | + | ||
165 | + | @Callable(i) | |
166 | + | func voteReveal (item,vote,salt) = { | |
167 | + | let user = toBase58String(i.caller.bytes) | |
168 | + | let status = getValueItemStatus(item) | |
169 | + | let newVoteCount = (getValueVoteCount(item, vote) + 1) | |
170 | + | if ((VOTERS > getValueCommitsCount(item))) | |
171 | + | then throw("max num of voters hasnt reached yet") | |
172 | + | else if ((getValueReveal(item, user) != NONE)) | |
173 | + | then throw("user has already participated") | |
174 | + | else if (if ((status != VOTING)) | |
175 | + | then (status != REVEAL) | |
176 | + | else false) | |
177 | + | then throw("wrong status") | |
178 | + | else if (if ((vote != FEATURED)) | |
179 | + | then (vote != DELISTED) | |
180 | + | else false) | |
181 | + | then throw("wrong vote") | |
182 | + | else if (if ((status == FEATURED)) | |
183 | + | then true | |
184 | + | else (status == DELISTED)) | |
185 | + | then throw("vote has finished") | |
186 | + | else [StringEntry(getKeyReveal(item, user), vote), IntegerEntry(getKeyVoteCount(item, vote), newVoteCount), StringEntry(getKeyItemStatus(item), if ((newVoteCount >= QUORUM)) | |
187 | + | then vote | |
188 | + | else REVEAL)] | |
189 | + | } | |
190 | + | ||
191 | + |
github/deemru/w8io/169f3d6 20.67 ms ◑