tx · 7juMp9cxW3aQCfDpbr6GQUTuCUJ8wmLJRu8PZSHX7aA1 3MsqcsQSU3FeyxcMjrRQHcM8pTGrHu8yyWX: -0.01600000 Waves 2019.09.07 23:29 [666154] smart account 3MsqcsQSU3FeyxcMjrRQHcM8pTGrHu8yyWX > SELF 0.00000000 Waves
{ "type": 13, "id": "7juMp9cxW3aQCfDpbr6GQUTuCUJ8wmLJRu8PZSHX7aA1", "fee": 1600000, "feeAssetId": null, "timestamp": 1567887961405, "version": 1, "sender": "3MsqcsQSU3FeyxcMjrRQHcM8pTGrHu8yyWX", "senderPublicKey": "D1oc84fv4treBFDLvPS9vQdrs7A9HwTHxaeK9C7nHRTH", "proofs": [ "3VPEFM2qmAvc6fDTNUK9MToLzLb5VHSvksBkczFKwVCv1dQsnTWXuoKc1r9j6uAtzkx1kim68nzYvsxy6RMYDb58" ], "script": "base64:AAIDAAAAAAAAAAAAAAAAAAAAAgAAAAFpAQAAAAtjcmVhdGVPcmRlcgAAAAEAAAAFcHJpY2UEAAAAA3BtdAkBAAAAB2V4dHJhY3QAAAABCAUAAAABaQAAAAdwYXltZW50AwkBAAAAASEAAAABCQEAAAAJaXNEZWZpbmVkAAAAAQgFAAAAA3BtdAAAAAdhc3NldElkCQAAAgAAAAECAAAAIllvdSBuZWVkIHRvIHVzZSB0b2tlbklkLCBub3Qgd2F2ZXMEAAAACmN1cnJlbnRLZXkJAAJYAAAAAQgIBQAAAAFpAAAABmNhbGxlcgAAAAVieXRlcwQAAAAHYXNzZXRJZAkAAlgAAAABCQEAAAAHZXh0cmFjdAAAAAEIBQAAAANwbXQAAAAHYXNzZXRJZAQAAAAHdW5pcUtleQkAASwAAAACCQABLAAAAAIJAAEsAAAAAgkAASwAAAACBQAAAApjdXJyZW50S2V5AgAAAAFfBQAAAAdhc3NldElkAgAAAAFfCQABpAAAAAEFAAAABmhlaWdodAkBAAAACFdyaXRlU2V0AAAAAQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkAASw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cmljZQkBAAAAC1RyYW5zZmVyU2V0AAAAAQkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADCAUAAAABaQAAAAZjYWxsZXIAAAAAAAAAAAEJAAGbAAAAAQUAAAAHYXNzZXRJZAUAAAADbmlsAAAAAOpQ1D0=", "chainId": 84, "height": 666154, "spentComplexity": 0 } View: original | compacted Prev: CK9rYNCQUkEfHUZnscJPpS58v6NGepGfGLTgmKDrUxSz Next: Gz1tDQwdrEYM9WS9UzzPSGGQddExef6j8WuD3kiogQWB Diff:
Old | New | Differences | |
---|---|---|---|
11 | 11 | else { | |
12 | 12 | let currentKey = toBase58String(i.caller.bytes) | |
13 | 13 | let assetId = toBase58String(extract(pmt.assetId)) | |
14 | - | WriteSet([DataEntry(((((("assetAmount_" + currentKey) + "_") + assetId) + "_") + toString(height)), pmt.amount), DataEntry(((((("assetPrice_" + currentKey) + "_") + assetId) + "_") + toString(height)), price)]) | |
14 | + | let uniqKey = ((((currentKey + "_") + assetId) + "_") + toString(height)) | |
15 | + | WriteSet([DataEntry(("assetAmount_" + uniqKey), pmt.amount), DataEntry(("assetPrice_" + uniqKey), price)]) | |
15 | 16 | } | |
17 | + | } | |
18 | + | ||
19 | + | ||
20 | + | ||
21 | + | @Callable(i) | |
22 | + | func buyTicket (uniqKey) = { | |
23 | + | let pmt = extract(i.payment) | |
24 | + | let assetId = extract(split(uniqKey, "_")[2]) | |
25 | + | let price = match getInteger(i.caller, ("assetPrice_" + uniqKey)) { | |
26 | + | case p: Int => | |
27 | + | p | |
28 | + | case _ => | |
29 | + | 0 | |
30 | + | } | |
31 | + | let currentAmount = match getInteger(i.caller, ("assetAmount_" + uniqKey)) { | |
32 | + | case a: Int => | |
33 | + | a | |
34 | + | case _ => | |
35 | + | 0 | |
36 | + | } | |
37 | + | if ((0 >= currentAmount)) | |
38 | + | then throw("Have not enough of tickets") | |
39 | + | else if (isDefined(pmt.assetId)) | |
40 | + | then throw("You need to use waves") | |
41 | + | else if ((pmt.amount != price)) | |
42 | + | then throw("Count of waves is not match price") | |
43 | + | else TransferSet([ScriptTransfer(i.caller, 1, toBytes(assetId))]) | |
16 | 44 | } | |
17 | 45 | ||
18 | 46 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | ||
5 | 5 | ||
6 | 6 | @Callable(i) | |
7 | 7 | func createOrder (price) = { | |
8 | 8 | let pmt = extract(i.payment) | |
9 | 9 | if (!(isDefined(pmt.assetId))) | |
10 | 10 | then throw("You need to use tokenId, not waves") | |
11 | 11 | else { | |
12 | 12 | let currentKey = toBase58String(i.caller.bytes) | |
13 | 13 | let assetId = toBase58String(extract(pmt.assetId)) | |
14 | - | WriteSet([DataEntry(((((("assetAmount_" + currentKey) + "_") + assetId) + "_") + toString(height)), pmt.amount), DataEntry(((((("assetPrice_" + currentKey) + "_") + assetId) + "_") + toString(height)), price)]) | |
14 | + | let uniqKey = ((((currentKey + "_") + assetId) + "_") + toString(height)) | |
15 | + | WriteSet([DataEntry(("assetAmount_" + uniqKey), pmt.amount), DataEntry(("assetPrice_" + uniqKey), price)]) | |
15 | 16 | } | |
17 | + | } | |
18 | + | ||
19 | + | ||
20 | + | ||
21 | + | @Callable(i) | |
22 | + | func buyTicket (uniqKey) = { | |
23 | + | let pmt = extract(i.payment) | |
24 | + | let assetId = extract(split(uniqKey, "_")[2]) | |
25 | + | let price = match getInteger(i.caller, ("assetPrice_" + uniqKey)) { | |
26 | + | case p: Int => | |
27 | + | p | |
28 | + | case _ => | |
29 | + | 0 | |
30 | + | } | |
31 | + | let currentAmount = match getInteger(i.caller, ("assetAmount_" + uniqKey)) { | |
32 | + | case a: Int => | |
33 | + | a | |
34 | + | case _ => | |
35 | + | 0 | |
36 | + | } | |
37 | + | if ((0 >= currentAmount)) | |
38 | + | then throw("Have not enough of tickets") | |
39 | + | else if (isDefined(pmt.assetId)) | |
40 | + | then throw("You need to use waves") | |
41 | + | else if ((pmt.amount != price)) | |
42 | + | then throw("Count of waves is not match price") | |
43 | + | else TransferSet([ScriptTransfer(i.caller, 1, toBytes(assetId))]) | |
16 | 44 | } | |
17 | 45 | ||
18 | 46 |
github/deemru/w8io/03bedc9 21.63 ms ◑![]()