tx · 9Z3DiMwbHP4SkNpsMSPMhgwKHWAWQpKRuixmJi5Fu8be 3MxN6Cszfki941gTcEwXc8ngmbWPTsHoJFq: -0.01500000 Waves 2019.06.22 10:40 [552935] smart account 3MxN6Cszfki941gTcEwXc8ngmbWPTsHoJFq > SELF 0.00000000 Waves
{ "type": 13, "id": "9Z3DiMwbHP4SkNpsMSPMhgwKHWAWQpKRuixmJi5Fu8be", "fee": 1500000, "feeAssetId": null, "timestamp": 1561189232098, "version": 1, "sender": "3MxN6Cszfki941gTcEwXc8ngmbWPTsHoJFq", "senderPublicKey": "4fygXNNAjU52sT9N6uq4o9Ck8G75e94ukktN3pd4VxVo", "proofs": [ "5TGCSeDpNEc6ZaoYJoz1cFs37FUhkGTxSJgEn5ZiK9ZqzvE6nGeUmnpRR4kaDBVdVRXX8arGifXuxThpivnb1gv5" ], "script": "base64:AAIDAAAAAAAAAAAAAAANAAAAAAROT05FAgAAAARub25lAQAAAA9nZXRLZXlJdGVtUHJpY2UAAAABAAAABGl0ZW0JAAEsAAAAAgUAAAAEaXRlbQIAAAAGX3ByaWNlAQAAAA5nZXROdW1iZXJCeUtleQAAAAEAAAADa2V5BAAAAANudW0EAAAAByRtYXRjaDAJAAQaAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAANJbnQEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEAAAAAAAAAAAAFAAAAA251bQEAAAALZ2V0U3RyQnlLZXkAAAABAAAAA2tleQQAAAADc3RyBAAAAAckbWF0Y2gwCQAEHQAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAGU3RyaW5nBAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhBQAAAAROT05FBQAAAANzdHIBAAAAFWdldEtleVVzZXJJdGVtQ291bnRlcgAAAAIAAAAEdXNlcgAAAARpdGVtCQABLAAAAAIJAAEsAAAAAgkAASwAAAACBQAAAARpd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3Vwb25fcHJpY2UDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQAAAAAAAAAAAAMJAABmAAAAAgUAAAAFcHJpY2UIBQAAAANwbXQAAAAGYW1vdW50CQAAAgAAAAECAAAAL3B1cmNoYXNlIGFtb3VudCBjYW5ub3QgYmUgbGVzcyB0aGFuIGl0ZW0gcHJpY2UgAwkAAGYAAAACCAUAAAADcG10AAAABmFtb3VudAUAAAAFcHJpY2UJAAACAAAAAQIAAAAwcHVyY2hhc2UgYW1vdW50IGNhbm5vdCBiZSBoaWdoZXIgdGhhbiBpdGVtIHByaWNlCQEAAAAIV3JpdGVTZXQAAAABCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQABLAAAAAIJAAEsAAAAAgkAASwAAAACAgAAABVzdGF0dXM6cHVyY2hhc2VfaXRlbV8FAAAABGl0ZW0CAAAACl9jdXN0b21lcl8FAAAAD2N1c3RvbWVyQWRkcmVzcwIAAAAJY29uZmlybWVkCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQABLAAAAAIJAAEsAAAAAgkAASwAAAACAgAAABRwcmljZTpwdXJjaGFzZV9pdGVtXwUAAAAEaXRlbQIAAAAKX2N1c3RvbWVyXwUAAAAPY3VzdG9tZXJBZGRyZXNzBQAAAAVwcmljZQUAAAADbmlsAAAAAMoEwOY=", "chainId": 84, "height": 552935, "spentComplexity": 0 } View: original | compacted Prev: AraUkP3ARw7eQ9vqvUij6GLKFoiFyH7yUFhe8vCUhmbm Next: CWrLUufHmLNSbDeiEJXyBgDDFcBNkrBwR9jRnzUmkLhB Diff:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let NONE = "none" | |
5 | + | ||
6 | + | func getKeyItemPrice (item) = (item + "_price") | |
7 | + | ||
8 | + | ||
9 | + | func getNumberByKey (key) = { | |
10 | + | let num = match getInteger(this, key) { | |
11 | + | case a: Int => | |
12 | + | a | |
13 | + | case _ => | |
14 | + | 0 | |
15 | + | } | |
16 | + | num | |
17 | + | } | |
18 | + | ||
19 | + | ||
20 | + | func getStrByKey (key) = { | |
21 | + | let str = match getString(this, key) { | |
22 | + | case a: String => | |
23 | + | a | |
24 | + | case _ => | |
25 | + | NONE | |
26 | + | } | |
27 | + | str | |
28 | + | } | |
29 | + | ||
30 | + | ||
31 | + | func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt") | |
32 | + | ||
33 | + | ||
34 | + | func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item)) | |
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)) | |
4 | 56 | ||
5 | 57 | ||
6 | 58 | @Callable(i) | |
7 | - | func purchase () = { | |
59 | + | func additem (title,price,data) = { | |
60 | + | let suppad = toBase58String(i.caller.bytes) | |
61 | + | let item = getKeyItem(suppad, title) | |
62 | + | if ((0 >= price)) | |
63 | + | then throw("purchase amount cannot be less than 0 or 0") | |
64 | + | else if ((getValueItemSupplier(item) != NONE)) | |
65 | + | then throw("an item already exists") | |
66 | + | else WriteSet([DataEntry(getKeyItemSupplier(item), suppad), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data)]) | |
67 | + | } | |
68 | + | ||
69 | + | ||
70 | + | ||
71 | + | @Callable(i) | |
72 | + | func purchase (item) = { | |
8 | 73 | let pmt = extract(i.payment) | |
9 | 74 | if (isDefined(pmt.assetId)) | |
10 | 75 | then throw("Can use Waves only at the moment") | |
11 | 76 | else { | |
12 | 77 | let customerAddress = toBase58String(i.caller.bytes) | |
13 | - | let price = match getInteger(this, "item_ | |
78 | + | let price = match getInteger(this, (("item_" + item) + "_coupon_price")) { | |
14 | 79 | case a: Int => | |
15 | 80 | a | |
16 | 81 | case _ => | |
20 | 85 | then throw("purchase amount cannot be less than item price ") | |
21 | 86 | else if ((pmt.amount > price)) | |
22 | 87 | then throw("purchase amount cannot be higher than item price") | |
23 | - | else WriteSet([DataEntry(("status:purchase_item_ | |
88 | + | else WriteSet([DataEntry(((("status:purchase_item_" + item) + "_customer_") + customerAddress), "confirmed"), DataEntry(((("price:purchase_item_" + item) + "_customer_") + customerAddress), price)]) | |
24 | 89 | } | |
25 | 90 | } | |
26 | 91 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let NONE = "none" | |
5 | + | ||
6 | + | func getKeyItemPrice (item) = (item + "_price") | |
7 | + | ||
8 | + | ||
9 | + | func getNumberByKey (key) = { | |
10 | + | let num = match getInteger(this, key) { | |
11 | + | case a: Int => | |
12 | + | a | |
13 | + | case _ => | |
14 | + | 0 | |
15 | + | } | |
16 | + | num | |
17 | + | } | |
18 | + | ||
19 | + | ||
20 | + | func getStrByKey (key) = { | |
21 | + | let str = match getString(this, key) { | |
22 | + | case a: String => | |
23 | + | a | |
24 | + | case _ => | |
25 | + | NONE | |
26 | + | } | |
27 | + | str | |
28 | + | } | |
29 | + | ||
30 | + | ||
31 | + | func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt") | |
32 | + | ||
33 | + | ||
34 | + | func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item)) | |
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)) | |
4 | 56 | ||
5 | 57 | ||
6 | 58 | @Callable(i) | |
7 | - | func purchase () = { | |
59 | + | func additem (title,price,data) = { | |
60 | + | let suppad = toBase58String(i.caller.bytes) | |
61 | + | let item = getKeyItem(suppad, title) | |
62 | + | if ((0 >= price)) | |
63 | + | then throw("purchase amount cannot be less than 0 or 0") | |
64 | + | else if ((getValueItemSupplier(item) != NONE)) | |
65 | + | then throw("an item already exists") | |
66 | + | else WriteSet([DataEntry(getKeyItemSupplier(item), suppad), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data)]) | |
67 | + | } | |
68 | + | ||
69 | + | ||
70 | + | ||
71 | + | @Callable(i) | |
72 | + | func purchase (item) = { | |
8 | 73 | let pmt = extract(i.payment) | |
9 | 74 | if (isDefined(pmt.assetId)) | |
10 | 75 | then throw("Can use Waves only at the moment") | |
11 | 76 | else { | |
12 | 77 | let customerAddress = toBase58String(i.caller.bytes) | |
13 | - | let price = match getInteger(this, "item_ | |
78 | + | let price = match getInteger(this, (("item_" + item) + "_coupon_price")) { | |
14 | 79 | case a: Int => | |
15 | 80 | a | |
16 | 81 | case _ => | |
17 | 82 | 0 | |
18 | 83 | } | |
19 | 84 | if ((price > pmt.amount)) | |
20 | 85 | then throw("purchase amount cannot be less than item price ") | |
21 | 86 | else if ((pmt.amount > price)) | |
22 | 87 | then throw("purchase amount cannot be higher than item price") | |
23 | - | else WriteSet([DataEntry(("status:purchase_item_ | |
88 | + | else WriteSet([DataEntry(((("status:purchase_item_" + item) + "_customer_") + customerAddress), "confirmed"), DataEntry(((("price:purchase_item_" + item) + "_customer_") + customerAddress), price)]) | |
24 | 89 | } | |
25 | 90 | } | |
26 | 91 | ||
27 | 92 |
github/deemru/w8io/026f985 34.90 ms ◑