tx · 5ZxKaZqKrWFUA9r44xAPgMSpZKfHSVRicfvqsASXkzsK 3NCTUyjM4SX4hK2kaFTkYv4J2fzcQHtvSjv: -0.05000000 Waves 2020.06.21 10:55 [1053078] smart account 3NCTUyjM4SX4hK2kaFTkYv4J2fzcQHtvSjv > SELF 0.00000000 Waves
{ "type": 13, "id": "5ZxKaZqKrWFUA9r44xAPgMSpZKfHSVRicfvqsASXkzsK", "fee": 5000000, "feeAssetId": null, "timestamp": 1592726137345, "version": 1, "sender": "3NCTUyjM4SX4hK2kaFTkYv4J2fzcQHtvSjv", "senderPublicKey": "CCEAkP4AnTM1HmKyRheQLmgNxPKACsL5hcH72JUeCiDJ", "proofs": [ "5raoFQWMk8KnUQFgtWDfYUKqY21cCXzstJyXnXTcSeGszMmrncDFsrtoPaLK1ZcqnWyeyWbEBT53ar2CAmRrYUkW" ], "script": "base64:AAIDAAAAAAAAABoIARIHCgUIAQEICBIDCgEIEgMKAQgSAwoBCAAAAAMAAAAADm93bmVyUHVibGljS2V5AQAAACCmUNWS0Pf/tmct+/B/I05Ro9F4HTOauOin2of4SgTvNQEAAAAKcmFuZG9taXplcgAAAAEAAAADaW52BAAAAARyYW5kCQAAywAAAAIJAADLAAAAAgkAAMsAAAACCQAAywAAAAIIBQAAAANpbnYAAAANdHJhbnNhY3Rpb25JZAgFAAAAA2ludgAAAA9jYWxsZXJQdWJsaWNLZXkIBQAAAAlsYXN0QmxvY2sAAAATZ2VuZXJhdGlvblNpZ25hdHVyZQkAAZoAAAABCAUAAAAJbGFzdEJsb2NrAAAACXRpbWVzdGFtcAkAAZoAAAABCAUAAAAJbGFzdEJsb2NrAAAABmhlaWdodAkAAfcAAAABBQAAAARyYW5kAQAAABFvZmZlckVycm9ySGFuZGxlcgAAAAYAAAAFdG9rZW4AAAAGYW1vdW50AAAABXByaWNlAAAABHR5cGUAAAAFYXNzZXQAAAADaW52AwMDAwkBAAAAASEAAAABCQEAAAAJaXNEZWZpbmVkAAAAAQUAAAAFdG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J5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAFAAAADm93bmVyUHVibGljS2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAABdJbnZva2VTY3JpcHRUcmFuc2FjdGlvbgkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAIBQAAAAJ0eAAAAA9zZW5kZXJQdWJsaWNLZXkHCuzIAQ==", "chainId": 84, "height": 1053078, "spentComplexity": 0 } View: original | compacted Prev: E6EJN2SfxwKA1EZk4EyRKasZp9wjNrAmWFELSfJpshDP Next: hb1KvygDyKWXft2iZRAnAopvqAKgoNxnTCjDR33N6CW Diff:
Old | New | Differences | |
---|---|---|---|
9 | 9 | } | |
10 | 10 | ||
11 | 11 | ||
12 | - | func e (f,g,h,i,c) = if (if (if (if (!(isDefined(f))) | |
12 | + | func e (f,g,h,i,j,c) = if (if (if (if (!(isDefined(f))) | |
13 | 13 | then true | |
14 | 14 | else !(isDefined(g))) | |
15 | 15 | then true | |
25 | 25 | then isDefined(c.payment) | |
26 | 26 | else false) | |
27 | 27 | then { | |
28 | - | let | |
29 | - | if (( | |
28 | + | let k = extract(c.payment) | |
29 | + | if ((k.amount != (g * 100000000))) | |
30 | 30 | then throw("Payment amount insufficient") | |
31 | - | else true | |
31 | + | else if ((j != f)) | |
32 | + | then throw("AssetId invalid") | |
33 | + | else true | |
32 | 34 | } | |
33 | 35 | else true | |
34 | 36 | ||
35 | 37 | ||
36 | - | @Callable( | |
37 | - | func postOffer ( | |
38 | + | @Callable(l) | |
39 | + | func postOffer (m,n,o,p,q) = if (e(m, n, o, p, q, l)) | |
38 | 40 | then { | |
39 | - | let p = toBase64String(b(k)) | |
40 | - | let q = ((((((l + ",") + toString(m)) + ",") + toString(n)) + ",") + o) | |
41 | - | WriteSet([DataEntry(p, "open"), DataEntry((p + "_tokenId"), l), DataEntry((p + "_amount"), m), DataEntry((p + "_price"), n), DataEntry((p + "_type"), o), DataEntry((p + "_firstParty"), toBase58String(k.caller.bytes))]) | |
41 | + | let r = toBase64String(b(l)) | |
42 | + | WriteSet([DataEntry(r, "op en"), DataEntry((r + "_tokenId"), m), DataEntry((r + "_amount"), n), DataEntry((r + "_price"), o), DataEntry((r + "_type"), p), DataEntry((r + "_firstParty"), toBase58String(l.caller.bytes)), DataEntry((r + "_assetId"), q)]) | |
42 | 43 | } | |
43 | 44 | else throw("Conditions not met") | |
44 | 45 | ||
45 | 46 | ||
46 | 47 | ||
47 | - | @Callable(k) | |
48 | - | func acceptOffer (p) = { | |
49 | - | let r = getString(this, (p + "_type")) | |
50 | - | let s = getString(this, p) | |
51 | - | let t = getInteger(this, (p + "_amount")) | |
52 | - | if ((s == "open")) | |
53 | - | then if ((r == "buy")) | |
54 | - | then if (!(isDefined(k.payment))) | |
48 | + | @Callable(l) | |
49 | + | func acceptOffer (r) = { | |
50 | + | let s = getString(this, (r + "_type")) | |
51 | + | let t = getString(this, r) | |
52 | + | let u = getString(this, (r + "_assetId")) | |
53 | + | let v = getInteger(this, (r + "_amount")) | |
54 | + | if ((t == "open")) | |
55 | + | then if ((s == "buy")) | |
56 | + | then if (!(isDefined(l.payment))) | |
55 | 57 | then throw("Payment needed for buy offer") | |
56 | 58 | else { | |
57 | - | let | |
58 | - | if ((( | |
59 | + | let k = extract(l.payment) | |
60 | + | if (((k.amount / 100000000) != v)) | |
59 | 61 | then throw("Insufficient Payment Amount") | |
60 | - | else WriteSet([DataEntry(p, "accepted"), DataEntry((p + "_secondParty"), toBase58String(k.caller.bytes))]) | |
62 | + | else if ((k.assetId != u)) | |
63 | + | then throw("AssetId invalid") | |
64 | + | else WriteSet([DataEntry(r, "accepted"), DataEntry((r + "_secondParty"), toBase58String(l.caller.bytes))]) | |
61 | 65 | } | |
62 | - | else if (( | |
63 | - | then WriteSet([DataEntry( | |
66 | + | else if ((s == "sell")) | |
67 | + | then WriteSet([DataEntry(r, "accepted"), DataEntry((r + "_secondParty"), toBase58String(l.caller.bytes))]) | |
64 | 68 | else throw("Offer Type Error") | |
65 | 69 | else throw("Wrong offer status - forbidden") | |
66 | 70 | } | |
67 | 71 | ||
68 | 72 | ||
69 | 73 | ||
70 | - | @Callable(k) | |
71 | - | func signOffer (p) = { | |
72 | - | let s = getString(this, p) | |
73 | - | let u = getString(this, (p + "_firstParty")) | |
74 | - | let v = getStringValue(this, (p + "_secondParty")) | |
75 | - | let r = getString(this, (p + "_type")) | |
76 | - | let g = getIntegerValue(this, (p + "_amount")) | |
77 | - | if ((s == "accepted")) | |
78 | - | then if ((u != toBase58String(k.caller.bytes))) | |
74 | + | @Callable(l) | |
75 | + | func signOffer (r) = { | |
76 | + | let t = getString(this, r) | |
77 | + | let w = getString(this, (r + "_firstParty")) | |
78 | + | let x = getStringValue(this, (r + "_secondParty")) | |
79 | + | let s = getString(this, (r + "_type")) | |
80 | + | let g = getIntegerValue(this, (r + "_amount")) | |
81 | + | let u = getStringValue(this, (r + "_assetId")) | |
82 | + | if ((t == "accepted")) | |
83 | + | then if ((w != toBase58String(l.caller.bytes))) | |
79 | 84 | then throw("User not allowed to sign") | |
80 | - | else if (( | |
81 | - | then ScriptResult(WriteSet([DataEntry( | |
82 | - | else if (( | |
83 | - | then ScriptResult(WriteSet([DataEntry( | |
85 | + | else if ((s == "buy")) | |
86 | + | then ScriptResult(WriteSet([DataEntry(r, "closed")]), TransferSet([ScriptTransfer(l.caller, (g * 100000000), toBytes(u))])) | |
87 | + | else if ((s == "sell")) | |
88 | + | then ScriptResult(WriteSet([DataEntry(r, "closed")]), TransferSet([ScriptTransfer(addressFromStringValue(x), (g * 100000000), toBytes(u))])) | |
84 | 89 | else throw("Offer Type Error") | |
85 | 90 | else throw("Wrong offer status - forbidden") | |
86 | 91 | } | |
87 | 92 | ||
88 | 93 | ||
89 | 94 | ||
90 | - | @Callable( | |
91 | - | func deleteOffer ( | |
92 | - | let | |
93 | - | if (( | |
95 | + | @Callable(l) | |
96 | + | func deleteOffer (r) = { | |
97 | + | let w = getString(this, (r + "_firstParty")) | |
98 | + | if ((w != toBase58String(l.caller.bytes))) | |
94 | 99 | then throw("User not allowed to sign") | |
95 | - | else WriteSet([DataEntry( | |
100 | + | else WriteSet([DataEntry(r, "deleted")]) | |
96 | 101 | } | |
97 | 102 | ||
98 | 103 | ||
99 | - | @Verifier(w) | |
100 | - | func x () = { | |
101 | - | let y = w | |
102 | - | if ($isInstanceOf(y, "SetScriptTransaction")) | |
103 | - | then { | |
104 | - | let z = y | |
105 | - | sigVerify(w.bodyBytes, w.proofs[0], a) | |
106 | - | } | |
107 | - | else if ($isInstanceOf(y, "InvokeScriptTransaction")) | |
108 | - | then { | |
109 | - | let k = y | |
110 | - | sigVerify(w.bodyBytes, w.proofs[0], w.senderPublicKey) | |
111 | - | } | |
104 | + | @Verifier(y) | |
105 | + | func z () = { | |
106 | + | let A = y | |
107 | + | if ($isInstanceOf(A, "SetScriptTransaction")) | |
108 | + | then sigVerify(y.bodyBytes, y.proofs[0], a) | |
109 | + | else if ($isInstanceOf(A, "InvokeScriptTransaction")) | |
110 | + | then sigVerify(y.bodyBytes, y.proofs[0], y.senderPublicKey) | |
112 | 111 | else false | |
113 | 112 | } | |
114 | 113 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let a = base58'CCEAkP4AnTM1HmKyRheQLmgNxPKACsL5hcH72JUeCiDJ' | |
5 | 5 | ||
6 | 6 | func b (c) = { | |
7 | 7 | let d = ((((c.transactionId + c.callerPublicKey) + lastBlock.generationSignature) + toBytes(lastBlock.timestamp)) + toBytes(lastBlock.height)) | |
8 | 8 | sha256(d) | |
9 | 9 | } | |
10 | 10 | ||
11 | 11 | ||
12 | - | func e (f,g,h,i,c) = if (if (if (if (!(isDefined(f))) | |
12 | + | func e (f,g,h,i,j,c) = if (if (if (if (!(isDefined(f))) | |
13 | 13 | then true | |
14 | 14 | else !(isDefined(g))) | |
15 | 15 | then true | |
16 | 16 | else !(isDefined(h))) | |
17 | 17 | then true | |
18 | 18 | else !(isDefined(i))) | |
19 | 19 | then throw("Invalid Transaction") | |
20 | 20 | else if (if ((i == "sell")) | |
21 | 21 | then !(isDefined(c.payment)) | |
22 | 22 | else false) | |
23 | 23 | then throw("No payment attached") | |
24 | 24 | else if (if ((i == "sell")) | |
25 | 25 | then isDefined(c.payment) | |
26 | 26 | else false) | |
27 | 27 | then { | |
28 | - | let | |
29 | - | if (( | |
28 | + | let k = extract(c.payment) | |
29 | + | if ((k.amount != (g * 100000000))) | |
30 | 30 | then throw("Payment amount insufficient") | |
31 | - | else true | |
31 | + | else if ((j != f)) | |
32 | + | then throw("AssetId invalid") | |
33 | + | else true | |
32 | 34 | } | |
33 | 35 | else true | |
34 | 36 | ||
35 | 37 | ||
36 | - | @Callable( | |
37 | - | func postOffer ( | |
38 | + | @Callable(l) | |
39 | + | func postOffer (m,n,o,p,q) = if (e(m, n, o, p, q, l)) | |
38 | 40 | then { | |
39 | - | let p = toBase64String(b(k)) | |
40 | - | let q = ((((((l + ",") + toString(m)) + ",") + toString(n)) + ",") + o) | |
41 | - | WriteSet([DataEntry(p, "open"), DataEntry((p + "_tokenId"), l), DataEntry((p + "_amount"), m), DataEntry((p + "_price"), n), DataEntry((p + "_type"), o), DataEntry((p + "_firstParty"), toBase58String(k.caller.bytes))]) | |
41 | + | let r = toBase64String(b(l)) | |
42 | + | WriteSet([DataEntry(r, "op en"), DataEntry((r + "_tokenId"), m), DataEntry((r + "_amount"), n), DataEntry((r + "_price"), o), DataEntry((r + "_type"), p), DataEntry((r + "_firstParty"), toBase58String(l.caller.bytes)), DataEntry((r + "_assetId"), q)]) | |
42 | 43 | } | |
43 | 44 | else throw("Conditions not met") | |
44 | 45 | ||
45 | 46 | ||
46 | 47 | ||
47 | - | @Callable(k) | |
48 | - | func acceptOffer (p) = { | |
49 | - | let r = getString(this, (p + "_type")) | |
50 | - | let s = getString(this, p) | |
51 | - | let t = getInteger(this, (p + "_amount")) | |
52 | - | if ((s == "open")) | |
53 | - | then if ((r == "buy")) | |
54 | - | then if (!(isDefined(k.payment))) | |
48 | + | @Callable(l) | |
49 | + | func acceptOffer (r) = { | |
50 | + | let s = getString(this, (r + "_type")) | |
51 | + | let t = getString(this, r) | |
52 | + | let u = getString(this, (r + "_assetId")) | |
53 | + | let v = getInteger(this, (r + "_amount")) | |
54 | + | if ((t == "open")) | |
55 | + | then if ((s == "buy")) | |
56 | + | then if (!(isDefined(l.payment))) | |
55 | 57 | then throw("Payment needed for buy offer") | |
56 | 58 | else { | |
57 | - | let | |
58 | - | if ((( | |
59 | + | let k = extract(l.payment) | |
60 | + | if (((k.amount / 100000000) != v)) | |
59 | 61 | then throw("Insufficient Payment Amount") | |
60 | - | else WriteSet([DataEntry(p, "accepted"), DataEntry((p + "_secondParty"), toBase58String(k.caller.bytes))]) | |
62 | + | else if ((k.assetId != u)) | |
63 | + | then throw("AssetId invalid") | |
64 | + | else WriteSet([DataEntry(r, "accepted"), DataEntry((r + "_secondParty"), toBase58String(l.caller.bytes))]) | |
61 | 65 | } | |
62 | - | else if (( | |
63 | - | then WriteSet([DataEntry( | |
66 | + | else if ((s == "sell")) | |
67 | + | then WriteSet([DataEntry(r, "accepted"), DataEntry((r + "_secondParty"), toBase58String(l.caller.bytes))]) | |
64 | 68 | else throw("Offer Type Error") | |
65 | 69 | else throw("Wrong offer status - forbidden") | |
66 | 70 | } | |
67 | 71 | ||
68 | 72 | ||
69 | 73 | ||
70 | - | @Callable(k) | |
71 | - | func signOffer (p) = { | |
72 | - | let s = getString(this, p) | |
73 | - | let u = getString(this, (p + "_firstParty")) | |
74 | - | let v = getStringValue(this, (p + "_secondParty")) | |
75 | - | let r = getString(this, (p + "_type")) | |
76 | - | let g = getIntegerValue(this, (p + "_amount")) | |
77 | - | if ((s == "accepted")) | |
78 | - | then if ((u != toBase58String(k.caller.bytes))) | |
74 | + | @Callable(l) | |
75 | + | func signOffer (r) = { | |
76 | + | let t = getString(this, r) | |
77 | + | let w = getString(this, (r + "_firstParty")) | |
78 | + | let x = getStringValue(this, (r + "_secondParty")) | |
79 | + | let s = getString(this, (r + "_type")) | |
80 | + | let g = getIntegerValue(this, (r + "_amount")) | |
81 | + | let u = getStringValue(this, (r + "_assetId")) | |
82 | + | if ((t == "accepted")) | |
83 | + | then if ((w != toBase58String(l.caller.bytes))) | |
79 | 84 | then throw("User not allowed to sign") | |
80 | - | else if (( | |
81 | - | then ScriptResult(WriteSet([DataEntry( | |
82 | - | else if (( | |
83 | - | then ScriptResult(WriteSet([DataEntry( | |
85 | + | else if ((s == "buy")) | |
86 | + | then ScriptResult(WriteSet([DataEntry(r, "closed")]), TransferSet([ScriptTransfer(l.caller, (g * 100000000), toBytes(u))])) | |
87 | + | else if ((s == "sell")) | |
88 | + | then ScriptResult(WriteSet([DataEntry(r, "closed")]), TransferSet([ScriptTransfer(addressFromStringValue(x), (g * 100000000), toBytes(u))])) | |
84 | 89 | else throw("Offer Type Error") | |
85 | 90 | else throw("Wrong offer status - forbidden") | |
86 | 91 | } | |
87 | 92 | ||
88 | 93 | ||
89 | 94 | ||
90 | - | @Callable( | |
91 | - | func deleteOffer ( | |
92 | - | let | |
93 | - | if (( | |
95 | + | @Callable(l) | |
96 | + | func deleteOffer (r) = { | |
97 | + | let w = getString(this, (r + "_firstParty")) | |
98 | + | if ((w != toBase58String(l.caller.bytes))) | |
94 | 99 | then throw("User not allowed to sign") | |
95 | - | else WriteSet([DataEntry( | |
100 | + | else WriteSet([DataEntry(r, "deleted")]) | |
96 | 101 | } | |
97 | 102 | ||
98 | 103 | ||
99 | - | @Verifier(w) | |
100 | - | func x () = { | |
101 | - | let y = w | |
102 | - | if ($isInstanceOf(y, "SetScriptTransaction")) | |
103 | - | then { | |
104 | - | let z = y | |
105 | - | sigVerify(w.bodyBytes, w.proofs[0], a) | |
106 | - | } | |
107 | - | else if ($isInstanceOf(y, "InvokeScriptTransaction")) | |
108 | - | then { | |
109 | - | let k = y | |
110 | - | sigVerify(w.bodyBytes, w.proofs[0], w.senderPublicKey) | |
111 | - | } | |
104 | + | @Verifier(y) | |
105 | + | func z () = { | |
106 | + | let A = y | |
107 | + | if ($isInstanceOf(A, "SetScriptTransaction")) | |
108 | + | then sigVerify(y.bodyBytes, y.proofs[0], a) | |
109 | + | else if ($isInstanceOf(A, "InvokeScriptTransaction")) | |
110 | + | then sigVerify(y.bodyBytes, y.proofs[0], y.senderPublicKey) | |
112 | 111 | else false | |
113 | 112 | } | |
114 | 113 |
github/deemru/w8io/169f3d6 39.27 ms ◑