@chainrails/sdk 0.2.9 → 0.2.10
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 +383 -298
- package/dist/chainrails-sdk.es.mjs +383 -298
- package/dist/chainrails-sdk.umd.js +2 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/src/Auth/index.d.ts.map +1 -1
- package/dist/src/Intents/index.d.ts.map +1 -1
- package/dist/src/Quotes/index.d.ts.map +1 -1
- package/dist/src/Router/index.d.ts.map +1 -1
- package/dist/src/Router/types.d.ts +4 -4
- package/dist/src/Router/types.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import ne from "ky";
|
|
2
2
|
const c = {
|
|
3
3
|
ARBITRUM: "ARBITRUM_MAINNET",
|
|
4
4
|
ARBITRUM_TESTNET: "ARBITRUM_TESTNET",
|
|
@@ -18,27 +18,46 @@ const c = {
|
|
|
18
18
|
POLYGON: "POLYGON_MAINNET",
|
|
19
19
|
STARKNET: "STARKNET_MAINNET",
|
|
20
20
|
STARKNET_TESTNET: "STARKNET_TESTNET"
|
|
21
|
+
}, ss = {
|
|
22
|
+
ARBITRUM: "ARBITRUM",
|
|
23
|
+
ARBITRUM_TESTNET: "ARBITRUM_TESTNET",
|
|
24
|
+
AVALANCHE: "AVALANCHE",
|
|
25
|
+
AVALANCHE_TESTNET: "AVALANCHE_TESTNET",
|
|
26
|
+
BASE: "BASE",
|
|
27
|
+
BASE_TESTNET: "BASE_TESTNET",
|
|
28
|
+
BSC: "BSC",
|
|
29
|
+
ETHEREUM: "ETHEREUM",
|
|
30
|
+
ETHEREUM_TESTNET: "ETHEREUM_TESTNET",
|
|
31
|
+
HYPEREVM: "HYPEREVM",
|
|
32
|
+
LISK: "LISK",
|
|
33
|
+
MONAD: "MONAD",
|
|
34
|
+
MONAD_TESTNET: "MONAD_TESTNET",
|
|
35
|
+
OPTIMISM: "OPTIMISM",
|
|
36
|
+
OPTIMISM_TESTNET: "OPTIMISM_TESTNET",
|
|
37
|
+
POLYGON: "POLYGON",
|
|
38
|
+
STARKNET: "STARKNET",
|
|
39
|
+
STARKNET_TESTNET: "STARKNET_TESTNET"
|
|
21
40
|
};
|
|
22
|
-
function
|
|
41
|
+
function N(s, { strict: e = !0 } = {}) {
|
|
23
42
|
return !s || typeof s != "string" ? !1 : e ? /^0x[0-9a-fA-F]*$/.test(s) : s.startsWith("0x");
|
|
24
43
|
}
|
|
25
|
-
function
|
|
26
|
-
return
|
|
44
|
+
function v(s) {
|
|
45
|
+
return N(s, { strict: !1 }) ? Math.ceil((s.length - 2) / 2) : s.length;
|
|
27
46
|
}
|
|
28
|
-
const
|
|
29
|
-
let
|
|
47
|
+
const L = "2.43.4";
|
|
48
|
+
let I = {
|
|
30
49
|
getDocsUrl: ({ docsBaseUrl: s, docsPath: e = "", docsSlug: t }) => e ? `${s ?? "https://viem.sh"}${e}${t ? `#${t}` : ""}` : void 0,
|
|
31
|
-
version: `viem@${
|
|
50
|
+
version: `viem@${L}`
|
|
32
51
|
};
|
|
33
52
|
class T extends Error {
|
|
34
53
|
constructor(e, t = {}) {
|
|
35
|
-
const
|
|
54
|
+
const a = t.cause instanceof T ? t.cause.details : t.cause?.message ? t.cause.message : t.details, o = t.cause instanceof T && t.cause.docsPath || t.docsPath, r = I.getDocsUrl?.({ ...t, docsPath: o }), i = [
|
|
36
55
|
e || "An error occurred.",
|
|
37
56
|
"",
|
|
38
57
|
...t.metaMessages ? [...t.metaMessages, ""] : [],
|
|
39
58
|
...r ? [`Docs: ${r}`] : [],
|
|
40
|
-
...
|
|
41
|
-
...
|
|
59
|
+
...a ? [`Details: ${a}`] : [],
|
|
60
|
+
...I.version ? [`Version: ${I.version}`] : []
|
|
42
61
|
].join(`
|
|
43
62
|
`);
|
|
44
63
|
super(i, t.cause ? { cause: t.cause } : void 0), Object.defineProperty(this, "details", {
|
|
@@ -71,95 +90,95 @@ class T extends Error {
|
|
|
71
90
|
configurable: !0,
|
|
72
91
|
writable: !0,
|
|
73
92
|
value: "BaseError"
|
|
74
|
-
}), this.details =
|
|
93
|
+
}), this.details = a, this.docsPath = o, this.metaMessages = t.metaMessages, this.name = t.name ?? this.name, this.shortMessage = e, this.version = L;
|
|
75
94
|
}
|
|
76
95
|
walk(e) {
|
|
77
|
-
return
|
|
96
|
+
return _(this, e);
|
|
78
97
|
}
|
|
79
98
|
}
|
|
80
|
-
function
|
|
81
|
-
return e?.(s) ? s : s && typeof s == "object" && "cause" in s && s.cause !== void 0 ?
|
|
99
|
+
function _(s, e) {
|
|
100
|
+
return e?.(s) ? s : s && typeof s == "object" && "cause" in s && s.cause !== void 0 ? _(s.cause, e) : e ? null : s;
|
|
82
101
|
}
|
|
83
|
-
class
|
|
84
|
-
constructor({ size: e, targetSize: t, type:
|
|
85
|
-
super(`${
|
|
102
|
+
class j extends T {
|
|
103
|
+
constructor({ size: e, targetSize: t, type: a }) {
|
|
104
|
+
super(`${a.charAt(0).toUpperCase()}${a.slice(1).toLowerCase()} size (${e}) exceeds padding size (${t}).`, { name: "SizeExceedsPaddingSizeError" });
|
|
86
105
|
}
|
|
87
106
|
}
|
|
88
|
-
function
|
|
89
|
-
return typeof s == "string" ?
|
|
107
|
+
function U(s, { dir: e, size: t = 32 } = {}) {
|
|
108
|
+
return typeof s == "string" ? ae(s, { dir: e, size: t }) : oe(s, { dir: e, size: t });
|
|
90
109
|
}
|
|
91
|
-
function
|
|
110
|
+
function ae(s, { dir: e, size: t = 32 } = {}) {
|
|
92
111
|
if (t === null)
|
|
93
112
|
return s;
|
|
94
|
-
const
|
|
95
|
-
if (
|
|
96
|
-
throw new
|
|
97
|
-
size: Math.ceil(
|
|
113
|
+
const a = s.replace("0x", "");
|
|
114
|
+
if (a.length > t * 2)
|
|
115
|
+
throw new j({
|
|
116
|
+
size: Math.ceil(a.length / 2),
|
|
98
117
|
targetSize: t,
|
|
99
118
|
type: "hex"
|
|
100
119
|
});
|
|
101
|
-
return `0x${
|
|
120
|
+
return `0x${a[e === "right" ? "padEnd" : "padStart"](t * 2, "0")}`;
|
|
102
121
|
}
|
|
103
122
|
function oe(s, { dir: e, size: t = 32 } = {}) {
|
|
104
123
|
if (t === null)
|
|
105
124
|
return s;
|
|
106
125
|
if (s.length > t)
|
|
107
|
-
throw new
|
|
126
|
+
throw new j({
|
|
108
127
|
size: s.length,
|
|
109
128
|
targetSize: t,
|
|
110
129
|
type: "bytes"
|
|
111
130
|
});
|
|
112
|
-
const
|
|
113
|
-
for (let
|
|
131
|
+
const a = new Uint8Array(t);
|
|
132
|
+
for (let o = 0; o < t; o++) {
|
|
114
133
|
const r = e === "right";
|
|
115
|
-
|
|
134
|
+
a[r ? o : t - o - 1] = s[r ? o : s.length - o - 1];
|
|
116
135
|
}
|
|
117
|
-
return
|
|
136
|
+
return a;
|
|
118
137
|
}
|
|
119
|
-
class
|
|
120
|
-
constructor({ max: e, min: t, signed:
|
|
121
|
-
super(`Number "${r}" is not in safe ${
|
|
138
|
+
class ie extends T {
|
|
139
|
+
constructor({ max: e, min: t, signed: a, size: o, value: r }) {
|
|
140
|
+
super(`Number "${r}" is not in safe ${o ? `${o * 8}-bit ${a ? "signed" : "unsigned"} ` : ""}integer range ${e ? `(${t} to ${e})` : `(above ${t})`}`, { name: "IntegerOutOfRangeError" });
|
|
122
141
|
}
|
|
123
142
|
}
|
|
124
|
-
class
|
|
143
|
+
class re extends T {
|
|
125
144
|
constructor({ givenSize: e, maxSize: t }) {
|
|
126
145
|
super(`Size cannot exceed ${t} bytes. Given size: ${e} bytes.`, { name: "SizeOverflowError" });
|
|
127
146
|
}
|
|
128
147
|
}
|
|
129
|
-
function
|
|
130
|
-
if (
|
|
131
|
-
throw new
|
|
132
|
-
givenSize:
|
|
148
|
+
function k(s, { size: e }) {
|
|
149
|
+
if (v(s) > e)
|
|
150
|
+
throw new re({
|
|
151
|
+
givenSize: v(s),
|
|
133
152
|
maxSize: e
|
|
134
153
|
});
|
|
135
154
|
}
|
|
136
|
-
function
|
|
137
|
-
const { signed: t, size:
|
|
155
|
+
function ce(s, e = {}) {
|
|
156
|
+
const { signed: t, size: a } = e, o = BigInt(s);
|
|
138
157
|
let r;
|
|
139
|
-
|
|
158
|
+
a ? t ? r = (1n << BigInt(a) * 8n - 1n) - 1n : r = 2n ** (BigInt(a) * 8n) - 1n : typeof s == "number" && (r = BigInt(Number.MAX_SAFE_INTEGER));
|
|
140
159
|
const i = typeof r == "bigint" && t ? -r - 1n : 0;
|
|
141
|
-
if (r &&
|
|
142
|
-
const
|
|
143
|
-
throw new
|
|
144
|
-
max: r ? `${r}${
|
|
145
|
-
min: `${i}${
|
|
160
|
+
if (r && o > r || o < i) {
|
|
161
|
+
const E = typeof s == "bigint" ? "n" : "";
|
|
162
|
+
throw new ie({
|
|
163
|
+
max: r ? `${r}${E}` : void 0,
|
|
164
|
+
min: `${i}${E}`,
|
|
146
165
|
signed: t,
|
|
147
|
-
size:
|
|
148
|
-
value: `${s}${
|
|
166
|
+
size: a,
|
|
167
|
+
value: `${s}${E}`
|
|
149
168
|
});
|
|
150
169
|
}
|
|
151
|
-
const
|
|
152
|
-
return
|
|
153
|
-
}
|
|
154
|
-
const ce = /* @__PURE__ */ new TextEncoder();
|
|
155
|
-
function de(s, e = {}) {
|
|
156
|
-
return typeof s == "number" || typeof s == "bigint" ? ue(s, e) : typeof s == "boolean" ? le(s, e) : B(s) ? j(s, e) : K(s, e);
|
|
170
|
+
const d = `0x${(t && o < 0 ? (1n << BigInt(a * 8)) + BigInt(o) : o).toString(16)}`;
|
|
171
|
+
return a ? U(d, { size: a }) : d;
|
|
157
172
|
}
|
|
173
|
+
const de = /* @__PURE__ */ new TextEncoder();
|
|
158
174
|
function le(s, e = {}) {
|
|
175
|
+
return typeof s == "number" || typeof s == "bigint" ? ge(s, e) : typeof s == "boolean" ? ue(s, e) : N(s) ? K(s, e) : W(s, e);
|
|
176
|
+
}
|
|
177
|
+
function ue(s, e = {}) {
|
|
159
178
|
const t = new Uint8Array(1);
|
|
160
|
-
return t[0] = Number(s), typeof e.size == "number" ? (
|
|
179
|
+
return t[0] = Number(s), typeof e.size == "number" ? (k(t, { size: e.size }), U(t, { size: e.size })) : t;
|
|
161
180
|
}
|
|
162
|
-
const
|
|
181
|
+
const f = {
|
|
163
182
|
zero: 48,
|
|
164
183
|
nine: 57,
|
|
165
184
|
A: 65,
|
|
@@ -167,72 +186,72 @@ const h = {
|
|
|
167
186
|
a: 97,
|
|
168
187
|
f: 102
|
|
169
188
|
};
|
|
170
|
-
function
|
|
171
|
-
if (s >=
|
|
172
|
-
return s -
|
|
173
|
-
if (s >=
|
|
174
|
-
return s - (
|
|
175
|
-
if (s >=
|
|
176
|
-
return s - (
|
|
189
|
+
function M(s) {
|
|
190
|
+
if (s >= f.zero && s <= f.nine)
|
|
191
|
+
return s - f.zero;
|
|
192
|
+
if (s >= f.A && s <= f.F)
|
|
193
|
+
return s - (f.A - 10);
|
|
194
|
+
if (s >= f.a && s <= f.f)
|
|
195
|
+
return s - (f.a - 10);
|
|
177
196
|
}
|
|
178
|
-
function
|
|
197
|
+
function K(s, e = {}) {
|
|
179
198
|
let t = s;
|
|
180
|
-
e.size && (
|
|
181
|
-
let
|
|
182
|
-
|
|
183
|
-
const
|
|
184
|
-
for (let i = 0,
|
|
185
|
-
const
|
|
186
|
-
if (
|
|
187
|
-
throw new T(`Invalid byte sequence ("${
|
|
188
|
-
r[i] =
|
|
199
|
+
e.size && (k(t, { size: e.size }), t = U(t, { dir: "right", size: e.size }));
|
|
200
|
+
let a = t.slice(2);
|
|
201
|
+
a.length % 2 && (a = `0${a}`);
|
|
202
|
+
const o = a.length / 2, r = new Uint8Array(o);
|
|
203
|
+
for (let i = 0, d = 0; i < o; i++) {
|
|
204
|
+
const E = M(a.charCodeAt(d++)), S = M(a.charCodeAt(d++));
|
|
205
|
+
if (E === void 0 || S === void 0)
|
|
206
|
+
throw new T(`Invalid byte sequence ("${a[d - 2]}${a[d - 1]}" in "${a}").`);
|
|
207
|
+
r[i] = E * 16 + S;
|
|
189
208
|
}
|
|
190
209
|
return r;
|
|
191
210
|
}
|
|
192
|
-
function
|
|
193
|
-
const t =
|
|
194
|
-
return
|
|
211
|
+
function ge(s, e) {
|
|
212
|
+
const t = ce(s, e);
|
|
213
|
+
return K(t);
|
|
195
214
|
}
|
|
196
|
-
function
|
|
197
|
-
const t =
|
|
198
|
-
return typeof e.size == "number" ? (
|
|
215
|
+
function W(s, e = {}) {
|
|
216
|
+
const t = de.encode(s);
|
|
217
|
+
return typeof e.size == "number" ? (k(t, { size: e.size }), U(t, { dir: "right", size: e.size })) : t;
|
|
199
218
|
}
|
|
200
|
-
const A = /* @__PURE__ */ BigInt(2 ** 32 - 1),
|
|
201
|
-
function
|
|
202
|
-
return e ? { h: Number(s & A), l: Number(s >>
|
|
219
|
+
const A = /* @__PURE__ */ BigInt(2 ** 32 - 1), O = /* @__PURE__ */ BigInt(32);
|
|
220
|
+
function he(s, e = !1) {
|
|
221
|
+
return e ? { h: Number(s & A), l: Number(s >> O & A) } : { h: Number(s >> O & A) | 0, l: Number(s & A) | 0 };
|
|
203
222
|
}
|
|
204
|
-
function
|
|
223
|
+
function me(s, e = !1) {
|
|
205
224
|
const t = s.length;
|
|
206
|
-
let
|
|
225
|
+
let a = new Uint32Array(t), o = new Uint32Array(t);
|
|
207
226
|
for (let r = 0; r < t; r++) {
|
|
208
|
-
const { h: i, l } =
|
|
209
|
-
[
|
|
227
|
+
const { h: i, l: d } = he(s[r], e);
|
|
228
|
+
[a[r], o[r]] = [i, d];
|
|
210
229
|
}
|
|
211
|
-
return [
|
|
230
|
+
return [a, o];
|
|
212
231
|
}
|
|
213
|
-
const
|
|
232
|
+
const Ee = (s, e, t) => s << t | e >>> 32 - t, fe = (s, e, t) => e << t | s >>> 32 - t, Te = (s, e, t) => e << t - 32 | s >>> 64 - t, Se = (s, e, t) => s << t - 32 | e >>> 64 - t;
|
|
214
233
|
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
215
|
-
function
|
|
234
|
+
function pe(s) {
|
|
216
235
|
return s instanceof Uint8Array || ArrayBuffer.isView(s) && s.constructor.name === "Uint8Array";
|
|
217
236
|
}
|
|
218
|
-
function
|
|
237
|
+
function F(s) {
|
|
219
238
|
if (!Number.isSafeInteger(s) || s < 0)
|
|
220
239
|
throw new Error("positive integer expected, got " + s);
|
|
221
240
|
}
|
|
222
|
-
function
|
|
223
|
-
if (!
|
|
241
|
+
function D(s, ...e) {
|
|
242
|
+
if (!pe(s))
|
|
224
243
|
throw new Error("Uint8Array expected");
|
|
225
244
|
if (e.length > 0 && !e.includes(s.length))
|
|
226
245
|
throw new Error("Uint8Array expected of length " + e + ", got length=" + s.length);
|
|
227
246
|
}
|
|
228
|
-
function
|
|
247
|
+
function H(s, e = !0) {
|
|
229
248
|
if (s.destroyed)
|
|
230
249
|
throw new Error("Hash instance has been destroyed");
|
|
231
250
|
if (e && s.finished)
|
|
232
251
|
throw new Error("Hash#digest() has already been called");
|
|
233
252
|
}
|
|
234
|
-
function
|
|
235
|
-
|
|
253
|
+
function Ce(s, e) {
|
|
254
|
+
D(s);
|
|
236
255
|
const t = e.outputLen;
|
|
237
256
|
if (s.length < t)
|
|
238
257
|
throw new Error("digestInto() expects output buffer of length at least " + t);
|
|
@@ -240,72 +259,72 @@ function pe(s, e) {
|
|
|
240
259
|
function be(s) {
|
|
241
260
|
return new Uint32Array(s.buffer, s.byteOffset, Math.floor(s.byteLength / 4));
|
|
242
261
|
}
|
|
243
|
-
function
|
|
262
|
+
function V(...s) {
|
|
244
263
|
for (let e = 0; e < s.length; e++)
|
|
245
264
|
s[e].fill(0);
|
|
246
265
|
}
|
|
247
266
|
const Ae = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
|
|
248
|
-
function
|
|
267
|
+
function De(s) {
|
|
249
268
|
return s << 24 & 4278190080 | s << 8 & 16711680 | s >>> 8 & 65280 | s >>> 24 & 255;
|
|
250
269
|
}
|
|
251
|
-
function
|
|
270
|
+
function Ue(s) {
|
|
252
271
|
for (let e = 0; e < s.length; e++)
|
|
253
|
-
s[e] =
|
|
272
|
+
s[e] = De(s[e]);
|
|
254
273
|
return s;
|
|
255
274
|
}
|
|
256
|
-
const
|
|
257
|
-
function
|
|
275
|
+
const P = Ae ? (s) => s : Ue;
|
|
276
|
+
function Ie(s) {
|
|
258
277
|
if (typeof s != "string")
|
|
259
278
|
throw new Error("string expected");
|
|
260
279
|
return new Uint8Array(new TextEncoder().encode(s));
|
|
261
280
|
}
|
|
262
|
-
function
|
|
263
|
-
return typeof s == "string" && (s =
|
|
281
|
+
function Y(s) {
|
|
282
|
+
return typeof s == "string" && (s = Ie(s)), D(s), s;
|
|
264
283
|
}
|
|
265
|
-
class
|
|
284
|
+
class ye {
|
|
266
285
|
}
|
|
267
|
-
function
|
|
268
|
-
const e = (
|
|
286
|
+
function Re(s) {
|
|
287
|
+
const e = (a) => s().update(Y(a)).digest(), t = s();
|
|
269
288
|
return e.outputLen = t.outputLen, e.blockLen = t.blockLen, e.create = () => s(), e;
|
|
270
289
|
}
|
|
271
|
-
const
|
|
272
|
-
for (let s = 0, e =
|
|
273
|
-
[t,
|
|
274
|
-
let
|
|
290
|
+
const we = BigInt(0), C = BigInt(1), Be = BigInt(2), Ne = BigInt(7), ke = BigInt(256), xe = BigInt(113), G = [], q = [], X = [];
|
|
291
|
+
for (let s = 0, e = C, t = 1, a = 0; s < 24; s++) {
|
|
292
|
+
[t, a] = [a, (2 * t + 3 * a) % 5], G.push(2 * (5 * a + t)), q.push((s + 1) * (s + 2) / 2 % 64);
|
|
293
|
+
let o = we;
|
|
275
294
|
for (let r = 0; r < 7; r++)
|
|
276
|
-
e = (e <<
|
|
277
|
-
|
|
295
|
+
e = (e << C ^ (e >> Ne) * xe) % ke, e & Be && (o ^= C << (C << /* @__PURE__ */ BigInt(r)) - C);
|
|
296
|
+
X.push(o);
|
|
278
297
|
}
|
|
279
|
-
const
|
|
280
|
-
function
|
|
298
|
+
const Q = me(X, !0), ve = Q[0], Me = Q[1], $ = (s, e, t) => t > 32 ? Te(s, e, t) : Ee(s, e, t), z = (s, e, t) => t > 32 ? Se(s, e, t) : fe(s, e, t);
|
|
299
|
+
function Oe(s, e = 24) {
|
|
281
300
|
const t = new Uint32Array(10);
|
|
282
|
-
for (let
|
|
301
|
+
for (let a = 24 - e; a < 24; a++) {
|
|
283
302
|
for (let i = 0; i < 10; i++)
|
|
284
303
|
t[i] = s[i] ^ s[i + 10] ^ s[i + 20] ^ s[i + 30] ^ s[i + 40];
|
|
285
304
|
for (let i = 0; i < 10; i += 2) {
|
|
286
|
-
const
|
|
305
|
+
const d = (i + 8) % 10, E = (i + 2) % 10, S = t[E], p = t[E + 1], se = $(S, p, 1) ^ t[d], te = z(S, p, 1) ^ t[d + 1];
|
|
287
306
|
for (let b = 0; b < 50; b += 10)
|
|
288
|
-
s[i + b] ^=
|
|
307
|
+
s[i + b] ^= se, s[i + b + 1] ^= te;
|
|
289
308
|
}
|
|
290
|
-
let
|
|
309
|
+
let o = s[2], r = s[3];
|
|
291
310
|
for (let i = 0; i < 24; i++) {
|
|
292
|
-
const
|
|
293
|
-
|
|
311
|
+
const d = q[i], E = $(o, r, d), S = z(o, r, d), p = G[i];
|
|
312
|
+
o = s[p], r = s[p + 1], s[p] = E, s[p + 1] = S;
|
|
294
313
|
}
|
|
295
314
|
for (let i = 0; i < 50; i += 10) {
|
|
296
|
-
for (let
|
|
297
|
-
t[
|
|
298
|
-
for (let
|
|
299
|
-
s[i +
|
|
315
|
+
for (let d = 0; d < 10; d++)
|
|
316
|
+
t[d] = s[i + d];
|
|
317
|
+
for (let d = 0; d < 10; d++)
|
|
318
|
+
s[i + d] ^= ~t[(d + 2) % 10] & t[(d + 4) % 10];
|
|
300
319
|
}
|
|
301
|
-
s[0] ^=
|
|
320
|
+
s[0] ^= ve[a], s[1] ^= Me[a];
|
|
302
321
|
}
|
|
303
|
-
|
|
322
|
+
V(t);
|
|
304
323
|
}
|
|
305
|
-
class
|
|
324
|
+
class x extends ye {
|
|
306
325
|
// NOTE: we accept arguments in bytes instead of bits here.
|
|
307
|
-
constructor(e, t,
|
|
308
|
-
if (super(), this.pos = 0, this.posOut = 0, this.finished = !1, this.destroyed = !1, this.enableXOF = !1, this.blockLen = e, this.suffix = t, this.outputLen =
|
|
326
|
+
constructor(e, t, a, o = !1, r = 24) {
|
|
327
|
+
if (super(), this.pos = 0, this.posOut = 0, this.finished = !1, this.destroyed = !1, this.enableXOF = !1, this.blockLen = e, this.suffix = t, this.outputLen = a, this.enableXOF = o, this.rounds = r, F(a), !(0 < e && e < 200))
|
|
309
328
|
throw new Error("only keccak-f1600 function is supported");
|
|
310
329
|
this.state = new Uint8Array(200), this.state32 = be(this.state);
|
|
311
330
|
}
|
|
@@ -313,15 +332,15 @@ class k extends Ie {
|
|
|
313
332
|
return this._cloneInto();
|
|
314
333
|
}
|
|
315
334
|
keccak() {
|
|
316
|
-
|
|
335
|
+
P(this.state32), Oe(this.state32, this.rounds), P(this.state32), this.posOut = 0, this.pos = 0;
|
|
317
336
|
}
|
|
318
337
|
update(e) {
|
|
319
|
-
|
|
320
|
-
const { blockLen: t, state:
|
|
321
|
-
for (let r = 0; r <
|
|
322
|
-
const i = Math.min(t - this.pos,
|
|
323
|
-
for (let
|
|
324
|
-
|
|
338
|
+
H(this), e = Y(e), D(e);
|
|
339
|
+
const { blockLen: t, state: a } = this, o = e.length;
|
|
340
|
+
for (let r = 0; r < o; ) {
|
|
341
|
+
const i = Math.min(t - this.pos, o - r);
|
|
342
|
+
for (let d = 0; d < i; d++)
|
|
343
|
+
a[this.pos++] ^= e[r++];
|
|
325
344
|
this.pos === t && this.keccak();
|
|
326
345
|
}
|
|
327
346
|
return this;
|
|
@@ -330,16 +349,16 @@ class k extends Ie {
|
|
|
330
349
|
if (this.finished)
|
|
331
350
|
return;
|
|
332
351
|
this.finished = !0;
|
|
333
|
-
const { state: e, suffix: t, pos:
|
|
334
|
-
e[
|
|
352
|
+
const { state: e, suffix: t, pos: a, blockLen: o } = this;
|
|
353
|
+
e[a] ^= t, (t & 128) !== 0 && a === o - 1 && this.keccak(), e[o - 1] ^= 128, this.keccak();
|
|
335
354
|
}
|
|
336
355
|
writeInto(e) {
|
|
337
|
-
|
|
338
|
-
const t = this.state, { blockLen:
|
|
339
|
-
for (let
|
|
340
|
-
this.posOut >=
|
|
341
|
-
const i = Math.min(
|
|
342
|
-
e.set(t.subarray(this.posOut, this.posOut + i),
|
|
356
|
+
H(this, !1), D(e), this.finish();
|
|
357
|
+
const t = this.state, { blockLen: a } = this;
|
|
358
|
+
for (let o = 0, r = e.length; o < r; ) {
|
|
359
|
+
this.posOut >= a && this.keccak();
|
|
360
|
+
const i = Math.min(a - this.posOut, r - o);
|
|
361
|
+
e.set(t.subarray(this.posOut, this.posOut + i), o), this.posOut += i, o += i;
|
|
343
362
|
}
|
|
344
363
|
return e;
|
|
345
364
|
}
|
|
@@ -349,10 +368,10 @@ class k extends Ie {
|
|
|
349
368
|
return this.writeInto(e);
|
|
350
369
|
}
|
|
351
370
|
xof(e) {
|
|
352
|
-
return
|
|
371
|
+
return F(e), this.xofInto(new Uint8Array(e));
|
|
353
372
|
}
|
|
354
373
|
digestInto(e) {
|
|
355
|
-
if (
|
|
374
|
+
if (Ce(e, this), this.finished)
|
|
356
375
|
throw new Error("digest() was already called");
|
|
357
376
|
return this.writeInto(e), this.destroy(), e;
|
|
358
377
|
}
|
|
@@ -360,18 +379,18 @@ class k extends Ie {
|
|
|
360
379
|
return this.digestInto(new Uint8Array(this.outputLen));
|
|
361
380
|
}
|
|
362
381
|
destroy() {
|
|
363
|
-
this.destroyed = !0,
|
|
382
|
+
this.destroyed = !0, V(this.state);
|
|
364
383
|
}
|
|
365
384
|
_cloneInto(e) {
|
|
366
|
-
const { blockLen: t, suffix:
|
|
367
|
-
return e || (e = new
|
|
385
|
+
const { blockLen: t, suffix: a, outputLen: o, rounds: r, enableXOF: i } = this;
|
|
386
|
+
return e || (e = new x(t, 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;
|
|
368
387
|
}
|
|
369
388
|
}
|
|
370
|
-
const
|
|
371
|
-
function
|
|
372
|
-
return
|
|
389
|
+
const Fe = (s, e, t) => Re(() => new x(e, s, t)), He = Fe(1, 136, 256 / 8);
|
|
390
|
+
function Pe(s, e) {
|
|
391
|
+
return He(N(s, { strict: !1 }) ? le(s) : s);
|
|
373
392
|
}
|
|
374
|
-
class
|
|
393
|
+
class $e extends T {
|
|
375
394
|
constructor({ address: e }) {
|
|
376
395
|
super(`Address "${e}" is invalid.`, {
|
|
377
396
|
metaMessages: [
|
|
@@ -382,7 +401,7 @@ class Pe extends T {
|
|
|
382
401
|
});
|
|
383
402
|
}
|
|
384
403
|
}
|
|
385
|
-
class
|
|
404
|
+
class J extends Map {
|
|
386
405
|
constructor(e) {
|
|
387
406
|
super(), Object.defineProperty(this, "maxSize", {
|
|
388
407
|
enumerable: !0,
|
|
@@ -397,34 +416,34 @@ class Q extends Map {
|
|
|
397
416
|
}
|
|
398
417
|
set(e, t) {
|
|
399
418
|
if (super.set(e, t), this.maxSize && this.size > this.maxSize) {
|
|
400
|
-
const
|
|
401
|
-
|
|
419
|
+
const a = this.keys().next().value;
|
|
420
|
+
a && this.delete(a);
|
|
402
421
|
}
|
|
403
422
|
return this;
|
|
404
423
|
}
|
|
405
424
|
}
|
|
406
|
-
const
|
|
407
|
-
function
|
|
408
|
-
if (
|
|
409
|
-
return
|
|
410
|
-
const t = s.substring(2).toLowerCase(),
|
|
425
|
+
const y = /* @__PURE__ */ new J(8192);
|
|
426
|
+
function Z(s, e) {
|
|
427
|
+
if (y.has(`${s}.${e}`))
|
|
428
|
+
return y.get(`${s}.${e}`);
|
|
429
|
+
const t = s.substring(2).toLowerCase(), a = Pe(W(t)), o = t.split("");
|
|
411
430
|
for (let i = 0; i < 40; i += 2)
|
|
412
|
-
|
|
413
|
-
const r = `0x${
|
|
414
|
-
return
|
|
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
|
+
const r = `0x${o.join("")}`;
|
|
433
|
+
return y.set(`${s}.${e}`, r), r;
|
|
415
434
|
}
|
|
416
|
-
function
|
|
417
|
-
if (
|
|
418
|
-
throw new
|
|
419
|
-
return
|
|
435
|
+
function h(s, e) {
|
|
436
|
+
if (!Le(s, { strict: !1 }))
|
|
437
|
+
throw new $e({ address: s });
|
|
438
|
+
return Z(s, e);
|
|
420
439
|
}
|
|
421
|
-
const
|
|
422
|
-
function
|
|
423
|
-
const { strict: t = !0 } = e ?? {},
|
|
424
|
-
if (
|
|
425
|
-
return
|
|
426
|
-
const
|
|
427
|
-
return
|
|
440
|
+
const ze = /^0x[a-fA-F0-9]{40}$/, R = /* @__PURE__ */ new J(8192);
|
|
441
|
+
function Le(s, e) {
|
|
442
|
+
const { strict: t = !0 } = e ?? {}, a = `${s}.${t}`;
|
|
443
|
+
if (R.has(a))
|
|
444
|
+
return R.get(a);
|
|
445
|
+
const o = ze.test(s) ? s.toLowerCase() === s ? !0 : t ? Z(s) === s : !0 : !1;
|
|
446
|
+
return R.set(a, o), o;
|
|
428
447
|
}
|
|
429
448
|
const n = {
|
|
430
449
|
USDC: "USDC",
|
|
@@ -439,10 +458,10 @@ const n = {
|
|
|
439
458
|
LORDS: "LORDS"
|
|
440
459
|
};
|
|
441
460
|
n.USDC;
|
|
442
|
-
const
|
|
461
|
+
const m = {
|
|
443
462
|
[c.ARBITRUM]: {
|
|
444
463
|
[n.DAI]: {
|
|
445
|
-
address:
|
|
464
|
+
address: h("0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1"),
|
|
446
465
|
symbol: n.DAI,
|
|
447
466
|
name: "Dai Stablecoin",
|
|
448
467
|
decimals: 18,
|
|
@@ -458,7 +477,7 @@ const d = {
|
|
|
458
477
|
/* ETH */
|
|
459
478
|
},
|
|
460
479
|
[n.USDC]: {
|
|
461
|
-
address:
|
|
480
|
+
address: h("0xaf88d065e77c8cC2239327C5EDb3A432268e5831"),
|
|
462
481
|
symbol: n.USDC,
|
|
463
482
|
name: "USD Coin",
|
|
464
483
|
decimals: 6,
|
|
@@ -466,7 +485,7 @@ const d = {
|
|
|
466
485
|
/* USDC */
|
|
467
486
|
},
|
|
468
487
|
[n.USDT]: {
|
|
469
|
-
address:
|
|
488
|
+
address: h("0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9"),
|
|
470
489
|
symbol: n.USDT,
|
|
471
490
|
name: "Tether USD",
|
|
472
491
|
decimals: 6,
|
|
@@ -474,7 +493,7 @@ const d = {
|
|
|
474
493
|
/* USDT */
|
|
475
494
|
},
|
|
476
495
|
[n.WETH]: {
|
|
477
|
-
address:
|
|
496
|
+
address: h("0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"),
|
|
478
497
|
symbol: n.WETH,
|
|
479
498
|
name: "Wrapped Ether",
|
|
480
499
|
decimals: 18,
|
|
@@ -484,7 +503,7 @@ const d = {
|
|
|
484
503
|
},
|
|
485
504
|
[c.ARBITRUM_TESTNET]: {
|
|
486
505
|
[n.USDC]: {
|
|
487
|
-
address:
|
|
506
|
+
address: h("0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d"),
|
|
488
507
|
symbol: n.USDC,
|
|
489
508
|
name: "USD Coin",
|
|
490
509
|
fiatISO: "USD",
|
|
@@ -503,7 +522,7 @@ const d = {
|
|
|
503
522
|
/* DAI */
|
|
504
523
|
},
|
|
505
524
|
[n.USDC]: {
|
|
506
|
-
address:
|
|
525
|
+
address: h("0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E"),
|
|
507
526
|
symbol: n.USDC,
|
|
508
527
|
name: "USD Coin",
|
|
509
528
|
fiatISO: "USD",
|
|
@@ -530,7 +549,7 @@ const d = {
|
|
|
530
549
|
},
|
|
531
550
|
[c.AVALANCHE_TESTNET]: {
|
|
532
551
|
[n.USDC]: {
|
|
533
|
-
address:
|
|
552
|
+
address: h("0x5425890298aed601595a70AB815c96711a31Bc65"),
|
|
534
553
|
symbol: n.USDC,
|
|
535
554
|
name: "USD Coin",
|
|
536
555
|
fiatISO: "USD",
|
|
@@ -565,7 +584,7 @@ const d = {
|
|
|
565
584
|
/* EURC */
|
|
566
585
|
},
|
|
567
586
|
[n.USDC]: {
|
|
568
|
-
address:
|
|
587
|
+
address: h("0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"),
|
|
569
588
|
symbol: n.USDC,
|
|
570
589
|
name: "USD Coin",
|
|
571
590
|
fiatISO: "USD",
|
|
@@ -574,7 +593,7 @@ const d = {
|
|
|
574
593
|
logoSourceURI: "https://pay.daimo.com/coin-logos/usdc.png"
|
|
575
594
|
},
|
|
576
595
|
[n.WETH]: {
|
|
577
|
-
address:
|
|
596
|
+
address: h("0x4200000000000000000000000000000000000006"),
|
|
578
597
|
symbol: n.WETH,
|
|
579
598
|
name: "Wrapped Ether",
|
|
580
599
|
decimals: 18,
|
|
@@ -584,7 +603,7 @@ const d = {
|
|
|
584
603
|
},
|
|
585
604
|
[c.BASE_TESTNET]: {
|
|
586
605
|
[n.USDC]: {
|
|
587
|
-
address:
|
|
606
|
+
address: h("0x036CbD53842c5426634e7929541eC2318f3dCF7e"),
|
|
588
607
|
symbol: n.USDC,
|
|
589
608
|
name: "USD Coin",
|
|
590
609
|
fiatISO: "USD",
|
|
@@ -627,7 +646,7 @@ const d = {
|
|
|
627
646
|
/* ETH */
|
|
628
647
|
},
|
|
629
648
|
[n.USDC]: {
|
|
630
|
-
address:
|
|
649
|
+
address: h("0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"),
|
|
631
650
|
symbol: n.USDC,
|
|
632
651
|
decimals: 18,
|
|
633
652
|
name: "USD Coin",
|
|
@@ -653,7 +672,7 @@ const d = {
|
|
|
653
672
|
/* BUSD */
|
|
654
673
|
},
|
|
655
674
|
[n.DAI]: {
|
|
656
|
-
address:
|
|
675
|
+
address: h("0x6B175474E89094C44Da98b954EedeAC495271d0F"),
|
|
657
676
|
symbol: n.DAI,
|
|
658
677
|
name: "Dai Stablecoin",
|
|
659
678
|
decimals: 18,
|
|
@@ -685,7 +704,7 @@ const d = {
|
|
|
685
704
|
/* STRK */
|
|
686
705
|
},
|
|
687
706
|
[n.USDC]: {
|
|
688
|
-
address:
|
|
707
|
+
address: h("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"),
|
|
689
708
|
symbol: n.USDC,
|
|
690
709
|
name: "USD Coin",
|
|
691
710
|
decimals: 6,
|
|
@@ -693,7 +712,7 @@ const d = {
|
|
|
693
712
|
logoSourceURI: "https://pay.daimo.com/coin-logos/usdc.png"
|
|
694
713
|
},
|
|
695
714
|
[n.USDT]: {
|
|
696
|
-
address:
|
|
715
|
+
address: h("0xdAC17F958D2ee523a2206206994597C13D831ec7"),
|
|
697
716
|
symbol: n.USDT,
|
|
698
717
|
name: "Tether USD",
|
|
699
718
|
decimals: 6,
|
|
@@ -701,7 +720,7 @@ const d = {
|
|
|
701
720
|
/* USDT */
|
|
702
721
|
},
|
|
703
722
|
[n.WETH]: {
|
|
704
|
-
address:
|
|
723
|
+
address: h("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"),
|
|
705
724
|
symbol: n.WETH,
|
|
706
725
|
name: "Wrapped Ether",
|
|
707
726
|
decimals: 18,
|
|
@@ -711,7 +730,7 @@ const d = {
|
|
|
711
730
|
},
|
|
712
731
|
[c.ETHEREUM_TESTNET]: {
|
|
713
732
|
[n.USDC]: {
|
|
714
|
-
address:
|
|
733
|
+
address: h("0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238"),
|
|
715
734
|
symbol: n.USDC,
|
|
716
735
|
decimals: 6,
|
|
717
736
|
name: "USD Coin",
|
|
@@ -905,90 +924,100 @@ const d = {
|
|
|
905
924
|
/* USDC */
|
|
906
925
|
}
|
|
907
926
|
}
|
|
908
|
-
},
|
|
909
|
-
ARBITRUM:
|
|
910
|
-
ARBITRUM_TESTNET:
|
|
911
|
-
AVALANCHE:
|
|
912
|
-
AVALANCHE_TESTNET:
|
|
913
|
-
BASE:
|
|
914
|
-
BASE_TESTNET:
|
|
915
|
-
BSC:
|
|
916
|
-
ETHEREUM:
|
|
917
|
-
ETHEREUM_TESTNET:
|
|
918
|
-
STARKNET:
|
|
919
|
-
};
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
927
|
+
}, ts = {
|
|
928
|
+
ARBITRUM: m[c.ARBITRUM],
|
|
929
|
+
ARBITRUM_TESTNET: m[c.ARBITRUM_TESTNET],
|
|
930
|
+
AVALANCHE: m[c.AVALANCHE],
|
|
931
|
+
AVALANCHE_TESTNET: m[c.AVALANCHE_TESTNET],
|
|
932
|
+
BASE: m[c.BASE],
|
|
933
|
+
BASE_TESTNET: m[c.BASE_TESTNET],
|
|
934
|
+
BSC: m[c.BSC],
|
|
935
|
+
ETHEREUM: m[c.ETHEREUM],
|
|
936
|
+
ETHEREUM_TESTNET: m[c.ETHEREUM_TESTNET],
|
|
937
|
+
STARKNET: m[c.STARKNET]
|
|
938
|
+
}, _e = new Set(Object.values(c));
|
|
939
|
+
function g(s) {
|
|
940
|
+
if (je(s))
|
|
941
|
+
return s;
|
|
942
|
+
const e = c[s];
|
|
943
|
+
if (!e)
|
|
944
|
+
throw new Error(`Invalid chain: ${s}. Chain must be a valid chain alias or internal chain value from Chains.`);
|
|
945
|
+
return e;
|
|
946
|
+
}
|
|
947
|
+
function je(s) {
|
|
948
|
+
return _e.has(s);
|
|
949
|
+
}
|
|
950
|
+
function Ke(s, e) {
|
|
951
|
+
const t = e.toLowerCase().trim(), a = m[s];
|
|
952
|
+
if (!a)
|
|
924
953
|
throw new Error(
|
|
925
954
|
`Chain not found: ${s}. The chain key must be a valid chain identifier.`
|
|
926
955
|
);
|
|
927
|
-
let
|
|
928
|
-
for (const r in
|
|
929
|
-
const i =
|
|
956
|
+
let o;
|
|
957
|
+
for (const r in a) {
|
|
958
|
+
const i = a[r];
|
|
930
959
|
if (i && i.address.toLowerCase() === t.toLowerCase()) {
|
|
931
|
-
|
|
960
|
+
o = i;
|
|
932
961
|
break;
|
|
933
962
|
}
|
|
934
963
|
}
|
|
935
|
-
if (!
|
|
964
|
+
if (!o)
|
|
936
965
|
throw new Error(
|
|
937
966
|
`Token address mismatch: address ${e} does not exist on chain ${s}. The token address must be a valid token address on the specified chain.`
|
|
938
967
|
);
|
|
939
|
-
return
|
|
968
|
+
return o;
|
|
940
969
|
}
|
|
941
|
-
function
|
|
942
|
-
const
|
|
943
|
-
if (
|
|
970
|
+
function w(s, e, t) {
|
|
971
|
+
const a = Ke(s, e);
|
|
972
|
+
if (a.symbol !== t)
|
|
944
973
|
throw new Error(
|
|
945
|
-
`Token address and symbol mismatch: address ${e} on chain ${s} corresponds to token "${
|
|
974
|
+
`Token address and symbol mismatch: address ${e} on chain ${s} corresponds to token "${a.symbol}", but expected "${t}". The token address must correspond to a token with the expected symbol on the specified chain.`
|
|
946
975
|
);
|
|
947
|
-
return
|
|
976
|
+
return a;
|
|
948
977
|
}
|
|
949
|
-
function
|
|
950
|
-
return
|
|
978
|
+
function We(s, e) {
|
|
979
|
+
return m[s]?.[e];
|
|
951
980
|
}
|
|
952
|
-
function
|
|
953
|
-
return
|
|
981
|
+
function Ve(s, e) {
|
|
982
|
+
return We(s, e)?.address;
|
|
954
983
|
}
|
|
955
|
-
var
|
|
956
|
-
class
|
|
957
|
-
constructor({ api_key: e, env: t, seesion_token:
|
|
958
|
-
this.api_key = e || "", this.sessionToken =
|
|
984
|
+
var ee = /* @__PURE__ */ ((s) => (s.PRODUCTION = "production", s.STAGING = "staging", s))(ee || {});
|
|
985
|
+
class l {
|
|
986
|
+
constructor({ api_key: e, env: t, seesion_token: a, props: o }) {
|
|
987
|
+
this.api_key = e || "", this.sessionToken = a || "", this.env = t ?? ee.PRODUCTION, this.props = o;
|
|
959
988
|
}
|
|
960
989
|
static async config(e) {
|
|
961
|
-
if (!
|
|
990
|
+
if (!l.app) {
|
|
962
991
|
if (!e)
|
|
963
992
|
throw new Error("Please provide an api_key");
|
|
964
|
-
|
|
993
|
+
l.app = new l(e);
|
|
965
994
|
}
|
|
966
|
-
return e && (e.api_key !== void 0 && (
|
|
995
|
+
return e && (e.api_key !== void 0 && (l.app.api_key = e.api_key), e.seesion_token !== void 0 && (l.app.sessionToken = e.seesion_token), e.env !== void 0 && (l.app.env = e.env), e.props !== void 0 && (l.app.props = e.props)), l.app;
|
|
967
996
|
}
|
|
968
997
|
static getApiKey() {
|
|
969
|
-
if (!
|
|
998
|
+
if (!l.app)
|
|
970
999
|
throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
|
|
971
|
-
return
|
|
1000
|
+
return l.app.api_key;
|
|
972
1001
|
}
|
|
973
1002
|
static getSessionToken() {
|
|
974
|
-
if (!
|
|
1003
|
+
if (!l.app)
|
|
975
1004
|
throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
|
|
976
|
-
return
|
|
1005
|
+
return l.app.sessionToken;
|
|
977
1006
|
}
|
|
978
1007
|
static getProps() {
|
|
979
|
-
if (!
|
|
1008
|
+
if (!l.app)
|
|
980
1009
|
throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
|
|
981
|
-
return
|
|
1010
|
+
return l.app.props;
|
|
982
1011
|
}
|
|
983
1012
|
static getEnv() {
|
|
984
|
-
if (!
|
|
1013
|
+
if (!l.app)
|
|
985
1014
|
throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
|
|
986
|
-
return
|
|
1015
|
+
return l.app.env === "internal" ? "staging" : l.app.env;
|
|
987
1016
|
}
|
|
988
1017
|
static getBaseUrl() {
|
|
989
|
-
if (!
|
|
1018
|
+
if (!l.app)
|
|
990
1019
|
throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
|
|
991
|
-
switch (
|
|
1020
|
+
switch (l.app.env) {
|
|
992
1021
|
case "production":
|
|
993
1022
|
return "https://api.chainrails.io/api/v1";
|
|
994
1023
|
case "staging":
|
|
@@ -1000,23 +1029,23 @@ class u {
|
|
|
1000
1029
|
}
|
|
1001
1030
|
}
|
|
1002
1031
|
static getPayModalUrl(e) {
|
|
1003
|
-
if (!
|
|
1032
|
+
if (!l.app)
|
|
1004
1033
|
throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
|
|
1005
|
-
const t =
|
|
1006
|
-
return t +
|
|
1034
|
+
const t = l.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 : ""}`;
|
|
1035
|
+
return t + o + r;
|
|
1007
1036
|
}
|
|
1008
1037
|
}
|
|
1009
|
-
let
|
|
1010
|
-
function
|
|
1011
|
-
|
|
1012
|
-
prefixUrl:
|
|
1038
|
+
let B = null;
|
|
1039
|
+
function Ye() {
|
|
1040
|
+
B = ne.create({
|
|
1041
|
+
prefixUrl: l.getBaseUrl(),
|
|
1013
1042
|
headers: {
|
|
1014
1043
|
"Content-Type": "application/json"
|
|
1015
1044
|
},
|
|
1016
1045
|
hooks: {
|
|
1017
1046
|
beforeRequest: [
|
|
1018
1047
|
(s) => {
|
|
1019
|
-
const e =
|
|
1048
|
+
const e = l.getSessionToken() || l.getApiKey();
|
|
1020
1049
|
s.headers.set("Authorization", `Bearer ${e}`);
|
|
1021
1050
|
}
|
|
1022
1051
|
],
|
|
@@ -1027,121 +1056,177 @@ function Ke() {
|
|
|
1027
1056
|
}
|
|
1028
1057
|
});
|
|
1029
1058
|
}
|
|
1030
|
-
function
|
|
1031
|
-
return
|
|
1059
|
+
function u() {
|
|
1060
|
+
return B || Ye(), B;
|
|
1032
1061
|
}
|
|
1033
|
-
class
|
|
1062
|
+
class Ge {
|
|
1034
1063
|
async getById(e) {
|
|
1035
|
-
return await
|
|
1064
|
+
return await u().get("intents/" + e).json();
|
|
1036
1065
|
}
|
|
1037
1066
|
async getForSender(e) {
|
|
1038
|
-
return await
|
|
1067
|
+
return await u().get("intents/user/" + e).json();
|
|
1039
1068
|
}
|
|
1040
1069
|
async getForAddress(e) {
|
|
1041
|
-
return await
|
|
1070
|
+
return await u().get("intents/address/" + e).json();
|
|
1042
1071
|
}
|
|
1043
1072
|
async getForSession(e) {
|
|
1044
|
-
return await
|
|
1073
|
+
return await u().get("modal/sessions/intents/" + e).json();
|
|
1045
1074
|
}
|
|
1046
1075
|
async getAll(e) {
|
|
1047
|
-
return await
|
|
1076
|
+
return await u().get("intents", { searchParams: e }).json();
|
|
1048
1077
|
}
|
|
1049
1078
|
async create(e) {
|
|
1050
|
-
|
|
1079
|
+
const t = g(e.source_chain), a = g(e.destination_chain);
|
|
1080
|
+
return await u().post("intents", {
|
|
1081
|
+
json: {
|
|
1082
|
+
...e,
|
|
1083
|
+
source_chain: t,
|
|
1084
|
+
destination_chain: a
|
|
1085
|
+
}
|
|
1086
|
+
}).json();
|
|
1051
1087
|
}
|
|
1052
1088
|
async createForSession(e) {
|
|
1053
|
-
|
|
1089
|
+
const t = g(e.sourceChain);
|
|
1090
|
+
return await u().post("modal/sessions/intents", {
|
|
1091
|
+
json: { ...e, sourceChain: t }
|
|
1092
|
+
}).json();
|
|
1054
1093
|
}
|
|
1055
1094
|
async update(e, t) {
|
|
1056
|
-
return await
|
|
1095
|
+
return await u().post("intents", { json: t }).json();
|
|
1057
1096
|
}
|
|
1058
1097
|
async triggerProcessing(e) {
|
|
1059
|
-
return await
|
|
1098
|
+
return await u().post(`intents/${e}/trigger-processing`).json();
|
|
1060
1099
|
}
|
|
1061
1100
|
async triggerProcessingForSession(e) {
|
|
1062
|
-
return await
|
|
1101
|
+
return await u().post(`modal/sessions/intents/${e}/process`).json();
|
|
1063
1102
|
}
|
|
1064
1103
|
}
|
|
1065
|
-
class
|
|
1104
|
+
class qe {
|
|
1066
1105
|
async getFromSpecificBridge(e) {
|
|
1067
|
-
|
|
1106
|
+
const t = g(e.sourceChain);
|
|
1107
|
+
w(t, e.tokenIn, e.amountSymbol);
|
|
1108
|
+
const a = g(e.destinationChain);
|
|
1109
|
+
return await u().get("quotes/single", {
|
|
1110
|
+
searchParams: {
|
|
1111
|
+
...e,
|
|
1112
|
+
sourceChain: t,
|
|
1113
|
+
destinationChain: a
|
|
1114
|
+
}
|
|
1115
|
+
}).json();
|
|
1068
1116
|
}
|
|
1069
1117
|
async getFromAllBridges(e) {
|
|
1070
|
-
|
|
1118
|
+
const t = g(e.sourceChain);
|
|
1119
|
+
w(t, e.tokenIn, e.amountSymbol);
|
|
1120
|
+
const a = g(e.destinationChain);
|
|
1121
|
+
return await u().get("quotes/multiple", {
|
|
1122
|
+
searchParams: {
|
|
1123
|
+
...e,
|
|
1124
|
+
sourceChain: t,
|
|
1125
|
+
destinationChain: a
|
|
1126
|
+
}
|
|
1127
|
+
}).json();
|
|
1071
1128
|
}
|
|
1072
1129
|
async getBestAcrossBridges(e) {
|
|
1073
|
-
|
|
1130
|
+
const t = g(e.sourceChain);
|
|
1131
|
+
w(t, e.tokenIn, e.amountSymbol);
|
|
1132
|
+
const a = g(e.destinationChain);
|
|
1133
|
+
return await u().get("quotes/best", { searchParams: {
|
|
1134
|
+
...e,
|
|
1135
|
+
sourceChain: t,
|
|
1136
|
+
destinationChain: a
|
|
1137
|
+
} }).json();
|
|
1074
1138
|
}
|
|
1075
1139
|
async getAll(e) {
|
|
1076
|
-
|
|
1140
|
+
const t = g(e.destinationChain);
|
|
1141
|
+
return await u().get("quotes/multi-source", { searchParams: {
|
|
1142
|
+
...e,
|
|
1143
|
+
destinationChain: t
|
|
1144
|
+
} }).json();
|
|
1077
1145
|
}
|
|
1078
1146
|
async getAllForSession(e) {
|
|
1079
|
-
return await
|
|
1147
|
+
return await u().get("modal/sessions/quotes", { searchParams: e }).json();
|
|
1080
1148
|
}
|
|
1081
1149
|
}
|
|
1082
|
-
class
|
|
1150
|
+
class Xe {
|
|
1083
1151
|
async getOptimalRoutes(e) {
|
|
1084
|
-
|
|
1152
|
+
const t = g(e.sourceChain), a = g(e.destinationChain);
|
|
1153
|
+
return await u().get("router/optimal-route", {
|
|
1154
|
+
searchParams: {
|
|
1155
|
+
...e,
|
|
1156
|
+
sourceChain: t,
|
|
1157
|
+
destinationChain: a
|
|
1158
|
+
}
|
|
1159
|
+
}).json();
|
|
1085
1160
|
}
|
|
1086
1161
|
async getAllSupportedBridges() {
|
|
1087
|
-
return await
|
|
1162
|
+
return await u().get("router/supported-bridges/all").json();
|
|
1088
1163
|
}
|
|
1089
1164
|
async getSupportedBridges(e) {
|
|
1090
|
-
|
|
1165
|
+
const t = g(e.sourceChain), a = g(e.destinationChain);
|
|
1166
|
+
return await u().get("router/supported-bridges/route", { searchParams: {
|
|
1167
|
+
...e,
|
|
1168
|
+
sourceChain: t,
|
|
1169
|
+
destinationChain: a
|
|
1170
|
+
} }).json();
|
|
1091
1171
|
}
|
|
1092
1172
|
async getSupportedRoutes(e, t) {
|
|
1093
|
-
|
|
1173
|
+
const a = g(t.sourceChain), o = g(t.destinationChain);
|
|
1174
|
+
return await u().get("router/supported-routes/bridge/" + e, { searchParams: {
|
|
1175
|
+
...t,
|
|
1176
|
+
sourceChain: a,
|
|
1177
|
+
destinationChain: o
|
|
1178
|
+
} }).json();
|
|
1094
1179
|
}
|
|
1095
1180
|
}
|
|
1096
|
-
class
|
|
1181
|
+
class Qe {
|
|
1097
1182
|
async getSupported(e) {
|
|
1098
|
-
return await
|
|
1183
|
+
return await u().get("chains", { searchParams: e }).json();
|
|
1099
1184
|
}
|
|
1100
1185
|
async getBalance(e) {
|
|
1101
|
-
return await
|
|
1186
|
+
return await u().get(`chains/balances/${e.address}`, { searchParams: e }).json();
|
|
1102
1187
|
}
|
|
1103
1188
|
}
|
|
1104
|
-
class
|
|
1189
|
+
class Je {
|
|
1105
1190
|
async getClientInfo() {
|
|
1106
|
-
return await
|
|
1191
|
+
return await u().get("client/auth/client-info").json();
|
|
1107
1192
|
}
|
|
1108
1193
|
async getClientInfoForSession() {
|
|
1109
|
-
return await
|
|
1194
|
+
return await u().get("modal/sessions/client").json();
|
|
1110
1195
|
}
|
|
1111
1196
|
}
|
|
1112
|
-
class
|
|
1197
|
+
class Ze {
|
|
1113
1198
|
async getSessionToken(e) {
|
|
1114
|
-
const t =
|
|
1199
|
+
const t = g(e.destinationChain), a = {
|
|
1115
1200
|
recipient: e.recipient,
|
|
1116
|
-
tokenOut:
|
|
1117
|
-
|
|
1201
|
+
tokenOut: Ve(
|
|
1202
|
+
t,
|
|
1118
1203
|
e.token
|
|
1119
1204
|
),
|
|
1120
|
-
destinationChain:
|
|
1205
|
+
destinationChain: t,
|
|
1121
1206
|
amount: e.amount
|
|
1122
1207
|
};
|
|
1123
|
-
return
|
|
1208
|
+
return u().post("modal/sessions", { json: a }).json().then((o) => ({ ...o, amount: a.amount }));
|
|
1124
1209
|
}
|
|
1125
1210
|
}
|
|
1126
|
-
const
|
|
1211
|
+
const ns = {
|
|
1127
1212
|
ACROSS: "ACROSS",
|
|
1128
1213
|
CCTP: "CCTP",
|
|
1129
1214
|
GATEWAY: "GATEWAY",
|
|
1130
1215
|
RHINOFI: "RHINOFI"
|
|
1131
|
-
},
|
|
1132
|
-
router: new
|
|
1133
|
-
quotes: new
|
|
1134
|
-
intents: new
|
|
1135
|
-
chains: new
|
|
1136
|
-
client: new
|
|
1137
|
-
auth: new
|
|
1216
|
+
}, as = {
|
|
1217
|
+
router: new Xe(),
|
|
1218
|
+
quotes: new qe(),
|
|
1219
|
+
intents: new Ge(),
|
|
1220
|
+
chains: new Qe(),
|
|
1221
|
+
client: new Je(),
|
|
1222
|
+
auth: new Ze()
|
|
1138
1223
|
};
|
|
1139
1224
|
export {
|
|
1140
1225
|
n as AmountSymbols,
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1226
|
+
ns as Bridges,
|
|
1227
|
+
l as Chainrails,
|
|
1228
|
+
ss as Chains,
|
|
1229
|
+
ts as Tokens,
|
|
1230
|
+
as as crapi,
|
|
1231
|
+
ee as environment
|
|
1147
1232
|
};
|