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/EchOaJzhclRFzOZsCtGy7ySpoi0epc7fB20UHAAAAAwAAAAFiAQAAAAhwdXJjaGFzZQAAAAEAAAABYwQAAAABZAkAAZEAAAACCAUAAAABYgAAAAhwYXltZW50cwAAAAAAAAAAAAMJAQAAAAlpc0RlZmluZWQAAAABBQAAAAFjAwkBAAAACWlzRGVmaW5lZAAAAAEIBQAAAAFkAAAAB2Fzc2V0SWQJAAACAAAAAQIAAAAYT25seSBzaG91bGQgcGF5IGluIHdhdmVzBAAAAAFlCQACWAAAAAEICAUAAAABYgAAAAZjYWxsZXIAAAAFYnl0ZXMEAAAAAWYEAAAAAWcJAAQaAAAAAgU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yRW50cnkAAAACAgAAABNpdGVtX0JfY291cG9uX3ByaWNlAAAAAAACYloABQAAAANuaWwJAAACAAAAAQIAAAAZT25seSBvd25lciBjYW4gc2V0IHByaWNlcwAAAAFiAQAAAAtkZWxldGVFbnRyeQAAAAEAAAABaQMJAAAAAAAAAggFAAAAAWIAAAAPY2FsbGVyUHVibGljS2V5BQAAAAFhCQAETAAAAAIJAQAAAAtEZWxldGVFbnRyeQAAAAEFAAAAAWkFAAAAA25pbAkAAAIAAAABAgAAAB1Pbmx5IG93bmVyIGNhbiBkZWxldGUgZW50cmllcwAAAAEAAAABagEAAAABawAAAAAJAAH0AAAAAwgFAAAAAWoAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAFqAAAABnByb29mcwAAAAAAAAAAAAgFAAAAAWoAAAAPc2VuZGVyUHVibGljS2V5y6WUgA==", "height": 1873466, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 73GEufqkgET8UiCV3ih7eny1za32Q6iZbVZNve4yKe5T Next: DFYHaEJBitYpWA5xzEsX8CanzEACaw2t63Xp1fMLCBtg Diff:
OldNewDifferences
44 let accountPubKey = base58'HxF3FdYr3sD3ju9Y1wL4d5kmRtKJGhgSSYQkCyo78xGn'
55
66 @Callable(i)
7-func purchase () = {
7+func purchase (name) = {
88 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")
2529 }
2630
2731
2832
2933 @Callable(i)
3034 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)]
3236 else throw("Only owner can set prices")
3337
3438
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let accountPubKey = base58'HxF3FdYr3sD3ju9Y1wL4d5kmRtKJGhgSSYQkCyo78xGn'
55
66 @Callable(i)
7-func purchase () = {
7+func purchase (name) = {
88 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")
2529 }
2630
2731
2832
2933 @Callable(i)
3034 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)]
3236 else throw("Only owner can set prices")
3337
3438
3539
3640 @Callable(i)
3741 func deleteEntry (key) = if ((i.callerPublicKey == accountPubKey))
3842 then [DeleteEntry(key)]
3943 else throw("Only owner can delete entries")
4044
4145
4246 @Verifier(tx)
4347 func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
4448

github/deemru/w8io/169f3d6 
48.21 ms