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:AAIEAAAAAAAAAA4IAhIDCgEIEgUKAwgBCAAAAAAAAAACAAAAAWkBAAAACHB1cmNoYXNlAAAAAQAAAARpdGVtBAAAAAdwYXltZW50CQEAAAAFdmFsdWUAAAABCQABkQAAAAIIBQAAAAFpAAAACHBheW1lbnRzAAAAAAAAAAAAAwkBAAAACWlzRGVmaW5lZAAAAAEIBQAAAAdwYXltZW50AAAAB2Fzc2V0SWQJAAACAAAAAQIAAAAKV2F2ZXMgb25seQQAAAALdXNlckFkZHJlc3MJAAJYAAAAAQgIBQAAAAFpAAAABmNhbGxlcgAAAAVieXRlcwQAAAAFcHJpY2UJAQAAABFAZXh0ck5hdGl2ZSgxMDUwKQAAAAIFAAAABHRoaXMJAAEsAAAAAgUAAAAEaXRlbQIAAAAGX3ByaWNlBAAAAAhzdXBwbGllcgkBAAAAEUBleHRyTmF0aXZlKDEwNTMpAAAAAgUAAAAEdGhpcwkAASwAAAACBQAAAARpdGVtAgAAAAlfc3VwcGxpZXIDCQAAZgAAAAIFAAAABXByaWNlCAUAAAAHcGF5bWVudAAAAAZhbW91bnQJAAACAAAAAQIA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AUAAAADbmlsAAAAAQAAAAJ0eAEAAAAGdmVyaWZ5AAAAAAZyu/uJ", "height": 1270858, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: EH3rjfx3jQY3oymHJnWF263qfCuqGB6a9BsYjwNEikZv Next: 4ppnnPcbAokg66apjxWC9sX6gGmFbkGz9CShCiExuNu5 Diff:
OldNewDifferences
44
55
66 @Callable(i)
7-func purchase (itemName) = {
7+func purchase (item) = {
88 let payment = value(i.payments[0])
99 if (isDefined(payment.assetId))
10- then throw("Only Waves are accepted")
10+ then throw("Waves only")
1111 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"))
1915 if ((price > payment.amount))
20- then throw("Purchase amount is too low")
16+ then throw("Too low")
2117 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))]
2420 }
2521 }
2622
3430 then throw("Price cannot be lower than 0")
3531 else if (isDefined(getString(this, key)))
3632 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)]
3834 }
3935
4036
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 4 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44
55
66 @Callable(i)
7-func purchase (itemName) = {
7+func purchase (item) = {
88 let payment = value(i.payments[0])
99 if (isDefined(payment.assetId))
10- then throw("Only Waves are accepted")
10+ then throw("Waves only")
1111 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"))
1915 if ((price > payment.amount))
20- then throw("Purchase amount is too low")
16+ then throw("Too low")
2117 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))]
2420 }
2521 }
2622
2723
2824
2925 @Callable(i)
3026 func addItem (title,price,data) = {
3127 let supplierAddress = toBase58String(i.caller.bytes)
3228 let key = ((("item_" + supplierAddress) + "_") + title)
3329 if ((0 >= price))
3430 then throw("Price cannot be lower than 0")
3531 else if (isDefined(getString(this, key)))
3632 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)]
3834 }
3935
4036
4137 @Verifier(tx)
4238 func verify () = true
4339

github/deemru/w8io/026f985 
24.58 ms