tx · BTT2t6sVT8BKhZmi7qZUTWYJvyUk3kqBvqyXu53uxLjD 3MxRqURevjNgwbz8kneeUwGPzCtszagdsx4: -0.01400000 Waves 2020.11.20 11:43 [1273464] smart account 3MxRqURevjNgwbz8kneeUwGPzCtszagdsx4 > SELF 0.00000000 Waves
{ "type": 13, "id": "BTT2t6sVT8BKhZmi7qZUTWYJvyUk3kqBvqyXu53uxLjD", "fee": 1400000, "feeAssetId": null, "timestamp": 1605861809192, "version": 2, "chainId": 84, "sender": "3MxRqURevjNgwbz8kneeUwGPzCtszagdsx4", "senderPublicKey": "2qjcWuL7QitmuhkSTM7CnNxurCYXuqJ9ubswLBGmXfDv", "proofs": [ "5khP8Loqxau9QCbfw5MHrDBrYMzu4oLqd8vhRYPKpGssKaonaPC6qCG2E81feZAqLQHzcJ7WKSU3LcXB267rduTk" ], "script": "base64:AAIEAAAAAAAAAAcIAhIDCgEIAAAAAwAAAAARYWNjb3VudDFQdWJsaWNLZXkBAAAAIPeNeDDs4TWVhR1bzOk94lFsHOraL9B/FRj0XfVMj0hOAAAAABFhY2NvdW50MlB1YmxpY0tleQEAAAAgG1e/aEwKrtMkcq9WyiLLAHtKPJgLd/oAoUXcKuUDIhUAAAAADm90aGVyUHVibGljS2V5AQAAACDnblGJprjxGAm9jEz8V5M0TOEG6bhNvbMQquBNrx0dWgAAAAEAAAABaQEAAAAIcHVyY2hhc2UAAAABAAAABmNvdXBvbgQAAAADcG10CQEAAAAFdmFsdWUAAAABCAUAAAABaQAAAAhwYXltZW50cwMJAQAAAAlpc0RlZmluZWQAAAABCAkAAZEAAAACBQAAAANwbXQAAAAAAAAAAAAAAAAHYXNzZXRJZAkAAAIAAAABAgAAAAhvbmx5IHd3cwQAAAAPY3VzdG9tZXJBZGRyZXNzCQACWAAAAAEICAUAAAABaQAAAAZjYWxsZXIAAAAFYnl0ZXMEAAAABXByaWNlBAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMJAAEsAAAAAgUAAAAGY291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FAAAAAnR4AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAABRTZXRTY3JpcHRUcmFuc2FjdGlvbgQAAAABZAUAAAAHJG1hdGNoMAYDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAD0RhdGFUcmFuc2FjdGlvbgQAAAABZAUAAAAHJG1hdGNoMAYDAwUAAAAQYWNjb3VudDFhY2NvdW50MgYFAAAADWFjY291bnQxb3RoZXIGBQAAAA1hY2NvdW50Mm90aGVy8g6peg==", "height": 1273464, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: AvT16XRz5LeDDDYmFhfPZnVEeeoA3VgVrB8wgrF8BCW1 Next: none Diff:
Old | New | Differences | |
---|---|---|---|
8 | 8 | let otherPublicKey = base58'GaQkBG6yLLAarb8wvPrEKnQhFqWomD2ZGT1T4vVx24qw' | |
9 | 9 | ||
10 | 10 | @Callable(i) | |
11 | - | func purchase () = { | |
11 | + | func purchase (coupon) = { | |
12 | 12 | let pmt = value(i.payments) | |
13 | 13 | if (isDefined(pmt[0].assetId)) | |
14 | 14 | then throw("only wws") | |
15 | 15 | else { | |
16 | 16 | let customerAddress = toBase58String(i.caller.bytes) | |
17 | - | let price = match getInteger(this, " | |
17 | + | let price = match getInteger(this, (coupon + "_coupon_price")) { | |
18 | 18 | case a: Int => | |
19 | 19 | a | |
20 | 20 | case _ => | |
21 | 21 | 0 | |
22 | 22 | } | |
23 | - | if ((price > pmt[0].amount)) | |
24 | - | then throw("moar moeny") | |
25 | - | else if ((pmt[0].amount > price)) | |
26 | - | then throw(toString(price)) | |
27 | - | else if ((size(pmt) > 1)) | |
28 | - | then throw("single item only") | |
29 | - | else [StringEntry(("status:purchase_item_A_customer_" + customerAddress), "confirmed"), IntegerEntry(("price:purchase_item_A_customer_" + customerAddress), price)] | |
23 | + | if ((price == 0)) | |
24 | + | then throw("coupon not found") | |
25 | + | else if ((price > pmt[0].amount)) | |
26 | + | then throw("moar moeny") | |
27 | + | else if ((pmt[0].amount > price)) | |
28 | + | then throw(toString(price)) | |
29 | + | else if ((size(pmt) > 1)) | |
30 | + | then throw("single item only") | |
31 | + | else [StringEntry(((("status:purchase_" + coupon) + "_customer_") + customerAddress), "confirmed"), IntegerEntry(((("price:purchase_" + coupon) + "_customer_") + customerAddress), price)] | |
30 | 32 | } | |
31 | 33 | } | |
32 | 34 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 4 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let account1PublicKey = base58'HfLpRhXtnuCabRyNT6z7soaXcbUpwLUhjyBCVQ4szwzd' | |
5 | 5 | ||
6 | 6 | let account2PublicKey = base58'2qjcWuL7QitmuhkSTM7CnNxurCYXuqJ9ubswLBGmXfDv' | |
7 | 7 | ||
8 | 8 | let otherPublicKey = base58'GaQkBG6yLLAarb8wvPrEKnQhFqWomD2ZGT1T4vVx24qw' | |
9 | 9 | ||
10 | 10 | @Callable(i) | |
11 | - | func purchase () = { | |
11 | + | func purchase (coupon) = { | |
12 | 12 | let pmt = value(i.payments) | |
13 | 13 | if (isDefined(pmt[0].assetId)) | |
14 | 14 | then throw("only wws") | |
15 | 15 | else { | |
16 | 16 | let customerAddress = toBase58String(i.caller.bytes) | |
17 | - | let price = match getInteger(this, " | |
17 | + | let price = match getInteger(this, (coupon + "_coupon_price")) { | |
18 | 18 | case a: Int => | |
19 | 19 | a | |
20 | 20 | case _ => | |
21 | 21 | 0 | |
22 | 22 | } | |
23 | - | if ((price > pmt[0].amount)) | |
24 | - | then throw("moar moeny") | |
25 | - | else if ((pmt[0].amount > price)) | |
26 | - | then throw(toString(price)) | |
27 | - | else if ((size(pmt) > 1)) | |
28 | - | then throw("single item only") | |
29 | - | else [StringEntry(("status:purchase_item_A_customer_" + customerAddress), "confirmed"), IntegerEntry(("price:purchase_item_A_customer_" + customerAddress), price)] | |
23 | + | if ((price == 0)) | |
24 | + | then throw("coupon not found") | |
25 | + | else if ((price > pmt[0].amount)) | |
26 | + | then throw("moar moeny") | |
27 | + | else if ((pmt[0].amount > price)) | |
28 | + | then throw(toString(price)) | |
29 | + | else if ((size(pmt) > 1)) | |
30 | + | then throw("single item only") | |
31 | + | else [StringEntry(((("status:purchase_" + coupon) + "_customer_") + customerAddress), "confirmed"), IntegerEntry(((("price:purchase_" + coupon) + "_customer_") + customerAddress), price)] | |
30 | 32 | } | |
31 | 33 | } | |
32 | 34 | ||
33 | 35 | ||
34 | 36 | @Verifier(tx) | |
35 | 37 | func verify () = { | |
36 | 38 | let account1 = if (if (sigVerify(tx.bodyBytes, tx.proofs[0], account1PublicKey)) | |
37 | 39 | then true | |
38 | 40 | else sigVerify(tx.bodyBytes, tx.proofs[1], account1PublicKey)) | |
39 | 41 | then true | |
40 | 42 | else sigVerify(tx.bodyBytes, tx.proofs[2], account1PublicKey) | |
41 | 43 | let account2 = if (if (sigVerify(tx.bodyBytes, tx.proofs[0], account2PublicKey)) | |
42 | 44 | then true | |
43 | 45 | else sigVerify(tx.bodyBytes, tx.proofs[1], account2PublicKey)) | |
44 | 46 | then true | |
45 | 47 | else sigVerify(tx.bodyBytes, tx.proofs[2], account2PublicKey) | |
46 | 48 | let other = if (if (sigVerify(tx.bodyBytes, tx.proofs[0], otherPublicKey)) | |
47 | 49 | then true | |
48 | 50 | else sigVerify(tx.bodyBytes, tx.proofs[1], otherPublicKey)) | |
49 | 51 | then true | |
50 | 52 | else sigVerify(tx.bodyBytes, tx.proofs[2], otherPublicKey) | |
51 | 53 | let account1account2 = if (account1) | |
52 | 54 | then account2 | |
53 | 55 | else false | |
54 | 56 | let account1other = if (account1) | |
55 | 57 | then other | |
56 | 58 | else false | |
57 | 59 | let account2other = if (other) | |
58 | 60 | then account2 | |
59 | 61 | else false | |
60 | 62 | match tx { | |
61 | 63 | case d: SetScriptTransaction => | |
62 | 64 | true | |
63 | 65 | case d: DataTransaction => | |
64 | 66 | true | |
65 | 67 | case _ => | |
66 | 68 | if (if (account1account2) | |
67 | 69 | then true | |
68 | 70 | else account1other) | |
69 | 71 | then true | |
70 | 72 | else account2other | |
71 | 73 | } | |
72 | 74 | } | |
73 | 75 |
github/deemru/w8io/169f3d6 45.38 ms ◑