tx · E2AHDVsdo9hLL4FN1wT6FRC3CHziXBgpKdpqCuN87Pxt

3N7a7sTSKaE621QewSqQcL1mUbknJjnLkZc:  -0.01000000 Waves

2021.10.21 23:42 [1756548] smart account 3N7a7sTSKaE621QewSqQcL1mUbknJjnLkZc > SELF 0.00000000 Waves

{ "type": 13, "id": "E2AHDVsdo9hLL4FN1wT6FRC3CHziXBgpKdpqCuN87Pxt", "fee": 1000000, "feeAssetId": null, "timestamp": 1634848965479, "version": 2, "chainId": 84, "sender": "3N7a7sTSKaE621QewSqQcL1mUbknJjnLkZc", "senderPublicKey": "6LrPmGtwuADhwHYcxBouLzwfSTGgucbwYG5Pja7LUrcd", "proofs": [ "fkxCFwVy6PqfhZY1qcuMsH9Y1hnFZCRfAFsWK2FK1NrhbZQiLNbUakKHyShjMVE51C5eGn9s6Mt2hc4YzzctHbK" ], "script": "base64:AAIFAAAAAAAAABcIAhIECgIIGBIDCgEBEgMKAQESAwoBAQAAABAAAAAACm9mZmVySWRLZXkCAAAADSRPRkZFUl9OVU1CRVIAAAAAB3Rlc3RLZXkCAAAABSRURVNUAAAAAA9vZmZlck9wZW5TdGF0dXMAAAAAAAAAAAEAAAAAE29mZmVyQ2FuY2VsZWRTdGF0dXMAAAAAAAAAAAIAAAAAE29mZmVyQWNjZXB0ZWRTdGF0dXMAAAAAAAAAAAMAAAAAE29mZmVyUmVqZWN0ZWRTdGF0dXMAAAAAAAAAAAQAAAAAFndhdmVzU3RhbmRJbkJ5dGVWZWN0b3IJAAGbAAAAAQIAAAAFV0FWRVMBAAAAEWdldE9mZmVyU3RhdHVzS2V5AAAAAQAAAAdvZmZlcklkCQABLAAAAAIJAAGkAAAAAQUAAAAHb2ZmZXJJZAIAAAAHX3N0YXR1cwEAAAAWZ2V0T2ZmZXJBZGRyZXNzRnJvbUtleQAAAAEAAAAHb2ZmZXJJZAkAASwAAAACCQABpAAAAAEFAAAAB29mZmVySWQCAAAABV9mcm9tAQAAABRnZXRPZmZlckFkZHJlc3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XNLZXkAAAABBQAAAAdvZmZlcklkAwkBAAAAAiE9AAAAAgUAAAALb2ZmZXJTdGF0dXMFAAAAD29mZmVyT3BlblN0YXR1cwkAAAIAAAABAgAAABlvZmZlciBzdGF0dXMgbXVzdCBiZSBvcGVuBAAAAAlhZGRyZXNzVG8JAQAAABFAZXh0ck5hdGl2ZSgxMDUzKQAAAAIFAAAABHRoaXMJAQAAABRnZXRPZmZlckFkZHJlc3NUb0tleQAAAAEFAAAAB29mZmVySWQEAAAACWNhbGxlclN0cgkAAlgAAAABCAgFAAAAAWkAAAAGY2FsbGVyAAAABWJ5dGVzAwkBAAAAAiE9AAAAAgUAAAAJYWRkcmVzc1RvBQAAAAljYWxsZXJTdHIJAAACAAAAAQIAAAAcb2ZmZXIgbXVzdCBiZSBtYWRlIHRvIGNhbGxlcgkABEwAAAACCQEAAAAMSW50ZWdlckVudHJ5AAAAAgkBAAAAEWdldE9mZmVyU3RhdHVzS2V5AAAAAQUAAAAHb2ZmZXJJZAUAAAATb2ZmZXJSZWplY3RlZFN0YXR1cwUAAAADbmlsAAAAAGd8nhQ=", "height": 1756548, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: AshK3p7zNscKXJwKwy5AH9Zk25mqgcq55zf9ztdZvjnH Next: 9N8EDBLqcnWxKYnRMt6jJHLYw1wzjsmUVfR7xcdVxpGx Diff:
OldNewDifferences
1212 let offerAcceptedStatus = 3
1313
1414 let offerRejectedStatus = 4
15+
16+let wavesStandInByteVector = toBytes("WAVES")
1517
1618 func getOfferStatusKey (offerId) = (toString(offerId) + "_status")
1719
4547 }
4648
4749
50+func tryGetAssetId (offerId,itemNumber) = {
51+ let val = fromBase64String(getStringValue(this, getOfferOfferedAssetKey(offerId, itemNumber)))
52+ if ((val == wavesStandInByteVector))
53+ then unit
54+ else val
55+ }
56+
57+
4858 @Callable(i)
4959 func createOffer (toAddress,asset) = {
5060 let offerId = tryGetInteger(offerIdKey)
5161 let firstPayment = value(i.payments[0])
5262 if (!(isDefined(firstPayment)))
5363 then throw("no payment")
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)]
64+ else [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)]
5565 }
5666
5767
6676 let callerStr = toBase58String(i.caller.bytes)
6777 if ((addressFrom != callerStr))
6878 then throw("offer must be made by caller")
69- else [IntegerEntry(getOfferStatusKey(offerId), offerCanceledStatus)]
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+ }
7084 }
7185 }
7286
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let offerIdKey = "$OFFER_NUMBER"
55
66 let testKey = "$TEST"
77
88 let offerOpenStatus = 1
99
1010 let offerCanceledStatus = 2
1111
1212 let offerAcceptedStatus = 3
1313
1414 let offerRejectedStatus = 4
15+
16+let wavesStandInByteVector = toBytes("WAVES")
1517
1618 func getOfferStatusKey (offerId) = (toString(offerId) + "_status")
1719
1820
1921 func getOfferAddressFromKey (offerId) = (toString(offerId) + "_from")
2022
2123
2224 func getOfferAddressToKey (offerId) = (toString(offerId) + "_to")
2325
2426
2527 func getOfferOfferedAssetKey (offerId,itemNumber) = (((toString(offerId) + "_") + toString(itemNumber)) + "_offered_asset_id")
2628
2729
2830 func getOfferOfferedAmountKey (offerId,itemNumber) = (((toString(offerId) + "_") + toString(itemNumber)) + "_offered_asset_amount")
2931
3032
3133 func getOfferAskedAssetKey (offerId,itemNumber) = (((toString(offerId) + "_") + toString(itemNumber)) + "_asked_asset_id")
3234
3335
3436 func getOfferAskedAmountKey (offerId,itemNumber) = (((toString(offerId) + "_") + toString(itemNumber)) + "_asked_asset_amount")
3537
3638
3739 func tryGetInteger (key) = {
3840 let val = match getInteger(this, key) {
3941 case b: Int =>
4042 b
4143 case _ =>
4244 0
4345 }
4446 val
4547 }
4648
4749
50+func tryGetAssetId (offerId,itemNumber) = {
51+ let val = fromBase64String(getStringValue(this, getOfferOfferedAssetKey(offerId, itemNumber)))
52+ if ((val == wavesStandInByteVector))
53+ then unit
54+ else val
55+ }
56+
57+
4858 @Callable(i)
4959 func createOffer (toAddress,asset) = {
5060 let offerId = tryGetInteger(offerIdKey)
5161 let firstPayment = value(i.payments[0])
5262 if (!(isDefined(firstPayment)))
5363 then throw("no payment")
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)]
64+ else [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)]
5565 }
5666
5767
5868
5969 @Callable(i)
6070 func cancelOffer (offerId) = {
6171 let offerStatus = tryGetInteger(getOfferStatusKey(offerId))
6272 if ((offerStatus != offerOpenStatus))
6373 then throw("offer status must be open")
6474 else {
6575 let addressFrom = getStringValue(this, getOfferAddressFromKey(offerId))
6676 let callerStr = toBase58String(i.caller.bytes)
6777 if ((addressFrom != callerStr))
6878 then throw("offer must be made by caller")
69- else [IntegerEntry(getOfferStatusKey(offerId), offerCanceledStatus)]
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+ }
7084 }
7185 }
7286
7387
7488
7589 @Callable(i)
7690 func acceptOffer (offerId) = {
7791 let offerStatus = tryGetInteger(getOfferStatusKey(offerId))
7892 if ((offerStatus != offerOpenStatus))
7993 then throw("offer status must be open")
8094 else {
8195 let addressTo = getStringValue(this, getOfferAddressToKey(offerId))
8296 let callerStr = toBase58String(i.caller.bytes)
8397 if ((addressTo != callerStr))
8498 then throw("offer must be made to caller")
8599 else [IntegerEntry(getOfferStatusKey(offerId), offerAcceptedStatus)]
86100 }
87101 }
88102
89103
90104
91105 @Callable(i)
92106 func rejectOffer (offerId) = {
93107 let offerStatus = tryGetInteger(getOfferStatusKey(offerId))
94108 if ((offerStatus != offerOpenStatus))
95109 then throw("offer status must be open")
96110 else {
97111 let addressTo = getStringValue(this, getOfferAddressToKey(offerId))
98112 let callerStr = toBase58String(i.caller.bytes)
99113 if ((addressTo != callerStr))
100114 then throw("offer must be made to caller")
101115 else [IntegerEntry(getOfferStatusKey(offerId), offerRejectedStatus)]
102116 }
103117 }
104118
105119

github/deemru/w8io/026f985 
30.05 ms