@chainrails/sdk 0.3.4 → 0.3.6
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/chainrails-sdk.es.js +286 -202
- package/dist/chainrails-sdk.es.mjs +286 -202
- package/dist/chainrails-sdk.umd.js +2 -2
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/src/Auth/index.d.ts +3 -1
- package/dist/src/Auth/index.d.ts.map +1 -1
- package/dist/src/Auth/types.d.ts +14 -0
- package/dist/src/Auth/types.d.ts.map +1 -1
- package/dist/src/Ramp/index.d.ts +45 -0
- package/dist/src/Ramp/index.d.ts.map +1 -0
- package/dist/src/Ramp/types.d.ts +156 -0
- package/dist/src/Ramp/types.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import ae from "ky";
|
|
2
|
-
const
|
|
2
|
+
const d = {
|
|
3
3
|
ARBITRUM: "ARBITRUM_MAINNET",
|
|
4
4
|
ARBITRUM_TESTNET: "ARBITRUM_TESTNET",
|
|
5
5
|
AVALANCHE: "AVALANCHE_MAINNET",
|
|
@@ -18,7 +18,7 @@ const c = {
|
|
|
18
18
|
POLYGON: "POLYGON_MAINNET",
|
|
19
19
|
STARKNET: "STARKNET_MAINNET",
|
|
20
20
|
STARKNET_TESTNET: "STARKNET_TESTNET"
|
|
21
|
-
},
|
|
21
|
+
}, as = {
|
|
22
22
|
ARBITRUM: "ARBITRUM",
|
|
23
23
|
ARBITRUM_TESTNET: "ARBITRUM_TESTNET",
|
|
24
24
|
AVALANCHE: "AVALANCHE",
|
|
@@ -38,20 +38,20 @@ const c = {
|
|
|
38
38
|
STARKNET: "STARKNET",
|
|
39
39
|
STARKNET_TESTNET: "STARKNET_TESTNET"
|
|
40
40
|
};
|
|
41
|
-
function
|
|
41
|
+
function v(s, { strict: e = !0 } = {}) {
|
|
42
42
|
return !s || typeof s != "string" ? !1 : e ? /^0x[0-9a-fA-F]*$/.test(s) : s.startsWith("0x");
|
|
43
43
|
}
|
|
44
44
|
function x(s) {
|
|
45
|
-
return
|
|
45
|
+
return v(s, { strict: !1 }) ? Math.ceil((s.length - 2) / 2) : s.length;
|
|
46
46
|
}
|
|
47
|
-
const
|
|
47
|
+
const j = "2.43.4";
|
|
48
48
|
let I = {
|
|
49
49
|
getDocsUrl: ({ docsBaseUrl: s, docsPath: e = "", docsSlug: n }) => e ? `${s ?? "https://viem.sh"}${e}${n ? `#${n}` : ""}` : void 0,
|
|
50
|
-
version: `viem@${
|
|
50
|
+
version: `viem@${j}`
|
|
51
51
|
};
|
|
52
|
-
class
|
|
52
|
+
class T extends Error {
|
|
53
53
|
constructor(e, n = {}) {
|
|
54
|
-
const a = n.cause instanceof
|
|
54
|
+
const a = n.cause instanceof T ? n.cause.details : n.cause?.message ? n.cause.message : n.details, o = n.cause instanceof T && n.cause.docsPath || n.docsPath, r = I.getDocsUrl?.({ ...n, docsPath: o }), i = [
|
|
55
55
|
e || "An error occurred.",
|
|
56
56
|
"",
|
|
57
57
|
...n.metaMessages ? [...n.metaMessages, ""] : [],
|
|
@@ -90,16 +90,16 @@ class E extends Error {
|
|
|
90
90
|
configurable: !0,
|
|
91
91
|
writable: !0,
|
|
92
92
|
value: "BaseError"
|
|
93
|
-
}), this.details = a, this.docsPath = o, this.metaMessages = n.metaMessages, this.name = n.name ?? this.name, this.shortMessage = e, this.version =
|
|
93
|
+
}), this.details = a, this.docsPath = o, this.metaMessages = n.metaMessages, this.name = n.name ?? this.name, this.shortMessage = e, this.version = j;
|
|
94
94
|
}
|
|
95
95
|
walk(e) {
|
|
96
|
-
return
|
|
96
|
+
return z(this, e);
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
|
-
function
|
|
100
|
-
return e?.(s) ? s : s && typeof s == "object" && "cause" in s && s.cause !== void 0 ?
|
|
99
|
+
function z(s, e) {
|
|
100
|
+
return e?.(s) ? s : s && typeof s == "object" && "cause" in s && s.cause !== void 0 ? z(s.cause, e) : e ? null : s;
|
|
101
101
|
}
|
|
102
|
-
class K extends
|
|
102
|
+
class K extends T {
|
|
103
103
|
constructor({ size: e, targetSize: n, type: a }) {
|
|
104
104
|
super(`${a.charAt(0).toUpperCase()}${a.slice(1).toLowerCase()} size (${e}) exceeds padding size (${n}).`, { name: "SizeExceedsPaddingSizeError" });
|
|
105
105
|
}
|
|
@@ -135,17 +135,17 @@ function ie(s, { dir: e, size: n = 32 } = {}) {
|
|
|
135
135
|
}
|
|
136
136
|
return a;
|
|
137
137
|
}
|
|
138
|
-
class re extends
|
|
138
|
+
class re extends T {
|
|
139
139
|
constructor({ max: e, min: n, signed: a, size: o, value: r }) {
|
|
140
140
|
super(`Number "${r}" is not in safe ${o ? `${o * 8}-bit ${a ? "signed" : "unsigned"} ` : ""}integer range ${e ? `(${n} to ${e})` : `(above ${n})`}`, { name: "IntegerOutOfRangeError" });
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
|
-
class ce extends
|
|
143
|
+
class ce extends T {
|
|
144
144
|
constructor({ givenSize: e, maxSize: n }) {
|
|
145
145
|
super(`Size cannot exceed ${n} bytes. Given size: ${e} bytes.`, { name: "SizeOverflowError" });
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
|
-
function
|
|
148
|
+
function w(s, { size: e }) {
|
|
149
149
|
if (x(s) > e)
|
|
150
150
|
throw new ce({
|
|
151
151
|
givenSize: x(s),
|
|
@@ -158,27 +158,27 @@ function de(s, e = {}) {
|
|
|
158
158
|
a ? n ? r = (1n << BigInt(a) * 8n - 1n) - 1n : r = 2n ** (BigInt(a) * 8n) - 1n : typeof s == "number" && (r = BigInt(Number.MAX_SAFE_INTEGER));
|
|
159
159
|
const i = typeof r == "bigint" && n ? -r - 1n : 0;
|
|
160
160
|
if (r && o > r || o < i) {
|
|
161
|
-
const
|
|
161
|
+
const h = typeof s == "bigint" ? "n" : "";
|
|
162
162
|
throw new re({
|
|
163
|
-
max: r ? `${r}${
|
|
164
|
-
min: `${i}${
|
|
163
|
+
max: r ? `${r}${h}` : void 0,
|
|
164
|
+
min: `${i}${h}`,
|
|
165
165
|
signed: n,
|
|
166
166
|
size: a,
|
|
167
|
-
value: `${s}${
|
|
167
|
+
value: `${s}${h}`
|
|
168
168
|
});
|
|
169
169
|
}
|
|
170
|
-
const
|
|
171
|
-
return a ? U(
|
|
170
|
+
const l = `0x${(n && o < 0 ? (1n << BigInt(a * 8)) + BigInt(o) : o).toString(16)}`;
|
|
171
|
+
return a ? U(l, { size: a }) : l;
|
|
172
172
|
}
|
|
173
173
|
const le = /* @__PURE__ */ new TextEncoder();
|
|
174
174
|
function ue(s, e = {}) {
|
|
175
|
-
return typeof s == "number" || typeof s == "bigint" ?
|
|
175
|
+
return typeof s == "number" || typeof s == "bigint" ? me(s, e) : typeof s == "boolean" ? ge(s, e) : v(s) ? W(s, e) : V(s, e);
|
|
176
176
|
}
|
|
177
177
|
function ge(s, e = {}) {
|
|
178
178
|
const n = new Uint8Array(1);
|
|
179
|
-
return n[0] = Number(s), typeof e.size == "number" ? (
|
|
179
|
+
return n[0] = Number(s), typeof e.size == "number" ? (w(n, { size: e.size }), U(n, { size: e.size })) : n;
|
|
180
180
|
}
|
|
181
|
-
const
|
|
181
|
+
const E = {
|
|
182
182
|
zero: 48,
|
|
183
183
|
nine: 57,
|
|
184
184
|
A: 65,
|
|
@@ -186,50 +186,50 @@ const T = {
|
|
|
186
186
|
a: 97,
|
|
187
187
|
f: 102
|
|
188
188
|
};
|
|
189
|
-
function
|
|
190
|
-
if (s >=
|
|
191
|
-
return s -
|
|
192
|
-
if (s >=
|
|
193
|
-
return s - (
|
|
194
|
-
if (s >=
|
|
195
|
-
return s - (
|
|
189
|
+
function O(s) {
|
|
190
|
+
if (s >= E.zero && s <= E.nine)
|
|
191
|
+
return s - E.zero;
|
|
192
|
+
if (s >= E.A && s <= E.F)
|
|
193
|
+
return s - (E.A - 10);
|
|
194
|
+
if (s >= E.a && s <= E.f)
|
|
195
|
+
return s - (E.a - 10);
|
|
196
196
|
}
|
|
197
197
|
function W(s, e = {}) {
|
|
198
198
|
let n = s;
|
|
199
|
-
e.size && (
|
|
199
|
+
e.size && (w(n, { size: e.size }), n = U(n, { dir: "right", size: e.size }));
|
|
200
200
|
let a = n.slice(2);
|
|
201
201
|
a.length % 2 && (a = `0${a}`);
|
|
202
202
|
const o = a.length / 2, r = new Uint8Array(o);
|
|
203
|
-
for (let i = 0,
|
|
204
|
-
const
|
|
205
|
-
if (
|
|
206
|
-
throw new
|
|
207
|
-
r[i] =
|
|
203
|
+
for (let i = 0, l = 0; i < o; i++) {
|
|
204
|
+
const h = O(a.charCodeAt(l++)), S = O(a.charCodeAt(l++));
|
|
205
|
+
if (h === void 0 || S === void 0)
|
|
206
|
+
throw new T(`Invalid byte sequence ("${a[l - 2]}${a[l - 1]}" in "${a}").`);
|
|
207
|
+
r[i] = h * 16 + S;
|
|
208
208
|
}
|
|
209
209
|
return r;
|
|
210
210
|
}
|
|
211
|
-
function
|
|
211
|
+
function me(s, e) {
|
|
212
212
|
const n = de(s, e);
|
|
213
213
|
return W(n);
|
|
214
214
|
}
|
|
215
215
|
function V(s, e = {}) {
|
|
216
216
|
const n = le.encode(s);
|
|
217
|
-
return typeof e.size == "number" ? (
|
|
217
|
+
return typeof e.size == "number" ? (w(n, { size: e.size }), U(n, { dir: "right", size: e.size })) : n;
|
|
218
218
|
}
|
|
219
|
-
const
|
|
219
|
+
const b = /* @__PURE__ */ BigInt(2 ** 32 - 1), M = /* @__PURE__ */ BigInt(32);
|
|
220
220
|
function fe(s, e = !1) {
|
|
221
|
-
return e ? { h: Number(s &
|
|
221
|
+
return e ? { h: Number(s & b), l: Number(s >> M & b) } : { h: Number(s >> M & b) | 0, l: Number(s & b) | 0 };
|
|
222
222
|
}
|
|
223
|
-
function
|
|
223
|
+
function he(s, e = !1) {
|
|
224
224
|
const n = s.length;
|
|
225
225
|
let a = new Uint32Array(n), o = new Uint32Array(n);
|
|
226
226
|
for (let r = 0; r < n; r++) {
|
|
227
|
-
const { h: i, l
|
|
228
|
-
[a[r], o[r]] = [i,
|
|
227
|
+
const { h: i, l } = fe(s[r], e);
|
|
228
|
+
[a[r], o[r]] = [i, l];
|
|
229
229
|
}
|
|
230
230
|
return [a, o];
|
|
231
231
|
}
|
|
232
|
-
const
|
|
232
|
+
const Ee = (s, e, n) => s << n | e >>> 32 - n, Te = (s, e, n) => e << n | s >>> 32 - n, Se = (s, e, n) => e << n - 32 | s >>> 64 - n, pe = (s, e, n) => s << n - 32 | e >>> 64 - n;
|
|
233
233
|
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
234
234
|
function Ce(s) {
|
|
235
235
|
return s instanceof Uint8Array || ArrayBuffer.isView(s) && s.constructor.name === "Uint8Array";
|
|
@@ -238,32 +238,32 @@ function F(s) {
|
|
|
238
238
|
if (!Number.isSafeInteger(s) || s < 0)
|
|
239
239
|
throw new Error("positive integer expected, got " + s);
|
|
240
240
|
}
|
|
241
|
-
function
|
|
241
|
+
function A(s, ...e) {
|
|
242
242
|
if (!Ce(s))
|
|
243
243
|
throw new Error("Uint8Array expected");
|
|
244
244
|
if (e.length > 0 && !e.includes(s.length))
|
|
245
245
|
throw new Error("Uint8Array expected of length " + e + ", got length=" + s.length);
|
|
246
246
|
}
|
|
247
|
-
function
|
|
247
|
+
function P(s, e = !0) {
|
|
248
248
|
if (s.destroyed)
|
|
249
249
|
throw new Error("Hash instance has been destroyed");
|
|
250
250
|
if (e && s.finished)
|
|
251
251
|
throw new Error("Hash#digest() has already been called");
|
|
252
252
|
}
|
|
253
|
-
function
|
|
254
|
-
|
|
253
|
+
function De(s, e) {
|
|
254
|
+
A(s);
|
|
255
255
|
const n = e.outputLen;
|
|
256
256
|
if (s.length < n)
|
|
257
257
|
throw new Error("digestInto() expects output buffer of length at least " + n);
|
|
258
258
|
}
|
|
259
|
-
function
|
|
259
|
+
function be(s) {
|
|
260
260
|
return new Uint32Array(s.buffer, s.byteOffset, Math.floor(s.byteLength / 4));
|
|
261
261
|
}
|
|
262
|
-
function
|
|
262
|
+
function G(...s) {
|
|
263
263
|
for (let e = 0; e < s.length; e++)
|
|
264
264
|
s[e].fill(0);
|
|
265
265
|
}
|
|
266
|
-
const
|
|
266
|
+
const Ae = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
|
|
267
267
|
function Ue(s) {
|
|
268
268
|
return s << 24 & 4278190080 | s << 8 & 16711680 | s >>> 8 & 65280 | s >>> 24 & 255;
|
|
269
269
|
}
|
|
@@ -272,74 +272,74 @@ function Ie(s) {
|
|
|
272
272
|
s[e] = Ue(s[e]);
|
|
273
273
|
return s;
|
|
274
274
|
}
|
|
275
|
-
const
|
|
275
|
+
const H = Ae ? (s) => s : Ie;
|
|
276
276
|
function ye(s) {
|
|
277
277
|
if (typeof s != "string")
|
|
278
278
|
throw new Error("string expected");
|
|
279
279
|
return new Uint8Array(new TextEncoder().encode(s));
|
|
280
280
|
}
|
|
281
|
-
function
|
|
282
|
-
return typeof s == "string" && (s = ye(s)),
|
|
281
|
+
function Y(s) {
|
|
282
|
+
return typeof s == "string" && (s = ye(s)), A(s), s;
|
|
283
283
|
}
|
|
284
|
-
class
|
|
284
|
+
class Re {
|
|
285
285
|
}
|
|
286
|
-
function
|
|
287
|
-
const e = (a) => s().update(
|
|
286
|
+
function ke(s) {
|
|
287
|
+
const e = (a) => s().update(Y(a)).digest(), n = s();
|
|
288
288
|
return e.outputLen = n.outputLen, e.blockLen = n.blockLen, e.create = () => s(), e;
|
|
289
289
|
}
|
|
290
|
-
const
|
|
290
|
+
const Ne = BigInt(0), C = BigInt(1), ve = BigInt(2), we = BigInt(7), Be = BigInt(256), xe = BigInt(113), q = [], X = [], Q = [];
|
|
291
291
|
for (let s = 0, e = C, n = 1, a = 0; s < 24; s++) {
|
|
292
292
|
[n, a] = [a, (2 * n + 3 * a) % 5], q.push(2 * (5 * a + n)), X.push((s + 1) * (s + 2) / 2 % 64);
|
|
293
|
-
let o =
|
|
293
|
+
let o = Ne;
|
|
294
294
|
for (let r = 0; r < 7; r++)
|
|
295
|
-
e = (e << C ^ (e >>
|
|
295
|
+
e = (e << C ^ (e >> we) * xe) % Be, e & ve && (o ^= C << (C << /* @__PURE__ */ BigInt(r)) - C);
|
|
296
296
|
Q.push(o);
|
|
297
297
|
}
|
|
298
|
-
const J =
|
|
298
|
+
const J = he(Q, !0), Oe = J[0], Me = J[1], $ = (s, e, n) => n > 32 ? Se(s, e, n) : Ee(s, e, n), L = (s, e, n) => n > 32 ? pe(s, e, n) : Te(s, e, n);
|
|
299
299
|
function Fe(s, e = 24) {
|
|
300
300
|
const n = new Uint32Array(10);
|
|
301
301
|
for (let a = 24 - e; a < 24; a++) {
|
|
302
302
|
for (let i = 0; i < 10; i++)
|
|
303
303
|
n[i] = s[i] ^ s[i + 10] ^ s[i + 20] ^ s[i + 30] ^ s[i + 40];
|
|
304
304
|
for (let i = 0; i < 10; i += 2) {
|
|
305
|
-
const
|
|
306
|
-
for (let
|
|
307
|
-
s[i +
|
|
305
|
+
const l = (i + 8) % 10, h = (i + 2) % 10, S = n[h], p = n[h + 1], ne = $(S, p, 1) ^ n[l], te = L(S, p, 1) ^ n[l + 1];
|
|
306
|
+
for (let D = 0; D < 50; D += 10)
|
|
307
|
+
s[i + D] ^= ne, s[i + D + 1] ^= te;
|
|
308
308
|
}
|
|
309
309
|
let o = s[2], r = s[3];
|
|
310
310
|
for (let i = 0; i < 24; i++) {
|
|
311
|
-
const
|
|
312
|
-
o = s[p], r = s[p + 1], s[p] =
|
|
311
|
+
const l = X[i], h = $(o, r, l), S = L(o, r, l), p = q[i];
|
|
312
|
+
o = s[p], r = s[p + 1], s[p] = h, s[p + 1] = S;
|
|
313
313
|
}
|
|
314
314
|
for (let i = 0; i < 50; i += 10) {
|
|
315
|
-
for (let
|
|
316
|
-
n[
|
|
317
|
-
for (let
|
|
318
|
-
s[i +
|
|
315
|
+
for (let l = 0; l < 10; l++)
|
|
316
|
+
n[l] = s[i + l];
|
|
317
|
+
for (let l = 0; l < 10; l++)
|
|
318
|
+
s[i + l] ^= ~n[(l + 2) % 10] & n[(l + 4) % 10];
|
|
319
319
|
}
|
|
320
|
-
s[0] ^=
|
|
320
|
+
s[0] ^= Oe[a], s[1] ^= Me[a];
|
|
321
321
|
}
|
|
322
|
-
|
|
322
|
+
G(n);
|
|
323
323
|
}
|
|
324
|
-
class B extends
|
|
324
|
+
class B extends Re {
|
|
325
325
|
// NOTE: we accept arguments in bytes instead of bits here.
|
|
326
326
|
constructor(e, n, a, o = !1, r = 24) {
|
|
327
327
|
if (super(), this.pos = 0, this.posOut = 0, this.finished = !1, this.destroyed = !1, this.enableXOF = !1, this.blockLen = e, this.suffix = n, this.outputLen = a, this.enableXOF = o, this.rounds = r, F(a), !(0 < e && e < 200))
|
|
328
328
|
throw new Error("only keccak-f1600 function is supported");
|
|
329
|
-
this.state = new Uint8Array(200), this.state32 =
|
|
329
|
+
this.state = new Uint8Array(200), this.state32 = be(this.state);
|
|
330
330
|
}
|
|
331
331
|
clone() {
|
|
332
332
|
return this._cloneInto();
|
|
333
333
|
}
|
|
334
334
|
keccak() {
|
|
335
|
-
|
|
335
|
+
H(this.state32), Fe(this.state32, this.rounds), H(this.state32), this.posOut = 0, this.pos = 0;
|
|
336
336
|
}
|
|
337
337
|
update(e) {
|
|
338
|
-
|
|
338
|
+
P(this), e = Y(e), A(e);
|
|
339
339
|
const { blockLen: n, state: a } = this, o = e.length;
|
|
340
340
|
for (let r = 0; r < o; ) {
|
|
341
341
|
const i = Math.min(n - this.pos, o - r);
|
|
342
|
-
for (let
|
|
342
|
+
for (let l = 0; l < i; l++)
|
|
343
343
|
a[this.pos++] ^= e[r++];
|
|
344
344
|
this.pos === n && this.keccak();
|
|
345
345
|
}
|
|
@@ -353,7 +353,7 @@ class B extends ke {
|
|
|
353
353
|
e[a] ^= n, (n & 128) !== 0 && a === o - 1 && this.keccak(), e[o - 1] ^= 128, this.keccak();
|
|
354
354
|
}
|
|
355
355
|
writeInto(e) {
|
|
356
|
-
|
|
356
|
+
P(this, !1), A(e), this.finish();
|
|
357
357
|
const n = this.state, { blockLen: a } = this;
|
|
358
358
|
for (let o = 0, r = e.length; o < r; ) {
|
|
359
359
|
this.posOut >= a && this.keccak();
|
|
@@ -371,7 +371,7 @@ class B extends ke {
|
|
|
371
371
|
return F(e), this.xofInto(new Uint8Array(e));
|
|
372
372
|
}
|
|
373
373
|
digestInto(e) {
|
|
374
|
-
if (
|
|
374
|
+
if (De(e, this), this.finished)
|
|
375
375
|
throw new Error("digest() was already called");
|
|
376
376
|
return this.writeInto(e), this.destroy(), e;
|
|
377
377
|
}
|
|
@@ -379,18 +379,18 @@ class B extends ke {
|
|
|
379
379
|
return this.digestInto(new Uint8Array(this.outputLen));
|
|
380
380
|
}
|
|
381
381
|
destroy() {
|
|
382
|
-
this.destroyed = !0,
|
|
382
|
+
this.destroyed = !0, G(this.state);
|
|
383
383
|
}
|
|
384
384
|
_cloneInto(e) {
|
|
385
385
|
const { blockLen: n, suffix: a, outputLen: o, rounds: r, enableXOF: i } = this;
|
|
386
386
|
return e || (e = new B(n, a, o, i, r)), e.state32.set(this.state32), e.pos = this.pos, e.posOut = this.posOut, e.finished = this.finished, e.rounds = r, e.suffix = a, e.outputLen = o, e.enableXOF = i, e.destroyed = this.destroyed, e;
|
|
387
387
|
}
|
|
388
388
|
}
|
|
389
|
-
const
|
|
390
|
-
function
|
|
391
|
-
return
|
|
389
|
+
const Pe = (s, e, n) => ke(() => new B(e, s, n)), He = Pe(1, 136, 256 / 8);
|
|
390
|
+
function $e(s, e) {
|
|
391
|
+
return He(v(s, { strict: !1 }) ? ue(s) : s);
|
|
392
392
|
}
|
|
393
|
-
class
|
|
393
|
+
class Le extends T {
|
|
394
394
|
constructor({ address: e }) {
|
|
395
395
|
super(`Address "${e}" is invalid.`, {
|
|
396
396
|
metaMessages: [
|
|
@@ -426,24 +426,24 @@ const y = /* @__PURE__ */ new Z(8192);
|
|
|
426
426
|
function ee(s, e) {
|
|
427
427
|
if (y.has(`${s}.${e}`))
|
|
428
428
|
return y.get(`${s}.${e}`);
|
|
429
|
-
const n = s.substring(2).toLowerCase(), a =
|
|
429
|
+
const n = s.substring(2).toLowerCase(), a = $e(V(n)), o = n.split("");
|
|
430
430
|
for (let i = 0; i < 40; i += 2)
|
|
431
431
|
a[i >> 1] >> 4 >= 8 && o[i] && (o[i] = o[i].toUpperCase()), (a[i >> 1] & 15) >= 8 && o[i + 1] && (o[i + 1] = o[i + 1].toUpperCase());
|
|
432
432
|
const r = `0x${o.join("")}`;
|
|
433
433
|
return y.set(`${s}.${e}`, r), r;
|
|
434
434
|
}
|
|
435
435
|
function g(s, e) {
|
|
436
|
-
if (!
|
|
437
|
-
throw new
|
|
436
|
+
if (!je(s, { strict: !1 }))
|
|
437
|
+
throw new Le({ address: s });
|
|
438
438
|
return ee(s, e);
|
|
439
439
|
}
|
|
440
|
-
const _e = /^0x[a-fA-F0-9]{40}$/,
|
|
441
|
-
function
|
|
440
|
+
const _e = /^0x[a-fA-F0-9]{40}$/, R = /* @__PURE__ */ new Z(8192);
|
|
441
|
+
function je(s, e) {
|
|
442
442
|
const { strict: n = !0 } = e ?? {}, a = `${s}.${n}`;
|
|
443
|
-
if (
|
|
444
|
-
return
|
|
443
|
+
if (R.has(a))
|
|
444
|
+
return R.get(a);
|
|
445
445
|
const o = _e.test(s) ? s.toLowerCase() === s ? !0 : n ? ee(s) === s : !0 : !1;
|
|
446
|
-
return
|
|
446
|
+
return R.set(a, o), o;
|
|
447
447
|
}
|
|
448
448
|
const t = {
|
|
449
449
|
USDC: "USDC",
|
|
@@ -459,7 +459,7 @@ const t = {
|
|
|
459
459
|
};
|
|
460
460
|
t.USDC;
|
|
461
461
|
const f = {
|
|
462
|
-
[
|
|
462
|
+
[d.ARBITRUM]: {
|
|
463
463
|
[t.DAI]: {
|
|
464
464
|
address: g("0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1"),
|
|
465
465
|
symbol: t.DAI,
|
|
@@ -501,7 +501,7 @@ const f = {
|
|
|
501
501
|
nativeToken: !1
|
|
502
502
|
}
|
|
503
503
|
},
|
|
504
|
-
[
|
|
504
|
+
[d.ARBITRUM_TESTNET]: {
|
|
505
505
|
[t.USDC]: {
|
|
506
506
|
address: g("0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d"),
|
|
507
507
|
symbol: t.USDC,
|
|
@@ -513,7 +513,7 @@ const f = {
|
|
|
513
513
|
nativeToken: !1
|
|
514
514
|
}
|
|
515
515
|
},
|
|
516
|
-
[
|
|
516
|
+
[d.AVALANCHE]: {
|
|
517
517
|
[t.DAI]: {
|
|
518
518
|
address: "0xd586E7F844cEa2F87f50152665BCbc2C279D8d70",
|
|
519
519
|
symbol: t.DAI,
|
|
@@ -549,7 +549,7 @@ const f = {
|
|
|
549
549
|
nativeToken: !1
|
|
550
550
|
}
|
|
551
551
|
},
|
|
552
|
-
[
|
|
552
|
+
[d.AVALANCHE_TESTNET]: {
|
|
553
553
|
[t.USDC]: {
|
|
554
554
|
address: g("0x5425890298aed601595a70AB815c96711a31Bc65"),
|
|
555
555
|
symbol: t.USDC,
|
|
@@ -561,7 +561,7 @@ const f = {
|
|
|
561
561
|
nativeToken: !1
|
|
562
562
|
}
|
|
563
563
|
},
|
|
564
|
-
[
|
|
564
|
+
[d.BASE]: {
|
|
565
565
|
[t.DAI]: {
|
|
566
566
|
address: "0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb",
|
|
567
567
|
symbol: t.DAI,
|
|
@@ -605,7 +605,7 @@ const f = {
|
|
|
605
605
|
nativeToken: !1
|
|
606
606
|
}
|
|
607
607
|
},
|
|
608
|
-
[
|
|
608
|
+
[d.BASE_TESTNET]: {
|
|
609
609
|
[t.USDC]: {
|
|
610
610
|
address: g("0x036CbD53842c5426634e7929541eC2318f3dCF7e"),
|
|
611
611
|
symbol: t.USDC,
|
|
@@ -617,7 +617,7 @@ const f = {
|
|
|
617
617
|
nativeToken: !1
|
|
618
618
|
}
|
|
619
619
|
},
|
|
620
|
-
[
|
|
620
|
+
[d.BSC]: {
|
|
621
621
|
[t.BNB]: {
|
|
622
622
|
address: "0x0000000000000000000000000000000000000000",
|
|
623
623
|
symbol: t.BNB,
|
|
@@ -668,7 +668,7 @@ const f = {
|
|
|
668
668
|
nativeToken: !1
|
|
669
669
|
}
|
|
670
670
|
},
|
|
671
|
-
[
|
|
671
|
+
[d.ETHEREUM]: {
|
|
672
672
|
[t.BUSD]: {
|
|
673
673
|
address: "0x4Fabb145d64652a948d72533023f6E7A623C7C53",
|
|
674
674
|
symbol: t.BUSD,
|
|
@@ -735,7 +735,7 @@ const f = {
|
|
|
735
735
|
nativeToken: !1
|
|
736
736
|
}
|
|
737
737
|
},
|
|
738
|
-
[
|
|
738
|
+
[d.ETHEREUM_TESTNET]: {
|
|
739
739
|
[t.USDC]: {
|
|
740
740
|
address: g("0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238"),
|
|
741
741
|
symbol: t.USDC,
|
|
@@ -746,7 +746,7 @@ const f = {
|
|
|
746
746
|
nativeToken: !1
|
|
747
747
|
}
|
|
748
748
|
},
|
|
749
|
-
[
|
|
749
|
+
[d.HYPEREVM]: {
|
|
750
750
|
[t.USDC]: {
|
|
751
751
|
address: "0xb88339CB7199b77E23DB6E890353E22632Ba630f",
|
|
752
752
|
symbol: t.USDC,
|
|
@@ -756,7 +756,7 @@ const f = {
|
|
|
756
756
|
nativeToken: !1
|
|
757
757
|
}
|
|
758
758
|
},
|
|
759
|
-
[
|
|
759
|
+
[d.LISK]: {
|
|
760
760
|
[t.USDC]: {
|
|
761
761
|
address: "0xF242275d3a6527d877f2c927a82D9b057609cc71",
|
|
762
762
|
symbol: t.USDC,
|
|
@@ -766,7 +766,7 @@ const f = {
|
|
|
766
766
|
nativeToken: !1
|
|
767
767
|
}
|
|
768
768
|
},
|
|
769
|
-
[
|
|
769
|
+
[d.MONAD]: {
|
|
770
770
|
[t.USDC]: {
|
|
771
771
|
address: "0x754704Bc059F8C67012fEd69BC8A327a5aafb603",
|
|
772
772
|
symbol: t.USDC,
|
|
@@ -776,7 +776,7 @@ const f = {
|
|
|
776
776
|
nativeToken: !1
|
|
777
777
|
}
|
|
778
778
|
},
|
|
779
|
-
[
|
|
779
|
+
[d.MONAD_TESTNET]: {
|
|
780
780
|
[t.USDC]: {
|
|
781
781
|
address: "0x534b2f3A21130d7a60830c2Df862319e593943A3",
|
|
782
782
|
symbol: t.USDC,
|
|
@@ -786,7 +786,7 @@ const f = {
|
|
|
786
786
|
nativeToken: !1
|
|
787
787
|
}
|
|
788
788
|
},
|
|
789
|
-
[
|
|
789
|
+
[d.OPTIMISM]: {
|
|
790
790
|
[t.DAI]: {
|
|
791
791
|
address: "0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1",
|
|
792
792
|
symbol: t.DAI,
|
|
@@ -828,7 +828,7 @@ const f = {
|
|
|
828
828
|
nativeToken: !1
|
|
829
829
|
}
|
|
830
830
|
},
|
|
831
|
-
[
|
|
831
|
+
[d.OPTIMISM_TESTNET]: {
|
|
832
832
|
[t.USDC]: {
|
|
833
833
|
address: "0x5fd84259d66Cd46123540766Be93DFE6D43130D7",
|
|
834
834
|
symbol: t.USDC,
|
|
@@ -838,7 +838,7 @@ const f = {
|
|
|
838
838
|
nativeToken: !1
|
|
839
839
|
}
|
|
840
840
|
},
|
|
841
|
-
[
|
|
841
|
+
[d.POLYGON]: {
|
|
842
842
|
[t.DAI]: {
|
|
843
843
|
address: "0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063",
|
|
844
844
|
symbol: t.DAI,
|
|
@@ -872,7 +872,7 @@ const f = {
|
|
|
872
872
|
nativeToken: !1
|
|
873
873
|
}
|
|
874
874
|
},
|
|
875
|
-
[
|
|
875
|
+
[d.STARKNET]: {
|
|
876
876
|
[t.DAI]: {
|
|
877
877
|
address: "0x05574eb6b8789a91466f902c380d978e472db68170ff82a5b650b95a58ddf4ad",
|
|
878
878
|
symbol: t.DAI,
|
|
@@ -923,7 +923,7 @@ const f = {
|
|
|
923
923
|
nativeToken: !1
|
|
924
924
|
}
|
|
925
925
|
},
|
|
926
|
-
[
|
|
926
|
+
[d.STARKNET_TESTNET]: {
|
|
927
927
|
[t.USDC]: {
|
|
928
928
|
address: "0x0512feAc6339Ff7889822cb5aA2a86C848e9D392bB0E3E237C008674feeD8343",
|
|
929
929
|
symbol: t.USDC,
|
|
@@ -933,28 +933,28 @@ const f = {
|
|
|
933
933
|
nativeToken: !1
|
|
934
934
|
}
|
|
935
935
|
}
|
|
936
|
-
},
|
|
937
|
-
ARBITRUM: f[
|
|
938
|
-
ARBITRUM_TESTNET: f[
|
|
939
|
-
AVALANCHE: f[
|
|
940
|
-
AVALANCHE_TESTNET: f[
|
|
941
|
-
BASE: f[
|
|
942
|
-
BASE_TESTNET: f[
|
|
943
|
-
BSC: f[
|
|
944
|
-
ETHEREUM: f[
|
|
945
|
-
ETHEREUM_TESTNET: f[
|
|
946
|
-
STARKNET: f[
|
|
947
|
-
},
|
|
948
|
-
function
|
|
936
|
+
}, os = {
|
|
937
|
+
ARBITRUM: f[d.ARBITRUM],
|
|
938
|
+
ARBITRUM_TESTNET: f[d.ARBITRUM_TESTNET],
|
|
939
|
+
AVALANCHE: f[d.AVALANCHE],
|
|
940
|
+
AVALANCHE_TESTNET: f[d.AVALANCHE_TESTNET],
|
|
941
|
+
BASE: f[d.BASE],
|
|
942
|
+
BASE_TESTNET: f[d.BASE_TESTNET],
|
|
943
|
+
BSC: f[d.BSC],
|
|
944
|
+
ETHEREUM: f[d.ETHEREUM],
|
|
945
|
+
ETHEREUM_TESTNET: f[d.ETHEREUM_TESTNET],
|
|
946
|
+
STARKNET: f[d.STARKNET]
|
|
947
|
+
}, ze = new Set(Object.values(d));
|
|
948
|
+
function m(s) {
|
|
949
949
|
if (Ke(s))
|
|
950
950
|
return s;
|
|
951
|
-
const e =
|
|
951
|
+
const e = d[s];
|
|
952
952
|
if (!e)
|
|
953
953
|
throw new Error(`Invalid chain: ${s}. Chain must be a valid chain alias or internal chain value from Chains.`);
|
|
954
954
|
return e;
|
|
955
955
|
}
|
|
956
956
|
function Ke(s) {
|
|
957
|
-
return
|
|
957
|
+
return ze.has(s);
|
|
958
958
|
}
|
|
959
959
|
function We(s, e) {
|
|
960
960
|
const n = e.toLowerCase().trim(), a = f[s];
|
|
@@ -976,7 +976,7 @@ function We(s, e) {
|
|
|
976
976
|
);
|
|
977
977
|
return o;
|
|
978
978
|
}
|
|
979
|
-
function
|
|
979
|
+
function k(s, e, n) {
|
|
980
980
|
const a = We(s, e);
|
|
981
981
|
if (a.symbol !== n)
|
|
982
982
|
throw new Error(
|
|
@@ -991,42 +991,42 @@ function _(s, e) {
|
|
|
991
991
|
return Ve(s, e)?.address;
|
|
992
992
|
}
|
|
993
993
|
var se = /* @__PURE__ */ ((s) => (s.PRODUCTION = "production", s.STAGING = "staging", s))(se || {});
|
|
994
|
-
class
|
|
994
|
+
class u {
|
|
995
995
|
constructor({ api_key: e, env: n, seesion_token: a, props: o }) {
|
|
996
996
|
this.api_key = e || "", this.sessionToken = a || "", this.env = n ?? se.PRODUCTION, this.props = o;
|
|
997
997
|
}
|
|
998
998
|
static async config(e) {
|
|
999
|
-
if (!
|
|
999
|
+
if (!u.app) {
|
|
1000
1000
|
if (!e)
|
|
1001
1001
|
throw new Error("Please provide an api_key");
|
|
1002
|
-
|
|
1002
|
+
u.app = new u(e);
|
|
1003
1003
|
}
|
|
1004
|
-
return e && (e.api_key !== void 0 && (
|
|
1004
|
+
return e && (e.api_key !== void 0 && (u.app.api_key = e.api_key), e.seesion_token !== void 0 && (u.app.sessionToken = e.seesion_token), e.env !== void 0 && (u.app.env = e.env), e.props !== void 0 && (u.app.props = e.props)), u.app;
|
|
1005
1005
|
}
|
|
1006
1006
|
static getApiKey() {
|
|
1007
|
-
if (!
|
|
1007
|
+
if (!u.app)
|
|
1008
1008
|
throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
|
|
1009
|
-
return
|
|
1009
|
+
return u.app.api_key;
|
|
1010
1010
|
}
|
|
1011
1011
|
static getSessionToken() {
|
|
1012
|
-
if (!
|
|
1012
|
+
if (!u.app)
|
|
1013
1013
|
throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
|
|
1014
|
-
return
|
|
1014
|
+
return u.app.sessionToken;
|
|
1015
1015
|
}
|
|
1016
1016
|
static getProps() {
|
|
1017
|
-
if (!
|
|
1017
|
+
if (!u.app)
|
|
1018
1018
|
throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
|
|
1019
|
-
return
|
|
1019
|
+
return u.app.props;
|
|
1020
1020
|
}
|
|
1021
1021
|
static getEnv() {
|
|
1022
|
-
if (!
|
|
1022
|
+
if (!u.app)
|
|
1023
1023
|
throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
|
|
1024
|
-
return
|
|
1024
|
+
return u.app.env === "internal" ? "staging" : u.app.env;
|
|
1025
1025
|
}
|
|
1026
1026
|
static getBaseUrl() {
|
|
1027
|
-
if (!
|
|
1027
|
+
if (!u.app)
|
|
1028
1028
|
throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
|
|
1029
|
-
switch (
|
|
1029
|
+
switch (u.app.env) {
|
|
1030
1030
|
case "production":
|
|
1031
1031
|
return "https://api.chainrails.io/api/v1";
|
|
1032
1032
|
case "staging":
|
|
@@ -1038,23 +1038,23 @@ class l {
|
|
|
1038
1038
|
}
|
|
1039
1039
|
}
|
|
1040
1040
|
static getPayModalUrl(e) {
|
|
1041
|
-
if (!
|
|
1041
|
+
if (!u.app)
|
|
1042
1042
|
throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
|
|
1043
|
-
const n =
|
|
1043
|
+
const n = u.app.env === "internal" ? "https://chainrails-frontend-git-staging-horus-labs.vercel.app" : "https://app.chainrails.io", a = Number(e), o = e && !isNaN(Number(e)) && a > 0 ? "/pay/" : "/deposit/", r = `${e && !isNaN(Number(e)) && a > 0 ? a * 100 : ""}`;
|
|
1044
1044
|
return n + o + r;
|
|
1045
1045
|
}
|
|
1046
1046
|
}
|
|
1047
|
-
let
|
|
1048
|
-
function
|
|
1049
|
-
|
|
1050
|
-
prefixUrl:
|
|
1047
|
+
let N = null;
|
|
1048
|
+
function Ge() {
|
|
1049
|
+
N = ae.create({
|
|
1050
|
+
prefixUrl: u.getBaseUrl(),
|
|
1051
1051
|
headers: {
|
|
1052
1052
|
"Content-Type": "application/json"
|
|
1053
1053
|
},
|
|
1054
1054
|
hooks: {
|
|
1055
1055
|
beforeRequest: [
|
|
1056
1056
|
(s) => {
|
|
1057
|
-
const e =
|
|
1057
|
+
const e = u.getSessionToken() || u.getApiKey();
|
|
1058
1058
|
s.headers.set("Authorization", `Bearer ${e}`);
|
|
1059
1059
|
}
|
|
1060
1060
|
],
|
|
@@ -1065,28 +1065,28 @@ function Ye() {
|
|
|
1065
1065
|
}
|
|
1066
1066
|
});
|
|
1067
1067
|
}
|
|
1068
|
-
function
|
|
1069
|
-
return
|
|
1068
|
+
function c() {
|
|
1069
|
+
return N || Ge(), N;
|
|
1070
1070
|
}
|
|
1071
|
-
class
|
|
1071
|
+
class Ye {
|
|
1072
1072
|
async getById(e) {
|
|
1073
|
-
return await
|
|
1073
|
+
return await c().get("intents/" + e).json();
|
|
1074
1074
|
}
|
|
1075
1075
|
async getForSender(e) {
|
|
1076
|
-
return await
|
|
1076
|
+
return await c().get("intents/user/" + e).json();
|
|
1077
1077
|
}
|
|
1078
1078
|
async getForAddress(e) {
|
|
1079
|
-
return await
|
|
1079
|
+
return await c().get("intents/address/" + e).json();
|
|
1080
1080
|
}
|
|
1081
1081
|
async getForSession(e) {
|
|
1082
|
-
return await
|
|
1082
|
+
return await c().get("modal/sessions/intents/" + e).json();
|
|
1083
1083
|
}
|
|
1084
1084
|
async getAll(e) {
|
|
1085
|
-
return await
|
|
1085
|
+
return await c().get("intents", { searchParams: e }).json();
|
|
1086
1086
|
}
|
|
1087
1087
|
async create(e) {
|
|
1088
|
-
const n =
|
|
1089
|
-
return await
|
|
1088
|
+
const n = m(e.source_chain), a = m(e.destination_chain);
|
|
1089
|
+
return await c().post("intents", {
|
|
1090
1090
|
json: {
|
|
1091
1091
|
...e,
|
|
1092
1092
|
source_chain: n,
|
|
@@ -1095,27 +1095,27 @@ class Ge {
|
|
|
1095
1095
|
}).json();
|
|
1096
1096
|
}
|
|
1097
1097
|
async createForSession(e) {
|
|
1098
|
-
const n =
|
|
1099
|
-
return await
|
|
1098
|
+
const n = m(e.sourceChain);
|
|
1099
|
+
return await c().post("modal/sessions/intents", {
|
|
1100
1100
|
json: { ...e, sourceChain: n }
|
|
1101
1101
|
}).json();
|
|
1102
1102
|
}
|
|
1103
1103
|
async update(e, n) {
|
|
1104
|
-
return await
|
|
1104
|
+
return await c().post("intents", { json: n }).json();
|
|
1105
1105
|
}
|
|
1106
1106
|
async triggerProcessing(e) {
|
|
1107
|
-
return await
|
|
1107
|
+
return await c().post(`intents/${e}/trigger-processing`).json();
|
|
1108
1108
|
}
|
|
1109
1109
|
async triggerProcessingForSession(e) {
|
|
1110
|
-
return await
|
|
1110
|
+
return await c().post(`modal/sessions/intents/${e}/process`).json();
|
|
1111
1111
|
}
|
|
1112
1112
|
}
|
|
1113
1113
|
class qe {
|
|
1114
1114
|
async getFromSpecificBridge(e) {
|
|
1115
|
-
const n =
|
|
1116
|
-
|
|
1117
|
-
const a =
|
|
1118
|
-
return await
|
|
1115
|
+
const n = m(e.sourceChain);
|
|
1116
|
+
k(n, e.tokenIn, e.amountSymbol);
|
|
1117
|
+
const a = m(e.destinationChain);
|
|
1118
|
+
return await c().get("quotes/single", {
|
|
1119
1119
|
searchParams: {
|
|
1120
1120
|
...e,
|
|
1121
1121
|
sourceChain: n,
|
|
@@ -1124,10 +1124,10 @@ class qe {
|
|
|
1124
1124
|
}).json();
|
|
1125
1125
|
}
|
|
1126
1126
|
async getFromAllBridges(e) {
|
|
1127
|
-
const n =
|
|
1128
|
-
|
|
1129
|
-
const a =
|
|
1130
|
-
return await
|
|
1127
|
+
const n = m(e.sourceChain);
|
|
1128
|
+
k(n, e.tokenIn, e.amountSymbol);
|
|
1129
|
+
const a = m(e.destinationChain);
|
|
1130
|
+
return await c().get("quotes/multiple", {
|
|
1131
1131
|
searchParams: {
|
|
1132
1132
|
...e,
|
|
1133
1133
|
sourceChain: n,
|
|
@@ -1136,30 +1136,30 @@ class qe {
|
|
|
1136
1136
|
}).json();
|
|
1137
1137
|
}
|
|
1138
1138
|
async getBestAcrossBridges(e) {
|
|
1139
|
-
const n =
|
|
1140
|
-
|
|
1141
|
-
const a =
|
|
1142
|
-
return await
|
|
1139
|
+
const n = m(e.sourceChain);
|
|
1140
|
+
k(n, e.tokenIn, e.amountSymbol);
|
|
1141
|
+
const a = m(e.destinationChain);
|
|
1142
|
+
return await c().get("quotes/best", { searchParams: {
|
|
1143
1143
|
...e,
|
|
1144
1144
|
sourceChain: n,
|
|
1145
1145
|
destinationChain: a
|
|
1146
1146
|
} }).json();
|
|
1147
1147
|
}
|
|
1148
1148
|
async getAll(e) {
|
|
1149
|
-
const n =
|
|
1150
|
-
return await
|
|
1149
|
+
const n = m(e.destinationChain);
|
|
1150
|
+
return await c().get("quotes/multi-source", { searchParams: {
|
|
1151
1151
|
...e,
|
|
1152
1152
|
destinationChain: n
|
|
1153
1153
|
} }).json();
|
|
1154
1154
|
}
|
|
1155
1155
|
async getAllForSession(e) {
|
|
1156
|
-
return await
|
|
1156
|
+
return await c().get("modal/sessions/quotes", { searchParams: e }).json();
|
|
1157
1157
|
}
|
|
1158
1158
|
}
|
|
1159
1159
|
class Xe {
|
|
1160
1160
|
async getOptimalRoutes(e) {
|
|
1161
|
-
const n =
|
|
1162
|
-
return await
|
|
1161
|
+
const n = m(e.sourceChain), a = m(e.destinationChain);
|
|
1162
|
+
return await c().get("router/optimal-route", {
|
|
1163
1163
|
searchParams: {
|
|
1164
1164
|
...e,
|
|
1165
1165
|
sourceChain: n,
|
|
@@ -1168,76 +1168,160 @@ class Xe {
|
|
|
1168
1168
|
}).json();
|
|
1169
1169
|
}
|
|
1170
1170
|
async getAllSupportedBridges() {
|
|
1171
|
-
return await
|
|
1171
|
+
return await c().get("router/supported-bridges/all").json();
|
|
1172
1172
|
}
|
|
1173
1173
|
async getSupportedBridges(e) {
|
|
1174
|
-
const n =
|
|
1175
|
-
return await
|
|
1174
|
+
const n = m(e.sourceChain), a = m(e.destinationChain);
|
|
1175
|
+
return await c().get("router/supported-bridges/route", { searchParams: {
|
|
1176
1176
|
...e,
|
|
1177
1177
|
sourceChain: n,
|
|
1178
1178
|
destinationChain: a
|
|
1179
1179
|
} }).json();
|
|
1180
1180
|
}
|
|
1181
1181
|
async getSupportedRoutes(e) {
|
|
1182
|
-
return await
|
|
1182
|
+
return await c().get("router/supported-routes/bridge/" + e).json();
|
|
1183
1183
|
}
|
|
1184
1184
|
}
|
|
1185
1185
|
class Qe {
|
|
1186
1186
|
async getSupported(e) {
|
|
1187
|
-
return await
|
|
1187
|
+
return await c().get("chains", { searchParams: e }).json();
|
|
1188
1188
|
}
|
|
1189
1189
|
async getBalance(e) {
|
|
1190
|
-
return await
|
|
1190
|
+
return await c().get(`chains/balances/${e.address}`, { searchParams: e }).json();
|
|
1191
1191
|
}
|
|
1192
1192
|
}
|
|
1193
1193
|
class Je {
|
|
1194
1194
|
async getClientInfo() {
|
|
1195
|
-
return await
|
|
1195
|
+
return await c().get("client/auth/client-info").json();
|
|
1196
1196
|
}
|
|
1197
1197
|
async getClientInfoForSession() {
|
|
1198
|
-
return await
|
|
1198
|
+
return await c().get("modal/sessions/client").json();
|
|
1199
1199
|
}
|
|
1200
1200
|
}
|
|
1201
1201
|
class Ze {
|
|
1202
1202
|
async getSessionToken(e) {
|
|
1203
|
-
const n =
|
|
1203
|
+
const n = m(e.destinationChain);
|
|
1204
1204
|
let a = _(n, e.token);
|
|
1205
|
-
a || (console.error(
|
|
1205
|
+
a || (console.error(
|
|
1206
|
+
`${e.token} on ${e.destinationChain} is currently unsupported, defaulting to usdc`
|
|
1207
|
+
), a = _(n, "USDC"));
|
|
1206
1208
|
const o = {
|
|
1207
1209
|
recipient: e.recipient,
|
|
1208
1210
|
tokenOut: a,
|
|
1209
1211
|
destinationChain: n,
|
|
1210
1212
|
amount: e.amount
|
|
1211
1213
|
};
|
|
1212
|
-
return
|
|
1214
|
+
return c().post("modal/sessions", { json: o }).json().then((r) => ({ ...r, amount: o.amount }));
|
|
1215
|
+
}
|
|
1216
|
+
async getHandOffToken() {
|
|
1217
|
+
return c().post("modal/sessions/handoff-token").json();
|
|
1218
|
+
}
|
|
1219
|
+
async resumeSession(e) {
|
|
1220
|
+
return c().post(`modal/sessions/${e.sessionId}/resume`, { json: e }).json();
|
|
1213
1221
|
}
|
|
1214
1222
|
}
|
|
1215
1223
|
const es = "modal/sessions/history";
|
|
1216
1224
|
class ss {
|
|
1217
1225
|
async getHistoryForSession(e) {
|
|
1218
|
-
return
|
|
1226
|
+
return c().post(es, { json: e }).json();
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
const is = {
|
|
1230
|
+
FONBNK: "FONBNK",
|
|
1231
|
+
ONRAMP_MONEY: "ONRAMP_MONEY"
|
|
1232
|
+
}, rs = {
|
|
1233
|
+
PENDING: "PENDING",
|
|
1234
|
+
INITIATED: "INITIATED",
|
|
1235
|
+
PROCESSING: "PROCESSING",
|
|
1236
|
+
COMPLETED: "COMPLETED",
|
|
1237
|
+
FAILED: "FAILED",
|
|
1238
|
+
CANCELLED: "CANCELLED",
|
|
1239
|
+
EXPIRED: "EXPIRED",
|
|
1240
|
+
REFUNDED: "REFUNDED"
|
|
1241
|
+
};
|
|
1242
|
+
class ns {
|
|
1243
|
+
/**
|
|
1244
|
+
* Get aggregated fiat-to-crypto quotes from all eligible providers.
|
|
1245
|
+
* Fans out to multiple providers and picks the cheapest path.
|
|
1246
|
+
*/
|
|
1247
|
+
async getQuotes(e) {
|
|
1248
|
+
return await c().get("ramp/quotes", { searchParams: e }).json();
|
|
1249
|
+
}
|
|
1250
|
+
/**
|
|
1251
|
+
* Get all supported countries with currency details.
|
|
1252
|
+
* Use this as the primary discovery endpoint.
|
|
1253
|
+
*/
|
|
1254
|
+
async getCountries(e) {
|
|
1255
|
+
return await c().get("ramp/countries", { searchParams: e }).json();
|
|
1256
|
+
}
|
|
1257
|
+
/**
|
|
1258
|
+
* Get a deduplicated list of supported fiat currencies.
|
|
1259
|
+
* Useful for currency dropdowns.
|
|
1260
|
+
*/
|
|
1261
|
+
async getCurrencies(e) {
|
|
1262
|
+
return await c().get("ramp/currencies", { searchParams: e }).json();
|
|
1263
|
+
}
|
|
1264
|
+
/**
|
|
1265
|
+
* Create a fiat-to-crypto order.
|
|
1266
|
+
* Returns a provider widget URL for the user to complete payment.
|
|
1267
|
+
*/
|
|
1268
|
+
async createOrder(e) {
|
|
1269
|
+
return await c().post("ramp/orders", { json: e }).json();
|
|
1270
|
+
}
|
|
1271
|
+
/**
|
|
1272
|
+
* Get an order by ID.
|
|
1273
|
+
*/
|
|
1274
|
+
async getOrder(e) {
|
|
1275
|
+
return await c().get(`ramp/orders/${e}`).json();
|
|
1276
|
+
}
|
|
1277
|
+
/**
|
|
1278
|
+
* Get an order by intent address.
|
|
1279
|
+
*/
|
|
1280
|
+
async getOrderByIntent(e) {
|
|
1281
|
+
return await c().get(`ramp/orders/by-intent/${e}`).json();
|
|
1282
|
+
}
|
|
1283
|
+
/**
|
|
1284
|
+
* List all orders (newest first).
|
|
1285
|
+
*/
|
|
1286
|
+
async listOrders(e) {
|
|
1287
|
+
return await c().get("ramp/orders", { searchParams: e }).json();
|
|
1288
|
+
}
|
|
1289
|
+
/**
|
|
1290
|
+
* Confirm an order after the user completes the deposit action.
|
|
1291
|
+
*/
|
|
1292
|
+
async confirmOrder(e) {
|
|
1293
|
+
return await c().post(`ramp/orders/${e}/confirm`).json();
|
|
1294
|
+
}
|
|
1295
|
+
/**
|
|
1296
|
+
* Cancel an order if it's still in a cancellable state.
|
|
1297
|
+
*/
|
|
1298
|
+
async cancelOrder(e) {
|
|
1299
|
+
return await c().post(`ramp/orders/${e}/cancel`).json();
|
|
1219
1300
|
}
|
|
1220
1301
|
}
|
|
1221
|
-
const
|
|
1302
|
+
const cs = {
|
|
1222
1303
|
ACROSS: "ACROSS",
|
|
1223
1304
|
CCTP: "CCTP",
|
|
1224
1305
|
GATEWAY: "GATEWAY",
|
|
1225
1306
|
RHINOFI: "RHINOFI"
|
|
1226
|
-
},
|
|
1307
|
+
}, ds = {
|
|
1227
1308
|
router: new Xe(),
|
|
1228
1309
|
quotes: new qe(),
|
|
1229
|
-
intents: new
|
|
1310
|
+
intents: new Ye(),
|
|
1230
1311
|
chains: new Qe(),
|
|
1231
1312
|
client: new Je(),
|
|
1232
1313
|
auth: new Ze(),
|
|
1233
|
-
history: new ss()
|
|
1314
|
+
history: new ss(),
|
|
1315
|
+
ramp: new ns()
|
|
1234
1316
|
};
|
|
1235
1317
|
export {
|
|
1236
1318
|
t as AmountSymbols,
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
is as
|
|
1319
|
+
cs as Bridges,
|
|
1320
|
+
u as Chainrails,
|
|
1321
|
+
as as Chains,
|
|
1322
|
+
rs as RampOrderStatuses,
|
|
1323
|
+
is as RampProviders,
|
|
1324
|
+
os as Tokens,
|
|
1325
|
+
ds as crapi,
|
|
1242
1326
|
se as environment
|
|
1243
1327
|
};
|