tx · BzahxzYZFuNh5PvUKJKQGB4KxPVgrYQC937ZQE1sMCQM
3NAj7owPjfmLoE3odgXC6cXfB1QzEhnpBtt: -0.01400000 Waves
2020.11.18 16:42 [1270858] smart account 3NAj7owPjfmLoE3odgXC6cXfB1QzEhnpBtt > SELF 0.00000000 Waves
{
"type": 13,
"id": "BzahxzYZFuNh5PvUKJKQGB4KxPVgrYQC937ZQE1sMCQM",
"fee": 1400000,
"feeAssetId": null,
"timestamp": 1605707018481,
"version": 2,
"chainId": 84,
"sender": "3NAj7owPjfmLoE3odgXC6cXfB1QzEhnpBtt",
"senderPublicKey": "iRqJrgq4rS2ndNGFJoZtKcoTfskkxr3zfTesPWqtKzp",
"proofs": [
"LQaRtFSSvXkrEQ3pgBauit2JLueLXuCE2vJGSvm2dT571QxjLcU6uUkDx3GWEQYwVDPajnVXFPiXcZZrfRXgKaA"
],
"script": "base64:AAIEAAAAAAAAAA4IAhIDCgEIEgUKAwgBCAAAAAAAAAACAAAAAWkBAAAACHB1cmNoYXNlAAAAAQAAAARpdGVtBAAAAAdwYXltZW50CQEAAAAFdmFsdWUAAAABCQABkQAAAAIIBQAAAAFpAAAACHBheW1lbnRzAAAAAAAAAAAAAwkBAAAACWlzRGVmaW5lZAAAAAEIBQAAAAdwYXltZW50AAAAB2Fzc2V0SWQJAAACAAAAAQIAAAAKV2F2ZXMgb25seQQAAAALdXNlckFkZHJlc3MJAAJYAAAAAQgIBQAAAAFpAAAABmNhbGxlcgAAAAVieXRlcwQAAAAFcHJpY2UJAQAAABFAZXh0ck5hdGl2ZSgxMDUwKQAAAAIFAAAABHRoaXMJAAEsAAAAAgUAAAAEaXRlbQIAAAAGX3ByaWNlBAAAAAhzdXBwbGllcgkBAAAAEUBleHRyTmF0aXZlKDEwNTMpAAAAAgUAAAAEdGhpcwkAASwAAAACBQAAAARpdGVtAgAAAAlfc3VwcGxpZXIDCQAAZgAAAAIFAAAABXByaWNlCAUAAAAHcGF5bWVudAAAAAZhbW91bnQJAA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AAAAAAAAAAUAAAADbmlsAAAAAQAAAAJ0eAEAAAAGdmVyaWZ5AAAAAAZyu/uJ",
"height": 1270858,
"applicationStatus": "succeeded",
"spentComplexity": 0
}
View: original | compacted
Prev: EH3rjfx3jQY3oymHJnWF263qfCuqGB6a9BsYjwNEikZv
Next: 4ppnnPcbAokg66apjxWC9sX6gGmFbkGz9CShCiExuNu5
Diff:
Old | New | | Differences |
---|
4 | 4 | | |
---|
5 | 5 | | |
---|
6 | 6 | | @Callable(i) |
---|
7 | | - | func purchase (itemName) = { |
---|
| 7 | + | func purchase (item) = { |
---|
8 | 8 | | let payment = value(i.payments[0]) |
---|
9 | 9 | | if (isDefined(payment.assetId)) |
---|
10 | | - | then throw("Only Waves are accepted") |
---|
| 10 | + | then throw("Waves only") |
---|
11 | 11 | | else { |
---|
12 | | - | let customerAddress = toBase58String(i.caller.bytes) |
---|
13 | | - | let price = match getInteger(this, (itemName + "_coupon_price")) { |
---|
14 | | - | case a: Int => |
---|
15 | | - | (a * 100000000) |
---|
16 | | - | case _ => |
---|
17 | | - | throw("Item not found") |
---|
18 | | - | } |
---|
| 12 | + | let userAddress = toBase58String(i.caller.bytes) |
---|
| 13 | + | let price = getIntegerValue(this, (item + "_price")) |
---|
| 14 | + | let supplier = getStringValue(this, (item + "_supplier")) |
---|
19 | 15 | | if ((price > payment.amount)) |
---|
20 | | - | then throw("Purchase amount is too low") |
---|
| 16 | + | then throw("Too low") |
---|
21 | 17 | | else if ((payment.amount > price)) |
---|
22 | | - | then throw("Purchase amount is too high") |
---|
23 | | - | else [StringEntry(("status:purchase_item_A_customer" + customerAddress), "true"), IntegerEntry(("price:purchase_item_A_customer" + customerAddress), price)] |
---|
| 18 | + | then throw("Too high") |
---|
| 19 | + | else [IntegerEntry((item + "_counter"), (getIntegerValue(this, (item + "_counter")) + 1))] |
---|
24 | 20 | | } |
---|
25 | 21 | | } |
---|
26 | 22 | | |
---|
|
34 | 30 | | then throw("Price cannot be lower than 0") |
---|
35 | 31 | | else if (isDefined(getString(this, key))) |
---|
36 | 32 | | then throw("Item exists") |
---|
37 | | - | else [StringEntry((key + "_supplier"), supplierAddress), IntegerEntry((key + "_price"), price), StringEntry((key + "_data"), data)] |
---|
| 33 | + | else [StringEntry((key + "_supplier"), supplierAddress), IntegerEntry((key + "_price"), price), StringEntry((key + "_data"), data), IntegerEntry((key + "_counter"), 0)] |
---|
38 | 34 | | } |
---|
39 | 35 | | |
---|
40 | 36 | | |
---|
Full:
Old | New | | Differences |
---|
1 | 1 | | {-# STDLIB_VERSION 4 #-} |
---|
2 | 2 | | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | 3 | | {-# CONTENT_TYPE DAPP #-} |
---|
4 | 4 | | |
---|
5 | 5 | | |
---|
6 | 6 | | @Callable(i) |
---|
7 | | - | func purchase (itemName) = { |
---|
| 7 | + | func purchase (item) = { |
---|
8 | 8 | | let payment = value(i.payments[0]) |
---|
9 | 9 | | if (isDefined(payment.assetId)) |
---|
10 | | - | then throw("Only Waves are accepted") |
---|
| 10 | + | then throw("Waves only") |
---|
11 | 11 | | else { |
---|
12 | | - | let customerAddress = toBase58String(i.caller.bytes) |
---|
13 | | - | let price = match getInteger(this, (itemName + "_coupon_price")) { |
---|
14 | | - | case a: Int => |
---|
15 | | - | (a * 100000000) |
---|
16 | | - | case _ => |
---|
17 | | - | throw("Item not found") |
---|
18 | | - | } |
---|
| 12 | + | let userAddress = toBase58String(i.caller.bytes) |
---|
| 13 | + | let price = getIntegerValue(this, (item + "_price")) |
---|
| 14 | + | let supplier = getStringValue(this, (item + "_supplier")) |
---|
19 | 15 | | if ((price > payment.amount)) |
---|
20 | | - | then throw("Purchase amount is too low") |
---|
| 16 | + | then throw("Too low") |
---|
21 | 17 | | else if ((payment.amount > price)) |
---|
22 | | - | then throw("Purchase amount is too high") |
---|
23 | | - | else [StringEntry(("status:purchase_item_A_customer" + customerAddress), "true"), IntegerEntry(("price:purchase_item_A_customer" + customerAddress), price)] |
---|
| 18 | + | then throw("Too high") |
---|
| 19 | + | else [IntegerEntry((item + "_counter"), (getIntegerValue(this, (item + "_counter")) + 1))] |
---|
24 | 20 | | } |
---|
25 | 21 | | } |
---|
26 | 22 | | |
---|
27 | 23 | | |
---|
28 | 24 | | |
---|
29 | 25 | | @Callable(i) |
---|
30 | 26 | | func addItem (title,price,data) = { |
---|
31 | 27 | | let supplierAddress = toBase58String(i.caller.bytes) |
---|
32 | 28 | | let key = ((("item_" + supplierAddress) + "_") + title) |
---|
33 | 29 | | if ((0 >= price)) |
---|
34 | 30 | | then throw("Price cannot be lower than 0") |
---|
35 | 31 | | else if (isDefined(getString(this, key))) |
---|
36 | 32 | | then throw("Item exists") |
---|
37 | | - | else [StringEntry((key + "_supplier"), supplierAddress), IntegerEntry((key + "_price"), price), StringEntry((key + "_data"), data)] |
---|
| 33 | + | else [StringEntry((key + "_supplier"), supplierAddress), IntegerEntry((key + "_price"), price), StringEntry((key + "_data"), data), IntegerEntry((key + "_counter"), 0)] |
---|
38 | 34 | | } |
---|
39 | 35 | | |
---|
40 | 36 | | |
---|
41 | 37 | | @Verifier(tx) |
---|
42 | 38 | | func verify () = true |
---|
43 | 39 | | |
---|