tx · 3vs5DtLjRZYsWrTFW1X352ZgjAQbjS5uQNjyWBDRvZCq 3NCTUyjM4SX4hK2kaFTkYv4J2fzcQHtvSjv: -0.05000000 Waves 2020.06.05 17:07 [1030053] smart account 3NCTUyjM4SX4hK2kaFTkYv4J2fzcQHtvSjv > SELF 0.00000000 Waves
{ "type": 13, "id": "3vs5DtLjRZYsWrTFW1X352ZgjAQbjS5uQNjyWBDRvZCq", "fee": 5000000, "feeAssetId": null, "timestamp": 1591366102525, "version": 1, "sender": "3NCTUyjM4SX4hK2kaFTkYv4J2fzcQHtvSjv", "senderPublicKey": "CCEAkP4AnTM1HmKyRheQLmgNxPKACsL5hcH72JUeCiDJ", "proofs": [ "5AJTuxyVTu63MCtVieAXTKzPS9UWebmGz7BYW2dgXvcBQzoovbpWHyhzTVPhPTHxrLGbnodNbKMxhuJypX6KEJnr" ], "script": "base64:AAIDAAAAAAAAABkIARIGCgQIAQEIEgMKAQgSAwoBCBIDCgEIAAAAAwAAAAAOb3duZXJQdWJsaWNLZXkBAAAAIKZQ1ZLQ9/+2Zy378H8jTlGj0XgdM5q46Kfah/hKBO81AQAAAApyYW5kb21pemVyAAAAAQAAAANpbnYEAAAABHJhbmQJAADLAAAAAgkAAMsAAAACCQAAywAAAAIJAADLAAAAAggFAAAAA2ludgAAAA10cmFuc2FjdGlvbklkCAUAAAADaW52AAAAD2NhbGxlclB1YmxpY0tleQgFAAAACWxhc3RCbG9jawAAABNnZW5lcmF0aW9uU2lnbmF0dXJlCQABmgAAAAEIBQAAAAlsYXN0QmxvY2sAAAAJdGltZXN0YW1wCQABmgAAAAEIBQAAAAlsYXN0QmxvY2sAAAAGaGVpZ2h0CQAB9wAAAAEFAAAABHJhbmQBAAAAEW9mZmVyRXJyb3JIYW5kbGVyAAAABQAAAAV0b2tlbgAAAAZhbW91bnQAAAAFcHJpY2UAAAAEdHlwZQAAAANpbnYDAwMDCQEAAAABIQAAAAEJAQAAAAlpc0RlZmluZWQAAAABBQAAAAV0b2t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WxsZXIAAAAFYnl0ZXMJAAACAAAAAQIAAAAYVXNlciBub3QgYWxsb3dlZCB0byBzaWduCQEAAAAIV3JpdGVTZXQAAAABCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACBQAAAAdvZmZlcklkAgAAAAdkZWxldGVkBQAAAANuaWwAAAABAAAAAnR4AQAAAAZ2ZXJpZnkAAAAABAAAAAckbWF0Y2gwBQAAAAJ0eAMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAUU2V0U2NyaXB0VHJhbnNhY3Rpb24EAAAAAXMFAAAAByRtYXRjaDAJAAH0AAAAAwgFAAAAAnR4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAABQAAAA5vd25lclB1YmxpY0tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAXSW52b2tlU2NyaXB0VHJhbnNhY3Rpb24EAAAAAWkFAAAAByRtYXRjaDAJAAH0AAAAAwgFAAAAAnR4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAACAUAAAACdHgAAAAPc2VuZGVyUHVibGljS2V5B2h37A8=", "chainId": 84, "height": 1030053, "spentComplexity": 0 } View: original | compacted Prev: DD82pjNvTvVN7CQCLSCtVrEydxZopuVC4exosqAhBdBK Next: 2otcT2EHUqs5uMKgUfezdb3tb1opCV1spPRK3Vbjf3xR Diff:
Old | New | Differences | |
---|---|---|---|
73 | 73 | if ((firstParty != toBase58String(i.caller.bytes))) | |
74 | 74 | then throw("User not allowed to sign") | |
75 | 75 | else if ((offerType == "buy")) | |
76 | - | then ScriptResult(WriteSet([DataEntry(offerId, "closed")]), TransferSet([ScriptTransfer(i.caller, ( | |
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(i.caller, (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 | 58 | else WriteSet([DataEntry(offerId, "accepted"), DataEntry("_secondParty", toBase58String(i.caller.bytes))]) | |
59 | 59 | } | |
60 | 60 | else if ((offerType == "sell")) | |
61 | 61 | then WriteSet([DataEntry(offerId, "accepted"), DataEntry("_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 | - | then ScriptResult(WriteSet([DataEntry(offerId, "closed")]), TransferSet([ScriptTransfer(i.caller, ( | |
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(i.caller, (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 63.99 ms ◑