@lombard.finance/sdk 2.0.5 → 2.0.8

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.
Files changed (30) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.js +488 -1719
  4. package/dist/index.js.map +1 -1
  5. package/package.json +1 -1
  6. package/src/common/types/types.ts +3 -1
  7. package/src/sdk/const.ts +1 -1
  8. package/src/sdk/generateDepositBtcAddress/generateDepositBtcAddress.ts +8 -2
  9. package/src/sdk/getLBTCExchangeRate/getLBTCExchangeRate.ts +2 -2
  10. package/src/sdk/getNetworkFeeSignature/getNetworkFeeSignature.stories.tsx +2 -2
  11. package/src/sdk/index.ts +2 -0
  12. package/src/sdk/storeNetworkFeeSignature/storeNetworkFeeSignature.stories.tsx +3 -3
  13. package/src/sdk/storeStakeAndBakeSignature/index.ts +1 -0
  14. package/src/sdk/storeStakeAndBakeSignature/storeStakeAndBakeSignature.stories.tsx +143 -0
  15. package/src/sdk/storeStakeAndBakeSignature/storeStakeAndBakeSignature.ts +56 -0
  16. package/src/web3Sdk/getBasculeDepositStatus/getBasculeDepositStatus.ts +12 -1
  17. package/src/web3Sdk/getLBTCMintingFee/getLBTCMintingFee.stories.tsx +2 -2
  18. package/src/web3Sdk/index.ts +2 -11
  19. package/src/web3Sdk/lbtcAddressConfig.ts +4 -1
  20. package/src/web3Sdk/lbtcOFTAdapterAddressConfig.ts +21 -12
  21. package/src/web3Sdk/signNetworkFee/getTypedData.ts +1 -1
  22. package/src/web3Sdk/signNetworkFee/signNetworkFee.ts +6 -2
  23. package/src/web3Sdk/signStakeAndBake/config.ts +13 -0
  24. package/src/web3Sdk/signStakeAndBake/getTypedData.ts +82 -0
  25. package/src/web3Sdk/signStakeAndBake/index.ts +2 -0
  26. package/src/web3Sdk/signStakeAndBake/signStakeAndBake.stories.tsx +143 -0
  27. package/src/web3Sdk/signStakeAndBake/signStakeAndBake.ts +99 -0
  28. package/src/web3Sdk/utils/chainIdToEnv.ts +7 -6
  29. package/src/web3Sdk/utils/getBasculeTokenContract.ts +4 -13
  30. package/src/web3Sdk/basculeAddressConfig.ts +0 -68
