@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.
@@ -1,5 +1,5 @@
1
1
  import Ee from "ky";
2
- var h = /* @__PURE__ */ ((e) => (e.USDC = "USDC", e))(h || {});
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(e, { strict: t = !0 } = {}) {
66
- return !e || typeof e != "string" ? !1 : t ? /^0x[0-9a-fA-F]*$/.test(e) : e.startsWith("0x");
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(e) {
69
- return j(e, { strict: !1 }) ? Math.ceil((e.length - 2) / 2) : e.length;
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: e, docsPath: t = "", docsSlug: s }) => t ? `${e ?? "https://viem.sh"}${t}${s ? `#${s}` : ""}` : void 0,
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(t, s = {}) {
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
- t || "An error occurred.",
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 = t, this.version = ie;
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(t) {
120
- return oe(this, t);
119
+ walk(e) {
120
+ return oe(this, e);
121
121
  }
122
122
  }
123
- function oe(e, t) {
124
- return t?.(e) ? e : e && typeof e == "object" && "cause" in e && e.cause !== void 0 ? oe(e.cause, t) : t ? null : e;
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: t, targetSize: s, type: n }) {
128
- super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (${t}) exceeds padding size (${s}).`, { name: "SizeExceedsPaddingSizeError" });
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(e, { dir: t, size: s = 32 } = {}) {
132
- return typeof e == "string" ? Se(e, { dir: t, size: s }) : Ae(e, { dir: t, size: s });
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(e, { dir: t, size: s = 32 } = {}) {
134
+ function Se(t, { dir: e, size: s = 32 } = {}) {
135
135
  if (s === null)
136
- return e;
137
- const n = e.replace("0x", "");
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[t === "right" ? "padEnd" : "padStart"](s * 2, "0")}`;
144
+ return `0x${n[e === "right" ? "padEnd" : "padStart"](s * 2, "0")}`;
145
145
  }
