@lombard.finance/sdk 2.0.2 → 2.0.4
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/README.md +45 -44
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +285 -274
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/common/types/types.ts +11 -0
- package/src/sdk/apiConfig.ts +0 -4
- package/src/sdk/getDepositBtcAddress/getDepositBtcAddress.ts +1 -1
- package/src/sdk/getDepositsByAddress/getDepositsByAddress.ts +2 -2
- package/src/sdk/getNetworkFeeSignature/getNetworkFeeSignature.ts +2 -2
- package/src/sdk/index.ts +2 -1
- package/src/sdk/internalTypes.ts +5 -0
- package/src/sdk/storeNetworkFeeSignature/storeNetworkFeeSignature.ts +3 -3
- package/src/sdk/utils/getChainIdByName.ts +32 -0
- package/src/sdk/utils/getChainNameById.ts +1 -1
- package/src/sdk/utils/getCainIdByName.ts +0 -21
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
var he = Object.defineProperty;
|
|
2
2
|
var ge = (e, t, n) => t in e ? he(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
3
|
var A = (e, t, n) => (ge(e, typeof t != "symbol" ? t + "" : t, n), n);
|
|
4
|
-
import
|
|
5
|
-
import
|
|
4
|
+
import C from "axios";
|
|
5
|
+
import R from "bignumber.js";
|
|
6
6
|
import ye, { Web3 as re, utils as w } from "web3";
|
|
7
7
|
import * as we from "@bitcoin-js/tiny-secp256k1-asmjs";
|
|
8
8
|
import { initEccLib as Ee, payments as Ae, networks as oe, address as ve } from "bitcoinjs-lib";
|
|
9
|
-
const
|
|
9
|
+
const d = {
|
|
10
10
|
prod: "prod",
|
|
11
11
|
testnet: "testnet",
|
|
12
12
|
stage: "stage"
|
|
@@ -20,60 +20,62 @@ const c = {
|
|
|
20
20
|
baseTestnet: 84532,
|
|
21
21
|
berachainBartioTestnet: 80084,
|
|
22
22
|
corn: 21e6
|
|
23
|
-
},
|
|
24
|
-
baseApiUrl: "https://staging.prod.lombard.finance"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
},
|
|
30
|
-
baseApiUrl: "https://mainnet.prod.lombard.finance",
|
|
31
|
-
claimerApiUrl: ""
|
|
32
|
-
}, C = (e = _) => {
|
|
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 = {
|
|
24
|
+
baseApiUrl: "https://staging.prod.lombard.finance"
|
|
25
|
+
}, _e = {
|
|
26
|
+
baseApiUrl: "https://gastald-testnet.prod.lombard.finance"
|
|
27
|
+
}, xe = {
|
|
28
|
+
baseApiUrl: "https://mainnet.prod.lombard.finance"
|
|
29
|
+
}, S = (e = x) => {
|
|
33
30
|
switch (e) {
|
|
34
|
-
case
|
|
35
|
-
return
|
|
36
|
-
case
|
|
37
|
-
return
|
|
31
|
+
case d.prod:
|
|
32
|
+
return xe;
|
|
33
|
+
case d.testnet:
|
|
34
|
+
return _e;
|
|
38
35
|
default:
|
|
39
|
-
return
|
|
36
|
+
return Ie;
|
|
40
37
|
}
|
|
41
38
|
};
|
|
42
|
-
function
|
|
39
|
+
function I(e) {
|
|
43
40
|
return typeof e == "string" ? e : ((n) => {
|
|
44
41
|
var s;
|
|
45
42
|
return ((s = n == null ? void 0 : n.data) == null ? void 0 : s.message) && typeof n.data.message == "string";
|
|
46
|
-
})(e) ? e.data.message : e instanceof Error ?
|
|
43
|
+
})(e) ? e.data.message : e instanceof Error ? De(e) : Me(e);
|
|
47
44
|
}
|
|
48
|
-
function
|
|
45
|
+
function De(e) {
|
|
49
46
|
return e.response ? e.response.data.message : e.message;
|
|
50
47
|
}
|
|
51
|
-
function
|
|
48
|
+
function Me(e) {
|
|
52
49
|
return e != null && e.message ? e.message : "Unknown error";
|
|
53
50
|
}
|
|
54
|
-
const
|
|
51
|
+
const v = {
|
|
55
52
|
eth: "DESTINATION_BLOCKCHAIN_ETHEREUM",
|
|
56
53
|
base: "DESTINATION_BLOCKCHAIN_BASE",
|
|
57
|
-
bsc: "DESTINATION_BLOCKCHAIN_BSC"
|
|
54
|
+
bsc: "DESTINATION_BLOCKCHAIN_BSC",
|
|
55
|
+
mantle: "DESTINATION_BLOCKCHAIN_MANTLE",
|
|
56
|
+
linea: "DESTINATION_BLOCKCHAIN_LINEA",
|
|
57
|
+
zcircuit: "DESTINATION_BLOCKCHAIN_ZIRCUIT",
|
|
58
|
+
scroll: "DESTINATION_BLOCKCHAIN_SCROLL",
|
|
59
|
+
xlayer: "DESTINATION_BLOCKCHAIN_XLAYER"
|
|
58
60
|
};
|
|
59
|
-
function
|
|
61
|
+
function X(e) {
|
|
60
62
|
switch (e) {
|
|
63
|
+
case a.ethereum:
|
|
61
64
|
case a.holesky:
|
|
62
65
|
case a.sepolia:
|
|
63
|
-
|
|
64
|
-
return Z.eth;
|
|
66
|
+
return v.eth;
|
|
65
67
|
case a.base:
|
|
66
68
|
case a.baseTestnet:
|
|
67
|
-
return
|
|
69
|
+
return v.base;
|
|
68
70
|
case a.binanceSmartChain:
|
|
69
71
|
case a.binanceSmartChainTestnet:
|
|
70
|
-
return
|
|
72
|
+
return v.bsc;
|
|
71
73
|
default:
|
|
72
74
|
throw new Error(`Unknown chain ID: ${e}`);
|
|
73
75
|
}
|
|
74
76
|
}
|
|
75
|
-
const
|
|
76
|
-
async function
|
|
77
|
+
const Ne = "sanctioned_address", Pe = "api/v1/address/generate", Oe = "destination address is under sanctions";
|
|
78
|
+
async function Jt({
|
|
77
79
|
address: e,
|
|
78
80
|
chainId: t,
|
|
79
81
|
signature: n,
|
|
@@ -82,109 +84,113 @@ async function Vt({
|
|
|
82
84
|
partnerId: r,
|
|
83
85
|
captchaToken: p = ""
|
|
84
86
|
}) {
|
|
85
|
-
const { baseApiUrl: u } =
|
|
87
|
+
const { baseApiUrl: u } = S(s), y = X(t), h = {
|
|
86
88
|
to_address: e,
|
|
87
89
|
to_address_signature: n,
|
|
88
|
-
to_chain:
|
|
90
|
+
to_chain: y,
|
|
89
91
|
referrer_code: i,
|
|
90
92
|
partner_id: r,
|
|
91
93
|
nonce: 0,
|
|
92
94
|
captcha: p
|
|
93
95
|
};
|
|
94
96
|
try {
|
|
95
|
-
const { data: l } = await
|
|
96
|
-
|
|
97
|
+
const { data: l } = await C.post(
|
|
98
|
+
Pe,
|
|
97
99
|
h,
|
|
98
100
|
{ baseURL: u }
|
|
99
101
|
);
|
|
100
102
|
return l.address;
|
|
101
103
|
} catch (l) {
|
|
102
|
-
const g =
|
|
103
|
-
if (
|
|
104
|
-
return
|
|
104
|
+
const g = I(l);
|
|
105
|
+
if (Ue(g))
|
|
106
|
+
return Ne;
|
|
105
107
|
throw new Error(g);
|
|
106
108
|
}
|
|
107
109
|
}
|
|
108
|
-
function
|
|
109
|
-
return !!e.includes(
|
|
110
|
+
function Ue(e) {
|
|
111
|
+
return !!e.includes(Oe);
|
|
110
112
|
}
|
|
111
|
-
const
|
|
112
|
-
async function
|
|
113
|
+
const Fe = "api/v1/address";
|
|
114
|
+
async function Zt({
|
|
113
115
|
address: e,
|
|
114
116
|
chainId: t,
|
|
115
117
|
env: n,
|
|
116
118
|
partnerId: s
|
|
117
119
|
}) {
|
|
118
|
-
const i = await
|
|
120
|
+
const i = await Le({
|
|
119
121
|
address: e,
|
|
120
122
|
chainId: t,
|
|
121
123
|
env: n,
|
|
122
124
|
partnerId: s
|
|
123
|
-
}), r =
|
|
125
|
+
}), r = Be(i);
|
|
124
126
|
if (!r)
|
|
125
127
|
throw new Error("No address");
|
|
126
128
|
return r.btc_address;
|
|
127
129
|
}
|
|
128
|
-
function
|
|
130
|
+
function Be(e) {
|
|
129
131
|
if (!e.length)
|
|
130
132
|
return;
|
|
131
133
|
const t = e.reduce((n, s) => n.created_at < s.created_at ? s : n, e[0]);
|
|
132
134
|
return t.deprecated ? void 0 : t;
|
|
133
135
|
}
|
|
134
|
-
async function
|
|
136
|
+
async function Le({
|
|
135
137
|
address: e,
|
|
136
138
|
chainId: t,
|
|
137
139
|
env: n,
|
|
138
140
|
partnerId: s
|
|
139
141
|
}) {
|
|
140
|
-
const { baseApiUrl: i } =
|
|
142
|
+
const { baseApiUrl: i } = S(n), r = X(t), p = {
|
|
141
143
|
to_address: e,
|
|
142
144
|
to_blockchain: r,
|
|
143
145
|
limit: 1,
|
|
144
146
|
offset: 0,
|
|
145
147
|
asc: !1,
|
|
146
|
-
|
|
147
|
-
}, { data: u } = await
|
|
148
|
+
referralId: s
|
|
149
|
+
}, { data: u } = await C.get(Fe, {
|
|
148
150
|
baseURL: i,
|
|
149
151
|
params: p
|
|
150
152
|
});
|
|
151
153
|
return (u == null ? void 0 : u.addresses) || [];
|
|
152
154
|
}
|
|
153
|
-
const
|
|
154
|
-
function
|
|
155
|
+
const ke = 8, Y = 10 ** ke;
|
|
156
|
+
function K(e) {
|
|
155
157
|
return +e / Y;
|
|
156
158
|
}
|
|
157
159
|
function ce(e) {
|
|
158
160
|
return Math.floor(+e * Y);
|
|
159
161
|
}
|
|
160
|
-
function
|
|
162
|
+
function Ge(e, t = x) {
|
|
161
163
|
switch (e) {
|
|
162
|
-
case
|
|
163
|
-
return t
|
|
164
|
+
case v.eth:
|
|
165
|
+
return Re(t);
|
|
166
|
+
case v.base:
|
|
167
|
+
return Se(t);
|
|
168
|
+
case v.bsc:
|
|
169
|
+
return Ce(t);
|
|
164
170
|
default:
|
|
165
171
|
return a.ethereum;
|
|
166
172
|
}
|
|
167
173
|
}
|
|
168
|
-
var
|
|
169
|
-
async function
|
|
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({
|
|
170
176
|
address: e,
|
|
171
177
|
env: t
|
|
172
178
|
}) {
|
|
173
|
-
const { baseApiUrl: n } =
|
|
179
|
+
const { baseApiUrl: n } = S(t), { data: s } = await C.get(
|
|
174
180
|
`api/v1/address/outputs-v2/${e}`,
|
|
175
181
|
{ baseURL: n }
|
|
176
182
|
);
|
|
177
|
-
return ((s == null ? void 0 : s.outputs) ?? []).map(
|
|
183
|
+
return ((s == null ? void 0 : s.outputs) ?? []).map($e(t));
|
|
178
184
|
}
|
|
179
|
-
function
|
|
185
|
+
function $e(e) {
|
|
180
186
|
return (t) => ({
|
|
181
187
|
txid: t.txid,
|
|
182
188
|
index: t.index ?? 0,
|
|
183
189
|
blockHeight: t.block_height ? Number(t.block_height) : void 0,
|
|
184
190
|
blockTime: t.block_time ? Number(t.block_time) : void 0,
|
|
185
|
-
value: new
|
|
191
|
+
value: new R(K(t.value)),
|
|
186
192
|
address: t.address,
|
|
187
|
-
chainId:
|
|
193
|
+
chainId: Ge(t.to_chain, e),
|
|
188
194
|
claimedTxId: t.claim_tx,
|
|
189
195
|
rawPayload: t.raw_payload,
|
|
190
196
|
signature: t.proof,
|
|
@@ -196,27 +202,27 @@ function ke(e) {
|
|
|
196
202
|
sessionState: t.session_state
|
|
197
203
|
});
|
|
198
204
|
}
|
|
199
|
-
const
|
|
200
|
-
async function
|
|
205
|
+
const He = 2e-4;
|
|
206
|
+
async function qt({
|
|
201
207
|
env: e,
|
|
202
208
|
chainId: t = a.ethereum,
|
|
203
209
|
amount: n = 1
|
|
204
210
|
}) {
|
|
205
|
-
const { baseApiUrl: s } =
|
|
211
|
+
const { baseApiUrl: s } = S(e), i = X(t), { data: r } = await C.get(
|
|
206
212
|
`api/v1/exchange/rate/${i}`,
|
|
207
213
|
{ baseURL: s, params: { amount: n } }
|
|
208
|
-
), p = new
|
|
214
|
+
), p = new R(He).multipliedBy(Y).toFixed();
|
|
209
215
|
return { exchangeRate: +r.amount_out, minAmount: +p };
|
|
210
216
|
}
|
|
211
|
-
async function
|
|
217
|
+
async function zt({
|
|
212
218
|
address: e,
|
|
213
219
|
chainId: t,
|
|
214
220
|
env: n
|
|
215
221
|
}) {
|
|
216
|
-
const {
|
|
222
|
+
const { baseApiUrl: s } = S(n);
|
|
217
223
|
try {
|
|
218
|
-
const { data: i } = await
|
|
219
|
-
`${s}/
|
|
224
|
+
const { data: i } = await C.get(
|
|
225
|
+
`${s}/api/v1/claimer/get-user-signature`,
|
|
220
226
|
{
|
|
221
227
|
params: {
|
|
222
228
|
user_destination_address: e,
|
|
@@ -230,20 +236,20 @@ async function jt({
|
|
|
230
236
|
isDelayed: i == null ? void 0 : i.is_delayed
|
|
231
237
|
};
|
|
232
238
|
} catch (i) {
|
|
233
|
-
const r =
|
|
239
|
+
const r = I(i);
|
|
234
240
|
throw new Error(r);
|
|
235
241
|
}
|
|
236
242
|
}
|
|
237
|
-
async function
|
|
243
|
+
async function Kt({
|
|
238
244
|
signature: e,
|
|
239
245
|
typedData: t,
|
|
240
246
|
address: n,
|
|
241
247
|
env: s
|
|
242
248
|
}) {
|
|
243
|
-
const {
|
|
249
|
+
const { baseApiUrl: i } = S(s);
|
|
244
250
|
try {
|
|
245
|
-
const { data: r } = await
|
|
246
|
-
`${i}/
|
|
251
|
+
const { data: r } = await C.post(
|
|
252
|
+
`${i}/api/v1/claimer/save-user-signature`,
|
|
247
253
|
null,
|
|
248
254
|
{
|
|
249
255
|
params: {
|
|
@@ -255,11 +261,11 @@ async function qt({
|
|
|
255
261
|
);
|
|
256
262
|
return r.status;
|
|
257
263
|
} catch (r) {
|
|
258
|
-
const p =
|
|
264
|
+
const p = I(r);
|
|
259
265
|
throw new Error(p);
|
|
260
266
|
}
|
|
261
267
|
}
|
|
262
|
-
const
|
|
268
|
+
const P = {
|
|
263
269
|
[a.ethereum]: "https://rpc.ankr.com/eth",
|
|
264
270
|
[a.holesky]: "https://rpc.ankr.com/eth_holesky",
|
|
265
271
|
[a.sepolia]: "https://rpc.ankr.com/eth_sepolia",
|
|
@@ -267,7 +273,7 @@ const N = {
|
|
|
267
273
|
[a.baseTestnet]: "https://rpc.ankr.com/base_sepolia",
|
|
268
274
|
[a.binanceSmartChain]: "https://rpc.ankr.com/bsc"
|
|
269
275
|
};
|
|
270
|
-
async function
|
|
276
|
+
async function Je(e) {
|
|
271
277
|
const n = await (await fetch(e, {
|
|
272
278
|
method: "POST",
|
|
273
279
|
headers: {
|
|
@@ -280,14 +286,14 @@ async function Ve(e) {
|
|
|
280
286
|
params: []
|
|
281
287
|
})
|
|
282
288
|
})).json(), s = ye.utils.hexToNumber(n == null ? void 0 : n.result);
|
|
283
|
-
return new
|
|
289
|
+
return new R(Number(s));
|
|
284
290
|
}
|
|
285
|
-
const
|
|
291
|
+
const Ze = 2, je = 25e3;
|
|
286
292
|
class q {
|
|
287
293
|
constructor({ chainId: t, rpcUrlConfig: n }) {
|
|
288
294
|
A(this, "chainId");
|
|
289
295
|
A(this, "rpcConfig");
|
|
290
|
-
this.chainId = t, this.rpcConfig = { ...
|
|
296
|
+
this.chainId = t, this.rpcConfig = { ...P, ...n };
|
|
291
297
|
}
|
|
292
298
|
/**
|
|
293
299
|
* Returns web3 instance for read operations.
|
|
@@ -324,10 +330,10 @@ class q {
|
|
|
324
330
|
async getMaxFees() {
|
|
325
331
|
const t = this.getReadWeb3(), n = this.getRpcUrl(), [s, i] = await Promise.all([
|
|
326
332
|
t.eth.getBlock("latest"),
|
|
327
|
-
|
|
333
|
+
Je(n)
|
|
328
334
|
]);
|
|
329
335
|
return !(s != null && s.baseFeePerGas) && typeof (s == null ? void 0 : s.baseFeePerGas) != "bigint" ? {} : {
|
|
330
|
-
maxFeePerGas: +new
|
|
336
|
+
maxFeePerGas: +new R(s.baseFeePerGas.toString(10)).multipliedBy(Ze).plus(i),
|
|
331
337
|
maxPriorityFeePerGas: +i
|
|
332
338
|
};
|
|
333
339
|
}
|
|
@@ -339,8 +345,8 @@ class q {
|
|
|
339
345
|
*/
|
|
340
346
|
async getSafeGasPriceWei() {
|
|
341
347
|
const t = await this.getReadWeb3().eth.getGasPrice();
|
|
342
|
-
return new
|
|
343
|
-
|
|
348
|
+
return new R(t.toString(10)).plus(
|
|
349
|
+
je
|
|
344
350
|
);
|
|
345
351
|
}
|
|
346
352
|
/**
|
|
@@ -356,13 +362,13 @@ class q {
|
|
|
356
362
|
return new s.eth.Contract(t, n);
|
|
357
363
|
}
|
|
358
364
|
}
|
|
359
|
-
class
|
|
365
|
+
class _ extends q {
|
|
360
366
|
constructor({ provider: n, account: s, chainId: i, rpcUrlConfig: r }) {
|
|
361
367
|
super({ chainId: i, rpcUrlConfig: r });
|
|
362
368
|
A(this, "web3");
|
|
363
369
|
A(this, "account");
|
|
364
|
-
A(this, "rpcConfig",
|
|
365
|
-
this.web3 = new ye(n), this.account = s, this.chainId = i, this.rpcConfig = { ...
|
|
370
|
+
A(this, "rpcConfig", P);
|
|
371
|
+
this.web3 = new ye(n), this.account = s, this.chainId = i, this.rpcConfig = { ...P, ...r };
|
|
366
372
|
}
|
|
367
373
|
/**
|
|
368
374
|
* Signs a message using the current provider and account.
|
|
@@ -388,54 +394,54 @@ class I extends q {
|
|
|
388
394
|
*/
|
|
389
395
|
async sendTransactionAsync(n, s, i) {
|
|
390
396
|
const { chainId: r, web3: p } = this, u = this.getReadWeb3(), {
|
|
391
|
-
data:
|
|
397
|
+
data: y,
|
|
392
398
|
estimate: h = !1,
|
|
393
399
|
estimateFee: l = !1,
|
|
394
400
|
extendedGasLimit: g,
|
|
395
|
-
gasLimit:
|
|
401
|
+
gasLimit: D = "0",
|
|
396
402
|
value: fe = "0",
|
|
397
403
|
gasLimitMultiplier: Te = 1
|
|
398
404
|
} = i;
|
|
399
|
-
let { nonce:
|
|
400
|
-
|
|
401
|
-
const
|
|
405
|
+
let { nonce: M } = i;
|
|
406
|
+
M || (M = await u.eth.getTransactionCount(n)), console.log(`Nonce: ${M}`);
|
|
407
|
+
const c = {
|
|
402
408
|
from: n,
|
|
403
409
|
to: s,
|
|
404
410
|
value: w.numberToHex(fe),
|
|
405
|
-
data:
|
|
406
|
-
nonce:
|
|
411
|
+
data: y,
|
|
412
|
+
nonce: M,
|
|
407
413
|
chainId: w.numberToHex(r)
|
|
408
414
|
};
|
|
409
415
|
if (h)
|
|
410
416
|
try {
|
|
411
|
-
const T = await u.eth.estimateGas(
|
|
417
|
+
const T = await u.eth.estimateGas(c), N = Math.round(
|
|
412
418
|
Number(T) * Te
|
|
413
419
|
);
|
|
414
|
-
g ?
|
|
420
|
+
g ? c.gas = w.numberToHex(N + g) : c.gas = w.numberToHex(N);
|
|
415
421
|
} catch (T) {
|
|
416
422
|
throw new Error(
|
|
417
423
|
T.message ?? "Failed to estimate gas limit for transaction."
|
|
418
424
|
);
|
|
419
425
|
}
|
|
420
426
|
else
|
|
421
|
-
|
|
427
|
+
c.gas = w.numberToHex(D);
|
|
422
428
|
const { maxFeePerGas: ne, maxPriorityFeePerGas: ae } = l ? await this.getMaxFees().catch(() => i) : i;
|
|
423
|
-
if (ae !== void 0 && (
|
|
429
|
+
if (ae !== void 0 && (c.maxPriorityFeePerGas = w.numberToHex(ae)), ne !== void 0 && (c.maxFeePerGas = w.numberToHex(ne)), !c.maxFeePerGas && !c.maxPriorityFeePerGas) {
|
|
424
430
|
const T = await this.getSafeGasPriceWei();
|
|
425
|
-
|
|
431
|
+
c.gasPrice = T.toString(10);
|
|
426
432
|
}
|
|
427
|
-
if (!
|
|
433
|
+
if (!c.maxFeePerGas && !c.maxPriorityFeePerGas) {
|
|
428
434
|
const T = await this.getSafeGasPriceWei();
|
|
429
|
-
|
|
435
|
+
c.gasPrice = T.toString(10);
|
|
430
436
|
}
|
|
431
|
-
return console.log("Sending transaction via Web3: ",
|
|
432
|
-
const se = p.eth.sendTransaction(
|
|
437
|
+
return console.log("Sending transaction via Web3: ", c), new Promise((T, N) => {
|
|
438
|
+
const se = p.eth.sendTransaction(c);
|
|
433
439
|
se.once("transactionHash", async (ie) => {
|
|
434
440
|
console.log(`Just signed transaction has is: ${ie}`), T({
|
|
435
441
|
receiptPromise: se,
|
|
436
442
|
transactionHash: ie
|
|
437
443
|
});
|
|
438
|
-
}).catch(
|
|
444
|
+
}).catch(N);
|
|
439
445
|
});
|
|
440
446
|
}
|
|
441
447
|
createContract(n, s) {
|
|
@@ -456,7 +462,7 @@ function Q(e) {
|
|
|
456
462
|
function ee(e) {
|
|
457
463
|
return Object.values(a).includes(e);
|
|
458
464
|
}
|
|
459
|
-
const
|
|
465
|
+
const qe = {
|
|
460
466
|
[a.holesky]: "0xED7bfd5C1790576105Af4649817f6d35A75CD818",
|
|
461
467
|
[a.ethereum]: o,
|
|
462
468
|
[a.binanceSmartChainTestnet]: "0x731eFa688F3679688cf60A3993b8658138953ED6",
|
|
@@ -467,7 +473,7 @@ const Je = {
|
|
|
467
473
|
[a.baseTestnet]: o,
|
|
468
474
|
[a.berachainBartioTestnet]: "0xc47e4b3124597FDF8DD07843D4a7052F2eE80C30",
|
|
469
475
|
[a.corn]: o
|
|
470
|
-
},
|
|
476
|
+
}, ze = {
|
|
471
477
|
[a.holesky]: "0x38A13AB20D15ffbE5A7312d2336EF1552580a4E2",
|
|
472
478
|
[a.ethereum]: o,
|
|
473
479
|
[a.binanceSmartChainTestnet]: "0x107Fc7d90484534704dD2A9e24c7BD45DB4dD1B5",
|
|
@@ -477,7 +483,7 @@ const Je = {
|
|
|
477
483
|
[a.baseTestnet]: o,
|
|
478
484
|
[a.berachainBartioTestnet]: "0xc47e4b3124597FDF8DD07843D4a7052F2eE80C30",
|
|
479
485
|
[a.corn]: o
|
|
480
|
-
},
|
|
486
|
+
}, Ke = {
|
|
481
487
|
[a.ethereum]: "0x8236a87084f8b84306f72007f36f2618a5634494",
|
|
482
488
|
[a.holesky]: o,
|
|
483
489
|
[a.sepolia]: o,
|
|
@@ -488,17 +494,17 @@ const Je = {
|
|
|
488
494
|
[a.berachainBartioTestnet]: o,
|
|
489
495
|
[a.corn]: "0xecAc9C5F704e954931349Da37F60E39f515c11c1"
|
|
490
496
|
};
|
|
491
|
-
function
|
|
497
|
+
function Xe(e = x) {
|
|
492
498
|
switch (e) {
|
|
493
|
-
case
|
|
494
|
-
return
|
|
495
|
-
case
|
|
496
|
-
return
|
|
499
|
+
case d.prod:
|
|
500
|
+
return Ke;
|
|
501
|
+
case d.testnet:
|
|
502
|
+
return ze;
|
|
497
503
|
default:
|
|
498
|
-
return
|
|
504
|
+
return qe;
|
|
499
505
|
}
|
|
500
506
|
}
|
|
501
|
-
const
|
|
507
|
+
const Ye = [
|
|
502
508
|
{
|
|
503
509
|
constant: !0,
|
|
504
510
|
inputs: [],
|
|
@@ -719,7 +725,7 @@ const ze = [
|
|
|
719
725
|
name: "Transfer",
|
|
720
726
|
type: "event"
|
|
721
727
|
}
|
|
722
|
-
],
|
|
728
|
+
], Qe = [
|
|
723
729
|
{
|
|
724
730
|
inputs: [],
|
|
725
731
|
stateMutability: "nonpayable",
|
|
@@ -2479,7 +2485,7 @@ const ze = [
|
|
|
2479
2485
|
stateMutability: "nonpayable",
|
|
2480
2486
|
type: "function"
|
|
2481
2487
|
}
|
|
2482
|
-
],
|
|
2488
|
+
], et = [
|
|
2483
2489
|
{
|
|
2484
2490
|
inputs: [
|
|
2485
2491
|
{
|
|
@@ -3329,31 +3335,31 @@ const ze = [
|
|
|
3329
3335
|
type: "function"
|
|
3330
3336
|
}
|
|
3331
3337
|
];
|
|
3332
|
-
function
|
|
3338
|
+
function tt(e) {
|
|
3333
3339
|
switch (e) {
|
|
3334
3340
|
case "LBTC":
|
|
3335
|
-
return
|
|
3341
|
+
return Qe;
|
|
3336
3342
|
default:
|
|
3337
|
-
return
|
|
3343
|
+
return Ye;
|
|
3338
3344
|
}
|
|
3339
3345
|
}
|
|
3340
3346
|
function E(e, t) {
|
|
3341
|
-
const n =
|
|
3347
|
+
const n = Xe(t), { chainId: s } = e;
|
|
3342
3348
|
if (!ee(s))
|
|
3343
3349
|
throw new Error(`This chain ${s} is not supported`);
|
|
3344
3350
|
const i = n[s];
|
|
3345
3351
|
if (!i)
|
|
3346
3352
|
throw new Error(`Token address for chain ${s} is not defined`);
|
|
3347
|
-
const r =
|
|
3353
|
+
const r = tt("LBTC"), p = e.createContract(r, i);
|
|
3348
3354
|
return p.options.address || (p.options.address = i), p;
|
|
3349
3355
|
}
|
|
3350
|
-
function
|
|
3356
|
+
function Xt({
|
|
3351
3357
|
spender: e,
|
|
3352
3358
|
amount: t,
|
|
3353
3359
|
env: n,
|
|
3354
3360
|
...s
|
|
3355
3361
|
}) {
|
|
3356
|
-
const i = new
|
|
3362
|
+
const i = new _(s), r = E(i, n), p = ce(t), u = r.methods.approve(e, p);
|
|
3357
3363
|
return i.sendTransactionAsync(
|
|
3358
3364
|
i.account,
|
|
3359
3365
|
r.options.address,
|
|
@@ -3365,14 +3371,14 @@ function Zt({
|
|
|
3365
3371
|
}
|
|
3366
3372
|
);
|
|
3367
3373
|
}
|
|
3368
|
-
const
|
|
3369
|
-
async function
|
|
3374
|
+
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;
|
|
3375
|
+
async function Yt({
|
|
3370
3376
|
data: e,
|
|
3371
3377
|
proofSignature: t,
|
|
3372
3378
|
env: n,
|
|
3373
3379
|
...s
|
|
3374
3380
|
}) {
|
|
3375
|
-
const i = new
|
|
3381
|
+
const i = new _(s), r = E(i, n), p = r.methods.mint(pe(e), pe(t));
|
|
3376
3382
|
try {
|
|
3377
3383
|
return await i.sendTransactionAsync(
|
|
3378
3384
|
i.account,
|
|
@@ -3386,11 +3392,11 @@ async function zt({
|
|
|
3386
3392
|
);
|
|
3387
3393
|
} catch (u) {
|
|
3388
3394
|
console.log("error", u);
|
|
3389
|
-
const
|
|
3390
|
-
throw
|
|
3395
|
+
const y = I(u);
|
|
3396
|
+
throw y.includes(nt) ? new Error(at) : new Error(y);
|
|
3391
3397
|
}
|
|
3392
3398
|
}
|
|
3393
|
-
const
|
|
3399
|
+
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;
|
|
3394
3400
|
class le extends Error {
|
|
3395
3401
|
constructor(t, n) {
|
|
3396
3402
|
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;
|
|
@@ -3426,33 +3432,33 @@ class le extends Error {
|
|
|
3426
3432
|
}
|
|
3427
3433
|
class z extends le {
|
|
3428
3434
|
constructor(t) {
|
|
3429
|
-
super(`Multiple errors occurred: [${t.map((n) => n.message).join("], [")}]`), this.code =
|
|
3435
|
+
super(`Multiple errors occurred: [${t.map((n) => n.message).join("], [")}]`), this.code = st, this.errors = t;
|
|
3430
3436
|
}
|
|
3431
3437
|
}
|
|
3432
|
-
const
|
|
3438
|
+
const dt = "An Rpc error has occured with a code of *code*", m = {
|
|
3433
3439
|
// EIP-1474 & JSON RPC 2.0
|
|
3434
3440
|
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1474.md
|
|
3435
|
-
[
|
|
3441
|
+
[O]: {
|
|
3436
3442
|
message: "Parse error",
|
|
3437
3443
|
description: "Invalid JSON"
|
|
3438
3444
|
},
|
|
3439
|
-
[
|
|
3445
|
+
[U]: {
|
|
3440
3446
|
message: "Invalid request",
|
|
3441
3447
|
description: "JSON is not a valid request object "
|
|
3442
3448
|
},
|
|
3443
|
-
[
|
|
3449
|
+
[F]: {
|
|
3444
3450
|
message: "Method not found",
|
|
3445
3451
|
description: "Method does not exist "
|
|
3446
3452
|
},
|
|
3447
|
-
[
|
|
3453
|
+
[B]: {
|
|
3448
3454
|
message: "Invalid params",
|
|
3449
3455
|
description: "Invalid method parameters"
|
|
3450
3456
|
},
|
|
3451
|
-
[
|
|
3457
|
+
[L]: {
|
|
3452
3458
|
message: "Internal error",
|
|
3453
3459
|
description: "Internal JSON-RPC error"
|
|
3454
3460
|
},
|
|
3455
|
-
[
|
|
3461
|
+
[k]: {
|
|
3456
3462
|
message: "Invalid input",
|
|
3457
3463
|
description: "Missing or invalid parameters"
|
|
3458
3464
|
},
|
|
@@ -3460,45 +3466,45 @@ const ot = "An Rpc error has occured with a code of *code*", m = {
|
|
|
3460
3466
|
message: "Resource not found",
|
|
3461
3467
|
description: "Requested resource not found"
|
|
3462
3468
|
},
|
|
3463
|
-
[
|
|
3469
|
+
[W]: {
|
|
3464
3470
|
message: "Resource unavailable",
|
|
3465
3471
|
description: "Requested resource not available"
|
|
3466
3472
|
},
|
|
3467
|
-
[
|
|
3473
|
+
[V]: {
|
|
3468
3474
|
message: "Transaction rejected",
|
|
3469
3475
|
description: "Transaction creation failed"
|
|
3470
3476
|
},
|
|
3471
|
-
[
|
|
3477
|
+
[$]: {
|
|
3472
3478
|
message: "Method not supported",
|
|
3473
3479
|
description: "Method is not implemented"
|
|
3474
3480
|
},
|
|
3475
|
-
[
|
|
3481
|
+
[H]: {
|
|
3476
3482
|
message: "Limit exceeded",
|
|
3477
3483
|
description: "Request exceeds defined limit"
|
|
3478
3484
|
},
|
|
3479
|
-
[
|
|
3485
|
+
[J]: {
|
|
3480
3486
|
message: "JSON-RPC version not supported",
|
|
3481
3487
|
description: "Version of JSON-RPC protocol is not supported"
|
|
3482
3488
|
},
|
|
3483
3489
|
// EIP-1193
|
|
3484
3490
|
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1193.md#provider-errors
|
|
3485
|
-
[
|
|
3491
|
+
[it]: {
|
|
3486
3492
|
name: "User Rejected Request",
|
|
3487
3493
|
message: "The user rejected the request."
|
|
3488
3494
|
},
|
|
3489
|
-
[
|
|
3495
|
+
[rt]: {
|
|
3490
3496
|
name: "Unauthorized",
|
|
3491
3497
|
message: "The requested method and/or account has not been authorized by the user."
|
|
3492
3498
|
},
|
|
3493
|
-
[
|
|
3499
|
+
[ot]: {
|
|
3494
3500
|
name: "Unsupported Method",
|
|
3495
3501
|
message: "The Provider does not support the requested method."
|
|
3496
3502
|
},
|
|
3497
|
-
[
|
|
3503
|
+
[pt]: {
|
|
3498
3504
|
name: "Disconnected",
|
|
3499
3505
|
message: "The Provider is disconnected from all chains."
|
|
3500
3506
|
},
|
|
3501
|
-
[
|
|
3507
|
+
[ut]: {
|
|
3502
3508
|
name: "Chain Disconnected",
|
|
3503
3509
|
message: "The Provider is not connected to the requested chain."
|
|
3504
3510
|
},
|
|
@@ -3587,110 +3593,110 @@ const ot = "An Rpc error has occured with a code of *code*", m = {
|
|
|
3587
3593
|
};
|
|
3588
3594
|
class b extends le {
|
|
3589
3595
|
constructor(t, n) {
|
|
3590
|
-
super(n ??
|
|
3596
|
+
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;
|
|
3591
3597
|
}
|
|
3592
3598
|
toJSON() {
|
|
3593
3599
|
return Object.assign(Object.assign({}, super.toJSON()), { error: this.jsonRpcError, id: this.id, jsonRpc: this.jsonrpc });
|
|
3594
3600
|
}
|
|
3595
3601
|
}
|
|
3596
|
-
class
|
|
3597
|
-
constructor(t) {
|
|
3598
|
-
super(t, m[P].message), this.code = P;
|
|
3599
|
-
}
|
|
3600
|
-
}
|
|
3601
|
-
class ut extends b {
|
|
3602
|
+
class yt extends b {
|
|
3602
3603
|
constructor(t) {
|
|
3603
3604
|
super(t, m[O].message), this.code = O;
|
|
3604
3605
|
}
|
|
3605
3606
|
}
|
|
3606
|
-
class
|
|
3607
|
+
class ct extends b {
|
|
3607
3608
|
constructor(t) {
|
|
3608
3609
|
super(t, m[U].message), this.code = U;
|
|
3609
3610
|
}
|
|
3610
3611
|
}
|
|
3611
|
-
class
|
|
3612
|
+
class lt extends b {
|
|
3612
3613
|
constructor(t) {
|
|
3613
3614
|
super(t, m[F].message), this.code = F;
|
|
3614
3615
|
}
|
|
3615
3616
|
}
|
|
3616
|
-
class
|
|
3617
|
+
class mt extends b {
|
|
3617
3618
|
constructor(t) {
|
|
3618
3619
|
super(t, m[B].message), this.code = B;
|
|
3619
3620
|
}
|
|
3620
3621
|
}
|
|
3621
|
-
class
|
|
3622
|
+
class bt extends b {
|
|
3622
3623
|
constructor(t) {
|
|
3623
3624
|
super(t, m[L].message), this.code = L;
|
|
3624
3625
|
}
|
|
3625
3626
|
}
|
|
3626
|
-
class
|
|
3627
|
+
class ft extends b {
|
|
3627
3628
|
constructor(t) {
|
|
3628
|
-
super(t, m[
|
|
3629
|
+
super(t, m[k].message), this.code = k;
|
|
3629
3630
|
}
|
|
3630
3631
|
}
|
|
3631
|
-
class
|
|
3632
|
+
class Tt extends b {
|
|
3632
3633
|
constructor(t) {
|
|
3633
|
-
super(t, m[
|
|
3634
|
+
super(t, m[$].message), this.code = $;
|
|
3634
3635
|
}
|
|
3635
3636
|
}
|
|
3636
|
-
class
|
|
3637
|
+
class ht extends b {
|
|
3638
|
+
constructor(t) {
|
|
3639
|
+
super(t, m[W].message), this.code = W;
|
|
3640
|
+
}
|
|
3641
|
+
}
|
|
3642
|
+
class gt extends b {
|
|
3637
3643
|
constructor(t) {
|
|
3638
3644
|
super(t, m[G].message), this.code = G;
|
|
3639
3645
|
}
|
|
3640
3646
|
}
|
|
3641
|
-
class
|
|
3647
|
+
class wt extends b {
|
|
3642
3648
|
constructor(t) {
|
|
3643
|
-
super(t, m[
|
|
3649
|
+
super(t, m[J].message), this.code = J;
|
|
3644
3650
|
}
|
|
3645
3651
|
}
|
|
3646
|
-
class
|
|
3652
|
+
class Et extends b {
|
|
3647
3653
|
constructor(t) {
|
|
3648
|
-
super(t, m[
|
|
3654
|
+
super(t, m[V].message), this.code = V;
|
|
3649
3655
|
}
|
|
3650
3656
|
}
|
|
3651
|
-
class
|
|
3657
|
+
class At extends b {
|
|
3652
3658
|
constructor(t) {
|
|
3653
|
-
super(t, m[
|
|
3659
|
+
super(t, m[H].message), this.code = H;
|
|
3654
3660
|
}
|
|
3655
3661
|
}
|
|
3656
3662
|
const f = /* @__PURE__ */ new Map();
|
|
3657
|
-
f.set(
|
|
3658
|
-
f.set(O, {
|
|
3659
|
-
error: ut
|
|
3660
|
-
});
|
|
3663
|
+
f.set(O, { error: yt });
|
|
3661
3664
|
f.set(U, {
|
|
3662
|
-
error:
|
|
3665
|
+
error: ct
|
|
3663
3666
|
});
|
|
3664
|
-
f.set(F, {
|
|
3665
|
-
|
|
3666
|
-
f.set(L, { error: lt });
|
|
3667
|
-
f.set(V, {
|
|
3668
|
-
error: mt
|
|
3667
|
+
f.set(F, {
|
|
3668
|
+
error: lt
|
|
3669
3669
|
});
|
|
3670
|
-
f.set(
|
|
3671
|
-
|
|
3670
|
+
f.set(B, { error: mt });
|
|
3671
|
+
f.set(L, { error: bt });
|
|
3672
|
+
f.set(k, { error: ft });
|
|
3673
|
+
f.set($, {
|
|
3674
|
+
error: Tt
|
|
3672
3675
|
});
|
|
3673
3676
|
f.set(W, {
|
|
3674
3677
|
error: ht
|
|
3675
3678
|
});
|
|
3679
|
+
f.set(V, {
|
|
3680
|
+
error: Et
|
|
3681
|
+
});
|
|
3676
3682
|
f.set(G, {
|
|
3677
|
-
error:
|
|
3683
|
+
error: gt
|
|
3678
3684
|
});
|
|
3679
|
-
f.set(
|
|
3680
|
-
error:
|
|
3685
|
+
f.set(J, {
|
|
3686
|
+
error: wt
|
|
3681
3687
|
});
|
|
3682
|
-
f.set(
|
|
3683
|
-
const
|
|
3684
|
-
var
|
|
3688
|
+
f.set(H, { error: At });
|
|
3689
|
+
const vt = (e) => typeof e == "string" && /^((-)?0x[0-9a-f]+|(0x))$/i.test(e);
|
|
3690
|
+
var Z;
|
|
3685
3691
|
(function(e) {
|
|
3686
3692
|
e.NUMBER = "NUMBER_NUMBER", e.HEX = "NUMBER_HEX", e.STR = "NUMBER_STR", e.BIGINT = "NUMBER_BIGINT";
|
|
3687
|
-
})(
|
|
3693
|
+
})(Z || (Z = {}));
|
|
3688
3694
|
var j;
|
|
3689
3695
|
(function(e) {
|
|
3690
3696
|
e.HEX = "BYTES_HEX", e.UINT8ARRAY = "BYTES_UINT8ARRAY";
|
|
3691
3697
|
})(j || (j = {}));
|
|
3692
|
-
|
|
3693
|
-
|
|
3698
|
+
Z.BIGINT, j.HEX;
|
|
3699
|
+
Z.HEX, j.HEX;
|
|
3694
3700
|
var ue;
|
|
3695
3701
|
(function(e) {
|
|
3696
3702
|
e.EARLIEST = "earliest", e.LATEST = "latest", e.PENDING = "pending", e.SAFE = "safe", e.FINALIZED = "finalized";
|
|
@@ -3699,7 +3705,7 @@ var de;
|
|
|
3699
3705
|
(function(e) {
|
|
3700
3706
|
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";
|
|
3701
3707
|
})(de || (de = {}));
|
|
3702
|
-
const
|
|
3708
|
+
const Rt = {
|
|
3703
3709
|
[a.holesky]: "0x3a0c40c84b5034ed9a98a9a47a02af2b0885246f",
|
|
3704
3710
|
[a.sepolia]: o,
|
|
3705
3711
|
[a.ethereum]: o,
|
|
@@ -3709,7 +3715,7 @@ const Et = {
|
|
|
3709
3715
|
[a.baseTestnet]: o,
|
|
3710
3716
|
[a.berachainBartioTestnet]: o,
|
|
3711
3717
|
[a.corn]: o
|
|
3712
|
-
},
|
|
3718
|
+
}, Ct = {
|
|
3713
3719
|
[a.holesky]: "0x3a0c40c84b5034ed9a98a9a47a02af2b0885246f",
|
|
3714
3720
|
[a.sepolia]: o,
|
|
3715
3721
|
[a.ethereum]: o,
|
|
@@ -3719,7 +3725,7 @@ const Et = {
|
|
|
3719
3725
|
[a.baseTestnet]: o,
|
|
3720
3726
|
[a.berachainBartioTestnet]: o,
|
|
3721
3727
|
[a.corn]: o
|
|
3722
|
-
},
|
|
3728
|
+
}, St = {
|
|
3723
3729
|
[a.holesky]: o,
|
|
3724
3730
|
[a.sepolia]: o,
|
|
3725
3731
|
[a.ethereum]: "0xc750eCAC7250E0D18ecE2C7a5F130E3A765dc260",
|
|
@@ -3730,64 +3736,64 @@ const Et = {
|
|
|
3730
3736
|
[a.berachainBartioTestnet]: o,
|
|
3731
3737
|
[a.corn]: o
|
|
3732
3738
|
};
|
|
3733
|
-
function
|
|
3739
|
+
function It(e = x) {
|
|
3734
3740
|
switch (e) {
|
|
3735
|
-
case
|
|
3736
|
-
return
|
|
3737
|
-
case
|
|
3738
|
-
return
|
|
3741
|
+
case d.prod:
|
|
3742
|
+
return St;
|
|
3743
|
+
case d.testnet:
|
|
3744
|
+
return Ct;
|
|
3739
3745
|
default:
|
|
3740
|
-
return
|
|
3746
|
+
return Rt;
|
|
3741
3747
|
}
|
|
3742
3748
|
}
|
|
3743
|
-
function
|
|
3744
|
-
const n =
|
|
3749
|
+
function _t(e, t) {
|
|
3750
|
+
const n = It(t), { chainId: s } = e;
|
|
3745
3751
|
if (!ee(s))
|
|
3746
3752
|
throw new Error(`This chain ${s} is not supported`);
|
|
3747
3753
|
const i = n[s];
|
|
3748
3754
|
if (!i)
|
|
3749
3755
|
throw new Error("The address for bascule module is not defined");
|
|
3750
|
-
const r = e.createContract(
|
|
3756
|
+
const r = e.createContract(et, i);
|
|
3751
3757
|
return r.options.address || (r.options.address = i), r;
|
|
3752
3758
|
}
|
|
3753
|
-
const
|
|
3754
|
-
var
|
|
3755
|
-
async function
|
|
3759
|
+
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.";
|
|
3760
|
+
var Mt = /* @__PURE__ */ ((e) => (e[e.UNREPORTED = 0] = "UNREPORTED", e[e.REPORTED = 1] = "REPORTED", e[e.WITHDRAWN = 2] = "WITHDRAWN", e))(Mt || {});
|
|
3761
|
+
async function Qt({
|
|
3756
3762
|
txId: e,
|
|
3757
3763
|
env: t,
|
|
3758
3764
|
...n
|
|
3759
3765
|
}) {
|
|
3760
3766
|
if (!e)
|
|
3761
|
-
throw new Error(
|
|
3762
|
-
if (!
|
|
3763
|
-
throw new Error(
|
|
3764
|
-
const s = new
|
|
3767
|
+
throw new Error(xt);
|
|
3768
|
+
if (!vt(e))
|
|
3769
|
+
throw new Error(Dt);
|
|
3770
|
+
const s = new _(n), i = _t(s, t);
|
|
3765
3771
|
try {
|
|
3766
3772
|
const r = await i.methods.depositHistory(Buffer.from(e.replace(/^0x/, ""), "hex")).call();
|
|
3767
3773
|
return Number(r);
|
|
3768
3774
|
} catch (r) {
|
|
3769
|
-
const p =
|
|
3775
|
+
const p = I(r);
|
|
3770
3776
|
throw new Error(p);
|
|
3771
3777
|
}
|
|
3772
3778
|
}
|
|
3773
|
-
const me = (e) => e in [a.ethereum, a.base, a.binanceSmartChain] ?
|
|
3779
|
+
const me = (e) => e in [a.ethereum, a.base, a.binanceSmartChain] ? d.prod : d.stage;
|
|
3774
3780
|
function be(e, t) {
|
|
3775
3781
|
if (!ee(e))
|
|
3776
3782
|
throw new Error(`This chain ${e} is not supported`);
|
|
3777
|
-
const n = t ? { [e]: t } :
|
|
3783
|
+
const n = t ? { [e]: t } : P;
|
|
3778
3784
|
if (!n[e])
|
|
3779
3785
|
throw new Error(`RPC URL for chainId ${e} not found`);
|
|
3780
3786
|
return n;
|
|
3781
3787
|
}
|
|
3782
|
-
async function
|
|
3788
|
+
async function en({
|
|
3783
3789
|
chainId: e,
|
|
3784
3790
|
bakeGasEstimate: t = 0,
|
|
3785
3791
|
rpcUrl: n
|
|
3786
3792
|
}) {
|
|
3787
|
-
const s = be(e, n), i = new q({ chainId: e, rpcUrlConfig: s }), r = me(e), u = await E(i, r).methods.getMintFee().call(),
|
|
3788
|
-
return t ?
|
|
3793
|
+
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)));
|
|
3794
|
+
return t ? y.plus(K(t)) : y;
|
|
3789
3795
|
}
|
|
3790
|
-
async function
|
|
3796
|
+
async function tn({
|
|
3791
3797
|
env: e,
|
|
3792
3798
|
rpcUrl: t,
|
|
3793
3799
|
chainId: n
|
|
@@ -3795,7 +3801,7 @@ async function Yt({
|
|
|
3795
3801
|
const s = { [n]: t }, i = new q({ chainId: n, rpcUrlConfig: s });
|
|
3796
3802
|
return (await E(i, e).methods.totalSupply().call()).toString();
|
|
3797
3803
|
}
|
|
3798
|
-
async function
|
|
3804
|
+
async function nn({
|
|
3799
3805
|
owner: e,
|
|
3800
3806
|
rpcUrl: t,
|
|
3801
3807
|
chainId: n
|
|
@@ -3804,8 +3810,8 @@ async function Qt({
|
|
|
3804
3810
|
try {
|
|
3805
3811
|
return (await p.methods.nonces(e).call()).toString();
|
|
3806
3812
|
} catch (u) {
|
|
3807
|
-
const
|
|
3808
|
-
throw new Error(
|
|
3813
|
+
const y = I(u);
|
|
3814
|
+
throw new Error(y);
|
|
3809
3815
|
}
|
|
3810
3816
|
}
|
|
3811
3817
|
const te = {
|
|
@@ -3813,29 +3819,29 @@ const te = {
|
|
|
3813
3819
|
[a.berachainBartioTestnet]: "0x1977013acaf27856ac8048C42EE2ed0134d53895",
|
|
3814
3820
|
[a.corn]: o,
|
|
3815
3821
|
[a.ethereum]: o
|
|
3816
|
-
},
|
|
3822
|
+
}, Nt = {
|
|
3817
3823
|
...te
|
|
3818
|
-
},
|
|
3824
|
+
}, Pt = {
|
|
3819
3825
|
...te,
|
|
3820
3826
|
[a.corn]: "0xfc7B20D9B59A8A466f4fC3d34aA69a7D98e71d7A",
|
|
3821
3827
|
[a.ethereum]: "0x6bc15d7930839ec18a57f6f7df72ae1b439d077f"
|
|
3822
3828
|
};
|
|
3823
|
-
function
|
|
3829
|
+
function an(e = x) {
|
|
3824
3830
|
switch (e) {
|
|
3825
|
-
case
|
|
3826
|
-
return
|
|
3827
|
-
case
|
|
3828
|
-
return
|
|
3831
|
+
case d.prod:
|
|
3832
|
+
return Pt;
|
|
3833
|
+
case d.testnet:
|
|
3834
|
+
return Nt;
|
|
3829
3835
|
default:
|
|
3830
3836
|
return te;
|
|
3831
3837
|
}
|
|
3832
3838
|
}
|
|
3833
|
-
async function
|
|
3834
|
-
const t = new
|
|
3839
|
+
async function sn(e) {
|
|
3840
|
+
const t = new _(e), n = `destination chain id is ${e.chainId}`;
|
|
3835
3841
|
return t.signMessage(n);
|
|
3836
3842
|
}
|
|
3837
|
-
const
|
|
3838
|
-
function
|
|
3843
|
+
const Ot = 24 * 60 * 60;
|
|
3844
|
+
function Ut({
|
|
3839
3845
|
chainId: e,
|
|
3840
3846
|
verifyingContract: t,
|
|
3841
3847
|
fee: n,
|
|
@@ -3869,73 +3875,73 @@ function Nt({
|
|
|
3869
3875
|
}
|
|
3870
3876
|
};
|
|
3871
3877
|
}
|
|
3872
|
-
const
|
|
3873
|
-
async function
|
|
3878
|
+
const Ft = "Failed to obtain a valid signature. The response is undefined or invalid.";
|
|
3879
|
+
async function rn({
|
|
3874
3880
|
address: e,
|
|
3875
3881
|
provider: t,
|
|
3876
3882
|
fee: n,
|
|
3877
3883
|
chainId: s,
|
|
3878
3884
|
env: i,
|
|
3879
|
-
expiry: r = Date.now() +
|
|
3885
|
+
expiry: r = Date.now() + Ot
|
|
3880
3886
|
}) {
|
|
3881
|
-
var g,
|
|
3882
|
-
const p = new
|
|
3887
|
+
var g, D;
|
|
3888
|
+
const p = new _({
|
|
3883
3889
|
provider: t,
|
|
3884
3890
|
account: e,
|
|
3885
3891
|
chainId: s
|
|
3886
|
-
}),
|
|
3887
|
-
|
|
3892
|
+
}), y = E(p, i).options.address, h = JSON.stringify(
|
|
3893
|
+
Ut({
|
|
3888
3894
|
chainId: s,
|
|
3889
|
-
verifyingContract:
|
|
3895
|
+
verifyingContract: y,
|
|
3890
3896
|
fee: n,
|
|
3891
3897
|
expiry: r.toString()
|
|
3892
3898
|
})
|
|
3893
|
-
), l = await ((
|
|
3899
|
+
), l = await ((D = (g = p.web3) == null ? void 0 : g.currentProvider) == null ? void 0 : D.request({
|
|
3894
3900
|
method: "eth_signTypedData_v4",
|
|
3895
3901
|
params: [e, h]
|
|
3896
3902
|
}));
|
|
3897
3903
|
if (typeof l == "string")
|
|
3898
3904
|
return { signature: l, typedData: h };
|
|
3899
3905
|
if (!(l != null && l.result))
|
|
3900
|
-
throw new Error(
|
|
3906
|
+
throw new Error(Ft);
|
|
3901
3907
|
return { signature: l.result, typedData: h };
|
|
3902
3908
|
}
|
|
3903
3909
|
Ee(we);
|
|
3904
|
-
function
|
|
3910
|
+
function Bt(e, t = d.prod) {
|
|
3905
3911
|
var r;
|
|
3906
|
-
const n =
|
|
3912
|
+
const n = Lt(e), i = (r = Ae[n]({
|
|
3907
3913
|
address: e,
|
|
3908
|
-
network: t ===
|
|
3914
|
+
network: t === d.prod ? oe.bitcoin : oe.testnet
|
|
3909
3915
|
}).output) == null ? void 0 : r.toString("hex");
|
|
3910
3916
|
if (!i)
|
|
3911
3917
|
throw new Error("Output script is not found.");
|
|
3912
3918
|
return `0x${i}`;
|
|
3913
3919
|
}
|
|
3914
|
-
function
|
|
3920
|
+
function Lt(e) {
|
|
3915
3921
|
const t = ve.fromBech32(e);
|
|
3916
3922
|
if (t.version === 1 && t.data.length === 32)
|
|
3917
3923
|
return "p2tr";
|
|
3918
3924
|
if (t.version === 0 && t.data.length === 20)
|
|
3919
3925
|
return "p2wpkh";
|
|
3920
|
-
if (
|
|
3926
|
+
if (kt(e))
|
|
3921
3927
|
return "p2wsh";
|
|
3922
3928
|
throw new Error("Address type is not supported.");
|
|
3923
3929
|
}
|
|
3924
|
-
function
|
|
3930
|
+
function kt(e) {
|
|
3925
3931
|
return (e.startsWith("bc1") || e.startsWith("tb1")) && e.length === 62;
|
|
3926
3932
|
}
|
|
3927
|
-
function
|
|
3933
|
+
function on({
|
|
3928
3934
|
btcAddress: e,
|
|
3929
3935
|
amount: t,
|
|
3930
3936
|
env: n,
|
|
3931
3937
|
...s
|
|
3932
3938
|
}) {
|
|
3933
|
-
const i = new
|
|
3939
|
+
const i = new _(s), r = E(i, n), p = Bt(e, n), u = ce(t), y = r.methods.redeem(p, u);
|
|
3934
3940
|
return i.sendTransactionAsync(
|
|
3935
3941
|
i.account,
|
|
3936
3942
|
r.options.address,
|
|
3937
3943
|
{
|
|
3938
|
-
data:
|
|
3944
|
+
data: y.encodeABI(),
|
|
3939
3945
|
estimate: !0,
|
|
3940
3946
|
estimateFee: !0,
|
|
3941
3947
|
gasLimitMultiplier: Q(i.chainId)
|
|
@@ -3943,34 +3949,39 @@ function an({
|
|
|
3943
3949
|
);
|
|
3944
3950
|
}
|
|
3945
3951
|
export {
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3952
|
+
Mt as BasculeDepositStatus,
|
|
3953
|
+
We as ENotarizationStatus,
|
|
3954
|
+
Ve as ESessionState,
|
|
3949
3955
|
a as OChainId,
|
|
3950
|
-
|
|
3951
|
-
|
|
3956
|
+
d as OEnv,
|
|
3957
|
+
Ne as SANCTIONED_ADDRESS,
|
|
3952
3958
|
Y as SATOSHI_SCALE,
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3959
|
+
Xt as approveLBTC,
|
|
3960
|
+
Yt as claimLBTC,
|
|
3961
|
+
K as fromSatoshi,
|
|
3962
|
+
Jt as generateDepositBtcAddress,
|
|
3963
|
+
S as getApiConfig,
|
|
3964
|
+
Qt as getBasculeDepositStatus,
|
|
3965
|
+
Se as getBaseNetworkByEnv,
|
|
3966
|
+
Ce as getBscNetworkByEnv,
|
|
3967
|
+
Ge as getChainIdByName,
|
|
3968
|
+
X as getChainNameById,
|
|
3969
|
+
Zt as getDepositBtcAddress,
|
|
3970
|
+
Le as getDepositBtcAddresses,
|
|
3971
|
+
jt as getDepositsByAddress,
|
|
3972
|
+
Re as getEthNetworkByEnv,
|
|
3973
|
+
qt as getLBTCExchangeRate,
|
|
3974
|
+
en as getLBTCMintingFee,
|
|
3975
|
+
tn as getLBTCTotalSupply,
|
|
3976
|
+
Xe as getLbtcAddressConfig,
|
|
3977
|
+
an as getLbtcOFTAdapterAddressConfig,
|
|
3978
|
+
zt as getNetworkFeeSignature,
|
|
3979
|
+
nn as getPermitNonce,
|
|
3969
3980
|
ee as isValidChain,
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3981
|
+
sn as signLbtcDestionationAddr,
|
|
3982
|
+
rn as signNetworkFee,
|
|
3983
|
+
Kt as storeNetworkFeeSignature,
|
|
3973
3984
|
ce as toSatoshi,
|
|
3974
|
-
|
|
3985
|
+
on as unstakeLBTC
|
|
3975
3986
|
};
|
|
3976
3987
|
//# sourceMappingURL=index.js.map
|