tx · 5bcfpdH6gcBw4fbcnxDqQtvdgqv2dtYYGi47WudZb9A9 3NCTUyjM4SX4hK2kaFTkYv4J2fzcQHtvSjv: -0.05000000 Waves 2020.06.21 11:23 [1053108] smart account 3NCTUyjM4SX4hK2kaFTkYv4J2fzcQHtvSjv > SELF 0.00000000 Waves
{ "type": 13, "id": "5bcfpdH6gcBw4fbcnxDqQtvdgqv2dtYYGi47WudZb9A9", "fee": 5000000, "feeAssetId": null, "timestamp": 1592727818814, "version": 1, "sender": "3NCTUyjM4SX4hK2kaFTkYv4J2fzcQHtvSjv", "senderPublicKey": "CCEAkP4AnTM1HmKyRheQLmgNxPKACsL5hcH72JUeCiDJ", "proofs": [ "3y8eXL4NxyBLET9y7i6o4386VprZ1fBn4n2LCwY7UnqM13h8NZwXqJASJwVMAm9v4MceK765mH3WrvJLj7mMeKeF" ], "script": "base64:AAIDAAAAAAAAABoIARIHCgUIAQEICBIDCgEIEgMKAQgSAwoBCAAAAAMAAAAADm93bmVyUHVibGljS2V5AQAAACCmUNWS0Pf/tmct+/B/I05Ro9F4HTOauOin2of4SgTvNQEAAAAKcmFuZG9taXplcgAAAAEAAAADaW52BAAAAARyYW5kCQAAywAAAAIJAADLAAAAAgkAAMsAAAACCQAAywAAAAIIBQAAAANpbnYAAAANdHJhbnNhY3Rpb25JZAgFAAAAA2ludgAAAA9jYWxsZXJQdWJsaWNLZXkIBQAAAAlsYXN0QmxvY2sAAAATZ2VuZXJhdGlvblNpZ25hdHVyZQkAAZoAAAABCAUAAAAJbGFzdEJsb2NrAAAACXRpbWVzdGFtcAkAAZoAAAABCAUAAAAJbGFzdEJsb2NrAAAABmhlaWdodAkAAfcAAAABBQAAAARyYW5kAQAAABFvZmZlckVycm9ySGFuZGxlcgAAAAYAAAAFdG9rZW4AAAAGYW1vdW50AAAABXByaWNlAAAABHR5cGUAAAAFYXNzZXQAAAADaW52AwMDAwkBAAAAASEAAAABCQEAAAAJaXNEZWZpbmVkAAAAAQUAAAAFdG9rZ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J0eAAAAAZwcm9vZnMAAAAAAAAAAAAFAAAADm93bmVyUHVibGljS2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAABdJbnZva2VTY3JpcHRUcmFuc2FjdGlvbgkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAIBQAAAAJ0eAAAAA9zZW5kZXJQdWJsaWNLZXkHcl2Jrg==", "chainId": 84, "height": 1053108, "spentComplexity": 0 } View: original | compacted Prev: 89xC877h4LzjUaB1X9AHVS8BqoeqV2mFYeKHFdoJv331 Next: AABmRxAVrouPqrMtFDbUuJTcvd2RNGZYCg8xXkTByjXG Diff:
Old | New | Differences | |
---|---|---|---|
78 | 78 | let secondParty = getStringValue(this, (offerId + "_secondParty")) | |
79 | 79 | let offerType = getString(this, (offerId + "_type")) | |
80 | 80 | let amount = getIntegerValue(this, (offerId + "_amount")) | |
81 | - | let assetId = | |
81 | + | let assetId = getBinaryValue(this, (offerId + "_assetId")) | |
82 | 82 | if ((offerStatus == "accepted")) | |
83 | 83 | then if ((firstParty != toBase58String(i.caller.bytes))) | |
84 | 84 | then throw("User not allowed to sign") | |
85 | 85 | else if ((offerType == "buy")) | |
86 | - | then ScriptResult(WriteSet([DataEntry(offerId, "closed")]), TransferSet([ScriptTransfer(i.caller, amount, | |
86 | + | then ScriptResult(WriteSet([DataEntry(offerId, "closed")]), TransferSet([ScriptTransfer(i.caller, amount, assetId)])) | |
87 | 87 | else if ((offerType == "sell")) | |
88 | - | then ScriptResult(WriteSet([DataEntry(offerId, "closed")]), TransferSet([ScriptTransfer(addressFromStringValue(secondParty), amount, | |
88 | + | then ScriptResult(WriteSet([DataEntry(offerId, "closed")]), TransferSet([ScriptTransfer(addressFromStringValue(secondParty), amount, assetId)])) | |
89 | 89 | else throw("Offer Type Error") | |
90 | 90 | else throw("Wrong offer status - forbidden") | |
91 | 91 | } |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let ownerPublicKey = base58'CCEAkP4AnTM1HmKyRheQLmgNxPKACsL5hcH72JUeCiDJ' | |
5 | 5 | ||
6 | 6 | func randomizer (inv) = { | |
7 | 7 | let rand = ((((inv.transactionId + inv.callerPublicKey) + lastBlock.generationSignature) + toBytes(lastBlock.timestamp)) + toBytes(lastBlock.height)) | |
8 | 8 | sha256(rand) | |
9 | 9 | } | |
10 | 10 | ||
11 | 11 | ||
12 | 12 | func offerErrorHandler (token,amount,price,type,asset,inv) = if (if (if (if (!(isDefined(token))) | |
13 | 13 | then true | |
14 | 14 | else !(isDefined(amount))) | |
15 | 15 | then true | |
16 | 16 | else !(isDefined(price))) | |
17 | 17 | then true | |
18 | 18 | else !(isDefined(type))) | |
19 | 19 | then throw("Invalid Transaction") | |
20 | 20 | else if (if ((type == "sell")) | |
21 | 21 | then !(isDefined(inv.payment)) | |
22 | 22 | else false) | |
23 | 23 | then throw("No payment attached") | |
24 | 24 | else if (if ((type == "sell")) | |
25 | 25 | then isDefined(inv.payment) | |
26 | 26 | else false) | |
27 | 27 | then { | |
28 | 28 | let payment = extract(inv.payment) | |
29 | 29 | if ((payment.amount != amount)) | |
30 | 30 | then throw("Payment amount insufficient") | |
31 | 31 | else if ((toBase58String(value(payment.assetId)) != asset)) | |
32 | 32 | then throw("AssetId invalid") | |
33 | 33 | else true | |
34 | 34 | } | |
35 | 35 | else true | |
36 | 36 | ||
37 | 37 | ||
38 | 38 | @Callable(i) | |
39 | 39 | func postOffer (tokenIn,amountIn,priceIn,typeIn,assetIn) = if (offerErrorHandler(tokenIn, amountIn, priceIn, typeIn, assetIn, i)) | |
40 | 40 | then { | |
41 | 41 | let offerId = toBase64String(randomizer(i)) | |
42 | 42 | WriteSet([DataEntry(offerId, "open"), DataEntry((offerId + "_tokenId"), tokenIn), DataEntry((offerId + "_amount"), amountIn), DataEntry((offerId + "_price"), priceIn), DataEntry((offerId + "_type"), typeIn), DataEntry((offerId + "_firstParty"), toBase58String(i.caller.bytes)), DataEntry((offerId + "_assetId"), assetIn)]) | |
43 | 43 | } | |
44 | 44 | else throw("Conditions not met") | |
45 | 45 | ||
46 | 46 | ||
47 | 47 | ||
48 | 48 | @Callable(i) | |
49 | 49 | func acceptOffer (offerId) = { | |
50 | 50 | let offerType = getString(this, (offerId + "_type")) | |
51 | 51 | let offerStatus = getString(this, offerId) | |
52 | 52 | let assetId = getString(this, (offerId + "_assetId")) | |
53 | 53 | let offerAmount = getInteger(this, (offerId + "_amount")) | |
54 | 54 | if ((offerStatus == "open")) | |
55 | 55 | then if ((offerType == "buy")) | |
56 | 56 | then if (!(isDefined(i.payment))) | |
57 | 57 | then throw("Payment needed for buy offer") | |
58 | 58 | else { | |
59 | 59 | let payment = extract(i.payment) | |
60 | 60 | if ((payment.amount != offerAmount)) | |
61 | 61 | then throw("Insufficient Payment Amount") | |
62 | 62 | else if ((payment.assetId != assetId)) | |
63 | 63 | then throw("AssetId invalid") | |
64 | 64 | else WriteSet([DataEntry(offerId, "accepted"), DataEntry((offerId + "_secondParty"), toBase58String(i.caller.bytes))]) | |
65 | 65 | } | |
66 | 66 | else if ((offerType == "sell")) | |
67 | 67 | then WriteSet([DataEntry(offerId, "accepted"), DataEntry((offerId + "_secondParty"), toBase58String(i.caller.bytes))]) | |
68 | 68 | else throw("Offer Type Error") | |
69 | 69 | else throw("Wrong offer status - forbidden") | |
70 | 70 | } | |
71 | 71 | ||
72 | 72 | ||
73 | 73 | ||
74 | 74 | @Callable(i) | |
75 | 75 | func signOffer (offerId) = { | |
76 | 76 | let offerStatus = getString(this, offerId) | |
77 | 77 | let firstParty = getString(this, (offerId + "_firstParty")) | |
78 | 78 | let secondParty = getStringValue(this, (offerId + "_secondParty")) | |
79 | 79 | let offerType = getString(this, (offerId + "_type")) | |
80 | 80 | let amount = getIntegerValue(this, (offerId + "_amount")) | |
81 | - | let assetId = | |
81 | + | let assetId = getBinaryValue(this, (offerId + "_assetId")) | |
82 | 82 | if ((offerStatus == "accepted")) | |
83 | 83 | then if ((firstParty != toBase58String(i.caller.bytes))) | |
84 | 84 | then throw("User not allowed to sign") | |
85 | 85 | else if ((offerType == "buy")) | |
86 | - | then ScriptResult(WriteSet([DataEntry(offerId, "closed")]), TransferSet([ScriptTransfer(i.caller, amount, | |
86 | + | then ScriptResult(WriteSet([DataEntry(offerId, "closed")]), TransferSet([ScriptTransfer(i.caller, amount, assetId)])) | |
87 | 87 | else if ((offerType == "sell")) | |
88 | - | then ScriptResult(WriteSet([DataEntry(offerId, "closed")]), TransferSet([ScriptTransfer(addressFromStringValue(secondParty), amount, | |
88 | + | then ScriptResult(WriteSet([DataEntry(offerId, "closed")]), TransferSet([ScriptTransfer(addressFromStringValue(secondParty), amount, assetId)])) | |
89 | 89 | else throw("Offer Type Error") | |
90 | 90 | else throw("Wrong offer status - forbidden") | |
91 | 91 | } | |
92 | 92 | ||
93 | 93 | ||
94 | 94 | ||
95 | 95 | @Callable(i) | |
96 | 96 | func deleteOffer (offerId) = { | |
97 | 97 | let firstParty = getString(this, (offerId + "_firstParty")) | |
98 | 98 | if ((firstParty != toBase58String(i.caller.bytes))) | |
99 | 99 | then throw("User not allowed to sign") | |
100 | 100 | else WriteSet([DataEntry(offerId, "deleted")]) | |
101 | 101 | } | |
102 | 102 | ||
103 | 103 | ||
104 | 104 | @Verifier(tx) | |
105 | 105 | func verify () = match tx { | |
106 | 106 | case _: SetScriptTransaction => | |
107 | 107 | sigVerify(tx.bodyBytes, tx.proofs[0], ownerPublicKey) | |
108 | 108 | case _: InvokeScriptTransaction => | |
109 | 109 | sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
110 | 110 | case _ => | |
111 | 111 | false | |
112 | 112 | } | |
113 | 113 |
github/deemru/w8io/169f3d6 29.68 ms ◑