tx · FBqnYqzcxC2mDudFec3gJsqkbRatDSPat3S3EjNoDiTz 3MpniGh4Ab64nzX6AXtoL5tzeC5EwSyHuaq: -0.01400000 Waves 2022.01.11 01:54 [1873466] smart account 3MpniGh4Ab64nzX6AXtoL5tzeC5EwSyHuaq > SELF 0.00000000 Waves
{ "type": 13, "id": "FBqnYqzcxC2mDudFec3gJsqkbRatDSPat3S3EjNoDiTz", "fee": 1400000, "feeAssetId": null, "timestamp": 1641855266040, "version": 2, "chainId": 84, "sender": "3MpniGh4Ab64nzX6AXtoL5tzeC5EwSyHuaq", "senderPublicKey": "HxF3FdYr3sD3ju9Y1wL4d5kmRtKJGhgSSYQkCyo78xGn", "proofs": [ "2yp7TKzwCESFLG5aKcRgBZnYBfZwziLYkJE3P9Y4s29Lwhg1kjh8wZJwVPD4swg3yzBoEQA18qWkRCxYf6SVs9b" ], "script": "base64:AAIFAAAAAAAAAJgIAhIDCgEIEgASAwoBCBoSCgFhEg1hY2NvdW50UHViS2V5GgYKAWISAWkaCQoBYxIEbmFtZRoMCgFkEgdwYXltZW50GhEKAWUSDGN1c3RvbWVyQWRkchoKCgFmEgVwcmljZRoMCgFnEgckbWF0Y2gwGgYKAWgSAXQaCAoBaRIDa2V5GgcKAWoSAnR4GgsKAWsSBnZlcmlmeQAAAAEAAAAAAWEBAAAAIPvhzx/EchOaJzhclRFzOZsCtGy7ySpoi0epc7fB20UHAAAAAwAAAAFiAQAAAAhwdXJjaGFzZQAAAAEAAAABYwQAAAABZAkAAZEAAAACCAUAAAABYgAAAAhwYXltZW50cwAAAAAAAAAAAAMJAQAAAAlpc0RlZmluZWQAAAABBQAAAAFjAwkBAAAACWlzRGVmaW5lZAAAAAEIBQAAAAFkAAAAB2Fzc2V0SWQJAAACAAAAAQIAAAAYT25seSBzaG91bGQgcGF5IGluIHdhdmVzBAAAAAFlCQACWAAAAAEICAUAAAABYgAAAAZjYWxsZXIAAAAFYnl0ZXMEAAAAAWYEAAAAAWcJAAQaAAAAAgUA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RW50cnkAAAACAgAAABNpdGVtX0JfY291cG9uX3ByaWNlAAAAAAACYloABQAAAANuaWwJAAACAAAAAQIAAAAZT25seSBvd25lciBjYW4gc2V0IHByaWNlcwAAAAFiAQAAAAtkZWxldGVFbnRyeQAAAAEAAAABaQMJAAAAAAAAAggFAAAAAWIAAAAPY2FsbGVyUHVibGljS2V5BQAAAAFhCQAETAAAAAIJAQAAAAtEZWxldGVFbnRyeQAAAAEFAAAAAWkFAAAAA25pbAkAAAIAAAABAgAAAB1Pbmx5IG93bmVyIGNhbiBkZWxldGUgZW50cmllcwAAAAEAAAABagEAAAABawAAAAAJAAH0AAAAAwgFAAAAAWoAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAFqAAAABnByb29mcwAAAAAAAAAAAAgFAAAAAWoAAAAPc2VuZGVyUHVibGljS2V5y6WUgA==", "height": 1873466, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 73GEufqkgET8UiCV3ih7eny1za32Q6iZbVZNve4yKe5T Next: DFYHaEJBitYpWA5xzEsX8CanzEACaw2t63Xp1fMLCBtg Diff:
Old | New | Differences | |
---|---|---|---|
4 | 4 | let accountPubKey = base58'HxF3FdYr3sD3ju9Y1wL4d5kmRtKJGhgSSYQkCyo78xGn' | |
5 | 5 | ||
6 | 6 | @Callable(i) | |
7 | - | func purchase () = { | |
7 | + | func purchase (name) = { | |
8 | 8 | let payment = i.payments[0] | |
9 | - | if (isDefined(payment.assetId)) | |
10 | - | then throw("Only should pay in waves") | |
11 | - | else { | |
12 | - | let customerAddr = toBase58String(i.caller.bytes) | |
13 | - | let price = match getInteger(this, "item_A_coupon_price") { | |
14 | - | case t: Int => | |
15 | - | t | |
16 | - | case _ => | |
17 | - | 0 | |
18 | - | } | |
19 | - | if ((payment.amount > price)) | |
20 | - | then throw(("payment cant be higher than price" + toString(price))) | |
21 | - | else if ((price > payment.amount)) | |
22 | - | then throw(("payment cant be less than price: " + toString(price))) | |
23 | - | else [StringEntry(("status:purchase_item_A_customer_" + customerAddr), "confirmed"), IntegerEntry(("price:purchase_item_A_customer_" + customerAddr), price)] | |
24 | - | } | |
9 | + | if (isDefined(name)) | |
10 | + | then if (isDefined(payment.assetId)) | |
11 | + | then throw("Only should pay in waves") | |
12 | + | else { | |
13 | + | let customerAddr = toBase58String(i.caller.bytes) | |
14 | + | let price = match getInteger(this, (("item_" + name) + "_coupon_price")) { | |
15 | + | case t: Int => | |
16 | + | t | |
17 | + | case _ => | |
18 | + | 0 | |
19 | + | } | |
20 | + | if ((price != 0)) | |
21 | + | then if ((payment.amount > price)) | |
22 | + | then throw(("payment cant be higher than price" + toString(price))) | |
23 | + | else if ((price > payment.amount)) | |
24 | + | then throw(("payment cant be less than price: " + toString(price))) | |
25 | + | else [StringEntry(((("status:purchase_item_" + name) + "_customer_") + customerAddr), "confirmed"), IntegerEntry(((("price:purchase_item_" + name) + "_customer_") + customerAddr), price)] | |
26 | + | else throw("Please enter valid coupon name: A or B") | |
27 | + | } | |
28 | + | else throw("Coupon name should be present") | |
25 | 29 | } | |
26 | 30 | ||
27 | 31 | ||
28 | 32 | ||
29 | 33 | @Callable(i) | |
30 | 34 | func setPrices () = if ((i.callerPublicKey == accountPubKey)) | |
31 | - | then [IntegerEntry("item_A_coupon_price", 30000000)] | |
35 | + | then [IntegerEntry("item_A_coupon_price", 30000000), IntegerEntry("item_B_coupon_price", 40000000)] | |
32 | 36 | else throw("Only owner can set prices") | |
33 | 37 | ||
34 | 38 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let accountPubKey = base58'HxF3FdYr3sD3ju9Y1wL4d5kmRtKJGhgSSYQkCyo78xGn' | |
5 | 5 | ||
6 | 6 | @Callable(i) | |
7 | - | func purchase () = { | |
7 | + | func purchase (name) = { | |
8 | 8 | let payment = i.payments[0] | |
9 | - | if (isDefined(payment.assetId)) | |
10 | - | then throw("Only should pay in waves") | |
11 | - | else { | |
12 | - | let customerAddr = toBase58String(i.caller.bytes) | |
13 | - | let price = match getInteger(this, "item_A_coupon_price") { | |
14 | - | case t: Int => | |
15 | - | t | |
16 | - | case _ => | |
17 | - | 0 | |
18 | - | } | |
19 | - | if ((payment.amount > price)) | |
20 | - | then throw(("payment cant be higher than price" + toString(price))) | |
21 | - | else if ((price > payment.amount)) | |
22 | - | then throw(("payment cant be less than price: " + toString(price))) | |
23 | - | else [StringEntry(("status:purchase_item_A_customer_" + customerAddr), "confirmed"), IntegerEntry(("price:purchase_item_A_customer_" + customerAddr), price)] | |
24 | - | } | |
9 | + | if (isDefined(name)) | |
10 | + | then if (isDefined(payment.assetId)) | |
11 | + | then throw("Only should pay in waves") | |
12 | + | else { | |
13 | + | let customerAddr = toBase58String(i.caller.bytes) | |
14 | + | let price = match getInteger(this, (("item_" + name) + "_coupon_price")) { | |
15 | + | case t: Int => | |
16 | + | t | |
17 | + | case _ => | |
18 | + | 0 | |
19 | + | } | |
20 | + | if ((price != 0)) | |
21 | + | then if ((payment.amount > price)) | |
22 | + | then throw(("payment cant be higher than price" + toString(price))) | |
23 | + | else if ((price > payment.amount)) | |
24 | + | then throw(("payment cant be less than price: " + toString(price))) | |
25 | + | else [StringEntry(((("status:purchase_item_" + name) + "_customer_") + customerAddr), "confirmed"), IntegerEntry(((("price:purchase_item_" + name) + "_customer_") + customerAddr), price)] | |
26 | + | else throw("Please enter valid coupon name: A or B") | |
27 | + | } | |
28 | + | else throw("Coupon name should be present") | |
25 | 29 | } | |
26 | 30 | ||
27 | 31 | ||
28 | 32 | ||
29 | 33 | @Callable(i) | |
30 | 34 | func setPrices () = if ((i.callerPublicKey == accountPubKey)) | |
31 | - | then [IntegerEntry("item_A_coupon_price", 30000000)] | |
35 | + | then [IntegerEntry("item_A_coupon_price", 30000000), IntegerEntry("item_B_coupon_price", 40000000)] | |
32 | 36 | else throw("Only owner can set prices") | |
33 | 37 | ||
34 | 38 | ||
35 | 39 | ||
36 | 40 | @Callable(i) | |
37 | 41 | func deleteEntry (key) = if ((i.callerPublicKey == accountPubKey)) | |
38 | 42 | then [DeleteEntry(key)] | |
39 | 43 | else throw("Only owner can delete entries") | |
40 | 44 | ||
41 | 45 | ||
42 | 46 | @Verifier(tx) | |
43 | 47 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
44 | 48 |
github/deemru/w8io/169f3d6 48.21 ms ◑