@lombard.finance/sdk 2.0.1 → 2.0.2

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,11 +1,11 @@
1
- var Te = Object.defineProperty;
2
- var he = (e, t, n) => t in e ? Te(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var v = (e, t, n) => (he(e, typeof t != "symbol" ? t + "" : t, n), n);
1
+ var he = Object.defineProperty;
2
+ var ge = (e, t, n) => t in e ? he(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var A = (e, t, n) => (ge(e, typeof t != "symbol" ? t + "" : t, n), n);
4
4
  import R from "axios";
5
- import A from "bignumber.js";
6
- import de, { Web3 as ie, utils as w } from "web3";
7
- import * as ge from "@bitcoin-js/tiny-secp256k1-asmjs";
8
- import { initEccLib as we, payments as Ee, networks as re, address as ve } from "bitcoinjs-lib";
5
+ import v from "bignumber.js";
6
+ import ye, { Web3 as re, utils as w } from "web3";
7
+ import * as we from "@bitcoin-js/tiny-secp256k1-asmjs";
8
+ import { initEccLib as Ee, payments as Ae, networks as oe, address as ve } from "bitcoinjs-lib";
9
9
  const c = {
10
10
  prod: "prod",
11
11
  testnet: "testnet",
@@ -20,72 +20,80 @@ const c = {
20
20
  baseTestnet: 84532,
21
21
  berachainBartioTestnet: 80084,
22
22
  corn: 21e6
23
- }, x = c.prod, o = "0x0000000000000000000000000000000000000000", Ae = {
24
- baseApiUrl: "https://bft-dev.stage.lombard.finance",
23
+ }, _ = c.prod, o = "0x0000000000000000000000000000000000000000", Re = {
24
+ baseApiUrl: "https://staging.prod.lombard.finance",
25
25
  claimerApiUrl: "https://claimer.staging.lombard.finance"
26
- }, Re = {
26
+ }, Ce = {
27
27
  baseApiUrl: "https://gastald-testnet.prod.lombard.finance",
28
28
  claimerApiUrl: "https://claimer.staging.lombard.finance"
29
- }, Ce = {
29
+ }, Se = {
30
30
  baseApiUrl: "https://mainnet.prod.lombard.finance",
31
31
  claimerApiUrl: ""
32
- }, C = (e = x) => {
32
+ }, C = (e = _) => {
33
33
  switch (e) {
34
34
  case c.prod:
35
- return Ce;
35
+ return Se;
36
36
  case c.testnet:
37
- return Re;
37
+ return Ce;
38
38
  default:
39
- return Ae;
39
+ return Re;
40
40
  }
41
41
  };
42
42
  function S(e) {
43
43
  return typeof e == "string" ? e : ((n) => {
44
44
  var s;
45
45
  return ((s = n == null ? void 0 : n.data) == null ? void 0 : s.message) && typeof n.data.message == "string";
46
- })(e) ? e.data.message : e instanceof Error ? Se(e) : Ie(e);
46
+ })(e) ? e.data.message : e instanceof Error ? Ie(e) : _e(e);
47
47
  }
48
- function Se(e) {
48
+ function Ie(e) {
49
49
  return e.response ? e.response.data.message : e.message;
50
50
  }
51
- function Ie(e) {
51
+ function _e(e) {
52
52
  return e != null && e.message ? e.message : "Unknown error";
53
53
  }
54
- const xe = {
55
- eth: "DESTINATION_BLOCKCHAIN_ETHEREUM"
54
+ const Z = {
55
+ eth: "DESTINATION_BLOCKCHAIN_ETHEREUM",
56
+ base: "DESTINATION_BLOCKCHAIN_BASE",
57
+ bsc: "DESTINATION_BLOCKCHAIN_BSC"
56
58
  };
57
- function X(e) {
59
+ function K(e) {
58
60
  switch (e) {
59
61
  case a.holesky:
60
62
  case a.sepolia:
61
63
  case a.ethereum:
62
- return xe.eth;
64
+ return Z.eth;
65
+ case a.base:
66
+ case a.baseTestnet:
67
+ return Z.base;
68
+ case a.binanceSmartChain:
69
+ case a.binanceSmartChainTestnet:
70
+ return Z.bsc;
63
71
  default:
64
72
  throw new Error(`Unknown chain ID: ${e}`);
65
73
  }
66
74
  }
67
- const _e = "sanctioned_address", Me = "api/v1/address/generate", De = "destination address is under sanctions";
68
- async function Wt({
75
+ const xe = "sanctioned_address", De = "api/v1/address/generate", Me = "destination address is under sanctions";
76
+ async function Vt({
69
77
  address: e,
70
78
  chainId: t,
71
79
  signature: n,
72
80
  env: s,
73
- captchaToken: i,
74
- referrerCode: r,
75
- referralId: p
81
+ referrerCode: i,
82
+ partnerId: r,
83
+ captchaToken: p = ""
76
84
  }) {
77
- const { baseApiUrl: u } = C(s), d = X(t), h = {
85
+ const { baseApiUrl: u } = C(s), d = K(t), h = {
78
86
  to_address: e,
79
87
  to_address_signature: n,
80
88
  to_chain: d,
81
- referrer_code: r,
82
- referral_id: p,
89
+ referrer_code: i,
90
+ partner_id: r,
83
91
  nonce: 0,
84
- captcha: i
92
+ captcha: p
85
93
  };
86
94
  try {
87
95
  const { data: l } = await R.post(
88
- Me,
96
+ De,
89
97
  h,
90
98
  { baseURL: u }
91
99
  );
@@ -93,63 +101,63 @@ async function Wt({
93
101
  } catch (l) {
94
102
  const g = S(l);
95
103
  if (Ne(g))
96
- return _e;
104
+ return xe;
97
105
  throw new Error(g);
98
106
  }
99
107
  }
100
108
  function Ne(e) {
101
- return !!e.includes(De);
109
+ return !!e.includes(Me);
102
110
  }
103
111
  const Pe = "api/v1/address";
104
- async function Vt({
112
+ async function $t({
105
113
  address: e,
106
114
  chainId: t,
107
115
  env: n,
108
- referralId: s
116
+ partnerId: s
109
117
  }) {
110
- const i = await Oe({
118
+ const i = await Ue({
111
119
  address: e,
112
120
  chainId: t,
113
121
  env: n,
114
- referralId: s
115
- }), r = Ue(i);
122
+ partnerId: s
123
+ }), r = Oe(i);
116
124
  if (!r)
117
125
  throw new Error("No address");
118
126
  return r.btc_address;
119
127
  }
120
- function Ue(e) {
128
+ function Oe(e) {
121
129
  if (!e.length)
122
130
  return;
123
131
  const t = e.reduce((n, s) => n.created_at < s.created_at ? s : n, e[0]);
124
132
  return t.deprecated ? void 0 : t;
125
133
  }
126
- async function Oe({
134
+ async function Ue({
127
135
  address: e,
128
136
  chainId: t,
129
137
  env: n,
130
- referralId: s
138
+ partnerId: s
131
139
  }) {
132
- const { baseApiUrl: i } = C(n), r = X(t), p = {
140
+ const { baseApiUrl: i } = C(n), r = K(t), p = {
133
141
  to_address: e,
134
142
  to_blockchain: r,
135
143
  limit: 1,
136
144
  offset: 0,
137
145
  asc: !1,
138
- referralId: s
146
+ partnerId: s
139
147
  }, { data: u } = await R.get(Pe, {
140
148
  baseURL: i,
141
149
  params: p
142
150
  });
143
151
  return (u == null ? void 0 : u.addresses) || [];
144
152
  }
145
- const Fe = 8, K = 10 ** Fe;
146
- function z(e) {
147
- return +e / K;
153
+ const Fe = 8, Y = 10 ** Fe;
154
+ function X(e) {
155
+ return +e / Y;
148
156
  }
149
- function ye(e) {
150
- return Math.floor(+e * K);
157
+ function ce(e) {
158
+ return Math.floor(+e * Y);
151
159
  }
152
- function Le(e, t = x) {
160
+ function Be(e, t = _) {
153
161
  switch (e) {
154
162
  case "DESTINATION_BLOCKCHAIN_ETHEREUM":
155
163
  return t === c.prod ? a.ethereum : a.sepolia;
@@ -157,8 +165,8 @@ function Le(e, t = x) {
157
165
  return a.ethereum;
158
166
  }
159
167
  }
160
- var Be = /* @__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))(Be || {}), Ge = /* @__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))(Ge || {});
161
- async function $t({
168
+ var Le = /* @__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))(Le || {}), Ge = /* @__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))(Ge || {});
169
+ async function Ht({
162
170
  address: e,
163
171
  env: t
164
172
  }) {
@@ -174,9 +182,9 @@ function ke(e) {
174
182
  index: t.index ?? 0,
175
183
  blockHeight: t.block_height ? Number(t.block_height) : void 0,
176
184
  blockTime: t.block_time ? Number(t.block_time) : void 0,
177
- value: new A(z(t.value)),
185
+ value: new v(X(t.value)),
178
186
  address: t.address,
179
- chainId: Le(t.to_chain, e),
187
+ chainId: Be(t.to_chain, e),
180
188
  claimedTxId: t.claim_tx,
181
189
  rawPayload: t.raw_payload,
182
190
  signature: t.proof,
@@ -189,18 +197,18 @@ function ke(e) {
189
197
  });
190
198
  }
191
199
  const We = 2e-4;
192
- async function Ht({
200
+ async function Jt({
193
201
  env: e,
194
202
  chainId: t = a.ethereum,
195
203
  amount: n = 1
196
204
  }) {
197
- const { baseApiUrl: s } = C(e), i = X(t), { data: r } = await R.get(
205
+ const { baseApiUrl: s } = C(e), i = K(t), { data: r } = await R.get(
198
206
  `api/v1/exchange/rate/${i}`,
199
207
  { baseURL: s, params: { amount: n } }
200
- ), p = new A(We).multipliedBy(K).toFixed();
208
+ ), p = new v(We).multipliedBy(Y).toFixed();
201
209
  return { exchangeRate: +r.amount_out, minAmount: +p };
202
210
  }
203
- async function Jt({
211
+ async function jt({
204
212
  address: e,
205
213
  chainId: t,
206
214
  env: n
@@ -226,7 +234,7 @@ async function Jt({
226
234
  throw new Error(r);
227
235
  }
228
236
  }
229
- async function jt({
237
+ async function qt({
230
238
  signature: e,
231
239
  typedData: t,
232
240
  address: n,
@@ -271,14 +279,14 @@ async function Ve(e) {
271
279
  method: "eth_maxPriorityFeePerGas",
272
280
  params: []
273
281
  })
274
- })).json(), s = de.utils.hexToNumber(n == null ? void 0 : n.result);
275
- return new A(Number(s));
282
+ })).json(), s = ye.utils.hexToNumber(n == null ? void 0 : n.result);
283
+ return new v(Number(s));
276
284
  }
277
285
  const $e = 2, He = 25e3;
278
286
  class q {
279
287
  constructor({ chainId: t, rpcUrlConfig: n }) {
280
- v(this, "chainId");
281
- v(this, "rpcConfig");
288
+ A(this, "chainId");
289
+ A(this, "rpcConfig");
282
290
  this.chainId = t, this.rpcConfig = { ...N, ...n };
283
291
  }
284
292
  /**
@@ -288,7 +296,7 @@ class q {
288
296
  * @returns {Web3} Web3 instance.
289
297
  */
290
298
  getReadWeb3() {
291
- const t = this.getRpcUrl(), n = new ie(), s = new ie.providers.HttpProvider(t);
299
+ const t = this.getRpcUrl(), n = new re(), s = new re.providers.HttpProvider(t);
292
300
  return n.setProvider(s), n;
293
301
  }
294
302
  /**
@@ -319,7 +327,7 @@ class q {
319
327
  Ve(n)
320
328
  ]);
321
329
  return !(s != null && s.baseFeePerGas) && typeof (s == null ? void 0 : s.baseFeePerGas) != "bigint" ? {} : {
322
- maxFeePerGas: +new A(s.baseFeePerGas.toString(10)).multipliedBy($e).plus(i),
330
+ maxFeePerGas: +new v(s.baseFeePerGas.toString(10)).multipliedBy($e).plus(i),
323
331
  maxPriorityFeePerGas: +i
324
332
  };
325
333
  }
@@ -331,7 +339,7 @@ class q {
331
339
  */
332
340
  async getSafeGasPriceWei() {
333
341
  const t = await this.getReadWeb3().eth.getGasPrice();
334
- return new A(t.toString(10)).plus(
342
+ return new v(t.toString(10)).plus(
335
343
  He
336
344
  );
337
345
  }
@@ -351,10 +359,10 @@ class q {
351
359
  class I extends q {
352
360
  constructor({ provider: n, account: s, chainId: i, rpcUrlConfig: r }) {
353
361
  super({ chainId: i, rpcUrlConfig: r });
354
- v(this, "web3");
355
- v(this, "account");
356
- v(this, "rpcConfig", N);
357
- this.web3 = new de(n), this.account = s, this.chainId = i, this.rpcConfig = { ...N, ...r };
362
+ A(this, "web3");
363
+ A(this, "account");
364
+ A(this, "rpcConfig", N);
365
+ this.web3 = new ye(n), this.account = s, this.chainId = i, this.rpcConfig = { ...N, ...r };
358
366
  }
359
367
  /**
360
368
  * Signs a message using the current provider and account.
@@ -384,35 +392,35 @@ class I extends q {
384
392
  estimate: h = !1,
385
393
  estimateFee: l = !1,
386
394
  extendedGasLimit: g,
387
- gasLimit: _ = "0",
395
+ gasLimit: x = "0",
388
396
  value: fe = "0",
389
- gasLimitMultiplier: be = 1
397
+ gasLimitMultiplier: Te = 1
390
398
  } = i;
391
- let { nonce: M } = i;
392
- M || (M = await u.eth.getTransactionCount(n)), console.log(`Nonce: ${M}`);
399
+ let { nonce: D } = i;
400
+ D || (D = await u.eth.getTransactionCount(n)), console.log(`Nonce: ${D}`);
393
401
  const y = {
394
402
  from: n,
395
403
  to: s,
396
404
  value: w.numberToHex(fe),
397
405
  data: d,
398
- nonce: M,
406
+ nonce: D,
399
407
  chainId: w.numberToHex(r)
400
408
  };
401
409
  if (h)
402
410
  try {
403
- const T = await u.eth.estimateGas(y), D = Math.round(
404
- Number(T) * be
411
+ const T = await u.eth.estimateGas(y), M = Math.round(
412
+ Number(T) * Te
405
413
  );
406
- g ? y.gas = w.numberToHex(D + g) : y.gas = w.numberToHex(D);
414
+ g ? y.gas = w.numberToHex(M + g) : y.gas = w.numberToHex(M);
407
415
  } catch (T) {
408
416
  throw new Error(
409
417
  T.message ?? "Failed to estimate gas limit for transaction."
410
418
  );
411
419
  }
412
420
  else
413
- y.gas = w.numberToHex(_);
414
- const { maxFeePerGas: te, maxPriorityFeePerGas: ne } = l ? await this.getMaxFees().catch(() => i) : i;
415
- if (ne !== void 0 && (y.maxPriorityFeePerGas = w.numberToHex(ne)), te !== void 0 && (y.maxFeePerGas = w.numberToHex(te)), !y.maxFeePerGas && !y.maxPriorityFeePerGas) {
421
+ y.gas = w.numberToHex(x);
422
+ const { maxFeePerGas: ne, maxPriorityFeePerGas: ae } = l ? await this.getMaxFees().catch(() => i) : i;
423
+ if (ae !== void 0 && (y.maxPriorityFeePerGas = w.numberToHex(ae)), ne !== void 0 && (y.maxFeePerGas = w.numberToHex(ne)), !y.maxFeePerGas && !y.maxPriorityFeePerGas) {
416
424
  const T = await this.getSafeGasPriceWei();
417
425
  y.gasPrice = T.toString(10);
418
426
  }
@@ -420,21 +428,21 @@ class I extends q {
420
428
  const T = await this.getSafeGasPriceWei();
421
429
  y.gasPrice = T.toString(10);
422
430
  }
423
- return console.log("Sending transaction via Web3: ", y), new Promise((T, D) => {
424
- const ae = p.eth.sendTransaction(y);
425
- ae.once("transactionHash", async (se) => {
426
- console.log(`Just signed transaction has is: ${se}`), T({
427
- receiptPromise: ae,
428
- transactionHash: se
431
+ return console.log("Sending transaction via Web3: ", y), new Promise((T, M) => {
432
+ const se = p.eth.sendTransaction(y);
433
+ se.once("transactionHash", async (ie) => {
434
+ console.log(`Just signed transaction has is: ${ie}`), T({
435
+ receiptPromise: se,
436
+ transactionHash: ie
429
437
  });
430
- }).catch(D);
438
+ }).catch(M);
431
439
  });
432
440
  }
433
441
  createContract(n, s) {
434
442
  return new this.web3.eth.Contract(n, s);
435
443
  }
436
444
  }
437
- function Y(e) {
445
+ function Q(e) {
438
446
  switch (e) {
439
447
  case a.ethereum:
440
448
  return 1.3;
@@ -445,7 +453,7 @@ function Y(e) {
445
453
  return 1.3;
446
454
  }
447
455
  }
448
- function Q(e) {
456
+ function ee(e) {
449
457
  return Object.values(a).includes(e);
450
458
  }
451
459
  const Je = {
@@ -480,7 +488,7 @@ const Je = {
480
488
  [a.berachainBartioTestnet]: o,
481
489
  [a.corn]: "0xecAc9C5F704e954931349Da37F60E39f515c11c1"
482
490
  };
483
- function Ze(e = x) {
491
+ function Ze(e = _) {
484
492
  switch (e) {
485
493
  case c.prod:
486
494
  return qe;
@@ -3331,7 +3339,7 @@ function Ye(e) {
3331
3339
  }
3332
3340
  function E(e, t) {
3333
3341
  const n = Ze(t), { chainId: s } = e;
3334
- if (!Q(s))
3342
+ if (!ee(s))
3335
3343
  throw new Error(`This chain ${s} is not supported`);
3336
3344
  const i = n[s];
3337
3345
  if (!i)
@@ -3339,13 +3347,13 @@ function E(e, t) {
3339
3347
  const r = Ye("LBTC"), p = e.createContract(r, i);
3340
3348
  return p.options.address || (p.options.address = i), p;
3341
3349
  }
3342
- function qt({
3350
+ function Zt({
3343
3351
  spender: e,
3344
3352
  amount: t,
3345
3353
  env: n,
3346
3354
  ...s
3347
3355
  }) {
3348
- const i = new I(s), r = E(i, n), p = ye(t), u = r.methods.approve(e, p);
3356
+ const i = new I(s), r = E(i, n), p = ce(t), u = r.methods.approve(e, p);
3349
3357
  return i.sendTransactionAsync(
3350
3358
  i.account,
3351
3359
  r.options.address,
@@ -3353,18 +3361,18 @@ function qt({
3353
3361
  data: u.encodeABI(),
3354
3362
  estimate: !0,
3355
3363
  estimateFee: !0,
3356
- gasLimitMultiplier: Y(i.chainId)
3364
+ gasLimitMultiplier: Q(i.chainId)
3357
3365
  }
3358
3366
  );
3359
3367
  }
3360
- const Qe = "insufficient funds", et = "Insufficient funds for transfer. Make sure you have enough ETH to cover the gas cost.", oe = (e) => e.startsWith("0x") ? e : "0x" + e;
3361
- async function Zt({
3368
+ const Qe = "insufficient funds", et = "Insufficient funds for transfer. Make sure you have enough ETH to cover the gas cost.", pe = (e) => e.startsWith("0x") ? e : "0x" + e;
3369
+ async function zt({
3362
3370
  data: e,
3363
3371
  proofSignature: t,
3364
3372
  env: n,
3365
3373
  ...s
3366
3374
  }) {
3367
- const i = new I(s), r = E(i, n), p = r.methods.mint(oe(e), oe(t));
3375
+ const i = new I(s), r = E(i, n), p = r.methods.mint(pe(e), pe(t));
3368
3376
  try {
3369
3377
  return await i.sendTransactionAsync(
3370
3378
  i.account,
@@ -3373,7 +3381,7 @@ async function Zt({
3373
3381
  data: p.encodeABI(),
3374
3382
  estimate: !0,
3375
3383
  estimateFee: !0,
3376
- gasLimitMultiplier: Y(i.chainId)
3384
+ gasLimitMultiplier: Q(i.chainId)
3377
3385
  }
3378
3386
  );
3379
3387
  } catch (u) {
@@ -3382,22 +3390,22 @@ async function Zt({
3382
3390
  throw d.includes(Qe) ? new Error(et) : new Error(d);
3383
3391
  }
3384
3392
  }
3385
- const tt = 208, nt = 4001, at = 4100, st = 4200, it = 4900, rt = 4901, P = -32700, U = -32600, O = -32601, F = -32602, L = -32603, B = -32e3, G = -32001, k = -32002, W = -32003, V = -32004, $ = -32005, H = -32006;
3386
- class ce extends Error {
3393
+ const tt = 208, nt = 4001, at = 4100, st = 4200, it = 4900, rt = 4901, P = -32700, O = -32600, U = -32601, F = -32602, B = -32603, L = -32e3, G = -32001, k = -32002, W = -32003, V = -32004, $ = -32005, H = -32006;
3394
+ class le extends Error {
3387
3395
  constructor(t, n) {
3388
- super(t), Array.isArray(n) ? this.cause = new Z(n) : this.cause = n, this.name = this.constructor.name, typeof Error.captureStackTrace == "function" ? Error.captureStackTrace(new.target.constructor) : this.stack = new Error().stack;
3396
+ super(t), Array.isArray(n) ? this.cause = new z(n) : this.cause = n, this.name = this.constructor.name, typeof Error.captureStackTrace == "function" ? Error.captureStackTrace(new.target.constructor) : this.stack = new Error().stack;
3389
3397
  }
3390
3398
  /**
3391
3399
  * @deprecated Use the `cause` property instead.
3392
3400
  */
3393
3401
  get innerError() {
3394
- return this.cause instanceof Z ? this.cause.errors : this.cause;
3402
+ return this.cause instanceof z ? this.cause.errors : this.cause;
3395
3403
  }
3396
3404
  /**
3397
3405
  * @deprecated Use the `cause` property instead.
3398
3406
  */
3399
3407
  set innerError(t) {
3400
- Array.isArray(t) ? this.cause = new Z(t) : this.cause = t;
3408
+ Array.isArray(t) ? this.cause = new z(t) : this.cause = t;
3401
3409
  }
3402
3410
  static convertToString(t, n = !1) {
3403
3411
  if (t == null)
@@ -3416,7 +3424,7 @@ class ce extends Error {
3416
3424
  };
3417
3425
  }
3418
3426
  }
3419
- class Z extends ce {
3427
+ class z extends le {
3420
3428
  constructor(t) {
3421
3429
  super(`Multiple errors occurred: [${t.map((n) => n.message).join("], [")}]`), this.code = tt, this.errors = t;
3422
3430
  }
@@ -3428,11 +3436,11 @@ const ot = "An Rpc error has occured with a code of *code*", m = {
3428
3436
  message: "Parse error",
3429
3437
  description: "Invalid JSON"
3430
3438
  },
3431
- [U]: {
3439
+ [O]: {
3432
3440
  message: "Invalid request",
3433
3441
  description: "JSON is not a valid request object "
3434
3442
  },
3435
- [O]: {
3443
+ [U]: {
3436
3444
  message: "Method not found",
3437
3445
  description: "Method does not exist "
3438
3446
  },
@@ -3440,11 +3448,11 @@ const ot = "An Rpc error has occured with a code of *code*", m = {
3440
3448
  message: "Invalid params",
3441
3449
  description: "Invalid method parameters"
3442
3450
  },
3443
- [L]: {
3451
+ [B]: {
3444
3452
  message: "Internal error",
3445
3453
  description: "Internal JSON-RPC error"
3446
3454
  },
3447
- [B]: {
3455
+ [L]: {
3448
3456
  message: "Invalid input",
3449
3457
  description: "Missing or invalid parameters"
3450
3458
  },
@@ -3577,7 +3585,7 @@ const ot = "An Rpc error has occured with a code of *code*", m = {
3577
3585
  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."
3578
3586
  }
3579
3587
  };
3580
- class f extends ce {
3588
+ class b extends le {
3581
3589
  constructor(t, n) {
3582
3590
  super(n ?? ot.replace("*code*", t.error.code.toString())), this.code = t.error.code, this.id = t.id, this.jsonrpc = t.jsonrpc, this.jsonRpcError = t.error;
3583
3591
  }
@@ -3585,93 +3593,93 @@ class f extends ce {
3585
3593
  return Object.assign(Object.assign({}, super.toJSON()), { error: this.jsonRpcError, id: this.id, jsonRpc: this.jsonrpc });
3586
3594
  }
3587
3595
  }
3588
- class pt extends f {
3596
+ class pt extends b {
3589
3597
  constructor(t) {
3590
3598
  super(t, m[P].message), this.code = P;
3591
3599
  }
3592
3600
  }
3593
- class ut extends f {
3601
+ class ut extends b {
3594
3602
  constructor(t) {
3595
- super(t, m[U].message), this.code = U;
3603
+ super(t, m[O].message), this.code = O;
3596
3604
  }
3597
3605
  }
3598
- class dt extends f {
3606
+ class dt extends b {
3599
3607
  constructor(t) {
3600
- super(t, m[O].message), this.code = O;
3608
+ super(t, m[U].message), this.code = U;
3601
3609
  }
3602
3610
  }
3603
- class yt extends f {
3611
+ class yt extends b {
3604
3612
  constructor(t) {
3605
3613
  super(t, m[F].message), this.code = F;
3606
3614
  }
3607
3615
  }
3608
- class ct extends f {
3616
+ class ct extends b {
3609
3617
  constructor(t) {
3610
- super(t, m[L].message), this.code = L;
3618
+ super(t, m[B].message), this.code = B;
3611
3619
  }
3612
3620
  }
3613
- class lt extends f {
3621
+ class lt extends b {
3614
3622
  constructor(t) {
3615
- super(t, m[B].message), this.code = B;
3623
+ super(t, m[L].message), this.code = L;
3616
3624
  }
3617
3625
  }
3618
- class mt extends f {
3626
+ class mt extends b {
3619
3627
  constructor(t) {
3620
3628
  super(t, m[V].message), this.code = V;
3621
3629
  }
3622
3630
  }
3623
- class ft extends f {
3631
+ class bt extends b {
3624
3632
  constructor(t) {
3625
3633
  super(t, m[k].message), this.code = k;
3626
3634
  }
3627
3635
  }
3628
- class bt extends f {
3636
+ class ft extends b {
3629
3637
  constructor(t) {
3630
3638
  super(t, m[G].message), this.code = G;
3631
3639
  }
3632
3640
  }
3633
- class Tt extends f {
3641
+ class Tt extends b {
3634
3642
  constructor(t) {
3635
3643
  super(t, m[H].message), this.code = H;
3636
3644
  }
3637
3645
  }
3638
- class ht extends f {
3646
+ class ht extends b {
3639
3647
  constructor(t) {
3640
3648
  super(t, m[W].message), this.code = W;
3641
3649
  }
3642
3650
  }
3643
- class gt extends f {
3651
+ class gt extends b {
3644
3652
  constructor(t) {
3645
3653
  super(t, m[$].message), this.code = $;
3646
3654
  }
3647
3655
  }
3648
- const b = /* @__PURE__ */ new Map();
3649
- b.set(P, { error: pt });
3650
- b.set(U, {
3656
+ const f = /* @__PURE__ */ new Map();
3657
+ f.set(P, { error: pt });
3658
+ f.set(O, {
3651
3659
  error: ut
3652
3660
  });
3653
- b.set(O, {
3661
+ f.set(U, {
3654
3662
  error: dt
3655
3663
  });
3656
- b.set(F, { error: yt });
3657
- b.set(L, { error: ct });
3658
- b.set(B, { error: lt });
3659
- b.set(V, {
3664
+ f.set(F, { error: yt });
3665
+ f.set(B, { error: ct });
3666
+ f.set(L, { error: lt });
3667
+ f.set(V, {
3660
3668
  error: mt
3661
3669
  });
3662
- b.set(k, {
3663
- error: ft
3670
+ f.set(k, {
3671
+ error: bt
3664
3672
  });
3665
- b.set(W, {
3673
+ f.set(W, {
3666
3674
  error: ht
3667
3675
  });
3668
- b.set(G, {
3669
- error: bt
3676
+ f.set(G, {
3677
+ error: ft
3670
3678
  });
3671
- b.set(H, {
3679
+ f.set(H, {
3672
3680
  error: Tt
3673
3681
  });
3674
- b.set($, { error: gt });
3682
+ f.set($, { error: gt });
3675
3683
  const wt = (e) => typeof e == "string" && /^((-)?0x[0-9a-f]+|(0x))$/i.test(e);
3676
3684
  var J;
3677
3685
  (function(e) {
@@ -3683,14 +3691,14 @@ var j;
3683
3691
  })(j || (j = {}));
3684
3692
  J.BIGINT, j.HEX;
3685
3693
  J.HEX, j.HEX;
3686
- var pe;
3694
+ var ue;
3687
3695
  (function(e) {
3688
3696
  e.EARLIEST = "earliest", e.LATEST = "latest", e.PENDING = "pending", e.SAFE = "safe", e.FINALIZED = "finalized";
3689
- })(pe || (pe = {}));
3690
- var ue;
3697
+ })(ue || (ue = {}));
3698
+ var de;
3691
3699
  (function(e) {
3692
3700
  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";
3693
- })(ue || (ue = {}));
3701
+ })(de || (de = {}));
3694
3702
  const Et = {
3695
3703
  [a.holesky]: "0x3a0c40c84b5034ed9a98a9a47a02af2b0885246f",
3696
3704
  [a.sepolia]: o,
@@ -3701,7 +3709,7 @@ const Et = {
3701
3709
  [a.baseTestnet]: o,
3702
3710
  [a.berachainBartioTestnet]: o,
3703
3711
  [a.corn]: o
3704
- }, vt = {
3712
+ }, At = {
3705
3713
  [a.holesky]: "0x3a0c40c84b5034ed9a98a9a47a02af2b0885246f",
3706
3714
  [a.sepolia]: o,
3707
3715
  [a.ethereum]: o,
@@ -3711,7 +3719,7 @@ const Et = {
3711
3719
  [a.baseTestnet]: o,
3712
3720
  [a.berachainBartioTestnet]: o,
3713
3721
  [a.corn]: o
3714
- }, At = {
3722
+ }, vt = {
3715
3723
  [a.holesky]: o,
3716
3724
  [a.sepolia]: o,
3717
3725
  [a.ethereum]: "0xc750eCAC7250E0D18ecE2C7a5F130E3A765dc260",
@@ -3722,19 +3730,19 @@ const Et = {
3722
3730
  [a.berachainBartioTestnet]: o,
3723
3731
  [a.corn]: o
3724
3732
  };
3725
- function Rt(e = x) {
3733
+ function Rt(e = _) {
3726
3734
  switch (e) {
3727
3735
  case c.prod:
3728
- return At;
3729
- case c.testnet:
3730
3736
  return vt;
3737
+ case c.testnet:
3738
+ return At;
3731
3739
  default:
3732
3740
  return Et;
3733
3741
  }
3734
3742
  }
3735
3743
  function Ct(e, t) {
3736
3744
  const n = Rt(t), { chainId: s } = e;
3737
- if (!Q(s))
3745
+ if (!ee(s))
3738
3746
  throw new Error(`This chain ${s} is not supported`);
3739
3747
  const i = n[s];
3740
3748
  if (!i)
@@ -3743,8 +3751,8 @@ function Ct(e, t) {
3743
3751
  return r.options.address || (r.options.address = i), r;
3744
3752
  }
3745
3753
  const St = "No deposit ID provided. Please provide a deposit ID as an argument.", It = "Invalid deposit ID. Expected a 0x-prefixed 32-byte hex string.";
3746
- var xt = /* @__PURE__ */ ((e) => (e[e.UNREPORTED = 0] = "UNREPORTED", e[e.REPORTED = 1] = "REPORTED", e[e.WITHDRAWN = 2] = "WITHDRAWN", e))(xt || {});
3747
- async function zt({
3754
+ var _t = /* @__PURE__ */ ((e) => (e[e.UNREPORTED = 0] = "UNREPORTED", e[e.REPORTED = 1] = "REPORTED", e[e.WITHDRAWN = 2] = "WITHDRAWN", e))(_t || {});
3755
+ async function Xt({
3748
3756
  txId: e,
3749
3757
  env: t,
3750
3758
  ...n
@@ -3762,24 +3770,24 @@ async function zt({
3762
3770
  throw new Error(p);
3763
3771
  }
3764
3772
  }
3765
- const le = (e) => e in [a.ethereum, a.base, a.binanceSmartChain] ? c.prod : c.stage;
3766
- function me(e, t) {
3767
- if (!Q(e))
3773
+ const me = (e) => e in [a.ethereum, a.base, a.binanceSmartChain] ? c.prod : c.stage;
3774
+ function be(e, t) {
3775
+ if (!ee(e))
3768
3776
  throw new Error(`This chain ${e} is not supported`);
3769
3777
  const n = t ? { [e]: t } : N;
3770
3778
  if (!n[e])
3771
3779
  throw new Error(`RPC URL for chainId ${e} not found`);
3772
3780
  return n;
3773
3781
  }
3774
- async function Xt({
3782
+ async function Kt({
3775
3783
  chainId: e,
3776
3784
  bakeGasEstimate: t = 0,
3777
3785
  rpcUrl: n
3778
3786
  }) {
3779
- const s = me(e, n), i = new q({ chainId: e, rpcUrlConfig: s }), r = le(e), u = await E(i, r).methods.getMintFee().call(), d = new A(z(u.toString(10)));
3780
- return t ? d.plus(z(t)) : d;
3787
+ const s = be(e, n), i = new q({ chainId: e, rpcUrlConfig: s }), r = me(e), u = await E(i, r).methods.getMintFee().call(), d = new v(X(u.toString(10)));
3788
+ return t ? d.plus(X(t)) : d;
3781
3789
  }
3782
- async function Kt({
3790
+ async function Yt({
3783
3791
  env: e,
3784
3792
  rpcUrl: t,
3785
3793
  chainId: n
@@ -3787,12 +3795,12 @@ async function Kt({
3787
3795
  const s = { [n]: t }, i = new q({ chainId: n, rpcUrlConfig: s });
3788
3796
  return (await E(i, e).methods.totalSupply().call()).toString();
3789
3797
  }
3790
- async function Yt({
3798
+ async function Qt({
3791
3799
  owner: e,
3792
3800
  rpcUrl: t,
3793
3801
  chainId: n
3794
3802
  }) {
3795
- const s = me(n, t), i = new q({ chainId: n, rpcUrlConfig: s }), r = le(n), p = E(i, r);
3803
+ const s = be(n, t), i = new q({ chainId: n, rpcUrlConfig: s }), r = me(n), p = E(i, r);
3796
3804
  try {
3797
3805
  return (await p.methods.nonces(e).call()).toString();
3798
3806
  } catch (u) {
@@ -3800,33 +3808,34 @@ async function Yt({
3800
3808
  throw new Error(d);
3801
3809
  }
3802
3810
  }
3803
- const ee = {
3811
+ const te = {
3804
3812
  [a.sepolia]: "0xe3748bF0Ec0A76767539eE28610B3367e35fe2C2",
3805
3813
  [a.berachainBartioTestnet]: "0x1977013acaf27856ac8048C42EE2ed0134d53895",
3806
3814
  [a.corn]: o,
3807
3815
  [a.ethereum]: o
3808
- }, _t = {
3809
- ...ee
3810
- }, Mt = {
3811
- ...ee,
3816
+ }, xt = {
3817
+ ...te
3818
+ }, Dt = {
3819
+ ...te,
3812
3820
  [a.corn]: "0xfc7B20D9B59A8A466f4fC3d34aA69a7D98e71d7A",
3813
3821
  [a.ethereum]: "0x6bc15d7930839ec18a57f6f7df72ae1b439d077f"
3814
3822
  };
3815
- function Qt(e = x) {
3823
+ function en(e = _) {
3816
3824
  switch (e) {
3817
3825
  case c.prod:
3818
- return Mt;
3826
+ return Dt;
3819
3827
  case c.testnet:
3820
- return _t;
3828
+ return xt;
3821
3829
  default:
3822
- return ee;
3830
+ return te;
3823
3831
  }
3824
3832
  }
3825
- async function en(e) {
3833
+ async function tn(e) {
3826
3834
  const t = new I(e), n = `destination chain id is ${e.chainId}`;
3827
3835
  return t.signMessage(n);
3828
3836
  }
3829
- function Dt({
3837
+ const Mt = 24 * 60 * 60;
3838
+ function Nt({
3830
3839
  chainId: e,
3831
3840
  verifyingContract: t,
3832
3841
  fee: n,
@@ -3860,38 +3869,43 @@ function Dt({
3860
3869
  }
3861
3870
  };
3862
3871
  }
3863
- const Nt = "Failed to obtain a valid signature. The response is undefined or invalid.";
3864
- async function tn({
3872
+ const Pt = "Failed to obtain a valid signature. The response is undefined or invalid.";
3873
+ async function nn({
3865
3874
  address: e,
3866
3875
  provider: t,
3867
3876
  fee: n,
3868
- expiry: s,
3869
- chainId: i,
3870
- env: r
3877
+ chainId: s,
3878
+ env: i,
3879
+ expiry: r = Date.now() + Mt
3871
3880
  }) {
3872
- var g, _;
3881
+ var g, x;
3873
3882
  const p = new I({
3874
3883
  provider: t,
3875
3884
  account: e,
3876
- chainId: i
3877
- }), d = E(p, r).options.address, h = JSON.stringify(
3878
- Dt({ chainId: i, verifyingContract: d, fee: n, expiry: s })
3879
- ), l = await ((_ = (g = p.web3) == null ? void 0 : g.currentProvider) == null ? void 0 : _.request({
3885
+ chainId: s
3886
+ }), d = E(p, i).options.address, h = JSON.stringify(
3887
+ Nt({
3888
+ chainId: s,
3889
+ verifyingContract: d,
3890
+ fee: n,
3891
+ expiry: r.toString()
3892
+ })
3893
+ ), l = await ((x = (g = p.web3) == null ? void 0 : g.currentProvider) == null ? void 0 : x.request({
3880
3894
  method: "eth_signTypedData_v4",
3881
3895
  params: [e, h]
3882
3896
  }));
3883
3897
  if (typeof l == "string")
3884
3898
  return { signature: l, typedData: h };
3885
3899
  if (!(l != null && l.result))
3886
- throw new Error(Nt);
3900
+ throw new Error(Pt);
3887
3901
  return { signature: l.result, typedData: h };
3888
3902
  }
3889
- we(ge);
3890
- function Pt(e, t = c.prod) {
3903
+ Ee(we);
3904
+ function Ot(e, t = c.prod) {
3891
3905
  var r;
3892
- const n = Ut(e), i = (r = Ee[n]({
3906
+ const n = Ut(e), i = (r = Ae[n]({
3893
3907
  address: e,
3894
- network: t === c.prod ? re.bitcoin : re.testnet
3908
+ network: t === c.prod ? oe.bitcoin : oe.testnet
3895
3909
  }).output) == null ? void 0 : r.toString("hex");
3896
3910
  if (!i)
3897
3911
  throw new Error("Output script is not found.");
@@ -3903,20 +3917,20 @@ function Ut(e) {
3903
3917
  return "p2tr";
3904
3918
  if (t.version === 0 && t.data.length === 20)
3905
3919
  return "p2wpkh";
3906
- if (Ot(e))
3920
+ if (Ft(e))
3907
3921
  return "p2wsh";
3908
3922
  throw new Error("Address type is not supported.");
3909
3923
  }
3910
- function Ot(e) {
3924
+ function Ft(e) {
3911
3925
  return (e.startsWith("bc1") || e.startsWith("tb1")) && e.length === 62;
3912
3926
  }
3913
- function nn({
3927
+ function an({
3914
3928
  btcAddress: e,
3915
3929
  amount: t,
3916
3930
  env: n,
3917
3931
  ...s
3918
3932
  }) {
3919
- const i = new I(s), r = E(i, n), p = Pt(e, n), u = ye(t), d = r.methods.redeem(p, u);
3933
+ const i = new I(s), r = E(i, n), p = Ot(e, n), u = ce(t), d = r.methods.redeem(p, u);
3920
3934
  return i.sendTransactionAsync(
3921
3935
  i.account,
3922
3936
  r.options.address,
@@ -3924,39 +3938,39 @@ function nn({
3924
3938
  data: d.encodeABI(),
3925
3939
  estimate: !0,
3926
3940
  estimateFee: !0,
3927
- gasLimitMultiplier: Y(i.chainId)
3941
+ gasLimitMultiplier: Q(i.chainId)
3928
3942
  }
3929
3943
  );
3930
3944
  }
3931
3945
  export {
3932
- xt as BasculeDepositStatus,
3933
- Be as ENotarizationStatus,
3946
+ _t as BasculeDepositStatus,
3947
+ Le as ENotarizationStatus,
3934
3948
  Ge as ESessionState,
3935
3949
  a as OChainId,
3936
3950
  c as OEnv,
3937
- _e as SANCTIONED_ADDRESS,
3938
- K as SATOSHI_SCALE,
3939
- qt as approveLBTC,
3940
- Zt as claimLBTC,
3941
- z as fromSatoshi,
3942
- Wt as generateDepositBtcAddress,
3951
+ xe as SANCTIONED_ADDRESS,
3952
+ Y as SATOSHI_SCALE,
3953
+ Zt as approveLBTC,
3954
+ zt as claimLBTC,
3955
+ X as fromSatoshi,
3956
+ Vt as generateDepositBtcAddress,
3943
3957
  C as getApiConfig,
3944
- zt as getBasculeDepositStatus,
3945
- Vt as getDepositBtcAddress,
3946
- Oe as getDepositBtcAddresses,
3947
- $t as getDepositsByAddress,
3948
- Ht as getLBTCExchangeRate,
3949
- Xt as getLBTCMintingFee,
3950
- Kt as getLBTCTotalSupply,
3958
+ Xt as getBasculeDepositStatus,
3959
+ $t as getDepositBtcAddress,
3960
+ Ue as getDepositBtcAddresses,
3961
+ Ht as getDepositsByAddress,
3962
+ Jt as getLBTCExchangeRate,
3963
+ Kt as getLBTCMintingFee,
3964
+ Yt as getLBTCTotalSupply,
3951
3965
  Ze as getLbtcAddressConfig,
3952
- Qt as getLbtcOFTAdapterAddressConfig,
3953
- Jt as getNetworkFeeSignature,
3954
- Yt as getPermitNonce,
3955
- Q as isValidChain,
3956
- en as signLbtcDestionationAddr,
3957
- tn as signNetworkFee,
3958
- jt as storeNetworkFeeSignature,
3959
- ye as toSatoshi,
3960
- nn as unstakeLBTC
3966
+ en as getLbtcOFTAdapterAddressConfig,
3967
+ jt as getNetworkFeeSignature,
3968
+ Qt as getPermitNonce,
3969
+ ee as isValidChain,
3970
+ tn as signLbtcDestionationAddr,
3971
+ nn as signNetworkFee,
3972
+ qt as storeNetworkFeeSignature,
3973
+ ce as toSatoshi,
3974
+ an as unstakeLBTC
3961
3975
  };
3962
3976
  //# sourceMappingURL=index.js.map