@lombard.finance/sdk 2.0.14 → 2.0.16
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.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +456 -331
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/sdk/getNetworkFeeSignature/getNetworkFeeSignature.stories.tsx +1 -1
- package/src/sdk/getUserStakeAndBakeSignature/getUserStakeAndBakeSignature.stories.tsx +34 -5
- package/src/sdk/getUserStakeAndBakeSignature/getUserStakeAndBakeSignature.ts +30 -4
- package/src/sdk/storeStakeAndBakeSignature/storeStakeAndBakeSignature.stories.tsx +36 -29
- package/src/web3Sdk/index.ts +7 -2
- package/src/web3Sdk/signStakeAndBake/contracts.ts +46 -5
- package/src/web3Sdk/signStakeAndBake/signStakeAndBake.stories.tsx +27 -27
- package/src/web3Sdk/signStakeAndBake/signStakeAndBake.ts +5 -3
- package/src/web3Sdk/signStakeAndBake/config.ts +0 -10
package/dist/index.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
1
|
+
var we = Object.defineProperty;
|
|
2
|
+
var Ee = (e, t, n) => t in e ? we(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var _ = (e, t, n) => (Ee(e, typeof t != "symbol" ? t + "" : t, n), n);
|
|
4
4
|
import E from "axios";
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
5
|
+
import D from "bignumber.js";
|
|
6
|
+
import ye, { Web3 as re, utils as S } from "web3";
|
|
7
|
+
import * as Ae from "@bitcoin-js/tiny-secp256k1-asmjs";
|
|
8
|
+
import { initEccLib as ve, payments as Re, networks as oe, address as Se } from "bitcoinjs-lib";
|
|
9
|
+
const l = {
|
|
8
10
|
prod: "prod",
|
|
9
11
|
testnet: "testnet",
|
|
10
12
|
stage: "stage"
|
|
@@ -19,35 +21,35 @@ const h = {
|
|
|
19
21
|
berachainBartioTestnet: 80084,
|
|
20
22
|
corn: 21e6,
|
|
21
23
|
swell: 1923
|
|
22
|
-
},
|
|
24
|
+
}, Ce = (e) => e === l.prod ? i.ethereum : i.holesky, _e = (e) => e === l.prod ? i.binanceSmartChain : i.binanceSmartChainTestnet, Ie = (e) => e === l.prod ? i.base : i.baseTestnet, K = l.prod, u = "0x0000000000000000000000000000000000000000", De = {
|
|
23
25
|
baseApiUrl: "https://staging.prod.lombard.finance"
|
|
24
|
-
},
|
|
26
|
+
}, xe = {
|
|
25
27
|
baseApiUrl: "https://gastald-testnet.prod.lombard.finance"
|
|
26
|
-
},
|
|
28
|
+
}, Ne = {
|
|
27
29
|
baseApiUrl: "https://mainnet.prod.lombard.finance"
|
|
28
|
-
}, A = (e =
|
|
30
|
+
}, A = (e = K) => {
|
|
29
31
|
switch (e) {
|
|
30
|
-
case
|
|
31
|
-
return
|
|
32
|
-
case
|
|
33
|
-
return
|
|
32
|
+
case l.prod:
|
|
33
|
+
return Ne;
|
|
34
|
+
case l.testnet:
|
|
35
|
+
return xe;
|
|
34
36
|
default:
|
|
35
|
-
return
|
|
37
|
+
return De;
|
|
36
38
|
}
|
|
37
39
|
};
|
|
38
40
|
function v(e) {
|
|
39
41
|
return typeof e == "string" ? e : ((n) => {
|
|
40
42
|
var a;
|
|
41
43
|
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 ?
|
|
44
|
+
})(e) ? e.data.message : e instanceof Error ? Me(e) : Pe(e);
|
|
43
45
|
}
|
|
44
|
-
function
|
|
46
|
+
function Me(e) {
|
|
45
47
|
return e.response ? e.response.data.message : e.message;
|
|
46
48
|
}
|
|
47
|
-
function
|
|
49
|
+
function Pe(e) {
|
|
48
50
|
return e != null && e.message ? e.message : "Unknown error";
|
|
49
51
|
}
|
|
50
|
-
const
|
|
52
|
+
const I = {
|
|
51
53
|
eth: "DESTINATION_BLOCKCHAIN_ETHEREUM",
|
|
52
54
|
base: "DESTINATION_BLOCKCHAIN_BASE",
|
|
53
55
|
bsc: "DESTINATION_BLOCKCHAIN_BSC",
|
|
@@ -57,24 +59,24 @@ const _ = {
|
|
|
57
59
|
scroll: "DESTINATION_BLOCKCHAIN_SCROLL",
|
|
58
60
|
xlayer: "DESTINATION_BLOCKCHAIN_XLAYER"
|
|
59
61
|
};
|
|
60
|
-
function
|
|
62
|
+
function Y(e) {
|
|
61
63
|
switch (e) {
|
|
62
64
|
case i.ethereum:
|
|
63
65
|
case i.holesky:
|
|
64
66
|
case i.sepolia:
|
|
65
|
-
return
|
|
67
|
+
return I.eth;
|
|
66
68
|
case i.base:
|
|
67
69
|
case i.baseTestnet:
|
|
68
|
-
return
|
|
70
|
+
return I.base;
|
|
69
71
|
case i.binanceSmartChain:
|
|
70
72
|
case i.binanceSmartChainTestnet:
|
|
71
|
-
return
|
|
73
|
+
return I.bsc;
|
|
72
74
|
default:
|
|
73
75
|
throw new Error(`Unknown chain ID: ${e}`);
|
|
74
76
|
}
|
|
75
77
|
}
|
|
76
|
-
const
|
|
77
|
-
async function
|
|
78
|
+
const Oe = "sanctioned_address", Ue = "api/v1/address/generate", Be = "destination address is under sanctions";
|
|
79
|
+
async function zt({
|
|
78
80
|
address: e,
|
|
79
81
|
chainId: t,
|
|
80
82
|
signature: n,
|
|
@@ -84,7 +86,7 @@ async function Ut({
|
|
|
84
86
|
partnerId: o,
|
|
85
87
|
captchaToken: p
|
|
86
88
|
}) {
|
|
87
|
-
const { baseApiUrl: d } = A(s), g =
|
|
89
|
+
const { baseApiUrl: d } = A(s), g = Y(t), b = {
|
|
88
90
|
to_address: e,
|
|
89
91
|
to_address_signature: n,
|
|
90
92
|
to_chain: g,
|
|
@@ -95,85 +97,85 @@ async function Ut({
|
|
|
95
97
|
eip_712_data: a
|
|
96
98
|
};
|
|
97
99
|
try {
|
|
98
|
-
const { data:
|
|
99
|
-
|
|
100
|
-
|
|
100
|
+
const { data: m } = await E.post(
|
|
101
|
+
Ue,
|
|
102
|
+
b,
|
|
101
103
|
{ baseURL: d }
|
|
102
104
|
);
|
|
103
|
-
return
|
|
104
|
-
} catch (
|
|
105
|
-
const
|
|
106
|
-
if (
|
|
107
|
-
return
|
|
108
|
-
throw new Error(
|
|
105
|
+
return m.address;
|
|
106
|
+
} catch (m) {
|
|
107
|
+
const y = v(m);
|
|
108
|
+
if (Fe(y))
|
|
109
|
+
return Oe;
|
|
110
|
+
throw new Error(y);
|
|
109
111
|
}
|
|
110
112
|
}
|
|
111
|
-
function
|
|
112
|
-
return !!e.includes(
|
|
113
|
+
function Fe(e) {
|
|
114
|
+
return !!e.includes(Be);
|
|
113
115
|
}
|
|
114
|
-
const
|
|
115
|
-
async function
|
|
116
|
+
const Le = "api/v1/address";
|
|
117
|
+
async function Xt({
|
|
116
118
|
address: e,
|
|
117
119
|
chainId: t,
|
|
118
120
|
env: n,
|
|
119
121
|
partnerId: a
|
|
120
122
|
}) {
|
|
121
|
-
const s = await
|
|
123
|
+
const s = await Ge({
|
|
122
124
|
address: e,
|
|
123
125
|
chainId: t,
|
|
124
126
|
env: n,
|
|
125
127
|
partnerId: a
|
|
126
|
-
}), r =
|
|
128
|
+
}), r = ke(s);
|
|
127
129
|
if (!r)
|
|
128
130
|
throw new Error("No address");
|
|
129
131
|
return r.btc_address;
|
|
130
132
|
}
|
|
131
|
-
function
|
|
133
|
+
function ke(e) {
|
|
132
134
|
if (!e.length)
|
|
133
135
|
return;
|
|
134
136
|
const t = e.reduce((n, a) => n.created_at < a.created_at ? a : n, e[0]);
|
|
135
137
|
return t.deprecated ? void 0 : t;
|
|
136
138
|
}
|
|
137
|
-
async function
|
|
139
|
+
async function Ge({
|
|
138
140
|
address: e,
|
|
139
141
|
chainId: t,
|
|
140
142
|
env: n,
|
|
141
143
|
partnerId: a
|
|
142
144
|
}) {
|
|
143
|
-
const { baseApiUrl: s } = A(n), r =
|
|
145
|
+
const { baseApiUrl: s } = A(n), r = Y(t), o = {
|
|
144
146
|
to_address: e,
|
|
145
147
|
to_blockchain: r,
|
|
146
148
|
limit: 1,
|
|
147
149
|
offset: 0,
|
|
148
150
|
asc: !1,
|
|
149
151
|
referralId: a
|
|
150
|
-
}, { data: p } = await E.get(
|
|
152
|
+
}, { data: p } = await E.get(Le, {
|
|
151
153
|
baseURL: s,
|
|
152
154
|
params: o
|
|
153
155
|
});
|
|
154
156
|
return (p == null ? void 0 : p.addresses) || [];
|
|
155
157
|
}
|
|
156
|
-
const
|
|
157
|
-
function
|
|
158
|
-
return +e /
|
|
158
|
+
const We = 8, Q = 10 ** We;
|
|
159
|
+
function ce(e) {
|
|
160
|
+
return +e / Q;
|
|
159
161
|
}
|
|
160
|
-
function
|
|
161
|
-
return Math.floor(+e *
|
|
162
|
+
function le(e) {
|
|
163
|
+
return Math.floor(+e * Q);
|
|
162
164
|
}
|
|
163
|
-
function
|
|
165
|
+
function Ve(e, t = K) {
|
|
164
166
|
switch (e) {
|
|
165
|
-
case
|
|
166
|
-
return
|
|
167
|
-
case
|
|
168
|
-
return
|
|
169
|
-
case
|
|
170
|
-
return
|
|
167
|
+
case I.eth:
|
|
168
|
+
return Ce(t);
|
|
169
|
+
case I.base:
|
|
170
|
+
return Ie(t);
|
|
171
|
+
case I.bsc:
|
|
172
|
+
return _e(t);
|
|
171
173
|
default:
|
|
172
174
|
return i.ethereum;
|
|
173
175
|
}
|
|
174
176
|
}
|
|
175
|
-
var
|
|
176
|
-
async function
|
|
177
|
+
var $e = /* @__PURE__ */ ((e) => (e.NOTARIZATION_STATUS_UNSPECIFIED = "NOTARIZATION_STATUS_UNSPECIFIED", e.NOTARIZATION_STATUS_PENDING = "NOTARIZATION_STATUS_PENDING", e.NOTARIZATION_STATUS_SUBMITTED = "NOTARIZATION_STATUS_SUBMITTED", e.NOTARIZATION_STATUS_SESSION_APPROVED = "NOTARIZATION_STATUS_SESSION_APPROVED", e.NOTARIZATION_STATUS_FAILED = "NOTARIZATION_STATUS_FAILED", e))($e || {}), He = /* @__PURE__ */ ((e) => (e.SESSION_STATE_UNSPECIFIED = "SESSION_STATE_UNSPECIFIED", e.SESSION_STATE_PENDING = "SESSION_STATE_PENDING", e.SESSION_STATE_COMPLETED = "SESSION_STATE_COMPLETED", e.SESSION_STATE_EXPIRED = "SESSION_STATE_EXPIRED", e))(He || {});
|
|
178
|
+
async function Yt({
|
|
177
179
|
address: e,
|
|
178
180
|
env: t
|
|
179
181
|
}) {
|
|
@@ -181,17 +183,17 @@ async function Lt({
|
|
|
181
183
|
`api/v1/address/outputs-v2/${e}`,
|
|
182
184
|
{ baseURL: n }
|
|
183
185
|
);
|
|
184
|
-
return ((a == null ? void 0 : a.outputs) ?? []).map(
|
|
186
|
+
return ((a == null ? void 0 : a.outputs) ?? []).map(je(t));
|
|
185
187
|
}
|
|
186
|
-
function
|
|
188
|
+
function je(e) {
|
|
187
189
|
return (t) => ({
|
|
188
190
|
txid: t.txid,
|
|
189
191
|
index: t.index ?? 0,
|
|
190
192
|
blockHeight: t.block_height ? Number(t.block_height) : void 0,
|
|
191
193
|
blockTime: t.block_time ? Number(t.block_time) : void 0,
|
|
192
|
-
value: new
|
|
194
|
+
value: new D(ce(t.value)),
|
|
193
195
|
address: t.address,
|
|
194
|
-
chainId:
|
|
196
|
+
chainId: Ve(t.to_chain, e),
|
|
195
197
|
claimedTxId: t.claim_tx,
|
|
196
198
|
rawPayload: t.raw_payload,
|
|
197
199
|
signature: t.proof,
|
|
@@ -203,19 +205,19 @@ function Be(e) {
|
|
|
203
205
|
sessionState: t.session_state
|
|
204
206
|
});
|
|
205
207
|
}
|
|
206
|
-
const
|
|
207
|
-
async function
|
|
208
|
+
const Je = 2e-4;
|
|
209
|
+
async function Qt({
|
|
208
210
|
env: e,
|
|
209
211
|
chainId: t = i.ethereum,
|
|
210
212
|
amount: n = 1
|
|
211
213
|
}) {
|
|
212
|
-
const { baseApiUrl: a } = A(e), s =
|
|
214
|
+
const { baseApiUrl: a } = A(e), s = Y(t), { data: r } = await E.get(
|
|
213
215
|
`api/v1/exchange/rate/${s}`,
|
|
214
216
|
{ baseURL: a, params: { amount: n } }
|
|
215
|
-
), o = new
|
|
217
|
+
), o = new D(Je).multipliedBy(Q).toFixed();
|
|
216
218
|
return { exchangeRate: +r.amount_out, minAmount: +o };
|
|
217
219
|
}
|
|
218
|
-
async function
|
|
220
|
+
async function en({
|
|
219
221
|
address: e,
|
|
220
222
|
chainId: t,
|
|
221
223
|
env: n
|
|
@@ -241,7 +243,7 @@ async function Gt({
|
|
|
241
243
|
throw new Error(r);
|
|
242
244
|
}
|
|
243
245
|
}
|
|
244
|
-
async function
|
|
246
|
+
async function tn({
|
|
245
247
|
userDestinationAddress: e,
|
|
246
248
|
chainId: t,
|
|
247
249
|
env: n
|
|
@@ -257,7 +259,13 @@ async function Wt({
|
|
|
257
259
|
}
|
|
258
260
|
}
|
|
259
261
|
);
|
|
260
|
-
return
|
|
262
|
+
return {
|
|
263
|
+
userDestinationAddress: s.user_destination_address,
|
|
264
|
+
signature: s.signature,
|
|
265
|
+
expirationDate: s.expiration_date,
|
|
266
|
+
depositAmount: s.deposit_amount,
|
|
267
|
+
chainId: s.chain_id
|
|
268
|
+
};
|
|
261
269
|
} catch (s) {
|
|
262
270
|
const r = v(s);
|
|
263
271
|
throw new Error(
|
|
@@ -265,7 +273,7 @@ async function Wt({
|
|
|
265
273
|
);
|
|
266
274
|
}
|
|
267
275
|
}
|
|
268
|
-
async function
|
|
276
|
+
async function nn({
|
|
269
277
|
signature: e,
|
|
270
278
|
typedData: t,
|
|
271
279
|
address: n,
|
|
@@ -290,7 +298,7 @@ async function Vt({
|
|
|
290
298
|
throw new Error(o);
|
|
291
299
|
}
|
|
292
300
|
}
|
|
293
|
-
async function
|
|
301
|
+
async function an({
|
|
294
302
|
signature: e,
|
|
295
303
|
typedData: t,
|
|
296
304
|
env: n
|
|
@@ -313,7 +321,7 @@ async function $t({
|
|
|
313
321
|
throw new Error(r);
|
|
314
322
|
}
|
|
315
323
|
}
|
|
316
|
-
const
|
|
324
|
+
const O = {
|
|
317
325
|
[i.ethereum]: "https://rpc.ankr.com/eth",
|
|
318
326
|
[i.holesky]: "https://rpc.ankr.com/eth_holesky",
|
|
319
327
|
[i.sepolia]: "https://rpc.ankr.com/eth_sepolia",
|
|
@@ -322,7 +330,7 @@ const P = {
|
|
|
322
330
|
[i.binanceSmartChain]: "https://rpc.ankr.com/bsc",
|
|
323
331
|
[i.binanceSmartChainTestnet]: "https://rpc.ankr.com/bsc_testnet_chapel"
|
|
324
332
|
};
|
|
325
|
-
async function
|
|
333
|
+
async function qe(e) {
|
|
326
334
|
const n = await (await fetch(e, {
|
|
327
335
|
method: "POST",
|
|
328
336
|
headers: {
|
|
@@ -334,15 +342,15 @@ async function ke(e) {
|
|
|
334
342
|
method: "eth_maxPriorityFeePerGas",
|
|
335
343
|
params: []
|
|
336
344
|
})
|
|
337
|
-
})).json(), a =
|
|
338
|
-
return new
|
|
345
|
+
})).json(), a = ye.utils.hexToNumber(n == null ? void 0 : n.result);
|
|
346
|
+
return new D(Number(a));
|
|
339
347
|
}
|
|
340
|
-
const
|
|
341
|
-
class
|
|
348
|
+
const Ze = 2, Ke = 25e3;
|
|
349
|
+
class z {
|
|
342
350
|
constructor({ chainId: t, rpcUrlConfig: n }) {
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
this.chainId = t, this.rpcConfig = { ...
|
|
351
|
+
_(this, "chainId");
|
|
352
|
+
_(this, "rpcConfig");
|
|
353
|
+
this.chainId = t, this.rpcConfig = { ...O, ...n };
|
|
346
354
|
}
|
|
347
355
|
/**
|
|
348
356
|
* Returns web3 instance for read operations.
|
|
@@ -351,7 +359,7 @@ class Y {
|
|
|
351
359
|
* @returns {Web3} Web3 instance.
|
|
352
360
|
*/
|
|
353
361
|
getReadWeb3() {
|
|
354
|
-
const t = this.getRpcUrl(), n = new
|
|
362
|
+
const t = this.getRpcUrl(), n = new re(), a = new re.providers.HttpProvider(t);
|
|
355
363
|
return n.setProvider(a), n;
|
|
356
364
|
}
|
|
357
365
|
/**
|
|
@@ -379,10 +387,10 @@ class Y {
|
|
|
379
387
|
async getMaxFees() {
|
|
380
388
|
const t = this.getReadWeb3(), n = this.getRpcUrl(), [a, s] = await Promise.all([
|
|
381
389
|
t.eth.getBlock("latest"),
|
|
382
|
-
|
|
390
|
+
qe(n)
|
|
383
391
|
]);
|
|
384
392
|
return !(a != null && a.baseFeePerGas) && typeof (a == null ? void 0 : a.baseFeePerGas) != "bigint" ? {} : {
|
|
385
|
-
maxFeePerGas: +new
|
|
393
|
+
maxFeePerGas: +new D(a.baseFeePerGas.toString(10)).multipliedBy(Ze).plus(s),
|
|
386
394
|
maxPriorityFeePerGas: +s
|
|
387
395
|
};
|
|
388
396
|
}
|
|
@@ -394,8 +402,8 @@ class Y {
|
|
|
394
402
|
*/
|
|
395
403
|
async getSafeGasPriceWei() {
|
|
396
404
|
const t = await this.getReadWeb3().eth.getGasPrice();
|
|
397
|
-
return new
|
|
398
|
-
|
|
405
|
+
return new D(t.toString(10)).plus(
|
|
406
|
+
Ke
|
|
399
407
|
);
|
|
400
408
|
}
|
|
401
409
|
/**
|
|
@@ -411,13 +419,13 @@ class Y {
|
|
|
411
419
|
return new a.eth.Contract(t, n);
|
|
412
420
|
}
|
|
413
421
|
}
|
|
414
|
-
class C extends
|
|
422
|
+
class C extends z {
|
|
415
423
|
constructor({ provider: n, account: a, chainId: s, rpcUrlConfig: r }) {
|
|
416
424
|
super({ chainId: s, rpcUrlConfig: r });
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
this.web3 = new
|
|
425
|
+
_(this, "web3");
|
|
426
|
+
_(this, "account");
|
|
427
|
+
_(this, "rpcConfig", O);
|
|
428
|
+
this.web3 = new ye(n), this.account = a, this.chainId = s, this.rpcConfig = { ...O, ...r };
|
|
421
429
|
}
|
|
422
430
|
/**
|
|
423
431
|
* Signs a message using the current provider and account.
|
|
@@ -445,59 +453,59 @@ class C extends Y {
|
|
|
445
453
|
const { chainId: r, web3: o } = this, p = this.getReadWeb3(), {
|
|
446
454
|
data: d,
|
|
447
455
|
estimate: g = !1,
|
|
448
|
-
estimateFee:
|
|
449
|
-
extendedGasLimit:
|
|
450
|
-
gasLimit:
|
|
456
|
+
estimateFee: b = !1,
|
|
457
|
+
extendedGasLimit: m,
|
|
458
|
+
gasLimit: y = "0",
|
|
451
459
|
value: x = "0",
|
|
452
|
-
gasLimitMultiplier:
|
|
460
|
+
gasLimitMultiplier: N = 1
|
|
453
461
|
} = s;
|
|
454
|
-
let { nonce:
|
|
455
|
-
|
|
456
|
-
const
|
|
462
|
+
let { nonce: M } = s;
|
|
463
|
+
M || (M = await p.eth.getTransactionCount(n)), console.log(`Nonce: ${M}`);
|
|
464
|
+
const c = {
|
|
457
465
|
from: n,
|
|
458
466
|
to: a,
|
|
459
|
-
value:
|
|
467
|
+
value: S.numberToHex(x),
|
|
460
468
|
data: d,
|
|
461
|
-
nonce:
|
|
462
|
-
chainId:
|
|
469
|
+
nonce: M,
|
|
470
|
+
chainId: S.numberToHex(r)
|
|
463
471
|
};
|
|
464
472
|
if (g)
|
|
465
473
|
try {
|
|
466
|
-
const w = await p.eth.estimateGas(
|
|
467
|
-
Number(w) *
|
|
474
|
+
const w = await p.eth.estimateGas(c), P = Math.round(
|
|
475
|
+
Number(w) * N
|
|
468
476
|
);
|
|
469
|
-
|
|
477
|
+
m ? c.gas = S.numberToHex(P + m) : c.gas = S.numberToHex(P);
|
|
470
478
|
} catch (w) {
|
|
471
479
|
throw new Error(
|
|
472
480
|
w.message ?? "Failed to estimate gas limit for transaction."
|
|
473
481
|
);
|
|
474
482
|
}
|
|
475
483
|
else
|
|
476
|
-
|
|
477
|
-
const { maxFeePerGas:
|
|
478
|
-
if (
|
|
484
|
+
c.gas = S.numberToHex(y);
|
|
485
|
+
const { maxFeePerGas: ne, maxPriorityFeePerGas: ae } = b ? await this.getMaxFees().catch(() => s) : s;
|
|
486
|
+
if (ae !== void 0 && (c.maxPriorityFeePerGas = S.numberToHex(ae)), ne !== void 0 && (c.maxFeePerGas = S.numberToHex(ne)), !c.maxFeePerGas && !c.maxPriorityFeePerGas) {
|
|
479
487
|
const w = await this.getSafeGasPriceWei();
|
|
480
|
-
|
|
488
|
+
c.gasPrice = w.toString(10);
|
|
481
489
|
}
|
|
482
|
-
if (!
|
|
490
|
+
if (!c.maxFeePerGas && !c.maxPriorityFeePerGas) {
|
|
483
491
|
const w = await this.getSafeGasPriceWei();
|
|
484
|
-
|
|
492
|
+
c.gasPrice = w.toString(10);
|
|
485
493
|
}
|
|
486
|
-
return console.log("Sending transaction via Web3: ",
|
|
487
|
-
const
|
|
488
|
-
|
|
489
|
-
console.log(`Just signed transaction has is: ${
|
|
490
|
-
receiptPromise:
|
|
491
|
-
transactionHash:
|
|
494
|
+
return console.log("Sending transaction via Web3: ", c), new Promise((w, P) => {
|
|
495
|
+
const se = o.eth.sendTransaction(c);
|
|
496
|
+
se.once("transactionHash", async (ie) => {
|
|
497
|
+
console.log(`Just signed transaction has is: ${ie}`), w({
|
|
498
|
+
receiptPromise: se,
|
|
499
|
+
transactionHash: ie
|
|
492
500
|
});
|
|
493
|
-
}).catch(
|
|
501
|
+
}).catch(P);
|
|
494
502
|
});
|
|
495
503
|
}
|
|
496
504
|
createContract(n, a) {
|
|
497
505
|
return new this.web3.eth.Contract(n, a);
|
|
498
506
|
}
|
|
499
507
|
}
|
|
500
|
-
function
|
|
508
|
+
function ee(e) {
|
|
501
509
|
switch (e) {
|
|
502
510
|
case i.ethereum:
|
|
503
511
|
return 1.3;
|
|
@@ -508,10 +516,10 @@ function Ve(e) {
|
|
|
508
516
|
return 1.3;
|
|
509
517
|
}
|
|
510
518
|
}
|
|
511
|
-
function
|
|
519
|
+
function me(e) {
|
|
512
520
|
return Object.values(i).includes(e);
|
|
513
521
|
}
|
|
514
|
-
const
|
|
522
|
+
const ze = {
|
|
515
523
|
[i.holesky]: "0xED7bfd5C1790576105Af4649817f6d35A75CD818",
|
|
516
524
|
[i.ethereum]: u,
|
|
517
525
|
[i.binanceSmartChainTestnet]: "0x731eFa688F3679688cf60A3993b8658138953ED6",
|
|
@@ -523,7 +531,7 @@ const $e = {
|
|
|
523
531
|
[i.berachainBartioTestnet]: "0xc47e4b3124597FDF8DD07843D4a7052F2eE80C30",
|
|
524
532
|
[i.corn]: u,
|
|
525
533
|
[i.swell]: u
|
|
526
|
-
},
|
|
534
|
+
}, Xe = {
|
|
527
535
|
[i.holesky]: "0x38A13AB20D15ffbE5A7312d2336EF1552580a4E2",
|
|
528
536
|
[i.ethereum]: u,
|
|
529
537
|
[i.binanceSmartChainTestnet]: "0x107Fc7d90484534704dD2A9e24c7BD45DB4dD1B5",
|
|
@@ -534,7 +542,7 @@ const $e = {
|
|
|
534
542
|
[i.berachainBartioTestnet]: "0xc47e4b3124597FDF8DD07843D4a7052F2eE80C30",
|
|
535
543
|
[i.corn]: u,
|
|
536
544
|
[i.swell]: u
|
|
537
|
-
},
|
|
545
|
+
}, Ye = {
|
|
538
546
|
[i.ethereum]: "0x8236a87084f8b84306f72007f36f2618a5634494",
|
|
539
547
|
[i.holesky]: u,
|
|
540
548
|
[i.sepolia]: u,
|
|
@@ -546,17 +554,17 @@ const $e = {
|
|
|
546
554
|
[i.corn]: "0xecAc9C5F704e954931349Da37F60E39f515c11c1",
|
|
547
555
|
[i.swell]: "0xecAc9C5F704e954931349Da37F60E39f515c11c1"
|
|
548
556
|
};
|
|
549
|
-
function
|
|
557
|
+
function be(e = K) {
|
|
550
558
|
switch (e) {
|
|
551
|
-
case
|
|
552
|
-
return
|
|
553
|
-
case
|
|
554
|
-
return
|
|
559
|
+
case l.prod:
|
|
560
|
+
return Ye;
|
|
561
|
+
case l.testnet:
|
|
562
|
+
return Xe;
|
|
555
563
|
default:
|
|
556
|
-
return
|
|
564
|
+
return ze;
|
|
557
565
|
}
|
|
558
566
|
}
|
|
559
|
-
const
|
|
567
|
+
const Qe = [
|
|
560
568
|
{
|
|
561
569
|
constant: !0,
|
|
562
570
|
inputs: [],
|
|
@@ -777,7 +785,7 @@ const Je = [
|
|
|
777
785
|
name: "Transfer",
|
|
778
786
|
type: "event"
|
|
779
787
|
}
|
|
780
|
-
],
|
|
788
|
+
], et = [
|
|
781
789
|
{
|
|
782
790
|
inputs: [],
|
|
783
791
|
stateMutability: "nonpayable",
|
|
@@ -2537,7 +2545,7 @@ const Je = [
|
|
|
2537
2545
|
stateMutability: "nonpayable",
|
|
2538
2546
|
type: "function"
|
|
2539
2547
|
}
|
|
2540
|
-
],
|
|
2548
|
+
], tt = [
|
|
2541
2549
|
{
|
|
2542
2550
|
inputs: [
|
|
2543
2551
|
{
|
|
@@ -3387,32 +3395,50 @@ const Je = [
|
|
|
3387
3395
|
type: "function"
|
|
3388
3396
|
}
|
|
3389
3397
|
];
|
|
3390
|
-
function
|
|
3398
|
+
function nt(e) {
|
|
3391
3399
|
switch (e) {
|
|
3392
3400
|
case "LBTC":
|
|
3393
|
-
return
|
|
3401
|
+
return et;
|
|
3394
3402
|
default:
|
|
3395
|
-
return
|
|
3403
|
+
return Qe;
|
|
3396
3404
|
}
|
|
3397
3405
|
}
|
|
3398
|
-
function
|
|
3399
|
-
const n =
|
|
3400
|
-
if (!
|
|
3406
|
+
function R(e, t) {
|
|
3407
|
+
const n = be(t), { chainId: a } = e;
|
|
3408
|
+
if (!me(a))
|
|
3401
3409
|
throw new Error(`This chain ${a} is not supported`);
|
|
3402
3410
|
const s = n[a];
|
|
3403
3411
|
if (!s)
|
|
3404
3412
|
throw new Error(`Token address for chain ${a} is not defined`);
|
|
3405
|
-
const r =
|
|
3413
|
+
const r = nt("LBTC"), o = e.createContract(r, s);
|
|
3406
3414
|
return o.options.address || (o.options.address = s), o;
|
|
3407
3415
|
}
|
|
3408
|
-
|
|
3409
|
-
|
|
3416
|
+
function sn({
|
|
3417
|
+
spender: e,
|
|
3418
|
+
amount: t,
|
|
3419
|
+
env: n,
|
|
3420
|
+
...a
|
|
3421
|
+
}) {
|
|
3422
|
+
const s = new C(a), r = R(s, n), o = le(t), p = r.methods.approve(e, o);
|
|
3423
|
+
return s.sendTransactionAsync(
|
|
3424
|
+
s.account,
|
|
3425
|
+
r.options.address,
|
|
3426
|
+
{
|
|
3427
|
+
data: p.encodeABI(),
|
|
3428
|
+
estimate: !0,
|
|
3429
|
+
estimateFee: !0,
|
|
3430
|
+
gasLimitMultiplier: ee(s.chainId)
|
|
3431
|
+
}
|
|
3432
|
+
);
|
|
3433
|
+
}
|
|
3434
|
+
const at = "insufficient funds", st = "Insufficient funds for transfer. Make sure you have enough ETH to cover the gas cost.", pe = (e) => e.startsWith("0x") ? e : "0x" + e;
|
|
3435
|
+
async function rn({
|
|
3410
3436
|
data: e,
|
|
3411
3437
|
proofSignature: t,
|
|
3412
3438
|
env: n,
|
|
3413
3439
|
...a
|
|
3414
3440
|
}) {
|
|
3415
|
-
const s = new C(a), r =
|
|
3441
|
+
const s = new C(a), r = R(s, n), o = r.methods.mint(pe(e), pe(t));
|
|
3416
3442
|
try {
|
|
3417
3443
|
return await s.sendTransactionAsync(
|
|
3418
3444
|
s.account,
|
|
@@ -3422,31 +3448,31 @@ async function Ht({
|
|
|
3422
3448
|
// TODO: add getGasOptions from the app for bsc here
|
|
3423
3449
|
estimate: !0,
|
|
3424
3450
|
estimateFee: !0,
|
|
3425
|
-
gasLimitMultiplier:
|
|
3451
|
+
gasLimitMultiplier: ee(s.chainId)
|
|
3426
3452
|
}
|
|
3427
3453
|
);
|
|
3428
3454
|
} catch (p) {
|
|
3429
3455
|
console.log("error", p);
|
|
3430
3456
|
const d = v(p);
|
|
3431
|
-
throw d.includes(
|
|
3457
|
+
throw d.includes(at) ? new Error(st) : new Error(d);
|
|
3432
3458
|
}
|
|
3433
3459
|
}
|
|
3434
|
-
const
|
|
3435
|
-
class
|
|
3460
|
+
const it = 208, rt = 4001, ot = 4100, pt = 4200, ut = 4900, dt = 4901, U = -32700, B = -32600, F = -32601, L = -32602, k = -32603, G = -32e3, W = -32001, V = -32002, $ = -32003, H = -32004, j = -32005, J = -32006;
|
|
3461
|
+
class fe extends Error {
|
|
3436
3462
|
constructor(t, n) {
|
|
3437
|
-
super(t), Array.isArray(n) ? this.cause = new
|
|
3463
|
+
super(t), Array.isArray(n) ? this.cause = new X(n) : this.cause = n, this.name = this.constructor.name, typeof Error.captureStackTrace == "function" ? Error.captureStackTrace(new.target.constructor) : this.stack = new Error().stack;
|
|
3438
3464
|
}
|
|
3439
3465
|
/**
|
|
3440
3466
|
* @deprecated Use the `cause` property instead.
|
|
3441
3467
|
*/
|
|
3442
3468
|
get innerError() {
|
|
3443
|
-
return this.cause instanceof
|
|
3469
|
+
return this.cause instanceof X ? this.cause.errors : this.cause;
|
|
3444
3470
|
}
|
|
3445
3471
|
/**
|
|
3446
3472
|
* @deprecated Use the `cause` property instead.
|
|
3447
3473
|
*/
|
|
3448
3474
|
set innerError(t) {
|
|
3449
|
-
Array.isArray(t) ? this.cause = new
|
|
3475
|
+
Array.isArray(t) ? this.cause = new X(t) : this.cause = t;
|
|
3450
3476
|
}
|
|
3451
3477
|
static convertToString(t, n = !1) {
|
|
3452
3478
|
if (t == null)
|
|
@@ -3465,19 +3491,19 @@ class ce extends Error {
|
|
|
3465
3491
|
};
|
|
3466
3492
|
}
|
|
3467
3493
|
}
|
|
3468
|
-
class
|
|
3494
|
+
class X extends fe {
|
|
3469
3495
|
constructor(t) {
|
|
3470
|
-
super(`Multiple errors occurred: [${t.map((n) => n.message).join("], [")}]`), this.code =
|
|
3496
|
+
super(`Multiple errors occurred: [${t.map((n) => n.message).join("], [")}]`), this.code = it, this.errors = t;
|
|
3471
3497
|
}
|
|
3472
3498
|
}
|
|
3473
|
-
const
|
|
3499
|
+
const yt = "An Rpc error has occured with a code of *code*", f = {
|
|
3474
3500
|
// EIP-1474 & JSON RPC 2.0
|
|
3475
3501
|
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1474.md
|
|
3476
|
-
[
|
|
3502
|
+
[U]: {
|
|
3477
3503
|
message: "Parse error",
|
|
3478
3504
|
description: "Invalid JSON"
|
|
3479
3505
|
},
|
|
3480
|
-
[
|
|
3506
|
+
[B]: {
|
|
3481
3507
|
message: "Invalid request",
|
|
3482
3508
|
description: "JSON is not a valid request object "
|
|
3483
3509
|
},
|
|
@@ -3485,61 +3511,61 @@ const st = "An Rpc error has occured with a code of *code*", m = {
|
|
|
3485
3511
|
message: "Method not found",
|
|
3486
3512
|
description: "Method does not exist "
|
|
3487
3513
|
},
|
|
3488
|
-
[
|
|
3514
|
+
[L]: {
|
|
3489
3515
|
message: "Invalid params",
|
|
3490
3516
|
description: "Invalid method parameters"
|
|
3491
3517
|
},
|
|
3492
|
-
[
|
|
3518
|
+
[k]: {
|
|
3493
3519
|
message: "Internal error",
|
|
3494
3520
|
description: "Internal JSON-RPC error"
|
|
3495
3521
|
},
|
|
3496
|
-
[
|
|
3522
|
+
[G]: {
|
|
3497
3523
|
message: "Invalid input",
|
|
3498
3524
|
description: "Missing or invalid parameters"
|
|
3499
3525
|
},
|
|
3500
|
-
[
|
|
3526
|
+
[W]: {
|
|
3501
3527
|
message: "Resource not found",
|
|
3502
3528
|
description: "Requested resource not found"
|
|
3503
3529
|
},
|
|
3504
|
-
[
|
|
3530
|
+
[V]: {
|
|
3505
3531
|
message: "Resource unavailable",
|
|
3506
3532
|
description: "Requested resource not available"
|
|
3507
3533
|
},
|
|
3508
|
-
[
|
|
3534
|
+
[$]: {
|
|
3509
3535
|
message: "Transaction rejected",
|
|
3510
3536
|
description: "Transaction creation failed"
|
|
3511
3537
|
},
|
|
3512
|
-
[
|
|
3538
|
+
[H]: {
|
|
3513
3539
|
message: "Method not supported",
|
|
3514
3540
|
description: "Method is not implemented"
|
|
3515
3541
|
},
|
|
3516
|
-
[
|
|
3542
|
+
[j]: {
|
|
3517
3543
|
message: "Limit exceeded",
|
|
3518
3544
|
description: "Request exceeds defined limit"
|
|
3519
3545
|
},
|
|
3520
|
-
[
|
|
3546
|
+
[J]: {
|
|
3521
3547
|
message: "JSON-RPC version not supported",
|
|
3522
3548
|
description: "Version of JSON-RPC protocol is not supported"
|
|
3523
3549
|
},
|
|
3524
3550
|
// EIP-1193
|
|
3525
3551
|
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1193.md#provider-errors
|
|
3526
|
-
[
|
|
3552
|
+
[rt]: {
|
|
3527
3553
|
name: "User Rejected Request",
|
|
3528
3554
|
message: "The user rejected the request."
|
|
3529
3555
|
},
|
|
3530
|
-
[
|
|
3556
|
+
[ot]: {
|
|
3531
3557
|
name: "Unauthorized",
|
|
3532
3558
|
message: "The requested method and/or account has not been authorized by the user."
|
|
3533
3559
|
},
|
|
3534
|
-
[
|
|
3560
|
+
[pt]: {
|
|
3535
3561
|
name: "Unsupported Method",
|
|
3536
3562
|
message: "The Provider does not support the requested method."
|
|
3537
3563
|
},
|
|
3538
|
-
[
|
|
3564
|
+
[ut]: {
|
|
3539
3565
|
name: "Disconnected",
|
|
3540
3566
|
message: "The Provider is disconnected from all chains."
|
|
3541
3567
|
},
|
|
3542
|
-
[
|
|
3568
|
+
[dt]: {
|
|
3543
3569
|
name: "Chain Disconnected",
|
|
3544
3570
|
message: "The Provider is not connected to the requested chain."
|
|
3545
3571
|
},
|
|
@@ -3626,141 +3652,141 @@ const st = "An Rpc error has occured with a code of *code*", m = {
|
|
|
3626
3652
|
message: "For private use, and thus can't be registered. Such codes can be used by prior agreements between WebSocket applications. The interpretation of these codes is undefined by the WebSocket protocol."
|
|
3627
3653
|
}
|
|
3628
3654
|
};
|
|
3629
|
-
class
|
|
3655
|
+
class T extends fe {
|
|
3630
3656
|
constructor(t, n) {
|
|
3631
|
-
super(n ??
|
|
3657
|
+
super(n ?? yt.replace("*code*", t.error.code.toString())), this.code = t.error.code, this.id = t.id, this.jsonrpc = t.jsonrpc, this.jsonRpcError = t.error;
|
|
3632
3658
|
}
|
|
3633
3659
|
toJSON() {
|
|
3634
3660
|
return Object.assign(Object.assign({}, super.toJSON()), { error: this.jsonRpcError, id: this.id, jsonRpc: this.jsonrpc });
|
|
3635
3661
|
}
|
|
3636
3662
|
}
|
|
3637
|
-
class
|
|
3663
|
+
class ct extends T {
|
|
3638
3664
|
constructor(t) {
|
|
3639
|
-
super(t,
|
|
3665
|
+
super(t, f[U].message), this.code = U;
|
|
3640
3666
|
}
|
|
3641
3667
|
}
|
|
3642
|
-
class
|
|
3668
|
+
class lt extends T {
|
|
3643
3669
|
constructor(t) {
|
|
3644
|
-
super(t,
|
|
3670
|
+
super(t, f[B].message), this.code = B;
|
|
3645
3671
|
}
|
|
3646
3672
|
}
|
|
3647
|
-
class
|
|
3673
|
+
class mt extends T {
|
|
3648
3674
|
constructor(t) {
|
|
3649
|
-
super(t,
|
|
3675
|
+
super(t, f[F].message), this.code = F;
|
|
3650
3676
|
}
|
|
3651
3677
|
}
|
|
3652
|
-
class
|
|
3678
|
+
class bt extends T {
|
|
3653
3679
|
constructor(t) {
|
|
3654
|
-
super(t,
|
|
3680
|
+
super(t, f[L].message), this.code = L;
|
|
3655
3681
|
}
|
|
3656
3682
|
}
|
|
3657
|
-
class
|
|
3683
|
+
class ft extends T {
|
|
3658
3684
|
constructor(t) {
|
|
3659
|
-
super(t,
|
|
3685
|
+
super(t, f[k].message), this.code = k;
|
|
3660
3686
|
}
|
|
3661
3687
|
}
|
|
3662
|
-
class
|
|
3688
|
+
class Tt extends T {
|
|
3663
3689
|
constructor(t) {
|
|
3664
|
-
super(t,
|
|
3690
|
+
super(t, f[G].message), this.code = G;
|
|
3665
3691
|
}
|
|
3666
3692
|
}
|
|
3667
|
-
class
|
|
3693
|
+
class ht extends T {
|
|
3668
3694
|
constructor(t) {
|
|
3669
|
-
super(t,
|
|
3695
|
+
super(t, f[H].message), this.code = H;
|
|
3670
3696
|
}
|
|
3671
3697
|
}
|
|
3672
|
-
class
|
|
3698
|
+
class gt extends T {
|
|
3673
3699
|
constructor(t) {
|
|
3674
|
-
super(t,
|
|
3700
|
+
super(t, f[V].message), this.code = V;
|
|
3675
3701
|
}
|
|
3676
3702
|
}
|
|
3677
|
-
class
|
|
3703
|
+
class wt extends T {
|
|
3678
3704
|
constructor(t) {
|
|
3679
|
-
super(t,
|
|
3705
|
+
super(t, f[W].message), this.code = W;
|
|
3680
3706
|
}
|
|
3681
3707
|
}
|
|
3682
|
-
class
|
|
3708
|
+
class Et extends T {
|
|
3683
3709
|
constructor(t) {
|
|
3684
|
-
super(t,
|
|
3710
|
+
super(t, f[J].message), this.code = J;
|
|
3685
3711
|
}
|
|
3686
3712
|
}
|
|
3687
|
-
class
|
|
3713
|
+
class At extends T {
|
|
3688
3714
|
constructor(t) {
|
|
3689
|
-
super(t,
|
|
3715
|
+
super(t, f[$].message), this.code = $;
|
|
3690
3716
|
}
|
|
3691
3717
|
}
|
|
3692
|
-
class
|
|
3718
|
+
class vt extends T {
|
|
3693
3719
|
constructor(t) {
|
|
3694
|
-
super(t,
|
|
3720
|
+
super(t, f[j].message), this.code = j;
|
|
3695
3721
|
}
|
|
3696
3722
|
}
|
|
3697
|
-
const
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
error:
|
|
3723
|
+
const h = /* @__PURE__ */ new Map();
|
|
3724
|
+
h.set(U, { error: ct });
|
|
3725
|
+
h.set(B, {
|
|
3726
|
+
error: lt
|
|
3701
3727
|
});
|
|
3702
|
-
|
|
3703
|
-
error:
|
|
3728
|
+
h.set(F, {
|
|
3729
|
+
error: mt
|
|
3704
3730
|
});
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
error:
|
|
3731
|
+
h.set(L, { error: bt });
|
|
3732
|
+
h.set(k, { error: ft });
|
|
3733
|
+
h.set(G, { error: Tt });
|
|
3734
|
+
h.set(H, {
|
|
3735
|
+
error: ht
|
|
3710
3736
|
});
|
|
3711
|
-
|
|
3712
|
-
error:
|
|
3737
|
+
h.set(V, {
|
|
3738
|
+
error: gt
|
|
3713
3739
|
});
|
|
3714
|
-
|
|
3715
|
-
error:
|
|
3740
|
+
h.set($, {
|
|
3741
|
+
error: At
|
|
3716
3742
|
});
|
|
3717
|
-
|
|
3718
|
-
error:
|
|
3743
|
+
h.set(W, {
|
|
3744
|
+
error: wt
|
|
3719
3745
|
});
|
|
3720
|
-
|
|
3721
|
-
error:
|
|
3746
|
+
h.set(J, {
|
|
3747
|
+
error: Et
|
|
3722
3748
|
});
|
|
3723
|
-
|
|
3724
|
-
const
|
|
3725
|
-
var
|
|
3749
|
+
h.set(j, { error: vt });
|
|
3750
|
+
const Rt = (e) => typeof e == "string" && /^((-)?0x[0-9a-f]+|(0x))$/i.test(e);
|
|
3751
|
+
var q;
|
|
3726
3752
|
(function(e) {
|
|
3727
3753
|
e.NUMBER = "NUMBER_NUMBER", e.HEX = "NUMBER_HEX", e.STR = "NUMBER_STR", e.BIGINT = "NUMBER_BIGINT";
|
|
3728
|
-
})(
|
|
3729
|
-
var
|
|
3754
|
+
})(q || (q = {}));
|
|
3755
|
+
var Z;
|
|
3730
3756
|
(function(e) {
|
|
3731
3757
|
e.HEX = "BYTES_HEX", e.UINT8ARRAY = "BYTES_UINT8ARRAY";
|
|
3732
|
-
})(
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
var
|
|
3758
|
+
})(Z || (Z = {}));
|
|
3759
|
+
q.BIGINT, Z.HEX;
|
|
3760
|
+
q.HEX, Z.HEX;
|
|
3761
|
+
var ue;
|
|
3736
3762
|
(function(e) {
|
|
3737
3763
|
e.EARLIEST = "earliest", e.LATEST = "latest", e.PENDING = "pending", e.SAFE = "safe", e.FINALIZED = "finalized";
|
|
3738
|
-
})(
|
|
3739
|
-
var
|
|
3764
|
+
})(ue || (ue = {}));
|
|
3765
|
+
var de;
|
|
3740
3766
|
(function(e) {
|
|
3741
3767
|
e.chainstart = "chainstart", e.frontier = "frontier", e.homestead = "homestead", e.dao = "dao", e.tangerineWhistle = "tangerineWhistle", e.spuriousDragon = "spuriousDragon", e.byzantium = "byzantium", e.constantinople = "constantinople", e.petersburg = "petersburg", e.istanbul = "istanbul", e.muirGlacier = "muirGlacier", e.berlin = "berlin", e.london = "london", e.altair = "altair", e.arrowGlacier = "arrowGlacier", e.grayGlacier = "grayGlacier", e.bellatrix = "bellatrix", e.merge = "merge", e.capella = "capella", e.shanghai = "shanghai";
|
|
3742
|
-
})(
|
|
3743
|
-
function
|
|
3768
|
+
})(de || (de = {}));
|
|
3769
|
+
function St(e, t) {
|
|
3744
3770
|
if (!t)
|
|
3745
3771
|
throw new Error("The address for bascule module is not defined");
|
|
3746
|
-
const n = e.createContract(
|
|
3772
|
+
const n = e.createContract(tt, t);
|
|
3747
3773
|
return n.options.address || (n.options.address = t), n;
|
|
3748
3774
|
}
|
|
3749
|
-
const
|
|
3750
|
-
var
|
|
3751
|
-
async function
|
|
3775
|
+
const Ct = "No deposit ID provided. Please provide a deposit ID as an argument.", _t = "Invalid deposit ID. Expected a 0x-prefixed 32-byte hex string.";
|
|
3776
|
+
var It = /* @__PURE__ */ ((e) => (e[e.UNREPORTED = 0] = "UNREPORTED", e[e.REPORTED = 1] = "REPORTED", e[e.WITHDRAWN = 2] = "WITHDRAWN", e))(It || {});
|
|
3777
|
+
async function on({
|
|
3752
3778
|
txId: e,
|
|
3753
3779
|
env: t,
|
|
3754
3780
|
...n
|
|
3755
3781
|
}) {
|
|
3756
3782
|
if (!e)
|
|
3757
|
-
throw new Error(
|
|
3758
|
-
if (!
|
|
3759
|
-
throw new Error(
|
|
3760
|
-
const a = new C(n), r = await
|
|
3783
|
+
throw new Error(Ct);
|
|
3784
|
+
if (!Rt(e))
|
|
3785
|
+
throw new Error(_t);
|
|
3786
|
+
const a = new C(n), r = await R(a, t).methods.Bascule().call();
|
|
3761
3787
|
if (r === u)
|
|
3762
3788
|
return 1;
|
|
3763
|
-
const o =
|
|
3789
|
+
const o = St(a, r);
|
|
3764
3790
|
try {
|
|
3765
3791
|
const p = await o.methods.depositHistory(Buffer.from(e.replace(/^0x/, ""), "hex")).call();
|
|
3766
3792
|
return Number(p);
|
|
@@ -3769,32 +3795,85 @@ async function jt({
|
|
|
3769
3795
|
throw new Error(d);
|
|
3770
3796
|
}
|
|
3771
3797
|
}
|
|
3772
|
-
const
|
|
3798
|
+
const Dt = [
|
|
3773
3799
|
i.ethereum,
|
|
3774
3800
|
i.base,
|
|
3775
3801
|
i.binanceSmartChain
|
|
3776
|
-
],
|
|
3777
|
-
function
|
|
3778
|
-
if (!
|
|
3802
|
+
], Te = (e) => Dt.includes(e) ? l.prod : l.stage;
|
|
3803
|
+
function he(e, t) {
|
|
3804
|
+
if (!me(e))
|
|
3779
3805
|
throw new Error(`This chain ${e} is not supported`);
|
|
3780
|
-
const n = t ? { [e]: t } :
|
|
3806
|
+
const n = t ? { [e]: t } : O;
|
|
3781
3807
|
if (!n[e])
|
|
3782
3808
|
throw new Error(`RPC URL for chainId ${e} not found`);
|
|
3783
3809
|
return n;
|
|
3784
3810
|
}
|
|
3785
|
-
async function
|
|
3811
|
+
async function pn({
|
|
3786
3812
|
chainId: e,
|
|
3787
3813
|
rpcUrl: t
|
|
3788
3814
|
}) {
|
|
3789
|
-
const n =
|
|
3790
|
-
return new
|
|
3815
|
+
const n = he(e, t), a = new z({ chainId: e, rpcUrlConfig: n }), s = Te(e), o = await R(a, s).methods.getMintFee().call();
|
|
3816
|
+
return new D(ce(o.toString(10)));
|
|
3817
|
+
}
|
|
3818
|
+
async function un({
|
|
3819
|
+
env: e,
|
|
3820
|
+
rpcUrl: t,
|
|
3821
|
+
chainId: n
|
|
3822
|
+
}) {
|
|
3823
|
+
const a = { [n]: t }, s = new z({ chainId: n, rpcUrlConfig: a });
|
|
3824
|
+
return (await R(s, e).methods.totalSupply().call()).toString();
|
|
3825
|
+
}
|
|
3826
|
+
async function xt({
|
|
3827
|
+
owner: e,
|
|
3828
|
+
rpcUrl: t,
|
|
3829
|
+
chainId: n
|
|
3830
|
+
}) {
|
|
3831
|
+
const a = he(n, t), s = new z({ chainId: n, rpcUrlConfig: a }), r = Te(n), o = R(s, r);
|
|
3832
|
+
try {
|
|
3833
|
+
return (await o.methods.nonces(e).call()).toString();
|
|
3834
|
+
} catch (p) {
|
|
3835
|
+
const d = v(p);
|
|
3836
|
+
throw new Error(d);
|
|
3837
|
+
}
|
|
3838
|
+
}
|
|
3839
|
+
const te = {
|
|
3840
|
+
[i.sepolia]: {
|
|
3841
|
+
[i.berachainBartioTestnet]: "0xe3748bF0Ec0A76767539eE28610B3367e35fe2C2"
|
|
3842
|
+
},
|
|
3843
|
+
[i.berachainBartioTestnet]: {
|
|
3844
|
+
[i.sepolia]: "0x1977013acaf27856ac8048C42EE2ed0134d53895"
|
|
3845
|
+
}
|
|
3846
|
+
}, Nt = {
|
|
3847
|
+
...te
|
|
3848
|
+
}, Mt = {
|
|
3849
|
+
...te,
|
|
3850
|
+
[i.corn]: {
|
|
3851
|
+
[i.ethereum]: "0xfc7B20D9B59A8A466f4fC3d34aA69a7D98e71d7A"
|
|
3852
|
+
},
|
|
3853
|
+
[i.ethereum]: {
|
|
3854
|
+
[i.corn]: "0x6bc15d7930839ec18a57f6f7df72ae1b439d077f",
|
|
3855
|
+
[i.swell]: "0x37E92d760a15231e652a2C502182a6b44c7510c0"
|
|
3856
|
+
},
|
|
3857
|
+
[i.swell]: {
|
|
3858
|
+
[i.ethereum]: "0x7B3784AD646C10A8Ddf42b47a4f4bd9aFD351E54"
|
|
3859
|
+
}
|
|
3860
|
+
};
|
|
3861
|
+
function dn(e = K) {
|
|
3862
|
+
switch (e) {
|
|
3863
|
+
case l.prod:
|
|
3864
|
+
return Mt;
|
|
3865
|
+
case l.testnet:
|
|
3866
|
+
return Nt;
|
|
3867
|
+
default:
|
|
3868
|
+
return te;
|
|
3869
|
+
}
|
|
3791
3870
|
}
|
|
3792
|
-
async function
|
|
3871
|
+
async function yn(e) {
|
|
3793
3872
|
const t = new C(e), n = `destination chain id is ${e.chainId}`;
|
|
3794
3873
|
return t.signMessage(n);
|
|
3795
3874
|
}
|
|
3796
|
-
const
|
|
3797
|
-
function
|
|
3875
|
+
const Pt = 24 * 60 * 60;
|
|
3876
|
+
function Ot({
|
|
3798
3877
|
chainId: e,
|
|
3799
3878
|
verifyingContract: t,
|
|
3800
3879
|
fee: n,
|
|
@@ -3828,56 +3907,61 @@ function Rt({
|
|
|
3828
3907
|
}
|
|
3829
3908
|
};
|
|
3830
3909
|
}
|
|
3831
|
-
const
|
|
3832
|
-
async function
|
|
3910
|
+
const Ut = "Failed to obtain a valid signature. The response is undefined or invalid.", Bt = () => Math.floor(Date.now() / 1e3 + Pt);
|
|
3911
|
+
async function cn({
|
|
3833
3912
|
address: e,
|
|
3834
3913
|
provider: t,
|
|
3835
3914
|
fee: n,
|
|
3836
3915
|
chainId: a,
|
|
3837
3916
|
env: s,
|
|
3838
|
-
expiry: r =
|
|
3917
|
+
expiry: r = Bt()
|
|
3839
3918
|
}) {
|
|
3840
|
-
var
|
|
3919
|
+
var m, y;
|
|
3841
3920
|
const o = new C({
|
|
3842
3921
|
provider: t,
|
|
3843
3922
|
account: e,
|
|
3844
3923
|
chainId: a
|
|
3845
|
-
}), d =
|
|
3846
|
-
|
|
3924
|
+
}), d = R(o, s).options.address, g = JSON.stringify(
|
|
3925
|
+
Ot({
|
|
3847
3926
|
chainId: a,
|
|
3848
3927
|
verifyingContract: d,
|
|
3849
3928
|
fee: n,
|
|
3850
3929
|
expiry: r
|
|
3851
3930
|
})
|
|
3852
|
-
),
|
|
3931
|
+
), b = await ((y = (m = o.web3) == null ? void 0 : m.currentProvider) == null ? void 0 : y.request({
|
|
3853
3932
|
method: "eth_signTypedData_v4",
|
|
3854
3933
|
params: [e, g]
|
|
3855
3934
|
}));
|
|
3856
|
-
if (typeof
|
|
3857
|
-
return { signature:
|
|
3858
|
-
if (!(
|
|
3859
|
-
throw new Error(
|
|
3860
|
-
return { signature:
|
|
3935
|
+
if (typeof b == "string")
|
|
3936
|
+
return { signature: b, typedData: g };
|
|
3937
|
+
if (!(b != null && b.result))
|
|
3938
|
+
throw new Error(Ut);
|
|
3939
|
+
return { signature: b.result, typedData: g };
|
|
3861
3940
|
}
|
|
3862
|
-
const
|
|
3863
|
-
[i.holesky]:
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3941
|
+
const ge = {
|
|
3942
|
+
[i.holesky]: [
|
|
3943
|
+
{
|
|
3944
|
+
key: "veda",
|
|
3945
|
+
name: "Veda / Lombard DeFi Vault",
|
|
3946
|
+
address: "0x52BD640617eeD47A00dA0da93351092D49208d1d"
|
|
3947
|
+
}
|
|
3948
|
+
]
|
|
3949
|
+
}, ln = Object.keys(
|
|
3950
|
+
ge
|
|
3951
|
+
).map(Number), Ft = (e) => {
|
|
3952
|
+
const t = ge[e];
|
|
3953
|
+
if (!(t != null && t.length))
|
|
3954
|
+
throw new Error(`No vaults configured for chain ID ${e}`);
|
|
3955
|
+
return t;
|
|
3956
|
+
}, Lt = (e, t) => {
|
|
3957
|
+
const a = Ft(e).find((s) => s.key === t);
|
|
3958
|
+
if (!a)
|
|
3959
|
+
throw new Error(
|
|
3960
|
+
`No vault found with key ${t} for chain ID ${e}`
|
|
3961
|
+
);
|
|
3962
|
+
return a.address;
|
|
3963
|
+
};
|
|
3964
|
+
async function kt({
|
|
3881
3965
|
chainId: e,
|
|
3882
3966
|
expiry: t,
|
|
3883
3967
|
owner: n,
|
|
@@ -3886,7 +3970,7 @@ async function Ct({
|
|
|
3886
3970
|
rpcUrl: r,
|
|
3887
3971
|
verifyingContract: o
|
|
3888
3972
|
}) {
|
|
3889
|
-
const p = await
|
|
3973
|
+
const p = await xt({
|
|
3890
3974
|
owner: n,
|
|
3891
3975
|
chainId: e,
|
|
3892
3976
|
rpcUrl: r
|
|
@@ -3935,87 +4019,128 @@ async function Ct({
|
|
|
3935
4019
|
}
|
|
3936
4020
|
};
|
|
3937
4021
|
}
|
|
3938
|
-
const
|
|
3939
|
-
const n =
|
|
4022
|
+
const Gt = (e) => {
|
|
4023
|
+
const n = be("stage")[e];
|
|
3940
4024
|
if (!n)
|
|
3941
4025
|
throw new Error(`No LBTC contract address configured for chain ID ${e}`);
|
|
3942
4026
|
return n;
|
|
3943
|
-
},
|
|
3944
|
-
async function
|
|
4027
|
+
}, Wt = "Failed to obtain a valid signature. The response is undefined or invalid.";
|
|
4028
|
+
async function mn({
|
|
3945
4029
|
address: e,
|
|
3946
4030
|
provider: t,
|
|
3947
4031
|
chainId: n,
|
|
3948
4032
|
value: a,
|
|
3949
4033
|
expiry: s,
|
|
3950
4034
|
rpcUrl: r,
|
|
3951
|
-
|
|
4035
|
+
vaultKey: o
|
|
3952
4036
|
}) {
|
|
3953
|
-
var
|
|
4037
|
+
var x, N;
|
|
3954
4038
|
const p = new C({
|
|
3955
4039
|
provider: t,
|
|
3956
4040
|
account: e,
|
|
3957
4041
|
chainId: n
|
|
3958
|
-
}), d =
|
|
4042
|
+
}), d = Gt(n), g = Lt(n, o), b = await kt({
|
|
3959
4043
|
chainId: n,
|
|
3960
4044
|
expiry: s,
|
|
3961
4045
|
owner: e,
|
|
3962
|
-
spender:
|
|
4046
|
+
spender: g,
|
|
3963
4047
|
value: a,
|
|
3964
4048
|
rpcUrl: r,
|
|
3965
4049
|
verifyingContract: d
|
|
3966
|
-
}),
|
|
4050
|
+
}), m = JSON.stringify(b), y = await ((N = (x = p.web3) == null ? void 0 : x.currentProvider) == null ? void 0 : N.request({
|
|
3967
4051
|
method: "eth_signTypedData_v4",
|
|
3968
|
-
params: [e,
|
|
4052
|
+
params: [e, m]
|
|
3969
4053
|
}));
|
|
3970
4054
|
if (typeof y == "string")
|
|
3971
|
-
return { signature: y, typedData:
|
|
4055
|
+
return { signature: y, typedData: m };
|
|
3972
4056
|
if (!(y != null && y.result))
|
|
3973
|
-
throw new Error(
|
|
3974
|
-
return { signature: y.result, typedData:
|
|
4057
|
+
throw new Error(Wt);
|
|
4058
|
+
return { signature: y.result, typedData: m };
|
|
4059
|
+
}
|
|
4060
|
+
ve(Ae);
|
|
4061
|
+
function Vt(e, t = l.prod) {
|
|
4062
|
+
var r;
|
|
4063
|
+
const n = $t(e), s = (r = Re[n]({
|
|
4064
|
+
address: e,
|
|
4065
|
+
network: t === l.prod ? oe.bitcoin : oe.testnet
|
|
4066
|
+
}).output) == null ? void 0 : r.toString("hex");
|
|
4067
|
+
if (!s)
|
|
4068
|
+
throw new Error("Output script is not found.");
|
|
4069
|
+
return `0x${s}`;
|
|
4070
|
+
}
|
|
4071
|
+
function $t(e) {
|
|
4072
|
+
const t = Se.fromBech32(e);
|
|
4073
|
+
if (t.version === 1 && t.data.length === 32)
|
|
4074
|
+
return "p2tr";
|
|
4075
|
+
if (t.version === 0 && t.data.length === 20)
|
|
4076
|
+
return "p2wpkh";
|
|
4077
|
+
if (Ht(e))
|
|
4078
|
+
return "p2wsh";
|
|
4079
|
+
throw new Error("Address type is not supported.");
|
|
4080
|
+
}
|
|
4081
|
+
function Ht(e) {
|
|
4082
|
+
return (e.startsWith("bc1") || e.startsWith("tb1")) && e.length === 62;
|
|
4083
|
+
}
|
|
4084
|
+
function bn({
|
|
4085
|
+
btcAddress: e,
|
|
4086
|
+
amount: t,
|
|
4087
|
+
env: n,
|
|
4088
|
+
...a
|
|
4089
|
+
}) {
|
|
4090
|
+
const s = new C(a), r = R(s, n), o = Vt(e, n), p = le(t), d = r.methods.redeem(o, p);
|
|
4091
|
+
return s.sendTransactionAsync(
|
|
4092
|
+
s.account,
|
|
4093
|
+
r.options.address,
|
|
4094
|
+
{
|
|
4095
|
+
data: d.encodeABI(),
|
|
4096
|
+
estimate: !0,
|
|
4097
|
+
estimateFee: !0,
|
|
4098
|
+
gasLimitMultiplier: ee(s.chainId)
|
|
4099
|
+
}
|
|
4100
|
+
);
|
|
3975
4101
|
}
|
|
3976
|
-
const Yt = (e) => {
|
|
3977
|
-
const t = Q[e];
|
|
3978
|
-
if (!t)
|
|
3979
|
-
throw new Error(`No spender address configured for chain ID ${e}`);
|
|
3980
|
-
return t;
|
|
3981
|
-
};
|
|
3982
4102
|
export {
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
4103
|
+
It as BasculeDepositStatus,
|
|
4104
|
+
$e as ENotarizationStatus,
|
|
4105
|
+
He as ESessionState,
|
|
3986
4106
|
i as OChainId,
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
|
|
4107
|
+
l as OEnv,
|
|
4108
|
+
Oe as SANCTIONED_ADDRESS,
|
|
4109
|
+
Q as SATOSHI_SCALE,
|
|
4110
|
+
ge as STAKE_AND_BAKE_VAULTS,
|
|
4111
|
+
ln as SUPPORTED_STAKE_AND_BAKE_CHAINS,
|
|
4112
|
+
sn as approveLBTC,
|
|
4113
|
+
rn as claimLBTC,
|
|
4114
|
+
ce as fromSatoshi,
|
|
4115
|
+
zt as generateDepositBtcAddress,
|
|
3995
4116
|
A as getApiConfig,
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
4117
|
+
on as getBasculeDepositStatus,
|
|
4118
|
+
Ie as getBaseNetworkByEnv,
|
|
4119
|
+
_e as getBscNetworkByEnv,
|
|
4120
|
+
Ve as getChainIdByName,
|
|
4121
|
+
Y as getChainNameById,
|
|
4122
|
+
Xt as getDepositBtcAddress,
|
|
4123
|
+
Ge as getDepositBtcAddresses,
|
|
4124
|
+
Yt as getDepositsByAddress,
|
|
4125
|
+
Ce as getEthNetworkByEnv,
|
|
4126
|
+
Qt as getLBTCExchangeRate,
|
|
4127
|
+
pn as getLBTCMintingFee,
|
|
4128
|
+
un as getLBTCTotalSupply,
|
|
4129
|
+
be as getLbtcAddressConfig,
|
|
4130
|
+
dn as getLbtcOFTAdapterAddressConfig,
|
|
4131
|
+
en as getNetworkFeeSignature,
|
|
4132
|
+
xt as getPermitNonce,
|
|
4133
|
+
Lt as getStakeAndBakeSpenderContract,
|
|
4134
|
+
kt as getStakeAndBakeTypedData,
|
|
4135
|
+
Ft as getStakeAndBakeVaults,
|
|
4136
|
+
tn as getUserStakeAndBakeSignature,
|
|
4137
|
+
me as isValidChain,
|
|
4138
|
+
yn as signLbtcDestionationAddr,
|
|
4139
|
+
cn as signNetworkFee,
|
|
4140
|
+
mn as signStakeAndBake,
|
|
4141
|
+
nn as storeNetworkFeeSignature,
|
|
4142
|
+
an as storeStakeAndBakeSignature,
|
|
4143
|
+
le as toSatoshi,
|
|
4144
|
+
bn as unstakeLBTC
|
|
4020
4145
|
};
|
|
4021
4146
|
//# sourceMappingURL=index.js.map
|