tx · AshK3p7zNscKXJwKwy5AH9Zk25mqgcq55zf9ztdZvjnH 3N7a7sTSKaE621QewSqQcL1mUbknJjnLkZc: -0.01000000 Waves 2021.10.21 23:29 [1756536] smart account 3N7a7sTSKaE621QewSqQcL1mUbknJjnLkZc > SELF 0.00000000 Waves
{ "type": 13, "id": "AshK3p7zNscKXJwKwy5AH9Zk25mqgcq55zf9ztdZvjnH", "fee": 1000000, "feeAssetId": null, "timestamp": 1634848178256, "version": 2, "chainId": 84, "sender": "3N7a7sTSKaE621QewSqQcL1mUbknJjnLkZc", "senderPublicKey": "6LrPmGtwuADhwHYcxBouLzwfSTGgucbwYG5Pja7LUrcd", "proofs": [ "5HmUFK9pwrfzwDHLC3fNVqBkckWzQdkWM7m8VkWFt8hfheK1hQFnhXMGTZxSXZU3xsf7jT2ttdtqj87xS87aayeB" ], "script": "base64:AAIFAAAAAAAAABcIAhIECgIIGBIDCgEBEgMKAQESAwoBAQAAAA4AAAAACm9mZmVySWRLZXkCAAAADSRPRkZFUl9OVU1CRVIAAAAAB3Rlc3RLZXkCAAAABSRURVNUAAAAAA9vZmZlck9wZW5TdGF0dXMAAAAAAAAAAAEAAAAAE29mZmVyQ2FuY2VsZWRTdGF0dXMAAAAAAAAAAAIAAAAAE29mZmVyQWNjZXB0ZWRTdGF0dXMAAAAAAAAAAAMAAAAAE29mZmVyUmVqZWN0ZWRTdGF0dXMAAAAAAAAAAAQBAAAAEWdldE9mZmVyU3RhdHVzS2V5AAAAAQAAAAdvZmZlcklkCQABLAAAAAIJAAGkAAAAAQUAAAAHb2ZmZXJJZAIAAAAHX3N0YXR1cwEAAAAWZ2V0T2ZmZXJBZGRyZXNzRnJvbUtleQAAAAEAAAAHb2ZmZXJJZAkAASwAAAACCQABpAAAAAEFAAAAB29mZmVySWQCAAAABV9mcm9tAQAAABRnZXRPZmZlckFkZHJlc3NUb0tleQAAAAEAAAAHb2ZmZXJJZAkAASwAAAACCQABpAAAAAEFAAAAB29mZmVySWQCAAAAA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5dGVzAwkBAAAAAiE9AAAAAgUAAAAJYWRkcmVzc1RvBQAAAAljYWxsZXJTdHIJAAACAAAAAQIAAAAcb2ZmZXIgbXVzdCBiZSBtYWRlIHRvIGNhbGxlcgkABEwAAAACCQEAAAAMSW50ZWdlckVudHJ5AAAAAgkBAAAAEWdldE9mZmVyU3RhdHVzS2V5AAAAAQUAAAAHb2ZmZXJJZAUAAAATb2ZmZXJBY2NlcHRlZFN0YXR1cwUAAAADbmlsAAAAAWkBAAAAC3JlamVjdE9mZmVyAAAAAQAAAAdvZmZlcklkBAAAAAtvZmZlclN0YXR1cwkBAAAADXRyeUdldEludGVnZXIAAAABCQEAAAARZ2V0T2ZmZXJTdGF0dXNLZXkAAAABBQAAAAdvZmZlcklkAwkBAAAAAiE9AAAAAgUAAAALb2ZmZXJTdGF0dXMFAAAAD29mZmVyT3BlblN0YXR1cwkAAAIAAAABAgAAABlvZmZlciBzdGF0dXMgbXVzdCBiZSBvcGVuBAAAAAlhZGRyZXNzVG8JAQAAABFAZXh0ck5hdGl2ZSgxMDUzKQAAAAIFAAAABHRoaXMJAQAAABRnZXRPZmZlckFkZHJlc3NUb0tleQAAAAEFAAAAB29mZmVySWQEAAAACWNhbGxlclN0cgkAAlgAAAABCAgFAAAAAWkAAAAGY2FsbGVyAAAABWJ5dGVzAwkBAAAAAiE9AAAAAgUAAAAJYWRkcmVzc1RvBQAAAAljYWxsZXJTdHIJAAACAAAAAQIAAAAcb2ZmZXIgbXVzdCBiZSBtYWRlIHRvIGNhbGxlcgkABEwAAAACCQEAAAAMSW50ZWdlckVudHJ5AAAAAgkBAAAAEWdldE9mZmVyU3RhdHVzS2V5AAAAAQUAAAAHb2ZmZXJJZAUAAAATb2ZmZXJSZWplY3RlZFN0YXR1cwUAAAADbmlsAAAAAHLHJFc=", "height": 1756536, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 3N4ffp7GmyG7iZNusRdnNB498uB2MFy7eKMxSwYY2PYW Next: E2AHDVsdo9hLL4FN1wT6FRC3CHziXBgpKdpqCuN87Pxt Diff:
Old | New | Differences | |
---|---|---|---|
22 | 22 | func getOfferAddressToKey (offerId) = (toString(offerId) + "_to") | |
23 | 23 | ||
24 | 24 | ||
25 | - | func getOfferOfferedAssetKey (offerId,itemNumber) = ((toString(offerId) + toString(itemNumber)) + "_offered_asset_id") | |
25 | + | func getOfferOfferedAssetKey (offerId,itemNumber) = (((toString(offerId) + "_") + toString(itemNumber)) + "_offered_asset_id") | |
26 | 26 | ||
27 | 27 | ||
28 | - | func getOfferOfferedAmountKey (offerId,itemNumber) = ((toString(offerId) + toString(itemNumber)) + "_offered_asset_amount") | |
28 | + | func getOfferOfferedAmountKey (offerId,itemNumber) = (((toString(offerId) + "_") + toString(itemNumber)) + "_offered_asset_amount") | |
29 | 29 | ||
30 | 30 | ||
31 | - | func getOfferAskedAssetKey (offerId,itemNumber) = ((toString(offerId) + toString(itemNumber)) + "_asked_asset_id") | |
31 | + | func getOfferAskedAssetKey (offerId,itemNumber) = (((toString(offerId) + "_") + toString(itemNumber)) + "_asked_asset_id") | |
32 | 32 | ||
33 | 33 | ||
34 | - | func getOfferAskedAmountKey (offerId,itemNumber) = ((toString(offerId) + toString(itemNumber)) + "_asked_asset_amount") | |
34 | + | func getOfferAskedAmountKey (offerId,itemNumber) = (((toString(offerId) + "_") + toString(itemNumber)) + "_asked_asset_amount") | |
35 | 35 | ||
36 | 36 | ||
37 | 37 | func tryGetInteger (key) = { |
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 | - | func getOfferOfferedAssetKey (offerId,itemNumber) = ((toString(offerId) + toString(itemNumber)) + "_offered_asset_id") | |
25 | + | func getOfferOfferedAssetKey (offerId,itemNumber) = (((toString(offerId) + "_") + toString(itemNumber)) + "_offered_asset_id") | |
26 | 26 | ||
27 | 27 | ||
28 | - | func getOfferOfferedAmountKey (offerId,itemNumber) = ((toString(offerId) + toString(itemNumber)) + "_offered_asset_amount") | |
28 | + | func getOfferOfferedAmountKey (offerId,itemNumber) = (((toString(offerId) + "_") + toString(itemNumber)) + "_offered_asset_amount") | |
29 | 29 | ||
30 | 30 | ||
31 | - | func getOfferAskedAssetKey (offerId,itemNumber) = ((toString(offerId) + toString(itemNumber)) + "_asked_asset_id") | |
31 | + | func getOfferAskedAssetKey (offerId,itemNumber) = (((toString(offerId) + "_") + toString(itemNumber)) + "_asked_asset_id") | |
32 | 32 | ||
33 | 33 | ||
34 | - | func getOfferAskedAmountKey (offerId,itemNumber) = ((toString(offerId) + toString(itemNumber)) + "_asked_asset_amount") | |
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 | 52 | if (!(isDefined(firstPayment))) | |
53 | 53 | then throw("no payment") | |
54 | 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)] | |
55 | 55 | } | |
56 | 56 | ||
57 | 57 | ||
58 | 58 | ||
59 | 59 | @Callable(i) | |
60 | 60 | func cancelOffer (offerId) = { | |
61 | 61 | let offerStatus = tryGetInteger(getOfferStatusKey(offerId)) | |
62 | 62 | if ((offerStatus != offerOpenStatus)) | |
63 | 63 | then throw("offer status must be open") | |
64 | 64 | else { | |
65 | 65 | let addressFrom = getStringValue(this, getOfferAddressFromKey(offerId)) | |
66 | 66 | let callerStr = toBase58String(i.caller.bytes) | |
67 | 67 | if ((addressFrom != callerStr)) | |
68 | 68 | then throw("offer must be made by caller") | |
69 | 69 | else [IntegerEntry(getOfferStatusKey(offerId), offerCanceledStatus)] | |
70 | 70 | } | |
71 | 71 | } | |
72 | 72 | ||
73 | 73 | ||
74 | 74 | ||
75 | 75 | @Callable(i) | |
76 | 76 | func acceptOffer (offerId) = { | |
77 | 77 | let offerStatus = tryGetInteger(getOfferStatusKey(offerId)) | |
78 | 78 | if ((offerStatus != offerOpenStatus)) | |
79 | 79 | then throw("offer status must be open") | |
80 | 80 | else { | |
81 | 81 | let addressTo = getStringValue(this, getOfferAddressToKey(offerId)) | |
82 | 82 | let callerStr = toBase58String(i.caller.bytes) | |
83 | 83 | if ((addressTo != callerStr)) | |
84 | 84 | then throw("offer must be made to caller") | |
85 | 85 | else [IntegerEntry(getOfferStatusKey(offerId), offerAcceptedStatus)] | |
86 | 86 | } | |
87 | 87 | } | |
88 | 88 | ||
89 | 89 | ||
90 | 90 | ||
91 | 91 | @Callable(i) | |
92 | 92 | func rejectOffer (offerId) = { | |
93 | 93 | let offerStatus = tryGetInteger(getOfferStatusKey(offerId)) | |
94 | 94 | if ((offerStatus != offerOpenStatus)) | |
95 | 95 | then throw("offer status must be open") | |
96 | 96 | else { | |
97 | 97 | let addressTo = getStringValue(this, getOfferAddressToKey(offerId)) | |
98 | 98 | let callerStr = toBase58String(i.caller.bytes) | |
99 | 99 | if ((addressTo != callerStr)) | |
100 | 100 | then throw("offer must be made to caller") | |
101 | 101 | else [IntegerEntry(getOfferStatusKey(offerId), offerRejectedStatus)] | |
102 | 102 | } | |
103 | 103 | } | |
104 | 104 | ||
105 | 105 |
github/deemru/w8io/026f985 22.33 ms ◑