tx · KCF2fX7EBAzrGinNGMZuUe5SWH8xZKfZSJVnW3dPzEE 3MovmZoJtqutkf49oGXHzABSMUQ7HU5Dcg7: -0.01400000 Waves 2021.08.02 03:44 [1640007] smart account 3MovmZoJtqutkf49oGXHzABSMUQ7HU5Dcg7 > SELF 0.00000000 Waves
{ "type": 13, "id": "KCF2fX7EBAzrGinNGMZuUe5SWH8xZKfZSJVnW3dPzEE", "fee": 1400000, "feeAssetId": null, "timestamp": 1627865115960, "version": 2, "chainId": 84, "sender": "3MovmZoJtqutkf49oGXHzABSMUQ7HU5Dcg7", "senderPublicKey": "3tp5fNYyPi4jMnkf6s1k4kBqvJ7nm57SxzvLyi8RkxT2", "proofs": [ "3nqE19Ct9pZ5AEA6MVDGSJE68UZtFV4i9hVP9eKvzoMbbFY1neqSUBUieWo5o1sMTBC7DhSgY1yeeWV4PHDGQyez" ], "script": "base64:AAIEAAAAAAAAADsIAhIDCgEIEgYKBAgBCAESBwoFCAgBCAESAwoBCBIECgIICBIDCgEIEgQKAggIEgQKAggIEgUKAwgICAAAADUAAAAABE5PTkUCAAAABE5PTkUAAAAABlZPVEVSUwAAAAAAAAAAAwAAAAAGUVVPUlVNAAAAAAAAAAACAAAAAAhGRUFUVVJFRAIAAAAIZmVhdHVyZWQAAAAACERFTElTVEVEAgAAAAhkZWxpc3RlZAAAAAAGVk9USU5HAgAAAAZ2b3RpbmcAAAAABlJFVkVBTAIAAAAGcmV2ZWFsAAAAAAhBUFBST1ZBTAIAAAAIYXBwcm92YWwAAAAACFJFSkVDVEVEAgAAAAhyZWplY3RlZAAAAAAIQUNDRVBURUQCAAAACGFjY2VwdGVkAQAAAA5nZXRTdHJpbmdCeUtleQAAAAEAAAADa2V5BAAAAAckbWF0Y2gwCQAEHQAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAGU3RyaW5nBAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhBQAAAAROT05FAQAAAA9nZX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XR1cwAAAAEFAAAABGl0ZW0FAAAACW5ld1N0YXR1cwUAAAADbmlsAAAAAQAAAAJ0eAEAAAAGdmVyaWZ5AAAAAAQAAAAHJG1hdGNoMAUAAAACdHgDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAFFNldFNjcmlwdFRyYW5zYWN0aW9uBAAAAAF0BQAAAAckbWF0Y2gwCQAB9AAAAAMIBQAAAAJ0eAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAAnR4AAAABnByb29mcwAAAAAAAAAAAAgFAAAAAnR4AAAAD3NlbmRlclB1YmxpY0tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAQSXNzdWVUcmFuc2FjdGlvbgQAAAABdAUAAAAHJG1hdGNoMAkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAIBQAAAAJ0eAAAAA9zZW5kZXJQdWJsaWNLZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAE1RyYW5zZmVyVHJhbnNhY3Rpb24EAAAAAXQFAAAAByRtYXRjaDAJAAH0AAAAAwgFAAAAAnR4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAACAUAAAACdHgAAAAPc2VuZGVyUHVibGljS2V5B/+iK6I=", "height": 1640007, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 5vS2PiVGJw3MezycGfnJsvmtRN1v41KPP2AF8dwyW6kP Next: Ca54uLDM9RY2i7g3QrdYDWAomvZQEQaZjoMJoBvyRCzR Diff:
Old | New | Differences | |
---|---|---|---|
14 | 14 | let VOTING = "voting" | |
15 | 15 | ||
16 | 16 | let REVEAL = "reveal" | |
17 | + | ||
18 | + | let APPROVAL = "approval" | |
19 | + | ||
20 | + | let REJECTED = "rejected" | |
21 | + | ||
22 | + | let ACCEPTED = "accepted" | |
17 | 23 | ||
18 | 24 | func getStringByKey (key) = match getString(this, key) { | |
19 | 25 | case a: String => | |
58 | 64 | func getKeyItemExpireDate (item) = (item + "_expiredate") | |
59 | 65 | ||
60 | 66 | ||
67 | + | func getKeyItemSoldCounter (item) = (item + "_sold") | |
68 | + | ||
69 | + | ||
61 | 70 | func getKeyCommit (item,user) = (((item + "_") + user) + "_commit") | |
62 | 71 | ||
63 | 72 | ||
73 | 82 | func getKeyVotesCount (item,vote) = ((item + "_res:") + vote) | |
74 | 83 | ||
75 | 84 | ||
76 | - | func | |
85 | + | func getKeySupplierBalance (supplier) = (supplier + "_balance") | |
77 | 86 | ||
78 | 87 | ||
79 | - | func getKeyBalanceSupplier (account) = (account + "_balance") | |
88 | + | func getPurchase (supplier,item,user) = ("purchase_" + toBase58String(sha256(toBytes(((((supplier + "_") + item) + "_") + user))))) | |
89 | + | ||
90 | + | ||
91 | + | func getKeyPurchaseStatus (purchase) = (purchase + "_status") | |
92 | + | ||
93 | + | ||
94 | + | func getKeyPurchaseItem (purchase) = (purchase + "_item") | |
95 | + | ||
96 | + | ||
97 | + | func getKeyPurchaseSupplier (purchase) = (purchase + "_supplier") | |
98 | + | ||
99 | + | ||
100 | + | func getKeyPurchaseUser (purchase) = (purchase + "_user") | |
101 | + | ||
102 | + | ||
103 | + | func getKeyPurchaseAmount (purchase) = (purchase + "_amount") | |
104 | + | ||
105 | + | ||
106 | + | func getKeyPurchaseTimestamp (purchase) = (purchase + "_timestamp") | |
80 | 107 | ||
81 | 108 | ||
82 | 109 | func getKeyCoupon (assetId) = ("coupon_" + assetId) | |
85 | 112 | func getKeyCouponItem (coupon) = (coupon + "_item") | |
86 | 113 | ||
87 | 114 | ||
88 | - | func getValueBalanceSupplier (account) = { | |
89 | - | let supplierBalanceKey = getKeyBalanceSupplier(account) | |
90 | - | match getInteger(this, supplierBalanceKey) { | |
91 | - | case a: Int => | |
92 | - | a | |
93 | - | case _ => | |
94 | - | 0 | |
95 | - | } | |
96 | - | } | |
115 | + | func getValueSupplierBalance (supplier) = getIntegerByKey(getKeySupplierBalance(supplier)) | |
97 | 116 | ||
98 | 117 | ||
99 | - | func getValueUserItemCounter (user,item) = { | |
100 | - | let userItemCounterKey = getKeyUserItemCounter(user, item) | |
101 | - | match getInteger(this, userItemCounterKey) { | |
102 | - | case a: Int => | |
103 | - | a | |
104 | - | case _ => | |
105 | - | 0 | |
106 | - | } | |
107 | - | } | |
118 | + | func getValuePurchaseStatus (purchase) = getStringByKey(getKeyPurchaseStatus(purchase)) | |
108 | 119 | ||
109 | 120 | ||
110 | - | func getValueItemPrice (item) = { | |
111 | - | let keyItemPrice = getKeyItemPrice(item) | |
112 | - | getIntegerValue(this, keyItemPrice) | |
113 | - | } | |
121 | + | func getValuePurchaseItem (purchase) = getStringValue(this, getKeyPurchaseItem(purchase)) | |
122 | + | ||
123 | + | ||
124 | + | func getValuePurchaseSupplier (purchase) = getStringValue(this, getKeyPurchaseSupplier(purchase)) | |
125 | + | ||
126 | + | ||
127 | + | func getValuePurchaseUser (purchase) = getStringValue(this, getKeyPurchaseUser(purchase)) | |
128 | + | ||
129 | + | ||
130 | + | func getValuePurchaseAmount (purchase) = getIntegerValue(this, getKeyPurchaseAmount(purchase)) | |
131 | + | ||
132 | + | ||
133 | + | func getValuePurchaseTimestamp (purchase) = getIntegerByKey(getKeyPurchaseTimestamp(purchase)) | |
134 | + | ||
135 | + | ||
136 | + | func getValueItemPrice (item) = getIntegerValue(this, getKeyItemPrice(item)) | |
114 | 137 | ||
115 | 138 | ||
116 | 139 | func getValueItemSupplier (item) = getStringByKey(getKeyItemSupplier(item)) | |
120 | 143 | ||
121 | 144 | ||
122 | 145 | func getValueItemTitle (item) = getStringByKey(getKeyItemTitle(item)) | |
146 | + | ||
147 | + | ||
148 | + | func getValueItemSoldCounter (item) = getIntegerByKey(getKeyItemSoldCounter(item)) | |
123 | 149 | ||
124 | 150 | ||
125 | 151 | func getValueCommit (item,user) = getStringByKey(getKeyCommit(item, user)) | |
202 | 228 | if (isDefined(pmt.assetId)) | |
203 | 229 | then throw("You can buy tokens only with Waves tokens") | |
204 | 230 | else { | |
205 | - | let | |
231 | + | let user = toBase58String(i.caller.bytes) | |
206 | 232 | let price = getValueItemPrice(item) | |
207 | 233 | let supplier = getValueItemSupplier(item) | |
208 | 234 | let expire = getValueItemExpireTime(item) | |
217 | 243 | else if ((supplier == NONE)) | |
218 | 244 | then throw("Supplier does not exists") | |
219 | 245 | else { | |
220 | - | let userItemCounter = getKeyUserItemCounter(userAddress, item) | |
221 | - | let newValueUserItemCounter = (getValueUserItemCounter(userAddress, item) + 1) | |
222 | - | let supplierBalanceKey = getKeyBalanceSupplier(supplier) | |
223 | - | let newSupplierBalance = (getValueBalanceSupplier(supplier) + pmt.amount) | |
224 | - | let coupon = getKeyCoupon(assetId) | |
225 | - | [IntegerEntry(userItemCounter, newValueUserItemCounter), IntegerEntry(supplierBalanceKey, newSupplierBalance), StringEntry(getKeyCouponItem(coupon), item), ScriptTransfer(i.caller, 1, fromBase58String(assetId))] | |
246 | + | let purchase = getPurchase(supplier, item, user) | |
247 | + | let keyPurchaseStatus = getKeyPurchaseStatus(purchase) | |
248 | + | let keyPurchaseItem = getKeyPurchaseItem(purchase) | |
249 | + | let keyPurchaseSupplier = getKeyPurchaseSupplier(purchase) | |
250 | + | let keyPurchaseUser = getKeyPurchaseUser(purchase) | |
251 | + | let keyPurchaseAmount = getKeyPurchaseAmount(purchase) | |
252 | + | let keyPurchaseTimestamp = getKeyPurchaseTimestamp(purchase) | |
253 | + | [StringEntry(keyPurchaseStatus, APPROVAL), StringEntry(keyPurchaseItem, item), StringEntry(keyPurchaseSupplier, supplier), StringEntry(keyPurchaseUser, user), IntegerEntry(keyPurchaseAmount, pmt.amount), IntegerEntry(keyPurchaseTimestamp, lastBlock.timestamp)] | |
226 | 254 | } | |
227 | 255 | } | |
256 | + | } | |
257 | + | ||
258 | + | ||
259 | + | ||
260 | + | @Callable(i) | |
261 | + | func rejectPurchase (purchase) = { | |
262 | + | let caller = toBase58String(i.caller.bytes) | |
263 | + | let status = getValuePurchaseStatus(purchase) | |
264 | + | let supplier = getValuePurchaseSupplier(purchase) | |
265 | + | let item = getValuePurchaseItem(purchase) | |
266 | + | if (if ((supplier == NONE)) | |
267 | + | then true | |
268 | + | else (caller != supplier)) | |
269 | + | then throw("Your are not the owner of this item") | |
270 | + | else if ((status != APPROVAL)) | |
271 | + | then throw("You cannot reject this purchased") | |
272 | + | else { | |
273 | + | let keyPurchaseStatus = getKeyPurchaseStatus(purchase) | |
274 | + | let keyPurchaseAmount = getKeyPurchaseAmount(purchase) | |
275 | + | let keySupplierBalance = getKeySupplierBalance(supplier) | |
276 | + | let keyItemSoldCounter = getKeyItemSoldCounter(item) | |
277 | + | let user = getValuePurchaseUser(purchase) | |
278 | + | let amount = getValuePurchaseAmount(purchase) | |
279 | + | let supplierBalance = (getValueSupplierBalance(supplier) - amount) | |
280 | + | let itemSoldCounter = (getValueItemSoldCounter(item) - 1) | |
281 | + | let address = addressFromStringValue(user) | |
282 | + | [StringEntry(keyPurchaseStatus, REJECTED), IntegerEntry(keyPurchaseAmount, 0), ScriptTransfer(address, amount, unit)] | |
283 | + | } | |
284 | + | } | |
285 | + | ||
286 | + | ||
287 | + | ||
288 | + | @Callable(i) | |
289 | + | func acceptPurchase (purchase,couponAssetId) = { | |
290 | + | let caller = toBase58String(i.caller.bytes) | |
291 | + | let status = getValuePurchaseStatus(purchase) | |
292 | + | let supplier = getValuePurchaseSupplier(purchase) | |
293 | + | let item = getValuePurchaseItem(purchase) | |
294 | + | let expire = getValueItemExpireTime(item) | |
295 | + | if (if ((supplier == NONE)) | |
296 | + | then true | |
297 | + | else (caller != supplier)) | |
298 | + | then throw("Your are not the owner of this item") | |
299 | + | else if ((status != APPROVAL)) | |
300 | + | then throw("You cannot reject this purchased") | |
301 | + | else if (if ((expire > 0)) | |
302 | + | then (lastBlock.timestamp >= expire) | |
303 | + | else false) | |
304 | + | then throw("Coupon expired") | |
305 | + | else { | |
306 | + | let keyPurchaseStatus = getKeyPurchaseStatus(purchase) | |
307 | + | let keySupplierBalance = getKeySupplierBalance(supplier) | |
308 | + | let keyItemSoldCounter = getKeyItemSoldCounter(item) | |
309 | + | let amount = getValuePurchaseAmount(purchase) | |
310 | + | let supplierBalance = (getValueSupplierBalance(supplier) + amount) | |
311 | + | let itemSoldCounter = (getValueItemSoldCounter(item) + 1) | |
312 | + | let user = getValuePurchaseUser(purchase) | |
313 | + | let address = addressFromStringValue(user) | |
314 | + | [IntegerEntry(keySupplierBalance, supplierBalance), IntegerEntry(keyItemSoldCounter, itemSoldCounter), ScriptTransfer(address, 1, fromBase58String(couponAssetId))] | |
315 | + | } | |
228 | 316 | } | |
229 | 317 | ||
230 | 318 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 4 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let NONE = "NONE" | |
5 | 5 | ||
6 | 6 | let VOTERS = 3 | |
7 | 7 | ||
8 | 8 | let QUORUM = 2 | |
9 | 9 | ||
10 | 10 | let FEATURED = "featured" | |
11 | 11 | ||
12 | 12 | let DELISTED = "delisted" | |
13 | 13 | ||
14 | 14 | let VOTING = "voting" | |
15 | 15 | ||
16 | 16 | let REVEAL = "reveal" | |
17 | + | ||
18 | + | let APPROVAL = "approval" | |
19 | + | ||
20 | + | let REJECTED = "rejected" | |
21 | + | ||
22 | + | let ACCEPTED = "accepted" | |
17 | 23 | ||
18 | 24 | func getStringByKey (key) = match getString(this, key) { | |
19 | 25 | case a: String => | |
20 | 26 | a | |
21 | 27 | case _ => | |
22 | 28 | NONE | |
23 | 29 | } | |
24 | 30 | ||
25 | 31 | ||
26 | 32 | func getIntegerByKey (key) = match getInteger(this, key) { | |
27 | 33 | case a: Int => | |
28 | 34 | a | |
29 | 35 | case _ => | |
30 | 36 | 0 | |
31 | 37 | } | |
32 | 38 | ||
33 | 39 | ||
34 | 40 | func getKeySupplierAccount (account) = (account + "_account") | |
35 | 41 | ||
36 | 42 | ||
37 | 43 | func getSupplierAccount (account) = getStringByKey(getKeySupplierAccount(account)) | |
38 | 44 | ||
39 | 45 | ||
40 | 46 | func getKeyItem (supplier,title) = { | |
41 | 47 | let supplierTitle = (supplier + title) | |
42 | 48 | ("item_" + toBase58String(sha256(toBytes(supplierTitle)))) | |
43 | 49 | } | |
44 | 50 | ||
45 | 51 | ||
46 | 52 | func getKeyItemSupplier (item) = (item + "_owner") | |
47 | 53 | ||
48 | 54 | ||
49 | 55 | func getKeyItemTitle (item) = (item + "_title") | |
50 | 56 | ||
51 | 57 | ||
52 | 58 | func getKeyItemPrice (item) = (item + "_price") | |
53 | 59 | ||
54 | 60 | ||
55 | 61 | func getKeyItemData (item) = (item + "_data") | |
56 | 62 | ||
57 | 63 | ||
58 | 64 | func getKeyItemExpireDate (item) = (item + "_expiredate") | |
59 | 65 | ||
60 | 66 | ||
67 | + | func getKeyItemSoldCounter (item) = (item + "_sold") | |
68 | + | ||
69 | + | ||
61 | 70 | func getKeyCommit (item,user) = (((item + "_") + user) + "_commit") | |
62 | 71 | ||
63 | 72 | ||
64 | 73 | func getKeyCommitsCount (item) = (item + "_cmtcnt") | |
65 | 74 | ||
66 | 75 | ||
67 | 76 | func getKeyReveal (item,user) = (((item + "_") + user) + "_reveal") | |
68 | 77 | ||
69 | 78 | ||
70 | 79 | func getKeyItemStatus (item) = (item + "_status") | |
71 | 80 | ||
72 | 81 | ||
73 | 82 | func getKeyVotesCount (item,vote) = ((item + "_res:") + vote) | |
74 | 83 | ||
75 | 84 | ||
76 | - | func | |
85 | + | func getKeySupplierBalance (supplier) = (supplier + "_balance") | |
77 | 86 | ||
78 | 87 | ||
79 | - | func getKeyBalanceSupplier (account) = (account + "_balance") | |
88 | + | func getPurchase (supplier,item,user) = ("purchase_" + toBase58String(sha256(toBytes(((((supplier + "_") + item) + "_") + user))))) | |
89 | + | ||
90 | + | ||
91 | + | func getKeyPurchaseStatus (purchase) = (purchase + "_status") | |
92 | + | ||
93 | + | ||
94 | + | func getKeyPurchaseItem (purchase) = (purchase + "_item") | |
95 | + | ||
96 | + | ||
97 | + | func getKeyPurchaseSupplier (purchase) = (purchase + "_supplier") | |
98 | + | ||
99 | + | ||
100 | + | func getKeyPurchaseUser (purchase) = (purchase + "_user") | |
101 | + | ||
102 | + | ||
103 | + | func getKeyPurchaseAmount (purchase) = (purchase + "_amount") | |
104 | + | ||
105 | + | ||
106 | + | func getKeyPurchaseTimestamp (purchase) = (purchase + "_timestamp") | |
80 | 107 | ||
81 | 108 | ||
82 | 109 | func getKeyCoupon (assetId) = ("coupon_" + assetId) | |
83 | 110 | ||
84 | 111 | ||
85 | 112 | func getKeyCouponItem (coupon) = (coupon + "_item") | |
86 | 113 | ||
87 | 114 | ||
88 | - | func getValueBalanceSupplier (account) = { | |
89 | - | let supplierBalanceKey = getKeyBalanceSupplier(account) | |
90 | - | match getInteger(this, supplierBalanceKey) { | |
91 | - | case a: Int => | |
92 | - | a | |
93 | - | case _ => | |
94 | - | 0 | |
95 | - | } | |
96 | - | } | |
115 | + | func getValueSupplierBalance (supplier) = getIntegerByKey(getKeySupplierBalance(supplier)) | |
97 | 116 | ||
98 | 117 | ||
99 | - | func getValueUserItemCounter (user,item) = { | |
100 | - | let userItemCounterKey = getKeyUserItemCounter(user, item) | |
101 | - | match getInteger(this, userItemCounterKey) { | |
102 | - | case a: Int => | |
103 | - | a | |
104 | - | case _ => | |
105 | - | 0 | |
106 | - | } | |
107 | - | } | |
118 | + | func getValuePurchaseStatus (purchase) = getStringByKey(getKeyPurchaseStatus(purchase)) | |
108 | 119 | ||
109 | 120 | ||
110 | - | func getValueItemPrice (item) = { | |
111 | - | let keyItemPrice = getKeyItemPrice(item) | |
112 | - | getIntegerValue(this, keyItemPrice) | |
113 | - | } | |
121 | + | func getValuePurchaseItem (purchase) = getStringValue(this, getKeyPurchaseItem(purchase)) | |
122 | + | ||
123 | + | ||
124 | + | func getValuePurchaseSupplier (purchase) = getStringValue(this, getKeyPurchaseSupplier(purchase)) | |
125 | + | ||
126 | + | ||
127 | + | func getValuePurchaseUser (purchase) = getStringValue(this, getKeyPurchaseUser(purchase)) | |
128 | + | ||
129 | + | ||
130 | + | func getValuePurchaseAmount (purchase) = getIntegerValue(this, getKeyPurchaseAmount(purchase)) | |
131 | + | ||
132 | + | ||
133 | + | func getValuePurchaseTimestamp (purchase) = getIntegerByKey(getKeyPurchaseTimestamp(purchase)) | |
134 | + | ||
135 | + | ||
136 | + | func getValueItemPrice (item) = getIntegerValue(this, getKeyItemPrice(item)) | |
114 | 137 | ||
115 | 138 | ||
116 | 139 | func getValueItemSupplier (item) = getStringByKey(getKeyItemSupplier(item)) | |
117 | 140 | ||
118 | 141 | ||
119 | 142 | func getValueItemExpireTime (item) = getIntegerByKey(getKeyItemExpireDate(item)) | |
120 | 143 | ||
121 | 144 | ||
122 | 145 | func getValueItemTitle (item) = getStringByKey(getKeyItemTitle(item)) | |
146 | + | ||
147 | + | ||
148 | + | func getValueItemSoldCounter (item) = getIntegerByKey(getKeyItemSoldCounter(item)) | |
123 | 149 | ||
124 | 150 | ||
125 | 151 | func getValueCommit (item,user) = getStringByKey(getKeyCommit(item, user)) | |
126 | 152 | ||
127 | 153 | ||
128 | 154 | func getValueCommitsCount (item) = getIntegerByKey(getKeyCommitsCount(item)) | |
129 | 155 | ||
130 | 156 | ||
131 | 157 | func getValueReveal (item,user) = getStringByKey(getKeyReveal(item, user)) | |
132 | 158 | ||
133 | 159 | ||
134 | 160 | func getValueItemStatus (item) = getStringByKey(getKeyItemStatus(item)) | |
135 | 161 | ||
136 | 162 | ||
137 | 163 | func getValueVotesCount (item,vote) = getIntegerByKey(getKeyVotesCount(item, vote)) | |
138 | 164 | ||
139 | 165 | ||
140 | 166 | @Callable(i) | |
141 | 167 | func registerSupplier (data) = { | |
142 | 168 | let supplier = toBase58String(i.caller.bytes) | |
143 | 169 | let account = getSupplierAccount(supplier) | |
144 | 170 | if ((account != NONE)) | |
145 | 171 | then throw("This address has already registred as supplier") | |
146 | 172 | else [StringEntry(getKeySupplierAccount(supplier), data)] | |
147 | 173 | } | |
148 | 174 | ||
149 | 175 | ||
150 | 176 | ||
151 | 177 | @Callable(i) | |
152 | 178 | func addItem (title,price,data,expire) = { | |
153 | 179 | let supplier = toBase58String(i.caller.bytes) | |
154 | 180 | let account = getSupplierAccount(supplier) | |
155 | 181 | let item = getKeyItem(supplier, title) | |
156 | 182 | if ((account == NONE)) | |
157 | 183 | then throw("You should register as supplier to add an item") | |
158 | 184 | else if ((0 >= price)) | |
159 | 185 | then throw("Purchase amount cannot be less than item price") | |
160 | 186 | else if ((getValueItemSupplier(item) != NONE)) | |
161 | 187 | then throw("An item already exists") | |
162 | 188 | else [StringEntry(getKeyItemSupplier(item), supplier), StringEntry(getKeyItemTitle(item), title), IntegerEntry(getKeyItemPrice(item), price), StringEntry(getKeyItemData(item), data), IntegerEntry(getKeyItemExpireDate(item), expire)] | |
163 | 189 | } | |
164 | 190 | ||
165 | 191 | ||
166 | 192 | ||
167 | 193 | @Callable(i) | |
168 | 194 | func updateItem (item,title,price,data,expire) = { | |
169 | 195 | let supplier = toBase58String(i.caller.bytes) | |
170 | 196 | let account = getSupplierAccount(supplier) | |
171 | 197 | let itemSupplier = getValueItemSupplier(item) | |
172 | 198 | if ((account == NONE)) | |
173 | 199 | then throw("You should register as supplier to remove an item") | |
174 | 200 | else if (if ((item == NONE)) | |
175 | 201 | then true | |
176 | 202 | else (supplier != itemSupplier)) | |
177 | 203 | then throw(("You don't owned item " + item)) | |
178 | 204 | else [StringEntry(getKeyItemTitle(item), title), IntegerEntry(getKeyItemPrice(item), price), StringEntry(getKeyItemData(item), data), IntegerEntry(getKeyItemExpireDate(item), expire)] | |
179 | 205 | } | |
180 | 206 | ||
181 | 207 | ||
182 | 208 | ||
183 | 209 | @Callable(i) | |
184 | 210 | func removeItem (item) = { | |
185 | 211 | let supplier = toBase58String(i.caller.bytes) | |
186 | 212 | let account = getSupplierAccount(supplier) | |
187 | 213 | let itemSupplier = getValueItemSupplier(item) | |
188 | 214 | if ((account == NONE)) | |
189 | 215 | then throw("You should register as supplier to remove an item") | |
190 | 216 | else if (if ((item == NONE)) | |
191 | 217 | then true | |
192 | 218 | else (supplier != itemSupplier)) | |
193 | 219 | then throw(("You don't owned item " + item)) | |
194 | 220 | else [DeleteEntry(getKeyItemSupplier(item)), DeleteEntry(getKeyItemTitle(item)), DeleteEntry(getKeyItemPrice(item)), DeleteEntry(getKeyItemData(item)), DeleteEntry(getKeyItemExpireDate(item))] | |
195 | 221 | } | |
196 | 222 | ||
197 | 223 | ||
198 | 224 | ||
199 | 225 | @Callable(i) | |
200 | 226 | func purchase (item,assetId) = { | |
201 | 227 | let pmt = i.payments[0] | |
202 | 228 | if (isDefined(pmt.assetId)) | |
203 | 229 | then throw("You can buy tokens only with Waves tokens") | |
204 | 230 | else { | |
205 | - | let | |
231 | + | let user = toBase58String(i.caller.bytes) | |
206 | 232 | let price = getValueItemPrice(item) | |
207 | 233 | let supplier = getValueItemSupplier(item) | |
208 | 234 | let expire = getValueItemExpireTime(item) | |
209 | 235 | if (if ((expire > 0)) | |
210 | 236 | then (lastBlock.timestamp >= expire) | |
211 | 237 | else false) | |
212 | 238 | then throw("Coupon expired") | |
213 | 239 | else if ((price > pmt.amount)) | |
214 | 240 | then throw("Purchase amount cannot be less than item price") | |
215 | 241 | else if ((pmt.amount > price)) | |
216 | 242 | then throw("Purchase amount cannot be higher than item price") | |
217 | 243 | else if ((supplier == NONE)) | |
218 | 244 | then throw("Supplier does not exists") | |
219 | 245 | else { | |
220 | - | let userItemCounter = getKeyUserItemCounter(userAddress, item) | |
221 | - | let newValueUserItemCounter = (getValueUserItemCounter(userAddress, item) + 1) | |
222 | - | let supplierBalanceKey = getKeyBalanceSupplier(supplier) | |
223 | - | let newSupplierBalance = (getValueBalanceSupplier(supplier) + pmt.amount) | |
224 | - | let coupon = getKeyCoupon(assetId) | |
225 | - | [IntegerEntry(userItemCounter, newValueUserItemCounter), IntegerEntry(supplierBalanceKey, newSupplierBalance), StringEntry(getKeyCouponItem(coupon), item), ScriptTransfer(i.caller, 1, fromBase58String(assetId))] | |
246 | + | let purchase = getPurchase(supplier, item, user) | |
247 | + | let keyPurchaseStatus = getKeyPurchaseStatus(purchase) | |
248 | + | let keyPurchaseItem = getKeyPurchaseItem(purchase) | |
249 | + | let keyPurchaseSupplier = getKeyPurchaseSupplier(purchase) | |
250 | + | let keyPurchaseUser = getKeyPurchaseUser(purchase) | |
251 | + | let keyPurchaseAmount = getKeyPurchaseAmount(purchase) | |
252 | + | let keyPurchaseTimestamp = getKeyPurchaseTimestamp(purchase) | |
253 | + | [StringEntry(keyPurchaseStatus, APPROVAL), StringEntry(keyPurchaseItem, item), StringEntry(keyPurchaseSupplier, supplier), StringEntry(keyPurchaseUser, user), IntegerEntry(keyPurchaseAmount, pmt.amount), IntegerEntry(keyPurchaseTimestamp, lastBlock.timestamp)] | |
226 | 254 | } | |
227 | 255 | } | |
256 | + | } | |
257 | + | ||
258 | + | ||
259 | + | ||
260 | + | @Callable(i) | |
261 | + | func rejectPurchase (purchase) = { | |
262 | + | let caller = toBase58String(i.caller.bytes) | |
263 | + | let status = getValuePurchaseStatus(purchase) | |
264 | + | let supplier = getValuePurchaseSupplier(purchase) | |
265 | + | let item = getValuePurchaseItem(purchase) | |
266 | + | if (if ((supplier == NONE)) | |
267 | + | then true | |
268 | + | else (caller != supplier)) | |
269 | + | then throw("Your are not the owner of this item") | |
270 | + | else if ((status != APPROVAL)) | |
271 | + | then throw("You cannot reject this purchased") | |
272 | + | else { | |
273 | + | let keyPurchaseStatus = getKeyPurchaseStatus(purchase) | |
274 | + | let keyPurchaseAmount = getKeyPurchaseAmount(purchase) | |
275 | + | let keySupplierBalance = getKeySupplierBalance(supplier) | |
276 | + | let keyItemSoldCounter = getKeyItemSoldCounter(item) | |
277 | + | let user = getValuePurchaseUser(purchase) | |
278 | + | let amount = getValuePurchaseAmount(purchase) | |
279 | + | let supplierBalance = (getValueSupplierBalance(supplier) - amount) | |
280 | + | let itemSoldCounter = (getValueItemSoldCounter(item) - 1) | |
281 | + | let address = addressFromStringValue(user) | |
282 | + | [StringEntry(keyPurchaseStatus, REJECTED), IntegerEntry(keyPurchaseAmount, 0), ScriptTransfer(address, amount, unit)] | |
283 | + | } | |
284 | + | } | |
285 | + | ||
286 | + | ||
287 | + | ||
288 | + | @Callable(i) | |
289 | + | func acceptPurchase (purchase,couponAssetId) = { | |
290 | + | let caller = toBase58String(i.caller.bytes) | |
291 | + | let status = getValuePurchaseStatus(purchase) | |
292 | + | let supplier = getValuePurchaseSupplier(purchase) | |
293 | + | let item = getValuePurchaseItem(purchase) | |
294 | + | let expire = getValueItemExpireTime(item) | |
295 | + | if (if ((supplier == NONE)) | |
296 | + | then true | |
297 | + | else (caller != supplier)) | |
298 | + | then throw("Your are not the owner of this item") | |
299 | + | else if ((status != APPROVAL)) | |
300 | + | then throw("You cannot reject this purchased") | |
301 | + | else if (if ((expire > 0)) | |
302 | + | then (lastBlock.timestamp >= expire) | |
303 | + | else false) | |
304 | + | then throw("Coupon expired") | |
305 | + | else { | |
306 | + | let keyPurchaseStatus = getKeyPurchaseStatus(purchase) | |
307 | + | let keySupplierBalance = getKeySupplierBalance(supplier) | |
308 | + | let keyItemSoldCounter = getKeyItemSoldCounter(item) | |
309 | + | let amount = getValuePurchaseAmount(purchase) | |
310 | + | let supplierBalance = (getValueSupplierBalance(supplier) + amount) | |
311 | + | let itemSoldCounter = (getValueItemSoldCounter(item) + 1) | |
312 | + | let user = getValuePurchaseUser(purchase) | |
313 | + | let address = addressFromStringValue(user) | |
314 | + | [IntegerEntry(keySupplierBalance, supplierBalance), IntegerEntry(keyItemSoldCounter, itemSoldCounter), ScriptTransfer(address, 1, fromBase58String(couponAssetId))] | |
315 | + | } | |
228 | 316 | } | |
229 | 317 | ||
230 | 318 | ||
231 | 319 | ||
232 | 320 | @Callable(i) | |
233 | 321 | func voteCommit (item,hash) = { | |
234 | 322 | let user = toBase58String(i.caller.bytes) | |
235 | 323 | let commitsCount = getValueCommitsCount(item) | |
236 | 324 | let status = getValueItemStatus(item) | |
237 | 325 | if ((commitsCount >= VOTERS)) | |
238 | 326 | then throw("Reached max number of voters") | |
239 | 327 | else if ((getValueCommit(item, user) != NONE)) | |
240 | 328 | then throw("You voted already") | |
241 | 329 | else if ((getKeyItemSupplier(item) == NONE)) | |
242 | 330 | then throw("Item does not exists") | |
243 | 331 | else if (if ((status != NONE)) | |
244 | 332 | then (status != VOTING) | |
245 | 333 | else false) | |
246 | 334 | then throw("Voting is not active for this item now") | |
247 | 335 | else { | |
248 | 336 | let newStatus = if ((commitsCount == VOTERS)) | |
249 | 337 | then REVEAL | |
250 | 338 | else VOTING | |
251 | 339 | [StringEntry(getKeyCommit(item, user), hash), IntegerEntry(getKeyCommitsCount(item), (commitsCount + 1)), StringEntry(getKeyItemStatus(item), newStatus)] | |
252 | 340 | } | |
253 | 341 | } | |
254 | 342 | ||
255 | 343 | ||
256 | 344 | ||
257 | 345 | @Callable(i) | |
258 | 346 | func voteReveal (item,vote,salt) = { | |
259 | 347 | let user = toBase58String(i.caller.bytes) | |
260 | 348 | let status = getValueItemStatus(item) | |
261 | 349 | let newVotesCount = (getValueVotesCount(item, vote) + 1) | |
262 | 350 | let saltedVote = toBase58String(sha256(toBytes(((item + vote) + salt)))) | |
263 | 351 | if ((saltedVote != getValueCommit(item, user))) | |
264 | 352 | then throw("Reveal data is not valid") | |
265 | 353 | else if ((VOTERS > getValueCommitsCount(item))) | |
266 | 354 | then throw("Max number of voters not reached") | |
267 | 355 | else if ((getValueReveal(item, user) != NONE)) | |
268 | 356 | then throw("You voted already") | |
269 | 357 | else if (if ((status != VOTING)) | |
270 | 358 | then (status != REVEAL) | |
271 | 359 | else false) | |
272 | 360 | then throw("Voting is not active for this item now") | |
273 | 361 | else if (if ((vote != FEATURED)) | |
274 | 362 | then (vote != DELISTED) | |
275 | 363 | else false) | |
276 | 364 | then throw("Provided voting option is incorrect") | |
277 | 365 | else { | |
278 | 366 | let newStatus = if ((newVotesCount >= QUORUM)) | |
279 | 367 | then vote | |
280 | 368 | else REVEAL | |
281 | 369 | [StringEntry(getKeyReveal(item, user), vote), IntegerEntry(getKeyVotesCount(item, user), newVotesCount), StringEntry(getKeyItemStatus(item), newStatus)] | |
282 | 370 | } | |
283 | 371 | } | |
284 | 372 | ||
285 | 373 | ||
286 | 374 | @Verifier(tx) | |
287 | 375 | func verify () = match tx { | |
288 | 376 | case t: SetScriptTransaction => | |
289 | 377 | sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
290 | 378 | case t: IssueTransaction => | |
291 | 379 | sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
292 | 380 | case t: TransferTransaction => | |
293 | 381 | sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
294 | 382 | case _ => | |
295 | 383 | false | |
296 | 384 | } | |
297 | 385 |
github/deemru/w8io/026f985 61.88 ms ◑