tx · b9niW7Wp4DXFaiyp3ZKavC26bKpupahBrbcUfu3TdVh 3NAj7owPjfmLoE3odgXC6cXfB1QzEhnpBtt: -0.01400000 Waves 2020.11.18 16:11 [1270833] smart account 3NAj7owPjfmLoE3odgXC6cXfB1QzEhnpBtt > SELF 0.00000000 Waves
{ "type": 13, "id": "b9niW7Wp4DXFaiyp3ZKavC26bKpupahBrbcUfu3TdVh", "fee": 1400000, "feeAssetId": null, "timestamp": 1605705163035, "version": 2, "chainId": 84, "sender": "3NAj7owPjfmLoE3odgXC6cXfB1QzEhnpBtt", "senderPublicKey": "iRqJrgq4rS2ndNGFJoZtKcoTfskkxr3zfTesPWqtKzp", "proofs": [ "2to6Wfvw1Hdxs3Bksb1JJbRCyHFUo8bhx5mGuo3riGfZ3GqbgcM8si6MpKrHHhiEKePEkhB5FXFmsTXQ5So8Xf7o" ], "script": "base64:AAIEAAAAAAAAAA4IAhIDCgEIEgUKAwgBCAAAAAAAAAACAAAAAWkBAAAACHB1cmNoYXNlAAAAAQAAAAhpdGVtTmFtZQQAAAAHcGF5bWVudAkBAAAABXZhbHVlAAAAAQkAAZEAAAACCAUAAAABaQAAAAhwYXltZW50cwAAAAAAAAAAAAMJAQAAAAlpc0RlZmluZWQAAAABCAUAAAAHcGF5bWVudAAAAAdhc3NldElkCQAAAgAAAAECAAAAF09ubHkgV2F2ZXMgYXJlIGFjY2VwdGVkBAAAAA9jdXN0b21lckFkZHJlc3MJAAJYAAAAAQgIBQAAAAFpAAAABmNhbGxlcgAAAAVieXRlcwQAAAAFcHJpY2UEAAAAByRtYXRjaDAJAAQaAAAAAgUAAAAEdGhpcwkAASwAAAACBQAAAAhpdGVtTmFtZQIAAAANX2NvdXBvbl9wcmljZQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFhBQAAAAckbWF0Y2gwCQAAaAAAAAIFAAAAAWEAAAAAAAX14QAJAAACAAAAAQIAAAAOSXRlbSBub3QgZm91bmQDCQAAZgAAAAIFA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AAxJbnRlZ2VyRW50cnkAAAACCQABLAAAAAIFAAAAA2tleQIAAAAGX3ByaWNlBQAAAAVwcmljZQkABEwAAAACCQEAAAALU3RyaW5nRW50cnkAAAACCQABLAAAAAIFAAAAA2tleQIAAAAFX2RhdGEFAAAABGRhdGEFAAAAA25pbAAAAAEAAAACdHgBAAAABnZlcmlmeQAAAAAGiniFNA==", "height": 1270833, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: CnaDhKVuCwogAt2eriKp8rAzajAkbeLX6Fsu4yXRjAoX Next: EH3rjfx3jQY3oymHJnWF263qfCuqGB6a9BsYjwNEikZv Diff:
Old | New | Differences | |
---|---|---|---|
32 | 32 | let key = ("item_" + toBase58String(sha256(toBytes((supplierAddress + title))))) | |
33 | 33 | if ((0 >= price)) | |
34 | 34 | then throw("Price cannot be lower than 0") | |
35 | - | else if ((getStringValue(this, key) | |
35 | + | else if (isDefined(getStringValue(this, key))) | |
36 | 36 | then throw("Item exists") | |
37 | 37 | else [StringEntry((key + "_supplier"), supplierAddress), IntegerEntry((key + "_price"), price), StringEntry((key + "_data"), data)] | |
38 | 38 | } |
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 | 7 | func purchase (itemName) = { | |
8 | 8 | let payment = value(i.payments[0]) | |
9 | 9 | if (isDefined(payment.assetId)) | |
10 | 10 | then throw("Only Waves are accepted") | |
11 | 11 | else { | |
12 | 12 | let customerAddress = toBase58String(i.caller.bytes) | |
13 | 13 | let price = match getInteger(this, (itemName + "_coupon_price")) { | |
14 | 14 | case a: Int => | |
15 | 15 | (a * 100000000) | |
16 | 16 | case _ => | |
17 | 17 | throw("Item not found") | |
18 | 18 | } | |
19 | 19 | if ((price > payment.amount)) | |
20 | 20 | then throw("Purchase amount is too low") | |
21 | 21 | else if ((payment.amount > price)) | |
22 | 22 | then throw("Purchase amount is too high") | |
23 | 23 | else [StringEntry(("status:purchase_item_A_customer" + customerAddress), "true"), IntegerEntry(("price:purchase_item_A_customer" + customerAddress), price)] | |
24 | 24 | } | |
25 | 25 | } | |
26 | 26 | ||
27 | 27 | ||
28 | 28 | ||
29 | 29 | @Callable(i) | |
30 | 30 | func addItem (title,price,data) = { | |
31 | 31 | let supplierAddress = toBase58String(i.caller.bytes) | |
32 | 32 | let key = ("item_" + toBase58String(sha256(toBytes((supplierAddress + title))))) | |
33 | 33 | if ((0 >= price)) | |
34 | 34 | then throw("Price cannot be lower than 0") | |
35 | - | else if ((getStringValue(this, key) | |
35 | + | else if (isDefined(getStringValue(this, key))) | |
36 | 36 | then throw("Item exists") | |
37 | 37 | else [StringEntry((key + "_supplier"), supplierAddress), IntegerEntry((key + "_price"), price), StringEntry((key + "_data"), data)] | |
38 | 38 | } | |
39 | 39 | ||
40 | 40 | ||
41 | 41 | @Verifier(tx) | |
42 | 42 | func verify () = true | |
43 | 43 |
github/deemru/w8io/026f985 35.17 ms ◑