tx · EUefa87Rb7Vh4C1VyTc9aZxkknapHdrq3vdAE975CNgX 3N7a7sTSKaE621QewSqQcL1mUbknJjnLkZc: -0.01000000 Waves 2021.10.21 23:02 [1756505] smart account 3N7a7sTSKaE621QewSqQcL1mUbknJjnLkZc > SELF 0.00000000 Waves
{ "type": 13, "id": "EUefa87Rb7Vh4C1VyTc9aZxkknapHdrq3vdAE975CNgX", "fee": 1000000, "feeAssetId": null, "timestamp": 1634846538916, "version": 2, "chainId": 84, "sender": "3N7a7sTSKaE621QewSqQcL1mUbknJjnLkZc", "senderPublicKey": "6LrPmGtwuADhwHYcxBouLzwfSTGgucbwYG5Pja7LUrcd", "proofs": [ "2np4vUArf26rGKhr4HEpr5wCYevm6Z7oE5JRfuXk29z52evtK8LEWs9qLwN8Hb2byWfJUbnxCUry5MdH4JWUwRKU" ], "script": "base64:AAIFAAAAAAAAABcIAhIECgIIGBIDCgEBEgMKAQESAwoBAQAAAA4AAAAACm9mZmVySWRLZXkCAAAADSRPRkZFUl9OVU1CRVIAAAAAB3Rlc3RLZXkCAAAABSRURVNUAAAAAA9vZmZlck9wZW5TdGF0dXMAAAAAAAAAAAEAAAAAE29mZmVyQ2FuY2VsZWRTdGF0dXMAAAAAAAAAAAIAAAAAE29mZmVyQWNjZXB0ZWRTdGF0dXMAAAAAAAAAAAMAAAAAE29mZmVyUmVqZWN0ZWRTdGF0dXMAAAAAAAAAAAQBAAAAEWdldE9mZmVyU3RhdHVzS2V5AAAAAQAAAAdvZmZlcklkCQABLAAAAAIJAAGkAAAAAQUAAAAHb2ZmZXJJZAIAAAAHX3N0YXR1cwEAAAAWZ2V0T2ZmZXJBZGRyZXNzRnJvbUtleQAAAAEAAAAHb2ZmZXJJZAkAASwAAAACCQABpAAAAAEFAAAAB29mZmVySWQCAAAABV9mcm9tAQAAABRnZXRPZmZlckFkZHJlc3NUb0tleQAAAAEAAAAHb2ZmZXJJZAkAASwAAAACCQABpAAAAAEFAAAAB29mZmVySWQCAAAAA190bwE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ZlcklkCQAETAAAAAIJAQAAAAxJbnRlZ2VyRW50cnkAAAACCQEAAAARZ2V0T2ZmZXJTdGF0dXNLZXkAAAABBQAAAAdvZmZlcklkBQAAABNvZmZlckNhbmNlbGVkU3RhdHVzBQAAAANuaWwAAAABaQEAAAALYWNjZXB0T2ZmZXIAAAABAAAAB29mZmVySWQJAARMAAAAAgkBAAAADEludGVnZXJFbnRyeQAAAAIJAQAAABFnZXRPZmZlclN0YXR1c0tleQAAAAEFAAAAB29mZmVySWQFAAAAE29mZmVyQWNjZXB0ZWRTdGF0dXMFAAAAA25pbAAAAAFpAQAAAAtyZWplY3RPZmZlcgAAAAEAAAAHb2ZmZXJJZAkABEwAAAACCQEAAAAMSW50ZWdlckVudHJ5AAAAAgkBAAAAEWdldE9mZmVyU3RhdHVzS2V5AAAAAQUAAAAHb2ZmZXJJZAUAAAATb2ZmZXJSZWplY3RlZFN0YXR1cwUAAAADbmlsAAAAAN2ijBk=", "height": 1756505, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: AukX1ALS9qG9MWq36y3Ys6cYQGtE1TYtRvgGdtwytqMB Next: A7Di3hxQ7VzmTaFLhFKBTLZ4t2k4taa7bg2VeXCStrBs Full:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let offerIdKey = "$OFFER_NUMBER" | |
5 | + | ||
6 | + | let testKey = "$TEST" | |
7 | + | ||
8 | + | let offerOpenStatus = 1 | |
9 | + | ||
10 | + | let offerCanceledStatus = 2 | |
11 | + | ||
12 | + | let offerAcceptedStatus = 3 | |
13 | + | ||
14 | + | let offerRejectedStatus = 4 | |
15 | + | ||
16 | + | func getOfferStatusKey (offerId) = (toString(offerId) + "_status") | |
17 | + | ||
18 | + | ||
19 | + | func getOfferAddressFromKey (offerId) = (toString(offerId) + "_from") | |
20 | + | ||
21 | + | ||
22 | + | func getOfferAddressToKey (offerId) = (toString(offerId) + "_to") | |
23 | + | ||
24 | + | ||
25 | + | func getOfferOfferedAssetKey (offerId,itemNumber) = ((toString(offerId) + toString(itemNumber)) + "_offered_asset_id") | |
26 | + | ||
27 | + | ||
28 | + | func getOfferOfferedAmountKey (offerId,itemNumber) = ((toString(offerId) + toString(itemNumber)) + "_offered_asset_amount") | |
29 | + | ||
30 | + | ||
31 | + | func getOfferAskedAssetKey (offerId,itemNumber) = ((toString(offerId) + toString(itemNumber)) + "_asked_asset_id") | |
32 | + | ||
33 | + | ||
34 | + | func getOfferAskedAmountKey (offerId,itemNumber) = ((toString(offerId) + toString(itemNumber)) + "_asked_asset_amount") | |
35 | + | ||
36 | + | ||
37 | + | func tryGetInteger (key) = { | |
38 | + | let val = match getInteger(this, key) { | |
39 | + | case b: Int => | |
40 | + | b | |
41 | + | case _ => | |
42 | + | 0 | |
43 | + | } | |
44 | + | val | |
45 | + | } | |
4 | 46 | ||
5 | 47 | ||
6 | 48 | @Callable(i) | |
7 | 49 | func createOffer (toAddress,asset) = { | |
8 | - | let | |
9 | - | [ | |
50 | + | let offerId = tryGetInteger(offerIdKey) | |
51 | + | [IntegerEntry(getOfferStatusKey(offerId), offerOpenStatus), StringEntry(getOfferAddressFromKey(offerId), toBase58String(i.caller.bytes)), StringEntry(getOfferAddressToKey(offerId), toAddress)] | |
10 | 52 | } | |
53 | + | ||
54 | + | ||
55 | + | ||
56 | + | @Callable(i) | |
57 | + | func cancelOffer (offerId) = { | |
58 | + | let offerStatus = tryGetInteger(getOfferStatusKey(offerId)) | |
59 | + | if ((offerStatus != offerOpenStatus)) | |
60 | + | then throw("offer status must be open") | |
61 | + | else { | |
62 | + | let addressFrom = getStringValue(this, getOfferAddressFromKey(offerId)) | |
63 | + | let callerStr = toBase58String(i.caller.bytes) | |
64 | + | if ((addressFrom != callerStr)) | |
65 | + | then throw("offer must be made by caller") | |
66 | + | else { | |
67 | + | let addressTo = getStringValue(this, getOfferAddressFromKey(offerId)) | |
68 | + | [IntegerEntry(getOfferStatusKey(offerId), offerCanceledStatus)] | |
69 | + | } | |
70 | + | } | |
71 | + | } | |
72 | + | ||
73 | + | ||
74 | + | ||
75 | + | @Callable(i) | |
76 | + | func acceptOffer (offerId) = [IntegerEntry(getOfferStatusKey(offerId), offerAcceptedStatus)] | |
77 | + | ||
78 | + | ||
79 | + | ||
80 | + | @Callable(i) | |
81 | + | func rejectOffer (offerId) = [IntegerEntry(getOfferStatusKey(offerId), offerRejectedStatus)] | |
11 | 82 | ||
12 | 83 |
github/deemru/w8io/169f3d6 37.91 ms ◑