@chainrails/sdk 0.0.31 → 0.0.33

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.
@@ -1,49 +1,663 @@
1
- import g from "ky";
2
- var h = /* @__PURE__ */ ((e) => (e.ARBITRUM = "ARBITRUM_MAINNET", e.ARBITRUM_TESTNET = "ARBITRUM_TESTNET", e.AVALANCHE = "AVALANCHE_MAINNET", e.AVALANCHE_TESTNET = "AVALANCHE_TESTNET", e.BASE = "BASE_MAINNET", e.BASE_TESTNET = "BASE_TESTNET", e.BSC = "BSC_MAINNET", e.ETHEREUM = "ETHEREUM_MAINNET", e.ETHEREUM_TESTNET = "ETHEREUM_TESTNET", e.STARKNET = "STARKNET_MAINNET", e))(h || {}), E = /* @__PURE__ */ ((e) => (e.USDC = "USDC", e))(E || {}), p = /* @__PURE__ */ ((e) => (e.PRODUCTION = "production", e.STAGING = "staging", e))(p || {});
3
- class a {
4
- constructor({ api_key: t, env: n }) {
5
- this.api_key = t, this.jwt = "", this.env = n ?? p.PRODUCTION;
1
+ import le from "ky";
2
+ var h = /* @__PURE__ */ ((e) => (e.USDC = "USDC", e))(h || {});
3
+ const P = {
4
+ type: "evm",
5
+ chainId: 42161,
6
+ name: "Arbitrum",
7
+ cctpDomain: 3,
8
+ logoURI: "/images/chains/arbitrum.svg"
9
+ }, j = {
10
+ type: "evm",
11
+ chainId: 421614,
12
+ name: "Arbitrum Sepolia",
13
+ cctpDomain: 3,
14
+ logoURI: "/images/chains/arbitrum.svg"
15
+ }, _ = {
16
+ type: "evm",
17
+ chainId: 8453,
18
+ name: "Base",
19
+ cctpDomain: 6,
20
+ logoURI: "/images/chains/base.webp"
21
+ }, F = {
22
+ type: "evm",
23
+ chainId: 84532,
24
+ name: "Base Sepolia",
25
+ cctpDomain: 6,
26
+ logoURI: "/images/chains/base.webp"
27
+ }, L = {
28
+ type: "evm",
29
+ chainId: 56,
30
+ name: "BNB Chain",
31
+ cctpDomain: null,
32
+ logoURI: "/images/chains/bsc.webp"
33
+ }, H = {
34
+ type: "evm",
35
+ chainId: 1,
36
+ name: "Ethereum",
37
+ cctpDomain: 0,
38
+ logoURI: "/images/chains/ethereum.svg"
39
+ }, K = {
40
+ type: "evm",
41
+ chainId: 11155111,
42
+ name: "Ethereum Sepolia",
43
+ cctpDomain: 0,
44
+ logoURI: "/images/chains/ethereum.svg"
45
+ }, q = {
46
+ type: "evm",
47
+ chainId: 43114,
48
+ name: "Avalanche",
49
+ cctpDomain: 1,
50
+ logoURI: "/images/chains/avalanche.svg"
51
+ }, V = {
52
+ type: "evm",
53
+ chainId: 43113,
54
+ name: "Avalanche Fuji",
55
+ cctpDomain: 1,
56
+ logoURI: "/images/chains/avalanche.svg"
57
+ }, X = {
58
+ type: "starknet",
59
+ chainId: "0x534e5f4d41494e",
60
+ // SN_MAIN
61
+ name: "Starknet",
62
+ cctpDomain: null,
63
+ logoURI: "/images/chains/starknet.svg"
64
+ };
65
+ function C(e, { strict: t = !0 } = {}) {
66
+ return !e || typeof e != "string" ? !1 : t ? /^0x[0-9a-fA-F]*$/.test(e) : e.startsWith("0x");
67
+ }
68
+ function D(e) {
69
+ return C(e, { strict: !1 }) ? Math.ceil((e.length - 2) / 2) : e.length;
70
+ }
71
+ const G = "2.43.4";
72
+ let S = {
73
+ getDocsUrl: ({ docsBaseUrl: e, docsPath: t = "", docsSlug: s }) => t ? `${e ?? "https://viem.sh"}${t}${s ? `#${s}` : ""}` : void 0,
74
+ version: `viem@${G}`
75
+ };
76
+ class g extends Error {
77
+ constructor(t, s = {}) {
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
+ t || "An error occurred.",
80
+ "",
81
+ ...s.metaMessages ? [...s.metaMessages, ""] : [],
82
+ ...r ? [`Docs: ${r}`] : [],
83
+ ...n ? [`Details: ${n}`] : [],
84
+ ...S.version ? [`Version: ${S.version}`] : []
85
+ ].join(`
86
+ `);
87
+ super(o, s.cause ? { cause: s.cause } : void 0), Object.defineProperty(this, "details", {
88
+ enumerable: !0,
89
+ configurable: !0,
90
+ writable: !0,
91
+ value: void 0
92
+ }), Object.defineProperty(this, "docsPath", {
93
+ enumerable: !0,
94
+ configurable: !0,
95
+ writable: !0,
96
+ value: void 0
97
+ }), Object.defineProperty(this, "metaMessages", {
98
+ enumerable: !0,
99
+ configurable: !0,
100
+ writable: !0,
101
+ value: void 0
102
+ }), Object.defineProperty(this, "shortMessage", {
103
+ enumerable: !0,
104
+ configurable: !0,
105
+ writable: !0,
106
+ value: void 0
107
+ }), Object.defineProperty(this, "version", {
108
+ enumerable: !0,
109
+ configurable: !0,
110
+ writable: !0,
111
+ value: void 0
112
+ }), Object.defineProperty(this, "name", {
113
+ enumerable: !0,
114
+ configurable: !0,
115
+ writable: !0,
116
+ value: "BaseError"
117
+ }), this.details = n, this.docsPath = i, this.metaMessages = s.metaMessages, this.name = s.name ?? this.name, this.shortMessage = t, this.version = G;
118
+ }
119
+ walk(t) {
120
+ return Q(this, t);
121
+ }
122
+ }
123
+ function Q(e, t) {
124
+ return t?.(e) ? e : e && typeof e == "object" && "cause" in e && e.cause !== void 0 ? Q(e.cause, t) : t ? null : e;
125
+ }
126
+ class W extends g {
127
+ constructor({ size: t, targetSize: s, type: n }) {
128
+ super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (${t}) exceeds padding size (${s}).`, { name: "SizeExceedsPaddingSizeError" });
129
+ }
130
+ }
131
+ function w(e, { dir: t, size: s = 32 } = {}) {
132
+ return typeof e == "string" ? he(e, { dir: t, size: s }) : pe(e, { dir: t, size: s });
133
+ }
134
+ function he(e, { dir: t, size: s = 32 } = {}) {
135
+ if (s === null)
136
+ return e;
137
+ const n = e.replace("0x", "");
138
+ if (n.length > s * 2)
139
+ throw new W({
140
+ size: Math.ceil(n.length / 2),
141
+ targetSize: s,
142
+ type: "hex"
143
+ });
144
+ return `0x${n[t === "right" ? "padEnd" : "padStart"](s * 2, "0")}`;
145
+ }
146
+ function pe(e, { dir: t, size: s = 32 } = {}) {
147
+ if (s === null)
148
+ return e;
149
+ if (e.length > s)
150
+ throw new W({
151
+ size: e.length,
152
+ targetSize: s,
153
+ type: "bytes"
154
+ });
155
+ const n = new Uint8Array(s);
156
+ for (let i = 0; i < s; i++) {
157
+ const r = t === "right";
158
+ n[r ? i : s - i - 1] = e[r ? i : e.length - i - 1];
159
+ }
160
+ return n;
161
+ }
162
+ class de extends g {
163
+ constructor({ max: t, 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 ${t ? `(${s} to ${t})` : `(above ${s})`}`, { name: "IntegerOutOfRangeError" });
165
+ }
166
+ }
167
+ class ge extends g {
168
+ constructor({ givenSize: t, maxSize: s }) {
169
+ super(`Size cannot exceed ${s} bytes. Given size: ${t} bytes.`, { name: "SizeOverflowError" });
170
+ }
171
+ }
172
+ function T(e, { size: t }) {
173
+ if (D(e) > t)
174
+ throw new ge({
175
+ givenSize: D(e),
176
+ maxSize: t
177
+ });
178
+ }
179
+ function fe(e, t = {}) {
180
+ const { signed: s, size: n } = t, i = BigInt(e);
181
+ let r;
182
+ n ? s ? r = (1n << BigInt(n) * 8n - 1n) - 1n : r = 2n ** (BigInt(n) * 8n) - 1n : typeof e == "number" && (r = BigInt(Number.MAX_SAFE_INTEGER));
183
+ const o = typeof r == "bigint" && s ? -r - 1n : 0;
184
+ if (r && i > r || i < o) {
185
+ const l = typeof e == "bigint" ? "n" : "";
186
+ throw new de({
187
+ max: r ? `${r}${l}` : void 0,
188
+ min: `${o}${l}`,
189
+ signed: s,
190
+ size: n,
191
+ value: `${e}${l}`
192
+ });
193
+ }
194
+ const a = `0x${(s && i < 0 ? (1n << BigInt(n * 8)) + BigInt(i) : i).toString(16)}`;
195
+ return n ? w(a, { size: n }) : a;
196
+ }
197
+ const me = /* @__PURE__ */ new TextEncoder();
198
+ function ye(e, t = {}) {
199
+ return typeof e == "number" || typeof e == "bigint" ? Ie(e, t) : typeof e == "boolean" ? be(e, t) : C(e) ? J(e, t) : Y(e, t);
200
+ }
201
+ function be(e, t = {}) {
202
+ const s = new Uint8Array(1);
203
+ return s[0] = Number(e), typeof t.size == "number" ? (T(s, { size: t.size }), w(s, { size: t.size })) : s;
204
+ }
205
+ const p = {
206
+ zero: 48,
207
+ nine: 57,
208
+ A: 65,
209
+ F: 70,
210
+ a: 97,
211
+ f: 102
212
+ };
213
+ function R(e) {
214
+ if (e >= p.zero && e <= p.nine)
215
+ return e - p.zero;
216
+ if (e >= p.A && e <= p.F)
217
+ return e - (p.A - 10);
218
+ if (e >= p.a && e <= p.f)
219
+ return e - (p.a - 10);
220
+ }
221
+ function J(e, t = {}) {
222
+ let s = e;
223
+ t.size && (T(s, { size: t.size }), s = w(s, { dir: "right", size: t.size }));
224
+ let n = s.slice(2);
225
+ n.length % 2 && (n = `0${n}`);
226
+ const i = n.length / 2, r = new Uint8Array(i);
227
+ for (let o = 0, a = 0; o < i; o++) {
228
+ const l = R(n.charCodeAt(a++)), f = R(n.charCodeAt(a++));
229
+ if (l === void 0 || f === void 0)
230
+ throw new g(`Invalid byte sequence ("${n[a - 2]}${n[a - 1]}" in "${n}").`);
231
+ r[o] = l * 16 + f;
232
+ }
233
+ return r;
234
+ }
235
+ function Ie(e, t) {
236
+ const s = fe(e, t);
237
+ return J(s);
238
+ }
239
+ function Y(e, t = {}) {
240
+ const s = me.encode(e);
241
+ return typeof t.size == "number" ? (T(s, { size: t.size }), w(s, { dir: "right", size: t.size })) : s;
242
+ }
243
+ const I = /* @__PURE__ */ BigInt(2 ** 32 - 1), k = /* @__PURE__ */ BigInt(32);
244
+ function Ee(e, t = !1) {
245
+ return t ? { h: Number(e & I), l: Number(e >> k & I) } : { h: Number(e >> k & I) | 0, l: Number(e & I) | 0 };
246
+ }
247
+ function we(e, t = !1) {
248
+ const s = e.length;
249
+ let n = new Uint32Array(s), i = new Uint32Array(s);
250
+ for (let r = 0; r < s; r++) {
251
+ const { h: o, l: a } = Ee(e[r], t);
252
+ [n[r], i[r]] = [o, a];
253
+ }
254
+ return [n, i];
255
+ }
256
+ const Se = (e, t, s) => e << s | t >>> 32 - s, Ae = (e, t, s) => t << s | e >>> 32 - s, Ue = (e, t, s) => t << s - 32 | e >>> 64 - s, ve = (e, t, s) => e << s - 32 | t >>> 64 - s;
257
+ /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
258
+ function Ce(e) {
259
+ return e instanceof Uint8Array || ArrayBuffer.isView(e) && e.constructor.name === "Uint8Array";
260
+ }
261
+ function N(e) {
262
+ if (!Number.isSafeInteger(e) || e < 0)
263
+ throw new Error("positive integer expected, got " + e);
264
+ }
265
+ function E(e, ...t) {
266
+ if (!Ce(e))
267
+ throw new Error("Uint8Array expected");
268
+ if (t.length > 0 && !t.includes(e.length))
269
+ throw new Error("Uint8Array expected of length " + t + ", got length=" + e.length);
270
+ }
271
+ function B(e, t = !0) {
272
+ if (e.destroyed)
273
+ throw new Error("Hash instance has been destroyed");
274
+ if (t && e.finished)
275
+ throw new Error("Hash#digest() has already been called");
276
+ }
277
+ function Te(e, t) {
278
+ E(e);
279
+ const s = t.outputLen;
280
+ if (e.length < s)
281
+ throw new Error("digestInto() expects output buffer of length at least " + s);
282
+ }
283
+ function xe(e) {
284
+ return new Uint32Array(e.buffer, e.byteOffset, Math.floor(e.byteLength / 4));
285
+ }
286
+ function Z(...e) {
287
+ for (let t = 0; t < e.length; t++)
288
+ e[t].fill(0);
289
+ }
290
+ const De = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
291
+ function Re(e) {
292
+ return e << 24 & 4278190080 | e << 8 & 16711680 | e >>> 8 & 65280 | e >>> 24 & 255;
293
+ }
294
+ function ke(e) {
295
+ for (let t = 0; t < e.length; t++)
296
+ e[t] = Re(e[t]);
297
+ return e;
298
+ }
299
+ const $ = De ? (e) => e : ke;
300
+ function Ne(e) {
301
+ if (typeof e != "string")
302
+ throw new Error("string expected");
303
+ return new Uint8Array(new TextEncoder().encode(e));
304
+ }
305
+ function ee(e) {
306
+ return typeof e == "string" && (e = Ne(e)), E(e), e;
307
+ }
308
+ class Be {
309
+ }
310
+ function $e(e) {
311
+ const t = (n) => e().update(ee(n)).digest(), s = e();
312
+ return t.outputLen = s.outputLen, t.blockLen = s.blockLen, t.create = () => e(), t;
313
+ }
314
+ const ze = BigInt(0), y = BigInt(1), Me = BigInt(2), Oe = BigInt(7), Pe = BigInt(256), je = BigInt(113), te = [], se = [], ne = [];
315
+ for (let e = 0, t = y, s = 1, n = 0; e < 24; e++) {
316
+ [s, n] = [n, (2 * s + 3 * n) % 5], te.push(2 * (5 * n + s)), se.push((e + 1) * (e + 2) / 2 % 64);
317
+ let i = ze;
318
+ for (let r = 0; r < 7; r++)
319
+ t = (t << y ^ (t >> Oe) * je) % Pe, t & Me && (i ^= y << (y << /* @__PURE__ */ BigInt(r)) - y);
320
+ ne.push(i);
321
+ }
322
+ const ie = we(ne, !0), _e = ie[0], Fe = ie[1], z = (e, t, s) => s > 32 ? Ue(e, t, s) : Se(e, t, s), M = (e, t, s) => s > 32 ? ve(e, t, s) : Ae(e, t, s);
323
+ function Le(e, t = 24) {
324
+ const s = new Uint32Array(10);
325
+ for (let n = 24 - t; n < 24; n++) {
326
+ for (let o = 0; o < 10; o++)
327
+ s[o] = e[o] ^ e[o + 10] ^ e[o + 20] ^ e[o + 30] ^ e[o + 40];
328
+ for (let o = 0; o < 10; o += 2) {
329
+ const a = (o + 8) % 10, l = (o + 2) % 10, f = s[l], m = s[l + 1], ce = z(f, m, 1) ^ s[a], ue = M(f, m, 1) ^ s[a + 1];
330
+ for (let b = 0; b < 50; b += 10)
331
+ e[o + b] ^= ce, e[o + b + 1] ^= ue;
332
+ }
333
+ let i = e[2], r = e[3];
334
+ for (let o = 0; o < 24; o++) {
335
+ const a = se[o], l = z(i, r, a), f = M(i, r, a), m = te[o];
336
+ i = e[m], r = e[m + 1], e[m] = l, e[m + 1] = f;
337
+ }
338
+ for (let o = 0; o < 50; o += 10) {
339
+ for (let a = 0; a < 10; a++)
340
+ s[a] = e[o + a];
341
+ for (let a = 0; a < 10; a++)
342
+ e[o + a] ^= ~s[(a + 2) % 10] & s[(a + 4) % 10];
343
+ }
344
+ e[0] ^= _e[n], e[1] ^= Fe[n];
345
+ }
346
+ Z(s);
347
+ }
348
+ class x extends Be {
349
+ // NOTE: we accept arguments in bytes instead of bits here.
350
+ constructor(t, 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 = t, this.suffix = s, this.outputLen = n, this.enableXOF = i, this.rounds = r, N(n), !(0 < t && t < 200))
352
+ throw new Error("only keccak-f1600 function is supported");
353
+ this.state = new Uint8Array(200), this.state32 = xe(this.state);
354
+ }
355
+ clone() {
356
+ return this._cloneInto();
357
+ }
358
+ keccak() {
359
+ $(this.state32), Le(this.state32, this.rounds), $(this.state32), this.posOut = 0, this.pos = 0;
360
+ }
361
+ update(t) {
362
+ B(this), t = ee(t), E(t);
363
+ const { blockLen: s, state: n } = this, i = t.length;
364
+ for (let r = 0; r < i; ) {
365
+ const o = Math.min(s - this.pos, i - r);
366
+ for (let a = 0; a < o; a++)
367
+ n[this.pos++] ^= t[r++];
368
+ this.pos === s && this.keccak();
369
+ }
370
+ return this;
371
+ }
372
+ finish() {
373
+ if (this.finished)
374
+ return;
375
+ this.finished = !0;
376
+ const { state: t, suffix: s, pos: n, blockLen: i } = this;
377
+ t[n] ^= s, (s & 128) !== 0 && n === i - 1 && this.keccak(), t[i - 1] ^= 128, this.keccak();
378
+ }
379
+ writeInto(t) {
380
+ B(this, !1), E(t), this.finish();
381
+ const s = this.state, { blockLen: n } = this;
382
+ for (let i = 0, r = t.length; i < r; ) {
383
+ this.posOut >= n && this.keccak();
384
+ const o = Math.min(n - this.posOut, r - i);
385
+ t.set(s.subarray(this.posOut, this.posOut + o), i), this.posOut += o, i += o;
386
+ }
387
+ return t;
388
+ }
389
+ xofInto(t) {
390
+ if (!this.enableXOF)
391
+ throw new Error("XOF is not possible for this instance");
392
+ return this.writeInto(t);
393
+ }
394
+ xof(t) {
395
+ return N(t), this.xofInto(new Uint8Array(t));
396
+ }
397
+ digestInto(t) {
398
+ if (Te(t, this), this.finished)
399
+ throw new Error("digest() was already called");
400
+ return this.writeInto(t), this.destroy(), t;
401
+ }
402
+ digest() {
403
+ return this.digestInto(new Uint8Array(this.outputLen));
404
+ }
405
+ destroy() {
406
+ this.destroyed = !0, Z(this.state);
407
+ }
408
+ _cloneInto(t) {
409
+ const { blockLen: s, suffix: n, outputLen: i, rounds: r, enableXOF: o } = this;
410
+ return t || (t = new x(s, n, i, o, r)), t.state32.set(this.state32), t.pos = this.pos, t.posOut = this.posOut, t.finished = this.finished, t.rounds = r, t.suffix = n, t.outputLen = i, t.enableXOF = o, t.destroyed = this.destroyed, t;
411
+ }
412
+ }
413
+ const He = (e, t, s) => $e(() => new x(t, e, s)), Ke = He(1, 136, 256 / 8);
414
+ function qe(e, t) {
415
+ return Ke(C(e, { strict: !1 }) ? ye(e) : e);
416
+ }
417
+ class Ve extends g {
418
+ constructor({ address: t }) {
419
+ super(`Address "${t}" is invalid.`, {
420
+ metaMessages: [
421
+ "- Address must be a hex value of 20 bytes (40 hex characters).",
422
+ "- Address must match its checksum counterpart."
423
+ ],
424
+ name: "InvalidAddressError"
425
+ });
426
+ }
427
+ }
428
+ class oe extends Map {
429
+ constructor(t) {
430
+ super(), Object.defineProperty(this, "maxSize", {
431
+ enumerable: !0,
432
+ configurable: !0,
433
+ writable: !0,
434
+ value: void 0
435
+ }), this.maxSize = t;
436
+ }
437
+ get(t) {
438
+ const s = super.get(t);
439
+ return super.has(t) && s !== void 0 && (this.delete(t), super.set(t, s)), s;
440
+ }
441
+ set(t, s) {
442
+ if (super.set(t, s), this.maxSize && this.size > this.maxSize) {
443
+ const n = this.keys().next().value;
444
+ n && this.delete(n);
445
+ }
446
+ return this;
447
+ }
448
+ }
449
+ const A = /* @__PURE__ */ new oe(8192);
450
+ function re(e, t) {
451
+ if (A.has(`${e}.${t}`))
452
+ return A.get(`${e}.${t}`);
453
+ const s = e.substring(2).toLowerCase(), n = qe(Y(s)), i = s.split("");
454
+ for (let o = 0; o < 40; o += 2)
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
+ const r = `0x${i.join("")}`;
457
+ return A.set(`${e}.${t}`, r), r;
458
+ }
459
+ function d(e, t) {
460
+ if (!Ge(e, { strict: !1 }))
461
+ throw new Ve({ address: e });
462
+ return re(e, t);
463
+ }
464
+ const Xe = /^0x[a-fA-F0-9]{40}$/, U = /* @__PURE__ */ new oe(8192);
465
+ function Ge(e, t) {
466
+ const { strict: s = !0 } = t ?? {}, n = `${e}.${s}`;
467
+ if (U.has(n))
468
+ return U.get(n);
469
+ const i = Xe.test(e) ? e.toLowerCase() === e ? !0 : s ? re(e) === e : !0 : !1;
470
+ return U.set(n, i), i;
471
+ }
472
+ const Qe = {
473
+ chainId: j.chainId,
474
+ address: d("0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d"),
475
+ symbol: "USDC",
476
+ fiatISO: "USD",
477
+ decimals: 6,
478
+ logoURI: "https://pay.daimo.com/coin-logos/usdc.png",
479
+ logoSourceURI: "https://pay.daimo.com/coin-logos/usdc.png"
480
+ }, We = {
481
+ chainId: P.chainId,
482
+ address: d("0xaf88d065e77c8cC2239327C5EDb3A432268e5831"),
483
+ symbol: "USDC",
484
+ name: "USD Coin",
485
+ decimals: 6,
486
+ logoURI: "https://pay.daimo.com/coin-logos/usdc.png"
487
+ /* USDC */
488
+ }, Je = {
489
+ chainId: V.chainId,
490
+ address: d("0x5425890298aed601595a70ab815c96711a31bc65"),
491
+ symbol: "USDC",
492
+ fiatISO: "USD",
493
+ decimals: 6,
494
+ logoURI: "https://pay.daimo.com/coin-logos/usdc.png",
495
+ logoSourceURI: "https://pay.daimo.com/coin-logos/usdc.png"
496
+ }, Ye = {
497
+ chainId: q.chainId,
498
+ address: d("0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E"),
499
+ symbol: "USDC",
500
+ fiatISO: "USD",
501
+ decimals: 6,
502
+ logoURI: "https://pay.daimo.com/coin-logos/usdc.png",
503
+ logoSourceURI: "https://pay.daimo.com/coin-logos/usdc.png"
504
+ }, Ze = {
505
+ chainId: F.chainId,
506
+ address: d("0x036CbD53842c5426634e7929541eC2318f3dCF7e"),
507
+ symbol: "USDC",
508
+ fiatISO: "USD",
509
+ decimals: 6,
510
+ logoURI: "https://pay.daimo.com/coin-logos/usdc.png",
511
+ logoSourceURI: "https://pay.daimo.com/coin-logos/usdc.png"
512
+ }, et = {
513
+ chainId: _.chainId,
514
+ address: d("0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"),
515
+ symbol: "USDC",
516
+ fiatISO: "USD",
517
+ decimals: 6,
518
+ logoURI: "https://pay.daimo.com/coin-logos/usdc.png",
519
+ logoSourceURI: "https://pay.daimo.com/coin-logos/usdc.png"
520
+ }, tt = {
521
+ chainId: L.chainId,
522
+ address: d("0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"),
523
+ symbol: "USDC",
524
+ decimals: 18,
525
+ logoURI: "https://pay.daimo.com/coin-logos/usdc.png",
526
+ logoSourceURI: "https://pay.daimo.com/coin-logos/usdc.png"
527
+ }, st = {
528
+ chainId: K.chainId,
529
+ address: d("0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238"),
530
+ symbol: "USDC",
531
+ decimals: 6,
532
+ logoURI: "https://pay.daimo.com/coin-logos/usdc.png",
533
+ logoSourceURI: "https://pay.daimo.com/coin-logos/usdc.png"
534
+ }, nt = {
535
+ chainId: H.chainId,
536
+ address: d("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"),
537
+ symbol: "USDC",
538
+ decimals: 6,
539
+ logoURI: "https://pay.daimo.com/coin-logos/usdc.png",
540
+ logoSourceURI: "https://pay.daimo.com/coin-logos/usdc.png"
541
+ }, it = {
542
+ chainId: X.chainId,
543
+ address: "0x053C91253BC9682c04929cA02ED00b3E423f6710D2ee7e0D5EBB06F3eCF368A8",
544
+ symbol: "USDC",
545
+ decimals: 6,
546
+ logoURI: "https://pay.daimo.com/coin-logos/usdc.png",
547
+ logoSourceURI: "https://pay.daimo.com/coin-logos/usdc.png"
548
+ }, O = {
549
+ ARBITRUM_MAINNET: {
550
+ ...P,
551
+ tokens: {
552
+ [h.USDC]: We
553
+ },
554
+ explorer: "https://arbiscan.io"
555
+ },
556
+ ARBITRUM_TESTNET: {
557
+ ...j,
558
+ explorer: "https://sepolia.arbiscan.io",
559
+ tokens: {
560
+ [h.USDC]: Qe
561
+ }
562
+ },
563
+ AVALANCHE_MAINNET: {
564
+ ...q,
565
+ tokens: {
566
+ [h.USDC]: Ye
567
+ },
568
+ explorer: "https://snowtrace.io"
569
+ },
570
+ AVALANCHE_TESTNET: {
571
+ ...V,
572
+ tokens: {
573
+ [h.USDC]: Je
574
+ },
575
+ explorer: "https://testnet.snowtrace.io"
576
+ },
577
+ BASE_MAINNET: {
578
+ ..._,
579
+ tokens: {
580
+ [h.USDC]: et
581
+ },
582
+ explorer: "https://basescan.org"
583
+ },
584
+ BASE_TESTNET: {
585
+ ...F,
586
+ tokens: {
587
+ [h.USDC]: Ze
588
+ },
589
+ explorer: "https://sepolia.basescan.org"
590
+ },
591
+ BSC_MAINNET: {
592
+ ...L,
593
+ tokens: {
594
+ [h.USDC]: tt
595
+ },
596
+ explorer: "https://bscscan.com"
597
+ },
598
+ ETHEREUM_MAINNET: {
599
+ ...H,
600
+ tokens: {
601
+ [h.USDC]: nt
602
+ },
603
+ explorer: "https://etherscan.io"
604
+ },
605
+ ETHEREUM_TESTNET: {
606
+ ...K,
607
+ tokens: {
608
+ [h.USDC]: st
609
+ },
610
+ explorer: "https://sepolia.etherscan.io"
611
+ },
612
+ STARKNET_MAINNET: {
613
+ ...X,
614
+ tokens: {
615
+ [h.USDC]: it
616
+ },
617
+ explorer: ""
618
+ }
619
+ };
620
+ var ot = /* @__PURE__ */ ((e) => (e.ARBITRUM = "ARBITRUM_MAINNET", e.ARBITRUM_TESTNET = "ARBITRUM_TESTNET", e.AVALANCHE = "AVALANCHE_MAINNET", e.AVALANCHE_TESTNET = "AVALANCHE_TESTNET", e.BASE = "BASE_MAINNET", e.BASE_TESTNET = "BASE_TESTNET", e.BSC = "BSC_MAINNET", e.ETHEREUM = "ETHEREUM_MAINNET", e.ETHEREUM_TESTNET = "ETHEREUM_TESTNET", e.STARKNET = "STARKNET_MAINNET", e))(ot || {}), rt = /* @__PURE__ */ ((e) => (e.USDC = "USDC", e))(rt || {});
621
+ const at = (e) => {
622
+ const t = e.trim().toUpperCase();
623
+ if (O[t])
624
+ return O[t];
625
+ };
626
+ function ct(e, t) {
627
+ return at(e)?.tokens[t]?.address;
628
+ }
629
+ var ae = /* @__PURE__ */ ((e) => (e.PRODUCTION = "production", e.STAGING = "staging", e))(ae || {});
630
+ class c {
631
+ constructor({ api_key: t, env: s, seesion_token: n }) {
632
+ this.api_key = t || "", this.sessionToken = n || "", this.env = s ?? ae.PRODUCTION;
6
633
  }
7
634
  static async config(t) {
8
- if (!a.app) {
635
+ if (!c.app) {
9
636
  if (!t)
10
637
  throw new Error("Please provide an api_key");
11
- a.app = new a(t);
12
- }
13
- return t && (a.app.api_key = t.api_key, t.env !== void 0 && (a.app.env = t.env), await this.updateJWT(), setInterval(this.updateJWT.bind(this), 1500 * 1e3)), a.app;
14
- }
15
- static async updateJWT() {
16
- try {
17
- const t = await (await fetch(this.getBaseUrl() + "/client/api-keys/session-token", {
18
- method: "POST",
19
- headers: {
20
- "content-type": "application/json"
21
- },
22
- body: JSON.stringify({
23
- apiKey: a.app.api_key
24
- })
25
- })).json();
26
- this.app.jwt = t.token;
27
- } catch {
638
+ c.app = new c(t);
28
639
  }
640
+ return t && (t.api_key !== void 0 && (c.app.api_key = t.api_key), t.seesion_token !== void 0 && (c.app.sessionToken = t.seesion_token), t.env !== void 0 && (c.app.env = t.env)), c.app;
29
641
  }
30
642
  static getApiKey() {
31
- if (!a.app)
643
+ if (!c.app)
32
644
  throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
33
- return a.app.api_key;
645
+ return c.app.api_key;
34
646
  }
35
- static getSessionKey() {
36
- return a.app.jwt;
647
+ static getSessionToken() {
648
+ if (!c.app)
649
+ throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
650
+ return c.app.sessionToken;
37
651
  }
38
652
  static getEnv() {
39
- if (!a.app)
653
+ if (!c.app)
40
654
  throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
41
- return a.app.env === "internal" ? "staging" : a.app.env;
655
+ return c.app.env === "internal" ? "staging" : c.app.env;
42
656
  }
43
657
  static getBaseUrl() {
44
- if (!a.app)
658
+ if (!c.app)
45
659
  throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
46
- switch (a.app.env) {
660
+ switch (c.app.env) {
47
661
  case "production":
48
662
  return "https://api.chainrails.io/api/v1";
49
663
  case "staging":
@@ -54,111 +668,121 @@ class a {
54
668
  return "https://api.chainrails.io/api/v1";
55
669
  }
56
670
  }
57
- static getPayModalUrl(t, n, c, r) {
58
- if (!a.app)
671
+ static getPayModalUrl(t, s, n, i) {
672
+ if (!c.app)
59
673
  throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
60
- const l = a.app.env === "internal" ? "https://chainrails-frontend-git-staging-horus-labs.vercel.app" : "https://app.chainrails.io", o = r && r > 0 ? "/pay/" : "/deposit/";
61
- console.log({ mode: o, mode2: r ? "/pay/" : "/deposit/", amount: r });
62
- const u = `_chain_/${t}/_token_/${n}/_to_/${c}${r && "/_amount_/" + r * 100}`;
63
- return l + o + u;
674
+ const r = c.app.env === "internal" ? "https://chainrails-frontend-git-staging-horus-labs.vercel.app" : "https://app.chainrails.io", o = i && i > 0 ? "/pay/" : "/deposit/", a = `_chain_/${t}/_token_/${s}/_to_/${n}${i ? "/_amount_/" + i * 100 : ""}`;
675
+ return r + o + a;
64
676
  }
65
677
  }
66
- let i = null;
67
- function T() {
68
- i = g.create({
69
- prefixUrl: a.getBaseUrl(),
678
+ let v = null;
679
+ function ut() {
680
+ v = le.create({
681
+ prefixUrl: c.getBaseUrl(),
70
682
  headers: {
71
683
  "Content-Type": "application/json"
72
684
  },
73
685
  hooks: {
74
686
  beforeRequest: [
75
687
  (e) => {
76
- const t = a.getSessionKey();
688
+ const t = c.getSessionToken() || c.getApiKey();
77
689
  e.headers.set("Authorization", `Bearer ${t}`);
78
690
  }
79
691
  ],
80
- afterResponse: [(e, t, n) => n]
692
+ afterResponse: [(e, t, s) => s]
81
693
  },
82
694
  retry: {
83
695
  limit: 2
84
696
  }
85
697
  });
86
698
  }
87
- function s() {
88
- return i || T(), i;
699
+ function u() {
700
+ return v || ut(), v;
89
701
  }
90
- class d {
702
+ class lt {
91
703
  async getById(t) {
92
- return await s().get("intents/" + t).json();
704
+ return await u().get("intents/" + t).json();
93
705
  }
94
706
  async getForSender(t) {
95
- return await s().get("intents/user/" + t).json();
707
+ return await u().get("intents/user/" + t).json();
96
708
  }
97
709
  async getForAddress(t) {
98
- return await s().get("intents/address/" + t).json();
710
+ return await u().get("intents/address/" + t).json();
99
711
  }
100
712
  async getAll(t) {
101
- return await s().get("intents", { searchParams: t }).json();
713
+ return await u().get("intents", { searchParams: t }).json();
102
714
  }
103
715
  async create(t) {
104
- return await s().post("intents", { json: t }).json();
716
+ return await u().post("intents", { json: t }).json();
105
717
  }
106
- async update(t, n) {
107
- return await s().post("intents", { json: n }).json();
718
+ async update(t, s) {
719
+ return await u().post("intents", { json: s }).json();
108
720
  }
109
721
  async triggerProcessing(t) {
110
- return await s().post(`intents/${t}/trigger-processing`).json();
722
+ return await u().post(`intents/${t}/trigger-processing`).json();
111
723
  }
112
724
  }
113
- class y {
725
+ class ht {
114
726
  async getFromSpecificBridge(t) {
115
- return await s().get("quotes/single", { searchParams: t }).json();
727
+ return await u().get("quotes/single", { searchParams: t }).json();
116
728
  }
117
729
  async getFromAllBridges(t) {
118
- return await s().get("quotes/multiple", { searchParams: t }).json();
730
+ return await u().get("quotes/multiple", { searchParams: t }).json();
119
731
  }
120
732
  async getBestAcrossBridges(t) {
121
- return await s().get("quotes/best", { searchParams: t }).json();
733
+ return await u().get("quotes/best", { searchParams: t }).json();
122
734
  }
123
735
  async getAll(t) {
124
- return await s().get("quotes/multi-source", { searchParams: t }).json();
736
+ return await u().get("quotes/multi-source", { searchParams: t }).json();
125
737
  }
126
738
  }
127
- class w {
739
+ class pt {
128
740
  async getOptimalRoutes(t) {
129
- return await s().get("router/optimal-route", { searchParams: t }).json();
741
+ return await u().get("router/optimal-route", { searchParams: t }).json();
130
742
  }
131
743
  async getAllSupportedBridges() {
132
- return await s().get("router/supported-bridges/all").json();
744
+ return await u().get("router/supported-bridges/all").json();
133
745
  }
134
746
  async getSupportedBridges(t) {
135
- return await s().get("router/supported-bridges/route", { searchParams: t }).json();
747
+ return await u().get("router/supported-bridges/route", { searchParams: t }).json();
136
748
  }
137
- async getSupportedRoutes(t, n) {
138
- return await s().get("router/supported-bridges/bridge/" + t, { searchParams: n }).json();
749
+ async getSupportedRoutes(t, s) {
750
+ return await u().get("router/supported-bridges/bridge/" + t, { searchParams: s }).json();
139
751
  }
140
752
  }
141
- class A {
753
+ class dt {
142
754
  async getSupported(t) {
143
- return await s().get("chains", { searchParams: t }).json();
755
+ return await u().get("chains", { searchParams: t }).json();
144
756
  }
145
757
  }
146
- class f {
758
+ class gt {
147
759
  async getClientInfo() {
148
- return await s().get("client/auth/client-info").json();
760
+ return await u().get("client/auth/client-info").json();
761
+ }
762
+ }
763
+ class ft {
764
+ async getSessionToken(t) {
765
+ const s = {
766
+ recipient: t.recipient,
767
+ tokenOut: ct(t.destinationChain, t.token),
768
+ destinationChain: t.destinationChain,
769
+ amount: t.amount
770
+ };
771
+ return await u().post("modal/session", { json: s }).json();
149
772
  }
150
773
  }
151
- const N = {
152
- router: new w(),
153
- quotes: new y(),
154
- intents: new d(),
155
- chains: new A(),
156
- client: new f()
774
+ const yt = {
775
+ router: new pt(),
776
+ quotes: new ht(),
777
+ intents: new lt(),
778
+ chains: new dt(),
779
+ client: new gt(),
780
+ auth: new ft()
157
781
  };
158
782
  export {
159
- a as Chainrails,
160
- h as chains,
161
- N as crapi,
162
- p as environment,
163
- E as tokens
783
+ c as Chainrails,
784
+ ot as chains,
785
+ yt as crapi,
786
+ ae as environment,
787
+ rt as tokens
164
788
  };