package/dist/index.js CHANGED
@@ -1,16 +1,14 @@
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
- import C from "axios";
5
- import R 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
- const d = {
1
+ var z = Object.defineProperty;
2
+ var q = (e, t, n) => t in e ? z(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var A = (e, t, n) => (q(e, typeof t != "symbol" ? t + "" : t, n), n);
4
+ import h from "axios";
5
+ import v from "bignumber.js";
6
+ import H, { Web3 as G, utils as g } from "web3";
7
+ const T = {
10
8
  prod: "prod",
11
9
  testnet: "testnet",
12
10
  stage: "stage"
13
- }, a = {
11
+ }, s = {
14
12
  ethereum: 1,
15
13
  holesky: 17e3,
16
14
  binanceSmartChain: 56,
@@ -19,36 +17,37 @@ const d = {
19
17
  base: 8453,
20
18
  baseTestnet: 84532,
21
19
  berachainBartioTestnet: 80084,
22
- corn: 21e6
23
- }, Re = (e) => e === d.prod ? a.ethereum : a.holesky, Ce = (e) => e === d.prod ? a.binanceSmartChain : a.binanceSmartChainTestnet, Se = (e) => e === d.prod ? a.base : a.baseTestnet, x = d.prod, o = "0x0000000000000000000000000000000000000000", Ie = {
20
+ corn: 21e6,
21
+ swell: 1923
22
+ }, j = (e) => e === T.prod ? s.ethereum : s.holesky, J = (e) => e === T.prod ? s.binanceSmartChain : s.binanceSmartChainTestnet, X = (e) => e === T.prod ? s.base : s.baseTestnet, N = T.prod, u = "0x0000000000000000000000000000000000000000", Y = {
24
23
  baseApiUrl: "https://staging.prod.lombard.finance"
25
- }, _e = {
24
+ }, Q = {
26
25
  baseApiUrl: "https://gastald-testnet.prod.lombard.finance"
27
- }, xe = {
26
+ }, ee = {
28
27
  baseApiUrl: "https://mainnet.prod.lombard.finance"
29
- }, S = (e = x) => {
28
+ }, w = (e = N) => {
30
29
  switch (e) {
31
- case d.prod:
32
- return xe;
33
- case d.testnet:
34
- return _e;
30
+ case T.prod:
31
+ return ee;
32
+ case T.testnet:
33
+ return Q;
35
34
  default:
36
- return Ie;
35
+ return Y;
37
36
  }
38
37
  };
39
- function I(e) {
38
+ function C(e) {
40
39
  return typeof e == "string" ? e : ((n) => {
41
- var s;
42
- return ((s = n == null ? void 0 : n.data) == null ? void 0 : s.message) && typeof n.data.message == "string";
43
- })(e) ? e.data.message : e instanceof Error ? De(e) : Me(e);
40
+ var a;
41
+ return ((a = n == null ? void 0 : n.data) == null ? void 0 : a.message) && typeof n.data.message == "string";
42
+ })(e) ? e.data.message : e instanceof Error ? te(e) : ne(e);
44
43
  }
45
- function De(e) {
44
+ function te(e) {
46
45
  return e.response ? e.response.data.message : e.message;
47
46
  }
48
- function Me(e) {
47
+ function ne(e) {
49
48
  return e != null && e.message ? e.message : "Unknown error";
50
49
  }
51
- const v = {
50
+ const S = {
52
51
  eth: "DESTINATION_BLOCKCHAIN_ETHEREUM",
53
52
  base: "DESTINATION_BLOCKCHAIN_BASE",
54
53
  bsc: "DESTINATION_BLOCKCHAIN_BSC",
@@ -58,139 +57,141 @@ const v = {
58
57
  scroll: "DESTINATION_BLOCKCHAIN_SCROLL",
59
58
  xlayer: "DESTINATION_BLOCKCHAIN_XLAYER"
60
59
  };
61
- function X(e) {
60
+ function D(e) {
62
61
  switch (e) {
63
- case a.ethereum:
64
- case a.holesky:
65
- case a.sepolia:
66
- return v.eth;
67
- case a.base:
68
- case a.baseTestnet:
69
- return v.base;
70
- case a.binanceSmartChain:
71
- case a.binanceSmartChainTestnet:
72
- return v.bsc;
62
+ case s.ethereum:
63
+ case s.holesky:
64
+ case s.sepolia:
65
+ return S.eth;
66
+ case s.base:
67
+ case s.baseTestnet:
68
+ return S.base;
69
+ case s.binanceSmartChain:
70
+ case s.binanceSmartChainTestnet:
71
+ return S.bsc;
73
72
  default:
74
73
  throw new Error(`Unknown chain ID: ${e}`);
75
74
  }
76
75
  }
77
- const Ne = "sanctioned_address", Pe = "api/v1/address/generate", Oe = "destination address is under sanctions";
78
- async function Jt({
76
+ const ae = "sanctioned_address", se = "api/v1/address/generate", ie = "destination address is under sanctions";
77
+ async function Le({
79
78
  address: e,
80
79
  chainId: t,
81
80
  signature: n,
82
- env: s,
83
- referrerCode: i,
84
- partnerId: r,
85
- captchaToken: p = ""
81
+ eip712Data: a,
82
+ env: i,
83
+ referrerCode: r,
84
+ partnerId: o,
85
+ captchaToken: p
86
86
  }) {
87
- const { baseApiUrl: u } = S(s), y = X(t), h = {
87
+ const { baseApiUrl: d } = w(i), m = D(t), l = {
88
88
  to_address: e,
89
89
  to_address_signature: n,
90
- to_chain: y,
91
- referrer_code: i,
92
- partner_id: r,
90
+ to_chain: m,
91
+ partner_id: o,
93
92
  nonce: 0,
94
- captcha: p
93
+ captcha: p,
94
+ referrer_code: r,
95
+ eip_712_data: a
95
96
  };
96
97
  try {
97
- const { data: l } = await C.post(
98
- Pe,
99
- h,
100
- { baseURL: u }
98
+ const { data: y } = await h.post(
99
+ se,
100
+ l,
101
+ { baseURL: d }
101
102
  );
102
- return l.address;
103
- } catch (l) {
104
- const g = I(l);
105
- if (Ue(g))
106
- return Ne;
107
- throw new Error(g);
103
+ return y.address;
104
+ } catch (y) {
105
+ const b = C(y);
106
+ if (re(b))
107
+ return ae;
108
+ throw new Error(b);
108
109
  }
109
110
  }
110
- function Ue(e) {
111
- return !!e.includes(Oe);
111
+ function re(e) {
112
+ return !!e.includes(ie);
112
113
  }
113
- const Fe = "api/v1/address";
114
- async function Zt({
114
+ const oe = "api/v1/address";
115
+ async function Ge({
115
116
  address: e,
116
117
  chainId: t,
117
118
  env: n,
118
- partnerId: s
119
+ partnerId: a
119
120
  }) {
120
- const i = await Le({
121
+ const i = await ue({
121
122
  address: e,
122
123
  chainId: t,
123
124
  env: n,
124
- partnerId: s
125
- }), r = Be(i);
125
+ partnerId: a
126
+ }), r = pe(i);
126
127
  if (!r)
127
128
  throw new Error("No address");
128
129
  return r.btc_address;
129
130
  }
130
- function Be(e) {
131
+ function pe(e) {
131
132
  if (!e.length)
132
133
  return;
133
- const t = e.reduce((n, s) => n.created_at < s.created_at ? s : n, e[0]);
134
+ const t = e.reduce((n, a) => n.created_at < a.created_at ? a : n, e[0]);
134
135
  return t.deprecated ? void 0 : t;
135
136
  }
136
- async function Le({
137
+ async function ue({
137
138
  address: e,
138
139
  chainId: t,
139
140
  env: n,
140
- partnerId: s
141
+ partnerId: a
141
142
  }) {
142
- const { baseApiUrl: i } = S(n), r = X(t), p = {
143
+ const { baseApiUrl: i } = w(n), r = D(t), o = {
143
144
  to_address: e,
144
145
  to_blockchain: r,
145
146
  limit: 1,
146
147
  offset: 0,
147
148
  asc: !1,
148
- referralId: s
149
- }, { data: u } = await C.get(Fe, {
149
+ referralId: a
150
+ }, { data: p } = await h.get(oe, {
150
151
  baseURL: i,
151
- params: p
152
+ params: o
152
153
  });
153
- return (u == null ? void 0 : u.addresses) || [];
154
+ return (p == null ? void 0 : p.addresses) || [];
154
155
  }
155
- const ke = 8, Y = 10 ** ke;
156
- function K(e) {
157
- return +e / Y;
156
+ const ye = 8, P = 10 ** ye;
157
+ function M(e) {
158
+ return +e / P;
158
159
  }
159
- function ce(e) {
160
- return Math.floor(+e * Y);
160
+ function He(e) {
161
+ return Math.floor(+e * P);
161
162
  }
162
- function Ge(e, t = x) {
163
+ function de(e, t = N) {
163
164
  switch (e) {
164
- case v.eth:
165
- return Re(t);
166
- case v.base:
167
- return Se(t);
168
- case v.bsc:
169
- return Ce(t);
165
+ case S.eth:
166
+ return j(t);
167
+ case S.base:
168
+ return X(t);
169
+ case S.bsc:
170
+ return J(t);
170
171
  default:
171
- return a.ethereum;
172
+ return s.ethereum;
172
173
  }
173
174
  }
174
- var We = /* @__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))(We || {}), 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 || {});
175
- async function jt({
175
+ 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 || {}), ce = /* @__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))(ce || {});
176
+ async function We({
176
177
  address: e,
177
178
  env: t
178
179
  }) {
179
- const { baseApiUrl: n } = S(t), { data: s } = await C.get(
180
+ const { baseApiUrl: n } = w(t), { data: a } = await h.get(
180
181
  `api/v1/address/outputs-v2/${e}`,
181
182
  { baseURL: n }
182
183
  );
183
- return ((s == null ? void 0 : s.outputs) ?? []).map($e(t));
184
+ return ((a == null ? void 0 : a.outputs) ?? []).map(me(t));
184
185
  }
185
- function $e(e) {
186
+ function me(e) {
186
187
  return (t) => ({
187
188
  txid: t.txid,
188
189
  index: t.index ?? 0,
189
190
  blockHeight: t.block_height ? Number(t.block_height) : void 0,
190
191
  blockTime: t.block_time ? Number(t.block_time) : void 0,
191
- value: new R(K(t.value)),
192
+ value: new v(M(t.value)),
192
193
  address: t.address,
193
- chainId: Ge(t.to_chain, e),
194
+ chainId: de(t.to_chain, e),
194
195
  claimedTxId: t.claim_tx,
195
196
  rawPayload: t.raw_payload,
196
197
  signature: t.proof,
@@ -202,27 +203,27 @@ function $e(e) {
202
203
  sessionState: t.session_state
203
204
  });
204
205
  }
205
- const He = 2e-4;
206
- async function qt({
206
+ const be = 2e-4;
207
+ async function $e({
207
208
  env: e,
208
- chainId: t = a.ethereum,
209
+ chainId: t = s.ethereum,
209
210
  amount: n = 1
210
211
  }) {
211
- const { baseApiUrl: s } = S(e), i = X(t), { data: r } = await C.get(
212
+ const { baseApiUrl: a } = w(e), i = D(t), { data: r } = await h.get(
212
213
  `api/v1/exchange/rate/${i}`,
213
- { baseURL: s, params: { amount: n } }
214
- ), p = new R(He).multipliedBy(Y).toFixed();
215
- return { exchangeRate: +r.amount_out, minAmount: +p };
214
+ { baseURL: a, params: { amount: n } }
215
+ ), o = new v(be).multipliedBy(P).toFixed();
216
+ return { exchangeRate: +r.amount_out, minAmount: +o };
216
217
  }
217
- async function zt({
218
+ async function Ve({
218
219
  address: e,
219
220
  chainId: t,
220
221
  env: n
221
222
  }) {
222
- const { baseApiUrl: s } = S(n);
223
+ const { baseApiUrl: a } = w(n);
223
224
  try {
224
- const { data: i } = await C.get(
225
- `${s}/api/v1/claimer/get-user-signature`,
225
+ const { data: i } = await h.get(
226
+ `${a}/api/v1/claimer/get-user-signature`,
226
227
  {
227
228
  params: {
228
229
  user_destination_address: e,
@@ -236,19 +237,19 @@ async function zt({
236
237
  isDelayed: i == null ? void 0 : i.is_delayed
237
238
  };
238
239
  } catch (i) {
239
- const r = I(i);
240
+ const r = C(i);
240
241
  throw new Error(r);
241
242
  }
242
243
  }
243
- async function Kt({
244
+ async function Ze({
244
245
  signature: e,
245
246
  typedData: t,
246
247
  address: n,
247
- env: s
248
+ env: a
248
249
  }) {
249
- const { baseApiUrl: i } = S(s);
250
+ const { baseApiUrl: i } = w(a);
250
251
  try {
251
- const { data: r } = await C.post(
252
+ const { data: r } = await h.post(
252
253
  `${i}/api/v1/claimer/save-user-signature`,
253
254
  null,
254
255
  {
@@ -261,20 +262,43 @@ async function Kt({
261
262
  );
262
263
  return r.status;
263
264
  } catch (r) {
264
- const p = I(r);
265
- throw new Error(p);
265
+ const o = C(r);
266
+ throw new Error(o);
267
+ }
268
+ }
269
+ async function Ke({
270
+ signature: e,
271
+ typedData: t,
272
+ env: n
273
+ }) {
274
+ const { baseApiUrl: a } = w(n);
275
+ try {
276
+ const { data: i } = await h.post(
277
+ `${a}/api/v1/claimer/save-stake-and-bake-signature`,
278
+ null,
279
+ {
280
+ params: {
281
+ typed_data: t,
282
+ signature: e
283
+ }
284
+ }
285
+ );
286
+ return i.status;
287
+ } catch (i) {
288
+ const r = C(i);
289
+ throw new Error(r);
266
290
  }
267
291
  }
268
- const P = {
269
- [a.ethereum]: "https://rpc.ankr.com/eth",
270
- [a.holesky]: "https://rpc.ankr.com/eth_holesky",
271
- [a.sepolia]: "https://rpc.ankr.com/eth_sepolia",
272
- [a.base]: "https://rpc.ankr.com/base",
273
- [a.baseTestnet]: "https://rpc.ankr.com/base_sepolia",
274
- [a.binanceSmartChain]: "https://rpc.ankr.com/bsc",
275
- [a.binanceSmartChainTestnet]: "https://rpc.ankr.com/bsc_testnet_chapel"
292
+ const x = {
293
+ [s.ethereum]: "https://rpc.ankr.com/eth",
294
+ [s.holesky]: "https://rpc.ankr.com/eth_holesky",
295
+ [s.sepolia]: "https://rpc.ankr.com/eth_sepolia",
296
+ [s.base]: "https://rpc.ankr.com/base",
297
+ [s.baseTestnet]: "https://rpc.ankr.com/base_sepolia",
298
+ [s.binanceSmartChain]: "https://rpc.ankr.com/bsc",
299
+ [s.binanceSmartChainTestnet]: "https://rpc.ankr.com/bsc_testnet_chapel"
276
300
  };
277
- async function Je(e) {
301
+ async function Te(e) {
278
302
  const n = await (await fetch(e, {
279
303
  method: "POST",
280
304
  headers: {
@@ -286,15 +310,15 @@ async function Je(e) {
286
310
  method: "eth_maxPriorityFeePerGas",
287
311
  params: []
288
312
  })
289
- })).json(), s = ye.utils.hexToNumber(n == null ? void 0 : n.result);
290
- return new R(Number(s));
313
+ })).json(), a = H.utils.hexToNumber(n == null ? void 0 : n.result);
314
+ return new v(Number(a));
291
315
  }
292
- const Ze = 2, je = 25e3;
293
- class q {
316
+ const fe = 2, ge = 25e3;
317
+ class O {
294
318
  constructor({ chainId: t, rpcUrlConfig: n }) {
295
319
  A(this, "chainId");
296
320
  A(this, "rpcConfig");
297
- this.chainId = t, this.rpcConfig = { ...P, ...n };
321
+ this.chainId = t, this.rpcConfig = { ...x, ...n };
298
322
  }
299
323
  /**
300
324
  * Returns web3 instance for read operations.
@@ -303,8 +327,8 @@ class q {
303
327
  * @returns {Web3} Web3 instance.
304
328
  */
305
329
  getReadWeb3() {
306
- const t = this.getRpcUrl(), n = new re(), s = new re.providers.HttpProvider(t);
307
- return n.setProvider(s), n;
330
+ const t = this.getRpcUrl(), n = new G(), a = new G.providers.HttpProvider(t);
331
+ return n.setProvider(a), n;
308
332
  }
309
333
  /**
310
334
  * Retrieves the RPC URL based on the current chain ID.
@@ -312,8 +336,8 @@ class q {
312
336
  * @throws Error if the RPC URL for the current chain ID is not found.
313
337
  */
314
338
  getRpcUrl() {
315
- var s;
316
- const { chainId: t } = this, n = (s = this.rpcConfig) == null ? void 0 : s[t];
339
+ var a;
340
+ const { chainId: t } = this, n = (a = this.rpcConfig) == null ? void 0 : a[t];
317
341
  if (!n)
318
342
  throw console.error(
319
343
  `You might need to add the rpcConfig for the ${t} chain ID when creating the provider.`
@@ -329,12 +353,12 @@ class q {
329
353
  * @returns {Promise<IGetMaxFeesResult>} Max fees for transaction.
330
354
  */
331
355
  async getMaxFees() {
332
- const t = this.getReadWeb3(), n = this.getRpcUrl(), [s, i] = await Promise.all([
356
+ const t = this.getReadWeb3(), n = this.getRpcUrl(), [a, i] = await Promise.all([
333
357
  t.eth.getBlock("latest"),
334
- Je(n)
358
+ Te(n)
335
359
  ]);
336
- return !(s != null && s.baseFeePerGas) && typeof (s == null ? void 0 : s.baseFeePerGas) != "bigint" ? {} : {
337
- maxFeePerGas: +new R(s.baseFeePerGas.toString(10)).multipliedBy(Ze).plus(i),
360
+ return !(a != null && a.baseFeePerGas) && typeof (a == null ? void 0 : a.baseFeePerGas) != "bigint" ? {} : {
361
+ maxFeePerGas: +new v(a.baseFeePerGas.toString(10)).multipliedBy(fe).plus(i),
338
362
  maxPriorityFeePerGas: +i
339
363
  };
340
364
  }
@@ -346,8 +370,8 @@ class q {
346
370
  */
347
371
  async getSafeGasPriceWei() {
348
372
  const t = await this.getReadWeb3().eth.getGasPrice();
349
- return new R(t.toString(10)).plus(
350
- je
373
+ return new v(t.toString(10)).plus(
374
+ ge
351
375
  );
352
376
  }
353
377
  /**
@@ -359,153 +383,64 @@ class q {
359
383
  * @returns {Contract<AbiType>} The contract instance.
360
384
  */
361
385
  createContract(t, n) {
362
- const s = this.getReadWeb3();
363
- return new s.eth.Contract(t, n);
364
- }
365
- }
366
- class _ extends q {
367
- constructor({ provider: n, account: s, chainId: i, rpcUrlConfig: r }) {
368
- super({ chainId: i, rpcUrlConfig: r });
369
- A(this, "web3");
370
- A(this, "account");
371
- A(this, "rpcConfig", P);
372
- this.web3 = new ye(n), this.account = s, this.chainId = i, this.rpcConfig = { ...P, ...r };
373
- }
374
- /**
375
- * Signs a message using the current provider and account.
376
- * @public
377
- * @param message - The message to be signed.
378
- * @returns A promise that resolves to the signed message as a string.
379
- */
380
- async signMessage(n) {
381
- const { account: s } = this, i = `0x${Buffer.from(n, "utf8").toString("hex")}`;
382
- return this.web3.currentProvider.request({
383
- method: "personal_sign",
384
- params: [i, s]
385
- });
386
- }
387
- /**
388
- * Custom replacement for web3js [send](https://docs.web3js.org/libdocs/Contract#send).
389
- *
390
- * @public
391
- * @param {string} from - Address of the sender.
392
- * @param {string} to - Address of the recipient.
393
- * @param {ISendOptions} sendOptions - Options for sending transaction.
394
- * @returns {Promise<IWeb3SendResult>} Promise with transaction hash and receipt promise.
395
- */
396
- async sendTransactionAsync(n, s, i) {
397
- const { chainId: r, web3: p } = this, u = this.getReadWeb3(), {
398
- data: y,
399
- estimate: h = !1,
400
- estimateFee: l = !1,
401
- extendedGasLimit: g,
402
- gasLimit: D = "0",
403
- value: fe = "0",
404
- gasLimitMultiplier: Te = 1
405
- } = i;
406
- let { nonce: M } = i;
407
- M || (M = await u.eth.getTransactionCount(n)), console.log(`Nonce: ${M}`);
408
- const c = {
409
- from: n,
410
- to: s,
411
- value: w.numberToHex(fe),
412
- data: y,
413
- nonce: M,
414
- chainId: w.numberToHex(r)
415
- };
416
- if (h)
417
- try {
418
- const T = await u.eth.estimateGas(c), N = Math.round(
419
- Number(T) * Te
420
- );
421
- g ? c.gas = w.numberToHex(N + g) : c.gas = w.numberToHex(N);
422
- } catch (T) {
423
- throw new Error(
424
- T.message ?? "Failed to estimate gas limit for transaction."
425
- );
426
- }
427
- else
428
- c.gas = w.numberToHex(D);
429
- const { maxFeePerGas: ne, maxPriorityFeePerGas: ae } = l ? await this.getMaxFees().catch(() => i) : i;
430
- if (ae !== void 0 && (c.maxPriorityFeePerGas = w.numberToHex(ae)), ne !== void 0 && (c.maxFeePerGas = w.numberToHex(ne)), !c.maxFeePerGas && !c.maxPriorityFeePerGas) {
431
- const T = await this.getSafeGasPriceWei();
432
- c.gasPrice = T.toString(10);
433
- }
434
- if (!c.maxFeePerGas && !c.maxPriorityFeePerGas) {
435
- const T = await this.getSafeGasPriceWei();
436
- c.gasPrice = T.toString(10);
437
- }
438
- return console.log("Sending transaction via Web3: ", c), new Promise((T, N) => {
439
- const se = p.eth.sendTransaction(c);
440
- se.once("transactionHash", async (ie) => {
441
- console.log(`Just signed transaction has is: ${ie}`), T({
442
- receiptPromise: se,
443
- transactionHash: ie
444
- });
445
- }).catch(N);
446
- });
447
- }
448
- createContract(n, s) {
449
- return new this.web3.eth.Contract(n, s);
450
- }
451
- }
452
- function Q(e) {
453
- switch (e) {
454
- case a.ethereum:
455
- return 1.3;
456
- case a.holesky:
457
- case a.sepolia:
458
- return 1.5;
459
- default:
460
- return 1.3;
386
+ const a = this.getReadWeb3();
387
+ return new a.eth.Contract(t, n);
461
388
  }
462
389
  }
463
- function ee(e) {
464
- return Object.values(a).includes(e);
390
+ const he = [
391
+ s.ethereum,
392
+ s.base,
393
+ s.binanceSmartChain
394
+ ], W = (e) => he.includes(e) ? T.prod : T.stage;
395
+ function $(e) {
396
+ return Object.values(s).includes(e);
465
397
  }
466
- const qe = {
467
- [a.holesky]: "0xED7bfd5C1790576105Af4649817f6d35A75CD818",
468
- [a.ethereum]: o,
469
- [a.binanceSmartChainTestnet]: "0x731eFa688F3679688cf60A3993b8658138953ED6",
470
- [a.binanceSmartChain]: o,
471
- [a.sepolia]: "0xc47e4b3124597fdf8dd07843d4a7052f2ee80c30",
472
- [a.base]: o,
398
+ const we = {
399
+ [s.holesky]: "0xED7bfd5C1790576105Af4649817f6d35A75CD818",
400
+ [s.ethereum]: u,
401
+ [s.binanceSmartChainTestnet]: "0x731eFa688F3679688cf60A3993b8658138953ED6",
402
+ [s.binanceSmartChain]: u,
403
+ [s.sepolia]: "0xc47e4b3124597fdf8dd07843d4a7052f2ee80c30",
404
+ [s.base]: u,
473
405
  // TODO: Add baseTestnet address
474
- [a.baseTestnet]: o,
475
- [a.berachainBartioTestnet]: "0xc47e4b3124597FDF8DD07843D4a7052F2eE80C30",
476
- [a.corn]: o
477
- }, ze = {
478
- [a.holesky]: "0x38A13AB20D15ffbE5A7312d2336EF1552580a4E2",
479
- [a.ethereum]: o,
480
- [a.binanceSmartChainTestnet]: "0x107Fc7d90484534704dD2A9e24c7BD45DB4dD1B5",
481
- [a.binanceSmartChain]: o,
482
- [a.sepolia]: "0xc47e4b3124597fdf8dd07843d4a7052f2ee80c30",
483
- [a.base]: o,
484
- [a.baseTestnet]: o,
485
- [a.berachainBartioTestnet]: "0xc47e4b3124597FDF8DD07843D4a7052F2eE80C30",
486
- [a.corn]: o
487
- }, Ke = {
488
- [a.ethereum]: "0x8236a87084f8b84306f72007f36f2618a5634494",
489
- [a.holesky]: o,
490
- [a.sepolia]: o,
491
- [a.binanceSmartChainTestnet]: o,
492
- [a.binanceSmartChain]: "0xecAc9C5F704e954931349Da37F60E39f515c11c1",
493
- [a.base]: "0xecAc9C5F704e954931349Da37F60E39f515c11c1",
494
- [a.baseTestnet]: o,
495
- [a.berachainBartioTestnet]: o,
496
- [a.corn]: "0xecAc9C5F704e954931349Da37F60E39f515c11c1"
406
+ [s.baseTestnet]: u,
407
+ [s.berachainBartioTestnet]: "0xc47e4b3124597FDF8DD07843D4a7052F2eE80C30",
408
+ [s.corn]: u,
409
+ [s.swell]: u
410
+ }, Ae = {
411
+ [s.holesky]: "0x38A13AB20D15ffbE5A7312d2336EF1552580a4E2",
412
+ [s.ethereum]: u,
413
+ [s.binanceSmartChainTestnet]: "0x107Fc7d90484534704dD2A9e24c7BD45DB4dD1B5",
414
+ [s.binanceSmartChain]: u,
415
+ [s.sepolia]: "0xc47e4b3124597fdf8dd07843d4a7052f2ee80c30",
416
+ [s.base]: u,
417
+ [s.baseTestnet]: u,
418
+ [s.berachainBartioTestnet]: "0xc47e4b3124597FDF8DD07843D4a7052F2eE80C30",
419
+ [s.corn]: u,
420
+ [s.swell]: u
421
+ }, Se = {
422
+ [s.ethereum]: "0x8236a87084f8b84306f72007f36f2618a5634494",
423
+ [s.holesky]: u,
424
+ [s.sepolia]: u,
425
+ [s.binanceSmartChainTestnet]: u,
426
+ [s.binanceSmartChain]: "0xecAc9C5F704e954931349Da37F60E39f515c11c1",
427
+ [s.base]: "0xecAc9C5F704e954931349Da37F60E39f515c11c1",
428
+ [s.baseTestnet]: u,
429
+ [s.berachainBartioTestnet]: u,
430
+ [s.corn]: "0xecAc9C5F704e954931349Da37F60E39f515c11c1",
431
+ [s.swell]: "0xecAc9C5F704e954931349Da37F60E39f515c11c1"
497
432
  };
498
- function Xe(e = x) {
433
+ function V(e = N) {
499
434
  switch (e) {
500
- case d.prod:
501
- return Ke;
502
- case d.testnet:
503
- return ze;
435
+ case T.prod:
436
+ return Se;
437
+ case T.testnet:
438
+ return Ae;
504
439
  default:
505
- return qe;
440
+ return we;
506
441
  }
507
442
  }
508
- const Ye = [
443
+ const ve = [
509
444
  {
510
445
  constant: !0,
511
446
  inputs: [],
@@ -726,7 +661,7 @@ const Ye = [
726
661
  name: "Transfer",
727
662
  type: "event"
728
663
  }
729
- ], Qe = [
664
+ ], Ce = [
730
665
  {
731
666
  inputs: [],
732
667
  stateMutability: "nonpayable",
@@ -2486,1368 +2421,137 @@ const Ye = [
2486
2421
  stateMutability: "nonpayable",
2487
2422
  type: "function"
2488
2423
  }
2489
- ], et = [
2490
- {
2491
- inputs: [
2492
- {
2493
- internalType: "address",
2494
- name: "aDefaultAdmin",
2495
- type: "address"
2496
- },
2497
- {
2498
- internalType: "address",
2499
- name: "aPauser",
2500
- type: "address"
2501
- },
2502
- {
2503
- internalType: "address",
2504
- name: "aDepositReporter",
2505
- type: "address"
2506
- },
2507
- {
2508
- internalType: "address",
2509
- name: "aWithdrawalValidator",
2510
- type: "address"
2511
- },
2512
- {
2513
- internalType: "uint256",
2514
- name: "aMaxDeposits",
2515
- type: "uint256"
2516
- }
2517
- ],
2518
- stateMutability: "nonpayable",
2519
- type: "constructor"
2520
- },
2521
- {
2522
- inputs: [],
2523
- name: "AccessControlBadConfirmation",
2524
- type: "error"
2525
- },
2526
- {
2527
- inputs: [
2528
- {
2529
- internalType: "uint48",
2530
- name: "schedule",
2531
- type: "uint48"
2532
- }
2533
- ],
2534
- name: "AccessControlEnforcedDefaultAdminDelay",
2535
- type: "error"
2536
- },
2537
- {
2538
- inputs: [],
2539
- name: "AccessControlEnforcedDefaultAdminRules",
2540
- type: "error"
2541
- },
2542
- {
2543
- inputs: [
2544
- {
2545
- internalType: "address",
2546
- name: "defaultAdmin",
2547
- type: "address"
2548
- }
2549
- ],
2550
- name: "AccessControlInvalidDefaultAdmin",
2551
- type: "error"
2552
- },
2553
- {
2554
- inputs: [
2555
- {
2556
- internalType: "address",
2557
- name: "account",
2558
- type: "address"
2559
- },
2560
- {
2561
- internalType: "bytes32",
2562
- name: "neededRole",
2563
- type: "bytes32"
2564
- }
2565
- ],
2566
- name: "AccessControlUnauthorizedAccount",
2567
- type: "error"
2568
- },
2569
- {
2570
- inputs: [
2571
- {
2572
- internalType: "bytes32",
2573
- name: "depositID",
2574
- type: "bytes32"
2575
- }
2576
- ],
2577
- name: "AlreadyReported",
2578
- type: "error"
2579
- },
2580
- {
2581
- inputs: [
2582
- {
2583
- internalType: "bytes32",
2584
- name: "depositID",
2585
- type: "bytes32"
2586
- },
2587
- {
2588
- internalType: "uint256",
2589
- name: "withdrawalAmount",
2590
- type: "uint256"
2591
- }
2592
- ],
2593
- name: "AlreadyWithdrawn",
2594
- type: "error"
2595
- },
2596
- {
2597
- inputs: [],
2598
- name: "BadDepositReport",
2599
- type: "error"
2600
- },
2601
- {
2602
- inputs: [],
2603
- name: "EnforcedPause",
2604
- type: "error"
2605
- },
2606
- {
2607
- inputs: [],
2608
- name: "ExpectedPause",
2609
- type: "error"
2610
- },
2611
- {
2612
- inputs: [
2613
- {
2614
- internalType: "uint8",
2615
- name: "bits",
2616
- type: "uint8"
2617
- },
2618
- {
2619
- internalType: "uint256",
2620
- name: "value",
2621
- type: "uint256"
2622
- }
2623
- ],
2624
- name: "SafeCastOverflowedUintDowncast",
2625
- type: "error"
2626
- },
2627
- {
2628
- inputs: [],
2629
- name: "SameValidationThreshold",
2630
- type: "error"
2631
- },
2632
- {
2633
- inputs: [
2634
- {
2635
- internalType: "bytes32",
2636
- name: "depositID",
2637
- type: "bytes32"
2638
- },
2639
- {
2640
- internalType: "uint256",
2641
- name: "withdrawalAmount",
2642
- type: "uint256"
2424
+ ];
2425
+ function _e(e) {
2426
+ switch (e) {
2427
+ case "LBTC":
2428
+ return Ce;
2429
+ default:
2430
+ return ve;
2431
+ }
2432
+ }
2433
+ function R(e, t) {
2434
+ const n = V(t), { chainId: a } = e;
2435
+ if (!$(a))
2436
+ throw new Error(`This chain ${a} is not supported`);
2437
+ const i = n[a];
2438
+ if (!i)
2439
+ throw new Error(`Token address for chain ${a} is not defined`);
2440
+ const r = _e("LBTC"), o = e.createContract(r, i);
2441
+ return o.options.address || (o.options.address = i), o;
2442
+ }
2443
+ function Z(e, t) {
2444
+ if (!$(e))
2445
+ throw new Error(`This chain ${e} is not supported`);
2446
+ const n = t ? { [e]: t } : x;
2447
+ if (!n[e])
2448
+ throw new Error(`RPC URL for chainId ${e} not found`);
2449
+ return n;
2450
+ }
2451
+ async function ze({
2452
+ chainId: e,
2453
+ bakeGasEstimate: t = 0,
2454
+ rpcUrl: n
2455
+ }) {
2456
+ const a = Z(e, n), i = new O({ chainId: e, rpcUrlConfig: a }), r = W(e), p = await R(i, r).methods.getMintFee().call(), d = new v(M(p.toString(10)));
2457
+ return t ? d.plus(M(t)) : d;
2458
+ }
2459
+ class F extends O {
2460
+ constructor({ provider: n, account: a, chainId: i, rpcUrlConfig: r }) {
2461
+ super({ chainId: i, rpcUrlConfig: r });
2462
+ A(this, "web3");
2463
+ A(this, "account");
2464
+ A(this, "rpcConfig", x);
2465
+ this.web3 = new H(n), this.account = a, this.chainId = i, this.rpcConfig = { ...x, ...r };
2466
+ }
2467
+ /**
2468
+ * Signs a message using the current provider and account.
2469
+ * @public
2470
+ * @param message - The message to be signed.
2471
+ * @returns A promise that resolves to the signed message as a string.
2472
+ */
2473
+ async signMessage(n) {
2474
+ const { account: a } = this, i = `0x${Buffer.from(n, "utf8").toString("hex")}`;
2475
+ return this.web3.currentProvider.request({
2476
+ method: "personal_sign",
2477
+ params: [i, a]
2478
+ });
2479
+ }
2480
+ /**
2481
+ * Custom replacement for web3js [send](https://docs.web3js.org/libdocs/Contract#send).
2482
+ *
2483
+ * @public
2484
+ * @param {string} from - Address of the sender.
2485
+ * @param {string} to - Address of the recipient.
2486
+ * @param {ISendOptions} sendOptions - Options for sending transaction.
2487
+ * @returns {Promise<IWeb3SendResult>} Promise with transaction hash and receipt promise.
2488
+ */
2489
+ async sendTransactionAsync(n, a, i) {
2490
+ const { chainId: r, web3: o } = this, p = this.getReadWeb3(), {
2491
+ data: d,
2492
+ estimate: m = !1,
2493
+ estimateFee: l = !1,
2494
+ extendedGasLimit: y,
2495
+ gasLimit: b = "0",
2496
+ value: _ = "0",
2497
+ gasLimitMultiplier: K = 1
2498
+ } = i;
2499
+ let { nonce: E } = i;
2500
+ E || (E = await p.eth.getTransactionCount(n)), console.log(`Nonce: ${E}`);
2501
+ const c = {
2502
+ from: n,
2503
+ to: a,
2504
+ value: g.numberToHex(_),
2505
+ data: d,
2506
+ nonce: E,
2507
+ chainId: g.numberToHex(r)
2508
+ };
2509
+ if (m)
2510
+ try {
2511
+ const f = await p.eth.estimateGas(c), I = Math.round(
2512
+ Number(f) * K
2513
+ );
2514
+ y ? c.gas = g.numberToHex(I + y) : c.gas = g.numberToHex(I);
2515
+ } catch (f) {
2516
+ throw new Error(
2517
+ f.message ?? "Failed to estimate gas limit for transaction."
2518
+ );
2643
2519
  }
2644
- ],
2645
- name: "WithdrawalFailedValidation",
2646
- type: "error"
2647
- },
2648
- {
2649
- anonymous: !1,
2650
- inputs: [],
2651
- name: "DefaultAdminDelayChangeCanceled",
2652
- type: "event"
2653
- },
2654
- {
2655
- anonymous: !1,
2656
- inputs: [
2657
- {
2658
- indexed: !1,
2659
- internalType: "uint48",
2660
- name: "newDelay",
2661
- type: "uint48"
2662
- },
2663
- {
2664
- indexed: !1,
2665
- internalType: "uint48",
2666
- name: "effectSchedule",
2667
- type: "uint48"
2668
- }
2669
- ],
2670
- name: "DefaultAdminDelayChangeScheduled",
2671
- type: "event"
2672
- },
2673
- {
2674
- anonymous: !1,
2675
- inputs: [],
2676
- name: "DefaultAdminTransferCanceled",
2677
- type: "event"
2678
- },
2679
- {
2680
- anonymous: !1,
2681
- inputs: [
2682
- {
2683
- indexed: !0,
2684
- internalType: "address",
2685
- name: "newAdmin",
2686
- type: "address"
2687
- },
2688
- {
2689
- indexed: !1,
2690
- internalType: "uint48",
2691
- name: "acceptSchedule",
2692
- type: "uint48"
2693
- }
2694
- ],
2695
- name: "DefaultAdminTransferScheduled",
2696
- type: "event"
2697
- },
2698
- {
2699
- anonymous: !1,
2700
- inputs: [
2701
- {
2702
- indexed: !0,
2703
- internalType: "bytes32",
2704
- name: "reportId",
2705
- type: "bytes32"
2706
- },
2707
- {
2708
- indexed: !1,
2709
- internalType: "uint256",
2710
- name: "numDeposits",
2711
- type: "uint256"
2712
- }
2713
- ],
2714
- name: "DepositsReported",
2715
- type: "event"
2716
- },
2717
- {
2718
- anonymous: !1,
2719
- inputs: [
2720
- {
2721
- indexed: !1,
2722
- internalType: "uint256",
2723
- name: "numDeposits",
2724
- type: "uint256"
2725
- }
2726
- ],
2727
- name: "MaxDepositsUpdated",
2728
- type: "event"
2729
- },
2730
- {
2731
- anonymous: !1,
2732
- inputs: [
2733
- {
2734
- indexed: !1,
2735
- internalType: "address",
2736
- name: "account",
2737
- type: "address"
2738
- }
2739
- ],
2740
- name: "Paused",
2741
- type: "event"
2742
- },
2743
- {
2744
- anonymous: !1,
2745
- inputs: [
2746
- {
2747
- indexed: !0,
2748
- internalType: "bytes32",
2749
- name: "role",
2750
- type: "bytes32"
2751
- },
2752
- {
2753
- indexed: !0,
2754
- internalType: "bytes32",
2755
- name: "previousAdminRole",
2756
- type: "bytes32"
2757
- },
2758
- {
2759
- indexed: !0,
2760
- internalType: "bytes32",
2761
- name: "newAdminRole",
2762
- type: "bytes32"
2763
- }
2764
- ],
2765
- name: "RoleAdminChanged",
2766
- type: "event"
2767
- },
2768
- {
2769
- anonymous: !1,
2770
- inputs: [
2771
- {
2772
- indexed: !0,
2773
- internalType: "bytes32",
2774
- name: "role",
2775
- type: "bytes32"
2776
- },
2777
- {
2778
- indexed: !0,
2779
- internalType: "address",
2780
- name: "account",
2781
- type: "address"
2782
- },
2783
- {
2784
- indexed: !0,
2785
- internalType: "address",
2786
- name: "sender",
2787
- type: "address"
2788
- }
2789
- ],
2790
- name: "RoleGranted",
2791
- type: "event"
2792
- },
2793
- {
2794
- anonymous: !1,
2795
- inputs: [
2796
- {
2797
- indexed: !0,
2798
- internalType: "bytes32",
2799
- name: "role",
2800
- type: "bytes32"
2801
- },
2802
- {
2803
- indexed: !0,
2804
- internalType: "address",
2805
- name: "account",
2806
- type: "address"
2807
- },
2808
- {
2809
- indexed: !0,
2810
- internalType: "address",
2811
- name: "sender",
2812
- type: "address"
2813
- }
2814
- ],
2815
- name: "RoleRevoked",
2816
- type: "event"
2817
- },
2818
- {
2819
- anonymous: !1,
2820
- inputs: [
2821
- {
2822
- indexed: !1,
2823
- internalType: "address",
2824
- name: "account",
2825
- type: "address"
2826
- }
2827
- ],
2828
- name: "Unpaused",
2829
- type: "event"
2830
- },
2831
- {
2832
- anonymous: !1,
2833
- inputs: [
2834
- {
2835
- indexed: !1,
2836
- internalType: "uint256",
2837
- name: "oldThreshold",
2838
- type: "uint256"
2839
- },
2840
- {
2841
- indexed: !1,
2842
- internalType: "uint256",
2843
- name: "newThreshold",
2844
- type: "uint256"
2845
- }
2846
- ],
2847
- name: "UpdateValidateThreshold",
2848
- type: "event"
2849
- },
2850
- {
2851
- anonymous: !1,
2852
- inputs: [
2853
- {
2854
- indexed: !1,
2855
- internalType: "bytes32",
2856
- name: "depositID",
2857
- type: "bytes32"
2858
- },
2859
- {
2860
- indexed: !1,
2861
- internalType: "uint256",
2862
- name: "withdrawalAmount",
2863
- type: "uint256"
2864
- }
2865
- ],
2866
- name: "WithdrawalNotValidated",
2867
- type: "event"
2868
- },
2869
- {
2870
- anonymous: !1,
2871
- inputs: [
2872
- {
2873
- indexed: !1,
2874
- internalType: "bytes32",
2875
- name: "depositID",
2876
- type: "bytes32"
2877
- },
2878
- {
2879
- indexed: !1,
2880
- internalType: "uint256",
2881
- name: "withdrawalAmount",
2882
- type: "uint256"
2883
- }
2884
- ],
2885
- name: "WithdrawalValidated",
2886
- type: "event"
2887
- },
2888
- {
2889
- inputs: [],
2890
- name: "DEFAULT_ADMIN_ROLE",
2891
- outputs: [
2892
- {
2893
- internalType: "bytes32",
2894
- name: "",
2895
- type: "bytes32"
2896
- }
2897
- ],
2898
- stateMutability: "view",
2899
- type: "function"
2900
- },
2901
- {
2902
- inputs: [],
2903
- name: "DEPOSIT_REPORTER_ROLE",
2904
- outputs: [
2905
- {
2906
- internalType: "bytes32",
2907
- name: "",
2908
- type: "bytes32"
2909
- }
2910
- ],
2911
- stateMutability: "view",
2912
- type: "function"
2913
- },
2914
- {
2915
- inputs: [],
2916
- name: "PAUSER_ROLE",
2917
- outputs: [
2918
- {
2919
- internalType: "bytes32",
2920
- name: "",
2921
- type: "bytes32"
2922
- }
2923
- ],
2924
- stateMutability: "view",
2925
- type: "function"
2926
- },
2927
- {
2928
- inputs: [],
2929
- name: "VALIDATION_GUARDIAN_ROLE",
2930
- outputs: [
2931
- {
2932
- internalType: "bytes32",
2933
- name: "",
2934
- type: "bytes32"
2935
- }
2936
- ],
2937
- stateMutability: "view",
2938
- type: "function"
2939
- },
2940
- {
2941
- inputs: [],
2942
- name: "WITHDRAWAL_VALIDATOR_ROLE",
2943
- outputs: [
2944
- {
2945
- internalType: "bytes32",
2946
- name: "",
2947
- type: "bytes32"
2948
- }
2949
- ],
2950
- stateMutability: "view",
2951
- type: "function"
2952
- },
2953
- {
2954
- inputs: [],
2955
- name: "acceptDefaultAdminTransfer",
2956
- outputs: [],
2957
- stateMutability: "nonpayable",
2958
- type: "function"
2959
- },
2960
- {
2961
- inputs: [
2962
- {
2963
- internalType: "address",
2964
- name: "newAdmin",
2965
- type: "address"
2966
- }
2967
- ],
2968
- name: "beginDefaultAdminTransfer",
2969
- outputs: [],
2970
- stateMutability: "nonpayable",
2971
- type: "function"
2972
- },
2973
- {
2974
- inputs: [],
2975
- name: "cancelDefaultAdminTransfer",
2976
- outputs: [],
2977
- stateMutability: "nonpayable",
2978
- type: "function"
2979
- },
2980
- {
2981
- inputs: [
2982
- {
2983
- internalType: "uint48",
2984
- name: "newDelay",
2985
- type: "uint48"
2986
- }
2987
- ],
2988
- name: "changeDefaultAdminDelay",
2989
- outputs: [],
2990
- stateMutability: "nonpayable",
2991
- type: "function"
2992
- },
2993
- {
2994
- inputs: [],
2995
- name: "defaultAdmin",
2996
- outputs: [
2997
- {
2998
- internalType: "address",
2999
- name: "",
3000
- type: "address"
3001
- }
3002
- ],
3003
- stateMutability: "view",
3004
- type: "function"
3005
- },
3006
- {
3007
- inputs: [],
3008
- name: "defaultAdminDelay",
3009
- outputs: [
3010
- {
3011
- internalType: "uint48",
3012
- name: "",
3013
- type: "uint48"
3014
- }
3015
- ],
3016
- stateMutability: "view",
3017
- type: "function"
3018
- },
3019
- {
3020
- inputs: [],
3021
- name: "defaultAdminDelayIncreaseWait",
3022
- outputs: [
3023
- {
3024
- internalType: "uint48",
3025
- name: "",
3026
- type: "uint48"
3027
- }
3028
- ],
3029
- stateMutability: "view",
3030
- type: "function"
3031
- },
3032
- {
3033
- inputs: [
3034
- {
3035
- internalType: "bytes32",
3036
- name: "depositID",
3037
- type: "bytes32"
3038
- }
3039
- ],
3040
- name: "depositHistory",
3041
- outputs: [
3042
- {
3043
- internalType: "enum Bascule.DepositState",
3044
- name: "status",
3045
- type: "uint8"
3046
- }
3047
- ],
3048
- stateMutability: "view",
3049
- type: "function"
3050
- },
3051
- {
3052
- inputs: [
3053
- {
3054
- internalType: "bytes32",
3055
- name: "role",
3056
- type: "bytes32"
3057
- }
3058
- ],
3059
- name: "getRoleAdmin",
3060
- outputs: [
3061
- {
3062
- internalType: "bytes32",
3063
- name: "",
3064
- type: "bytes32"
3065
- }
3066
- ],
3067
- stateMutability: "view",
3068
- type: "function"
3069
- },
3070
- {
3071
- inputs: [
3072
- {
3073
- internalType: "bytes32",
3074
- name: "role",
3075
- type: "bytes32"
3076
- },
3077
- {
3078
- internalType: "address",
3079
- name: "account",
3080
- type: "address"
3081
- }
3082
- ],
3083
- name: "grantRole",
3084
- outputs: [],
3085
- stateMutability: "nonpayable",
3086
- type: "function"
3087
- },
3088
- {
3089
- inputs: [
3090
- {
3091
- internalType: "bytes32",
3092
- name: "role",
3093
- type: "bytes32"
3094
- },
3095
- {
3096
- internalType: "address",
3097
- name: "account",
3098
- type: "address"
3099
- }
3100
- ],
3101
- name: "hasRole",
3102
- outputs: [
3103
- {
3104
- internalType: "bool",
3105
- name: "",
3106
- type: "bool"
3107
- }
3108
- ],
3109
- stateMutability: "view",
3110
- type: "function"
3111
- },
3112
- {
3113
- inputs: [],
3114
- name: "maxDeposits",
3115
- outputs: [
3116
- {
3117
- internalType: "uint256",
3118
- name: "",
3119
- type: "uint256"
3120
- }
3121
- ],
3122
- stateMutability: "view",
3123
- type: "function"
3124
- },
3125
- {
3126
- inputs: [],
3127
- name: "owner",
3128
- outputs: [
3129
- {
3130
- internalType: "address",
3131
- name: "",
3132
- type: "address"
3133
- }
3134
- ],
3135
- stateMutability: "view",
3136
- type: "function"
3137
- },
3138
- {
3139
- inputs: [],
3140
- name: "pause",
3141
- outputs: [],
3142
- stateMutability: "nonpayable",
3143
- type: "function"
3144
- },
3145
- {
3146
- inputs: [],
3147
- name: "paused",
3148
- outputs: [
3149
- {
3150
- internalType: "bool",
3151
- name: "",
3152
- type: "bool"
3153
- }
3154
- ],
3155
- stateMutability: "view",
3156
- type: "function"
3157
- },
3158
- {
3159
- inputs: [],
3160
- name: "pendingDefaultAdmin",
3161
- outputs: [
3162
- {
3163
- internalType: "address",
3164
- name: "newAdmin",
3165
- type: "address"
3166
- },
3167
- {
3168
- internalType: "uint48",
3169
- name: "schedule",
3170
- type: "uint48"
3171
- }
3172
- ],
3173
- stateMutability: "view",
3174
- type: "function"
3175
- },
3176
- {
3177
- inputs: [],
3178
- name: "pendingDefaultAdminDelay",
3179
- outputs: [
3180
- {
3181
- internalType: "uint48",
3182
- name: "newDelay",
3183
- type: "uint48"
3184
- },
3185
- {
3186
- internalType: "uint48",
3187
- name: "schedule",
3188
- type: "uint48"
3189
- }
3190
- ],
3191
- stateMutability: "view",
3192
- type: "function"
3193
- },
3194
- {
3195
- inputs: [
3196
- {
3197
- internalType: "bytes32",
3198
- name: "role",
3199
- type: "bytes32"
3200
- },
3201
- {
3202
- internalType: "address",
3203
- name: "account",
3204
- type: "address"
3205
- }
3206
- ],
3207
- name: "renounceRole",
3208
- outputs: [],
3209
- stateMutability: "nonpayable",
3210
- type: "function"
3211
- },
3212
- {
3213
- inputs: [
3214
- {
3215
- internalType: "bytes32",
3216
- name: "reportId",
3217
- type: "bytes32"
3218
- },
3219
- {
3220
- internalType: "bytes32[]",
3221
- name: "depositIDs",
3222
- type: "bytes32[]"
3223
- }
3224
- ],
3225
- name: "reportDeposits",
3226
- outputs: [],
3227
- stateMutability: "nonpayable",
3228
- type: "function"
3229
- },
3230
- {
3231
- inputs: [
3232
- {
3233
- internalType: "bytes32",
3234
- name: "role",
3235
- type: "bytes32"
3236
- },
3237
- {
3238
- internalType: "address",
3239
- name: "account",
3240
- type: "address"
3241
- }
3242
- ],
3243
- name: "revokeRole",
3244
- outputs: [],
3245
- stateMutability: "nonpayable",
3246
- type: "function"
3247
- },
3248
- {
3249
- inputs: [],
3250
- name: "rollbackDefaultAdminDelay",
3251
- outputs: [],
3252
- stateMutability: "nonpayable",
3253
- type: "function"
3254
- },
3255
- {
3256
- inputs: [
3257
- {
3258
- internalType: "uint256",
3259
- name: "aMaxDeposits",
3260
- type: "uint256"
3261
- }
3262
- ],
3263
- name: "setMaxDeposits",
3264
- outputs: [],
3265
- stateMutability: "nonpayable",
3266
- type: "function"
3267
- },
3268
- {
3269
- inputs: [
3270
- {
3271
- internalType: "bytes4",
3272
- name: "interfaceId",
3273
- type: "bytes4"
3274
- }
3275
- ],
3276
- name: "supportsInterface",
3277
- outputs: [
3278
- {
3279
- internalType: "bool",
3280
- name: "",
3281
- type: "bool"
3282
- }
3283
- ],
3284
- stateMutability: "view",
3285
- type: "function"
3286
- },
3287
- {
3288
- inputs: [],
3289
- name: "unpause",
3290
- outputs: [],
3291
- stateMutability: "nonpayable",
3292
- type: "function"
3293
- },
3294
- {
3295
- inputs: [
3296
- {
3297
- internalType: "uint256",
3298
- name: "newThreshold",
3299
- type: "uint256"
3300
- }
3301
- ],
3302
- name: "updateValidateThreshold",
3303
- outputs: [],
3304
- stateMutability: "nonpayable",
3305
- type: "function"
3306
- },
3307
- {
3308
- inputs: [],
3309
- name: "validateThreshold",
3310
- outputs: [
3311
- {
3312
- internalType: "uint256",
3313
- name: "",
3314
- type: "uint256"
3315
- }
3316
- ],
3317
- stateMutability: "view",
3318
- type: "function"
3319
- },
3320
- {
3321
- inputs: [
3322
- {
3323
- internalType: "bytes32",
3324
- name: "depositID",
3325
- type: "bytes32"
3326
- },
3327
- {
3328
- internalType: "uint256",
3329
- name: "withdrawalAmount",
3330
- type: "uint256"
3331
- }
3332
- ],
3333
- name: "validateWithdrawal",
3334
- outputs: [],
3335
- stateMutability: "nonpayable",
3336
- type: "function"
3337
- }
3338
- ];
3339
- function tt(e) {
3340
- switch (e) {
3341
- case "LBTC":
3342
- return Qe;
3343
- default:
3344
- return Ye;
3345
- }
3346
- }
3347
- function E(e, t) {
3348
- const n = Xe(t), { chainId: s } = e;
3349
- if (!ee(s))
3350
- throw new Error(`This chain ${s} is not supported`);
3351
- const i = n[s];
3352
- if (!i)
3353
- throw new Error(`Token address for chain ${s} is not defined`);
3354
- const r = tt("LBTC"), p = e.createContract(r, i);
3355
- return p.options.address || (p.options.address = i), p;
3356
- }
3357
- function Xt({
3358
- spender: e,
3359
- amount: t,
3360
- env: n,
3361
- ...s
3362
- }) {
3363
- const i = new _(s), r = E(i, n), p = ce(t), u = r.methods.approve(e, p);
3364
- return i.sendTransactionAsync(
3365
- i.account,
3366
- r.options.address,
3367
- {
3368
- data: u.encodeABI(),
3369
- estimate: !0,
3370
- estimateFee: !0,
3371
- gasLimitMultiplier: Q(i.chainId)
2520
+ else
2521
+ c.gas = g.numberToHex(b);
2522
+ const { maxFeePerGas: U, maxPriorityFeePerGas: B } = l ? await this.getMaxFees().catch(() => i) : i;
2523
+ if (B !== void 0 && (c.maxPriorityFeePerGas = g.numberToHex(B)), U !== void 0 && (c.maxFeePerGas = g.numberToHex(U)), !c.maxFeePerGas && !c.maxPriorityFeePerGas) {
2524
+ const f = await this.getSafeGasPriceWei();
2525
+ c.gasPrice = f.toString(10);
3372
2526
  }
3373
- );
3374
- }
3375
- const nt = "insufficient funds", at = "Insufficient funds for transfer. Make sure you have enough ETH to cover the gas cost.", pe = (e) => e.startsWith("0x") ? e : "0x" + e;
3376
- async function Yt({
3377
- data: e,
3378
- proofSignature: t,
3379
- env: n,
3380
- ...s
3381
- }) {
3382
- const i = new _(s), r = E(i, n), p = r.methods.mint(pe(e), pe(t));
3383
- try {
3384
- return await i.sendTransactionAsync(
3385
- i.account,
3386
- r.options.address,
3387
- {
3388
- data: p.encodeABI(),
3389
- // TODO: add getGasOptions from the app for bsc here
3390
- estimate: !0,
3391
- estimateFee: !0,
3392
- gasLimitMultiplier: Q(i.chainId)
3393
- }
3394
- );
3395
- } catch (u) {
3396
- console.log("error", u);
3397
- const y = I(u);
3398
- throw y.includes(nt) ? new Error(at) : new Error(y);
3399
- }
3400
- }
3401
- const st = 208, it = 4001, rt = 4100, ot = 4200, pt = 4900, ut = 4901, O = -32700, U = -32600, F = -32601, B = -32602, L = -32603, k = -32e3, G = -32001, W = -32002, V = -32003, $ = -32004, H = -32005, J = -32006;
3402
- class le extends Error {
3403
- constructor(t, n) {
3404
- 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;
3405
- }
3406
- /**
3407
- * @deprecated Use the `cause` property instead.
3408
- */
3409
- get innerError() {
3410
- return this.cause instanceof z ? this.cause.errors : this.cause;
3411
- }
3412
- /**
3413
- * @deprecated Use the `cause` property instead.
3414
- */
3415
- set innerError(t) {
3416
- Array.isArray(t) ? this.cause = new z(t) : this.cause = t;
3417
- }
3418
- static convertToString(t, n = !1) {
3419
- if (t == null)
3420
- return "undefined";
3421
- const s = JSON.stringify(t, (i, r) => typeof r == "bigint" ? r.toString() : r);
3422
- return n && ["bigint", "string"].includes(typeof t) ? s.replace(/['\\"]+/g, "") : s;
3423
- }
3424
- toJSON() {
3425
- return {
3426
- name: this.name,
3427
- code: this.code,
3428
- message: this.message,
3429
- cause: this.cause,
3430
- // deprecated
3431
- innerError: this.cause
3432
- };
3433
- }
3434
- }
3435
- class z extends le {
3436
- constructor(t) {
3437
- super(`Multiple errors occurred: [${t.map((n) => n.message).join("], [")}]`), this.code = st, this.errors = t;
3438
- }
3439
- }
3440
- const dt = "An Rpc error has occured with a code of *code*", m = {
3441
- // EIP-1474 & JSON RPC 2.0
3442
- // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1474.md
3443
- [O]: {
3444
- message: "Parse error",
3445
- description: "Invalid JSON"
3446
- },
3447
- [U]: {
3448
- message: "Invalid request",
3449
- description: "JSON is not a valid request object "
3450
- },
3451
- [F]: {
3452
- message: "Method not found",
3453
- description: "Method does not exist "
3454
- },
3455
- [B]: {
3456
- message: "Invalid params",
3457
- description: "Invalid method parameters"
3458
- },
3459
- [L]: {
3460
- message: "Internal error",
3461
- description: "Internal JSON-RPC error"
3462
- },
3463
- [k]: {
3464
- message: "Invalid input",
3465
- description: "Missing or invalid parameters"
3466
- },
3467
- [G]: {
3468
- message: "Resource not found",
3469
- description: "Requested resource not found"
3470
- },
3471
- [W]: {
3472
- message: "Resource unavailable",
3473
- description: "Requested resource not available"
3474
- },
3475
- [V]: {
3476
- message: "Transaction rejected",
3477
- description: "Transaction creation failed"
3478
- },
3479
- [$]: {
3480
- message: "Method not supported",
3481
- description: "Method is not implemented"
3482
- },
3483
- [H]: {
3484
- message: "Limit exceeded",
3485
- description: "Request exceeds defined limit"
3486
- },
3487
- [J]: {
3488
- message: "JSON-RPC version not supported",
3489
- description: "Version of JSON-RPC protocol is not supported"
3490
- },
3491
- // EIP-1193
3492
- // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1193.md#provider-errors
3493
- [it]: {
3494
- name: "User Rejected Request",
3495
- message: "The user rejected the request."
3496
- },
3497
- [rt]: {
3498
- name: "Unauthorized",
3499
- message: "The requested method and/or account has not been authorized by the user."
3500
- },
3501
- [ot]: {
3502
- name: "Unsupported Method",
3503
- message: "The Provider does not support the requested method."
3504
- },
3505
- [pt]: {
3506
- name: "Disconnected",
3507
- message: "The Provider is disconnected from all chains."
3508
- },
3509
- [ut]: {
3510
- name: "Chain Disconnected",
3511
- message: "The Provider is not connected to the requested chain."
3512
- },
3513
- // EIP-1193 - CloseEvent
3514
- // https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent/code
3515
- "0-999": {
3516
- name: "",
3517
- message: "Not used."
3518
- },
3519
- 1e3: {
3520
- name: "Normal Closure",
3521
- message: "The connection successfully completed the purpose for which it was created."
3522
- },
3523
- 1001: {
3524
- name: "Going Away",
3525
- 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."
3526
- },
3527
- 1002: {
3528
- name: "Protocol error",
3529
- message: "The endpoint is terminating the connection due to a protocol error."
3530
- },
3531
- 1003: {
3532
- name: "Unsupported Data",
3533
- 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.)"
3534
- },
3535
- 1004: {
3536
- name: "Reserved",
3537
- message: "Reserved. A meaning might be defined in the future."
3538
- },
3539
- 1005: {
3540
- name: "No Status Rcvd",
3541
- message: "Reserved. Indicates that no status code was provided even though one was expected."
3542
- },
3543
- 1006: {
3544
- name: "Abnormal Closure",
3545
- message: "Reserved. Indicates that a connection was closed abnormally (that is, with no close frame being sent) when a status code is expected."
3546
- },
3547
- 1007: {
3548
- name: "Invalid frame payload data",
3549
- 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)."
3550
- },
3551
- 1008: {
3552
- name: "Policy Violation",
3553
- 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."
3554
- },
3555
- 1009: {
3556
- name: "Message Too Big",
3557
- message: "The endpoint is terminating the connection because a data frame was received that is too large."
3558
- },
3559
- 1010: {
3560
- name: "Mandatory Ext.",
3561
- message: "The client is terminating the connection because it expected the server to negotiate one or more extension, but the server didn't."
3562
- },
3563
- 1011: {
3564
- name: "Internal Error",
3565
- message: "The server is terminating the connection because it encountered an unexpected condition that prevented it from fulfilling the request."
3566
- },
3567
- 1012: {
3568
- name: "Service Restart",
3569
- message: "The server is terminating the connection because it is restarting."
3570
- },
3571
- 1013: {
3572
- name: "Try Again Later",
3573
- 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."
3574
- },
3575
- 1014: {
3576
- name: "Bad Gateway",
3577
- 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."
3578
- },
3579
- 1015: {
3580
- name: "TLS handshake",
3581
- 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)."
3582
- },
3583
- "1016-2999": {
3584
- name: "",
3585
- message: "For definition by future revisions of the WebSocket Protocol specification, and for definition by extension specifications."
3586
- },
3587
- "3000-3999": {
3588
- name: "",
3589
- 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."
3590
- },
3591
- "4000-4999": {
3592
- name: "",
3593
- 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."
3594
- }
3595
- };
3596
- class b extends le {
3597
- constructor(t, n) {
3598
- super(n ?? dt.replace("*code*", t.error.code.toString())), this.code = t.error.code, this.id = t.id, this.jsonrpc = t.jsonrpc, this.jsonRpcError = t.error;
3599
- }
3600
- toJSON() {
3601
- return Object.assign(Object.assign({}, super.toJSON()), { error: this.jsonRpcError, id: this.id, jsonRpc: this.jsonrpc });
3602
- }
3603
- }
3604
- class yt extends b {
3605
- constructor(t) {
3606
- super(t, m[O].message), this.code = O;
3607
- }
3608
- }
3609
- class ct extends b {
3610
- constructor(t) {
3611
- super(t, m[U].message), this.code = U;
3612
- }
3613
- }
3614
- class lt extends b {
3615
- constructor(t) {
3616
- super(t, m[F].message), this.code = F;
3617
- }
3618
- }
3619
- class mt extends b {
3620
- constructor(t) {
3621
- super(t, m[B].message), this.code = B;
3622
- }
3623
- }
3624
- class bt extends b {
3625
- constructor(t) {
3626
- super(t, m[L].message), this.code = L;
3627
- }
3628
- }
3629
- class ft extends b {
3630
- constructor(t) {
3631
- super(t, m[k].message), this.code = k;
3632
- }
3633
- }
3634
- class Tt extends b {
3635
- constructor(t) {
3636
- super(t, m[$].message), this.code = $;
3637
- }
3638
- }
3639
- class ht extends b {
3640
- constructor(t) {
3641
- super(t, m[W].message), this.code = W;
3642
- }
3643
- }
3644
- class gt extends b {
3645
- constructor(t) {
3646
- super(t, m[G].message), this.code = G;
3647
- }
3648
- }
3649
- class wt extends b {
3650
- constructor(t) {
3651
- super(t, m[J].message), this.code = J;
3652
- }
3653
- }
3654
- class Et extends b {
3655
- constructor(t) {
3656
- super(t, m[V].message), this.code = V;
3657
- }
3658
- }
3659
- class At extends b {
3660
- constructor(t) {
3661
- super(t, m[H].message), this.code = H;
3662
- }
3663
- }
3664
- const f = /* @__PURE__ */ new Map();
3665
- f.set(O, { error: yt });
3666
- f.set(U, {
3667
- error: ct
3668
- });
3669
- f.set(F, {
3670
- error: lt
3671
- });
3672
- f.set(B, { error: mt });
3673
- f.set(L, { error: bt });
3674
- f.set(k, { error: ft });
3675
- f.set($, {
3676
- error: Tt
3677
- });
3678
- f.set(W, {
3679
- error: ht
3680
- });
3681
- f.set(V, {
3682
- error: Et
3683
- });
3684
- f.set(G, {
3685
- error: gt
3686
- });
3687
- f.set(J, {
3688
- error: wt
3689
- });
3690
- f.set(H, { error: At });
3691
- const vt = (e) => typeof e == "string" && /^((-)?0x[0-9a-f]+|(0x))$/i.test(e);
3692
- var Z;
3693
- (function(e) {
3694
- e.NUMBER = "NUMBER_NUMBER", e.HEX = "NUMBER_HEX", e.STR = "NUMBER_STR", e.BIGINT = "NUMBER_BIGINT";
3695
- })(Z || (Z = {}));
3696
- var j;
3697
- (function(e) {
3698
- e.HEX = "BYTES_HEX", e.UINT8ARRAY = "BYTES_UINT8ARRAY";
3699
- })(j || (j = {}));
3700
- Z.BIGINT, j.HEX;
3701
- Z.HEX, j.HEX;
3702
- var ue;
3703
- (function(e) {
3704
- e.EARLIEST = "earliest", e.LATEST = "latest", e.PENDING = "pending", e.SAFE = "safe", e.FINALIZED = "finalized";
3705
- })(ue || (ue = {}));
3706
- var de;
3707
- (function(e) {
3708
- 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";
3709
- })(de || (de = {}));
3710
- const Rt = {
3711
- [a.holesky]: "0x3a0c40c84b5034ed9a98a9a47a02af2b0885246f",
3712
- [a.sepolia]: o,
3713
- [a.ethereum]: o,
3714
- [a.binanceSmartChainTestnet]: o,
3715
- [a.binanceSmartChain]: o,
3716
- [a.base]: o,
3717
- [a.baseTestnet]: o,
3718
- [a.berachainBartioTestnet]: o,
3719
- [a.corn]: o
3720
- }, Ct = {
3721
- [a.holesky]: "0x3a0c40c84b5034ed9a98a9a47a02af2b0885246f",
3722
- [a.sepolia]: o,
3723
- [a.ethereum]: o,
3724
- [a.binanceSmartChainTestnet]: o,
3725
- [a.binanceSmartChain]: o,
3726
- [a.base]: o,
3727
- [a.baseTestnet]: o,
3728
- [a.berachainBartioTestnet]: o,
3729
- [a.corn]: o
3730
- }, St = {
3731
- [a.holesky]: o,
3732
- [a.sepolia]: o,
3733
- [a.ethereum]: "0xc750eCAC7250E0D18ecE2C7a5F130E3A765dc260",
3734
- [a.binanceSmartChainTestnet]: o,
3735
- [a.binanceSmartChain]: o,
3736
- [a.base]: o,
3737
- [a.baseTestnet]: o,
3738
- [a.berachainBartioTestnet]: o,
3739
- [a.corn]: o
3740
- };
3741
- function It(e = x) {
3742
- switch (e) {
3743
- case d.prod:
3744
- return St;
3745
- case d.testnet:
3746
- return Ct;
3747
- default:
3748
- return Rt;
3749
- }
3750
- }
3751
- function _t(e, t) {
3752
- const n = It(t), { chainId: s } = e;
3753
- if (!ee(s))
3754
- throw new Error(`This chain ${s} is not supported`);
3755
- const i = n[s];
3756
- if (!i)
3757
- throw new Error("The address for bascule module is not defined");
3758
- const r = e.createContract(et, i);
3759
- return r.options.address || (r.options.address = i), r;
3760
- }
3761
- const xt = "No deposit ID provided. Please provide a deposit ID as an argument.", Dt = "Invalid deposit ID. Expected a 0x-prefixed 32-byte hex string.";
3762
- var Mt = /* @__PURE__ */ ((e) => (e[e.UNREPORTED = 0] = "UNREPORTED", e[e.REPORTED = 1] = "REPORTED", e[e.WITHDRAWN = 2] = "WITHDRAWN", e))(Mt || {});
3763
- async function Qt({
3764
- txId: e,
3765
- env: t,
3766
- ...n
3767
- }) {
3768
- if (!e)
3769
- throw new Error(xt);
3770
- if (!vt(e))
3771
- throw new Error(Dt);
3772
- const s = new _(n), i = _t(s, t);
3773
- try {
3774
- const r = await i.methods.depositHistory(Buffer.from(e.replace(/^0x/, ""), "hex")).call();
3775
- return Number(r);
3776
- } catch (r) {
3777
- const p = I(r);
3778
- throw new Error(p);
3779
- }
3780
- }
3781
- const me = (e) => e in [a.ethereum, a.base, a.binanceSmartChain] ? d.prod : d.stage;
3782
- function be(e, t) {
3783
- if (!ee(e))
3784
- throw new Error(`This chain ${e} is not supported`);
3785
- const n = t ? { [e]: t } : P;
3786
- if (!n[e])
3787
- throw new Error(`RPC URL for chainId ${e} not found`);
3788
- return n;
3789
- }
3790
- async function en({
3791
- chainId: e,
3792
- bakeGasEstimate: t = 0,
3793
- rpcUrl: n
3794
- }) {
3795
- const s = be(e, n), i = new q({ chainId: e, rpcUrlConfig: s }), r = me(e), u = await E(i, r).methods.getMintFee().call(), y = new R(K(u.toString(10)));
3796
- return t ? y.plus(K(t)) : y;
3797
- }
3798
- async function tn({
3799
- env: e,
3800
- rpcUrl: t,
3801
- chainId: n
3802
- }) {
3803
- const s = { [n]: t }, i = new q({ chainId: n, rpcUrlConfig: s });
3804
- return (await E(i, e).methods.totalSupply().call()).toString();
3805
- }
3806
- async function nn({
3807
- owner: e,
3808
- rpcUrl: t,
3809
- chainId: n
3810
- }) {
3811
- const s = be(n, t), i = new q({ chainId: n, rpcUrlConfig: s }), r = me(n), p = E(i, r);
3812
- try {
3813
- return (await p.methods.nonces(e).call()).toString();
3814
- } catch (u) {
3815
- const y = I(u);
3816
- throw new Error(y);
2527
+ if (!c.maxFeePerGas && !c.maxPriorityFeePerGas) {
2528
+ const f = await this.getSafeGasPriceWei();
2529
+ c.gasPrice = f.toString(10);
2530
+ }
2531
+ return console.log("Sending transaction via Web3: ", c), new Promise((f, I) => {
2532
+ const k = o.eth.sendTransaction(c);
2533
+ k.once("transactionHash", async (L) => {
2534
+ console.log(`Just signed transaction has is: ${L}`), f({
2535
+ receiptPromise: k,
2536
+ transactionHash: L
2537
+ });
2538
+ }).catch(I);
2539
+ });
3817
2540
  }
3818
- }
3819
- const te = {
3820
- [a.sepolia]: "0xe3748bF0Ec0A76767539eE28610B3367e35fe2C2",
3821
- [a.berachainBartioTestnet]: "0x1977013acaf27856ac8048C42EE2ed0134d53895",
3822
- [a.corn]: o,
3823
- [a.ethereum]: o
3824
- }, Nt = {
3825
- ...te
3826
- }, Pt = {
3827
- ...te,
3828
- [a.corn]: "0xfc7B20D9B59A8A466f4fC3d34aA69a7D98e71d7A",
3829
- [a.ethereum]: "0x6bc15d7930839ec18a57f6f7df72ae1b439d077f"
3830
- };
3831
- function an(e = x) {
3832
- switch (e) {
3833
- case d.prod:
3834
- return Pt;
3835
- case d.testnet:
3836
- return Nt;
3837
- default:
3838
- return te;
2541
+ createContract(n, a) {
2542
+ return new this.web3.eth.Contract(n, a);
3839
2543
  }
3840
2544
  }
3841
- async function sn(e) {
3842
- const t = new _(e), n = `destination chain id is ${e.chainId}`;
2545
+ async function qe(e) {
2546
+ const t = new F(e), n = `destination chain id is ${e.chainId}`;
3843
2547
  return t.signMessage(n);
3844
2548
  }
3845
- const Ot = 24 * 60 * 60;
3846
- function Ut({
2549
+ const Ee = 24 * 60 * 60;
2550
+ function Ie({
3847
2551
  chainId: e,
3848
2552
  verifyingContract: t,
3849
2553
  fee: n,
3850
- expiry: s
2554
+ expiry: a
3851
2555
  }) {
3852
2556
  return {
3853
2557
  domain: {
@@ -3859,7 +2563,7 @@ function Ut({
3859
2563
  message: {
3860
2564
  chainId: e,
3861
2565
  fee: n,
3862
- expiry: s
2566
+ expiry: a
3863
2567
  },
3864
2568
  primaryType: "feeApproval",
3865
2569
  types: {
@@ -3877,113 +2581,178 @@ function Ut({
3877
2581
  }
3878
2582
  };
3879
2583
  }
3880
- const Ft = "Failed to obtain a valid signature. The response is undefined or invalid.";
3881
- async function rn({
2584
+ const xe = "Failed to obtain a valid signature. The response is undefined or invalid.", Me = () => Math.floor(Date.now() / 1e3 + Ee);
2585
+ async function je({
3882
2586
  address: e,
3883
2587
  provider: t,
3884
2588
  fee: n,
3885
- chainId: s,
2589
+ chainId: a,
3886
2590
  env: i,
3887
- expiry: r = Date.now() + Ot
2591
+ expiry: r = Me()
3888
2592
  }) {
3889
- var g, D;
3890
- const p = new _({
2593
+ var y, b;
2594
+ const o = new F({
3891
2595
  provider: t,
3892
2596
  account: e,
3893
- chainId: s
3894
- }), y = E(p, i).options.address, h = JSON.stringify(
3895
- Ut({
3896
- chainId: s,
3897
- verifyingContract: y,
2597
+ chainId: a
2598
+ }), d = R(o, i).options.address, m = JSON.stringify(
2599
+ Ie({
2600
+ chainId: a,
2601
+ verifyingContract: d,
3898
2602
  fee: n,
3899
- expiry: r.toString()
2603
+ expiry: r
3900
2604
  })
3901
- ), l = await ((D = (g = p.web3) == null ? void 0 : g.currentProvider) == null ? void 0 : D.request({
2605
+ ), l = await ((b = (y = o.web3) == null ? void 0 : y.currentProvider) == null ? void 0 : b.request({
3902
2606
  method: "eth_signTypedData_v4",
3903
- params: [e, h]
2607
+ params: [e, m]
3904
2608
  }));
3905
2609
  if (typeof l == "string")
3906
- return { signature: l, typedData: h };
2610
+ return { signature: l, typedData: m };
3907
2611
  if (!(l != null && l.result))
3908
- throw new Error(Ft);
3909
- return { signature: l.result, typedData: h };
3910
- }
3911
- Ee(we);
3912
- function Bt(e, t = d.prod) {
3913
- var r;
3914
- const n = Lt(e), i = (r = Ae[n]({
3915
- address: e,
3916
- network: t === d.prod ? oe.bitcoin : oe.testnet
3917
- }).output) == null ? void 0 : r.toString("hex");
3918
- if (!i)
3919
- throw new Error("Output script is not found.");
3920
- return `0x${i}`;
2612
+ throw new Error(xe);
2613
+ return { signature: l.result, typedData: m };
3921
2614
  }
3922
- function Lt(e) {
3923
- const t = ve.fromBech32(e);
3924
- if (t.version === 1 && t.data.length === 32)
3925
- return "p2tr";
3926
- if (t.version === 0 && t.data.length === 20)
3927
- return "p2wpkh";
3928
- if (kt(e))
3929
- return "p2wsh";
3930
- throw new Error("Address type is not supported.");
3931
- }
3932
- function kt(e) {
3933
- return (e.startsWith("bc1") || e.startsWith("tb1")) && e.length === 62;
2615
+ async function Ne({
2616
+ owner: e,
2617
+ rpcUrl: t,
2618
+ chainId: n
2619
+ }) {
2620
+ const a = Z(n, t), i = new O({ chainId: n, rpcUrlConfig: a }), r = W(n), o = R(i, r);
2621
+ try {
2622
+ return (await o.methods.nonces(e).call()).toString();
2623
+ } catch (p) {
2624
+ const d = C(p);
2625
+ throw new Error(d);
2626
+ }
3934
2627
  }
3935
- function on({
3936
- btcAddress: e,
3937
- amount: t,
3938
- env: n,
3939
- ...s
2628
+ async function De({
2629
+ chainId: e,
2630
+ expiryDate: t,
2631
+ owner: n,
2632
+ spender: a,
2633
+ value: i,
2634
+ env: r,
2635
+ rpcUrl: o
3940
2636
  }) {
3941
- const i = new _(s), r = E(i, n), p = Bt(e, n), u = ce(t), y = r.methods.redeem(p, u);
3942
- return i.sendTransactionAsync(
3943
- i.account,
3944
- r.options.address,
3945
- {
3946
- data: y.encodeABI(),
3947
- estimate: !0,
3948
- estimateFee: !0,
3949
- gasLimitMultiplier: Q(i.chainId)
2637
+ const d = V(r)[e], m = await Ne({
2638
+ owner: n,
2639
+ chainId: e,
2640
+ rpcUrl: o
2641
+ });
2642
+ return {
2643
+ domain: {
2644
+ name: "Lombard Staked Bitcoin",
2645
+ version: "1",
2646
+ chainId: e,
2647
+ verifyingContract: d
2648
+ },
2649
+ types: {
2650
+ EIP712Domain: [
2651
+ {
2652
+ name: "name",
2653
+ type: "string"
2654
+ },
2655
+ {
2656
+ name: "version",
2657
+ type: "string"
2658
+ },
2659
+ {
2660
+ name: "chainId",
2661
+ type: "uint256"
2662
+ },
2663
+ {
2664
+ name: "verifyingContract",
2665
+ type: "address"
2666
+ }
2667
+ ],
2668
+ Permit: [
2669
+ { name: "owner", type: "address" },
2670
+ { name: "spender", type: "address" },
2671
+ { name: "value", type: "uint256" },
2672
+ { name: "nonce", type: "uint256" },
2673
+ { name: "deadline", type: "uint256" }
2674
+ ]
2675
+ },
2676
+ primaryType: "Permit",
2677
+ message: {
2678
+ owner: n,
2679
+ spender: a,
2680
+ value: i,
2681
+ nonce: m,
2682
+ deadline: t.toString()
3950
2683
  }
3951
- );
2684
+ };
2685
+ }
2686
+ const Pe = {
2687
+ [s.holesky]: "0x52BD640617eeD47A00dA0da93351092D49208d1d"
2688
+ }, Oe = (e) => {
2689
+ const t = Pe[e];
2690
+ if (!t)
2691
+ throw new Error(`No spender address configured for chain ID ${e}`);
2692
+ return t;
2693
+ }, Re = "Failed to obtain a valid signature. The response is undefined or invalid.";
2694
+ async function Je({
2695
+ address: e,
2696
+ provider: t,
2697
+ chainId: n,
2698
+ value: a,
2699
+ env: i,
2700
+ expiryDate: r,
2701
+ rpcUrl: o
2702
+ }) {
2703
+ var b, _;
2704
+ const p = new F({
2705
+ provider: t,
2706
+ account: e,
2707
+ chainId: n
2708
+ }), d = Oe(n), m = await De({
2709
+ chainId: n,
2710
+ expiryDate: r,
2711
+ owner: e,
2712
+ spender: d,
2713
+ value: a,
2714
+ env: i,
2715
+ rpcUrl: o
2716
+ }), l = JSON.stringify(m), y = await ((_ = (b = p.web3) == null ? void 0 : b.currentProvider) == null ? void 0 : _.request({
2717
+ method: "eth_signTypedData_v4",
2718
+ params: [e, l]
2719
+ }));
2720
+ if (typeof y == "string")
2721
+ return { signature: y, typedData: l };
2722
+ if (!(y != null && y.result))
2723
+ throw new Error(Re);
2724
+ return { signature: y.result, typedData: l };
3952
2725
  }
3953
2726
  export {
3954
- Mt as BasculeDepositStatus,
3955
- We as ENotarizationStatus,
3956
- Ve as ESessionState,
3957
- a as OChainId,
3958
- d as OEnv,
3959
- Ne as SANCTIONED_ADDRESS,
3960
- Y as SATOSHI_SCALE,
3961
- Xt as approveLBTC,
3962
- Yt as claimLBTC,
3963
- K as fromSatoshi,
3964
- Jt as generateDepositBtcAddress,
3965
- S as getApiConfig,
3966
- Qt as getBasculeDepositStatus,
3967
- Se as getBaseNetworkByEnv,
3968
- Ce as getBscNetworkByEnv,
3969
- Ge as getChainIdByName,
3970
- X as getChainNameById,
3971
- Zt as getDepositBtcAddress,
3972
- Le as getDepositBtcAddresses,
3973
- jt as getDepositsByAddress,
3974
- Re as getEthNetworkByEnv,
3975
- qt as getLBTCExchangeRate,
3976
- en as getLBTCMintingFee,
3977
- tn as getLBTCTotalSupply,
3978
- Xe as getLbtcAddressConfig,
3979
- an as getLbtcOFTAdapterAddressConfig,
3980
- zt as getNetworkFeeSignature,
3981
- nn as getPermitNonce,
3982
- ee as isValidChain,
3983
- sn as signLbtcDestionationAddr,
3984
- rn as signNetworkFee,
3985
- Kt as storeNetworkFeeSignature,
3986
- ce as toSatoshi,
3987
- on as unstakeLBTC
2727
+ le as ENotarizationStatus,
2728
+ ce as ESessionState,
2729
+ s as OChainId,
2730
+ T as OEnv,
2731
+ ae as SANCTIONED_ADDRESS,
2732
+ P as SATOSHI_SCALE,
2733
+ Pe as STAKE_AND_BAKE_SPENDER_ADDRESSES,
2734
+ M as fromSatoshi,
2735
+ Le as generateDepositBtcAddress,
2736
+ w as getApiConfig,
2737
+ X as getBaseNetworkByEnv,
2738
+ J as getBscNetworkByEnv,
2739
+ de as getChainIdByName,
2740
+ D as getChainNameById,
2741
+ Ge as getDepositBtcAddress,
2742
+ ue as getDepositBtcAddresses,
2743
+ We as getDepositsByAddress,
2744
+ j as getEthNetworkByEnv,
2745
+ $e as getLBTCExchangeRate,
2746
+ ze as getLBTCMintingFee,
2747
+ Ve as getNetworkFeeSignature,
2748
+ Oe as getStakeAndBakeSpenderAddress,
2749
+ De as getStakeAndBakeTypedData,
2750
+ $ as isValidChain,
2751
+ qe as signLbtcDestionationAddr,
2752
+ je as signNetworkFee,
2753
+ Je as signStakeAndBake,
2754
+ Ze as storeNetworkFeeSignature,
2755
+ Ke as storeStakeAndBakeSignature,
2756
+ He as toSatoshi
3988
2757
  };
3989
2758
  //# sourceMappingURL=index.js.map