tx · 7AZAbkKJcjr7Cduct2433dDyb9Bgnxuz484Gxs4qugUV
3MzFjVphaDKp1oZjd5KmCYou3wCzCzTmEFe: -0.00300000 Waves
2022.09.20 22:17 [2237872] smart account 3MzFjVphaDKp1oZjd5KmCYou3wCzCzTmEFe > SELF 0.00000000 Waves
{
"type": 13,
"id": "7AZAbkKJcjr7Cduct2433dDyb9Bgnxuz484Gxs4qugUV",
"fee": 300000,
"feeAssetId": null,
"timestamp": 1663701479892,
"version": 2,
"chainId": 84,
"sender": "3MzFjVphaDKp1oZjd5KmCYou3wCzCzTmEFe",
"senderPublicKey": "FFVf3kC6HkjRMmf8W6Zr2bNKhJ5EN5W1vG44GbgvHd9Z",
"proofs": [
"AH77aHC8G9jD8fg9ds7uKpUUHzbE4zRnyqHi6SoZf1w7WMAFYZMaqD71j35B36xqQPUMmXsHMpv47jDDVbDabvV"
],
"script": "base64:AAIDAAAAAAAAAA4IARIDCgEIEgUKAwgBCAAAAA0AAAAABE5PTkUCAAAABG5vbmUBAAAADmdldE51bWJlckJ5S2V5AAAAAQAAAANrZXkEAAAAA251bQQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQAAAAAAAAAAAAUAAAADbnVtAQAAAAtnZXRTdHJCeUtleQAAAAEAAAADa2V5BAAAAANzdHIEAAAAByRtYXRjaDAJAAQdAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAAZTdHJpbmcEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEFAAAABE5PTkUFAAAAA3N0cgEAAAAPZ2V0S2V5SXRlbVByaWNlAAAAAQAAAARpdGVtCQABLAAAAAIFAAAABGl0ZW0CAAAABl9wcmljZQEAAAARZ2V0VmFsdWVJdGVtUHJpY2UAAAABAAAABGl0ZW0JAQAAAA5nZXROdW1iZXJ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AAAHYWRkSXRlbQAAAAMAAAAFdGl0bGUAAAAFcHJpY2UAAAAEZGF0YQQAAAAPc3VwcGxpZXJBZGRyZXNzCQACWAAAAAEICAUAAAABaQAAAAZjYWxsZXIAAAAFYnl0ZXMEAAAABGl0ZW0JAQAAAApnZXRLZXlJdGVtAAAAAgUAAAAPc3VwcGxpZXJBZGRyZXNzBQAAAAV0aXRsZQMJAABnAAAAAgAAAAAAAAAAAAUAAAAFcHJpY2UJAAACAAAAAQIAAAArcHVyY2hhc2UgY2Fubm90IGJlIGxlc3MgdGhhbiB0aGUgaXRlbSBwcmljZQMJAQAAAAIhPQAAAAIJAQAAABRnZXRWYWx1ZUl0ZW1TdXBwbGllcgAAAAEFAAAABGl0ZW0FAAAABE5PTkUJAAACAAAAAQIAAAAYVGhlIGl0ZW0gYWxyZWFkeSBleGl0c3RzCQEAAAAIV3JpdGVTZXQAAAABCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQEAAAASZ2V0S2V5SXRlbVN1cHBsaWVyAAAAAQUAAAAEaXRlbQUAAAAPc3VwcGxpZXJBZGRyZXNzCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQEAAAAPZ2V0S2V5SXRlbVByaWNlAAAAAQUAAAAEaXRlbQUAAAAFcHJpY2UJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAQAAAA5nZXRLZXlJdGVtRGF0YQAAAAEFAAAABGl0ZW0FAAAABGRhdGEFAAAAA25pbAAAAACVl79s",
"height": 2237872,
"applicationStatus": "succeeded",
"spentComplexity": 0
}
View: original | compacted
Prev: G6DAxYWgrrwBWBFg4uwSHuQHzqxV8y7fjyjruXmhRAJf
Next: LzGFe5oDRvadGJqCpt8fUXcb1cSp2WmFdCLsMk7LbAm
Diff:
Old | New | | Differences |
---|
15 | 15 | | |
---|
16 | 16 | | |
---|
17 | 17 | | func getStrByKey (key) = { |
---|
18 | | - | let str = match getInteger(this, key) { |
---|
19 | | - | case a: Int => |
---|
| 18 | + | let str = match getString(this, key) { |
---|
| 19 | + | case a: String => |
---|
20 | 20 | | a |
---|
21 | 21 | | case _ => |
---|
22 | 22 | | NONE |
---|
|
56 | 56 | | |
---|
57 | 57 | | |
---|
58 | 58 | | @Callable(i) |
---|
59 | | - | func purchase (CouponType) = { |
---|
| 59 | + | func purchase (item) = { |
---|
60 | 60 | | let pmt = extract(i.payment) |
---|
61 | 61 | | if (isDefined(pmt.assetId)) |
---|
62 | 62 | | then throw("can use WAVES only at the moment") |
---|
63 | 63 | | else { |
---|
64 | | - | let customerAddress = toBase58String(i.caller.bytes) |
---|
65 | | - | let price = match getInteger(this, (("Item_" + CouponType) + "_coupon_price")) { |
---|
66 | | - | case a: Int => |
---|
67 | | - | a |
---|
68 | | - | case _ => |
---|
69 | | - | 0 |
---|
70 | | - | } |
---|
| 64 | + | let userAddress = toBase58String(i.caller.bytes) |
---|
| 65 | + | let price = getValueItemPrice(item) |
---|
| 66 | + | let supplierAddress = getValueItemSupplier(item) |
---|
71 | 67 | | if ((pmt.amount != price)) |
---|
72 | 68 | | then throw("Purchase amount should be equal to price ") |
---|
73 | | - | else WriteSet([DataEntry(((("status: purchase_item_" + CouponType) + "_customer_") + customerAddress), "confirmed"), DataEntry(((("price: purchase_item_" + CouponType) + "_customer_") + customerAddress), price)]) |
---|
| 69 | + | else if ((supplierAddress == NONE)) |
---|
| 70 | + | then throw("The supplier does not exist") |
---|
| 71 | + | else WriteSet([DataEntry(getKeyUserItemCounter(userAddress, item), (getValueUserItemCounter(userAddress, item) + 1)), DataEntry(getKeyBalanceSupplier(supplierAddress), (getValueBalanceSupplier(supplierAddress) + pmt.amount))]) |
---|
74 | 72 | | } |
---|
75 | 73 | | } |
---|
76 | 74 | | |
---|
Full:
Old | New | | Differences |
---|
1 | 1 | | {-# STDLIB_VERSION 3 #-} |
---|
2 | 2 | | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | 3 | | {-# CONTENT_TYPE DAPP #-} |
---|
4 | 4 | | let NONE = "none" |
---|
5 | 5 | | |
---|
6 | 6 | | func getNumberByKey (key) = { |
---|
7 | 7 | | let num = match getInteger(this, key) { |
---|
8 | 8 | | case a: Int => |
---|
9 | 9 | | a |
---|
10 | 10 | | case _ => |
---|
11 | 11 | | 0 |
---|
12 | 12 | | } |
---|
13 | 13 | | num |
---|
14 | 14 | | } |
---|
15 | 15 | | |
---|
16 | 16 | | |
---|
17 | 17 | | func getStrByKey (key) = { |
---|
18 | | - | let str = match getInteger(this, key) { |
---|
19 | | - | case a: Int => |
---|
| 18 | + | let str = match getString(this, key) { |
---|
| 19 | + | case a: String => |
---|
20 | 20 | | a |
---|
21 | 21 | | case _ => |
---|
22 | 22 | | NONE |
---|
23 | 23 | | } |
---|
24 | 24 | | str |
---|
25 | 25 | | } |
---|
26 | 26 | | |
---|
27 | 27 | | |
---|
28 | 28 | | func getKeyItemPrice (item) = (item + "_price") |
---|
29 | 29 | | |
---|
30 | 30 | | |
---|
31 | 31 | | func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item)) |
---|
32 | 32 | | |
---|
33 | 33 | | |
---|
34 | 34 | | func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt") |
---|
35 | 35 | | |
---|
36 | 36 | | |
---|
37 | 37 | | func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item)) |
---|
38 | 38 | | |
---|
39 | 39 | | |
---|
40 | 40 | | func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title))))) |
---|
41 | 41 | | |
---|
42 | 42 | | |
---|
43 | 43 | | func getKeyItemData (item) = (item + "_data") |
---|
44 | 44 | | |
---|
45 | 45 | | |
---|
46 | 46 | | func getKeyItemSupplier (item) = (item + "_owner") |
---|
47 | 47 | | |
---|
48 | 48 | | |
---|
49 | 49 | | func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item)) |
---|
50 | 50 | | |
---|
51 | 51 | | |
---|
52 | 52 | | func getKeyBalanceSupplier (account) = (account + "_balance") |
---|
53 | 53 | | |
---|
54 | 54 | | |
---|
55 | 55 | | func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account)) |
---|
56 | 56 | | |
---|
57 | 57 | | |
---|
58 | 58 | | @Callable(i) |
---|
59 | | - | func purchase (CouponType) = { |
---|
| 59 | + | func purchase (item) = { |
---|
60 | 60 | | let pmt = extract(i.payment) |
---|
61 | 61 | | if (isDefined(pmt.assetId)) |
---|
62 | 62 | | then throw("can use WAVES only at the moment") |
---|
63 | 63 | | else { |
---|
64 | | - | let customerAddress = toBase58String(i.caller.bytes) |
---|
65 | | - | let price = match getInteger(this, (("Item_" + CouponType) + "_coupon_price")) { |
---|
66 | | - | case a: Int => |
---|
67 | | - | a |
---|
68 | | - | case _ => |
---|
69 | | - | 0 |
---|
70 | | - | } |
---|
| 64 | + | let userAddress = toBase58String(i.caller.bytes) |
---|
| 65 | + | let price = getValueItemPrice(item) |
---|
| 66 | + | let supplierAddress = getValueItemSupplier(item) |
---|
71 | 67 | | if ((pmt.amount != price)) |
---|
72 | 68 | | then throw("Purchase amount should be equal to price ") |
---|
73 | | - | else WriteSet([DataEntry(((("status: purchase_item_" + CouponType) + "_customer_") + customerAddress), "confirmed"), DataEntry(((("price: purchase_item_" + CouponType) + "_customer_") + customerAddress), price)]) |
---|
| 69 | + | else if ((supplierAddress == NONE)) |
---|
| 70 | + | then throw("The supplier does not exist") |
---|
| 71 | + | else WriteSet([DataEntry(getKeyUserItemCounter(userAddress, item), (getValueUserItemCounter(userAddress, item) + 1)), DataEntry(getKeyBalanceSupplier(supplierAddress), (getValueBalanceSupplier(supplierAddress) + pmt.amount))]) |
---|
74 | 72 | | } |
---|
75 | 73 | | } |
---|
76 | 74 | | |
---|
77 | 75 | | |
---|
78 | 76 | | |
---|
79 | 77 | | @Callable(i) |
---|
80 | 78 | | func addItem (title,price,data) = { |
---|
81 | 79 | | let supplierAddress = toBase58String(i.caller.bytes) |
---|
82 | 80 | | let item = getKeyItem(supplierAddress, title) |
---|
83 | 81 | | if ((0 >= price)) |
---|
84 | 82 | | then throw("purchase cannot be less than the item price") |
---|
85 | 83 | | else if ((getValueItemSupplier(item) != NONE)) |
---|
86 | 84 | | then throw("The item already exitsts") |
---|
87 | 85 | | else WriteSet([DataEntry(getKeyItemSupplier(item), supplierAddress), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data)]) |
---|
88 | 86 | | } |
---|
89 | 87 | | |
---|
90 | 88 | | |
---|