tx · G7pT9pBJ4LG7FMkT6rUYr3ou9jvsUetXM27REm4w9iXW 3N3nfqFcxXfd3T18V9icDdh58MJ9wQ2k2xx: -0.00600000 Waves 2024.12.14 22:40 [3414697] smart account 3N3nfqFcxXfd3T18V9icDdh58MJ9wQ2k2xx > SELF 0.00000000 Waves
{ "type": 13, "id": "G7pT9pBJ4LG7FMkT6rUYr3ou9jvsUetXM27REm4w9iXW", "fee": 600000, "feeAssetId": null, "timestamp": 1734205235950, "version": 2, "chainId": 84, "sender": "3N3nfqFcxXfd3T18V9icDdh58MJ9wQ2k2xx", "senderPublicKey": "UGqkWsCpv7xRVXkQRXyLd6pWPDtYGXmPip7FxSd1pAu", "proofs": [ "4kS2ZpNCcK9U6phkwEFbPijhRm6PexhN1KTMU65HqVL6TAfemoGsjoW6HFzLPxgvb7HzdLvCRztYnJxWocZGUzKF" ], "script": "base64:BgIWCAISAwoBCBIDCgEBEgMKAQgSAwoBCBcAA1NFUAICX18ABWNoYWluCQDJAQIJAMoBAggFBHRoaXMFYnl0ZXMAAQABABZkZWZhdWx0UmVzdDJBZGRyZXNzU3RyBAckbWF0Y2gwBQVjaGFpbgMJAAACAQFXBQckbWF0Y2gwAiMzUEZ3WXRhOGJpRXozMXpwZUZlNURKSzh3RTV0clNwUVZGOAMJAAACAQFUBQckbWF0Y2gwAiMzTjdVdVlhcjYyNjRQNThGQmhWV0tQUUFoNFl1YTJoZ25ndgkAAgECDVVua25vd24gY2hhaW4BD2dldFN0cmluZ09yRmFpbAIHYWRkcmVzcwNrZXkJARN2YWx1ZU9yRXJyb3JNZXNzYWdlAgkAnQgCBQdhZGRyZXNzBQNrZXkJALkJAgkAzAgCAgptYW5kYXRvcnkgCQDMCAIJAKUIAQUHYWRkcmVzcwkAzAgCAgEuCQDMCAIFA2tleQkAzAgCAg8gaXMgbm90IGRlZmluZWQFA25pbAIAABBJZHhDZmdBY3JlczJEYXBwAAEADUlkeENmZ1dsZ0RhcHAAAgEKa2V5UmVzdENmZwACD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compacted Prev: 8gHkNkGLT1BJLFhdMqDk2sNaz4oEQ82wuM8K85ewycDE Next: C3sLkjhp4nMZh5gCsKeL1pVwqYh25fQmjPwYx8CnUqKM Diff:
Old | New | Differences | |
---|---|---|---|
91 | 91 | if ((O == O)) | |
92 | 92 | then if ((0 >= N)) | |
93 | 93 | then throw("Price should be positive") | |
94 | - | else if ((size(L.payments) != | |
95 | - | then throw("Exactly | |
94 | + | else if ((size(L.payments) != 1)) | |
95 | + | then throw("Exactly 1 payment required") | |
96 | 96 | else { | |
97 | 97 | let P = value(L.payments[0]) | |
98 | 98 | if ((P.amount != 1)) | |
99 | 99 | then throw("NFT token should be attached as 1st payment") | |
100 | 100 | else { | |
101 | - | let Q = value(L.payments[1]) | |
102 | - | let R = valueOrErrorMessage(Q.assetId, "No WAVES payments allowed") | |
103 | - | if ((R != u)) | |
104 | - | then throw("Only WLGOLD payments are accepted as 2nd payment") | |
101 | + | let w = valueOrErrorMessage(P.assetId, "No WAVES payments allowed") | |
102 | + | let Q = value(assetInfo(w)) | |
103 | + | let R = toBase58String(w) | |
104 | + | let z = toString(L.caller) | |
105 | + | if ((Q.issuer != r)) | |
106 | + | then throw("Only WavesLands NFT tokens are accepted") | |
105 | 107 | else { | |
106 | - | let S = (Q.amount - (N / 20)) | |
107 | - | if ((0 > S)) | |
108 | - | then throw("5% fee should be attached as 2nd payment") | |
109 | - | else { | |
110 | - | let T = if ((S > 0)) | |
111 | - | then [ScriptTransfer(L.caller, S, u)] | |
112 | - | else nil | |
113 | - | let w = valueOrErrorMessage(P.assetId, "No WAVES payments allowed") | |
114 | - | let U = value(assetInfo(w)) | |
115 | - | let V = toBase58String(w) | |
116 | - | let z = toString(L.caller) | |
117 | - | if ((U.issuer != r)) | |
118 | - | then throw("Only WavesLands NFT tokens are accepted") | |
119 | - | else { | |
120 | - | let W = y(z) | |
121 | - | let X = valueOrElse(getString(W), "") | |
122 | - | let Y = if ((X != "")) | |
123 | - | then split_51C(value(X), "_") | |
124 | - | else nil | |
125 | - | $Tuple2(([IntegerEntry(x(V), N), StringEntry(v(V), z), StringEntry(W, makeString_11C((Y :+ V), "_"))] ++ T), O) | |
126 | - | } | |
127 | - | } | |
108 | + | let S = y(z) | |
109 | + | let T = valueOrElse(getString(S), "") | |
110 | + | let U = if ((T != "")) | |
111 | + | then split_51C(value(T), "_") | |
112 | + | else nil | |
113 | + | $Tuple2([IntegerEntry(x(R), N), StringEntry(v(R), z), StringEntry(S, makeString_11C((U :+ R), "_"))], O) | |
128 | 114 | } | |
129 | 115 | } | |
130 | 116 | } | |
134 | 120 | ||
135 | 121 | ||
136 | 122 | @Callable(L) | |
137 | - | func cancelSellOrder ( | |
123 | + | func cancelSellOrder (R) = { | |
138 | 124 | let O = K() | |
139 | 125 | if ((O == O)) | |
140 | 126 | then { | |
141 | 127 | let z = toString(L.caller) | |
142 | - | let | |
143 | - | let | |
144 | - | let | |
145 | - | then split_51C(value( | |
128 | + | let S = y(z) | |
129 | + | let T = valueOrElse(getString(S), "") | |
130 | + | let U = if ((T != "")) | |
131 | + | then split_51C(value(T), "_") | |
146 | 132 | else nil | |
147 | - | let p = indexOf( | |
133 | + | let p = indexOf(U, R) | |
148 | 134 | if (!(isDefined(p))) | |
149 | - | then throw(("Your don't have sell order for " + | |
135 | + | then throw(("Your don't have sell order for " + R)) | |
150 | 136 | else { | |
151 | - | let | |
152 | - | then StringEntry( | |
153 | - | else DeleteEntry( | |
154 | - | let N = valueOrErrorMessage(getInteger(x( | |
155 | - | $Tuple2([ | |
137 | + | let V = if ((size(U) > 1)) | |
138 | + | then StringEntry(S, makeString_11C(removeByIndex(U, value(p)), "_")) | |
139 | + | else DeleteEntry(S) | |
140 | + | let N = valueOrErrorMessage(getInteger(x(R)), ("You don't have sell order for " + R)) | |
141 | + | $Tuple2([V, DeleteEntry(v(R)), DeleteEntry(x(R)), ScriptTransfer(L.caller, 1, fromBase58String(R))], O) | |
156 | 142 | } | |
157 | 143 | } | |
158 | 144 | else throw("Strict value is not equal to itself.") | |
161 | 147 | ||
162 | 148 | ||
163 | 149 | @Callable(L) | |
164 | - | func acceptSellOrder ( | |
150 | + | func acceptSellOrder (R) = { | |
165 | 151 | let O = K() | |
166 | 152 | if ((O == O)) | |
167 | 153 | then if ((size(L.payments) != 1)) | |
173 | 159 | else (value(P.assetId) != u)) | |
174 | 160 | then throw("WLGOLD payments only!") | |
175 | 161 | else { | |
176 | - | let N = valueOrErrorMessage(getInteger(x( | |
177 | - | let | |
178 | - | if ((0 > | |
162 | + | let N = valueOrErrorMessage(getInteger(x(R)), (("NFT " + R) + " is not selling")) | |
163 | + | let W = (P.amount - N) | |
164 | + | if ((0 > W)) | |
179 | 165 | then throw((("Payment attached doesn't cover sell price of " + D(N, 8)) + " WLGOLD")) | |
180 | 166 | else { | |
181 | - | let | |
182 | - | then [ScriptTransfer(L.caller, | |
167 | + | let X = if ((W > 0)) | |
168 | + | then [ScriptTransfer(L.caller, W, u)] | |
183 | 169 | else nil | |
184 | - | let | |
185 | - | let | |
186 | - | let | |
187 | - | let | |
188 | - | then split_51C(value( | |
170 | + | let Y = valueOrErrorMessage(getString(v(R)), (("NFT " + R) + " is not selling")) | |
171 | + | let S = y(Y) | |
172 | + | let T = valueOrElse(getString(S), "") | |
173 | + | let U = if ((T != "")) | |
174 | + | then split_51C(value(T), "_") | |
189 | 175 | else nil | |
190 | - | let p = indexOf( | |
176 | + | let p = indexOf(U, R) | |
191 | 177 | if (!(isDefined(p))) | |
192 | - | then throw(("Seller don't have sell order for " + | |
178 | + | then throw(("Seller don't have sell order for " + R)) | |
193 | 179 | else { | |
194 | - | let | |
195 | - | then StringEntry( | |
196 | - | else DeleteEntry( | |
197 | - | let | |
198 | - | let | |
199 | - | let | |
200 | - | $Tuple2(([ | |
180 | + | let V = if ((size(U) > 1)) | |
181 | + | then StringEntry(S, makeString_11C(removeByIndex(U, value(p)), "_")) | |
182 | + | else DeleteEntry(S) | |
183 | + | let Z = (N / 20) | |
184 | + | let aa = (Z / 2) | |
185 | + | let ab = A(invoke(s, "burnWlgold", [(Z - aa)], nil)) | |
186 | + | $Tuple2(([V, DeleteEntry(v(R)), DeleteEntry(x(R)), ScriptTransfer(addressFromStringValue(Y), (N - Z), u), ScriptTransfer(addressFromStringValue(getStringValue(s, J)), aa, u), ScriptTransfer(L.caller, 1, fromBase58String(R))] ++ X), O) | |
201 | 187 | } | |
202 | 188 | } | |
203 | 189 | } |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let a = "__" | |
5 | 5 | ||
6 | 6 | let b = take(drop(this.bytes, 1), 1) | |
7 | 7 | ||
8 | 8 | let c = { | |
9 | 9 | let d = b | |
10 | 10 | if ((base58'2W' == d)) | |
11 | 11 | then "3PFwYta8biEz31zpeFe5DJK8wE5trSpQVF8" | |
12 | 12 | else if ((base58'2T' == d)) | |
13 | 13 | then "3N7UuYar6264P58FBhVWKPQAh4Yua2hgngv" | |
14 | 14 | else throw("Unknown chain") | |
15 | 15 | } | |
16 | 16 | ||
17 | 17 | func e (f,g) = valueOrErrorMessage(getString(f, g), makeString(["mandatory ", toString(f), ".", g, " is not defined"], "")) | |
18 | 18 | ||
19 | 19 | ||
20 | 20 | let h = 1 | |
21 | 21 | ||
22 | 22 | let i = 2 | |
23 | 23 | ||
24 | 24 | func j () = "%s__restConfig" | |
25 | 25 | ||
26 | 26 | ||
27 | 27 | func k () = "%s__rest2Addr" | |
28 | 28 | ||
29 | 29 | ||
30 | 30 | func l (m) = split_4C(e(m, j()), a) | |
31 | 31 | ||
32 | 32 | ||
33 | 33 | func n (o,p) = valueOrErrorMessage(addressFromString(o[p]), ("Rest cfg doesn't contain address at index " + toString(p))) | |
34 | 34 | ||
35 | 35 | ||
36 | 36 | let q = addressFromStringValue(valueOrElse(getString(this, k()), c)) | |
37 | 37 | ||
38 | 38 | let o = l(q) | |
39 | 39 | ||
40 | 40 | let r = n(o, h) | |
41 | 41 | ||
42 | 42 | let s = n(o, i) | |
43 | 43 | ||
44 | 44 | let t = "wlg_assetId" | |
45 | 45 | ||
46 | 46 | let u = valueOrErrorMessage(getBinary(s, t), "WLGOLD is not issued yet") | |
47 | 47 | ||
48 | 48 | func v (w) = ("seller_" + w) | |
49 | 49 | ||
50 | 50 | ||
51 | 51 | func x (w) = ("price_" + w) | |
52 | 52 | ||
53 | 53 | ||
54 | 54 | func y (z) = ("assetIds_" + z) | |
55 | 55 | ||
56 | 56 | ||
57 | 57 | func A (B) = { | |
58 | 58 | let d = B | |
59 | 59 | if ($isInstanceOf(d, "Int")) | |
60 | 60 | then { | |
61 | 61 | let C = d | |
62 | 62 | C | |
63 | 63 | } | |
64 | 64 | else throw("fail to cast into Int") | |
65 | 65 | } | |
66 | 66 | ||
67 | 67 | ||
68 | 68 | func D (E,F) = { | |
69 | 69 | let G = pow(10, 0, F, 0, 0, DOWN) | |
70 | 70 | let H = toString((E % G)) | |
71 | 71 | let I = drop(toString(G), (1 + size(H))) | |
72 | 72 | (((toString((E / G)) + ".") + I) + H) | |
73 | 73 | } | |
74 | 74 | ||
75 | 75 | ||
76 | 76 | let J = "teamAddr" | |
77 | 77 | ||
78 | 78 | func K () = A(reentrantInvoke(r, "saveLastTx", nil, nil)) | |
79 | 79 | ||
80 | 80 | ||
81 | 81 | @Callable(L) | |
82 | 82 | func constructorV1 (M) = if ((L.caller != this)) | |
83 | 83 | then throw("Permission denied") | |
84 | 84 | else [StringEntry(k(), M)] | |
85 | 85 | ||
86 | 86 | ||
87 | 87 | ||
88 | 88 | @Callable(L) | |
89 | 89 | func placeSellOrder (N) = { | |
90 | 90 | let O = K() | |
91 | 91 | if ((O == O)) | |
92 | 92 | then if ((0 >= N)) | |
93 | 93 | then throw("Price should be positive") | |
94 | - | else if ((size(L.payments) != | |
95 | - | then throw("Exactly | |
94 | + | else if ((size(L.payments) != 1)) | |
95 | + | then throw("Exactly 1 payment required") | |
96 | 96 | else { | |
97 | 97 | let P = value(L.payments[0]) | |
98 | 98 | if ((P.amount != 1)) | |
99 | 99 | then throw("NFT token should be attached as 1st payment") | |
100 | 100 | else { | |
101 | - | let Q = value(L.payments[1]) | |
102 | - | let R = valueOrErrorMessage(Q.assetId, "No WAVES payments allowed") | |
103 | - | if ((R != u)) | |
104 | - | then throw("Only WLGOLD payments are accepted as 2nd payment") | |
101 | + | let w = valueOrErrorMessage(P.assetId, "No WAVES payments allowed") | |
102 | + | let Q = value(assetInfo(w)) | |
103 | + | let R = toBase58String(w) | |
104 | + | let z = toString(L.caller) | |
105 | + | if ((Q.issuer != r)) | |
106 | + | then throw("Only WavesLands NFT tokens are accepted") | |
105 | 107 | else { | |
106 | - | let S = (Q.amount - (N / 20)) | |
107 | - | if ((0 > S)) | |
108 | - | then throw("5% fee should be attached as 2nd payment") | |
109 | - | else { | |
110 | - | let T = if ((S > 0)) | |
111 | - | then [ScriptTransfer(L.caller, S, u)] | |
112 | - | else nil | |
113 | - | let w = valueOrErrorMessage(P.assetId, "No WAVES payments allowed") | |
114 | - | let U = value(assetInfo(w)) | |
115 | - | let V = toBase58String(w) | |
116 | - | let z = toString(L.caller) | |
117 | - | if ((U.issuer != r)) | |
118 | - | then throw("Only WavesLands NFT tokens are accepted") | |
119 | - | else { | |
120 | - | let W = y(z) | |
121 | - | let X = valueOrElse(getString(W), "") | |
122 | - | let Y = if ((X != "")) | |
123 | - | then split_51C(value(X), "_") | |
124 | - | else nil | |
125 | - | $Tuple2(([IntegerEntry(x(V), N), StringEntry(v(V), z), StringEntry(W, makeString_11C((Y :+ V), "_"))] ++ T), O) | |
126 | - | } | |
127 | - | } | |
108 | + | let S = y(z) | |
109 | + | let T = valueOrElse(getString(S), "") | |
110 | + | let U = if ((T != "")) | |
111 | + | then split_51C(value(T), "_") | |
112 | + | else nil | |
113 | + | $Tuple2([IntegerEntry(x(R), N), StringEntry(v(R), z), StringEntry(S, makeString_11C((U :+ R), "_"))], O) | |
128 | 114 | } | |
129 | 115 | } | |
130 | 116 | } | |
131 | 117 | else throw("Strict value is not equal to itself.") | |
132 | 118 | } | |
133 | 119 | ||
134 | 120 | ||
135 | 121 | ||
136 | 122 | @Callable(L) | |
137 | - | func cancelSellOrder ( | |
123 | + | func cancelSellOrder (R) = { | |
138 | 124 | let O = K() | |
139 | 125 | if ((O == O)) | |
140 | 126 | then { | |
141 | 127 | let z = toString(L.caller) | |
142 | - | let | |
143 | - | let | |
144 | - | let | |
145 | - | then split_51C(value( | |
128 | + | let S = y(z) | |
129 | + | let T = valueOrElse(getString(S), "") | |
130 | + | let U = if ((T != "")) | |
131 | + | then split_51C(value(T), "_") | |
146 | 132 | else nil | |
147 | - | let p = indexOf( | |
133 | + | let p = indexOf(U, R) | |
148 | 134 | if (!(isDefined(p))) | |
149 | - | then throw(("Your don't have sell order for " + | |
135 | + | then throw(("Your don't have sell order for " + R)) | |
150 | 136 | else { | |
151 | - | let | |
152 | - | then StringEntry( | |
153 | - | else DeleteEntry( | |
154 | - | let N = valueOrErrorMessage(getInteger(x( | |
155 | - | $Tuple2([ | |
137 | + | let V = if ((size(U) > 1)) | |
138 | + | then StringEntry(S, makeString_11C(removeByIndex(U, value(p)), "_")) | |
139 | + | else DeleteEntry(S) | |
140 | + | let N = valueOrErrorMessage(getInteger(x(R)), ("You don't have sell order for " + R)) | |
141 | + | $Tuple2([V, DeleteEntry(v(R)), DeleteEntry(x(R)), ScriptTransfer(L.caller, 1, fromBase58String(R))], O) | |
156 | 142 | } | |
157 | 143 | } | |
158 | 144 | else throw("Strict value is not equal to itself.") | |
159 | 145 | } | |
160 | 146 | ||
161 | 147 | ||
162 | 148 | ||
163 | 149 | @Callable(L) | |
164 | - | func acceptSellOrder ( | |
150 | + | func acceptSellOrder (R) = { | |
165 | 151 | let O = K() | |
166 | 152 | if ((O == O)) | |
167 | 153 | then if ((size(L.payments) != 1)) | |
168 | 154 | then throw("exactly 1 payment must be attached") | |
169 | 155 | else { | |
170 | 156 | let P = L.payments[0] | |
171 | 157 | if (if (!(isDefined(P.assetId))) | |
172 | 158 | then true | |
173 | 159 | else (value(P.assetId) != u)) | |
174 | 160 | then throw("WLGOLD payments only!") | |
175 | 161 | else { | |
176 | - | let N = valueOrErrorMessage(getInteger(x( | |
177 | - | let | |
178 | - | if ((0 > | |
162 | + | let N = valueOrErrorMessage(getInteger(x(R)), (("NFT " + R) + " is not selling")) | |
163 | + | let W = (P.amount - N) | |
164 | + | if ((0 > W)) | |
179 | 165 | then throw((("Payment attached doesn't cover sell price of " + D(N, 8)) + " WLGOLD")) | |
180 | 166 | else { | |
181 | - | let | |
182 | - | then [ScriptTransfer(L.caller, | |
167 | + | let X = if ((W > 0)) | |
168 | + | then [ScriptTransfer(L.caller, W, u)] | |
183 | 169 | else nil | |
184 | - | let | |
185 | - | let | |
186 | - | let | |
187 | - | let | |
188 | - | then split_51C(value( | |
170 | + | let Y = valueOrErrorMessage(getString(v(R)), (("NFT " + R) + " is not selling")) | |
171 | + | let S = y(Y) | |
172 | + | let T = valueOrElse(getString(S), "") | |
173 | + | let U = if ((T != "")) | |
174 | + | then split_51C(value(T), "_") | |
189 | 175 | else nil | |
190 | - | let p = indexOf( | |
176 | + | let p = indexOf(U, R) | |
191 | 177 | if (!(isDefined(p))) | |
192 | - | then throw(("Seller don't have sell order for " + | |
178 | + | then throw(("Seller don't have sell order for " + R)) | |
193 | 179 | else { | |
194 | - | let | |
195 | - | then StringEntry( | |
196 | - | else DeleteEntry( | |
197 | - | let | |
198 | - | let | |
199 | - | let | |
200 | - | $Tuple2(([ | |
180 | + | let V = if ((size(U) > 1)) | |
181 | + | then StringEntry(S, makeString_11C(removeByIndex(U, value(p)), "_")) | |
182 | + | else DeleteEntry(S) | |
183 | + | let Z = (N / 20) | |
184 | + | let aa = (Z / 2) | |
185 | + | let ab = A(invoke(s, "burnWlgold", [(Z - aa)], nil)) | |
186 | + | $Tuple2(([V, DeleteEntry(v(R)), DeleteEntry(x(R)), ScriptTransfer(addressFromStringValue(Y), (N - Z), u), ScriptTransfer(addressFromStringValue(getStringValue(s, J)), aa, u), ScriptTransfer(L.caller, 1, fromBase58String(R))] ++ X), O) | |
201 | 187 | } | |
202 | 188 | } | |
203 | 189 | } | |
204 | 190 | } | |
205 | 191 | else throw("Strict value is not equal to itself.") | |
206 | 192 | } | |
207 | 193 | ||
208 | 194 |
github/deemru/w8io/169f3d6 49.09 ms ◑