tx · 5F3R3xJbF2ppjFAHPNKT66mK4ratLMndQXkW9QWQBA2B 3N7a7sTSKaE621QewSqQcL1mUbknJjnLkZc: -0.01000000 Waves 2021.10.21 23:58 [1756564] smart account 3N7a7sTSKaE621QewSqQcL1mUbknJjnLkZc > SELF 0.00000000 Waves
{ "type": 13, "id": "5F3R3xJbF2ppjFAHPNKT66mK4ratLMndQXkW9QWQBA2B", "fee": 1000000, "feeAssetId": null, "timestamp": 1634849975726, "version": 2, "chainId": 84, "sender": "3N7a7sTSKaE621QewSqQcL1mUbknJjnLkZc", "senderPublicKey": "6LrPmGtwuADhwHYcxBouLzwfSTGgucbwYG5Pja7LUrcd", "proofs": [ "2Nar1znCxGZBoWgnj3eDc1zQk7DjoVrLcJQWttSF2TfSxPXYTLGjn9riwVn7cmf3wHVPX1de2YS168Cu39pEBCUW" ], "script": "base64:AAIFAAAAAAAAABcIAhIECgIIGRIDCgEBEgMKAQESAwoBAQAAABEAAAAACm9mZmVySWRLZXkCAAAADSRPRkZFUl9OVU1CRVIAAAAAB3Rlc3RLZXkCAAAABSRURVNUAAAAAA9vZmZlck9wZW5TdGF0dXMAAAAAAAAAAAEAAAAAE29mZmVyQ2FuY2VsZWRTdGF0dXMAAAAAAAAAAAIAAAAAE29mZmVyQWNjZXB0ZWRTdGF0dXMAAAAAAAAAAAMAAAAAE29mZmVyUmVqZWN0ZWRTdGF0dXMAAAAAAAAAAAQAAAAAFndhdmVzU3RhbmRJbkJ5dGVWZWN0b3IJAAGbAAAAAQIAAAAFV0FWRVMBAAAAEWdldE9mZmVyU3RhdHVzS2V5AAAAAQAAAAdvZmZlcklkCQABLAAAAAIJAAGkAAAAAQUAAAAHb2ZmZXJJZAIAAAAHX3N0YXR1cwEAAAAWZ2V0T2ZmZXJBZGRyZXNzRnJvbUtleQAAAAEAAAAHb2ZmZXJJZAkAASwAAAACCQABpAAAAAEFAAAAB29mZmVySWQCAAAABV9mcm9tAQAAABRnZXRPZmZlckFkZHJlc3NUb0tleQ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MJAQAAAAIhPQAAAAIFAAAACWFkZHJlc3NUbwUAAAAJY2FsbGVyU3RyCQAAAgAAAAECAAAAHG9mZmVyIG11c3QgYmUgbWFkZSB0byBjYWxsZXIJAQAAAAlkcm9wT2ZmZXIAAAACBQAAAAdvZmZlcklkBQAAABNvZmZlclJlamVjdGVkU3RhdHVzAAAAAEL+UAI=", "height": 1756564, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: HdUYUQk91q5EuiGywKBw8iE6a8HNjMSa5dnr6R8o2iHq Next: CAR2m5ja2HCzeMUZAmpv77SL8vSFGqZuM9MdAF16ZAmY Diff:
Old | New | Differences | |
---|---|---|---|
55 | 55 | } | |
56 | 56 | ||
57 | 57 | ||
58 | + | func dropOffer (offerId,dropStatus) = { | |
59 | + | let addressFrom = Address(fromBase58String(getStringValue(this, getOfferAddressFromKey(offerId)))) | |
60 | + | let assetId = tryGetAssetId(offerId, 0) | |
61 | + | let assetAmount = tryGetInteger(getOfferOfferedAmountKey(offerId, 0)) | |
62 | + | [IntegerEntry(getOfferStatusKey(offerId), dropStatus), ScriptTransfer(addressFrom, assetAmount, assetId)] | |
63 | + | } | |
64 | + | ||
65 | + | ||
58 | 66 | @Callable(i) | |
59 | - | func createOffer (toAddress, | |
67 | + | func createOffer (toAddress,asset0) = { | |
60 | 68 | let offerId = (tryGetInteger(offerIdKey) + 1) | |
61 | 69 | let firstPayment = value(i.payments[0]) | |
62 | 70 | if (!(isDefined(firstPayment))) | |
63 | 71 | then throw("no payment") | |
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)] | |
72 | + | 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), StringEntry(getOfferOfferedAssetKey(offerId, 0), toBase64String(valueOrElse(firstPayment.assetId, wavesStandInByteVector))), IntegerEntry(getOfferOfferedAmountKey(offerId, 0), firstPayment.amount)] | |
65 | 73 | } | |
66 | 74 | ||
67 | 75 | ||
76 | 84 | let callerStr = toBase58String(i.caller.bytes) | |
77 | 85 | if ((addressFrom != callerStr)) | |
78 | 86 | then throw("offer must be made by caller") | |
79 | - | else { | |
80 | - | let assetId = tryGetAssetId(offerId, 0) | |
81 | - | let assetAmount = tryGetInteger(getOfferOfferedAmountKey(offerId, 0)) | |
82 | - | [IntegerEntry(getOfferStatusKey(offerId), offerCanceledStatus), ScriptTransfer(i.caller, assetAmount, assetId)] | |
83 | - | } | |
87 | + | else dropOffer(offerId, offerCanceledStatus) | |
84 | 88 | } | |
85 | 89 | } | |
86 | 90 | ||
112 | 116 | let callerStr = toBase58String(i.caller.bytes) | |
113 | 117 | if ((addressTo != callerStr)) | |
114 | 118 | then throw("offer must be made to caller") | |
115 | - | else | |
119 | + | else dropOffer(offerId, offerRejectedStatus) | |
116 | 120 | } | |
117 | 121 | } | |
118 | 122 |
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 | + | func dropOffer (offerId,dropStatus) = { | |
59 | + | let addressFrom = Address(fromBase58String(getStringValue(this, getOfferAddressFromKey(offerId)))) | |
60 | + | let assetId = tryGetAssetId(offerId, 0) | |
61 | + | let assetAmount = tryGetInteger(getOfferOfferedAmountKey(offerId, 0)) | |
62 | + | [IntegerEntry(getOfferStatusKey(offerId), dropStatus), ScriptTransfer(addressFrom, assetAmount, assetId)] | |
63 | + | } | |
64 | + | ||
65 | + | ||
58 | 66 | @Callable(i) | |
59 | - | func createOffer (toAddress, | |
67 | + | func createOffer (toAddress,asset0) = { | |
60 | 68 | let offerId = (tryGetInteger(offerIdKey) + 1) | |
61 | 69 | let firstPayment = value(i.payments[0]) | |
62 | 70 | if (!(isDefined(firstPayment))) | |
63 | 71 | then throw("no payment") | |
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)] | |
72 | + | 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), StringEntry(getOfferOfferedAssetKey(offerId, 0), toBase64String(valueOrElse(firstPayment.assetId, wavesStandInByteVector))), IntegerEntry(getOfferOfferedAmountKey(offerId, 0), firstPayment.amount)] | |
65 | 73 | } | |
66 | 74 | ||
67 | 75 | ||
68 | 76 | ||
69 | 77 | @Callable(i) | |
70 | 78 | func cancelOffer (offerId) = { | |
71 | 79 | let offerStatus = tryGetInteger(getOfferStatusKey(offerId)) | |
72 | 80 | if ((offerStatus != offerOpenStatus)) | |
73 | 81 | then throw("offer status must be open") | |
74 | 82 | else { | |
75 | 83 | let addressFrom = getStringValue(this, getOfferAddressFromKey(offerId)) | |
76 | 84 | let callerStr = toBase58String(i.caller.bytes) | |
77 | 85 | if ((addressFrom != callerStr)) | |
78 | 86 | then throw("offer must be made by caller") | |
79 | - | else { | |
80 | - | let assetId = tryGetAssetId(offerId, 0) | |
81 | - | let assetAmount = tryGetInteger(getOfferOfferedAmountKey(offerId, 0)) | |
82 | - | [IntegerEntry(getOfferStatusKey(offerId), offerCanceledStatus), ScriptTransfer(i.caller, assetAmount, assetId)] | |
83 | - | } | |
87 | + | else dropOffer(offerId, offerCanceledStatus) | |
84 | 88 | } | |
85 | 89 | } | |
86 | 90 | ||
87 | 91 | ||
88 | 92 | ||
89 | 93 | @Callable(i) | |
90 | 94 | func acceptOffer (offerId) = { | |
91 | 95 | let offerStatus = tryGetInteger(getOfferStatusKey(offerId)) | |
92 | 96 | if ((offerStatus != offerOpenStatus)) | |
93 | 97 | then throw("offer status must be open") | |
94 | 98 | else { | |
95 | 99 | let addressTo = getStringValue(this, getOfferAddressToKey(offerId)) | |
96 | 100 | let callerStr = toBase58String(i.caller.bytes) | |
97 | 101 | if ((addressTo != callerStr)) | |
98 | 102 | then throw("offer must be made to caller") | |
99 | 103 | else [IntegerEntry(getOfferStatusKey(offerId), offerAcceptedStatus)] | |
100 | 104 | } | |
101 | 105 | } | |
102 | 106 | ||
103 | 107 | ||
104 | 108 | ||
105 | 109 | @Callable(i) | |
106 | 110 | func rejectOffer (offerId) = { | |
107 | 111 | let offerStatus = tryGetInteger(getOfferStatusKey(offerId)) | |
108 | 112 | if ((offerStatus != offerOpenStatus)) | |
109 | 113 | then throw("offer status must be open") | |
110 | 114 | else { | |
111 | 115 | let addressTo = getStringValue(this, getOfferAddressToKey(offerId)) | |
112 | 116 | let callerStr = toBase58String(i.caller.bytes) | |
113 | 117 | if ((addressTo != callerStr)) | |
114 | 118 | then throw("offer must be made to caller") | |
115 | - | else | |
119 | + | else dropOffer(offerId, offerRejectedStatus) | |
116 | 120 | } | |
117 | 121 | } | |
118 | 122 | ||
119 | 123 |
github/deemru/w8io/026f985 41.46 ms ◑