146
- function Ae(e, { dir: t, size: s = 32 } = {}) {
146
+ function Ae(t, { dir: e, size: s = 32 } = {}) {
147
147
  if (s === null)
148
- return e;
149
- if (e.length > s)
148
+ return t;
149
+ if (t.length > s)
150
150
  throw new re({
151
- size: e.length,
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 = t === "right";
158
- n[r ? i : s - i - 1] = e[r ? i : e.length - 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: 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" });
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: t, maxSize: s }) {
169
- super(`Size cannot exceed ${s} bytes. Given size: ${t} bytes.`, { name: "SizeOverflowError" });
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(e, { size: t }) {
173
- if (F(e) > t)
172
+ function O(t, { size: e }) {
173
+ if (F(t) > e)
174
174
  throw new ve({
175
- givenSize: F(e),
176
- maxSize: t
175
+ givenSize: F(t),
176
+ maxSize: e
177
177
  });
178
178
  }
179
- function Ce(e, t = {}) {
180
- const { signed: s, size: n } = t, i = BigInt(e);
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 e == "number" && (r = BigInt(Number.MAX_SAFE_INTEGER));
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 e == "bigint" ? "n" : "";
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: `${e}${l}`
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(e, t = {}) {
199
- return typeof e == "number" || typeof e == "bigint" ? ke(e, t) : typeof e == "boolean" ? xe(e, t) : j(e) ? ae(e, t) : ce(e, t);
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(e, t = {}) {
201
+ function xe(t, e = {}) {
202
202
  const s = new Uint8Array(1);
203
- return s[0] = Number(e), typeof t.size == "number" ? (O(s, { size: t.size }), E(s, { size: t.size })) : s;
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 _(e) {
214
- if (e >= d.zero && e <= d.nine)
215
- return e - d.zero;
216
- if (e >= d.A && e <= d.F)
217
- return e - (d.A - 10);
218
- if (e >= d.a && e <= d.f)
219
- return e - (d.a - 10);
220
- }
221
- function ae(e, t = {}) {
222
- let s = e;
223
- t.size && (O(s, { size: t.size }), s = E(s, { dir: "right", size: t.size }));
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 = _(n.charCodeAt(a++)), f = _(n.charCodeAt(a++));
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 ke(e, t) {
236
- const s = Ce(e, t);
235
+ function Re(t, e) {
236
+ const s = Ce(t, e);
237
237
  return ae(s);
238
238
  }
239
- function ce(e, t = {}) {
240
- const s = Te.encode(e);
241
- return typeof t.size == "number" ? (O(s, { size: t.size }), E(s, { dir: "right", size: t.size })) : s;
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), L = /* @__PURE__ */ BigInt(32);
244
- function Re(e, t = !1) {
245
- return t ? { h: Number(e & b), l: Number(e >> L & b) } : { h: Number(e >> L & b) | 0, l: Number(e & b) | 0 };
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(e, t = !1) {
248
- const s = e.length;
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 } = Re(e[r], t);
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 = (e, t, s) => e << s | t >>> 32 - s, $e = (e, t, s) => t << s | e >>> 32 - s, ze = (e, t, s) => t << s - 32 | e >>> 64 - s, Me = (e, t, s) => e << s - 32 | t >>> 64 - s;
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(e) {
259
- return e instanceof Uint8Array || ArrayBuffer.isView(e) && e.constructor.name === "Uint8Array";
258
+ function je(t) {
259
+ return t instanceof Uint8Array || ArrayBuffer.isView(t) && t.constructor.name === "Uint8Array";
260
260
  }
261
- function H(e) {
262
- if (!Number.isSafeInteger(e) || e < 0)
263
- throw new Error("positive integer expected, got " + e);
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(e, ...t) {
266
- if (!je(e))
265
+ function w(t, ...e) {
266
+ if (!je(t))
267
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);
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(e, t = !0) {
272
- if (e.destroyed)
271
+ function q(t, e = !0) {
272
+ if (t.destroyed)
273
273
  throw new Error("Hash instance has been destroyed");
274
- if (t && e.finished)
274
+ if (e && t.finished)
275
275
  throw new Error("Hash#digest() has already been called");
276
276
  }
277
- function Oe(e, t) {
278
- w(e);
279
- const s = t.outputLen;
280
- if (e.length < s)
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(e) {
284
- return new Uint32Array(e.buffer, e.byteOffset, Math.floor(e.byteLength / 4));
283
+ function Pe(t) {
284
+ return new Uint32Array(t.buffer, t.byteOffset, Math.floor(t.byteLength / 4));
285
285
  }
286
- function ue(...e) {
287
- for (let t = 0; t < e.length; t++)
288
- e[t].fill(0);
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 _e(e) {
292
- return e << 24 & 4278190080 | e << 8 & 16711680 | e >>> 8 & 65280 | e >>> 24 & 255;
291
+ function Le(t) {
292
+ return t << 24 & 4278190080 | t << 8 & 16711680 | t >>> 8 & 65280 | t >>> 24 & 255;
293
293
  }
294
- function Le(e) {
295
- for (let t = 0; t < e.length; t++)
296
- e[t] = _e(e[t]);
297
- return e;
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 ? (e) => e : Le;
300
- function He(e) {
301
- if (typeof e != "string")
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(e));
303
+ return new Uint8Array(new TextEncoder().encode(t));
304
304
  }
305
- function le(e) {
306
- return typeof e == "string" && (e = He(e)), w(e), e;
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(e) {
311
- const t = (n) => e().update(le(n)).digest(), s = e();
312
- return t.outputLen = s.outputLen, t.blockLen = s.blockLen, t.create = () => e(), t;
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 e = 0, t = y, s = 1, n = 0; e < 24; e++) {
316
- [s, n] = [n, (2 * s + 3 * n) % 5], he.push(2 * (5 * n + s)), de.push((e + 1) * (e + 2) / 2 % 64);
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
- t = (t << y ^ (t >> Ge) * We) % Qe, t & Xe && (i ^= y << (y << /* @__PURE__ */ BigInt(r)) - y);
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 = (e, t, s) => s > 32 ? ze(e, t, s) : Be(e, t, s), X = (e, t, s) => s > 32 ? Me(e, t, s) : $e(e, t, s);
323
- function Ze(e, t = 24) {
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 - t; n < 24; n++) {
325
+ for (let n = 24 - e; n < 24; n++) {
326
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];
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
- e[o + I] ^= be, e[o + I + 1] ^= we;
331
+ t[o + I] ^= be, t[o + I + 1] ^= we;
332
332
  }
333
- let i = e[2], r = e[3];
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 = e[m], r = e[m + 1], e[m] = l, e[m + 1] = f;
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] = e[o + a];
340
+ s[a] = t[o + a];
341
341
  for (let a = 0; a < 10; a++)
342
- e[o + a] ^= ~s[(a + 2) % 10] & s[(a + 4) % 10];
342
+ t[o + a] ^= ~s[(a + 2) % 10] & s[(a + 4) % 10];
343
343
  }
344
- e[0] ^= Je[n], e[1] ^= Ye[n];
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(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, H(n), !(0 < t && t < 200))
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(t) {
362
- q(this), t = le(t), w(t);
363
- const { blockLen: s, state: n } = this, i = t.length;
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++] ^= t[r++];
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: 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();
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(t) {
380
- q(this, !1), w(t), this.finish();
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 = t.length; i < 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
- t.set(s.subarray(this.posOut, this.posOut + o), i), this.posOut += o, i += o;
385
+ e.set(s.subarray(this.posOut, this.posOut + o), i), this.posOut += o, i += o;
386
386
  }
387
- return t;
387
+ return e;
388
388
  }
389
- xofInto(t) {
389
+ xofInto(e) {
390
390
  if (!this.enableXOF)
391
391
  throw new Error("XOF is not possible for this instance");
392
- return this.writeInto(t);
392
+ return this.writeInto(e);
393
393
  }
394
- xof(t) {
395
- return H(t), this.xofInto(new Uint8Array(t));
394
+ xof(e) {
395
+ return H(e), this.xofInto(new Uint8Array(e));
396
396
  }
397
- digestInto(t) {
398
- if (Oe(t, this), this.finished)
397
+ digestInto(e) {
398
+ if (Oe(e, this), this.finished)
399
399
  throw new Error("digest() was already called");
400
- return this.writeInto(t), this.destroy(), t;
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(t) {
408
+ _cloneInto(e) {
409
409
  const { blockLen: s, suffix: n, outputLen: i, rounds: r, enableXOF: o } = this;
410
- return t || (t = new P(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;
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 = (e, t, s) => Ke(() => new P(t, e, s)), tt = et(1, 136, 256 / 8);
414
- function st(e, t) {
415
- return tt(j(e, { strict: !1 }) ? De(e) : e);
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: t }) {
419
- super(`Address "${t}" is invalid.`, {
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(t) {
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 = t;
435
+ }), this.maxSize = e;
436
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;
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(t, s) {
442
- if (super.set(t, s), this.maxSize && this.size > this.maxSize) {
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(e, t) {
451
- if (A.has(`${e}.${t}`))
452
- return A.get(`${e}.${t}`);
453
- const s = e.substring(2).toLowerCase(), n = st(ce(s)), i = s.split("");
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(`${e}.${t}`, r), r;
457
+ return A.set(`${t}.${e}`, r), r;
458
458
  }
459
- function p(e, t) {
460
- if (!ot(e, { strict: !1 }))
461
- throw new nt({ address: e });
462
- return me(e, t);
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(e, t) {
466
- const { strict: s = !0 } = t ?? {}, n = `${e}.${s}`;
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(e) ? e.toLowerCase() === e ? !0 : s ? me(e) === e : !0 : !1;
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
- }, k = {
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
- }, R = {
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
- [k.chainId]: k,
554
+ [R.chainId]: R,
555
555
  [N.chainId]: N,
556
556
  [B.chainId]: B,
557
- [R.chainId]: R
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]: k
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]: R
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 z = /* @__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))(z || {}), ye = /* @__PURE__ */ ((e) => (e.USDC = "USDC", e))(ye || {});
631
- function It(e) {
632
- return at[$[e || ""].chainId]?.decimals || 6;
633
- }
634
- const ct = (e) => {
635
- const t = e?.trim().toUpperCase();
636
- if ($[t])
637
- return $[t];
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(e, t) {
640
- return ct(e)?.tokens[t]?.address;
639
+ function ut(t, e) {
640
+ return ct(t)?.tokens[e]?.address;
641
641
  }
642
- var Ie = /* @__PURE__ */ ((e) => (e.PRODUCTION = "production", e.STAGING = "staging", e))(Ie || {});
642
+ var Ie = /* @__PURE__ */ ((t) => (t.PRODUCTION = "production", t.STAGING = "staging", t))(Ie || {});
643
643
  class u {
644
- constructor({ api_key: t, env: s, seesion_token: n }) {
645
- this.api_key = t || "", this.sessionToken = n || "", this.env = s ?? Ie.PRODUCTION;
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(t) {
647
+ static async config(e) {
648
648
  if (!u.app) {
649
- if (!t)
649
+ if (!e)
650
650
  throw new Error("Please provide an api_key");
651
- u.app = new u(t);
651
+ u.app = new u(e);
652
652
  }
653
- return t && (t.api_key !== void 0 && (u.app.api_key = t.api_key), t.seesion_token !== void 0 && (u.app.sessionToken = t.seesion_token), t.env !== void 0 && (u.app.env = t.env)), u.app;
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(t, s, n, i) {
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 r = u.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 : ""}`;
688
- return r + o + a;
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
- (e) => {
701
- const t = u.getSessionToken() || u.getApiKey();
702
- e.headers.set("Authorization", `Bearer ${t}`);
700
+ (t) => {
701
+ const e = u.getSessionToken() || u.getApiKey();
702
+ t.headers.set("Authorization", `Bearer ${e}`);
703
703
  }
704
704
  ],
705
- afterResponse: [(e, t, s) => s]
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(t) {
717
- return await c().get("intents/" + t).json();
716
+ async getById(e) {
717
+ return await c().get("intents/" + e).json();
718
718
  }
719
- async getForSender(t) {
720
- return await c().get("intents/user/" + t).json();
719
+ async getForSender(e) {
720
+ return await c().get("intents/user/" + e).json();
721
721
  }
722
- async getForAddress(t) {
723
- return await c().get("intents/address/" + t).json();
722
+ async getForAddress(e) {
723
+ return await c().get("intents/address/" + e).json();
724
724
  }
725
- async getForSession(t) {
726
- return await c().get("modal/sessions/intents/" + t).json();
725
+ async getForSession(e) {
726
+ return await c().get("modal/sessions/intents/" + e).json();
727
727
  }
728
- async getAll(t) {
729
- return await c().get("intents", { searchParams: t }).json();
728
+ async getAll(e) {
729
+ return await c().get("intents", { searchParams: e }).json();
730
730
  }
731
- async create(t) {
732
- return await c().post("intents", { json: t }).json();
731
+ async create(e) {
732
+ return await c().post("intents", { json: e }).json();
733
733
  }
734
- async createForSession(t) {
735
- return await c().post("modal/sessions/intents", { json: t }).json();
734
+ async createForSession(e) {
735
+ return await c().post("modal/sessions/intents", { json: e }).json();
736
736
  }
737
- async update(t, s) {
737
+ async update(e, s) {
738
738
  return await c().post("intents", { json: s }).json();
739
739
  }
740
- async triggerProcessing(t) {
741
- return await c().post(`intents/${t}/trigger-processing`).json();
740
+ async triggerProcessing(e) {
741
+ return await c().post(`intents/${e}/trigger-processing`).json();
742
742
  }
743
- async triggerProcessingForSession(t) {
744
- return await c().post(`modal/sessions/intents/${t}/process`).json();
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(t) {
749
- return await c().get("quotes/single", { searchParams: t }).json();
748
+ async getFromSpecificBridge(e) {
749
+ return await c().get("quotes/single", { searchParams: e }).json();
750
750
  }
751
- async getFromAllBridges(t) {
752
- return await c().get("quotes/multiple", { searchParams: t }).json();
751
+ async getFromAllBridges(e) {
752
+ return await c().get("quotes/multiple", { searchParams: e }).json();
753
753
  }
754
- async getBestAcrossBridges(t) {
755
- return await c().get("quotes/best", { searchParams: t }).json();
754
+ async getBestAcrossBridges(e) {
755
+ return await c().get("quotes/best", { searchParams: e }).json();
756
756
  }
757
- async getAll(t) {
758
- return await c().get("quotes/multi-source", { searchParams: t }).json();
757
+ async getAll(e) {
758
+ return await c().get("quotes/multi-source", { searchParams: e }).json();
759
759
  }
760
- async getAllForSession(t) {
761
- return await c().get("modal/sessions/quotes", { searchParams: t }).json();
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(t) {
766
- return await c().get("router/optimal-route", { searchParams: t }).json();
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(t) {
772
- return await c().get("router/supported-bridges/route", { searchParams: t }).json();
771
+ async getSupportedBridges(e) {
772
+ return await c().get("router/supported-bridges/route", { searchParams: e }).json();
773
773
  }
774
- async getSupportedRoutes(t, s) {
775
- return await c().get("router/supported-bridges/bridge/" + t, { searchParams: s }).json();
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(t) {
780
- return await c().get("chains", { searchParams: t }).json();
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(t) {
792
+ getSessionToken(e) {
793
793
  const s = {
794
- recipient: t.recipient,
794
+ recipient: e.recipient,
795
795
  tokenOut: ut(
796
- z[t.destinationChain],
797
- ye[t.token]
796
+ $[e.destinationChain],
797
+ ye[e.token]
798
798
  ),
799
- destinationChain: z[t.destinationChain],
800
- amount: t.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
- z as chains,
815
+ $ as chains,
816
816
  bt as crapi,
817
817
  Ie as environment,
818
818
  It as getTokenDecimals,