@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/dist/index.js CHANGED
@@ -1,12 +1,12 @@
1
- var we = Object.defineProperty;
2
- var Ee = (e, t, n) => t in e ? we(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var _ = (e, t, n) => (Ee(e, typeof t != "symbol" ? t + "" : t, n), n);
4
- import E from "axios";
5
- import D from "bignumber.js";
6
- import ye, { Web3 as re, utils as S } from "web3";
7
- import * as Ae from "@bitcoin-js/tiny-secp256k1-asmjs";
8
- import { initEccLib as ve, payments as Re, networks as oe, address as Se } from "bitcoinjs-lib";
9
- const l = {
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
- baseTestnet: 84532,
20
+ baseSepoliaTestnet: 84532,
21
21
  berachainBartioTestnet: 80084,
22
22
  corn: 21e6,
23
23
  swell: 1923
24
- }, Ce = (e) => e === l.prod ? i.ethereum : i.holesky, _e = (e) => e === l.prod ? i.binanceSmartChain : i.binanceSmartChainTestnet, Ie = (e) => e === l.prod ? i.base : i.baseTestnet, K = l.prod, u = "0x0000000000000000000000000000000000000000", De = {
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
- }, xe = {
26
+ }, pe = {
27
27
  baseApiUrl: "https://gastald-testnet.prod.lombard.finance"
28
- }, Ne = {
28
+ }, ue = {
29
29
  baseApiUrl: "https://mainnet.prod.lombard.finance"
30
- }, A = (e = K) => {
30
+ }, w = (e = P) => {
31
31
  switch (e) {
32
- case l.prod:
33
- return Ne;
34
- case l.testnet:
35
- return xe;
32
+ case c.prod:
33
+ return ue;
34
+ case c.testnet:
35
+ return pe;
36
36
  default:
37
- return De;
37
+ return oe;
38
38
  }
39
39
  };
40
- function v(e) {
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 ? Me(e) : Pe(e);
44
+ })(e) ? e.data.message : e instanceof Error ? ye(e) : de(e);
45
45
  }
