@chainrails/sdk 0.1.0 → 0.2.1
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 +152 -0
- package/dist/chainrails-sdk.es.js +239 -239
- package/dist/chainrails-sdk.es.mjs +239 -239
- package/dist/chainrails-sdk.umd.js +2 -2
- package/dist/src/Auth/index.d.ts +5 -2
- package/dist/src/Auth/index.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Ee from "ky";
|
|
2
|
-
var h = /* @__PURE__ */ ((
|
|
2
|
+
var h = /* @__PURE__ */ ((t) => (t.USDC = "USDC", t))(h || {});
|
|
3
3
|
const G = {
|
|
4
4
|
type: "evm",
|
|
5
5
|
chainId: 42161,
|
|
@@ -62,21 +62,21 @@ const G = {
|
|
|
62
62
|
cctpDomain: null,
|
|
63
63
|
logoURI: "/images/chains/starknet.svg"
|
|
64
64
|
};
|
|
65
|
-
function j(
|
|
66
|
-
return !
|
|
65
|
+
function j(t, { strict: e = !0 } = {}) {
|
|
66
|
+
return !t || typeof t != "string" ? !1 : e ? /^0x[0-9a-fA-F]*$/.test(t) : t.startsWith("0x");
|
|
67
67
|
}
|
|
68
|
-
function F(
|
|
69
|
-
return j(
|
|
68
|
+
function F(t) {
|
|
69
|
+
return j(t, { strict: !1 }) ? Math.ceil((t.length - 2) / 2) : t.length;
|
|
70
70
|
}
|
|
71
71
|
const ie = "2.43.4";
|
|
72
72
|
let S = {
|
|
73
|
-
getDocsUrl: ({ docsBaseUrl:
|
|
73
|
+
getDocsUrl: ({ docsBaseUrl: t, docsPath: e = "", docsSlug: s }) => e ? `${t ?? "https://viem.sh"}${e}${s ? `#${s}` : ""}` : void 0,
|
|
74
74
|
version: `viem@${ie}`
|
|
75
75
|
};
|
|
76
76
|
class g extends Error {
|
|
77
|
-
constructor(
|
|
77
|
+
constructor(e, s = {}) {
|
|
78
78
|
const n = s.cause instanceof g ? s.cause.details : s.cause?.message ? s.cause.message : s.details, i = s.cause instanceof g && s.cause.docsPath || s.docsPath, r = S.getDocsUrl?.({ ...s, docsPath: i }), o = [
|
|
79
|
-
|
|
79
|
+
e || "An error occurred.",
|
|
80
80
|
"",
|
|
81
81
|
...s.metaMessages ? [...s.metaMessages, ""] : [],
|
|
82
82
|
...r ? [`Docs: ${r}`] : [],
|
|
@@ -114,93 +114,93 @@ class g extends Error {
|
|
|
114
114
|
configurable: !0,
|
|
115
115
|
writable: !0,
|
|
116
116
|
value: "BaseError"
|
|
117
|
-
}), this.details = n, this.docsPath = i, this.metaMessages = s.metaMessages, this.name = s.name ?? this.name, this.shortMessage =
|
|
117
|
+
}), this.details = n, this.docsPath = i, this.metaMessages = s.metaMessages, this.name = s.name ?? this.name, this.shortMessage = e, this.version = ie;
|
|
118
118
|
}
|
|
119
|
-
walk(
|
|
120
|
-
return oe(this,
|
|
119
|
+
walk(e) {
|
|
120
|
+
return oe(this, e);
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
|
-
function oe(
|
|
124
|
-
return
|
|
123
|
+
function oe(t, e) {
|
|
124
|
+
return e?.(t) ? t : t && typeof t == "object" && "cause" in t && t.cause !== void 0 ? oe(t.cause, e) : e ? null : t;
|
|
125
125
|
}
|
|
126
126
|
class re extends g {
|
|
127
|
-
constructor({ size:
|
|
128
|
-
super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (${
|
|
127
|
+
constructor({ size: e, targetSize: s, type: n }) {
|
|
128
|
+
super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (${e}) exceeds padding size (${s}).`, { name: "SizeExceedsPaddingSizeError" });
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
|
-
function E(
|
|
132
|
-
return typeof
|
|
131
|
+
function E(t, { dir: e, size: s = 32 } = {}) {
|
|
132
|
+
return typeof t == "string" ? Se(t, { dir: e, size: s }) : Ae(t, { dir: e, size: s });
|
|
133
133
|
}
|
|
134
|
-
function Se(
|
|
134
|
+
function Se(t, { dir: e, size: s = 32 } = {}) {
|
|
135
135
|
if (s === null)
|
|
136
|
-
return
|
|
137
|
-
const n =
|
|
136
|
+
return t;
|
|
137
|
+
const n = t.replace("0x", "");
|
|
138
138
|
if (n.length > s * 2)
|
|
139
139
|
throw new re({
|
|
140
140
|
size: Math.ceil(n.length / 2),
|
|
141
141
|
targetSize: s,
|
|
142
142
|
type: "hex"
|
|
143
143
|
});
|
|
144
|
-
return `0x${n[
|
|
144
|
+
return `0x${n[e === "right" ? "padEnd" : "padStart"](s * 2, "0")}`;
|
|
145
145
|
}
|
|
146
|
-
function Ae(
|
|
146
|
+
function Ae(t, { dir: e, size: s = 32 } = {}) {
|
|
147
147
|
if (s === null)
|
|
148
|
-
return
|
|
149
|
-
if (
|
|
148
|
+
return t;
|
|
149
|
+
if (t.length > s)
|
|
150
150
|
throw new re({
|
|
151
|
-
size:
|
|
151
|
+
size: t.length,
|
|
152
152
|
targetSize: s,
|
|
153
153
|
type: "bytes"
|
|
154
154
|
});
|
|
155
155
|
const n = new Uint8Array(s);
|
|
156
156
|
for (let i = 0; i < s; i++) {
|
|
157
|
-
const r =
|
|
158
|
-
n[r ? i : s - i - 1] =
|
|
157
|
+
const r = e === "right";
|
|
158
|
+
n[r ? i : s - i - 1] = t[r ? i : t.length - i - 1];
|
|
159
159
|
}
|
|
160
160
|
return n;
|
|
161
161
|
}
|
|
162
162
|
class Ue extends g {
|
|
163
|
-
constructor({ max:
|
|
164
|
-
super(`Number "${r}" is not in safe ${i ? `${i * 8}-bit ${n ? "signed" : "unsigned"} ` : ""}integer range ${
|
|
163
|
+
constructor({ max: e, min: s, signed: n, size: i, value: r }) {
|
|
164
|
+
super(`Number "${r}" is not in safe ${i ? `${i * 8}-bit ${n ? "signed" : "unsigned"} ` : ""}integer range ${e ? `(${s} to ${e})` : `(above ${s})`}`, { name: "IntegerOutOfRangeError" });
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
167
|
class ve extends g {
|
|
168
|
-
constructor({ givenSize:
|
|
169
|
-
super(`Size cannot exceed ${s} bytes. Given size: ${
|
|
168
|
+
constructor({ givenSize: e, maxSize: s }) {
|
|
169
|
+
super(`Size cannot exceed ${s} bytes. Given size: ${e} bytes.`, { name: "SizeOverflowError" });
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
|
-
function O(
|
|
173
|
-
if (F(
|
|
172
|
+
function O(t, { size: e }) {
|
|
173
|
+
if (F(t) > e)
|
|
174
174
|
throw new ve({
|
|
175
|
-
givenSize: F(
|
|
176
|
-
maxSize:
|
|
175
|
+
givenSize: F(t),
|
|
176
|
+
maxSize: e
|
|
177
177
|
});
|
|
178
178
|
}
|
|
179
|
-
function Ce(
|
|
180
|
-
const { signed: s, size: n } =
|
|
179
|
+
function Ce(t, e = {}) {
|
|
180
|
+
const { signed: s, size: n } = e, i = BigInt(t);
|
|
181
181
|
let r;
|
|
182
|
-
n ? s ? r = (1n << BigInt(n) * 8n - 1n) - 1n : r = 2n ** (BigInt(n) * 8n) - 1n : typeof
|
|
182
|
+
n ? s ? r = (1n << BigInt(n) * 8n - 1n) - 1n : r = 2n ** (BigInt(n) * 8n) - 1n : typeof t == "number" && (r = BigInt(Number.MAX_SAFE_INTEGER));
|
|
183
183
|
const o = typeof r == "bigint" && s ? -r - 1n : 0;
|
|
184
184
|
if (r && i > r || i < o) {
|
|
185
|
-
const l = typeof
|
|
185
|
+
const l = typeof t == "bigint" ? "n" : "";
|
|
186
186
|
throw new Ue({
|
|
187
187
|
max: r ? `${r}${l}` : void 0,
|
|
188
188
|
min: `${o}${l}`,
|
|
189
189
|
signed: s,
|
|
190
190
|
size: n,
|
|
191
|
-
value: `${
|
|
191
|
+
value: `${t}${l}`
|
|
192
192
|
});
|
|
193
193
|
}
|
|
194
194
|
const a = `0x${(s && i < 0 ? (1n << BigInt(n * 8)) + BigInt(i) : i).toString(16)}`;
|
|
195
195
|
return n ? E(a, { size: n }) : a;
|
|
196
196
|
}
|
|
197
197
|
const Te = /* @__PURE__ */ new TextEncoder();
|
|
198
|
-
function De(
|
|
199
|
-
return typeof
|
|
198
|
+
function De(t, e = {}) {
|
|
199
|
+
return typeof t == "number" || typeof t == "bigint" ? Re(t, e) : typeof t == "boolean" ? xe(t, e) : j(t) ? ae(t, e) : ce(t, e);
|
|
200
200
|
}
|
|
201
|
-
function xe(
|
|
201
|
+
function xe(t, e = {}) {
|
|
202
202
|
const s = new Uint8Array(1);
|
|
203
|
-
return s[0] = Number(
|
|
203
|
+
return s[0] = Number(t), typeof e.size == "number" ? (O(s, { size: e.size }), E(s, { size: e.size })) : s;
|
|
204
204
|
}
|
|
205
205
|
const d = {
|
|
206
206
|
zero: 48,
|
|
@@ -210,145 +210,145 @@ const d = {
|
|
|
210
210
|
a: 97,
|
|
211
211
|
f: 102
|
|
212
212
|
};
|
|
213
|
-
function
|
|
214
|
-
if (
|
|
215
|
-
return
|
|
216
|
-
if (
|
|
217
|
-
return
|
|
218
|
-
if (
|
|
219
|
-
return
|
|
220
|
-
}
|
|
221
|
-
function ae(
|
|
222
|
-
let s =
|
|
223
|
-
|
|
213
|
+
function L(t) {
|
|
214
|
+
if (t >= d.zero && t <= d.nine)
|
|
215
|
+
return t - d.zero;
|
|
216
|
+
if (t >= d.A && t <= d.F)
|
|
217
|
+
return t - (d.A - 10);
|
|
218
|
+
if (t >= d.a && t <= d.f)
|
|
219
|
+
return t - (d.a - 10);
|
|
220
|
+
}
|
|
221
|
+
function ae(t, e = {}) {
|
|
222
|
+
let s = t;
|
|
223
|
+
e.size && (O(s, { size: e.size }), s = E(s, { dir: "right", size: e.size }));
|
|
224
224
|
let n = s.slice(2);
|
|
225
225
|
n.length % 2 && (n = `0${n}`);
|
|
226
226
|
const i = n.length / 2, r = new Uint8Array(i);
|
|
227
227
|
for (let o = 0, a = 0; o < i; o++) {
|
|
228
|
-
const l =
|
|
228
|
+
const l = L(n.charCodeAt(a++)), f = L(n.charCodeAt(a++));
|
|
229
229
|
if (l === void 0 || f === void 0)
|
|
230
230
|
throw new g(`Invalid byte sequence ("${n[a - 2]}${n[a - 1]}" in "${n}").`);
|
|
231
231
|
r[o] = l * 16 + f;
|
|
232
232
|
}
|
|
233
233
|
return r;
|
|
234
234
|
}
|
|
235
|
-
function
|
|
236
|
-
const s = Ce(
|
|
235
|
+
function Re(t, e) {
|
|
236
|
+
const s = Ce(t, e);
|
|
237
237
|
return ae(s);
|
|
238
238
|
}
|
|
239
|
-
function ce(
|
|
240
|
-
const s = Te.encode(
|
|
241
|
-
return typeof
|
|
239
|
+
function ce(t, e = {}) {
|
|
240
|
+
const s = Te.encode(t);
|
|
241
|
+
return typeof e.size == "number" ? (O(s, { size: e.size }), E(s, { dir: "right", size: e.size })) : s;
|
|
242
242
|
}
|
|
243
|
-
const b = /* @__PURE__ */ BigInt(2 ** 32 - 1),
|
|
244
|
-
function
|
|
245
|
-
return
|
|
243
|
+
const b = /* @__PURE__ */ BigInt(2 ** 32 - 1), _ = /* @__PURE__ */ BigInt(32);
|
|
244
|
+
function ke(t, e = !1) {
|
|
245
|
+
return e ? { h: Number(t & b), l: Number(t >> _ & b) } : { h: Number(t >> _ & b) | 0, l: Number(t & b) | 0 };
|
|
246
246
|
}
|
|
247
|
-
function Ne(
|
|
248
|
-
const s =
|
|
247
|
+
function Ne(t, e = !1) {
|
|
248
|
+
const s = t.length;
|
|
249
249
|
let n = new Uint32Array(s), i = new Uint32Array(s);
|
|
250
250
|
for (let r = 0; r < s; r++) {
|
|
251
|
-
const { h: o, l: a } =
|
|
251
|
+
const { h: o, l: a } = ke(t[r], e);
|
|
252
252
|
[n[r], i[r]] = [o, a];
|
|
253
253
|
}
|
|
254
254
|
return [n, i];
|
|
255
255
|
}
|
|
256
|
-
const Be = (
|
|
256
|
+
const Be = (t, e, s) => t << s | e >>> 32 - s, ze = (t, e, s) => e << s | t >>> 32 - s, $e = (t, e, s) => e << s - 32 | t >>> 64 - s, Me = (t, e, s) => t << s - 32 | e >>> 64 - s;
|
|
257
257
|
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
258
|
-
function je(
|
|
259
|
-
return
|
|
258
|
+
function je(t) {
|
|
259
|
+
return t instanceof Uint8Array || ArrayBuffer.isView(t) && t.constructor.name === "Uint8Array";
|
|
260
260
|
}
|
|
261
|
-
function H(
|
|
262
|
-
if (!Number.isSafeInteger(
|
|
263
|
-
throw new Error("positive integer expected, got " +
|
|
261
|
+
function H(t) {
|
|
262
|
+
if (!Number.isSafeInteger(t) || t < 0)
|
|
263
|
+
throw new Error("positive integer expected, got " + t);
|
|
264
264
|
}
|
|
265
|
-
function w(
|
|
266
|
-
if (!je(
|
|
265
|
+
function w(t, ...e) {
|
|
266
|
+
if (!je(t))
|
|
267
267
|
throw new Error("Uint8Array expected");
|
|
268
|
-
if (
|
|
269
|
-
throw new Error("Uint8Array expected of length " +
|
|
268
|
+
if (e.length > 0 && !e.includes(t.length))
|
|
269
|
+
throw new Error("Uint8Array expected of length " + e + ", got length=" + t.length);
|
|
270
270
|
}
|
|
271
|
-
function q(
|
|
272
|
-
if (
|
|
271
|
+
function q(t, e = !0) {
|
|
272
|
+
if (t.destroyed)
|
|
273
273
|
throw new Error("Hash instance has been destroyed");
|
|
274
|
-
if (
|
|
274
|
+
if (e && t.finished)
|
|
275
275
|
throw new Error("Hash#digest() has already been called");
|
|
276
276
|
}
|
|
277
|
-
function Oe(
|
|
278
|
-
w(
|
|
279
|
-
const s =
|
|
280
|
-
if (
|
|
277
|
+
function Oe(t, e) {
|
|
278
|
+
w(t);
|
|
279
|
+
const s = e.outputLen;
|
|
280
|
+
if (t.length < s)
|
|
281
281
|
throw new Error("digestInto() expects output buffer of length at least " + s);
|
|
282
282
|
}
|
|
283
|
-
function Pe(
|
|
284
|
-
return new Uint32Array(
|
|
283
|
+
function Pe(t) {
|
|
284
|
+
return new Uint32Array(t.buffer, t.byteOffset, Math.floor(t.byteLength / 4));
|
|
285
285
|
}
|
|
286
|
-
function ue(...
|
|
287
|
-
for (let
|
|
288
|
-
e
|
|
286
|
+
function ue(...t) {
|
|
287
|
+
for (let e = 0; e < t.length; e++)
|
|
288
|
+
t[e].fill(0);
|
|
289
289
|
}
|
|
290
290
|
const Fe = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
|
|
291
|
-
function
|
|
292
|
-
return
|
|
291
|
+
function Le(t) {
|
|
292
|
+
return t << 24 & 4278190080 | t << 8 & 16711680 | t >>> 8 & 65280 | t >>> 24 & 255;
|
|
293
293
|
}
|
|
294
|
-
function
|
|
295
|
-
for (let
|
|
296
|
-
e
|
|
297
|
-
return
|
|
294
|
+
function _e(t) {
|
|
295
|
+
for (let e = 0; e < t.length; e++)
|
|
296
|
+
t[e] = Le(t[e]);
|
|
297
|
+
return t;
|
|
298
298
|
}
|
|
299
|
-
const K = Fe ? (
|
|
300
|
-
function He(
|
|
301
|
-
if (typeof
|
|
299
|
+
const K = Fe ? (t) => t : _e;
|
|
300
|
+
function He(t) {
|
|
301
|
+
if (typeof t != "string")
|
|
302
302
|
throw new Error("string expected");
|
|
303
|
-
return new Uint8Array(new TextEncoder().encode(
|
|
303
|
+
return new Uint8Array(new TextEncoder().encode(t));
|
|
304
304
|
}
|
|
305
|
-
function le(
|
|
306
|
-
return typeof
|
|
305
|
+
function le(t) {
|
|
306
|
+
return typeof t == "string" && (t = He(t)), w(t), t;
|
|
307
307
|
}
|
|
308
308
|
class qe {
|
|
309
309
|
}
|
|
310
|
-
function Ke(
|
|
311
|
-
const
|
|
312
|
-
return
|
|
310
|
+
function Ke(t) {
|
|
311
|
+
const e = (n) => t().update(le(n)).digest(), s = t();
|
|
312
|
+
return e.outputLen = s.outputLen, e.blockLen = s.blockLen, e.create = () => t(), e;
|
|
313
313
|
}
|
|
314
314
|
const Ve = BigInt(0), y = BigInt(1), Xe = BigInt(2), Ge = BigInt(7), Qe = BigInt(256), We = BigInt(113), he = [], de = [], pe = [];
|
|
315
|
-
for (let
|
|
316
|
-
[s, n] = [n, (2 * s + 3 * n) % 5], he.push(2 * (5 * n + s)), de.push((
|
|
315
|
+
for (let t = 0, e = y, s = 1, n = 0; t < 24; t++) {
|
|
316
|
+
[s, n] = [n, (2 * s + 3 * n) % 5], he.push(2 * (5 * n + s)), de.push((t + 1) * (t + 2) / 2 % 64);
|
|
317
317
|
let i = Ve;
|
|
318
318
|
for (let r = 0; r < 7; r++)
|
|
319
|
-
|
|
319
|
+
e = (e << y ^ (e >> Ge) * We) % Qe, e & Xe && (i ^= y << (y << /* @__PURE__ */ BigInt(r)) - y);
|
|
320
320
|
pe.push(i);
|
|
321
321
|
}
|
|
322
|
-
const ge = Ne(pe, !0), Je = ge[0], Ye = ge[1], V = (
|
|
323
|
-
function Ze(
|
|
322
|
+
const ge = Ne(pe, !0), Je = ge[0], Ye = ge[1], V = (t, e, s) => s > 32 ? $e(t, e, s) : Be(t, e, s), X = (t, e, s) => s > 32 ? Me(t, e, s) : ze(t, e, s);
|
|
323
|
+
function Ze(t, e = 24) {
|
|
324
324
|
const s = new Uint32Array(10);
|
|
325
|
-
for (let n = 24 -
|
|
325
|
+
for (let n = 24 - e; n < 24; n++) {
|
|
326
326
|
for (let o = 0; o < 10; o++)
|
|
327
|
-
s[o] =
|
|
327
|
+
s[o] = t[o] ^ t[o + 10] ^ t[o + 20] ^ t[o + 30] ^ t[o + 40];
|
|
328
328
|
for (let o = 0; o < 10; o += 2) {
|
|
329
329
|
const a = (o + 8) % 10, l = (o + 2) % 10, f = s[l], m = s[l + 1], be = V(f, m, 1) ^ s[a], we = X(f, m, 1) ^ s[a + 1];
|
|
330
330
|
for (let I = 0; I < 50; I += 10)
|
|
331
|
-
|
|
331
|
+
t[o + I] ^= be, t[o + I + 1] ^= we;
|
|
332
332
|
}
|
|
333
|
-
let i =
|
|
333
|
+
let i = t[2], r = t[3];
|
|
334
334
|
for (let o = 0; o < 24; o++) {
|
|
335
335
|
const a = de[o], l = V(i, r, a), f = X(i, r, a), m = he[o];
|
|
336
|
-
i =
|
|
336
|
+
i = t[m], r = t[m + 1], t[m] = l, t[m + 1] = f;
|
|
337
337
|
}
|
|
338
338
|
for (let o = 0; o < 50; o += 10) {
|
|
339
339
|
for (let a = 0; a < 10; a++)
|
|
340
|
-
s[a] =
|
|
340
|
+
s[a] = t[o + a];
|
|
341
341
|
for (let a = 0; a < 10; a++)
|
|
342
|
-
|
|
342
|
+
t[o + a] ^= ~s[(a + 2) % 10] & s[(a + 4) % 10];
|
|
343
343
|
}
|
|
344
|
-
|
|
344
|
+
t[0] ^= Je[n], t[1] ^= Ye[n];
|
|
345
345
|
}
|
|
346
346
|
ue(s);
|
|
347
347
|
}
|
|
348
348
|
class P extends qe {
|
|
349
349
|
// NOTE: we accept arguments in bytes instead of bits here.
|
|
350
|
-
constructor(
|
|
351
|
-
if (super(), this.pos = 0, this.posOut = 0, this.finished = !1, this.destroyed = !1, this.enableXOF = !1, this.blockLen =
|
|
350
|
+
constructor(e, s, n, i = !1, r = 24) {
|
|
351
|
+
if (super(), this.pos = 0, this.posOut = 0, this.finished = !1, this.destroyed = !1, this.enableXOF = !1, this.blockLen = e, this.suffix = s, this.outputLen = n, this.enableXOF = i, this.rounds = r, H(n), !(0 < e && e < 200))
|
|
352
352
|
throw new Error("only keccak-f1600 function is supported");
|
|
353
353
|
this.state = new Uint8Array(200), this.state32 = Pe(this.state);
|
|
354
354
|
}
|
|
@@ -358,13 +358,13 @@ class P extends qe {
|
|
|
358
358
|
keccak() {
|
|
359
359
|
K(this.state32), Ze(this.state32, this.rounds), K(this.state32), this.posOut = 0, this.pos = 0;
|
|
360
360
|
}
|
|
361
|
-
update(
|
|
362
|
-
q(this),
|
|
363
|
-
const { blockLen: s, state: n } = this, i =
|
|
361
|
+
update(e) {
|
|
362
|
+
q(this), e = le(e), w(e);
|
|
363
|
+
const { blockLen: s, state: n } = this, i = e.length;
|
|
364
364
|
for (let r = 0; r < i; ) {
|
|
365
365
|
const o = Math.min(s - this.pos, i - r);
|
|
366
366
|
for (let a = 0; a < o; a++)
|
|
367
|
-
n[this.pos++] ^=
|
|
367
|
+
n[this.pos++] ^= e[r++];
|
|
368
368
|
this.pos === s && this.keccak();
|
|
369
369
|
}
|
|
370
370
|
return this;
|
|
@@ -373,31 +373,31 @@ class P extends qe {
|
|
|
373
373
|
if (this.finished)
|
|
374
374
|
return;
|
|
375
375
|
this.finished = !0;
|
|
376
|
-
const { state:
|
|
377
|
-
|
|
376
|
+
const { state: e, suffix: s, pos: n, blockLen: i } = this;
|
|
377
|
+
e[n] ^= s, (s & 128) !== 0 && n === i - 1 && this.keccak(), e[i - 1] ^= 128, this.keccak();
|
|
378
378
|
}
|
|
379
|
-
writeInto(
|
|
380
|
-
q(this, !1), w(
|
|
379
|
+
writeInto(e) {
|
|
380
|
+
q(this, !1), w(e), this.finish();
|
|
381
381
|
const s = this.state, { blockLen: n } = this;
|
|
382
|
-
for (let i = 0, r =
|
|
382
|
+
for (let i = 0, r = e.length; i < r; ) {
|
|
383
383
|
this.posOut >= n && this.keccak();
|
|
384
384
|
const o = Math.min(n - this.posOut, r - i);
|
|
385
|
-
|
|
385
|
+
e.set(s.subarray(this.posOut, this.posOut + o), i), this.posOut += o, i += o;
|
|
386
386
|
}
|
|
387
|
-
return
|
|
387
|
+
return e;
|
|
388
388
|
}
|
|
389
|
-
xofInto(
|
|
389
|
+
xofInto(e) {
|
|
390
390
|
if (!this.enableXOF)
|
|
391
391
|
throw new Error("XOF is not possible for this instance");
|
|
392
|
-
return this.writeInto(
|
|
392
|
+
return this.writeInto(e);
|
|
393
393
|
}
|
|
394
|
-
xof(
|
|
395
|
-
return H(
|
|
394
|
+
xof(e) {
|
|
395
|
+
return H(e), this.xofInto(new Uint8Array(e));
|
|
396
396
|
}
|
|
397
|
-
digestInto(
|
|
398
|
-
if (Oe(
|
|
397
|
+
digestInto(e) {
|
|
398
|
+
if (Oe(e, this), this.finished)
|
|
399
399
|
throw new Error("digest() was already called");
|
|
400
|
-
return this.writeInto(
|
|
400
|
+
return this.writeInto(e), this.destroy(), e;
|
|
401
401
|
}
|
|
402
402
|
digest() {
|
|
403
403
|
return this.digestInto(new Uint8Array(this.outputLen));
|
|
@@ -405,18 +405,18 @@ class P extends qe {
|
|
|
405
405
|
destroy() {
|
|
406
406
|
this.destroyed = !0, ue(this.state);
|
|
407
407
|
}
|
|
408
|
-
_cloneInto(
|
|
408
|
+
_cloneInto(e) {
|
|
409
409
|
const { blockLen: s, suffix: n, outputLen: i, rounds: r, enableXOF: o } = this;
|
|
410
|
-
return
|
|
410
|
+
return e || (e = new P(s, n, i, o, r)), e.state32.set(this.state32), e.pos = this.pos, e.posOut = this.posOut, e.finished = this.finished, e.rounds = r, e.suffix = n, e.outputLen = i, e.enableXOF = o, e.destroyed = this.destroyed, e;
|
|
411
411
|
}
|
|
412
412
|
}
|
|
413
|
-
const et = (
|
|
414
|
-
function st(
|
|
415
|
-
return tt(j(
|
|
413
|
+
const et = (t, e, s) => Ke(() => new P(e, t, s)), tt = et(1, 136, 256 / 8);
|
|
414
|
+
function st(t, e) {
|
|
415
|
+
return tt(j(t, { strict: !1 }) ? De(t) : t);
|
|
416
416
|
}
|
|
417
417
|
class nt extends g {
|
|
418
|
-
constructor({ address:
|
|
419
|
-
super(`Address "${
|
|
418
|
+
constructor({ address: e }) {
|
|
419
|
+
super(`Address "${e}" is invalid.`, {
|
|
420
420
|
metaMessages: [
|
|
421
421
|
"- Address must be a hex value of 20 bytes (40 hex characters).",
|
|
422
422
|
"- Address must match its checksum counterpart."
|
|
@@ -426,20 +426,20 @@ class nt extends g {
|
|
|
426
426
|
}
|
|
427
427
|
}
|
|
428
428
|
class fe extends Map {
|
|
429
|
-
constructor(
|
|
429
|
+
constructor(e) {
|
|
430
430
|
super(), Object.defineProperty(this, "maxSize", {
|
|
431
431
|
enumerable: !0,
|
|
432
432
|
configurable: !0,
|
|
433
433
|
writable: !0,
|
|
434
434
|
value: void 0
|
|
435
|
-
}), this.maxSize =
|
|
435
|
+
}), this.maxSize = e;
|
|
436
436
|
}
|
|
437
|
-
get(
|
|
438
|
-
const s = super.get(
|
|
439
|
-
return super.has(
|
|
437
|
+
get(e) {
|
|
438
|
+
const s = super.get(e);
|
|
439
|
+
return super.has(e) && s !== void 0 && (this.delete(e), super.set(e, s)), s;
|
|
440
440
|
}
|
|
441
|
-
set(
|
|
442
|
-
if (super.set(
|
|
441
|
+
set(e, s) {
|
|
442
|
+
if (super.set(e, s), this.maxSize && this.size > this.maxSize) {
|
|
443
443
|
const n = this.keys().next().value;
|
|
444
444
|
n && this.delete(n);
|
|
445
445
|
}
|
|
@@ -447,26 +447,26 @@ class fe extends Map {
|
|
|
447
447
|
}
|
|
448
448
|
}
|
|
449
449
|
const A = /* @__PURE__ */ new fe(8192);
|
|
450
|
-
function me(
|
|
451
|
-
if (A.has(`${
|
|
452
|
-
return A.get(`${
|
|
453
|
-
const s =
|
|
450
|
+
function me(t, e) {
|
|
451
|
+
if (A.has(`${t}.${e}`))
|
|
452
|
+
return A.get(`${t}.${e}`);
|
|
453
|
+
const s = t.substring(2).toLowerCase(), n = st(ce(s)), i = s.split("");
|
|
454
454
|
for (let o = 0; o < 40; o += 2)
|
|
455
455
|
n[o >> 1] >> 4 >= 8 && i[o] && (i[o] = i[o].toUpperCase()), (n[o >> 1] & 15) >= 8 && i[o + 1] && (i[o + 1] = i[o + 1].toUpperCase());
|
|
456
456
|
const r = `0x${i.join("")}`;
|
|
457
|
-
return A.set(`${
|
|
457
|
+
return A.set(`${t}.${e}`, r), r;
|
|
458
458
|
}
|
|
459
|
-
function p(
|
|
460
|
-
if (!ot(
|
|
461
|
-
throw new nt({ address:
|
|
462
|
-
return me(
|
|
459
|
+
function p(t, e) {
|
|
460
|
+
if (!ot(t, { strict: !1 }))
|
|
461
|
+
throw new nt({ address: t });
|
|
462
|
+
return me(t, e);
|
|
463
463
|
}
|
|
464
464
|
const it = /^0x[a-fA-F0-9]{40}$/, U = /* @__PURE__ */ new fe(8192);
|
|
465
|
-
function ot(
|
|
466
|
-
const { strict: s = !0 } =
|
|
465
|
+
function ot(t, e) {
|
|
466
|
+
const { strict: s = !0 } = e ?? {}, n = `${t}.${s}`;
|
|
467
467
|
if (U.has(n))
|
|
468
468
|
return U.get(n);
|
|
469
|
-
const i = it.test(
|
|
469
|
+
const i = it.test(t) ? t.toLowerCase() === t ? !0 : s ? me(t) === t : !0 : !1;
|
|
470
470
|
return U.set(n, i), i;
|
|
471
471
|
}
|
|
472
472
|
const v = {
|
|
@@ -509,7 +509,7 @@ const v = {
|
|
|
509
509
|
decimals: 6,
|
|
510
510
|
logoURI: "https://pay.daimo.com/coin-logos/usdc.png",
|
|
511
511
|
logoSourceURI: "https://pay.daimo.com/coin-logos/usdc.png"
|
|
512
|
-
},
|
|
512
|
+
}, R = {
|
|
513
513
|
chainId: W.chainId,
|
|
514
514
|
address: p("0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"),
|
|
515
515
|
symbol: "USDC",
|
|
@@ -517,7 +517,7 @@ const v = {
|
|
|
517
517
|
decimals: 6,
|
|
518
518
|
logoURI: "https://pay.daimo.com/coin-logos/usdc.png",
|
|
519
519
|
logoSourceURI: "https://pay.daimo.com/coin-logos/usdc.png"
|
|
520
|
-
},
|
|
520
|
+
}, k = {
|
|
521
521
|
chainId: Y.chainId,
|
|
522
522
|
address: p("0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"),
|
|
523
523
|
symbol: "USDC",
|
|
@@ -551,11 +551,11 @@ const v = {
|
|
|
551
551
|
[T.chainId]: T,
|
|
552
552
|
[D.chainId]: D,
|
|
553
553
|
[x.chainId]: x,
|
|
554
|
-
[
|
|
554
|
+
[R.chainId]: R,
|
|
555
555
|
[N.chainId]: N,
|
|
556
556
|
[B.chainId]: B,
|
|
557
|
-
[
|
|
558
|
-
},
|
|
557
|
+
[k.chainId]: k
|
|
558
|
+
}, z = {
|
|
559
559
|
ARBITRUM_MAINNET: {
|
|
560
560
|
...G,
|
|
561
561
|
tokens: {
|
|
@@ -587,7 +587,7 @@ const v = {
|
|
|
587
587
|
BASE_MAINNET: {
|
|
588
588
|
...W,
|
|
589
589
|
tokens: {
|
|
590
|
-
[h.USDC]:
|
|
590
|
+
[h.USDC]: R
|
|
591
591
|
},
|
|
592
592
|
explorer: "https://basescan.org"
|
|
593
593
|
},
|
|
@@ -601,7 +601,7 @@ const v = {
|
|
|
601
601
|
BSC_MAINNET: {
|
|
602
602
|
...Y,
|
|
603
603
|
tokens: {
|
|
604
|
-
[h.USDC]:
|
|
604
|
+
[h.USDC]: k
|
|
605
605
|
},
|
|
606
606
|
explorer: "https://bscscan.com"
|
|
607
607
|
},
|
|
@@ -627,30 +627,30 @@ const v = {
|
|
|
627
627
|
explorer: ""
|
|
628
628
|
}
|
|
629
629
|
};
|
|
630
|
-
var
|
|
631
|
-
function It(
|
|
632
|
-
return at[
|
|
633
|
-
}
|
|
634
|
-
const ct = (
|
|
635
|
-
const
|
|
636
|
-
if (
|
|
637
|
-
return
|
|
630
|
+
var $ = /* @__PURE__ */ ((t) => (t.ARBITRUM = "ARBITRUM_MAINNET", t.ARBITRUM_TESTNET = "ARBITRUM_TESTNET", t.AVALANCHE = "AVALANCHE_MAINNET", t.AVALANCHE_TESTNET = "AVALANCHE_TESTNET", t.BASE = "BASE_MAINNET", t.BASE_TESTNET = "BASE_TESTNET", t.BSC = "BSC_MAINNET", t.ETHEREUM = "ETHEREUM_MAINNET", t.ETHEREUM_TESTNET = "ETHEREUM_TESTNET", t.STARKNET = "STARKNET_MAINNET", t))($ || {}), ye = /* @__PURE__ */ ((t) => (t.USDC = "USDC", t))(ye || {});
|
|
631
|
+
function It(t) {
|
|
632
|
+
return at[z[t || ""].chainId]?.decimals || 6;
|
|
633
|
+
}
|
|
634
|
+
const ct = (t) => {
|
|
635
|
+
const e = t?.trim().toUpperCase();
|
|
636
|
+
if (z[e])
|
|
637
|
+
return z[e];
|
|
638
638
|
};
|
|
639
|
-
function ut(
|
|
640
|
-
return ct(
|
|
639
|
+
function ut(t, e) {
|
|
640
|
+
return ct(t)?.tokens[e]?.address;
|
|
641
641
|
}
|
|
642
|
-
var Ie = /* @__PURE__ */ ((
|
|
642
|
+
var Ie = /* @__PURE__ */ ((t) => (t.PRODUCTION = "production", t.STAGING = "staging", t))(Ie || {});
|
|
643
643
|
class u {
|
|
644
|
-
constructor({ api_key:
|
|
645
|
-
this.api_key =
|
|
644
|
+
constructor({ api_key: e, env: s, seesion_token: n }) {
|
|
645
|
+
this.api_key = e || "", this.sessionToken = n || "", this.env = s ?? Ie.PRODUCTION;
|
|
646
646
|
}
|
|
647
|
-
static async config(
|
|
647
|
+
static async config(e) {
|
|
648
648
|
if (!u.app) {
|
|
649
|
-
if (!
|
|
649
|
+
if (!e)
|
|
650
650
|
throw new Error("Please provide an api_key");
|
|
651
|
-
u.app = new u(
|
|
651
|
+
u.app = new u(e);
|
|
652
652
|
}
|
|
653
|
-
return
|
|
653
|
+
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)), u.app;
|
|
654
654
|
}
|
|
655
655
|
static getApiKey() {
|
|
656
656
|
if (!u.app)
|
|
@@ -681,11 +681,11 @@ class u {
|
|
|
681
681
|
return "https://api.chainrails.io/api/v1";
|
|
682
682
|
}
|
|
683
683
|
}
|
|
684
|
-
static getPayModalUrl(
|
|
684
|
+
static getPayModalUrl(e) {
|
|
685
685
|
if (!u.app)
|
|
686
686
|
throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
|
|
687
|
-
const
|
|
688
|
-
return
|
|
687
|
+
const s = u.app.env === "internal" ? "https://chainrails-frontend-git-staging-horus-labs.vercel.app" : "https://app.chainrails.io", n = e && e > 0 ? "/pay/" : "/deposit/", i = `${e && e > 0 ? e * 100 : ""}`;
|
|
688
|
+
return s + n + i;
|
|
689
689
|
}
|
|
690
690
|
}
|
|
691
691
|
let M = null;
|
|
@@ -697,12 +697,12 @@ function lt() {
|
|
|
697
697
|
},
|
|
698
698
|
hooks: {
|
|
699
699
|
beforeRequest: [
|
|
700
|
-
(
|
|
701
|
-
const
|
|
702
|
-
|
|
700
|
+
(t) => {
|
|
701
|
+
const e = u.getSessionToken() || u.getApiKey();
|
|
702
|
+
t.headers.set("Authorization", `Bearer ${e}`);
|
|
703
703
|
}
|
|
704
704
|
],
|
|
705
|
-
afterResponse: [(
|
|
705
|
+
afterResponse: [(t, e, s) => s]
|
|
706
706
|
},
|
|
707
707
|
retry: {
|
|
708
708
|
limit: 2
|
|
@@ -713,71 +713,71 @@ function c() {
|
|
|
713
713
|
return M || lt(), M;
|
|
714
714
|
}
|
|
715
715
|
class ht {
|
|
716
|
-
async getById(
|
|
717
|
-
return await c().get("intents/" +
|
|
716
|
+
async getById(e) {
|
|
717
|
+
return await c().get("intents/" + e).json();
|
|
718
718
|
}
|
|
719
|
-
async getForSender(
|
|
720
|
-
return await c().get("intents/user/" +
|
|
719
|
+
async getForSender(e) {
|
|
720
|
+
return await c().get("intents/user/" + e).json();
|
|
721
721
|
}
|
|
722
|
-
async getForAddress(
|
|
723
|
-
return await c().get("intents/address/" +
|
|
722
|
+
async getForAddress(e) {
|
|
723
|
+
return await c().get("intents/address/" + e).json();
|
|
724
724
|
}
|
|
725
|
-
async getForSession(
|
|
726
|
-
return await c().get("modal/sessions/intents/" +
|
|
725
|
+
async getForSession(e) {
|
|
726
|
+
return await c().get("modal/sessions/intents/" + e).json();
|
|
727
727
|
}
|
|
728
|
-
async getAll(
|
|
729
|
-
return await c().get("intents", { searchParams:
|
|
728
|
+
async getAll(e) {
|
|
729
|
+
return await c().get("intents", { searchParams: e }).json();
|
|
730
730
|
}
|
|
731
|
-
async create(
|
|
732
|
-
return await c().post("intents", { json:
|
|
731
|
+
async create(e) {
|
|
732
|
+
return await c().post("intents", { json: e }).json();
|
|
733
733
|
}
|
|
734
|
-
async createForSession(
|
|
735
|
-
return await c().post("modal/sessions/intents", { json:
|
|
734
|
+
async createForSession(e) {
|
|
735
|
+
return await c().post("modal/sessions/intents", { json: e }).json();
|
|
736
736
|
}
|
|
737
|
-
async update(
|
|
737
|
+
async update(e, s) {
|
|
738
738
|
return await c().post("intents", { json: s }).json();
|
|
739
739
|
}
|
|
740
|
-
async triggerProcessing(
|
|
741
|
-
return await c().post(`intents/${
|
|
740
|
+
async triggerProcessing(e) {
|
|
741
|
+
return await c().post(`intents/${e}/trigger-processing`).json();
|
|
742
742
|
}
|
|
743
|
-
async triggerProcessingForSession(
|
|
744
|
-
return await c().post(`modal/sessions/intents/${
|
|
743
|
+
async triggerProcessingForSession(e) {
|
|
744
|
+
return await c().post(`modal/sessions/intents/${e}/process`).json();
|
|
745
745
|
}
|
|
746
746
|
}
|
|
747
747
|
class dt {
|
|
748
|
-
async getFromSpecificBridge(
|
|
749
|
-
return await c().get("quotes/single", { searchParams:
|
|
748
|
+
async getFromSpecificBridge(e) {
|
|
749
|
+
return await c().get("quotes/single", { searchParams: e }).json();
|
|
750
750
|
}
|
|
751
|
-
async getFromAllBridges(
|
|
752
|
-
return await c().get("quotes/multiple", { searchParams:
|
|
751
|
+
async getFromAllBridges(e) {
|
|
752
|
+
return await c().get("quotes/multiple", { searchParams: e }).json();
|
|
753
753
|
}
|
|
754
|
-
async getBestAcrossBridges(
|
|
755
|
-
return await c().get("quotes/best", { searchParams:
|
|
754
|
+
async getBestAcrossBridges(e) {
|
|
755
|
+
return await c().get("quotes/best", { searchParams: e }).json();
|
|
756
756
|
}
|
|
757
|
-
async getAll(
|
|
758
|
-
return await c().get("quotes/multi-source", { searchParams:
|
|
757
|
+
async getAll(e) {
|
|
758
|
+
return await c().get("quotes/multi-source", { searchParams: e }).json();
|
|
759
759
|
}
|
|
760
|
-
async getAllForSession(
|
|
761
|
-
return await c().get("modal/sessions/quotes", { searchParams:
|
|
760
|
+
async getAllForSession(e) {
|
|
761
|
+
return await c().get("modal/sessions/quotes", { searchParams: e }).json();
|
|
762
762
|
}
|
|
763
763
|
}
|
|
764
764
|
class pt {
|
|
765
|
-
async getOptimalRoutes(
|
|
766
|
-
return await c().get("router/optimal-route", { searchParams:
|
|
765
|
+
async getOptimalRoutes(e) {
|
|
766
|
+
return await c().get("router/optimal-route", { searchParams: e }).json();
|
|
767
767
|
}
|
|
768
768
|
async getAllSupportedBridges() {
|
|
769
769
|
return await c().get("router/supported-bridges/all").json();
|
|
770
770
|
}
|
|
771
|
-
async getSupportedBridges(
|
|
772
|
-
return await c().get("router/supported-bridges/route", { searchParams:
|
|
771
|
+
async getSupportedBridges(e) {
|
|
772
|
+
return await c().get("router/supported-bridges/route", { searchParams: e }).json();
|
|
773
773
|
}
|
|
774
|
-
async getSupportedRoutes(
|
|
775
|
-
return await c().get("router/supported-bridges/bridge/" +
|
|
774
|
+
async getSupportedRoutes(e, s) {
|
|
775
|
+
return await c().get("router/supported-bridges/bridge/" + e, { searchParams: s }).json();
|
|
776
776
|
}
|
|
777
777
|
}
|
|
778
778
|
class gt {
|
|
779
|
-
async getSupported(
|
|
780
|
-
return await c().get("chains", { searchParams:
|
|
779
|
+
async getSupported(e) {
|
|
780
|
+
return await c().get("chains", { searchParams: e }).json();
|
|
781
781
|
}
|
|
782
782
|
}
|
|
783
783
|
class ft {
|
|
@@ -789,17 +789,17 @@ class ft {
|
|
|
789
789
|
}
|
|
790
790
|
}
|
|
791
791
|
class mt {
|
|
792
|
-
getSessionToken(
|
|
792
|
+
getSessionToken(e) {
|
|
793
793
|
const s = {
|
|
794
|
-
recipient:
|
|
794
|
+
recipient: e.recipient,
|
|
795
795
|
tokenOut: ut(
|
|
796
|
-
|
|
797
|
-
ye[
|
|
796
|
+
$[e.destinationChain],
|
|
797
|
+
ye[e.token]
|
|
798
798
|
),
|
|
799
|
-
destinationChain:
|
|
800
|
-
amount:
|
|
799
|
+
destinationChain: $[e.destinationChain],
|
|
800
|
+
amount: e.amount
|
|
801
801
|
};
|
|
802
|
-
return c().post("modal/sessions", { json: s }).json();
|
|
802
|
+
return c().post("modal/sessions", { json: s }).json().then((n) => ({ ...n, amount: s.amount }));
|
|
803
803
|
}
|
|
804
804
|
}
|
|
805
805
|
const bt = {
|
|
@@ -812,7 +812,7 @@ const bt = {
|
|
|
812
812
|
};
|
|
813
813
|
export {
|
|
814
814
|
u as Chainrails,
|
|
815
|
-
|
|
815
|
+
$ as chains,
|
|
816
816
|
bt as crapi,
|
|
817
817
|
Ie as environment,
|
|
818
818
|
It as getTokenDecimals,
|