tx · E6EJN2SfxwKA1EZk4EyRKasZp9wjNrAmWFELSfJpshDP 3NCTUyjM4SX4hK2kaFTkYv4J2fzcQHtvSjv: -0.05000000 Waves 2020.06.07 12:42 [1032695] smart account 3NCTUyjM4SX4hK2kaFTkYv4J2fzcQHtvSjv > SELF 0.00000000 Waves
{ "type": 13, "id": "E6EJN2SfxwKA1EZk4EyRKasZp9wjNrAmWFELSfJpshDP", "fee": 5000000, "feeAssetId": null, "timestamp": 1591522966536, "version": 1, "sender": "3NCTUyjM4SX4hK2kaFTkYv4J2fzcQHtvSjv", "senderPublicKey": "CCEAkP4AnTM1HmKyRheQLmgNxPKACsL5hcH72JUeCiDJ", "proofs": [ "Df3NL7VGBcqQubkA73wgbvhBrkLAytvPzbpeZ9kWy1yHm7W3WTuBFzBUWDFPsDQGWV4V83xmUi9V5kAYwidubAy" ], "script": "base64:AAIDAAAAAAAAABkIARIGCgQIAQEIEgMKAQgSAwoBCBIDCgEIAAAAAwAAAAAOb3duZXJQdWJsaWNLZXkBAAAAIKZQ1ZLQ9/+2Zy378H8jTlGj0XgdM5q46Kfah/hKBO81AQAAAApyYW5kb21pemVyAAAAAQAAAANpbnYEAAAABHJhbmQJAADLAAAAAgkAAMsAAAACCQAAywAAAAIJAADLAAAAAggFAAAAA2ludgAAAA10cmFuc2FjdGlvbklkCAUAAAADaW52AAAAD2NhbGxlclB1YmxpY0tleQgFAAAACWxhc3RCbG9jawAAABNnZW5lcmF0aW9uU2lnbmF0dXJlCQABmgAAAAEIBQAAAAlsYXN0QmxvY2sAAAAJdGltZXN0YW1wCQABmgAAAAEIBQAAAAlsYXN0QmxvY2sAAAAGaGVpZ2h0CQAB9wAAAAEFAAAABHJhbmQBAAAAEW9mZmVyRXJyb3JIYW5kbGVyAAAABQAAAAV0b2tlbgAAAAZhbW91bnQAAAAFcHJpY2UAAAAEdHlwZQAAAANpbnYDAwMDCQEAAAABIQAAAAEJAQAAAAlpc0RlZmluZWQAAAABBQAAAAV0b2tlbgYJ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0tleQdOQBab", "chainId": 84, "height": 1032695, "spentComplexity": 0 } View: original | compacted Prev: 2otcT2EHUqs5uMKgUfezdb3tb1opCV1spPRK3Vbjf3xR Next: 5ZxKaZqKrWFUA9r44xAPgMSpZKfHSVRicfvqsASXkzsK Diff:
Old | New | Differences | |
---|---|---|---|
47 | 47 | @Callable(i) | |
48 | 48 | func acceptOffer (offerId) = { | |
49 | 49 | let offerType = getString(this, (offerId + "_type")) | |
50 | + | let offerStatus = getString(this, offerId) | |
50 | 51 | let offerAmount = getInteger(this, (offerId + "_amount")) | |
51 | - | if ((offerType == "buy")) | |
52 | - | then if (!(isDefined(i.payment))) | |
53 | - | then throw("Payment needed for buy offer") | |
54 | - | else { | |
55 | - | let payment = extract(i.payment) | |
56 | - | if (((payment.amount / 100000000) != offerAmount)) | |
57 | - | then throw("Insufficient Payment Amount") | |
58 | - | else WriteSet([DataEntry(offerId, "accepted"), DataEntry((offerId + "_secondParty"), toBase58String(i.caller.bytes))]) | |
59 | - | } | |
60 | - | else if ((offerType == "sell")) | |
61 | - | then WriteSet([DataEntry(offerId, "accepted"), DataEntry((offerId + "_secondParty"), toBase58String(i.caller.bytes))]) | |
62 | - | else throw("Offer Type Error") | |
52 | + | if ((offerStatus == "open")) | |
53 | + | then if ((offerType == "buy")) | |
54 | + | then if (!(isDefined(i.payment))) | |
55 | + | then throw("Payment needed for buy offer") | |
56 | + | else { | |
57 | + | let payment = extract(i.payment) | |
58 | + | if (((payment.amount / 100000000) != offerAmount)) | |
59 | + | then throw("Insufficient Payment Amount") | |
60 | + | else WriteSet([DataEntry(offerId, "accepted"), DataEntry((offerId + "_secondParty"), toBase58String(i.caller.bytes))]) | |
61 | + | } | |
62 | + | else if ((offerType == "sell")) | |
63 | + | then WriteSet([DataEntry(offerId, "accepted"), DataEntry((offerId + "_secondParty"), toBase58String(i.caller.bytes))]) | |
64 | + | else throw("Offer Type Error") | |
65 | + | else throw("Wrong offer status - forbidden") | |
63 | 66 | } | |
64 | 67 | ||
65 | 68 | ||
66 | 69 | ||
67 | 70 | @Callable(i) | |
68 | 71 | func signOffer (offerId) = { | |
72 | + | let offerStatus = getString(this, offerId) | |
69 | 73 | let firstParty = getString(this, (offerId + "_firstParty")) | |
70 | 74 | let secondParty = getStringValue(this, (offerId + "_secondParty")) | |
71 | 75 | let offerType = getString(this, (offerId + "_type")) | |
72 | 76 | let amount = getIntegerValue(this, (offerId + "_amount")) | |
73 | - | if ((firstParty != toBase58String(i.caller.bytes))) | |
74 | - | then throw("User not allowed to sign") | |
75 | - | else if ((offerType == "buy")) | |
76 | - | then ScriptResult(WriteSet([DataEntry(offerId, "closed")]), TransferSet([ScriptTransfer(i.caller, (amount * 100000000), unit)])) | |
77 | - | else if ((offerType == "sell")) | |
78 | - | then ScriptResult(WriteSet([DataEntry(offerId, "closed")]), TransferSet([ScriptTransfer(addressFromStringValue(secondParty), (amount * 100000000), unit)])) | |
79 | - | else throw("Offer Type Error") | |
77 | + | if ((offerStatus == "accepted")) | |
78 | + | then if ((firstParty != toBase58String(i.caller.bytes))) | |
79 | + | then throw("User not allowed to sign") | |
80 | + | else if ((offerType == "buy")) | |
81 | + | then ScriptResult(WriteSet([DataEntry(offerId, "closed")]), TransferSet([ScriptTransfer(i.caller, (amount * 100000000), unit)])) | |
82 | + | else if ((offerType == "sell")) | |
83 | + | then ScriptResult(WriteSet([DataEntry(offerId, "closed")]), TransferSet([ScriptTransfer(addressFromStringValue(secondParty), (amount * 100000000), unit)])) | |
84 | + | else throw("Offer Type Error") | |
85 | + | else throw("Wrong offer status - forbidden") | |
80 | 86 | } | |
81 | 87 | ||
82 | 88 |
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 | + | let offerStatus = getString(this, offerId) | |
50 | 51 | let offerAmount = getInteger(this, (offerId + "_amount")) | |
51 | - | if ((offerType == "buy")) | |
52 | - | then if (!(isDefined(i.payment))) | |
53 | - | then throw("Payment needed for buy offer") | |
54 | - | else { | |
55 | - | let payment = extract(i.payment) | |
56 | - | if (((payment.amount / 100000000) != offerAmount)) | |
57 | - | then throw("Insufficient Payment Amount") | |
58 | - | else WriteSet([DataEntry(offerId, "accepted"), DataEntry((offerId + "_secondParty"), toBase58String(i.caller.bytes))]) | |
59 | - | } | |
60 | - | else if ((offerType == "sell")) | |
61 | - | then WriteSet([DataEntry(offerId, "accepted"), DataEntry((offerId + "_secondParty"), toBase58String(i.caller.bytes))]) | |
62 | - | else throw("Offer Type Error") | |
52 | + | if ((offerStatus == "open")) | |
53 | + | then if ((offerType == "buy")) | |
54 | + | then if (!(isDefined(i.payment))) | |
55 | + | then throw("Payment needed for buy offer") | |
56 | + | else { | |
57 | + | let payment = extract(i.payment) | |
58 | + | if (((payment.amount / 100000000) != offerAmount)) | |
59 | + | then throw("Insufficient Payment Amount") | |
60 | + | else WriteSet([DataEntry(offerId, "accepted"), DataEntry((offerId + "_secondParty"), toBase58String(i.caller.bytes))]) | |
61 | + | } | |
62 | + | else if ((offerType == "sell")) | |
63 | + | then WriteSet([DataEntry(offerId, "accepted"), DataEntry((offerId + "_secondParty"), toBase58String(i.caller.bytes))]) | |
64 | + | else throw("Offer Type Error") | |
65 | + | else throw("Wrong offer status - forbidden") | |
63 | 66 | } | |
64 | 67 | ||
65 | 68 | ||
66 | 69 | ||
67 | 70 | @Callable(i) | |
68 | 71 | func signOffer (offerId) = { | |
72 | + | let offerStatus = getString(this, offerId) | |
69 | 73 | let firstParty = getString(this, (offerId + "_firstParty")) | |
70 | 74 | let secondParty = getStringValue(this, (offerId + "_secondParty")) | |
71 | 75 | let offerType = getString(this, (offerId + "_type")) | |
72 | 76 | let amount = getIntegerValue(this, (offerId + "_amount")) | |
73 | - | if ((firstParty != toBase58String(i.caller.bytes))) | |
74 | - | then throw("User not allowed to sign") | |
75 | - | else if ((offerType == "buy")) | |
76 | - | then ScriptResult(WriteSet([DataEntry(offerId, "closed")]), TransferSet([ScriptTransfer(i.caller, (amount * 100000000), unit)])) | |
77 | - | else if ((offerType == "sell")) | |
78 | - | then ScriptResult(WriteSet([DataEntry(offerId, "closed")]), TransferSet([ScriptTransfer(addressFromStringValue(secondParty), (amount * 100000000), unit)])) | |
79 | - | else throw("Offer Type Error") | |
77 | + | if ((offerStatus == "accepted")) | |
78 | + | then if ((firstParty != toBase58String(i.caller.bytes))) | |
79 | + | then throw("User not allowed to sign") | |
80 | + | else if ((offerType == "buy")) | |
81 | + | then ScriptResult(WriteSet([DataEntry(offerId, "closed")]), TransferSet([ScriptTransfer(i.caller, (amount * 100000000), unit)])) | |
82 | + | else if ((offerType == "sell")) | |
83 | + | then ScriptResult(WriteSet([DataEntry(offerId, "closed")]), TransferSet([ScriptTransfer(addressFromStringValue(secondParty), (amount * 100000000), unit)])) | |
84 | + | else throw("Offer Type Error") | |
85 | + | else throw("Wrong offer status - forbidden") | |
80 | 86 | } | |
81 | 87 | ||
82 | 88 | ||
83 | 89 | ||
84 | 90 | @Callable(i) | |
85 | 91 | func deleteOffer (offerId) = { | |
86 | 92 | let firstParty = getString(this, (offerId + "_firstParty")) | |
87 | 93 | if ((firstParty != toBase58String(i.caller.bytes))) | |
88 | 94 | then throw("User not allowed to sign") | |
89 | 95 | else WriteSet([DataEntry(offerId, "deleted")]) | |
90 | 96 | } | |
91 | 97 | ||
92 | 98 | ||
93 | 99 | @Verifier(tx) | |
94 | 100 | func verify () = match tx { | |
95 | 101 | case s: SetScriptTransaction => | |
96 | 102 | sigVerify(tx.bodyBytes, tx.proofs[0], ownerPublicKey) | |
97 | 103 | case i: InvokeScriptTransaction => | |
98 | 104 | sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
99 | 105 | case _ => | |
100 | 106 | false | |
101 | 107 | } | |
102 | 108 |
github/deemru/w8io/169f3d6 51.96 ms ◑