@lombard.finance/sdk 2.0.16 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +105 -6
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +362 -673
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/common/types/types.ts +2 -9
- package/src/provider/Provider.ts +1 -0
- package/src/provider/rpcUrlConfig.ts +3 -3
- package/src/sdk/generateDepositBtcAddress/generateDepositBtcAddress.ts +6 -0
- package/src/sdk/getDepositsByAddress/getDepositsByAddress.ts +2 -0
- package/src/sdk/getUserStakeAndBakeSignature/getUserStakeAndBakeSignature.stories.tsx +1 -1
- package/src/sdk/internalTypes.ts +5 -5
- package/src/sdk/storeStakeAndBakeSignature/storeStakeAndBakeSignature.stories.tsx +27 -95
- package/src/sdk/storeStakeAndBakeSignature/storeStakeAndBakeSignature.ts +1 -1
- package/src/sdk/utils/getChainIdByName.ts +5 -0
- package/src/sdk/utils/getChainNameById.ts +1 -1
- package/src/web3Sdk/basculeAddressConfig.ts +70 -0
- package/src/web3Sdk/claimLBTC/claimLBTC.ts +0 -1
- package/src/web3Sdk/getBasculeDepositStatus/getBasculeDepositStatus.stories.tsx +3 -3
- package/src/web3Sdk/getBasculeDepositStatus/getBasculeDepositStatus.ts +12 -15
- package/src/web3Sdk/index.ts +2 -1
- package/src/web3Sdk/lbtcAddressConfig.ts +4 -4
- package/src/web3Sdk/signStakeAndBake/contracts.ts +29 -1
- package/src/web3Sdk/signStakeAndBake/signStakeAndBake.stories.tsx +25 -100
- package/src/web3Sdk/lbtcOFTAdapterAddressConfig.ts +0 -47
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import * as
|
|
8
|
-
import { initEccLib as
|
|
9
|
-
const
|
|
1
|
+
var Y = Object.defineProperty;
|
|
2
|
+
var Q = (e, t, n) => t in e ? Y(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var D = (e, t, n) => (Q(e, typeof t != "symbol" ? t + "" : t, n), n);
|
|
4
|
+
import g from "axios";
|
|
5
|
+
import _ from "bignumber.js";
|
|
6
|
+
import $, { Web3 as G, utils as S } from "web3";
|
|
7
|
+
import * as ee from "@bitcoin-js/tiny-secp256k1-asmjs";
|
|
8
|
+
import { initEccLib as te, payments as ne, networks as V, address as ae } from "bitcoinjs-lib";
|
|
9
|
+
const c = {
|
|
10
10
|
prod: "prod",
|
|
11
11
|
testnet: "testnet",
|
|
12
12
|
stage: "stage"
|
|
@@ -17,66 +17,64 @@ const l = {
|
|
|
17
17
|
binanceSmartChainTestnet: 97,
|
|
18
18
|
sepolia: 11155111,
|
|
19
19
|
base: 8453,
|
|
20
|
-
|
|
20
|
+
baseSepoliaTestnet: 84532,
|
|
21
21
|
berachainBartioTestnet: 80084,
|
|
22
22
|
corn: 21e6,
|
|
23
23
|
swell: 1923
|
|
24
|
-
},
|
|
24
|
+
}, se = (e) => e === c.prod ? i.ethereum : i.holesky, ie = (e) => e === c.prod ? i.binanceSmartChain : i.binanceSmartChainTestnet, re = (e) => e === c.prod ? i.base : i.baseSepoliaTestnet, P = c.prod, y = "0x0000000000000000000000000000000000000000", oe = {
|
|
25
25
|
baseApiUrl: "https://staging.prod.lombard.finance"
|
|
26
|
-
},
|
|
26
|
+
}, pe = {
|
|
27
27
|
baseApiUrl: "https://gastald-testnet.prod.lombard.finance"
|
|
28
|
-
},
|
|
28
|
+
}, ue = {
|
|
29
29
|
baseApiUrl: "https://mainnet.prod.lombard.finance"
|
|
30
|
-
},
|
|
30
|
+
}, w = (e = P) => {
|
|
31
31
|
switch (e) {
|
|
32
|
-
case
|
|
33
|
-
return
|
|
34
|
-
case
|
|
35
|
-
return
|
|
32
|
+
case c.prod:
|
|
33
|
+
return ue;
|
|
34
|
+
case c.testnet:
|
|
35
|
+
return pe;
|
|
36
36
|
default:
|
|
37
|
-
return
|
|
37
|
+
return oe;
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
|
-
function
|
|
40
|
+
function A(e) {
|
|
41
41
|
return typeof e == "string" ? e : ((n) => {
|
|
42
42
|
var a;
|
|
43
43
|
return ((a = n == null ? void 0 : n.data) == null ? void 0 : a.message) && typeof n.data.message == "string";
|
|
44
|
-
})(e) ? e.data.message : e instanceof Error ?
|
|
44
|
+
})(e) ? e.data.message : e instanceof Error ? ye(e) : de(e);
|
|
45
45
|
}
|
|
46
|
-
function
|
|
46
|
+
function ye(e) {
|
|
47
47
|
return e.response ? e.response.data.message : e.message;
|
|
48
48
|
}
|
|
49
|
-
function
|
|
49
|
+
function de(e) {
|
|
50
50
|
return e != null && e.message ? e.message : "Unknown error";
|
|
51
51
|
}
|
|
52
|
-
const
|
|
52
|
+
const h = {
|
|
53
53
|
eth: "DESTINATION_BLOCKCHAIN_ETHEREUM",
|
|
54
|
+
ethOld: "BLOCKCHAIN_ETHEREUM",
|
|
54
55
|
base: "DESTINATION_BLOCKCHAIN_BASE",
|
|
56
|
+
baseOld: "BLOCKCHAIN_BASE",
|
|
55
57
|
bsc: "DESTINATION_BLOCKCHAIN_BSC",
|
|
56
|
-
|
|
57
|
-
linea: "DESTINATION_BLOCKCHAIN_LINEA",
|
|
58
|
-
zcircuit: "DESTINATION_BLOCKCHAIN_ZIRCUIT",
|
|
59
|
-
scroll: "DESTINATION_BLOCKCHAIN_SCROLL",
|
|
60
|
-
xlayer: "DESTINATION_BLOCKCHAIN_XLAYER"
|
|
58
|
+
bscOld: "BLOCKCHAIN_BSC"
|
|
61
59
|
};
|
|
62
|
-
function
|
|
60
|
+
function O(e) {
|
|
63
61
|
switch (e) {
|
|
64
62
|
case i.ethereum:
|
|
65
63
|
case i.holesky:
|
|
66
64
|
case i.sepolia:
|
|
67
|
-
return
|
|
65
|
+
return h.eth;
|
|
68
66
|
case i.base:
|
|
69
|
-
case i.
|
|
70
|
-
return
|
|
67
|
+
case i.baseSepoliaTestnet:
|
|
68
|
+
return h.base;
|
|
71
69
|
case i.binanceSmartChain:
|
|
72
70
|
case i.binanceSmartChainTestnet:
|
|
73
|
-
return
|
|
71
|
+
return h.bsc;
|
|
74
72
|
default:
|
|
75
73
|
throw new Error(`Unknown chain ID: ${e}`);
|
|
76
74
|
}
|
|
77
75
|
}
|
|
78
|
-
const
|
|
79
|
-
async function
|
|
76
|
+
const le = "sanctioned_address", me = "api/v1/address/generate", ce = "destination address is under sanctions";
|
|
77
|
+
async function it({
|
|
80
78
|
address: e,
|
|
81
79
|
chainId: t,
|
|
82
80
|
signature: n,
|
|
@@ -84,117 +82,124 @@ async function zt({
|
|
|
84
82
|
env: s,
|
|
85
83
|
referrerCode: r,
|
|
86
84
|
partnerId: o,
|
|
87
|
-
captchaToken: p
|
|
85
|
+
captchaToken: p,
|
|
86
|
+
signatureData: u
|
|
88
87
|
}) {
|
|
89
|
-
const { baseApiUrl:
|
|
88
|
+
const { baseApiUrl: f } = w(s), m = O(t), b = {
|
|
90
89
|
to_address: e,
|
|
91
90
|
to_address_signature: n,
|
|
92
|
-
to_chain:
|
|
91
|
+
to_chain: m,
|
|
93
92
|
partner_id: o,
|
|
94
93
|
nonce: 0,
|
|
95
94
|
captcha: p,
|
|
96
95
|
referrer_code: r,
|
|
97
|
-
eip_712_data: a
|
|
96
|
+
eip_712_data: a,
|
|
97
|
+
sb_signature_data: u
|
|
98
98
|
};
|
|
99
99
|
try {
|
|
100
|
-
const { data:
|
|
101
|
-
|
|
100
|
+
const { data: d } = await g.post(
|
|
101
|
+
me,
|
|
102
102
|
b,
|
|
103
|
-
{ baseURL:
|
|
103
|
+
{ baseURL: f }
|
|
104
104
|
);
|
|
105
|
-
return
|
|
106
|
-
} catch (
|
|
107
|
-
const
|
|
108
|
-
if (
|
|
109
|
-
return
|
|
110
|
-
throw new Error(
|
|
105
|
+
return d.address;
|
|
106
|
+
} catch (d) {
|
|
107
|
+
const C = A(d);
|
|
108
|
+
if (be(C))
|
|
109
|
+
return le;
|
|
110
|
+
throw new Error(C);
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
|
-
function
|
|
114
|
-
return !!e.includes(
|
|
113
|
+
function be(e) {
|
|
114
|
+
return !!e.includes(ce);
|
|
115
115
|
}
|
|
116
|
-
const
|
|
117
|
-
async function
|
|
116
|
+
const fe = "api/v1/address";
|
|
117
|
+
async function rt({
|
|
118
118
|
address: e,
|
|
119
119
|
chainId: t,
|
|
120
120
|
env: n,
|
|
121
121
|
partnerId: a
|
|
122
122
|
}) {
|
|
123
|
-
const s = await
|
|
123
|
+
const s = await he({
|
|
124
124
|
address: e,
|
|
125
125
|
chainId: t,
|
|
126
126
|
env: n,
|
|
127
127
|
partnerId: a
|
|
128
|
-
}), r =
|
|
128
|
+
}), r = Te(s);
|
|
129
129
|
if (!r)
|
|
130
130
|
throw new Error("No address");
|
|
131
131
|
return r.btc_address;
|
|
132
132
|
}
|
|
133
|
-
function
|
|
133
|
+
function Te(e) {
|
|
134
134
|
if (!e.length)
|
|
135
135
|
return;
|
|
136
136
|
const t = e.reduce((n, a) => n.created_at < a.created_at ? a : n, e[0]);
|
|
137
137
|
return t.deprecated ? void 0 : t;
|
|
138
138
|
}
|
|
139
|
-
async function
|
|
139
|
+
async function he({
|
|
140
140
|
address: e,
|
|
141
141
|
chainId: t,
|
|
142
142
|
env: n,
|
|
143
143
|
partnerId: a
|
|
144
144
|
}) {
|
|
145
|
-
const { baseApiUrl: s } =
|
|
145
|
+
const { baseApiUrl: s } = w(n), r = O(t), o = {
|
|
146
146
|
to_address: e,
|
|
147
147
|
to_blockchain: r,
|
|
148
148
|
limit: 1,
|
|
149
149
|
offset: 0,
|
|
150
150
|
asc: !1,
|
|
151
151
|
referralId: a
|
|
152
|
-
}, { data: p } = await
|
|
152
|
+
}, { data: p } = await g.get(fe, {
|
|
153
153
|
baseURL: s,
|
|
154
154
|
params: o
|
|
155
155
|
});
|
|
156
156
|
return (p == null ? void 0 : p.addresses) || [];
|
|
157
157
|
}
|
|
158
|
-
const
|
|
159
|
-
function
|
|
160
|
-
return +e /
|
|
158
|
+
const ge = 8, F = 10 ** ge;
|
|
159
|
+
function Z(e) {
|
|
160
|
+
return +e / F;
|
|
161
161
|
}
|
|
162
|
-
function
|
|
163
|
-
return Math.floor(+e *
|
|
162
|
+
function K(e) {
|
|
163
|
+
return Math.floor(+e * F);
|
|
164
164
|
}
|
|
165
|
-
function
|
|
165
|
+
function we(e, t = P) {
|
|
166
166
|
switch (e) {
|
|
167
|
-
case
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
case
|
|
172
|
-
return
|
|
167
|
+
case h.eth:
|
|
168
|
+
case h.ethOld:
|
|
169
|
+
return se(t);
|
|
170
|
+
case h.base:
|
|
171
|
+
case h.baseOld:
|
|
172
|
+
return re(t);
|
|
173
|
+
case h.bsc:
|
|
174
|
+
case h.bscOld:
|
|
175
|
+
return ie(t);
|
|
173
176
|
default:
|
|
174
177
|
return i.ethereum;
|
|
175
178
|
}
|
|
176
179
|
}
|
|
177
|
-
var
|
|
178
|
-
async function
|
|
180
|
+
var Ae = /* @__PURE__ */ ((e) => (e.NOTARIZATION_STATUS_UNSPECIFIED = "NOTARIZATION_STATUS_UNSPECIFIED", e.NOTARIZATION_STATUS_PENDING = "NOTARIZATION_STATUS_PENDING", e.NOTARIZATION_STATUS_SUBMITTED = "NOTARIZATION_STATUS_SUBMITTED", e.NOTARIZATION_STATUS_SESSION_APPROVED = "NOTARIZATION_STATUS_SESSION_APPROVED", e.NOTARIZATION_STATUS_FAILED = "NOTARIZATION_STATUS_FAILED", e))(Ae || {}), ve = /* @__PURE__ */ ((e) => (e.SESSION_STATE_UNSPECIFIED = "SESSION_STATE_UNSPECIFIED", e.SESSION_STATE_PENDING = "SESSION_STATE_PENDING", e.SESSION_STATE_COMPLETED = "SESSION_STATE_COMPLETED", e.SESSION_STATE_EXPIRED = "SESSION_STATE_EXPIRED", e))(ve || {});
|
|
181
|
+
async function ot({
|
|
179
182
|
address: e,
|
|
180
183
|
env: t
|
|
181
184
|
}) {
|
|
182
|
-
const { baseApiUrl: n } =
|
|
185
|
+
const { baseApiUrl: n } = w(t), { data: a } = await g.get(
|
|
183
186
|
`api/v1/address/outputs-v2/${e}`,
|
|
184
187
|
{ baseURL: n }
|
|
185
188
|
);
|
|
186
|
-
return ((a == null ? void 0 : a.outputs) ?? []).map(
|
|
189
|
+
return ((a == null ? void 0 : a.outputs) ?? []).map(Ce(t));
|
|
187
190
|
}
|
|
188
|
-
function
|
|
191
|
+
function Ce(e) {
|
|
189
192
|
return (t) => ({
|
|
190
193
|
txid: t.txid,
|
|
191
194
|
index: t.index ?? 0,
|
|
192
195
|
blockHeight: t.block_height ? Number(t.block_height) : void 0,
|
|
193
196
|
blockTime: t.block_time ? Number(t.block_time) : void 0,
|
|
194
|
-
value: new
|
|
197
|
+
value: new _(Z(t.value)),
|
|
195
198
|
address: t.address,
|
|
196
|
-
chainId:
|
|
199
|
+
chainId: we(t.to_chain, e),
|
|
197
200
|
claimedTxId: t.claim_tx,
|
|
201
|
+
// todo: return claiming tx from the API when it's available
|
|
202
|
+
isClaimed: !!t.claim_tx,
|
|
198
203
|
rawPayload: t.raw_payload,
|
|
199
204
|
signature: t.proof,
|
|
200
205
|
isRestricted: !!t.sanctioned,
|
|
@@ -205,26 +210,26 @@ function je(e) {
|
|
|
205
210
|
sessionState: t.session_state
|
|
206
211
|
});
|
|
207
212
|
}
|
|
208
|
-
const
|
|
209
|
-
async function
|
|
213
|
+
const Se = 2e-4;
|
|
214
|
+
async function pt({
|
|
210
215
|
env: e,
|
|
211
216
|
chainId: t = i.ethereum,
|
|
212
217
|
amount: n = 1
|
|
213
218
|
}) {
|
|
214
|
-
const { baseApiUrl: a } =
|
|
219
|
+
const { baseApiUrl: a } = w(e), s = O(t), { data: r } = await g.get(
|
|
215
220
|
`api/v1/exchange/rate/${s}`,
|
|
216
221
|
{ baseURL: a, params: { amount: n } }
|
|
217
|
-
), o = new
|
|
222
|
+
), o = new _(Se).multipliedBy(F).toFixed();
|
|
218
223
|
return { exchangeRate: +r.amount_out, minAmount: +o };
|
|
219
224
|
}
|
|
220
|
-
async function
|
|
225
|
+
async function ut({
|
|
221
226
|
address: e,
|
|
222
227
|
chainId: t,
|
|
223
228
|
env: n
|
|
224
229
|
}) {
|
|
225
|
-
const { baseApiUrl: a } =
|
|
230
|
+
const { baseApiUrl: a } = w(n);
|
|
226
231
|
try {
|
|
227
|
-
const { data: s } = await
|
|
232
|
+
const { data: s } = await g.get(
|
|
228
233
|
`${a}/api/v1/claimer/get-user-signature`,
|
|
229
234
|
{
|
|
230
235
|
params: {
|
|
@@ -239,18 +244,18 @@ async function en({
|
|
|
239
244
|
isDelayed: s == null ? void 0 : s.is_delayed
|
|
240
245
|
};
|
|
241
246
|
} catch (s) {
|
|
242
|
-
const r =
|
|
247
|
+
const r = A(s);
|
|
243
248
|
throw new Error(r);
|
|
244
249
|
}
|
|
245
250
|
}
|
|
246
|
-
async function
|
|
251
|
+
async function yt({
|
|
247
252
|
userDestinationAddress: e,
|
|
248
253
|
chainId: t,
|
|
249
254
|
env: n
|
|
250
255
|
}) {
|
|
251
|
-
const { baseApiUrl: a } =
|
|
256
|
+
const { baseApiUrl: a } = w(n);
|
|
252
257
|
try {
|
|
253
|
-
const { data: s } = await
|
|
258
|
+
const { data: s } = await g.get(
|
|
254
259
|
`${a}/api/v1/claimer/get-user-stake-and-bake-signature`,
|
|
255
260
|
{
|
|
256
261
|
params: {
|
|
@@ -267,21 +272,21 @@ async function tn({
|
|
|
267
272
|
chainId: s.chain_id
|
|
268
273
|
};
|
|
269
274
|
} catch (s) {
|
|
270
|
-
const r =
|
|
275
|
+
const r = A(s);
|
|
271
276
|
throw new Error(
|
|
272
277
|
`Failed to get user stake and bake signature: ${r}`
|
|
273
278
|
);
|
|
274
279
|
}
|
|
275
280
|
}
|
|
276
|
-
async function
|
|
281
|
+
async function dt({
|
|
277
282
|
signature: e,
|
|
278
283
|
typedData: t,
|
|
279
284
|
address: n,
|
|
280
285
|
env: a
|
|
281
286
|
}) {
|
|
282
|
-
const { baseApiUrl: s } =
|
|
287
|
+
const { baseApiUrl: s } = w(a);
|
|
283
288
|
try {
|
|
284
|
-
const { data: r } = await
|
|
289
|
+
const { data: r } = await g.post(
|
|
285
290
|
`${s}/api/v1/claimer/save-user-signature`,
|
|
286
291
|
null,
|
|
287
292
|
{
|
|
@@ -294,18 +299,18 @@ async function nn({
|
|
|
294
299
|
);
|
|
295
300
|
return r.status;
|
|
296
301
|
} catch (r) {
|
|
297
|
-
const o =
|
|
302
|
+
const o = A(r);
|
|
298
303
|
throw new Error(o);
|
|
299
304
|
}
|
|
300
305
|
}
|
|
301
|
-
async function
|
|
306
|
+
async function lt({
|
|
302
307
|
signature: e,
|
|
303
308
|
typedData: t,
|
|
304
309
|
env: n
|
|
305
310
|
}) {
|
|
306
|
-
const { baseApiUrl: a } =
|
|
311
|
+
const { baseApiUrl: a } = w(n);
|
|
307
312
|
try {
|
|
308
|
-
const { data: s } = await
|
|
313
|
+
const { data: s } = await g.post(
|
|
309
314
|
`${a}/api/v1/claimer/save-stake-and-bake-signature`,
|
|
310
315
|
null,
|
|
311
316
|
{
|
|
@@ -317,20 +322,20 @@ async function an({
|
|
|
317
322
|
);
|
|
318
323
|
return s.status;
|
|
319
324
|
} catch (s) {
|
|
320
|
-
const r =
|
|
325
|
+
const r = A(s);
|
|
321
326
|
throw new Error(r);
|
|
322
327
|
}
|
|
323
328
|
}
|
|
324
|
-
const
|
|
329
|
+
const R = {
|
|
325
330
|
[i.ethereum]: "https://rpc.ankr.com/eth",
|
|
326
331
|
[i.holesky]: "https://rpc.ankr.com/eth_holesky",
|
|
327
332
|
[i.sepolia]: "https://rpc.ankr.com/eth_sepolia",
|
|
328
333
|
[i.base]: "https://rpc.ankr.com/base",
|
|
329
|
-
[i.
|
|
330
|
-
[i.binanceSmartChain]: "https://
|
|
331
|
-
[i.binanceSmartChainTestnet]: "https://
|
|
334
|
+
[i.baseSepoliaTestnet]: "https://rpc.ankr.com/base_sepolia",
|
|
335
|
+
[i.binanceSmartChain]: "https://bsc-dataseed.bnbchain.org",
|
|
336
|
+
[i.binanceSmartChainTestnet]: "https://bsc-testnet-dataseed.bnbchain.org"
|
|
332
337
|
};
|
|
333
|
-
async function
|
|
338
|
+
async function Ee(e) {
|
|
334
339
|
const n = await (await fetch(e, {
|
|
335
340
|
method: "POST",
|
|
336
341
|
headers: {
|
|
@@ -342,15 +347,15 @@ async function qe(e) {
|
|
|
342
347
|
method: "eth_maxPriorityFeePerGas",
|
|
343
348
|
params: []
|
|
344
349
|
})
|
|
345
|
-
})).json(), a =
|
|
346
|
-
return new
|
|
350
|
+
})).json(), a = $.utils.hexToNumber(n == null ? void 0 : n.result);
|
|
351
|
+
return new _(Number(a));
|
|
347
352
|
}
|
|
348
|
-
const
|
|
349
|
-
class
|
|
353
|
+
const De = 2, _e = 25e3;
|
|
354
|
+
class N {
|
|
350
355
|
constructor({ chainId: t, rpcUrlConfig: n }) {
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
this.chainId = t, this.rpcConfig = { ...
|
|
356
|
+
D(this, "chainId");
|
|
357
|
+
D(this, "rpcConfig");
|
|
358
|
+
this.chainId = t, this.rpcConfig = { ...R, ...n };
|
|
354
359
|
}
|
|
355
360
|
/**
|
|
356
361
|
* Returns web3 instance for read operations.
|
|
@@ -359,7 +364,7 @@ class z {
|
|
|
359
364
|
* @returns {Web3} Web3 instance.
|
|
360
365
|
*/
|
|
361
366
|
getReadWeb3() {
|
|
362
|
-
const t = this.getRpcUrl(), n = new
|
|
367
|
+
const t = this.getRpcUrl(), n = new G(), a = new G.providers.HttpProvider(t);
|
|
363
368
|
return n.setProvider(a), n;
|
|
364
369
|
}
|
|
365
370
|
/**
|
|
@@ -387,10 +392,10 @@ class z {
|
|
|
387
392
|
async getMaxFees() {
|
|
388
393
|
const t = this.getReadWeb3(), n = this.getRpcUrl(), [a, s] = await Promise.all([
|
|
389
394
|
t.eth.getBlock("latest"),
|
|
390
|
-
|
|
395
|
+
Ee(n)
|
|
391
396
|
]);
|
|
392
397
|
return !(a != null && a.baseFeePerGas) && typeof (a == null ? void 0 : a.baseFeePerGas) != "bigint" ? {} : {
|
|
393
|
-
maxFeePerGas: +new
|
|
398
|
+
maxFeePerGas: +new _(a.baseFeePerGas.toString(10)).multipliedBy(De).plus(s),
|
|
394
399
|
maxPriorityFeePerGas: +s
|
|
395
400
|
};
|
|
396
401
|
}
|
|
@@ -402,8 +407,8 @@ class z {
|
|
|
402
407
|
*/
|
|
403
408
|
async getSafeGasPriceWei() {
|
|
404
409
|
const t = await this.getReadWeb3().eth.getGasPrice();
|
|
405
|
-
return new
|
|
406
|
-
|
|
410
|
+
return new _(t.toString(10)).plus(
|
|
411
|
+
_e
|
|
407
412
|
);
|
|
408
413
|
}
|
|
409
414
|
/**
|
|
@@ -419,13 +424,13 @@ class z {
|
|
|
419
424
|
return new a.eth.Contract(t, n);
|
|
420
425
|
}
|
|
421
426
|
}
|
|
422
|
-
class
|
|
427
|
+
class E extends N {
|
|
423
428
|
constructor({ provider: n, account: a, chainId: s, rpcUrlConfig: r }) {
|
|
424
429
|
super({ chainId: s, rpcUrlConfig: r });
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
this.web3 = new
|
|
430
|
+
D(this, "web3");
|
|
431
|
+
D(this, "account");
|
|
432
|
+
D(this, "rpcConfig", R);
|
|
433
|
+
this.web3 = new $(n), this.account = a, this.chainId = s, this.rpcConfig = { ...R, ...r };
|
|
429
434
|
}
|
|
430
435
|
/**
|
|
431
436
|
* Signs a message using the current provider and account.
|
|
@@ -451,61 +456,61 @@ class C extends z {
|
|
|
451
456
|
*/
|
|
452
457
|
async sendTransactionAsync(n, a, s) {
|
|
453
458
|
const { chainId: r, web3: o } = this, p = this.getReadWeb3(), {
|
|
454
|
-
data:
|
|
455
|
-
estimate:
|
|
456
|
-
estimateFee:
|
|
457
|
-
extendedGasLimit:
|
|
458
|
-
gasLimit:
|
|
459
|
-
value:
|
|
460
|
-
gasLimitMultiplier:
|
|
459
|
+
data: u,
|
|
460
|
+
estimate: f = !1,
|
|
461
|
+
estimateFee: m = !1,
|
|
462
|
+
extendedGasLimit: b,
|
|
463
|
+
gasLimit: d = "0",
|
|
464
|
+
value: C = "0",
|
|
465
|
+
gasLimitMultiplier: x = 1
|
|
461
466
|
} = s;
|
|
462
|
-
let { nonce:
|
|
463
|
-
|
|
464
|
-
const
|
|
467
|
+
let { nonce: I } = s;
|
|
468
|
+
I || (I = await p.eth.getTransactionCount(n)), console.log(`Nonce: ${I}`);
|
|
469
|
+
const l = {
|
|
465
470
|
from: n,
|
|
466
471
|
to: a,
|
|
467
|
-
value: S.numberToHex(
|
|
468
|
-
data:
|
|
469
|
-
nonce:
|
|
472
|
+
value: S.numberToHex(C),
|
|
473
|
+
data: u,
|
|
474
|
+
nonce: I,
|
|
470
475
|
chainId: S.numberToHex(r)
|
|
471
476
|
};
|
|
472
|
-
if (
|
|
477
|
+
if (f)
|
|
473
478
|
try {
|
|
474
|
-
const
|
|
475
|
-
Number(
|
|
479
|
+
const T = await p.eth.estimateGas(l), M = Math.round(
|
|
480
|
+
Number(T) * x
|
|
476
481
|
);
|
|
477
|
-
|
|
478
|
-
} catch (
|
|
482
|
+
b ? l.gas = S.numberToHex(M + b) : l.gas = S.numberToHex(M);
|
|
483
|
+
} catch (T) {
|
|
479
484
|
throw new Error(
|
|
480
|
-
|
|
485
|
+
T.message ?? "Failed to estimate gas limit for transaction."
|
|
481
486
|
);
|
|
482
487
|
}
|
|
483
488
|
else
|
|
484
|
-
|
|
485
|
-
const { maxFeePerGas:
|
|
486
|
-
if (
|
|
487
|
-
const
|
|
488
|
-
|
|
489
|
+
l.gas = S.numberToHex(d);
|
|
490
|
+
const { maxFeePerGas: U, maxPriorityFeePerGas: B } = m ? await this.getMaxFees().catch(() => s) : s;
|
|
491
|
+
if (B !== void 0 && (l.maxPriorityFeePerGas = S.numberToHex(B)), U !== void 0 && (l.maxFeePerGas = S.numberToHex(U)), !l.maxFeePerGas && !l.maxPriorityFeePerGas) {
|
|
492
|
+
const T = await this.getSafeGasPriceWei();
|
|
493
|
+
l.gasPrice = T.toString(10);
|
|
489
494
|
}
|
|
490
|
-
if (!
|
|
491
|
-
const
|
|
492
|
-
|
|
495
|
+
if (!l.maxFeePerGas && !l.maxPriorityFeePerGas) {
|
|
496
|
+
const T = await this.getSafeGasPriceWei();
|
|
497
|
+
l.gasPrice = T.toString(10);
|
|
493
498
|
}
|
|
494
|
-
return console.log("Sending transaction via Web3: ",
|
|
495
|
-
const
|
|
496
|
-
|
|
497
|
-
console.log(`Just signed transaction has is: ${
|
|
498
|
-
receiptPromise:
|
|
499
|
-
transactionHash:
|
|
499
|
+
return console.log("Sending transaction via Web3: ", l), new Promise((T, M) => {
|
|
500
|
+
const L = o.eth.sendTransaction(l);
|
|
501
|
+
L.once("transactionHash", async (W) => {
|
|
502
|
+
console.log(`Just signed transaction has is: ${W}`), T({
|
|
503
|
+
receiptPromise: L,
|
|
504
|
+
transactionHash: W
|
|
500
505
|
});
|
|
501
|
-
}).catch(
|
|
506
|
+
}).catch(M);
|
|
502
507
|
});
|
|
503
508
|
}
|
|
504
509
|
createContract(n, a) {
|
|
505
510
|
return new this.web3.eth.Contract(n, a);
|
|
506
511
|
}
|
|
507
512
|
}
|
|
508
|
-
function
|
|
513
|
+
function k(e) {
|
|
509
514
|
switch (e) {
|
|
510
515
|
case i.ethereum:
|
|
511
516
|
return 1.3;
|
|
@@ -516,55 +521,54 @@ function ee(e) {
|
|
|
516
521
|
return 1.3;
|
|
517
522
|
}
|
|
518
523
|
}
|
|
519
|
-
function
|
|
524
|
+
function z(e) {
|
|
520
525
|
return Object.values(i).includes(e);
|
|
521
526
|
}
|
|
522
|
-
const
|
|
527
|
+
const xe = {
|
|
523
528
|
[i.holesky]: "0xED7bfd5C1790576105Af4649817f6d35A75CD818",
|
|
524
|
-
[i.ethereum]:
|
|
529
|
+
[i.ethereum]: y,
|
|
525
530
|
[i.binanceSmartChainTestnet]: "0x731eFa688F3679688cf60A3993b8658138953ED6",
|
|
526
|
-
[i.binanceSmartChain]:
|
|
531
|
+
[i.binanceSmartChain]: y,
|
|
527
532
|
[i.sepolia]: "0xc47e4b3124597fdf8dd07843d4a7052f2ee80c30",
|
|
528
|
-
[i.base]:
|
|
529
|
-
|
|
530
|
-
[i.baseTestnet]: u,
|
|
533
|
+
[i.base]: y,
|
|
534
|
+
[i.baseSepoliaTestnet]: "0x731eFa688F3679688cf60A3993b8658138953ED6",
|
|
531
535
|
[i.berachainBartioTestnet]: "0xc47e4b3124597FDF8DD07843D4a7052F2eE80C30",
|
|
532
|
-
[i.corn]:
|
|
533
|
-
[i.swell]:
|
|
534
|
-
},
|
|
536
|
+
[i.corn]: y,
|
|
537
|
+
[i.swell]: y
|
|
538
|
+
}, Ie = {
|
|
535
539
|
[i.holesky]: "0x38A13AB20D15ffbE5A7312d2336EF1552580a4E2",
|
|
536
|
-
[i.ethereum]:
|
|
540
|
+
[i.ethereum]: y,
|
|
537
541
|
[i.binanceSmartChainTestnet]: "0x107Fc7d90484534704dD2A9e24c7BD45DB4dD1B5",
|
|
538
|
-
[i.binanceSmartChain]:
|
|
542
|
+
[i.binanceSmartChain]: y,
|
|
539
543
|
[i.sepolia]: "0xc47e4b3124597fdf8dd07843d4a7052f2ee80c30",
|
|
540
|
-
[i.base]:
|
|
541
|
-
[i.
|
|
544
|
+
[i.base]: y,
|
|
545
|
+
[i.baseSepoliaTestnet]: y,
|
|
542
546
|
[i.berachainBartioTestnet]: "0xc47e4b3124597FDF8DD07843D4a7052F2eE80C30",
|
|
543
|
-
[i.corn]:
|
|
544
|
-
[i.swell]:
|
|
545
|
-
},
|
|
547
|
+
[i.corn]: y,
|
|
548
|
+
[i.swell]: y
|
|
549
|
+
}, Me = {
|
|
546
550
|
[i.ethereum]: "0x8236a87084f8b84306f72007f36f2618a5634494",
|
|
547
|
-
[i.holesky]:
|
|
548
|
-
[i.sepolia]:
|
|
549
|
-
[i.binanceSmartChainTestnet]:
|
|
551
|
+
[i.holesky]: y,
|
|
552
|
+
[i.sepolia]: y,
|
|
553
|
+
[i.binanceSmartChainTestnet]: y,
|
|
550
554
|
[i.binanceSmartChain]: "0xecAc9C5F704e954931349Da37F60E39f515c11c1",
|
|
551
555
|
[i.base]: "0xecAc9C5F704e954931349Da37F60E39f515c11c1",
|
|
552
|
-
[i.
|
|
553
|
-
[i.berachainBartioTestnet]:
|
|
556
|
+
[i.baseSepoliaTestnet]: y,
|
|
557
|
+
[i.berachainBartioTestnet]: y,
|
|
554
558
|
[i.corn]: "0xecAc9C5F704e954931349Da37F60E39f515c11c1",
|
|
555
559
|
[i.swell]: "0xecAc9C5F704e954931349Da37F60E39f515c11c1"
|
|
556
560
|
};
|
|
557
|
-
function
|
|
561
|
+
function q(e = P) {
|
|
558
562
|
switch (e) {
|
|
559
|
-
case
|
|
560
|
-
return
|
|
561
|
-
case
|
|
562
|
-
return
|
|
563
|
+
case c.prod:
|
|
564
|
+
return Me;
|
|
565
|
+
case c.testnet:
|
|
566
|
+
return Ie;
|
|
563
567
|
default:
|
|
564
|
-
return
|
|
568
|
+
return xe;
|
|
565
569
|
}
|
|
566
570
|
}
|
|
567
|
-
const
|
|
571
|
+
const Re = [
|
|
568
572
|
{
|
|
569
573
|
constant: !0,
|
|
570
574
|
inputs: [],
|
|
@@ -785,7 +789,7 @@ const Qe = [
|
|
|
785
789
|
name: "Transfer",
|
|
786
790
|
type: "event"
|
|
787
791
|
}
|
|
788
|
-
],
|
|
792
|
+
], Ne = [
|
|
789
793
|
{
|
|
790
794
|
inputs: [],
|
|
791
795
|
stateMutability: "nonpayable",
|
|
@@ -2545,7 +2549,7 @@ const Qe = [
|
|
|
2545
2549
|
stateMutability: "nonpayable",
|
|
2546
2550
|
type: "function"
|
|
2547
2551
|
}
|
|
2548
|
-
],
|
|
2552
|
+
], Pe = [
|
|
2549
2553
|
{
|
|
2550
2554
|
inputs: [
|
|
2551
2555
|
{
|
|
@@ -3395,31 +3399,31 @@ const Qe = [
|
|
|
3395
3399
|
type: "function"
|
|
3396
3400
|
}
|
|
3397
3401
|
];
|
|
3398
|
-
function
|
|
3402
|
+
function Oe(e) {
|
|
3399
3403
|
switch (e) {
|
|
3400
3404
|
case "LBTC":
|
|
3401
|
-
return
|
|
3405
|
+
return Ne;
|
|
3402
3406
|
default:
|
|
3403
|
-
return
|
|
3407
|
+
return Re;
|
|
3404
3408
|
}
|
|
3405
3409
|
}
|
|
3406
|
-
function
|
|
3407
|
-
const n =
|
|
3408
|
-
if (!
|
|
3410
|
+
function v(e, t) {
|
|
3411
|
+
const n = q(t), { chainId: a } = e;
|
|
3412
|
+
if (!z(a))
|
|
3409
3413
|
throw new Error(`This chain ${a} is not supported`);
|
|
3410
3414
|
const s = n[a];
|
|
3411
3415
|
if (!s)
|
|
3412
3416
|
throw new Error(`Token address for chain ${a} is not defined`);
|
|
3413
|
-
const r =
|
|
3417
|
+
const r = Oe("LBTC"), o = e.createContract(r, s);
|
|
3414
3418
|
return o.options.address || (o.options.address = s), o;
|
|
3415
3419
|
}
|
|
3416
|
-
function
|
|
3420
|
+
function mt({
|
|
3417
3421
|
spender: e,
|
|
3418
3422
|
amount: t,
|
|
3419
3423
|
env: n,
|
|
3420
3424
|
...a
|
|
3421
3425
|
}) {
|
|
3422
|
-
const s = new
|
|
3426
|
+
const s = new E(a), r = v(s, n), o = K(t), p = r.methods.approve(e, o);
|
|
3423
3427
|
return s.sendTransactionAsync(
|
|
3424
3428
|
s.account,
|
|
3425
3429
|
r.options.address,
|
|
@@ -3427,453 +3431,111 @@ function sn({
|
|
|
3427
3431
|
data: p.encodeABI(),
|
|
3428
3432
|
estimate: !0,
|
|
3429
3433
|
estimateFee: !0,
|
|
3430
|
-
gasLimitMultiplier:
|
|
3434
|
+
gasLimitMultiplier: k(s.chainId)
|
|
3431
3435
|
}
|
|
3432
3436
|
);
|
|
3433
3437
|
}
|
|
3434
|
-
const
|
|
3435
|
-
async function
|
|
3438
|
+
const Fe = "insufficient funds", ke = "Insufficient funds for transfer. Make sure you have enough ETH to cover the gas cost.", H = (e) => e.startsWith("0x") ? e : "0x" + e;
|
|
3439
|
+
async function ct({
|
|
3436
3440
|
data: e,
|
|
3437
3441
|
proofSignature: t,
|
|
3438
3442
|
env: n,
|
|
3439
3443
|
...a
|
|
3440
3444
|
}) {
|
|
3441
|
-
const s = new
|
|
3445
|
+
const s = new E(a), r = v(s, n), o = r.methods.mint(H(e), H(t));
|
|
3442
3446
|
try {
|
|
3443
3447
|
return await s.sendTransactionAsync(
|
|
3444
3448
|
s.account,
|
|
3445
3449
|
r.options.address,
|
|
3446
3450
|
{
|
|
3447
3451
|
data: o.encodeABI(),
|
|
3448
|
-
// TODO: add getGasOptions from the app for bsc here
|
|
3449
3452
|
estimate: !0,
|
|
3450
3453
|
estimateFee: !0,
|
|
3451
|
-
gasLimitMultiplier:
|
|
3454
|
+
gasLimitMultiplier: k(s.chainId)
|
|
3452
3455
|
}
|
|
3453
3456
|
);
|
|
3454
3457
|
} catch (p) {
|
|
3455
3458
|
console.log("error", p);
|
|
3456
|
-
const
|
|
3457
|
-
throw
|
|
3458
|
-
}
|
|
3459
|
-
}
|
|
3460
|
-
const it = 208, rt = 4001, ot = 4100, pt = 4200, ut = 4900, dt = 4901, U = -32700, B = -32600, F = -32601, L = -32602, k = -32603, G = -32e3, W = -32001, V = -32002, $ = -32003, H = -32004, j = -32005, J = -32006;
|
|
3461
|
-
class fe extends Error {
|
|
3462
|
-
constructor(t, n) {
|
|
3463
|
-
super(t), Array.isArray(n) ? this.cause = new X(n) : this.cause = n, this.name = this.constructor.name, typeof Error.captureStackTrace == "function" ? Error.captureStackTrace(new.target.constructor) : this.stack = new Error().stack;
|
|
3464
|
-
}
|
|
3465
|
-
/**
|
|
3466
|
-
* @deprecated Use the `cause` property instead.
|
|
3467
|
-
*/
|
|
3468
|
-
get innerError() {
|
|
3469
|
-
return this.cause instanceof X ? this.cause.errors : this.cause;
|
|
3470
|
-
}
|
|
3471
|
-
/**
|
|
3472
|
-
* @deprecated Use the `cause` property instead.
|
|
3473
|
-
*/
|
|
3474
|
-
set innerError(t) {
|
|
3475
|
-
Array.isArray(t) ? this.cause = new X(t) : this.cause = t;
|
|
3476
|
-
}
|
|
3477
|
-
static convertToString(t, n = !1) {
|
|
3478
|
-
if (t == null)
|
|
3479
|
-
return "undefined";
|
|
3480
|
-
const a = JSON.stringify(t, (s, r) => typeof r == "bigint" ? r.toString() : r);
|
|
3481
|
-
return n && ["bigint", "string"].includes(typeof t) ? a.replace(/['\\"]+/g, "") : a;
|
|
3482
|
-
}
|
|
3483
|
-
toJSON() {
|
|
3484
|
-
return {
|
|
3485
|
-
name: this.name,
|
|
3486
|
-
code: this.code,
|
|
3487
|
-
message: this.message,
|
|
3488
|
-
cause: this.cause,
|
|
3489
|
-
// deprecated
|
|
3490
|
-
innerError: this.cause
|
|
3491
|
-
};
|
|
3459
|
+
const u = A(p);
|
|
3460
|
+
throw u.includes(Fe) ? new Error(ke) : new Error(u);
|
|
3492
3461
|
}
|
|
3493
3462
|
}
|
|
3494
|
-
|
|
3495
|
-
constructor(t) {
|
|
3496
|
-
super(`Multiple errors occurred: [${t.map((n) => n.message).join("], [")}]`), this.code = it, this.errors = t;
|
|
3497
|
-
}
|
|
3498
|
-
}
|
|
3499
|
-
const yt = "An Rpc error has occured with a code of *code*", f = {
|
|
3500
|
-
// EIP-1474 & JSON RPC 2.0
|
|
3501
|
-
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1474.md
|
|
3502
|
-
[U]: {
|
|
3503
|
-
message: "Parse error",
|
|
3504
|
-
description: "Invalid JSON"
|
|
3505
|
-
},
|
|
3506
|
-
[B]: {
|
|
3507
|
-
message: "Invalid request",
|
|
3508
|
-
description: "JSON is not a valid request object "
|
|
3509
|
-
},
|
|
3510
|
-
[F]: {
|
|
3511
|
-
message: "Method not found",
|
|
3512
|
-
description: "Method does not exist "
|
|
3513
|
-
},
|
|
3514
|
-
[L]: {
|
|
3515
|
-
message: "Invalid params",
|
|
3516
|
-
description: "Invalid method parameters"
|
|
3517
|
-
},
|
|
3518
|
-
[k]: {
|
|
3519
|
-
message: "Internal error",
|
|
3520
|
-
description: "Internal JSON-RPC error"
|
|
3521
|
-
},
|
|
3522
|
-
[G]: {
|
|
3523
|
-
message: "Invalid input",
|
|
3524
|
-
description: "Missing or invalid parameters"
|
|
3525
|
-
},
|
|
3526
|
-
[W]: {
|
|
3527
|
-
message: "Resource not found",
|
|
3528
|
-
description: "Requested resource not found"
|
|
3529
|
-
},
|
|
3530
|
-
[V]: {
|
|
3531
|
-
message: "Resource unavailable",
|
|
3532
|
-
description: "Requested resource not available"
|
|
3533
|
-
},
|
|
3534
|
-
[$]: {
|
|
3535
|
-
message: "Transaction rejected",
|
|
3536
|
-
description: "Transaction creation failed"
|
|
3537
|
-
},
|
|
3538
|
-
[H]: {
|
|
3539
|
-
message: "Method not supported",
|
|
3540
|
-
description: "Method is not implemented"
|
|
3541
|
-
},
|
|
3542
|
-
[j]: {
|
|
3543
|
-
message: "Limit exceeded",
|
|
3544
|
-
description: "Request exceeds defined limit"
|
|
3545
|
-
},
|
|
3546
|
-
[J]: {
|
|
3547
|
-
message: "JSON-RPC version not supported",
|
|
3548
|
-
description: "Version of JSON-RPC protocol is not supported"
|
|
3549
|
-
},
|
|
3550
|
-
// EIP-1193
|
|
3551
|
-
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1193.md#provider-errors
|
|
3552
|
-
[rt]: {
|
|
3553
|
-
name: "User Rejected Request",
|
|
3554
|
-
message: "The user rejected the request."
|
|
3555
|
-
},
|
|
3556
|
-
[ot]: {
|
|
3557
|
-
name: "Unauthorized",
|
|
3558
|
-
message: "The requested method and/or account has not been authorized by the user."
|
|
3559
|
-
},
|
|
3560
|
-
[pt]: {
|
|
3561
|
-
name: "Unsupported Method",
|
|
3562
|
-
message: "The Provider does not support the requested method."
|
|
3563
|
-
},
|
|
3564
|
-
[ut]: {
|
|
3565
|
-
name: "Disconnected",
|
|
3566
|
-
message: "The Provider is disconnected from all chains."
|
|
3567
|
-
},
|
|
3568
|
-
[dt]: {
|
|
3569
|
-
name: "Chain Disconnected",
|
|
3570
|
-
message: "The Provider is not connected to the requested chain."
|
|
3571
|
-
},
|
|
3572
|
-
// EIP-1193 - CloseEvent
|
|
3573
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent/code
|
|
3574
|
-
"0-999": {
|
|
3575
|
-
name: "",
|
|
3576
|
-
message: "Not used."
|
|
3577
|
-
},
|
|
3578
|
-
1e3: {
|
|
3579
|
-
name: "Normal Closure",
|
|
3580
|
-
message: "The connection successfully completed the purpose for which it was created."
|
|
3581
|
-
},
|
|
3582
|
-
1001: {
|
|
3583
|
-
name: "Going Away",
|
|
3584
|
-
message: "The endpoint is going away, either because of a server failure or because the browser is navigating away from the page that opened the connection."
|
|
3585
|
-
},
|
|
3586
|
-
1002: {
|
|
3587
|
-
name: "Protocol error",
|
|
3588
|
-
message: "The endpoint is terminating the connection due to a protocol error."
|
|
3589
|
-
},
|
|
3590
|
-
1003: {
|
|
3591
|
-
name: "Unsupported Data",
|
|
3592
|
-
message: "The connection is being terminated because the endpoint received data of a type it cannot accept. (For example, a text-only endpoint received binary data.)"
|
|
3593
|
-
},
|
|
3594
|
-
1004: {
|
|
3595
|
-
name: "Reserved",
|
|
3596
|
-
message: "Reserved. A meaning might be defined in the future."
|
|
3597
|
-
},
|
|
3598
|
-
1005: {
|
|
3599
|
-
name: "No Status Rcvd",
|
|
3600
|
-
message: "Reserved. Indicates that no status code was provided even though one was expected."
|
|
3601
|
-
},
|
|
3602
|
-
1006: {
|
|
3603
|
-
name: "Abnormal Closure",
|
|
3604
|
-
message: "Reserved. Indicates that a connection was closed abnormally (that is, with no close frame being sent) when a status code is expected."
|
|
3605
|
-
},
|
|
3606
|
-
1007: {
|
|
3607
|
-
name: "Invalid frame payload data",
|
|
3608
|
-
message: "The endpoint is terminating the connection because a message was received that contained inconsistent data (e.g., non-UTF-8 data within a text message)."
|
|
3609
|
-
},
|
|
3610
|
-
1008: {
|
|
3611
|
-
name: "Policy Violation",
|
|
3612
|
-
message: "The endpoint is terminating the connection because it received a message that violates its policy. This is a generic status code, used when codes 1003 and 1009 are not suitable."
|
|
3613
|
-
},
|
|
3614
|
-
1009: {
|
|
3615
|
-
name: "Message Too Big",
|
|
3616
|
-
message: "The endpoint is terminating the connection because a data frame was received that is too large."
|
|
3617
|
-
},
|
|
3618
|
-
1010: {
|
|
3619
|
-
name: "Mandatory Ext.",
|
|
3620
|
-
message: "The client is terminating the connection because it expected the server to negotiate one or more extension, but the server didn't."
|
|
3621
|
-
},
|
|
3622
|
-
1011: {
|
|
3623
|
-
name: "Internal Error",
|
|
3624
|
-
message: "The server is terminating the connection because it encountered an unexpected condition that prevented it from fulfilling the request."
|
|
3625
|
-
},
|
|
3626
|
-
1012: {
|
|
3627
|
-
name: "Service Restart",
|
|
3628
|
-
message: "The server is terminating the connection because it is restarting."
|
|
3629
|
-
},
|
|
3630
|
-
1013: {
|
|
3631
|
-
name: "Try Again Later",
|
|
3632
|
-
message: "The server is terminating the connection due to a temporary condition, e.g. it is overloaded and is casting off some of its clients."
|
|
3633
|
-
},
|
|
3634
|
-
1014: {
|
|
3635
|
-
name: "Bad Gateway",
|
|
3636
|
-
message: "The server was acting as a gateway or proxy and received an invalid response from the upstream server. This is similar to 502 HTTP Status Code."
|
|
3637
|
-
},
|
|
3638
|
-
1015: {
|
|
3639
|
-
name: "TLS handshake",
|
|
3640
|
-
message: "Reserved. Indicates that the connection was closed due to a failure to perform a TLS handshake (e.g., the server certificate can't be verified)."
|
|
3641
|
-
},
|
|
3642
|
-
"1016-2999": {
|
|
3643
|
-
name: "",
|
|
3644
|
-
message: "For definition by future revisions of the WebSocket Protocol specification, and for definition by extension specifications."
|
|
3645
|
-
},
|
|
3646
|
-
"3000-3999": {
|
|
3647
|
-
name: "",
|
|
3648
|
-
message: "For use by libraries, frameworks, and applications. These status codes are registered directly with IANA. The interpretation of these codes is undefined by the WebSocket protocol."
|
|
3649
|
-
},
|
|
3650
|
-
"4000-4999": {
|
|
3651
|
-
name: "",
|
|
3652
|
-
message: "For private use, and thus can't be registered. Such codes can be used by prior agreements between WebSocket applications. The interpretation of these codes is undefined by the WebSocket protocol."
|
|
3653
|
-
}
|
|
3654
|
-
};
|
|
3655
|
-
class T extends fe {
|
|
3656
|
-
constructor(t, n) {
|
|
3657
|
-
super(n ?? yt.replace("*code*", t.error.code.toString())), this.code = t.error.code, this.id = t.id, this.jsonrpc = t.jsonrpc, this.jsonRpcError = t.error;
|
|
3658
|
-
}
|
|
3659
|
-
toJSON() {
|
|
3660
|
-
return Object.assign(Object.assign({}, super.toJSON()), { error: this.jsonRpcError, id: this.id, jsonRpc: this.jsonrpc });
|
|
3661
|
-
}
|
|
3662
|
-
}
|
|
3663
|
-
class ct extends T {
|
|
3664
|
-
constructor(t) {
|
|
3665
|
-
super(t, f[U].message), this.code = U;
|
|
3666
|
-
}
|
|
3667
|
-
}
|
|
3668
|
-
class lt extends T {
|
|
3669
|
-
constructor(t) {
|
|
3670
|
-
super(t, f[B].message), this.code = B;
|
|
3671
|
-
}
|
|
3672
|
-
}
|
|
3673
|
-
class mt extends T {
|
|
3674
|
-
constructor(t) {
|
|
3675
|
-
super(t, f[F].message), this.code = F;
|
|
3676
|
-
}
|
|
3677
|
-
}
|
|
3678
|
-
class bt extends T {
|
|
3679
|
-
constructor(t) {
|
|
3680
|
-
super(t, f[L].message), this.code = L;
|
|
3681
|
-
}
|
|
3682
|
-
}
|
|
3683
|
-
class ft extends T {
|
|
3684
|
-
constructor(t) {
|
|
3685
|
-
super(t, f[k].message), this.code = k;
|
|
3686
|
-
}
|
|
3687
|
-
}
|
|
3688
|
-
class Tt extends T {
|
|
3689
|
-
constructor(t) {
|
|
3690
|
-
super(t, f[G].message), this.code = G;
|
|
3691
|
-
}
|
|
3692
|
-
}
|
|
3693
|
-
class ht extends T {
|
|
3694
|
-
constructor(t) {
|
|
3695
|
-
super(t, f[H].message), this.code = H;
|
|
3696
|
-
}
|
|
3697
|
-
}
|
|
3698
|
-
class gt extends T {
|
|
3699
|
-
constructor(t) {
|
|
3700
|
-
super(t, f[V].message), this.code = V;
|
|
3701
|
-
}
|
|
3702
|
-
}
|
|
3703
|
-
class wt extends T {
|
|
3704
|
-
constructor(t) {
|
|
3705
|
-
super(t, f[W].message), this.code = W;
|
|
3706
|
-
}
|
|
3707
|
-
}
|
|
3708
|
-
class Et extends T {
|
|
3709
|
-
constructor(t) {
|
|
3710
|
-
super(t, f[J].message), this.code = J;
|
|
3711
|
-
}
|
|
3712
|
-
}
|
|
3713
|
-
class At extends T {
|
|
3714
|
-
constructor(t) {
|
|
3715
|
-
super(t, f[$].message), this.code = $;
|
|
3716
|
-
}
|
|
3717
|
-
}
|
|
3718
|
-
class vt extends T {
|
|
3719
|
-
constructor(t) {
|
|
3720
|
-
super(t, f[j].message), this.code = j;
|
|
3721
|
-
}
|
|
3722
|
-
}
|
|
3723
|
-
const h = /* @__PURE__ */ new Map();
|
|
3724
|
-
h.set(U, { error: ct });
|
|
3725
|
-
h.set(B, {
|
|
3726
|
-
error: lt
|
|
3727
|
-
});
|
|
3728
|
-
h.set(F, {
|
|
3729
|
-
error: mt
|
|
3730
|
-
});
|
|
3731
|
-
h.set(L, { error: bt });
|
|
3732
|
-
h.set(k, { error: ft });
|
|
3733
|
-
h.set(G, { error: Tt });
|
|
3734
|
-
h.set(H, {
|
|
3735
|
-
error: ht
|
|
3736
|
-
});
|
|
3737
|
-
h.set(V, {
|
|
3738
|
-
error: gt
|
|
3739
|
-
});
|
|
3740
|
-
h.set($, {
|
|
3741
|
-
error: At
|
|
3742
|
-
});
|
|
3743
|
-
h.set(W, {
|
|
3744
|
-
error: wt
|
|
3745
|
-
});
|
|
3746
|
-
h.set(J, {
|
|
3747
|
-
error: Et
|
|
3748
|
-
});
|
|
3749
|
-
h.set(j, { error: vt });
|
|
3750
|
-
const Rt = (e) => typeof e == "string" && /^((-)?0x[0-9a-f]+|(0x))$/i.test(e);
|
|
3751
|
-
var q;
|
|
3752
|
-
(function(e) {
|
|
3753
|
-
e.NUMBER = "NUMBER_NUMBER", e.HEX = "NUMBER_HEX", e.STR = "NUMBER_STR", e.BIGINT = "NUMBER_BIGINT";
|
|
3754
|
-
})(q || (q = {}));
|
|
3755
|
-
var Z;
|
|
3756
|
-
(function(e) {
|
|
3757
|
-
e.HEX = "BYTES_HEX", e.UINT8ARRAY = "BYTES_UINT8ARRAY";
|
|
3758
|
-
})(Z || (Z = {}));
|
|
3759
|
-
q.BIGINT, Z.HEX;
|
|
3760
|
-
q.HEX, Z.HEX;
|
|
3761
|
-
var ue;
|
|
3762
|
-
(function(e) {
|
|
3763
|
-
e.EARLIEST = "earliest", e.LATEST = "latest", e.PENDING = "pending", e.SAFE = "safe", e.FINALIZED = "finalized";
|
|
3764
|
-
})(ue || (ue = {}));
|
|
3765
|
-
var de;
|
|
3766
|
-
(function(e) {
|
|
3767
|
-
e.chainstart = "chainstart", e.frontier = "frontier", e.homestead = "homestead", e.dao = "dao", e.tangerineWhistle = "tangerineWhistle", e.spuriousDragon = "spuriousDragon", e.byzantium = "byzantium", e.constantinople = "constantinople", e.petersburg = "petersburg", e.istanbul = "istanbul", e.muirGlacier = "muirGlacier", e.berlin = "berlin", e.london = "london", e.altair = "altair", e.arrowGlacier = "arrowGlacier", e.grayGlacier = "grayGlacier", e.bellatrix = "bellatrix", e.merge = "merge", e.capella = "capella", e.shanghai = "shanghai";
|
|
3768
|
-
})(de || (de = {}));
|
|
3769
|
-
function St(e, t) {
|
|
3463
|
+
function Ue(e, t) {
|
|
3770
3464
|
if (!t)
|
|
3771
3465
|
throw new Error("The address for bascule module is not defined");
|
|
3772
|
-
const n = e.createContract(
|
|
3466
|
+
const n = e.createContract(Pe, t);
|
|
3773
3467
|
return n.options.address || (n.options.address = t), n;
|
|
3774
3468
|
}
|
|
3775
|
-
const
|
|
3776
|
-
var
|
|
3777
|
-
async function
|
|
3778
|
-
|
|
3469
|
+
const Be = "No deposit ID provided. Please provide a deposit ID as an argument.";
|
|
3470
|
+
var Le = /* @__PURE__ */ ((e) => (e[e.UNREPORTED = 0] = "UNREPORTED", e[e.REPORTED = 1] = "REPORTED", e[e.WITHDRAWN = 2] = "WITHDRAWN", e))(Le || {});
|
|
3471
|
+
async function bt({
|
|
3472
|
+
rawPayload: e,
|
|
3779
3473
|
env: t,
|
|
3780
3474
|
...n
|
|
3781
3475
|
}) {
|
|
3782
3476
|
if (!e)
|
|
3783
|
-
throw new Error(
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
const a = new C(n), r = await R(a, t).methods.Bascule().call();
|
|
3787
|
-
if (r === u)
|
|
3477
|
+
throw new Error(Be);
|
|
3478
|
+
const a = new E(n), r = await v(a, t).methods.Bascule().call();
|
|
3479
|
+
if (r === y)
|
|
3788
3480
|
return 1;
|
|
3789
|
-
const o =
|
|
3481
|
+
const o = Ue(a, r);
|
|
3790
3482
|
try {
|
|
3791
|
-
const p =
|
|
3792
|
-
|
|
3483
|
+
const p = a.getReadWeb3().utils.keccak256(
|
|
3484
|
+
Buffer.from(e.slice(8), "hex")
|
|
3485
|
+
), u = await o.methods.depositHistory(p).call();
|
|
3486
|
+
return Number(u);
|
|
3793
3487
|
} catch (p) {
|
|
3794
|
-
const
|
|
3795
|
-
throw new Error(
|
|
3488
|
+
const u = A(p);
|
|
3489
|
+
throw new Error(u);
|
|
3796
3490
|
}
|
|
3797
3491
|
}
|
|
3798
|
-
const
|
|
3492
|
+
const We = [
|
|
3799
3493
|
i.ethereum,
|
|
3800
3494
|
i.base,
|
|
3801
3495
|
i.binanceSmartChain
|
|
3802
|
-
],
|
|
3803
|
-
function
|
|
3804
|
-
if (!
|
|
3496
|
+
], j = (e) => We.includes(e) ? c.prod : c.stage;
|
|
3497
|
+
function J(e, t) {
|
|
3498
|
+
if (!z(e))
|
|
3805
3499
|
throw new Error(`This chain ${e} is not supported`);
|
|
3806
|
-
const n = t ? { [e]: t } :
|
|
3500
|
+
const n = t ? { [e]: t } : R;
|
|
3807
3501
|
if (!n[e])
|
|
3808
3502
|
throw new Error(`RPC URL for chainId ${e} not found`);
|
|
3809
3503
|
return n;
|
|
3810
3504
|
}
|
|
3811
|
-
async function
|
|
3505
|
+
async function ft({
|
|
3812
3506
|
chainId: e,
|
|
3813
3507
|
rpcUrl: t
|
|
3814
3508
|
}) {
|
|
3815
|
-
const n =
|
|
3816
|
-
return new
|
|
3509
|
+
const n = J(e, t), a = new N({ chainId: e, rpcUrlConfig: n }), s = j(e), o = await v(a, s).methods.getMintFee().call();
|
|
3510
|
+
return new _(Z(o.toString(10)));
|
|
3817
3511
|
}
|
|
3818
|
-
async function
|
|
3512
|
+
async function Tt({
|
|
3819
3513
|
env: e,
|
|
3820
3514
|
rpcUrl: t,
|
|
3821
3515
|
chainId: n
|
|
3822
3516
|
}) {
|
|
3823
|
-
const a = { [n]: t }, s = new
|
|
3824
|
-
return (await
|
|
3517
|
+
const a = { [n]: t }, s = new N({ chainId: n, rpcUrlConfig: a });
|
|
3518
|
+
return (await v(s, e).methods.totalSupply().call()).toString();
|
|
3825
3519
|
}
|
|
3826
|
-
async function
|
|
3520
|
+
async function Ge({
|
|
3827
3521
|
owner: e,
|
|
3828
3522
|
rpcUrl: t,
|
|
3829
3523
|
chainId: n
|
|
3830
3524
|
}) {
|
|
3831
|
-
const a =
|
|
3525
|
+
const a = J(n, t), s = new N({ chainId: n, rpcUrlConfig: a }), r = j(n), o = v(s, r);
|
|
3832
3526
|
try {
|
|
3833
3527
|
return (await o.methods.nonces(e).call()).toString();
|
|
3834
3528
|
} catch (p) {
|
|
3835
|
-
const
|
|
3836
|
-
throw new Error(
|
|
3529
|
+
const u = A(p);
|
|
3530
|
+
throw new Error(u);
|
|
3837
3531
|
}
|
|
3838
3532
|
}
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
[i.berachainBartioTestnet]: "0xe3748bF0Ec0A76767539eE28610B3367e35fe2C2"
|
|
3842
|
-
},
|
|
3843
|
-
[i.berachainBartioTestnet]: {
|
|
3844
|
-
[i.sepolia]: "0x1977013acaf27856ac8048C42EE2ed0134d53895"
|
|
3845
|
-
}
|
|
3846
|
-
}, Nt = {
|
|
3847
|
-
...te
|
|
3848
|
-
}, Mt = {
|
|
3849
|
-
...te,
|
|
3850
|
-
[i.corn]: {
|
|
3851
|
-
[i.ethereum]: "0xfc7B20D9B59A8A466f4fC3d34aA69a7D98e71d7A"
|
|
3852
|
-
},
|
|
3853
|
-
[i.ethereum]: {
|
|
3854
|
-
[i.corn]: "0x6bc15d7930839ec18a57f6f7df72ae1b439d077f",
|
|
3855
|
-
[i.swell]: "0x37E92d760a15231e652a2C502182a6b44c7510c0"
|
|
3856
|
-
},
|
|
3857
|
-
[i.swell]: {
|
|
3858
|
-
[i.ethereum]: "0x7B3784AD646C10A8Ddf42b47a4f4bd9aFD351E54"
|
|
3859
|
-
}
|
|
3860
|
-
};
|
|
3861
|
-
function dn(e = K) {
|
|
3862
|
-
switch (e) {
|
|
3863
|
-
case l.prod:
|
|
3864
|
-
return Mt;
|
|
3865
|
-
case l.testnet:
|
|
3866
|
-
return Nt;
|
|
3867
|
-
default:
|
|
3868
|
-
return te;
|
|
3869
|
-
}
|
|
3870
|
-
}
|
|
3871
|
-
async function yn(e) {
|
|
3872
|
-
const t = new C(e), n = `destination chain id is ${e.chainId}`;
|
|
3533
|
+
async function ht(e) {
|
|
3534
|
+
const t = new E(e), n = `destination chain id is ${e.chainId}`;
|
|
3873
3535
|
return t.signMessage(n);
|
|
3874
3536
|
}
|
|
3875
|
-
const
|
|
3876
|
-
function
|
|
3537
|
+
const Ve = 24 * 60 * 60;
|
|
3538
|
+
function He({
|
|
3877
3539
|
chainId: e,
|
|
3878
3540
|
verifyingContract: t,
|
|
3879
3541
|
fee: n,
|
|
@@ -3907,61 +3569,89 @@ function Ot({
|
|
|
3907
3569
|
}
|
|
3908
3570
|
};
|
|
3909
3571
|
}
|
|
3910
|
-
const
|
|
3911
|
-
async function
|
|
3572
|
+
const $e = "Failed to obtain a valid signature. The response is undefined or invalid.", Ze = () => Math.floor(Date.now() / 1e3 + Ve);
|
|
3573
|
+
async function gt({
|
|
3912
3574
|
address: e,
|
|
3913
3575
|
provider: t,
|
|
3914
3576
|
fee: n,
|
|
3915
3577
|
chainId: a,
|
|
3916
3578
|
env: s,
|
|
3917
|
-
expiry: r =
|
|
3579
|
+
expiry: r = Ze()
|
|
3918
3580
|
}) {
|
|
3919
|
-
var
|
|
3920
|
-
const o = new
|
|
3581
|
+
var b, d;
|
|
3582
|
+
const o = new E({
|
|
3921
3583
|
provider: t,
|
|
3922
3584
|
account: e,
|
|
3923
3585
|
chainId: a
|
|
3924
|
-
}),
|
|
3925
|
-
|
|
3586
|
+
}), u = v(o, s).options.address, f = JSON.stringify(
|
|
3587
|
+
He({
|
|
3926
3588
|
chainId: a,
|
|
3927
|
-
verifyingContract:
|
|
3589
|
+
verifyingContract: u,
|
|
3928
3590
|
fee: n,
|
|
3929
3591
|
expiry: r
|
|
3930
3592
|
})
|
|
3931
|
-
),
|
|
3593
|
+
), m = await ((d = (b = o.web3) == null ? void 0 : b.currentProvider) == null ? void 0 : d.request({
|
|
3932
3594
|
method: "eth_signTypedData_v4",
|
|
3933
|
-
params: [e,
|
|
3595
|
+
params: [e, f]
|
|
3934
3596
|
}));
|
|
3935
|
-
if (typeof
|
|
3936
|
-
return { signature:
|
|
3937
|
-
if (!(
|
|
3938
|
-
throw new Error(
|
|
3939
|
-
return { signature:
|
|
3597
|
+
if (typeof m == "string")
|
|
3598
|
+
return { signature: m, typedData: f };
|
|
3599
|
+
if (!(m != null && m.result))
|
|
3600
|
+
throw new Error($e);
|
|
3601
|
+
return { signature: m.result, typedData: f };
|
|
3940
3602
|
}
|
|
3941
|
-
const
|
|
3603
|
+
const X = {
|
|
3942
3604
|
[i.holesky]: [
|
|
3943
3605
|
{
|
|
3944
3606
|
key: "veda",
|
|
3945
3607
|
name: "Veda / Lombard DeFi Vault",
|
|
3946
|
-
address: "
|
|
3608
|
+
address: "0x4A3cD83CEbb91E0Cd31EdA2Ee0F4AebfcCFCbBb6"
|
|
3609
|
+
}
|
|
3610
|
+
],
|
|
3611
|
+
// [OChainId.ethereum]: [
|
|
3612
|
+
// {
|
|
3613
|
+
// key: 'veda',
|
|
3614
|
+
// name: 'Veda / Lombard DeFi Vault',
|
|
3615
|
+
// address: '0x5401b8620e5fb570064ca9114fd1e135fd77d57c',
|
|
3616
|
+
// },
|
|
3617
|
+
// ],
|
|
3618
|
+
[i.binanceSmartChain]: [
|
|
3619
|
+
{
|
|
3620
|
+
key: "veda",
|
|
3621
|
+
name: "Veda / Lombard DeFi Vault",
|
|
3622
|
+
address: "0xC8bbF6153D7Ba105f1399D992ebd32B0541996ef"
|
|
3623
|
+
}
|
|
3624
|
+
],
|
|
3625
|
+
[i.binanceSmartChainTestnet]: [
|
|
3626
|
+
{
|
|
3627
|
+
key: "veda",
|
|
3628
|
+
name: "Veda / Lombard DeFi Vault",
|
|
3629
|
+
address: "0x72143309A662bDB4aad5cA65Ab59eD8977D047C5"
|
|
3947
3630
|
}
|
|
3948
3631
|
]
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3632
|
+
// [OChainId.base]: [
|
|
3633
|
+
// {
|
|
3634
|
+
// key: 'veda',
|
|
3635
|
+
// name: 'Veda / Lombard DeFi Vault',
|
|
3636
|
+
// address: '0x5401b8620e5fb570064ca9114fd1e135fd77d57c',
|
|
3637
|
+
// },
|
|
3638
|
+
// ],
|
|
3639
|
+
}, wt = Object.keys(
|
|
3640
|
+
X
|
|
3641
|
+
).map(Number), Ke = (e) => {
|
|
3642
|
+
const t = X[e];
|
|
3953
3643
|
if (!(t != null && t.length))
|
|
3954
3644
|
throw new Error(`No vaults configured for chain ID ${e}`);
|
|
3955
3645
|
return t;
|
|
3956
|
-
},
|
|
3957
|
-
const a =
|
|
3646
|
+
}, ze = (e, t) => {
|
|
3647
|
+
const a = Ke(e).find((s) => s.key === t);
|
|
3958
3648
|
if (!a)
|
|
3959
3649
|
throw new Error(
|
|
3960
3650
|
`No vault found with key ${t} for chain ID ${e}`
|
|
3961
3651
|
);
|
|
3962
3652
|
return a.address;
|
|
3963
3653
|
};
|
|
3964
|
-
async function
|
|
3654
|
+
async function qe({
|
|
3965
3655
|
chainId: e,
|
|
3966
3656
|
expiry: t,
|
|
3967
3657
|
owner: n,
|
|
@@ -3970,7 +3660,7 @@ async function kt({
|
|
|
3970
3660
|
rpcUrl: r,
|
|
3971
3661
|
verifyingContract: o
|
|
3972
3662
|
}) {
|
|
3973
|
-
const p = await
|
|
3663
|
+
const p = await Ge({
|
|
3974
3664
|
owner: n,
|
|
3975
3665
|
chainId: e,
|
|
3976
3666
|
rpcUrl: r
|
|
@@ -4019,13 +3709,13 @@ async function kt({
|
|
|
4019
3709
|
}
|
|
4020
3710
|
};
|
|
4021
3711
|
}
|
|
4022
|
-
const
|
|
4023
|
-
const n =
|
|
3712
|
+
const je = (e) => {
|
|
3713
|
+
const n = q("stage")[e];
|
|
4024
3714
|
if (!n)
|
|
4025
3715
|
throw new Error(`No LBTC contract address configured for chain ID ${e}`);
|
|
4026
3716
|
return n;
|
|
4027
|
-
},
|
|
4028
|
-
async function
|
|
3717
|
+
}, Je = "Failed to obtain a valid signature. The response is undefined or invalid.";
|
|
3718
|
+
async function At({
|
|
4029
3719
|
address: e,
|
|
4030
3720
|
provider: t,
|
|
4031
3721
|
chainId: n,
|
|
@@ -4034,113 +3724,112 @@ async function mn({
|
|
|
4034
3724
|
rpcUrl: r,
|
|
4035
3725
|
vaultKey: o
|
|
4036
3726
|
}) {
|
|
4037
|
-
var
|
|
4038
|
-
const p = new
|
|
3727
|
+
var C, x;
|
|
3728
|
+
const p = new E({
|
|
4039
3729
|
provider: t,
|
|
4040
3730
|
account: e,
|
|
4041
3731
|
chainId: n
|
|
4042
|
-
}),
|
|
3732
|
+
}), u = je(n), f = ze(n, o), m = await qe({
|
|
4043
3733
|
chainId: n,
|
|
4044
3734
|
expiry: s,
|
|
4045
3735
|
owner: e,
|
|
4046
|
-
spender:
|
|
3736
|
+
spender: f,
|
|
4047
3737
|
value: a,
|
|
4048
3738
|
rpcUrl: r,
|
|
4049
|
-
verifyingContract:
|
|
4050
|
-
}),
|
|
3739
|
+
verifyingContract: u
|
|
3740
|
+
}), b = JSON.stringify(m), d = await ((x = (C = p.web3) == null ? void 0 : C.currentProvider) == null ? void 0 : x.request({
|
|
4051
3741
|
method: "eth_signTypedData_v4",
|
|
4052
|
-
params: [e,
|
|
3742
|
+
params: [e, b]
|
|
4053
3743
|
}));
|
|
4054
|
-
if (typeof
|
|
4055
|
-
return { signature:
|
|
4056
|
-
if (!(
|
|
4057
|
-
throw new Error(
|
|
4058
|
-
return { signature:
|
|
3744
|
+
if (typeof d == "string")
|
|
3745
|
+
return { signature: d, typedData: b };
|
|
3746
|
+
if (!(d != null && d.result))
|
|
3747
|
+
throw new Error(Je);
|
|
3748
|
+
return { signature: d.result, typedData: b };
|
|
4059
3749
|
}
|
|
4060
|
-
|
|
4061
|
-
function
|
|
3750
|
+
te(ee);
|
|
3751
|
+
function Xe(e, t = c.prod) {
|
|
4062
3752
|
var r;
|
|
4063
|
-
const n =
|
|
3753
|
+
const n = Ye(e), s = (r = ne[n]({
|
|
4064
3754
|
address: e,
|
|
4065
|
-
network: t ===
|
|
3755
|
+
network: t === c.prod ? V.bitcoin : V.testnet
|
|
4066
3756
|
}).output) == null ? void 0 : r.toString("hex");
|
|
4067
3757
|
if (!s)
|
|
4068
3758
|
throw new Error("Output script is not found.");
|
|
4069
3759
|
return `0x${s}`;
|
|
4070
3760
|
}
|
|
4071
|
-
function
|
|
4072
|
-
const t =
|
|
3761
|
+
function Ye(e) {
|
|
3762
|
+
const t = ae.fromBech32(e);
|
|
4073
3763
|
if (t.version === 1 && t.data.length === 32)
|
|
4074
3764
|
return "p2tr";
|
|
4075
3765
|
if (t.version === 0 && t.data.length === 20)
|
|
4076
3766
|
return "p2wpkh";
|
|
4077
|
-
if (
|
|
3767
|
+
if (Qe(e))
|
|
4078
3768
|
return "p2wsh";
|
|
4079
3769
|
throw new Error("Address type is not supported.");
|
|
4080
3770
|
}
|
|
4081
|
-
function
|
|
3771
|
+
function Qe(e) {
|
|
4082
3772
|
return (e.startsWith("bc1") || e.startsWith("tb1")) && e.length === 62;
|
|
4083
3773
|
}
|
|
4084
|
-
function
|
|
3774
|
+
function vt({
|
|
4085
3775
|
btcAddress: e,
|
|
4086
3776
|
amount: t,
|
|
4087
3777
|
env: n,
|
|
4088
3778
|
...a
|
|
4089
3779
|
}) {
|
|
4090
|
-
const s = new
|
|
3780
|
+
const s = new E(a), r = v(s, n), o = Xe(e, n), p = K(t), u = r.methods.redeem(o, p);
|
|
4091
3781
|
return s.sendTransactionAsync(
|
|
4092
3782
|
s.account,
|
|
4093
3783
|
r.options.address,
|
|
4094
3784
|
{
|
|
4095
|
-
data:
|
|
3785
|
+
data: u.encodeABI(),
|
|
4096
3786
|
estimate: !0,
|
|
4097
3787
|
estimateFee: !0,
|
|
4098
|
-
gasLimitMultiplier:
|
|
3788
|
+
gasLimitMultiplier: k(s.chainId)
|
|
4099
3789
|
}
|
|
4100
3790
|
);
|
|
4101
3791
|
}
|
|
4102
3792
|
export {
|
|
4103
|
-
|
|
4104
|
-
|
|
4105
|
-
|
|
3793
|
+
Le as BasculeDepositStatus,
|
|
3794
|
+
Ae as ENotarizationStatus,
|
|
3795
|
+
ve as ESessionState,
|
|
4106
3796
|
i as OChainId,
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
bn as unstakeLBTC
|
|
3797
|
+
c as OEnv,
|
|
3798
|
+
le as SANCTIONED_ADDRESS,
|
|
3799
|
+
F as SATOSHI_SCALE,
|
|
3800
|
+
X as STAKE_AND_BAKE_VAULTS,
|
|
3801
|
+
wt as SUPPORTED_STAKE_AND_BAKE_CHAINS,
|
|
3802
|
+
mt as approveLBTC,
|
|
3803
|
+
ct as claimLBTC,
|
|
3804
|
+
Z as fromSatoshi,
|
|
3805
|
+
it as generateDepositBtcAddress,
|
|
3806
|
+
w as getApiConfig,
|
|
3807
|
+
bt as getBasculeDepositStatus,
|
|
3808
|
+
re as getBaseNetworkByEnv,
|
|
3809
|
+
ie as getBscNetworkByEnv,
|
|
3810
|
+
we as getChainIdByName,
|
|
3811
|
+
O as getChainNameById,
|
|
3812
|
+
rt as getDepositBtcAddress,
|
|
3813
|
+
he as getDepositBtcAddresses,
|
|
3814
|
+
ot as getDepositsByAddress,
|
|
3815
|
+
se as getEthNetworkByEnv,
|
|
3816
|
+
pt as getLBTCExchangeRate,
|
|
3817
|
+
ft as getLBTCMintingFee,
|
|
3818
|
+
Tt as getLBTCTotalSupply,
|
|
3819
|
+
q as getLbtcAddressConfig,
|
|
3820
|
+
ut as getNetworkFeeSignature,
|
|
3821
|
+
Ge as getPermitNonce,
|
|
3822
|
+
ze as getStakeAndBakeSpenderContract,
|
|
3823
|
+
qe as getStakeAndBakeTypedData,
|
|
3824
|
+
Ke as getStakeAndBakeVaults,
|
|
3825
|
+
yt as getUserStakeAndBakeSignature,
|
|
3826
|
+
z as isValidChain,
|
|
3827
|
+
ht as signLbtcDestionationAddr,
|
|
3828
|
+
gt as signNetworkFee,
|
|
3829
|
+
At as signStakeAndBake,
|
|
3830
|
+
dt as storeNetworkFeeSignature,
|
|
3831
|
+
lt as storeStakeAndBakeSignature,
|
|
3832
|
+
K as toSatoshi,
|
|
3833
|
+
vt as unstakeLBTC
|
|
4145
3834
|
};
|
|
4146
3835
|
//# sourceMappingURL=index.js.map
|