tx · CAR2m5ja2HCzeMUZAmpv77SL8vSFGqZuM9MdAF16ZAmY 3N7a7sTSKaE621QewSqQcL1mUbknJjnLkZc: -0.01000000 Waves 2021.10.22 00:10 [1756577] smart account 3N7a7sTSKaE621QewSqQcL1mUbknJjnLkZc > SELF 0.00000000 Waves
{ "type": 13, "id": "CAR2m5ja2HCzeMUZAmpv77SL8vSFGqZuM9MdAF16ZAmY", "fee": 1000000, "feeAssetId": null, "timestamp": 1634850681834, "version": 2, "chainId": 84, "sender": "3N7a7sTSKaE621QewSqQcL1mUbknJjnLkZc", "senderPublicKey": "6LrPmGtwuADhwHYcxBouLzwfSTGgucbwYG5Pja7LUrcd", "proofs": [ "5riiM1BhNncg8YjPLumhrbAoP9QUwHB72zvTST6vgdBZS7JBkDCNis9ybp3cN1b5Rzc5yXV21aZCYAgcpjJ14Sq7" ], "script": "base64:AAIFAAAAAAAAABcIAhIECgIIGRIDCgEBEgMKAQESAwoBAQAAABUAAAAACm9mZmVySWRLZXkCAAAADSRPRkZFUl9OVU1CRVIAAAAAB3Rlc3RLZXkCAAAABSRURVNUAAAAAA9vZmZlck9wZW5TdGF0dXMAAAAAAAAAAAEAAAAAE29mZmVyQ2FuY2VsZWRTdGF0dXMAAAAAAAAAAAIAAAAAE29mZmVyQWNjZXB0ZWRTdGF0dXMAAAAAAAAAAAMAAAAAE29mZmVyUmVqZWN0ZWRTdGF0dXMAAAAAAAAAAAQAAAAAEndhdmVzU3RhbmRJblN0cmluZwIAAAAFV0FWRVMAAAAAFndhdmVzU3RhbmRJbkJ5dGVWZWN0b3IJAAGbAAAAAQUAAAASd2F2ZXNTdGFuZEluU3RyaW5nAAAAABJ3YXZlc1N0YW5kSW5CYXNlNjQJAAJaAAAAAQUAAAAWd2F2ZXNTdGFuZEluQnl0ZVZlY3RvcgEAAAARZ2V0T2ZmZXJTdGF0dXNLZXkAAAABAAAAB29mZmVySWQJAAEsAAAAAgkAAaQAAAABBQAAAAdvZmZlcklkAgAAAAdfc3Rh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SBtYWRlIHRvIGNhbGxlcgkABEwAAAACCQEAAAAMSW50ZWdlckVudHJ5AAAAAgkBAAAAEWdldE9mZmVyU3RhdHVzS2V5AAAAAQUAAAAHb2ZmZXJJZAUAAAATb2ZmZXJBY2NlcHRlZFN0YXR1cwUAAAADbmlsAAAAAWkBAAAAC3JlamVjdE9mZmVyAAAAAQAAAAdvZmZlcklkBAAAAAtvZmZlclN0YXR1cwkBAAAADXRyeUdldEludGVnZXIAAAABCQEAAAARZ2V0T2ZmZXJTdGF0dXNLZXkAAAABBQAAAAdvZmZlcklkAwkBAAAAAiE9AAAAAgUAAAALb2ZmZXJTdGF0dXMFAAAAD29mZmVyT3BlblN0YXR1cwkAAAIAAAABAgAAABlvZmZlciBzdGF0dXMgbXVzdCBiZSBvcGVuBAAAAAlhZGRyZXNzVG8JAQAAABFAZXh0ck5hdGl2ZSgxMDUzKQAAAAIFAAAABHRoaXMJAQAAABRnZXRPZmZlckFkZHJlc3NUb0tleQAAAAEFAAAAB29mZmVySWQEAAAACWNhbGxlclN0cgkAAlgAAAABCAgFAAAAAWkAAAAGY2FsbGVyAAAABWJ5dGVzAwkBAAAAAiE9AAAAAgUAAAAJYWRkcmVzc1RvBQAAAAljYWxsZXJTdHIJAAACAAAAAQIAAAAcb2ZmZXIgbXVzdCBiZSBtYWRlIHRvIGNhbGxlcgkBAAAACWRyb3BPZmZlcgAAAAIFAAAAB29mZmVySWQFAAAAE29mZmVyUmVqZWN0ZWRTdGF0dXMAAAAAcf6/uA==", "height": 1756577, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 5F3R3xJbF2ppjFAHPNKT66mK4ratLMndQXkW9QWQBA2B Next: trJuHoX1NitFuvuN9RLQ4nq5rCwRBmH4qXBDwrvjfFu Diff:
Old | New | Differences | |
---|---|---|---|
13 | 13 | ||
14 | 14 | let offerRejectedStatus = 4 | |
15 | 15 | ||
16 | - | let wavesStandInByteVector = toBytes("WAVES") | |
16 | + | let wavesStandInString = "WAVES" | |
17 | + | ||
18 | + | let wavesStandInByteVector = toBytes(wavesStandInString) | |
19 | + | ||
20 | + | let wavesStandInBase64 = toBase64String(wavesStandInByteVector) | |
17 | 21 | ||
18 | 22 | func getOfferStatusKey (offerId) = (toString(offerId) + "_status") | |
19 | 23 | ||
47 | 51 | } | |
48 | 52 | ||
49 | 53 | ||
54 | + | func tryGetAssetIdFromAssetList (asset) = { | |
55 | + | let res = match asset[0] { | |
56 | + | case b: String => | |
57 | + | fromBase64String(b) | |
58 | + | case _ => | |
59 | + | throw("must have an assetId") | |
60 | + | } | |
61 | + | res | |
62 | + | } | |
63 | + | ||
64 | + | ||
65 | + | func tryGetAmountFromAssetList (asset) = { | |
66 | + | let res = match asset[1] { | |
67 | + | case b: Int => | |
68 | + | b | |
69 | + | case _ => | |
70 | + | throw("must have an amount") | |
71 | + | } | |
72 | + | res | |
73 | + | } | |
74 | + | ||
75 | + | ||
50 | 76 | func tryGetAssetId (offerId,itemNumber) = { | |
51 | 77 | let val = fromBase64String(getStringValue(this, getOfferOfferedAssetKey(offerId, itemNumber))) | |
52 | 78 | if ((val == wavesStandInByteVector)) | |
69 | 95 | let firstPayment = value(i.payments[0]) | |
70 | 96 | if (!(isDefined(firstPayment))) | |
71 | 97 | then throw("no payment") | |
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( | |
98 | + | 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(getOfferAskedAssetKey(offerId, 0), toBase64String(tryGetAssetIdFromAssetList(asset0))), IntegerEntry(getOfferAskedAmountKey(offerId, 0), tryGetAmountFromAssetList(asset0))] | |
73 | 99 | } | |
74 | 100 | ||
75 | 101 |
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 | - | let wavesStandInByteVector = toBytes("WAVES") | |
16 | + | let wavesStandInString = "WAVES" | |
17 | + | ||
18 | + | let wavesStandInByteVector = toBytes(wavesStandInString) | |
19 | + | ||
20 | + | let wavesStandInBase64 = toBase64String(wavesStandInByteVector) | |
17 | 21 | ||
18 | 22 | func getOfferStatusKey (offerId) = (toString(offerId) + "_status") | |
19 | 23 | ||
20 | 24 | ||
21 | 25 | func getOfferAddressFromKey (offerId) = (toString(offerId) + "_from") | |
22 | 26 | ||
23 | 27 | ||
24 | 28 | func getOfferAddressToKey (offerId) = (toString(offerId) + "_to") | |
25 | 29 | ||
26 | 30 | ||
27 | 31 | func getOfferOfferedAssetKey (offerId,itemNumber) = (((toString(offerId) + "_") + toString(itemNumber)) + "_offered_asset_id") | |
28 | 32 | ||
29 | 33 | ||
30 | 34 | func getOfferOfferedAmountKey (offerId,itemNumber) = (((toString(offerId) + "_") + toString(itemNumber)) + "_offered_asset_amount") | |
31 | 35 | ||
32 | 36 | ||
33 | 37 | func getOfferAskedAssetKey (offerId,itemNumber) = (((toString(offerId) + "_") + toString(itemNumber)) + "_asked_asset_id") | |
34 | 38 | ||
35 | 39 | ||
36 | 40 | func getOfferAskedAmountKey (offerId,itemNumber) = (((toString(offerId) + "_") + toString(itemNumber)) + "_asked_asset_amount") | |
37 | 41 | ||
38 | 42 | ||
39 | 43 | func tryGetInteger (key) = { | |
40 | 44 | let val = match getInteger(this, key) { | |
41 | 45 | case b: Int => | |
42 | 46 | b | |
43 | 47 | case _ => | |
44 | 48 | 0 | |
45 | 49 | } | |
46 | 50 | val | |
47 | 51 | } | |
48 | 52 | ||
49 | 53 | ||
54 | + | func tryGetAssetIdFromAssetList (asset) = { | |
55 | + | let res = match asset[0] { | |
56 | + | case b: String => | |
57 | + | fromBase64String(b) | |
58 | + | case _ => | |
59 | + | throw("must have an assetId") | |
60 | + | } | |
61 | + | res | |
62 | + | } | |
63 | + | ||
64 | + | ||
65 | + | func tryGetAmountFromAssetList (asset) = { | |
66 | + | let res = match asset[1] { | |
67 | + | case b: Int => | |
68 | + | b | |
69 | + | case _ => | |
70 | + | throw("must have an amount") | |
71 | + | } | |
72 | + | res | |
73 | + | } | |
74 | + | ||
75 | + | ||
50 | 76 | func tryGetAssetId (offerId,itemNumber) = { | |
51 | 77 | let val = fromBase64String(getStringValue(this, getOfferOfferedAssetKey(offerId, itemNumber))) | |
52 | 78 | if ((val == wavesStandInByteVector)) | |
53 | 79 | then unit | |
54 | 80 | else val | |
55 | 81 | } | |
56 | 82 | ||
57 | 83 | ||
58 | 84 | func dropOffer (offerId,dropStatus) = { | |
59 | 85 | let addressFrom = Address(fromBase58String(getStringValue(this, getOfferAddressFromKey(offerId)))) | |
60 | 86 | let assetId = tryGetAssetId(offerId, 0) | |
61 | 87 | let assetAmount = tryGetInteger(getOfferOfferedAmountKey(offerId, 0)) | |
62 | 88 | [IntegerEntry(getOfferStatusKey(offerId), dropStatus), ScriptTransfer(addressFrom, assetAmount, assetId)] | |
63 | 89 | } | |
64 | 90 | ||
65 | 91 | ||
66 | 92 | @Callable(i) | |
67 | 93 | func createOffer (toAddress,asset0) = { | |
68 | 94 | let offerId = (tryGetInteger(offerIdKey) + 1) | |
69 | 95 | let firstPayment = value(i.payments[0]) | |
70 | 96 | if (!(isDefined(firstPayment))) | |
71 | 97 | then throw("no payment") | |
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( | |
98 | + | 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(getOfferAskedAssetKey(offerId, 0), toBase64String(tryGetAssetIdFromAssetList(asset0))), IntegerEntry(getOfferAskedAmountKey(offerId, 0), tryGetAmountFromAssetList(asset0))] | |
73 | 99 | } | |
74 | 100 | ||
75 | 101 | ||
76 | 102 | ||
77 | 103 | @Callable(i) | |
78 | 104 | func cancelOffer (offerId) = { | |
79 | 105 | let offerStatus = tryGetInteger(getOfferStatusKey(offerId)) | |
80 | 106 | if ((offerStatus != offerOpenStatus)) | |
81 | 107 | then throw("offer status must be open") | |
82 | 108 | else { | |
83 | 109 | let addressFrom = getStringValue(this, getOfferAddressFromKey(offerId)) | |
84 | 110 | let callerStr = toBase58String(i.caller.bytes) | |
85 | 111 | if ((addressFrom != callerStr)) | |
86 | 112 | then throw("offer must be made by caller") | |
87 | 113 | else dropOffer(offerId, offerCanceledStatus) | |
88 | 114 | } | |
89 | 115 | } | |
90 | 116 | ||
91 | 117 | ||
92 | 118 | ||
93 | 119 | @Callable(i) | |
94 | 120 | func acceptOffer (offerId) = { | |
95 | 121 | let offerStatus = tryGetInteger(getOfferStatusKey(offerId)) | |
96 | 122 | if ((offerStatus != offerOpenStatus)) | |
97 | 123 | then throw("offer status must be open") | |
98 | 124 | else { | |
99 | 125 | let addressTo = getStringValue(this, getOfferAddressToKey(offerId)) | |
100 | 126 | let callerStr = toBase58String(i.caller.bytes) | |
101 | 127 | if ((addressTo != callerStr)) | |
102 | 128 | then throw("offer must be made to caller") | |
103 | 129 | else [IntegerEntry(getOfferStatusKey(offerId), offerAcceptedStatus)] | |
104 | 130 | } | |
105 | 131 | } | |
106 | 132 | ||
107 | 133 | ||
108 | 134 | ||
109 | 135 | @Callable(i) | |
110 | 136 | func rejectOffer (offerId) = { | |
111 | 137 | let offerStatus = tryGetInteger(getOfferStatusKey(offerId)) | |
112 | 138 | if ((offerStatus != offerOpenStatus)) | |
113 | 139 | then throw("offer status must be open") | |
114 | 140 | else { | |
115 | 141 | let addressTo = getStringValue(this, getOfferAddressToKey(offerId)) | |
116 | 142 | let callerStr = toBase58String(i.caller.bytes) | |
117 | 143 | if ((addressTo != callerStr)) | |
118 | 144 | then throw("offer must be made to caller") | |
119 | 145 | else dropOffer(offerId, offerRejectedStatus) | |
120 | 146 | } | |
121 | 147 | } | |
122 | 148 | ||
123 | 149 |
github/deemru/w8io/169f3d6 28.08 ms ◑