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