tx · 3XNuPqrLxCykM5YCU9L5mZmYiGrmPeEwC9g3UQwpDNG9 3N6LHjfGb6Fgcy7YsVcNxGyPTj49XbQAijq: -0.01300000 Waves 2023.01.26 14:16 [2421866] smart account 3N6LHjfGb6Fgcy7YsVcNxGyPTj49XbQAijq > SELF 0.00000000 Waves
{ "type": 13, "id": "3XNuPqrLxCykM5YCU9L5mZmYiGrmPeEwC9g3UQwpDNG9", "fee": 1300000, "feeAssetId": null, "timestamp": 1674731782857, "version": 1, "sender": "3N6LHjfGb6Fgcy7YsVcNxGyPTj49XbQAijq", "senderPublicKey": "2u2wYYcVBQv43Cc71zkhHPPitkqgg6dqTZ3nUMvYJ1uq", "proofs": [ "AaUKfJfJ29FFiRGXHMWLBTTTM5hjijKp65RFD5fyzjNe789SSBnsuYSGHHhMjZLKnsqohXMzdC3yEWjYXc1UNzM" ], "script": "base64:BgIXCAISBQoDAQgIEgUKAwEICBIDCgEIEgAUAANTRVACAl9fAAhmZWVTY2FsZQkAtgIBAKCNBgEPZ2V0U3RyaW5nT3JGYWlsAQNrZXkJARN2YWx1ZU9yRXJyb3JNZXNzYWdlAgkAnQgCBQR0aGlzBQNrZXkJAKwCAgIVTm8gZGF0YSBmb3IgdGhpcy5rZXk9BQNrZXkADHBvb2xEaXNhYmxlZAkAAgECDVBvb2wgZGlzYWJsZWQADHBvb2xOb3RFeGlzdAkAAgECEVBvb2wgaXMgbm90IGV4aXN0AA5zbGlwcGFnZVRvb0JpZwkAAgECE1NsaXBwYWdlIGlzIHRvbyBiaWcBE2tleU1hbmFnZXJQdWJsaWNLZXkAAhQlc19fbWFuYWdlclB1YmxpY0tleQEaa2V5UGVuZGluZ01hbmFnZXJQdWJsaWNLZXkAAhslc19fcGVuZGluZ01hbmFnZXJQdWJsaWNLZXkBAmZjAAITJXNfX2ZhY3RvcnlDb250cmFjdAAPZmFjdG9yeUNvbnRyYWN0CQERQGV4dHJOYXRpdmUoMTA2MikBCQEPZ2V0U3RyaW5nT3JGYWls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ev: ZbukTgBHH3KsgfZPGV2kZBR3SKvD2zW5wgMHEbddpog Next: 4LDgK1DQT1SAcPwQ1cis7UAysoZz2dFoN5vPHTU98Nek Diff:
Old | New | Differences | |
---|---|---|---|
28 | 28 | func l () = makeString(["%s", "feeLiquidityContractAddress"], a) | |
29 | 29 | ||
30 | 30 | ||
31 | - | func m () = makeString(["% | |
31 | + | func m () = makeString(["%s", "feeLiquidity"], a) | |
32 | 32 | ||
33 | 33 | ||
34 | - | func n () = makeString(["% | |
34 | + | func n () = makeString(["%s", "protocolFee"], a) | |
35 | 35 | ||
36 | 36 | ||
37 | 37 | func o (p) = { | |
92 | 92 | else throw("permission denied") | |
93 | 93 | ||
94 | 94 | ||
95 | + | func C (D) = if ((D == "WAVES")) | |
96 | + | then wavesBalance(this).available | |
97 | + | else assetBalance(this, fromBase58String(D)) | |
98 | + | ||
99 | + | ||
95 | 100 | @Callable(z) | |
96 | - | func constructor (C,D,E,j) = { | |
97 | - | let F = B(z) | |
98 | - | if ((F == F)) | |
99 | - | then [StringEntry(l(), E), IntegerEntry(m(), D), IntegerEntry(n(), C), StringEntry(j(), j)] | |
101 | + | func swapCalulateREADONLY (E,F,G) = { | |
102 | + | let H = value(getInteger(n())) | |
103 | + | let I = fraction(toBigInt(E), toBigInt(H), b) | |
104 | + | let J = fraction(toBigInt(E), toBigInt(H), b) | |
105 | + | let K = (toBigInt(E) - I) | |
106 | + | let L = (K - J) | |
107 | + | let M = invoke(k, "getLpAssetFromPoolAssetsREADONLY", [F, G], nil) | |
108 | + | let N = invoke(k, "getLpAssetFromPoolAssetsREADONLY", [G, F], nil) | |
109 | + | let O = if ((M != unit)) | |
110 | + | then { | |
111 | + | let P = false | |
112 | + | let Q = { | |
113 | + | let R = invoke(k, "getPoolAddressFromLpAssetREADONLY", [M], nil) | |
114 | + | if ($isInstanceOf(R, "Address")) | |
115 | + | then R | |
116 | + | else throw(($getType(R) + " couldn't be cast to Address")) | |
117 | + | } | |
118 | + | $Tuple2(P, Q) | |
119 | + | } | |
120 | + | else if ((N != unit)) | |
121 | + | then { | |
122 | + | let P = true | |
123 | + | let Q = invoke(k, "getPoolAddressFromLpAssetREADONLY", [N], nil) | |
124 | + | $Tuple2(P, Q) | |
125 | + | } | |
126 | + | else f | |
127 | + | let P = O._1 | |
128 | + | let Q = O._2 | |
129 | + | let S = { | |
130 | + | let R = invoke(k, "isPoolOneTokenOperationsDisabledREADONLY", [Q], nil) | |
131 | + | if ($isInstanceOf(R, "Boolean")) | |
132 | + | then R | |
133 | + | else throw(($getType(R) + " couldn't be cast to Boolean")) | |
134 | + | } | |
135 | + | let T = if (S) | |
136 | + | then true | |
137 | + | else e | |
138 | + | if ((T == T)) | |
139 | + | then { | |
140 | + | let U = addressFromStringValue(valueOrElse(Q, "")) | |
141 | + | let V = { | |
142 | + | let R = invoke(U, "calculateAmountOutForSwapREADONLY", [L, P], nil) | |
143 | + | if ($isInstanceOf(R, "Int")) | |
144 | + | then R | |
145 | + | else throw(($getType(R) + " couldn't be cast to Int")) | |
146 | + | } | |
147 | + | $Tuple2(nil, V) | |
148 | + | } | |
100 | 149 | else throw("Strict value is not equal to itself.") | |
101 | 150 | } | |
102 | 151 | ||
103 | 152 | ||
104 | 153 | ||
105 | 154 | @Callable(z) | |
106 | - | func swap (G,H,I) = { | |
107 | - | let J = value(z.payments[0]) | |
108 | - | let K = value(J.assetId) | |
109 | - | let L = value(J.amount) | |
110 | - | let M = value(getInteger(n())) | |
111 | - | let N = fraction(toBigInt(L), toBigInt(M), b) | |
112 | - | let D = fraction(toBigInt(L), toBigInt(M), b) | |
113 | - | let O = (toBigInt(L) - N) | |
114 | - | let P = (O - D) | |
115 | - | let Q = [if ((size(z.payments) == 1)) | |
155 | + | func swap (W,G,X) = { | |
156 | + | let Y = value(z.payments[0]) | |
157 | + | let F = if ((Y.assetId == unit)) | |
158 | + | then toBytes("WAVES") | |
159 | + | else value(Y.assetId) | |
160 | + | let E = value(Y.amount) | |
161 | + | let H = value(getInteger(n())) | |
162 | + | let I = fraction(toBigInt(E), toBigInt(H), b) | |
163 | + | let J = fraction(toBigInt(E), toBigInt(H), b) | |
164 | + | let K = (toBigInt(E) - I) | |
165 | + | let L = (K - J) | |
166 | + | let Z = [if ((size(z.payments) == 1)) | |
116 | 167 | then true | |
117 | 168 | else throw("exactly 1 payment are expected")] | |
118 | - | if (( | |
169 | + | if ((Z == Z)) | |
119 | 170 | then { | |
120 | - | let | |
121 | - | let | |
122 | - | let | |
171 | + | let M = invoke(k, "getLpAssetFromPoolAssetsREADONLY", [F, G], nil) | |
172 | + | let N = invoke(k, "getLpAssetFromPoolAssetsREADONLY", [G, F], nil) | |
173 | + | let aa = if ((M != unit)) | |
123 | 174 | then { | |
124 | - | let U = false | |
125 | - | let V = invoke(k, "getPoolAddressFromLpAssetREADONLY", [R], nil) | |
126 | - | $Tuple2(U, V) | |
175 | + | let P = false | |
176 | + | let Q = { | |
177 | + | let R = invoke(k, "getPoolAddressFromLpAssetREADONLY", [M], nil) | |
178 | + | if ($isInstanceOf(R, "Address")) | |
179 | + | then R | |
180 | + | else throw(($getType(R) + " couldn't be cast to Address")) | |
181 | + | } | |
182 | + | $Tuple2(P, Q) | |
127 | 183 | } | |
128 | - | else if (( | |
184 | + | else if ((N != unit)) | |
129 | 185 | then { | |
130 | - | let | |
131 | - | let | |
132 | - | $Tuple2( | |
186 | + | let P = true | |
187 | + | let Q = invoke(k, "getPoolAddressFromLpAssetREADONLY", [N], nil) | |
188 | + | $Tuple2(P, Q) | |
133 | 189 | } | |
134 | - | else { | |
135 | - | let U = true | |
136 | - | let V = "" | |
137 | - | $Tuple2(U, V) | |
190 | + | else f | |
191 | + | let P = aa._1 | |
192 | + | let Q = aa._2 | |
193 | + | let S = { | |
194 | + | let R = invoke(k, "isPoolOneTokenOperationsDisabledREADONLY", [Q], nil) | |
195 | + | if ($isInstanceOf(R, "Boolean")) | |
196 | + | then R | |
197 | + | else throw(($getType(R) + " couldn't be cast to Boolean")) | |
198 | + | } | |
199 | + | let T = if (S) | |
200 | + | then true | |
201 | + | else e | |
202 | + | if ((T == T)) | |
203 | + | then { | |
204 | + | let U = addressFromStringValue(valueOrElse(Q, "")) | |
205 | + | let V = { | |
206 | + | let R = invoke(U, "calculateAmountOutForSwapAndSendTokens", [L, P, W, X], [AttachedPayment(F, toInt(K))]) | |
207 | + | if ($isInstanceOf(R, "Boolean")) | |
208 | + | then R | |
209 | + | else throw(($getType(R) + " couldn't be cast to Boolean")) | |
138 | 210 | } | |
139 | - | let U = T._1 | |
140 | - | let V = T._2 | |
141 | - | let W = [if ((V != "")) | |
142 | - | then true | |
143 | - | else f] | |
144 | - | if ((W == W)) | |
145 | - | then { | |
146 | - | let X = { | |
147 | - | let Y = invoke(k, "isPoolOneTokenOperationsDisabledREADONLY", [V], nil) | |
148 | - | if ($isInstanceOf(Y, "Boolean")) | |
149 | - | then Y | |
150 | - | else throw(($getType(Y) + " couldn't be cast to Boolean")) | |
151 | - | } | |
152 | - | let F = [if (X) | |
153 | - | then true | |
154 | - | else e] | |
155 | - | if ((F == F)) | |
156 | - | then { | |
157 | - | let Z = addressFromStringValue(valueOrElse(V, "")) | |
158 | - | let aa = invoke(Z, "calculateAmountOutForSwapAndSendTokens", [P, U, G, I], [AttachedPayment(K, toInt(O))]) | |
159 | - | $Tuple2(nil, true) | |
160 | - | } | |
161 | - | else throw("Strict value is not equal to itself.") | |
211 | + | $Tuple2(nil, V) | |
162 | 212 | } | |
163 | 213 | else throw("Strict value is not equal to itself.") | |
164 | 214 | } |
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 = toBigInt(100000) | |
7 | 7 | ||
8 | 8 | func c (d) = valueOrErrorMessage(getString(this, d), ("No data for this.key=" + d)) | |
9 | 9 | ||
10 | 10 | ||
11 | 11 | let e = throw("Pool disabled") | |
12 | 12 | ||
13 | 13 | let f = throw("Pool is not exist") | |
14 | 14 | ||
15 | 15 | let g = throw("Slippage is too big") | |
16 | 16 | ||
17 | 17 | func h () = "%s__managerPublicKey" | |
18 | 18 | ||
19 | 19 | ||
20 | 20 | func i () = "%s__pendingManagerPublicKey" | |
21 | 21 | ||
22 | 22 | ||
23 | 23 | func j () = "%s__factoryContract" | |
24 | 24 | ||
25 | 25 | ||
26 | 26 | let k = addressFromStringValue(c(j())) | |
27 | 27 | ||
28 | 28 | func l () = makeString(["%s", "feeLiquidityContractAddress"], a) | |
29 | 29 | ||
30 | 30 | ||
31 | - | func m () = makeString(["% | |
31 | + | func m () = makeString(["%s", "feeLiquidity"], a) | |
32 | 32 | ||
33 | 33 | ||
34 | - | func n () = makeString(["% | |
34 | + | func n () = makeString(["%s", "protocolFee"], a) | |
35 | 35 | ||
36 | 36 | ||
37 | 37 | func o (p) = { | |
38 | 38 | let q = p | |
39 | 39 | if ($isInstanceOf(q, "Int")) | |
40 | 40 | then { | |
41 | 41 | let r = q | |
42 | 42 | r | |
43 | 43 | } | |
44 | 44 | else throw("fail to cast into Int") | |
45 | 45 | } | |
46 | 46 | ||
47 | 47 | ||
48 | 48 | func s (t,u) = makeString(["%d%d", toString(t), toString(u)], a) | |
49 | 49 | ||
50 | 50 | ||
51 | 51 | func v () = { | |
52 | 52 | let q = getString(h()) | |
53 | 53 | if ($isInstanceOf(q, "String")) | |
54 | 54 | then { | |
55 | 55 | let w = q | |
56 | 56 | fromBase58String(w) | |
57 | 57 | } | |
58 | 58 | else if ($isInstanceOf(q, "Unit")) | |
59 | 59 | then unit | |
60 | 60 | else throw("Match error") | |
61 | 61 | } | |
62 | 62 | ||
63 | 63 | ||
64 | 64 | func x () = { | |
65 | 65 | let q = getString(i()) | |
66 | 66 | if ($isInstanceOf(q, "String")) | |
67 | 67 | then { | |
68 | 68 | let w = q | |
69 | 69 | fromBase58String(w) | |
70 | 70 | } | |
71 | 71 | else if ($isInstanceOf(q, "Unit")) | |
72 | 72 | then unit | |
73 | 73 | else throw("Match error") | |
74 | 74 | } | |
75 | 75 | ||
76 | 76 | ||
77 | 77 | func y (z) = { | |
78 | 78 | let q = v() | |
79 | 79 | if ($isInstanceOf(q, "ByteVector")) | |
80 | 80 | then { | |
81 | 81 | let A = q | |
82 | 82 | (z.callerPublicKey == A) | |
83 | 83 | } | |
84 | 84 | else if ($isInstanceOf(q, "Unit")) | |
85 | 85 | then (z.caller == this) | |
86 | 86 | else throw("Match error") | |
87 | 87 | } | |
88 | 88 | ||
89 | 89 | ||
90 | 90 | func B (z) = if (y(z)) | |
91 | 91 | then true | |
92 | 92 | else throw("permission denied") | |
93 | 93 | ||
94 | 94 | ||
95 | + | func C (D) = if ((D == "WAVES")) | |
96 | + | then wavesBalance(this).available | |
97 | + | else assetBalance(this, fromBase58String(D)) | |
98 | + | ||
99 | + | ||
95 | 100 | @Callable(z) | |
96 | - | func constructor (C,D,E,j) = { | |
97 | - | let F = B(z) | |
98 | - | if ((F == F)) | |
99 | - | then [StringEntry(l(), E), IntegerEntry(m(), D), IntegerEntry(n(), C), StringEntry(j(), j)] | |
101 | + | func swapCalulateREADONLY (E,F,G) = { | |
102 | + | let H = value(getInteger(n())) | |
103 | + | let I = fraction(toBigInt(E), toBigInt(H), b) | |
104 | + | let J = fraction(toBigInt(E), toBigInt(H), b) | |
105 | + | let K = (toBigInt(E) - I) | |
106 | + | let L = (K - J) | |
107 | + | let M = invoke(k, "getLpAssetFromPoolAssetsREADONLY", [F, G], nil) | |
108 | + | let N = invoke(k, "getLpAssetFromPoolAssetsREADONLY", [G, F], nil) | |
109 | + | let O = if ((M != unit)) | |
110 | + | then { | |
111 | + | let P = false | |
112 | + | let Q = { | |
113 | + | let R = invoke(k, "getPoolAddressFromLpAssetREADONLY", [M], nil) | |
114 | + | if ($isInstanceOf(R, "Address")) | |
115 | + | then R | |
116 | + | else throw(($getType(R) + " couldn't be cast to Address")) | |
117 | + | } | |
118 | + | $Tuple2(P, Q) | |
119 | + | } | |
120 | + | else if ((N != unit)) | |
121 | + | then { | |
122 | + | let P = true | |
123 | + | let Q = invoke(k, "getPoolAddressFromLpAssetREADONLY", [N], nil) | |
124 | + | $Tuple2(P, Q) | |
125 | + | } | |
126 | + | else f | |
127 | + | let P = O._1 | |
128 | + | let Q = O._2 | |
129 | + | let S = { | |
130 | + | let R = invoke(k, "isPoolOneTokenOperationsDisabledREADONLY", [Q], nil) | |
131 | + | if ($isInstanceOf(R, "Boolean")) | |
132 | + | then R | |
133 | + | else throw(($getType(R) + " couldn't be cast to Boolean")) | |
134 | + | } | |
135 | + | let T = if (S) | |
136 | + | then true | |
137 | + | else e | |
138 | + | if ((T == T)) | |
139 | + | then { | |
140 | + | let U = addressFromStringValue(valueOrElse(Q, "")) | |
141 | + | let V = { | |
142 | + | let R = invoke(U, "calculateAmountOutForSwapREADONLY", [L, P], nil) | |
143 | + | if ($isInstanceOf(R, "Int")) | |
144 | + | then R | |
145 | + | else throw(($getType(R) + " couldn't be cast to Int")) | |
146 | + | } | |
147 | + | $Tuple2(nil, V) | |
148 | + | } | |
100 | 149 | else throw("Strict value is not equal to itself.") | |
101 | 150 | } | |
102 | 151 | ||
103 | 152 | ||
104 | 153 | ||
105 | 154 | @Callable(z) | |
106 | - | func swap (G,H,I) = { | |
107 | - | let J = value(z.payments[0]) | |
108 | - | let K = value(J.assetId) | |
109 | - | let L = value(J.amount) | |
110 | - | let M = value(getInteger(n())) | |
111 | - | let N = fraction(toBigInt(L), toBigInt(M), b) | |
112 | - | let D = fraction(toBigInt(L), toBigInt(M), b) | |
113 | - | let O = (toBigInt(L) - N) | |
114 | - | let P = (O - D) | |
115 | - | let Q = [if ((size(z.payments) == 1)) | |
155 | + | func swap (W,G,X) = { | |
156 | + | let Y = value(z.payments[0]) | |
157 | + | let F = if ((Y.assetId == unit)) | |
158 | + | then toBytes("WAVES") | |
159 | + | else value(Y.assetId) | |
160 | + | let E = value(Y.amount) | |
161 | + | let H = value(getInteger(n())) | |
162 | + | let I = fraction(toBigInt(E), toBigInt(H), b) | |
163 | + | let J = fraction(toBigInt(E), toBigInt(H), b) | |
164 | + | let K = (toBigInt(E) - I) | |
165 | + | let L = (K - J) | |
166 | + | let Z = [if ((size(z.payments) == 1)) | |
116 | 167 | then true | |
117 | 168 | else throw("exactly 1 payment are expected")] | |
118 | - | if (( | |
169 | + | if ((Z == Z)) | |
119 | 170 | then { | |
120 | - | let | |
121 | - | let | |
122 | - | let | |
171 | + | let M = invoke(k, "getLpAssetFromPoolAssetsREADONLY", [F, G], nil) | |
172 | + | let N = invoke(k, "getLpAssetFromPoolAssetsREADONLY", [G, F], nil) | |
173 | + | let aa = if ((M != unit)) | |
123 | 174 | then { | |
124 | - | let U = false | |
125 | - | let V = invoke(k, "getPoolAddressFromLpAssetREADONLY", [R], nil) | |
126 | - | $Tuple2(U, V) | |
175 | + | let P = false | |
176 | + | let Q = { | |
177 | + | let R = invoke(k, "getPoolAddressFromLpAssetREADONLY", [M], nil) | |
178 | + | if ($isInstanceOf(R, "Address")) | |
179 | + | then R | |
180 | + | else throw(($getType(R) + " couldn't be cast to Address")) | |
181 | + | } | |
182 | + | $Tuple2(P, Q) | |
127 | 183 | } | |
128 | - | else if (( | |
184 | + | else if ((N != unit)) | |
129 | 185 | then { | |
130 | - | let | |
131 | - | let | |
132 | - | $Tuple2( | |
186 | + | let P = true | |
187 | + | let Q = invoke(k, "getPoolAddressFromLpAssetREADONLY", [N], nil) | |
188 | + | $Tuple2(P, Q) | |
133 | 189 | } | |
134 | - | else { | |
135 | - | let U = true | |
136 | - | let V = "" | |
137 | - | $Tuple2(U, V) | |
190 | + | else f | |
191 | + | let P = aa._1 | |
192 | + | let Q = aa._2 | |
193 | + | let S = { | |
194 | + | let R = invoke(k, "isPoolOneTokenOperationsDisabledREADONLY", [Q], nil) | |
195 | + | if ($isInstanceOf(R, "Boolean")) | |
196 | + | then R | |
197 | + | else throw(($getType(R) + " couldn't be cast to Boolean")) | |
198 | + | } | |
199 | + | let T = if (S) | |
200 | + | then true | |
201 | + | else e | |
202 | + | if ((T == T)) | |
203 | + | then { | |
204 | + | let U = addressFromStringValue(valueOrElse(Q, "")) | |
205 | + | let V = { | |
206 | + | let R = invoke(U, "calculateAmountOutForSwapAndSendTokens", [L, P, W, X], [AttachedPayment(F, toInt(K))]) | |
207 | + | if ($isInstanceOf(R, "Boolean")) | |
208 | + | then R | |
209 | + | else throw(($getType(R) + " couldn't be cast to Boolean")) | |
138 | 210 | } | |
139 | - | let U = T._1 | |
140 | - | let V = T._2 | |
141 | - | let W = [if ((V != "")) | |
142 | - | then true | |
143 | - | else f] | |
144 | - | if ((W == W)) | |
145 | - | then { | |
146 | - | let X = { | |
147 | - | let Y = invoke(k, "isPoolOneTokenOperationsDisabledREADONLY", [V], nil) | |
148 | - | if ($isInstanceOf(Y, "Boolean")) | |
149 | - | then Y | |
150 | - | else throw(($getType(Y) + " couldn't be cast to Boolean")) | |
151 | - | } | |
152 | - | let F = [if (X) | |
153 | - | then true | |
154 | - | else e] | |
155 | - | if ((F == F)) | |
156 | - | then { | |
157 | - | let Z = addressFromStringValue(valueOrElse(V, "")) | |
158 | - | let aa = invoke(Z, "calculateAmountOutForSwapAndSendTokens", [P, U, G, I], [AttachedPayment(K, toInt(O))]) | |
159 | - | $Tuple2(nil, true) | |
160 | - | } | |
161 | - | else throw("Strict value is not equal to itself.") | |
211 | + | $Tuple2(nil, V) | |
162 | 212 | } | |
163 | 213 | else throw("Strict value is not equal to itself.") | |
164 | 214 | } | |
165 | 215 | else throw("Strict value is not equal to itself.") | |
166 | 216 | } | |
167 | 217 | ||
168 | 218 | ||
169 | 219 | ||
170 | 220 | @Callable(z) | |
171 | 221 | func setManager (ab) = { | |
172 | 222 | let ac = B(z) | |
173 | 223 | if ((ac == ac)) | |
174 | 224 | then { | |
175 | 225 | let ad = fromBase58String(ab) | |
176 | 226 | if ((ad == ad)) | |
177 | 227 | then [StringEntry(i(), ab)] | |
178 | 228 | else throw("Strict value is not equal to itself.") | |
179 | 229 | } | |
180 | 230 | else throw("Strict value is not equal to itself.") | |
181 | 231 | } | |
182 | 232 | ||
183 | 233 | ||
184 | 234 | ||
185 | 235 | @Callable(z) | |
186 | 236 | func confirmManager () = { | |
187 | 237 | let ae = x() | |
188 | 238 | let af = if (isDefined(ae)) | |
189 | 239 | then true | |
190 | 240 | else throw("no pending manager") | |
191 | 241 | if ((af == af)) | |
192 | 242 | then { | |
193 | 243 | let ag = if ((z.callerPublicKey == value(ae))) | |
194 | 244 | then true | |
195 | 245 | else throw("you are not pending manager") | |
196 | 246 | if ((ag == ag)) | |
197 | 247 | then [StringEntry(h(), toBase58String(value(ae))), DeleteEntry(i())] | |
198 | 248 | else throw("Strict value is not equal to itself.") | |
199 | 249 | } | |
200 | 250 | else throw("Strict value is not equal to itself.") | |
201 | 251 | } | |
202 | 252 | ||
203 | 253 | ||
204 | 254 | @Verifier(ah) | |
205 | 255 | func ai () = { | |
206 | 256 | let aj = { | |
207 | 257 | let q = v() | |
208 | 258 | if ($isInstanceOf(q, "ByteVector")) | |
209 | 259 | then { | |
210 | 260 | let A = q | |
211 | 261 | A | |
212 | 262 | } | |
213 | 263 | else if ($isInstanceOf(q, "Unit")) | |
214 | 264 | then ah.senderPublicKey | |
215 | 265 | else throw("Match error") | |
216 | 266 | } | |
217 | 267 | sigVerify(ah.bodyBytes, ah.proofs[0], aj) | |
218 | 268 | } | |
219 | 269 |
github/deemru/w8io/169f3d6 92.94 ms ◑