46
- function Me(e) {
46
+ function ye(e) {
47
47
  return e.response ? e.response.data.message : e.message;
48
48
  }
49
- function Pe(e) {
49
+ function de(e) {
50
50
  return e != null && e.message ? e.message : "Unknown error";
51
51
  }
52
- const I = {
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
- mantle: "DESTINATION_BLOCKCHAIN_MANTLE",
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 Y(e) {
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 I.eth;
65
+ return h.eth;
68
66
  case i.base:
69
- case i.baseTestnet:
70
- return I.base;
67
+ case i.baseSepoliaTestnet:
68
+ return h.base;
71
69
  case i.binanceSmartChain:
72
70
  case i.binanceSmartChainTestnet:
73
- return I.bsc;
71
+ return h.bsc;
74
72
  default:
75
73
  throw new Error(`Unknown chain ID: ${e}`);
76
74
  }
77
75
  }
78
- const Oe = "sanctioned_address", Ue = "api/v1/address/generate", Be = "destination address is under sanctions";
79
- async function zt({
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: d } = A(s), g = Y(t), b = {
88
+ const { baseApiUrl: f } = w(s), m = O(t), b = {
90
89
  to_address: e,
91
90
  to_address_signature: n,
92
- to_chain: g,
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: m } = await E.post(
101
- Ue,
100
+ const { data: d } = await g.post(
101
+ me,
102
102
  b,
103
- { baseURL: d }
103
+ { baseURL: f }
104
104
  );
105
- return m.address;
106
- } catch (m) {
107
- const y = v(m);
108
- if (Fe(y))
109
- return Oe;
110
- throw new Error(y);
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 Fe(e) {
114
- return !!e.includes(Be);
113
+ function be(e) {
114
+ return !!e.includes(ce);
115
115
  }
116
- const Le = "api/v1/address";
117
- async function Xt({
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 Ge({
123
+ const s = await he({
124
124
  address: e,
125
125
  chainId: t,
126
126
  env: n,
127
127
  partnerId: a
128
- }), r = ke(s);
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 ke(e) {
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 Ge({
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 } = A(n), r = Y(t), o = {
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 E.get(Le, {
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 We = 8, Q = 10 ** We;
159
- function ce(e) {
160
- return +e / Q;
158
+ const ge = 8, F = 10 ** ge;
159
+ function Z(e) {
160
+ return +e / F;
161
161
  }
162
- function le(e) {
163
- return Math.floor(+e * Q);
162
+ function K(e) {
163
+ return Math.floor(+e * F);
164
164
  }
165
- function Ve(e, t = K) {
165
+ function we(e, t = P) {
166
166
  switch (e) {
167
- case I.eth:
168
- return Ce(t);
169
- case I.base:
170
- return Ie(t);
171
- case I.bsc:
172
- return _e(t);
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 $e = /* @__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))($e || {}), He = /* @__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))(He || {});
178
- async function Yt({
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 } = A(t), { data: a } = await E.get(
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(je(t));
189
+ return ((a == null ? void 0 : a.outputs) ?? []).map(Ce(t));
187
190
  }
188
- function je(e) {
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 D(ce(t.value)),
197
+ value: new _(Z(t.value)),
195
198
  address: t.address,
196
- chainId: Ve(t.to_chain, e),
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 Je = 2e-4;
209
- async function Qt({
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 } = A(e), s = Y(t), { data: r } = await E.get(
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 D(Je).multipliedBy(Q).toFixed();
222
+ ), o = new _(Se).multipliedBy(F).toFixed();
218
223
  return { exchangeRate: +r.amount_out, minAmount: +o };
219
224
  }
220
- async function en({
225
+ async function ut({
221
226
  address: e,
222
227
  chainId: t,
223
228
  env: n
224
229
  }) {
225
- const { baseApiUrl: a } = A(n);
230
+ const { baseApiUrl: a } = w(n);
226
231
  try {
227
- const { data: s } = await E.get(
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 = v(s);
247
+ const r = A(s);
243
248
  throw new Error(r);
244
249
  }
245
250
  }
246
- async function tn({
251
+ async function yt({
247
252
  userDestinationAddress: e,
248
253
  chainId: t,
249
254
  env: n
250
255
  }) {
251
- const { baseApiUrl: a } = A(n);
256
+ const { baseApiUrl: a } = w(n);
252
257
  try {
253
- const { data: s } = await E.get(
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 = v(s);
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 nn({
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 } = A(a);
287
+ const { baseApiUrl: s } = w(a);
283
288
  try {
284
- const { data: r } = await E.post(
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 = v(r);
302
+ const o = A(r);
298
303
  throw new Error(o);
299
304
  }
300
305
  }
301
- async function an({
306
+ async function lt({
302
307
  signature: e,
303
308
  typedData: t,
304
309
  env: n
305
310
  }) {
306
- const { baseApiUrl: a } = A(n);
311
+ const { baseApiUrl: a } = w(n);
307
312
  try {
308
- const { data: s } = await E.post(
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 = v(s);
325
+ const r = A(s);
321
326
  throw new Error(r);
322
327
  }
323
328
  }
324
- const O = {
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.baseTestnet]: "https://rpc.ankr.com/base_sepolia",
330
- [i.binanceSmartChain]: "https://rpc.ankr.com/bsc",
331
- [i.binanceSmartChainTestnet]: "https://rpc.ankr.com/bsc_testnet_chapel"
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 qe(e) {
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 = ye.utils.hexToNumber(n == null ? void 0 : n.result);
346
- return new D(Number(a));
350
+ })).json(), a = $.utils.hexToNumber(n == null ? void 0 : n.result);
351
+ return new _(Number(a));
347
352
  }
348
- const Ze = 2, Ke = 25e3;
349
- class z {
353
+ const De = 2, _e = 25e3;
354
+ class N {
350
355
  constructor({ chainId: t, rpcUrlConfig: n }) {
351
- _(this, "chainId");
352
- _(this, "rpcConfig");
353
- this.chainId = t, this.rpcConfig = { ...O, ...n };
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 re(), a = new re.providers.HttpProvider(t);
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
- qe(n)
395
+ Ee(n)
391
396
  ]);
392
397
  return !(a != null && a.baseFeePerGas) && typeof (a == null ? void 0 : a.baseFeePerGas) != "bigint" ? {} : {
393
- maxFeePerGas: +new D(a.baseFeePerGas.toString(10)).multipliedBy(Ze).plus(s),
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 D(t.toString(10)).plus(
406
- Ke
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 C extends z {
427
+ class E extends N {
423
428
  constructor({ provider: n, account: a, chainId: s, rpcUrlConfig: r }) {
424
429
  super({ chainId: s, rpcUrlConfig: r });
425
- _(this, "web3");
426
- _(this, "account");
427
- _(this, "rpcConfig", O);
428
- this.web3 = new ye(n), this.account = a, this.chainId = s, this.rpcConfig = { ...O, ...r };
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: d,
455
- estimate: g = !1,
456
- estimateFee: b = !1,
457
- extendedGasLimit: m,
458
- gasLimit: y = "0",
459
- value: x = "0",
460
- gasLimitMultiplier: N = 1
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: M } = s;
463
- M || (M = await p.eth.getTransactionCount(n)), console.log(`Nonce: ${M}`);
464
- const c = {
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(x),
468
- data: d,
469
- nonce: M,
472
+ value: S.numberToHex(C),
473
+ data: u,
474
+ nonce: I,
470
475
  chainId: S.numberToHex(r)
471
476
  };
472
- if (g)
477
+ if (f)
473
478
  try {
474
- const w = await p.eth.estimateGas(c), P = Math.round(
475
- Number(w) * N
479
+ const T = await p.eth.estimateGas(l), M = Math.round(
480
+ Number(T) * x
476
481
  );
477
- m ? c.gas = S.numberToHex(P + m) : c.gas = S.numberToHex(P);
478
- } catch (w) {
482
+ b ? l.gas = S.numberToHex(M + b) : l.gas = S.numberToHex(M);
483
+ } catch (T) {
479
484
  throw new Error(
480
- w.message ?? "Failed to estimate gas limit for transaction."
485
+ T.message ?? "Failed to estimate gas limit for transaction."
481
486
  );
482
487
  }
483
488
  else
484
- c.gas = S.numberToHex(y);
485
- const { maxFeePerGas: ne, maxPriorityFeePerGas: ae } = b ? await this.getMaxFees().catch(() => s) : s;
486
- if (ae !== void 0 && (c.maxPriorityFeePerGas = S.numberToHex(ae)), ne !== void 0 && (c.maxFeePerGas = S.numberToHex(ne)), !c.maxFeePerGas && !c.maxPriorityFeePerGas) {
487
- const w = await this.getSafeGasPriceWei();
488
- c.gasPrice = w.toString(10);
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 (!c.maxFeePerGas && !c.maxPriorityFeePerGas) {
491
- const w = await this.getSafeGasPriceWei();
492
- c.gasPrice = w.toString(10);
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: ", c), new Promise((w, P) => {
495
- const se = o.eth.sendTransaction(c);
496
- se.once("transactionHash", async (ie) => {
497
- console.log(`Just signed transaction has is: ${ie}`), w({
498
- receiptPromise: se,
499
- transactionHash: ie
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(P);
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 ee(e) {
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 me(e) {
524
+ function z(e) {
520
525
  return Object.values(i).includes(e);
521
526
  }
522
- const ze = {
527
+ const xe = {
523
528
  [i.holesky]: "0xED7bfd5C1790576105Af4649817f6d35A75CD818",
524
- [i.ethereum]: u,
529
+ [i.ethereum]: y,
525
530
  [i.binanceSmartChainTestnet]: "0x731eFa688F3679688cf60A3993b8658138953ED6",
526
- [i.binanceSmartChain]: u,
531
+ [i.binanceSmartChain]: y,
527
532
  [i.sepolia]: "0xc47e4b3124597fdf8dd07843d4a7052f2ee80c30",
528
- [i.base]: u,
529
- // TODO: Add baseTestnet address
530
- [i.baseTestnet]: u,
533
+ [i.base]: y,
534
+ [i.baseSepoliaTestnet]: "0x731eFa688F3679688cf60A3993b8658138953ED6",
531
535
  [i.berachainBartioTestnet]: "0xc47e4b3124597FDF8DD07843D4a7052F2eE80C30",
532
- [i.corn]: u,
533
- [i.swell]: u
534
- }, Xe = {
536
+ [i.corn]: y,
537
+ [i.swell]: y
538
+ }, Ie = {
535
539
  [i.holesky]: "0x38A13AB20D15ffbE5A7312d2336EF1552580a4E2",
536
- [i.ethereum]: u,
540
+ [i.ethereum]: y,
537
541
  [i.binanceSmartChainTestnet]: "0x107Fc7d90484534704dD2A9e24c7BD45DB4dD1B5",
538
- [i.binanceSmartChain]: u,
542
+ [i.binanceSmartChain]: y,
539
543
  [i.sepolia]: "0xc47e4b3124597fdf8dd07843d4a7052f2ee80c30",
540
- [i.base]: u,
541
- [i.baseTestnet]: u,
544
+ [i.base]: y,
545
+ [i.baseSepoliaTestnet]: y,
542
546
  [i.berachainBartioTestnet]: "0xc47e4b3124597FDF8DD07843D4a7052F2eE80C30",
543
- [i.corn]: u,
544
- [i.swell]: u
545
- }, Ye = {
547
+ [i.corn]: y,
548
+ [i.swell]: y
549
+ }, Me = {
546
550
  [i.ethereum]: "0x8236a87084f8b84306f72007f36f2618a5634494",
547
- [i.holesky]: u,
548
- [i.sepolia]: u,
549
- [i.binanceSmartChainTestnet]: u,
551
+ [i.holesky]: y,
552
+ [i.sepolia]: y,
553
+ [i.binanceSmartChainTestnet]: y,
550
554
  [i.binanceSmartChain]: "0xecAc9C5F704e954931349Da37F60E39f515c11c1",
551
555
  [i.base]: "0xecAc9C5F704e954931349Da37F60E39f515c11c1",
552
- [i.baseTestnet]: u,
553
- [i.berachainBartioTestnet]: u,
556
+ [i.baseSepoliaTestnet]: y,
557
+ [i.berachainBartioTestnet]: y,
554
558
  [i.corn]: "0xecAc9C5F704e954931349Da37F60E39f515c11c1",
555
559
  [i.swell]: "0xecAc9C5F704e954931349Da37F60E39f515c11c1"
556
560
  };
557
- function be(e = K) {
561
+ function q(e = P) {
558
562
  switch (e) {
559
- case l.prod:
560
- return Ye;
561
- case l.testnet:
562
- return Xe;
563
+ case c.prod:
564
+ return Me;
565
+ case c.testnet:
566
+ return Ie;
563
567
  default:
564
- return ze;
568
+ return xe;
565
569
  }
566
570
  }
567
- const Qe = [
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
- ], et = [
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
- ], tt = [
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 nt(e) {
3402
+ function Oe(e) {
3399
3403
  switch (e) {
3400
3404
  case "LBTC":
3401
- return et;
3405
+ return Ne;
3402
3406
  default:
3403
- return Qe;
3407
+ return Re;
3404
3408
  }
3405
3409
  }
3406
- function R(e, t) {
3407
- const n = be(t), { chainId: a } = e;
3408
- if (!me(a))
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 = nt("LBTC"), o = e.createContract(r, s);
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 sn({
3420
+ function mt({
3417
3421
  spender: e,
3418
3422
  amount: t,
3419
3423
  env: n,
3420
3424
  ...a
3421
3425
  }) {
3422
- const s = new C(a), r = R(s, n), o = le(t), p = r.methods.approve(e, o);
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: ee(s.chainId)
3434
+ gasLimitMultiplier: k(s.chainId)
3431
3435
  }
3432
3436
  );
3433
3437
  }
3434
- const at = "insufficient funds", st = "Insufficient funds for transfer. Make sure you have enough ETH to cover the gas cost.", pe = (e) => e.startsWith("0x") ? e : "0x" + e;
3435
- async function rn({
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 C(a), r = R(s, n), o = r.methods.mint(pe(e), pe(t));
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: ee(s.chainId)
3454
+ gasLimitMultiplier: k(s.chainId)
3452
3455
  }
3453
3456
  );
3454
3457
  } catch (p) {
3455
3458
  console.log("error", p);
3456
- const d = v(p);
3457
- throw d.includes(at) ? new Error(st) : new Error(d);
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
- class X extends fe {
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(tt, t);
3466
+ const n = e.createContract(Pe, t);
3773
3467
  return n.options.address || (n.options.address = t), n;
3774
3468
  }
3775
- const Ct = "No deposit ID provided. Please provide a deposit ID as an argument.", _t = "Invalid deposit ID. Expected a 0x-prefixed 32-byte hex string.";
3776
- var It = /* @__PURE__ */ ((e) => (e[e.UNREPORTED = 0] = "UNREPORTED", e[e.REPORTED = 1] = "REPORTED", e[e.WITHDRAWN = 2] = "WITHDRAWN", e))(It || {});
3777
- async function on({
3778
- txId: e,
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(Ct);
3784
- if (!Rt(e))
3785
- throw new Error(_t);
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 = St(a, r);
3481
+ const o = Ue(a, r);
3790
3482
  try {
3791
- const p = await o.methods.depositHistory(Buffer.from(e.replace(/^0x/, ""), "hex")).call();
3792
- return Number(p);
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 d = v(p);
3795
- throw new Error(d);
3488
+ const u = A(p);
3489
+ throw new Error(u);
3796
3490
  }
3797
3491
  }
3798
- const Dt = [
3492
+ const We = [
3799
3493
  i.ethereum,
3800
3494
  i.base,
3801
3495
  i.binanceSmartChain
3802
- ], Te = (e) => Dt.includes(e) ? l.prod : l.stage;
3803
- function he(e, t) {
3804
- if (!me(e))
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 } : O;
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 pn({
3505
+ async function ft({
3812
3506
  chainId: e,
3813
3507
  rpcUrl: t
3814
3508
  }) {
3815
- const n = he(e, t), a = new z({ chainId: e, rpcUrlConfig: n }), s = Te(e), o = await R(a, s).methods.getMintFee().call();
3816
- return new D(ce(o.toString(10)));
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 un({
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 z({ chainId: n, rpcUrlConfig: a });
3824
- return (await R(s, e).methods.totalSupply().call()).toString();
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 xt({
3520
+ async function Ge({
3827
3521
  owner: e,
3828
3522
  rpcUrl: t,
3829
3523
  chainId: n
3830
3524
  }) {
3831
- const a = he(n, t), s = new z({ chainId: n, rpcUrlConfig: a }), r = Te(n), o = R(s, r);
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 d = v(p);
3836
- throw new Error(d);
3529
+ const u = A(p);
3530
+ throw new Error(u);
3837
3531
  }
3838
3532
  }
3839
- const te = {
3840
- [i.sepolia]: {
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 Pt = 24 * 60 * 60;
3876
- function Ot({
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 Ut = "Failed to obtain a valid signature. The response is undefined or invalid.", Bt = () => Math.floor(Date.now() / 1e3 + Pt);
3911
- async function cn({
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 = Bt()
3579
+ expiry: r = Ze()
3918
3580
  }) {
3919
- var m, y;
3920
- const o = new C({
3581
+ var b, d;
3582
+ const o = new E({
3921
3583
  provider: t,
3922
3584
  account: e,
3923
3585
  chainId: a
3924
- }), d = R(o, s).options.address, g = JSON.stringify(
3925
- Ot({
3586
+ }), u = v(o, s).options.address, f = JSON.stringify(
3587
+ He({
3926
3588
  chainId: a,
3927
- verifyingContract: d,
3589
+ verifyingContract: u,
3928
3590
  fee: n,
3929
3591
  expiry: r
3930
3592
  })
3931
- ), b = await ((y = (m = o.web3) == null ? void 0 : m.currentProvider) == null ? void 0 : y.request({
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, g]
3595
+ params: [e, f]
3934
3596
  }));
3935
- if (typeof b == "string")
3936
- return { signature: b, typedData: g };
3937
- if (!(b != null && b.result))
3938
- throw new Error(Ut);
3939
- return { signature: b.result, typedData: g };
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 ge = {
3603
+ const X = {
3942
3604
  [i.holesky]: [
3943
3605
  {
3944
3606
  key: "veda",
3945
3607
  name: "Veda / Lombard DeFi Vault",
3946
- address: "0x52BD640617eeD47A00dA0da93351092D49208d1d"
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
- }, ln = Object.keys(
3950
- ge
3951
- ).map(Number), Ft = (e) => {
3952
- const t = ge[e];
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
- }, Lt = (e, t) => {
3957
- const a = Ft(e).find((s) => s.key === t);
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 kt({
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 xt({
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 Gt = (e) => {
4023
- const n = be("stage")[e];
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
- }, Wt = "Failed to obtain a valid signature. The response is undefined or invalid.";
4028
- async function mn({
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 x, N;
4038
- const p = new C({
3727
+ var C, x;
3728
+ const p = new E({
4039
3729
  provider: t,
4040
3730
  account: e,
4041
3731
  chainId: n
4042
- }), d = Gt(n), g = Lt(n, o), b = await kt({
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: g,
3736
+ spender: f,
4047
3737
  value: a,
4048
3738
  rpcUrl: r,
4049
- verifyingContract: d
4050
- }), m = JSON.stringify(b), y = await ((N = (x = p.web3) == null ? void 0 : x.currentProvider) == null ? void 0 : N.request({
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, m]
3742
+ params: [e, b]
4053
3743
  }));
4054
- if (typeof y == "string")
4055
- return { signature: y, typedData: m };
4056
- if (!(y != null && y.result))
4057
- throw new Error(Wt);
4058
- return { signature: y.result, typedData: m };
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
- ve(Ae);
4061
- function Vt(e, t = l.prod) {
3750
+ te(ee);
3751
+ function Xe(e, t = c.prod) {
4062
3752
  var r;
4063
- const n = $t(e), s = (r = Re[n]({
3753
+ const n = Ye(e), s = (r = ne[n]({
4064
3754
  address: e,
4065
- network: t === l.prod ? oe.bitcoin : oe.testnet
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 $t(e) {
4072
- const t = Se.fromBech32(e);
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 (Ht(e))
3767
+ if (Qe(e))
4078
3768
  return "p2wsh";
4079
3769
  throw new Error("Address type is not supported.");
4080
3770
  }
4081
- function Ht(e) {
3771
+ function Qe(e) {
4082
3772
  return (e.startsWith("bc1") || e.startsWith("tb1")) && e.length === 62;
4083
3773
  }
4084
- function bn({
3774
+ function vt({
4085
3775
  btcAddress: e,
4086
3776
  amount: t,
4087
3777
  env: n,
4088
3778
  ...a
4089
3779
  }) {
4090
- const s = new C(a), r = R(s, n), o = Vt(e, n), p = le(t), d = r.methods.redeem(o, p);
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: d.encodeABI(),
3785
+ data: u.encodeABI(),
4096
3786
  estimate: !0,
4097
3787
  estimateFee: !0,
4098
- gasLimitMultiplier: ee(s.chainId)
3788
+ gasLimitMultiplier: k(s.chainId)
4099
3789
  }
4100
3790
  );
4101
3791
  }
4102
3792
  export {
4103
- It as BasculeDepositStatus,
4104
- $e as ENotarizationStatus,
4105
- He as ESessionState,
3793
+ Le as BasculeDepositStatus,
3794
+ Ae as ENotarizationStatus,
3795
+ ve as ESessionState,
4106
3796
  i as OChainId,
4107
- l as OEnv,
4108
- Oe as SANCTIONED_ADDRESS,
4109
- Q as SATOSHI_SCALE,
4110
- ge as STAKE_AND_BAKE_VAULTS,
4111
- ln as SUPPORTED_STAKE_AND_BAKE_CHAINS,
4112
- sn as approveLBTC,
4113
- rn as claimLBTC,
4114
- ce as fromSatoshi,
4115
- zt as generateDepositBtcAddress,
4116
- A as getApiConfig,
4117
- on as getBasculeDepositStatus,
4118
- Ie as getBaseNetworkByEnv,
4119
- _e as getBscNetworkByEnv,
4120
- Ve as getChainIdByName,
4121
- Y as getChainNameById,
4122
- Xt as getDepositBtcAddress,
4123
- Ge as getDepositBtcAddresses,
4124
- Yt as getDepositsByAddress,
4125
- Ce as getEthNetworkByEnv,
4126
- Qt as getLBTCExchangeRate,
4127
- pn as getLBTCMintingFee,
4128
- un as getLBTCTotalSupply,
4129
- be as getLbtcAddressConfig,
4130
- dn as getLbtcOFTAdapterAddressConfig,
4131
- en as getNetworkFeeSignature,
4132
- xt as getPermitNonce,
4133
- Lt as getStakeAndBakeSpenderContract,
4134
- kt as getStakeAndBakeTypedData,
4135
- Ft as getStakeAndBakeVaults,
4136
- tn as getUserStakeAndBakeSignature,
4137
- me as isValidChain,
4138
- yn as signLbtcDestionationAddr,
4139
- cn as signNetworkFee,
4140
- mn as signStakeAndBake,
4141
- nn as storeNetworkFeeSignature,
4142
- an as storeStakeAndBakeSignature,
4143
- le as toSatoshi,
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