tx · 4Q9mi4c6aa9MAZpEX1u9ji4V79qDpyRZ3uGEWm4skKXQ 3NAH9wsZ5Gr1LW7eZTnbbFAGL3omhKK7YWK: -0.01000000 Waves 2022.04.30 15:52 [2031218] smart account 3NAH9wsZ5Gr1LW7eZTnbbFAGL3omhKK7YWK > SELF 0.00000000 Waves
{ "type": 13, "id": "4Q9mi4c6aa9MAZpEX1u9ji4V79qDpyRZ3uGEWm4skKXQ", "fee": 1000000, "feeAssetId": null, "timestamp": 1651323159806, "version": 2, "chainId": 84, "sender": "3NAH9wsZ5Gr1LW7eZTnbbFAGL3omhKK7YWK", "senderPublicKey": "EdiZKeSSzmoYqkk6ce532zc65KcUXi9HckEuP7sWPHmW", "proofs": [ "DeLuwtzyt4B87L3t4ndixXmrvHbzUx8ogjNwdNtcoEzhWGoowWPMh227f6EA1UUJyMBFLU4Eevo5CGRynbjumAD" ], "script": "base64:AAIDAAAAAAAAAA4IARIFCgMIAQgSAwoBCAAAAA0AAAAABE5PTkUCAAAABG5vbmUBAAAADmdldE51bWJlckJ5S2V5AAAAAQAAAANrZXkEAAAAA251bQQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQAAAAAAAAAAAAUAAAADbnVtAQAAAAtnZXRTdHJCeUtleQAAAAEAAAADa2V5BAAAAANzdHIEAAAAByRtYXRjaDAJAAQdAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAAZTdHJpbmcEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEFAAAABE5PTkUFAAAAA3N0cgEAAAAPZ2V0S2V5SXRlbVByaWNlAAAAAQAAAARpdGVtCQABLAAAAAIFAAAABGl0ZW0CAAAABl9wcmljZQEAAAARZ2V0VmFsdWVJdGVtUHJpY2UAAAABAAAABGl0ZW0JAQAAAA5nZXROdW1i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QAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzCQABLAAAAAIJAAEsAAAAAgIAAAAFaXRlbV8FAAAABmNvdXBvbgIAAAANX2NvdXBvbl9wcmljZQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhAAAAAAAAAAAAAwkAAGYAAAACBQAAAAVwcmljZQgFAAAAA3BtdAAAAAZhbW91bnQJAAACAAAAAQIAAAAucHVyY2hhc2UgYW1vdW50IGNhbm5vdCBiZSBsZXNzIHRoYW4gaXRlbSBwcmljZQMJAABmAAAAAggFAAAAA3BtdAAAAAZhbW91bnQFAAAABXByaWNlCQAAAgAAAAECAAAAMHB1cmNoYXNlIGFtb3VudCBjYW5ub3QgYmUgaGlnaGVyIHRoYW4gaXRlbSBwcmljZQkBAAAACFdyaXRlU2V0AAAAAQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkAASwAAAACCQABLAAAAAIJAAEsAAAAAgIAAAAVc3RhdHVzOnB1cmNoYXNlX2l0ZW1fBQAAAAZjb3Vwb24CAAAACl9jdXN0b21lcl8FAAAAD2N1c3RvbWVyQWRkcmVzcwIAAAAJY29uZmlybWVkCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQABLAAAAAIJAAEsAAAAAgkAASwAAAACAgAAABRwcmljZTpwdXJjaGFzZV9pdGVtXwUAAAAGY291cG9uAgAAAApfY3VzdG9tZXJfBQAAAA9jdXN0b21lckFkZHJlc3MFAAAABXByaWNlBQAAAANuaWwAAAAA4jZVMA==", "height": 2031218, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 5iEA3oZjeqTBadABVhbNQaX5Mf6NhPwP57Ui3JK4vovL Next: 25JMQu2Eku8ER5ZwD7ybznMJASw9u49LxCZXmPSevb7A 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 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)) | |
4 | 56 | ||
5 | 57 | ||
6 | 58 | @Callable(i) | |
7 | - | func purchase () = { | |
59 | + | func addItem (title,price,data) = { | |
60 | + | let supplierAddress = toBase58String(i.caller.bytes) | |
61 | + | let item = getKeyItem(supplierAddress, title) | |
62 | + | if ((0 >= price)) | |
63 | + | then throw("purchase amount cannot be less thanitem price") | |
64 | + | else if ((getValueItemSupplier(item) != NONE)) | |
65 | + | then throw("an item is already exist") | |
66 | + | else WriteSet([DataEntry(getKeyItemSupplier(item), supplierAddress), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data)]) | |
67 | + | } | |
68 | + | ||
69 | + | ||
70 | + | ||
71 | + | @Callable(i) | |
72 | + | func purchase (coupon) = { | |
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_" + coupon) + "_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_" + coupon) + "_customer_") + customerAddress), "confirmed"), DataEntry(((("price:purchase_item_" + coupon) + "_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 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)) | |
4 | 56 | ||
5 | 57 | ||
6 | 58 | @Callable(i) | |
7 | - | func purchase () = { | |
59 | + | func addItem (title,price,data) = { | |
60 | + | let supplierAddress = toBase58String(i.caller.bytes) | |
61 | + | let item = getKeyItem(supplierAddress, title) | |
62 | + | if ((0 >= price)) | |
63 | + | then throw("purchase amount cannot be less thanitem price") | |
64 | + | else if ((getValueItemSupplier(item) != NONE)) | |
65 | + | then throw("an item is already exist") | |
66 | + | else WriteSet([DataEntry(getKeyItemSupplier(item), supplierAddress), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data)]) | |
67 | + | } | |
68 | + | ||
69 | + | ||
70 | + | ||
71 | + | @Callable(i) | |
72 | + | func purchase (coupon) = { | |
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_" + coupon) + "_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_" + coupon) + "_customer_") + customerAddress), "confirmed"), DataEntry(((("price:purchase_item_" + coupon) + "_customer_") + customerAddress), price)]) | |
24 | 89 | } | |
25 | 90 | } | |
26 | 91 | ||
27 | 92 |
github/deemru/w8io/026f985 36.16 ms ◑