tx · 2otcT2EHUqs5uMKgUfezdb3tb1opCV1spPRK3Vbjf3xR 3NCTUyjM4SX4hK2kaFTkYv4J2fzcQHtvSjv: -0.05000000 Waves 2020.06.05 17:14 [1030058] smart account 3NCTUyjM4SX4hK2kaFTkYv4J2fzcQHtvSjv > SELF 0.00000000 Waves
{ "type": 13, "id": "2otcT2EHUqs5uMKgUfezdb3tb1opCV1spPRK3Vbjf3xR", "fee": 5000000, "feeAssetId": null, "timestamp": 1591366362083, "version": 1, "sender": "3NCTUyjM4SX4hK2kaFTkYv4J2fzcQHtvSjv", "senderPublicKey": "CCEAkP4AnTM1HmKyRheQLmgNxPKACsL5hcH72JUeCiDJ", "proofs": [ "2Hb2YR1tnh7Z2aS2PNoV3xvREC2LQPDUymQKGvgVjbFjNzqAYbuvSsT36D4GhyQaoBHajcHpLqfZkdF14bYiYr77" ], "script": "base64:AAIDAAAAAAAAABkIARIGCgQIAQEIEgMKAQgSAwoBCBIDCgEIAAAAAwAAAAAOb3duZXJQdWJsaWNLZXkBAAAAIKZQ1ZLQ9/+2Zy378H8jTlGj0XgdM5q46Kfah/hKBO81AQAAAApyYW5kb21pemVyAAAAAQAAAANpbnYEAAAABHJhbmQJAADLAAAAAgkAAMsAAAACCQAAywAAAAIJAADLAAAAAggFAAAAA2ludgAAAA10cmFuc2FjdGlvbklkCAUAAAADaW52AAAAD2NhbGxlclB1YmxpY0tleQgFAAAACWxhc3RCbG9jawAAABNnZW5lcmF0aW9uU2lnbmF0dXJlCQABmgAAAAEIBQAAAAlsYXN0QmxvY2sAAAAJdGltZXN0YW1wCQABmgAAAAEIBQAAAAlsYXN0QmxvY2sAAAAGaGVpZ2h0CQAB9wAAAAEFAAAABHJhbmQBAAAAEW9mZmVyRXJyb3JIYW5kbGVyAAAABQAAAAV0b2tlbgAAAAZhbW91bnQAAAAFcHJpY2UAAAAEdHlwZQAAAANpbnYDAwMDCQEAAAABIQAAAAEJAQAAAAlpc0RlZmluZWQAAAABBQAAAAV0b2tlb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wAAAACBQAAAAdvZmZlcklkAgAAAAtfZmlyc3RQYXJ0eQMJAQAAAAIhPQAAAAIFAAAACmZpcnN0UGFydHkJAAJYAAAAAQgIBQAAAAFpAAAABmNhbGxlcgAAAAVieXRlcwkAAAIAAAABAgAAABhVc2VyIG5vdCBhbGxvd2VkIHRvIHNpZ24JAQAAAAhXcml0ZVNldAAAAAEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIFAAAAB29mZmVySWQCAAAAB2RlbGV0ZWQFAAAAA25pbAAAAAEAAAACdHgBAAAABnZlcmlmeQAAAAAEAAAAByRtYXRjaDAFAAAAAnR4AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAABRTZXRTY3JpcHRUcmFuc2FjdGlvbgQAAAABcwUAAAAHJG1hdGNoMAkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAFAAAADm93bmVyUHVibGljS2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAABdJbnZva2VTY3JpcHRUcmFuc2FjdGlvbgQAAAABaQUAAAAHJG1hdGNoMAkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAIBQAAAAJ0eAAAAA9zZW5kZXJQdWJsaWNLZXkHru8mVw==", "chainId": 84, "height": 1030058, "spentComplexity": 0 } View: original | compacted Prev: 3vs5DtLjRZYsWrTFW1X352ZgjAQbjS5uQNjyWBDRvZCq Next: E6EJN2SfxwKA1EZk4EyRKasZp9wjNrAmWFELSfJpshDP Diff:
Old | New | Differences | |
---|---|---|---|
55 | 55 | let payment = extract(i.payment) | |
56 | 56 | if (((payment.amount / 100000000) != offerAmount)) | |
57 | 57 | then throw("Insufficient Payment Amount") | |
58 | - | else WriteSet([DataEntry(offerId, "accepted"), DataEntry("_secondParty", toBase58String(i.caller.bytes))]) | |
58 | + | else WriteSet([DataEntry(offerId, "accepted"), DataEntry((offerId + "_secondParty"), toBase58String(i.caller.bytes))]) | |
59 | 59 | } | |
60 | 60 | else if ((offerType == "sell")) | |
61 | - | then WriteSet([DataEntry(offerId, "accepted"), DataEntry("_secondParty", toBase58String(i.caller.bytes))]) | |
61 | + | then WriteSet([DataEntry(offerId, "accepted"), DataEntry((offerId + "_secondParty"), toBase58String(i.caller.bytes))]) | |
62 | 62 | else throw("Offer Type Error") | |
63 | 63 | } | |
64 | 64 | ||
75 | 75 | else if ((offerType == "buy")) | |
76 | 76 | then ScriptResult(WriteSet([DataEntry(offerId, "closed")]), TransferSet([ScriptTransfer(i.caller, (amount * 100000000), unit)])) | |
77 | 77 | else if ((offerType == "sell")) | |
78 | - | then ScriptResult(WriteSet([DataEntry(offerId, "closed")]), TransferSet([ScriptTransfer( | |
78 | + | then ScriptResult(WriteSet([DataEntry(offerId, "closed")]), TransferSet([ScriptTransfer(addressFromStringValue(secondParty), (amount * 100000000), unit)])) | |
79 | 79 | else throw("Offer Type Error") | |
80 | 80 | } | |
81 | 81 |
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,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 * 100000000))) | |
30 | 30 | then throw("Payment amount insufficient") | |
31 | 31 | else true | |
32 | 32 | } | |
33 | 33 | else true | |
34 | 34 | ||
35 | 35 | ||
36 | 36 | @Callable(i) | |
37 | 37 | func postOffer (tokenIn,amountIn,priceIn,typeIn) = if (offerErrorHandler(tokenIn, amountIn, priceIn, typeIn, i)) | |
38 | 38 | then { | |
39 | 39 | let offerId = toBase64String(randomizer(i)) | |
40 | 40 | let offerDetails = ((((((tokenIn + ",") + toString(amountIn)) + ",") + toString(priceIn)) + ",") + typeIn) | |
41 | 41 | 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))]) | |
42 | 42 | } | |
43 | 43 | else throw("Conditions not met") | |
44 | 44 | ||
45 | 45 | ||
46 | 46 | ||
47 | 47 | @Callable(i) | |
48 | 48 | func acceptOffer (offerId) = { | |
49 | 49 | let offerType = getString(this, (offerId + "_type")) | |
50 | 50 | let offerAmount = getInteger(this, (offerId + "_amount")) | |
51 | 51 | if ((offerType == "buy")) | |
52 | 52 | then if (!(isDefined(i.payment))) | |
53 | 53 | then throw("Payment needed for buy offer") | |
54 | 54 | else { | |
55 | 55 | let payment = extract(i.payment) | |
56 | 56 | if (((payment.amount / 100000000) != offerAmount)) | |
57 | 57 | then throw("Insufficient Payment Amount") | |
58 | - | else WriteSet([DataEntry(offerId, "accepted"), DataEntry("_secondParty", toBase58String(i.caller.bytes))]) | |
58 | + | else WriteSet([DataEntry(offerId, "accepted"), DataEntry((offerId + "_secondParty"), toBase58String(i.caller.bytes))]) | |
59 | 59 | } | |
60 | 60 | else if ((offerType == "sell")) | |
61 | - | then WriteSet([DataEntry(offerId, "accepted"), DataEntry("_secondParty", toBase58String(i.caller.bytes))]) | |
61 | + | then WriteSet([DataEntry(offerId, "accepted"), DataEntry((offerId + "_secondParty"), toBase58String(i.caller.bytes))]) | |
62 | 62 | else throw("Offer Type Error") | |
63 | 63 | } | |
64 | 64 | ||
65 | 65 | ||
66 | 66 | ||
67 | 67 | @Callable(i) | |
68 | 68 | func signOffer (offerId) = { | |
69 | 69 | let firstParty = getString(this, (offerId + "_firstParty")) | |
70 | 70 | let secondParty = getStringValue(this, (offerId + "_secondParty")) | |
71 | 71 | let offerType = getString(this, (offerId + "_type")) | |
72 | 72 | let amount = getIntegerValue(this, (offerId + "_amount")) | |
73 | 73 | if ((firstParty != toBase58String(i.caller.bytes))) | |
74 | 74 | then throw("User not allowed to sign") | |
75 | 75 | else if ((offerType == "buy")) | |
76 | 76 | then ScriptResult(WriteSet([DataEntry(offerId, "closed")]), TransferSet([ScriptTransfer(i.caller, (amount * 100000000), unit)])) | |
77 | 77 | else if ((offerType == "sell")) | |
78 | - | then ScriptResult(WriteSet([DataEntry(offerId, "closed")]), TransferSet([ScriptTransfer( | |
78 | + | then ScriptResult(WriteSet([DataEntry(offerId, "closed")]), TransferSet([ScriptTransfer(addressFromStringValue(secondParty), (amount * 100000000), unit)])) | |
79 | 79 | else throw("Offer Type Error") | |
80 | 80 | } | |
81 | 81 | ||
82 | 82 | ||
83 | 83 | ||
84 | 84 | @Callable(i) | |
85 | 85 | func deleteOffer (offerId) = { | |
86 | 86 | let firstParty = getString(this, (offerId + "_firstParty")) | |
87 | 87 | if ((firstParty != toBase58String(i.caller.bytes))) | |
88 | 88 | then throw("User not allowed to sign") | |
89 | 89 | else WriteSet([DataEntry(offerId, "deleted")]) | |
90 | 90 | } | |
91 | 91 | ||
92 | 92 | ||
93 | 93 | @Verifier(tx) | |
94 | 94 | func verify () = match tx { | |
95 | 95 | case s: SetScriptTransaction => | |
96 | 96 | sigVerify(tx.bodyBytes, tx.proofs[0], ownerPublicKey) | |
97 | 97 | case i: InvokeScriptTransaction => | |
98 | 98 | sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
99 | 99 | case _ => | |
100 | 100 | false | |
101 | 101 | } | |
102 | 102 |
github/deemru/w8io/169f3d6 59.03 ms ◑