@lombard.finance/sdk 2.1.0 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
var Y = Object.defineProperty;
|
|
2
2
|
var Q = (e, t, n) => t in e ? Y(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
-
var
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import $, { Web3 as G, utils as
|
|
3
|
+
var _ = (e, t, n) => (Q(e, typeof t != "symbol" ? t + "" : t, n), n);
|
|
4
|
+
import w from "axios";
|
|
5
|
+
import x from "bignumber.js";
|
|
6
|
+
import $, { Web3 as G, utils as E } from "web3";
|
|
7
7
|
import * as ee from "@bitcoin-js/tiny-secp256k1-asmjs";
|
|
8
8
|
import { initEccLib as te, payments as ne, networks as V, address as ae } from "bitcoinjs-lib";
|
|
9
|
-
const
|
|
9
|
+
const l = {
|
|
10
10
|
prod: "prod",
|
|
11
11
|
testnet: "testnet",
|
|
12
12
|
stage: "stage"
|
|
@@ -21,23 +21,23 @@ const c = {
|
|
|
21
21
|
berachainBartioTestnet: 80084,
|
|
22
22
|
corn: 21e6,
|
|
23
23
|
swell: 1923
|
|
24
|
-
}, se = (e) => e ===
|
|
24
|
+
}, se = (e) => e === l.prod ? i.ethereum : i.holesky, ie = (e) => e === l.prod ? i.binanceSmartChain : i.binanceSmartChainTestnet, re = (e) => e === l.prod ? i.base : i.baseSepoliaTestnet, P = l.prod, y = "0x0000000000000000000000000000000000000000", oe = {
|
|
25
25
|
baseApiUrl: "https://staging.prod.lombard.finance"
|
|
26
26
|
}, pe = {
|
|
27
27
|
baseApiUrl: "https://gastald-testnet.prod.lombard.finance"
|
|
28
28
|
}, ue = {
|
|
29
29
|
baseApiUrl: "https://mainnet.prod.lombard.finance"
|
|
30
|
-
},
|
|
30
|
+
}, A = (e = P) => {
|
|
31
31
|
switch (e) {
|
|
32
|
-
case
|
|
32
|
+
case l.prod:
|
|
33
33
|
return ue;
|
|
34
|
-
case
|
|
34
|
+
case l.testnet:
|
|
35
35
|
return pe;
|
|
36
36
|
default:
|
|
37
37
|
return oe;
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
|
-
function
|
|
40
|
+
function v(e) {
|
|
41
41
|
return typeof e == "string" ? e : ((n) => {
|
|
42
42
|
var a;
|
|
43
43
|
return ((a = n == null ? void 0 : n.data) == null ? void 0 : a.message) && typeof n.data.message == "string";
|
|
@@ -49,7 +49,7 @@ function ye(e) {
|
|
|
49
49
|
function de(e) {
|
|
50
50
|
return e != null && e.message ? e.message : "Unknown error";
|
|
51
51
|
}
|
|
52
|
-
const
|
|
52
|
+
const g = {
|
|
53
53
|
eth: "DESTINATION_BLOCKCHAIN_ETHEREUM",
|
|
54
54
|
ethOld: "BLOCKCHAIN_ETHEREUM",
|
|
55
55
|
base: "DESTINATION_BLOCKCHAIN_BASE",
|
|
@@ -62,13 +62,13 @@ function O(e) {
|
|
|
62
62
|
case i.ethereum:
|
|
63
63
|
case i.holesky:
|
|
64
64
|
case i.sepolia:
|
|
65
|
-
return
|
|
65
|
+
return g.eth;
|
|
66
66
|
case i.base:
|
|
67
67
|
case i.baseSepoliaTestnet:
|
|
68
|
-
return
|
|
68
|
+
return g.base;
|
|
69
69
|
case i.binanceSmartChain:
|
|
70
70
|
case i.binanceSmartChainTestnet:
|
|
71
|
-
return
|
|
71
|
+
return g.bsc;
|
|
72
72
|
default:
|
|
73
73
|
throw new Error(`Unknown chain ID: ${e}`);
|
|
74
74
|
}
|
|
@@ -85,7 +85,7 @@ async function it({
|
|
|
85
85
|
captchaToken: p,
|
|
86
86
|
signatureData: u
|
|
87
87
|
}) {
|
|
88
|
-
const { baseApiUrl: f } =
|
|
88
|
+
const { baseApiUrl: f } = A(s), m = O(t), T = {
|
|
89
89
|
to_address: e,
|
|
90
90
|
to_address_signature: n,
|
|
91
91
|
to_chain: m,
|
|
@@ -97,17 +97,17 @@ async function it({
|
|
|
97
97
|
sb_signature_data: u
|
|
98
98
|
};
|
|
99
99
|
try {
|
|
100
|
-
const { data:
|
|
100
|
+
const { data: c } = await w.post(
|
|
101
101
|
me,
|
|
102
|
-
|
|
102
|
+
T,
|
|
103
103
|
{ baseURL: f }
|
|
104
104
|
);
|
|
105
|
-
return
|
|
106
|
-
} catch (
|
|
107
|
-
const
|
|
108
|
-
if (be(
|
|
105
|
+
return c.address;
|
|
106
|
+
} catch (c) {
|
|
107
|
+
const b = v(c);
|
|
108
|
+
if (be(b))
|
|
109
109
|
return le;
|
|
110
|
-
throw new Error(
|
|
110
|
+
throw new Error(b);
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
function be(e) {
|
|
@@ -142,14 +142,14 @@ async function he({
|
|
|
142
142
|
env: n,
|
|
143
143
|
partnerId: a
|
|
144
144
|
}) {
|
|
145
|
-
const { baseApiUrl: s } =
|
|
145
|
+
const { baseApiUrl: s } = A(n), r = O(t), o = {
|
|
146
146
|
to_address: e,
|
|
147
147
|
to_blockchain: r,
|
|
148
148
|
limit: 1,
|
|
149
149
|
offset: 0,
|
|
150
150
|
asc: !1,
|
|
151
151
|
referralId: a
|
|
152
|
-
}, { data: p } = await
|
|
152
|
+
}, { data: p } = await w.get(fe, {
|
|
153
153
|
baseURL: s,
|
|
154
154
|
params: o
|
|
155
155
|
});
|
|
@@ -164,14 +164,14 @@ function K(e) {
|
|
|
164
164
|
}
|
|
165
165
|
function we(e, t = P) {
|
|
166
166
|
switch (e) {
|
|
167
|
-
case
|
|
168
|
-
case
|
|
167
|
+
case g.eth:
|
|
168
|
+
case g.ethOld:
|
|
169
169
|
return se(t);
|
|
170
|
-
case
|
|
171
|
-
case
|
|
170
|
+
case g.base:
|
|
171
|
+
case g.baseOld:
|
|
172
172
|
return re(t);
|
|
173
|
-
case
|
|
174
|
-
case
|
|
173
|
+
case g.bsc:
|
|
174
|
+
case g.bscOld:
|
|
175
175
|
return ie(t);
|
|
176
176
|
default:
|
|
177
177
|
return i.ethereum;
|
|
@@ -182,7 +182,7 @@ async function ot({
|
|
|
182
182
|
address: e,
|
|
183
183
|
env: t
|
|
184
184
|
}) {
|
|
185
|
-
const { baseApiUrl: n } =
|
|
185
|
+
const { baseApiUrl: n } = A(t), { data: a } = await w.get(
|
|
186
186
|
`api/v1/address/outputs-v2/${e}`,
|
|
187
187
|
{ baseURL: n }
|
|
188
188
|
);
|
|
@@ -194,7 +194,7 @@ function Ce(e) {
|
|
|
194
194
|
index: t.index ?? 0,
|
|
195
195
|
blockHeight: t.block_height ? Number(t.block_height) : void 0,
|
|
196
196
|
blockTime: t.block_time ? Number(t.block_time) : void 0,
|
|
197
|
-
value: new
|
|
197
|
+
value: new x(Z(t.value)),
|
|
198
198
|
address: t.address,
|
|
199
199
|
chainId: we(t.to_chain, e),
|
|
200
200
|
claimedTxId: t.claim_tx,
|
|
@@ -216,10 +216,10 @@ async function pt({
|
|
|
216
216
|
chainId: t = i.ethereum,
|
|
217
217
|
amount: n = 1
|
|
218
218
|
}) {
|
|
219
|
-
const { baseApiUrl: a } =
|
|
219
|
+
const { baseApiUrl: a } = A(e), s = O(t), { data: r } = await w.get(
|
|
220
220
|
`api/v1/exchange/rate/${s}`,
|
|
221
221
|
{ baseURL: a, params: { amount: n } }
|
|
222
|
-
), o = new
|
|
222
|
+
), o = new x(Se).multipliedBy(F).toFixed();
|
|
223
223
|
return { exchangeRate: +r.amount_out, minAmount: +o };
|
|
224
224
|
}
|
|
225
225
|
async function ut({
|
|
@@ -227,9 +227,9 @@ async function ut({
|
|
|
227
227
|
chainId: t,
|
|
228
228
|
env: n
|
|
229
229
|
}) {
|
|
230
|
-
const { baseApiUrl: a } =
|
|
230
|
+
const { baseApiUrl: a } = A(n);
|
|
231
231
|
try {
|
|
232
|
-
const { data: s } = await
|
|
232
|
+
const { data: s } = await w.get(
|
|
233
233
|
`${a}/api/v1/claimer/get-user-signature`,
|
|
234
234
|
{
|
|
235
235
|
params: {
|
|
@@ -244,7 +244,7 @@ async function ut({
|
|
|
244
244
|
isDelayed: s == null ? void 0 : s.is_delayed
|
|
245
245
|
};
|
|
246
246
|
} catch (s) {
|
|
247
|
-
const r =
|
|
247
|
+
const r = v(s);
|
|
248
248
|
throw new Error(r);
|
|
249
249
|
}
|
|
250
250
|
}
|
|
@@ -253,9 +253,9 @@ async function yt({
|
|
|
253
253
|
chainId: t,
|
|
254
254
|
env: n
|
|
255
255
|
}) {
|
|
256
|
-
const { baseApiUrl: a } =
|
|
256
|
+
const { baseApiUrl: a } = A(n);
|
|
257
257
|
try {
|
|
258
|
-
const { data: s } = await
|
|
258
|
+
const { data: s } = await w.get(
|
|
259
259
|
`${a}/api/v1/claimer/get-user-stake-and-bake-signature`,
|
|
260
260
|
{
|
|
261
261
|
params: {
|
|
@@ -272,7 +272,7 @@ async function yt({
|
|
|
272
272
|
chainId: s.chain_id
|
|
273
273
|
};
|
|
274
274
|
} catch (s) {
|
|
275
|
-
const r =
|
|
275
|
+
const r = v(s);
|
|
276
276
|
throw new Error(
|
|
277
277
|
`Failed to get user stake and bake signature: ${r}`
|
|
278
278
|
);
|
|
@@ -284,9 +284,9 @@ async function dt({
|
|
|
284
284
|
address: n,
|
|
285
285
|
env: a
|
|
286
286
|
}) {
|
|
287
|
-
const { baseApiUrl: s } =
|
|
287
|
+
const { baseApiUrl: s } = A(a);
|
|
288
288
|
try {
|
|
289
|
-
const { data: r } = await
|
|
289
|
+
const { data: r } = await w.post(
|
|
290
290
|
`${s}/api/v1/claimer/save-user-signature`,
|
|
291
291
|
null,
|
|
292
292
|
{
|
|
@@ -299,7 +299,7 @@ async function dt({
|
|
|
299
299
|
);
|
|
300
300
|
return r.status;
|
|
301
301
|
} catch (r) {
|
|
302
|
-
const o =
|
|
302
|
+
const o = v(r);
|
|
303
303
|
throw new Error(o);
|
|
304
304
|
}
|
|
305
305
|
}
|
|
@@ -308,9 +308,9 @@ async function lt({
|
|
|
308
308
|
typedData: t,
|
|
309
309
|
env: n
|
|
310
310
|
}) {
|
|
311
|
-
const { baseApiUrl: a } =
|
|
311
|
+
const { baseApiUrl: a } = A(n);
|
|
312
312
|
try {
|
|
313
|
-
const { data: s } = await
|
|
313
|
+
const { data: s } = await w.post(
|
|
314
314
|
`${a}/api/v1/claimer/save-stake-and-bake-signature`,
|
|
315
315
|
null,
|
|
316
316
|
{
|
|
@@ -322,7 +322,7 @@ async function lt({
|
|
|
322
322
|
);
|
|
323
323
|
return s.status;
|
|
324
324
|
} catch (s) {
|
|
325
|
-
const r =
|
|
325
|
+
const r = v(s);
|
|
326
326
|
throw new Error(r);
|
|
327
327
|
}
|
|
328
328
|
}
|
|
@@ -348,13 +348,13 @@ async function Ee(e) {
|
|
|
348
348
|
params: []
|
|
349
349
|
})
|
|
350
350
|
})).json(), a = $.utils.hexToNumber(n == null ? void 0 : n.result);
|
|
351
|
-
return new
|
|
351
|
+
return new x(Number(a));
|
|
352
352
|
}
|
|
353
353
|
const De = 2, _e = 25e3;
|
|
354
354
|
class N {
|
|
355
355
|
constructor({ chainId: t, rpcUrlConfig: n }) {
|
|
356
|
-
|
|
357
|
-
|
|
356
|
+
_(this, "chainId");
|
|
357
|
+
_(this, "rpcConfig");
|
|
358
358
|
this.chainId = t, this.rpcConfig = { ...R, ...n };
|
|
359
359
|
}
|
|
360
360
|
/**
|
|
@@ -395,7 +395,7 @@ class N {
|
|
|
395
395
|
Ee(n)
|
|
396
396
|
]);
|
|
397
397
|
return !(a != null && a.baseFeePerGas) && typeof (a == null ? void 0 : a.baseFeePerGas) != "bigint" ? {} : {
|
|
398
|
-
maxFeePerGas: +new
|
|
398
|
+
maxFeePerGas: +new x(a.baseFeePerGas.toString(10)).multipliedBy(De).plus(s),
|
|
399
399
|
maxPriorityFeePerGas: +s
|
|
400
400
|
};
|
|
401
401
|
}
|
|
@@ -407,7 +407,7 @@ class N {
|
|
|
407
407
|
*/
|
|
408
408
|
async getSafeGasPriceWei() {
|
|
409
409
|
const t = await this.getReadWeb3().eth.getGasPrice();
|
|
410
|
-
return new
|
|
410
|
+
return new x(t.toString(10)).plus(
|
|
411
411
|
_e
|
|
412
412
|
);
|
|
413
413
|
}
|
|
@@ -424,12 +424,12 @@ class N {
|
|
|
424
424
|
return new a.eth.Contract(t, n);
|
|
425
425
|
}
|
|
426
426
|
}
|
|
427
|
-
class
|
|
427
|
+
class D extends N {
|
|
428
428
|
constructor({ provider: n, account: a, chainId: s, rpcUrlConfig: r }) {
|
|
429
429
|
super({ chainId: s, rpcUrlConfig: r });
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
430
|
+
_(this, "web3");
|
|
431
|
+
_(this, "account");
|
|
432
|
+
_(this, "rpcConfig", R);
|
|
433
433
|
this.web3 = new $(n), this.account = a, this.chainId = s, this.rpcConfig = { ...R, ...r };
|
|
434
434
|
}
|
|
435
435
|
/**
|
|
@@ -459,47 +459,47 @@ class E extends N {
|
|
|
459
459
|
data: u,
|
|
460
460
|
estimate: f = !1,
|
|
461
461
|
estimateFee: m = !1,
|
|
462
|
-
extendedGasLimit:
|
|
463
|
-
gasLimit:
|
|
464
|
-
value:
|
|
465
|
-
gasLimitMultiplier:
|
|
462
|
+
extendedGasLimit: T,
|
|
463
|
+
gasLimit: c = "0",
|
|
464
|
+
value: b = "0",
|
|
465
|
+
gasLimitMultiplier: I = 1
|
|
466
466
|
} = s;
|
|
467
|
-
let { nonce:
|
|
468
|
-
|
|
469
|
-
const
|
|
467
|
+
let { nonce: S } = s;
|
|
468
|
+
S || (S = await p.eth.getTransactionCount(n)), console.log(`Nonce: ${S}`);
|
|
469
|
+
const d = {
|
|
470
470
|
from: n,
|
|
471
471
|
to: a,
|
|
472
|
-
value:
|
|
472
|
+
value: E.numberToHex(b),
|
|
473
473
|
data: u,
|
|
474
|
-
nonce:
|
|
475
|
-
chainId:
|
|
474
|
+
nonce: S,
|
|
475
|
+
chainId: E.numberToHex(r)
|
|
476
476
|
};
|
|
477
477
|
if (f)
|
|
478
478
|
try {
|
|
479
|
-
const
|
|
480
|
-
Number(
|
|
479
|
+
const h = await p.eth.estimateGas(d), M = Math.round(
|
|
480
|
+
Number(h) * I
|
|
481
481
|
);
|
|
482
|
-
|
|
483
|
-
} catch (
|
|
482
|
+
T ? d.gas = E.numberToHex(M + T) : d.gas = E.numberToHex(M);
|
|
483
|
+
} catch (h) {
|
|
484
484
|
throw new Error(
|
|
485
|
-
|
|
485
|
+
h.message ?? "Failed to estimate gas limit for transaction."
|
|
486
486
|
);
|
|
487
487
|
}
|
|
488
488
|
else
|
|
489
|
-
|
|
489
|
+
d.gas = E.numberToHex(c);
|
|
490
490
|
const { maxFeePerGas: U, maxPriorityFeePerGas: B } = m ? await this.getMaxFees().catch(() => s) : s;
|
|
491
|
-
if (B !== void 0 && (
|
|
492
|
-
const
|
|
493
|
-
|
|
491
|
+
if (B !== void 0 && (d.maxPriorityFeePerGas = E.numberToHex(B)), U !== void 0 && (d.maxFeePerGas = E.numberToHex(U)), !d.maxFeePerGas && !d.maxPriorityFeePerGas) {
|
|
492
|
+
const h = await this.getSafeGasPriceWei();
|
|
493
|
+
d.gasPrice = h.toString(10);
|
|
494
494
|
}
|
|
495
|
-
if (!
|
|
496
|
-
const
|
|
497
|
-
|
|
495
|
+
if (!d.maxFeePerGas && !d.maxPriorityFeePerGas) {
|
|
496
|
+
const h = await this.getSafeGasPriceWei();
|
|
497
|
+
d.gasPrice = h.toString(10);
|
|
498
498
|
}
|
|
499
|
-
return console.log("Sending transaction via Web3: ",
|
|
500
|
-
const L = o.eth.sendTransaction(
|
|
499
|
+
return console.log("Sending transaction via Web3: ", d), new Promise((h, M) => {
|
|
500
|
+
const L = o.eth.sendTransaction(d);
|
|
501
501
|
L.once("transactionHash", async (W) => {
|
|
502
|
-
console.log(`Just signed transaction has is: ${W}`),
|
|
502
|
+
console.log(`Just signed transaction has is: ${W}`), h({
|
|
503
503
|
receiptPromise: L,
|
|
504
504
|
transactionHash: W
|
|
505
505
|
});
|
|
@@ -560,9 +560,9 @@ const xe = {
|
|
|
560
560
|
};
|
|
561
561
|
function q(e = P) {
|
|
562
562
|
switch (e) {
|
|
563
|
-
case
|
|
563
|
+
case l.prod:
|
|
564
564
|
return Me;
|
|
565
|
-
case
|
|
565
|
+
case l.testnet:
|
|
566
566
|
return Ie;
|
|
567
567
|
default:
|
|
568
568
|
return xe;
|
|
@@ -3407,7 +3407,7 @@ function Oe(e) {
|
|
|
3407
3407
|
return Re;
|
|
3408
3408
|
}
|
|
3409
3409
|
}
|
|
3410
|
-
function
|
|
3410
|
+
function C(e, t) {
|
|
3411
3411
|
const n = q(t), { chainId: a } = e;
|
|
3412
3412
|
if (!z(a))
|
|
3413
3413
|
throw new Error(`This chain ${a} is not supported`);
|
|
@@ -3423,7 +3423,7 @@ function mt({
|
|
|
3423
3423
|
env: n,
|
|
3424
3424
|
...a
|
|
3425
3425
|
}) {
|
|
3426
|
-
const s = new
|
|
3426
|
+
const s = new D(a), r = C(s, n), o = K(t), p = r.methods.approve(e, o);
|
|
3427
3427
|
return s.sendTransactionAsync(
|
|
3428
3428
|
s.account,
|
|
3429
3429
|
r.options.address,
|
|
@@ -3442,7 +3442,7 @@ async function ct({
|
|
|
3442
3442
|
env: n,
|
|
3443
3443
|
...a
|
|
3444
3444
|
}) {
|
|
3445
|
-
const s = new
|
|
3445
|
+
const s = new D(a), r = C(s, n), o = r.methods.mint(H(e), H(t));
|
|
3446
3446
|
try {
|
|
3447
3447
|
return await s.sendTransactionAsync(
|
|
3448
3448
|
s.account,
|
|
@@ -3456,7 +3456,7 @@ async function ct({
|
|
|
3456
3456
|
);
|
|
3457
3457
|
} catch (p) {
|
|
3458
3458
|
console.log("error", p);
|
|
3459
|
-
const u =
|
|
3459
|
+
const u = v(p);
|
|
3460
3460
|
throw u.includes(Fe) ? new Error(ke) : new Error(u);
|
|
3461
3461
|
}
|
|
3462
3462
|
}
|
|
@@ -3475,7 +3475,7 @@ async function bt({
|
|
|
3475
3475
|
}) {
|
|
3476
3476
|
if (!e)
|
|
3477
3477
|
throw new Error(Be);
|
|
3478
|
-
const a = new
|
|
3478
|
+
const a = new D(n), r = await C(a, t).methods.Bascule().call();
|
|
3479
3479
|
if (r === y)
|
|
3480
3480
|
return 1;
|
|
3481
3481
|
const o = Ue(a, r);
|
|
@@ -3485,7 +3485,7 @@ async function bt({
|
|
|
3485
3485
|
), u = await o.methods.depositHistory(p).call();
|
|
3486
3486
|
return Number(u);
|
|
3487
3487
|
} catch (p) {
|
|
3488
|
-
const u =
|
|
3488
|
+
const u = v(p);
|
|
3489
3489
|
throw new Error(u);
|
|
3490
3490
|
}
|
|
3491
3491
|
}
|
|
@@ -3493,7 +3493,7 @@ const We = [
|
|
|
3493
3493
|
i.ethereum,
|
|
3494
3494
|
i.base,
|
|
3495
3495
|
i.binanceSmartChain
|
|
3496
|
-
], j = (e) => We.includes(e) ?
|
|
3496
|
+
], j = (e) => We.includes(e) ? l.prod : l.stage;
|
|
3497
3497
|
function J(e, t) {
|
|
3498
3498
|
if (!z(e))
|
|
3499
3499
|
throw new Error(`This chain ${e} is not supported`);
|
|
@@ -3506,8 +3506,8 @@ async function ft({
|
|
|
3506
3506
|
chainId: e,
|
|
3507
3507
|
rpcUrl: t
|
|
3508
3508
|
}) {
|
|
3509
|
-
const n = J(e, t), a = new N({ chainId: e, rpcUrlConfig: n }), s = j(e), o = await
|
|
3510
|
-
return new
|
|
3509
|
+
const n = J(e, t), a = new N({ chainId: e, rpcUrlConfig: n }), s = j(e), o = await C(a, s).methods.getMintFee().call();
|
|
3510
|
+
return new x(Z(o.toString(10)));
|
|
3511
3511
|
}
|
|
3512
3512
|
async function Tt({
|
|
3513
3513
|
env: e,
|
|
@@ -3515,23 +3515,23 @@ async function Tt({
|
|
|
3515
3515
|
chainId: n
|
|
3516
3516
|
}) {
|
|
3517
3517
|
const a = { [n]: t }, s = new N({ chainId: n, rpcUrlConfig: a });
|
|
3518
|
-
return (await
|
|
3518
|
+
return (await C(s, e).methods.totalSupply().call()).toString();
|
|
3519
3519
|
}
|
|
3520
3520
|
async function Ge({
|
|
3521
3521
|
owner: e,
|
|
3522
3522
|
rpcUrl: t,
|
|
3523
3523
|
chainId: n
|
|
3524
3524
|
}) {
|
|
3525
|
-
const a = J(n, t), s = new N({ chainId: n, rpcUrlConfig: a }), r = j(n), o =
|
|
3525
|
+
const a = J(n, t), s = new N({ chainId: n, rpcUrlConfig: a }), r = j(n), o = C(s, r);
|
|
3526
3526
|
try {
|
|
3527
3527
|
return (await o.methods.nonces(e).call()).toString();
|
|
3528
3528
|
} catch (p) {
|
|
3529
|
-
const u =
|
|
3529
|
+
const u = v(p);
|
|
3530
3530
|
throw new Error(u);
|
|
3531
3531
|
}
|
|
3532
3532
|
}
|
|
3533
3533
|
async function ht(e) {
|
|
3534
|
-
const t = new
|
|
3534
|
+
const t = new D(e), n = `destination chain id is ${e.chainId}`;
|
|
3535
3535
|
return t.signMessage(n);
|
|
3536
3536
|
}
|
|
3537
3537
|
const Ve = 24 * 60 * 60;
|
|
@@ -3578,19 +3578,19 @@ async function gt({
|
|
|
3578
3578
|
env: s,
|
|
3579
3579
|
expiry: r = Ze()
|
|
3580
3580
|
}) {
|
|
3581
|
-
var
|
|
3582
|
-
const o = new
|
|
3581
|
+
var T, c;
|
|
3582
|
+
const o = new D({
|
|
3583
3583
|
provider: t,
|
|
3584
3584
|
account: e,
|
|
3585
3585
|
chainId: a
|
|
3586
|
-
}), u =
|
|
3586
|
+
}), u = C(o, s).options.address, f = JSON.stringify(
|
|
3587
3587
|
He({
|
|
3588
3588
|
chainId: a,
|
|
3589
3589
|
verifyingContract: u,
|
|
3590
3590
|
fee: n,
|
|
3591
3591
|
expiry: r
|
|
3592
3592
|
})
|
|
3593
|
-
), m = await ((
|
|
3593
|
+
), m = await ((c = (T = o.web3) == null ? void 0 : T.currentProvider) == null ? void 0 : c.request({
|
|
3594
3594
|
method: "eth_signTypedData_v4",
|
|
3595
3595
|
params: [e, f]
|
|
3596
3596
|
}));
|
|
@@ -3709,11 +3709,13 @@ async function qe({
|
|
|
3709
3709
|
}
|
|
3710
3710
|
};
|
|
3711
3711
|
}
|
|
3712
|
-
const je = (e) => {
|
|
3713
|
-
const
|
|
3714
|
-
if (!
|
|
3715
|
-
throw new Error(
|
|
3716
|
-
|
|
3712
|
+
const je = (e, t = l.prod) => {
|
|
3713
|
+
const a = q(t)[e];
|
|
3714
|
+
if (!a)
|
|
3715
|
+
throw new Error(
|
|
3716
|
+
`No LBTC contract address configured for chain ID ${e}`
|
|
3717
|
+
);
|
|
3718
|
+
return a;
|
|
3717
3719
|
}, Je = "Failed to obtain a valid signature. The response is undefined or invalid.";
|
|
3718
3720
|
async function At({
|
|
3719
3721
|
address: e,
|
|
@@ -3722,37 +3724,38 @@ async function At({
|
|
|
3722
3724
|
value: a,
|
|
3723
3725
|
expiry: s,
|
|
3724
3726
|
rpcUrl: r,
|
|
3725
|
-
vaultKey: o
|
|
3727
|
+
vaultKey: o,
|
|
3728
|
+
env: p
|
|
3726
3729
|
}) {
|
|
3727
|
-
var
|
|
3728
|
-
const
|
|
3730
|
+
var I, S;
|
|
3731
|
+
const u = new D({
|
|
3729
3732
|
provider: t,
|
|
3730
3733
|
account: e,
|
|
3731
3734
|
chainId: n
|
|
3732
|
-
}),
|
|
3735
|
+
}), f = je(n, p), m = ze(n, o), T = await qe({
|
|
3733
3736
|
chainId: n,
|
|
3734
3737
|
expiry: s,
|
|
3735
3738
|
owner: e,
|
|
3736
|
-
spender:
|
|
3739
|
+
spender: m,
|
|
3737
3740
|
value: a,
|
|
3738
3741
|
rpcUrl: r,
|
|
3739
|
-
verifyingContract:
|
|
3740
|
-
}),
|
|
3742
|
+
verifyingContract: f
|
|
3743
|
+
}), c = JSON.stringify(T), b = await ((S = (I = u.web3) == null ? void 0 : I.currentProvider) == null ? void 0 : S.request({
|
|
3741
3744
|
method: "eth_signTypedData_v4",
|
|
3742
|
-
params: [e,
|
|
3745
|
+
params: [e, c]
|
|
3743
3746
|
}));
|
|
3744
|
-
if (typeof
|
|
3745
|
-
return { signature:
|
|
3746
|
-
if (!(
|
|
3747
|
+
if (typeof b == "string")
|
|
3748
|
+
return { signature: b, typedData: c };
|
|
3749
|
+
if (!(b != null && b.result))
|
|
3747
3750
|
throw new Error(Je);
|
|
3748
|
-
return { signature:
|
|
3751
|
+
return { signature: b.result, typedData: c };
|
|
3749
3752
|
}
|
|
3750
3753
|
te(ee);
|
|
3751
|
-
function Xe(e, t =
|
|
3754
|
+
function Xe(e, t = l.prod) {
|
|
3752
3755
|
var r;
|
|
3753
3756
|
const n = Ye(e), s = (r = ne[n]({
|
|
3754
3757
|
address: e,
|
|
3755
|
-
network: t ===
|
|
3758
|
+
network: t === l.prod ? V.bitcoin : V.testnet
|
|
3756
3759
|
}).output) == null ? void 0 : r.toString("hex");
|
|
3757
3760
|
if (!s)
|
|
3758
3761
|
throw new Error("Output script is not found.");
|
|
@@ -3777,7 +3780,7 @@ function vt({
|
|
|
3777
3780
|
env: n,
|
|
3778
3781
|
...a
|
|
3779
3782
|
}) {
|
|
3780
|
-
const s = new
|
|
3783
|
+
const s = new D(a), r = C(s, n), o = Xe(e, n), p = K(t), u = r.methods.redeem(o, p);
|
|
3781
3784
|
return s.sendTransactionAsync(
|
|
3782
3785
|
s.account,
|
|
3783
3786
|
r.options.address,
|
|
@@ -3794,7 +3797,7 @@ export {
|
|
|
3794
3797
|
Ae as ENotarizationStatus,
|
|
3795
3798
|
ve as ESessionState,
|
|
3796
3799
|
i as OChainId,
|
|
3797
|
-
|
|
3800
|
+
l as OEnv,
|
|
3798
3801
|
le as SANCTIONED_ADDRESS,
|
|
3799
3802
|
F as SATOSHI_SCALE,
|
|
3800
3803
|
X as STAKE_AND_BAKE_VAULTS,
|
|
@@ -3803,7 +3806,7 @@ export {
|
|
|
3803
3806
|
ct as claimLBTC,
|
|
3804
3807
|
Z as fromSatoshi,
|
|
3805
3808
|
it as generateDepositBtcAddress,
|
|
3806
|
-
|
|
3809
|
+
A as getApiConfig,
|
|
3807
3810
|
bt as getBasculeDepositStatus,
|
|
3808
3811
|
re as getBaseNetworkByEnv,
|
|
3809
3812
|
ie as getBscNetworkByEnv,
|