tx · 3N4ffp7GmyG7iZNusRdnNB498uB2MFy7eKMxSwYY2PYW 3N7a7sTSKaE621QewSqQcL1mUbknJjnLkZc: -0.01000000 Waves 2021.10.21 23:28 [1756535] smart account 3N7a7sTSKaE621QewSqQcL1mUbknJjnLkZc > SELF 0.00000000 Waves
{ "type": 13, "id": "3N4ffp7GmyG7iZNusRdnNB498uB2MFy7eKMxSwYY2PYW", "fee": 1000000, "feeAssetId": null, "timestamp": 1634848130076, "version": 2, "chainId": 84, "sender": "3N7a7sTSKaE621QewSqQcL1mUbknJjnLkZc", "senderPublicKey": "6LrPmGtwuADhwHYcxBouLzwfSTGgucbwYG5Pja7LUrcd", "proofs": [ "3VcRRyrdREdq9T7KZBY9jZ4fXvLa9TSHiC5K1QVwnDHaJpDuHsA9HCQa4Bi7dKTBADwqAWuY4UQZ8McPQt6YNwLH" ], "script": "base64:AAIFAAAAAAAAABcIAhIECgIIGBIDCgEBEgMKAQESAwoBAQAAAA4AAAAACm9mZmVySWRLZXkCAAAADSRPRkZFUl9OVU1CRVIAAAAAB3Rlc3RLZXkCAAAABSRURVNUAAAAAA9vZmZlck9wZW5TdGF0dXMAAAAAAAAAAAEAAAAAE29mZmVyQ2FuY2VsZWRTdGF0dXMAAAAAAAAAAAIAAAAAE29mZmVyQWNjZXB0ZWRTdGF0dXMAAAAAAAAAAAMAAAAAE29mZmVyUmVqZWN0ZWRTdGF0dXMAAAAAAAAAAAQBAAAAEWdldE9mZmVyU3RhdHVzS2V5AAAAAQAAAAdvZmZlcklkCQABLAAAAAIJAAGkAAAAAQUAAAAHb2ZmZXJJZAIAAAAHX3N0YXR1cwEAAAAWZ2V0T2ZmZXJBZGRyZXNzRnJvbUtleQAAAAEAAAAHb2ZmZXJJZAkAASwAAAACCQABpAAAAAEFAAAAB29mZmVySWQCAAAABV9mcm9tAQAAABRnZXRPZmZlckFkZHJlc3NUb0tleQAAAAEAAAAHb2ZmZXJJZAkAASwAAAACCQABpAAAAAEFAAAAB29mZmVySWQ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lc3NUbwUAAAAJY2FsbGVyU3RyCQAAAgAAAAECAAAAHG9mZmVyIG11c3QgYmUgbWFkZSB0byBjYWxsZXIJAARMAAAAAgkBAAAADEludGVnZXJFbnRyeQAAAAIJAQAAABFnZXRPZmZlclN0YXR1c0tleQAAAAEFAAAAB29mZmVySWQFAAAAE29mZmVyQWNjZXB0ZWRTdGF0dXMFAAAAA25pbAAAAAFpAQAAAAtyZWplY3RPZmZlcgAAAAEAAAAHb2ZmZXJJZAQAAAALb2ZmZXJTdGF0dXMJAQAAAA10cnlHZXRJbnRlZ2VyAAAAAQkBAAAAEWdldE9mZmVyU3RhdHVzS2V5AAAAAQUAAAAHb2ZmZXJJZAMJAQAAAAIhPQAAAAIFAAAAC29mZmVyU3RhdHVzBQAAAA9vZmZlck9wZW5TdGF0dXMJAAACAAAAAQIAAAAZb2ZmZXIgc3RhdHVzIG11c3QgYmUgb3BlbgQAAAAJYWRkcmVzc1RvCQEAAAARQGV4dHJOYXRpdmUoMTA1MykAAAACBQAAAAR0aGlzCQEAAAAUZ2V0T2ZmZXJBZGRyZXNzVG9LZXkAAAABBQAAAAdvZmZlcklkBAAAAAljYWxsZXJTdHIJAAJYAAAAAQgIBQAAAAFpAAAABmNhbGxlcgAAAAVieXRlcwMJAQAAAAIhPQAAAAIFAAAACWFkZHJlc3NUbwUAAAAJY2FsbGVyU3RyCQAAAgAAAAECAAAAHG9mZmVyIG11c3QgYmUgbWFkZSB0byBjYWxsZXIJAARMAAAAAgkBAAAADEludGVnZXJFbnRyeQAAAAIJAQAAABFnZXRPZmZlclN0YXR1c0tleQAAAAEFAAAAB29mZmVySWQFAAAAE29mZmVyUmVqZWN0ZWRTdGF0dXMFAAAAA25pbAAAAADo8as0", "height": 1756535, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: A7Di3hxQ7VzmTaFLhFKBTLZ4t2k4taa7bg2VeXCStrBs Next: AshK3p7zNscKXJwKwy5AH9Zk25mqgcq55zf9ztdZvjnH Diff:
Old | New | Differences | |
---|---|---|---|
49 | 49 | func createOffer (toAddress,asset) = { | |
50 | 50 | let offerId = tryGetInteger(offerIdKey) | |
51 | 51 | let firstPayment = value(i.payments[0]) | |
52 | - | if (if (!(isDefined(firstPayment))) | |
53 | - | then !(isDefined(firstPayment.assetId)) | |
54 | - | else false) | |
52 | + | if (!(isDefined(firstPayment))) | |
55 | 53 | then throw("no payment") | |
56 | - | else [IntegerEntry(getOfferStatusKey(offerId), offerOpenStatus), StringEntry(getOfferAddressFromKey(offerId), toBase58String(i.caller.bytes)), StringEntry(getOfferAddressToKey(offerId), toAddress), StringEntry(getOfferOfferedAssetKey(offerId, 0), toBase58String( | |
54 | + | else [IntegerEntry(getOfferStatusKey(offerId), offerOpenStatus), StringEntry(getOfferAddressFromKey(offerId), toBase58String(i.caller.bytes)), StringEntry(getOfferAddressToKey(offerId), toAddress), StringEntry(getOfferOfferedAssetKey(offerId, 0), toBase58String(valueOrElse(firstPayment.assetId, toBytes("WAVES")))), IntegerEntry(getOfferOfferedAmountKey(offerId, 0), firstPayment.amount)] | |
57 | 55 | } | |
58 | 56 | ||
59 | 57 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let offerIdKey = "$OFFER_NUMBER" | |
5 | 5 | ||
6 | 6 | let testKey = "$TEST" | |
7 | 7 | ||
8 | 8 | let offerOpenStatus = 1 | |
9 | 9 | ||
10 | 10 | let offerCanceledStatus = 2 | |
11 | 11 | ||
12 | 12 | let offerAcceptedStatus = 3 | |
13 | 13 | ||
14 | 14 | let offerRejectedStatus = 4 | |
15 | 15 | ||
16 | 16 | func getOfferStatusKey (offerId) = (toString(offerId) + "_status") | |
17 | 17 | ||
18 | 18 | ||
19 | 19 | func getOfferAddressFromKey (offerId) = (toString(offerId) + "_from") | |
20 | 20 | ||
21 | 21 | ||
22 | 22 | func getOfferAddressToKey (offerId) = (toString(offerId) + "_to") | |
23 | 23 | ||
24 | 24 | ||
25 | 25 | func getOfferOfferedAssetKey (offerId,itemNumber) = ((toString(offerId) + toString(itemNumber)) + "_offered_asset_id") | |
26 | 26 | ||
27 | 27 | ||
28 | 28 | func getOfferOfferedAmountKey (offerId,itemNumber) = ((toString(offerId) + toString(itemNumber)) + "_offered_asset_amount") | |
29 | 29 | ||
30 | 30 | ||
31 | 31 | func getOfferAskedAssetKey (offerId,itemNumber) = ((toString(offerId) + toString(itemNumber)) + "_asked_asset_id") | |
32 | 32 | ||
33 | 33 | ||
34 | 34 | func getOfferAskedAmountKey (offerId,itemNumber) = ((toString(offerId) + toString(itemNumber)) + "_asked_asset_amount") | |
35 | 35 | ||
36 | 36 | ||
37 | 37 | func tryGetInteger (key) = { | |
38 | 38 | let val = match getInteger(this, key) { | |
39 | 39 | case b: Int => | |
40 | 40 | b | |
41 | 41 | case _ => | |
42 | 42 | 0 | |
43 | 43 | } | |
44 | 44 | val | |
45 | 45 | } | |
46 | 46 | ||
47 | 47 | ||
48 | 48 | @Callable(i) | |
49 | 49 | func createOffer (toAddress,asset) = { | |
50 | 50 | let offerId = tryGetInteger(offerIdKey) | |
51 | 51 | let firstPayment = value(i.payments[0]) | |
52 | - | if (if (!(isDefined(firstPayment))) | |
53 | - | then !(isDefined(firstPayment.assetId)) | |
54 | - | else false) | |
52 | + | if (!(isDefined(firstPayment))) | |
55 | 53 | then throw("no payment") | |
56 | - | else [IntegerEntry(getOfferStatusKey(offerId), offerOpenStatus), StringEntry(getOfferAddressFromKey(offerId), toBase58String(i.caller.bytes)), StringEntry(getOfferAddressToKey(offerId), toAddress), StringEntry(getOfferOfferedAssetKey(offerId, 0), toBase58String( | |
54 | + | else [IntegerEntry(getOfferStatusKey(offerId), offerOpenStatus), StringEntry(getOfferAddressFromKey(offerId), toBase58String(i.caller.bytes)), StringEntry(getOfferAddressToKey(offerId), toAddress), StringEntry(getOfferOfferedAssetKey(offerId, 0), toBase58String(valueOrElse(firstPayment.assetId, toBytes("WAVES")))), IntegerEntry(getOfferOfferedAmountKey(offerId, 0), firstPayment.amount)] | |
57 | 55 | } | |
58 | 56 | ||
59 | 57 | ||
60 | 58 | ||
61 | 59 | @Callable(i) | |
62 | 60 | func cancelOffer (offerId) = { | |
63 | 61 | let offerStatus = tryGetInteger(getOfferStatusKey(offerId)) | |
64 | 62 | if ((offerStatus != offerOpenStatus)) | |
65 | 63 | then throw("offer status must be open") | |
66 | 64 | else { | |
67 | 65 | let addressFrom = getStringValue(this, getOfferAddressFromKey(offerId)) | |
68 | 66 | let callerStr = toBase58String(i.caller.bytes) | |
69 | 67 | if ((addressFrom != callerStr)) | |
70 | 68 | then throw("offer must be made by caller") | |
71 | 69 | else [IntegerEntry(getOfferStatusKey(offerId), offerCanceledStatus)] | |
72 | 70 | } | |
73 | 71 | } | |
74 | 72 | ||
75 | 73 | ||
76 | 74 | ||
77 | 75 | @Callable(i) | |
78 | 76 | func acceptOffer (offerId) = { | |
79 | 77 | let offerStatus = tryGetInteger(getOfferStatusKey(offerId)) | |
80 | 78 | if ((offerStatus != offerOpenStatus)) | |
81 | 79 | then throw("offer status must be open") | |
82 | 80 | else { | |
83 | 81 | let addressTo = getStringValue(this, getOfferAddressToKey(offerId)) | |
84 | 82 | let callerStr = toBase58String(i.caller.bytes) | |
85 | 83 | if ((addressTo != callerStr)) | |
86 | 84 | then throw("offer must be made to caller") | |
87 | 85 | else [IntegerEntry(getOfferStatusKey(offerId), offerAcceptedStatus)] | |
88 | 86 | } | |
89 | 87 | } | |
90 | 88 | ||
91 | 89 | ||
92 | 90 | ||
93 | 91 | @Callable(i) | |
94 | 92 | func rejectOffer (offerId) = { | |
95 | 93 | let offerStatus = tryGetInteger(getOfferStatusKey(offerId)) | |
96 | 94 | if ((offerStatus != offerOpenStatus)) | |
97 | 95 | then throw("offer status must be open") | |
98 | 96 | else { | |
99 | 97 | let addressTo = getStringValue(this, getOfferAddressToKey(offerId)) | |
100 | 98 | let callerStr = toBase58String(i.caller.bytes) | |
101 | 99 | if ((addressTo != callerStr)) | |
102 | 100 | then throw("offer must be made to caller") | |
103 | 101 | else [IntegerEntry(getOfferStatusKey(offerId), offerRejectedStatus)] | |
104 | 102 | } | |
105 | 103 | } | |
106 | 104 | ||
107 | 105 |
github/deemru/w8io/169f3d6 45.52 ms ◑