@chainrails/sdk 0.0.47 → 0.1.0
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.
|
@@ -62,11 +62,11 @@ const G = {
|
|
|
62
62
|
cctpDomain: null,
|
|
63
63
|
logoURI: "/images/chains/starknet.svg"
|
|
64
64
|
};
|
|
65
|
-
function
|
|
65
|
+
function j(e, { strict: t = !0 } = {}) {
|
|
66
66
|
return !e || typeof e != "string" ? !1 : t ? /^0x[0-9a-fA-F]*$/.test(e) : e.startsWith("0x");
|
|
67
67
|
}
|
|
68
68
|
function F(e) {
|
|
69
|
-
return
|
|
69
|
+
return j(e, { strict: !1 }) ? Math.ceil((e.length - 2) / 2) : e.length;
|
|
70
70
|
}
|
|
71
71
|
const ie = "2.43.4";
|
|
72
72
|
let S = {
|
|
@@ -169,7 +169,7 @@ class ve extends g {
|
|
|
169
169
|
super(`Size cannot exceed ${s} bytes. Given size: ${t} bytes.`, { name: "SizeOverflowError" });
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
|
-
function
|
|
172
|
+
function O(e, { size: t }) {
|
|
173
173
|
if (F(e) > t)
|
|
174
174
|
throw new ve({
|
|
175
175
|
givenSize: F(e),
|
|
@@ -196,11 +196,11 @@ function Ce(e, t = {}) {
|
|
|
196
196
|
}
|
|
197
197
|
const Te = /* @__PURE__ */ new TextEncoder();
|
|
198
198
|
function De(e, t = {}) {
|
|
199
|
-
return typeof e == "number" || typeof e == "bigint" ? ke(e, t) : typeof e == "boolean" ? xe(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);
|
|
200
200
|
}
|
|
201
201
|
function xe(e, t = {}) {
|
|
202
202
|
const s = new Uint8Array(1);
|
|
203
|
-
return s[0] = Number(e), typeof t.size == "number" ? (
|
|
203
|
+
return s[0] = Number(e), typeof t.size == "number" ? (O(s, { size: t.size }), E(s, { size: t.size })) : s;
|
|
204
204
|
}
|
|
205
205
|
const d = {
|
|
206
206
|
zero: 48,
|
|
@@ -220,7 +220,7 @@ function _(e) {
|
|
|
220
220
|
}
|
|
221
221
|
function ae(e, t = {}) {
|
|
222
222
|
let s = e;
|
|
223
|
-
t.size && (
|
|
223
|
+
t.size && (O(s, { size: t.size }), s = E(s, { dir: "right", size: t.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);
|
|
@@ -238,7 +238,7 @@ function ke(e, t) {
|
|
|
238
238
|
}
|
|
239
239
|
function ce(e, t = {}) {
|
|
240
240
|
const s = Te.encode(e);
|
|
241
|
-
return typeof t.size == "number" ? (
|
|
241
|
+
return typeof t.size == "number" ? (O(s, { size: t.size }), E(s, { dir: "right", size: t.size })) : s;
|
|
242
242
|
}
|
|
243
243
|
const b = /* @__PURE__ */ BigInt(2 ** 32 - 1), L = /* @__PURE__ */ BigInt(32);
|
|
244
244
|
function Re(e, t = !1) {
|
|
@@ -255,7 +255,7 @@ function Ne(e, t = !1) {
|
|
|
255
255
|
}
|
|
256
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;
|
|
257
257
|
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
258
|
-
function
|
|
258
|
+
function je(e) {
|
|
259
259
|
return e instanceof Uint8Array || ArrayBuffer.isView(e) && e.constructor.name === "Uint8Array";
|
|
260
260
|
}
|
|
261
261
|
function H(e) {
|
|
@@ -263,7 +263,7 @@ function H(e) {
|
|
|
263
263
|
throw new Error("positive integer expected, got " + e);
|
|
264
264
|
}
|
|
265
265
|
function w(e, ...t) {
|
|
266
|
-
if (!
|
|
266
|
+
if (!je(e))
|
|
267
267
|
throw new Error("Uint8Array expected");
|
|
268
268
|
if (t.length > 0 && !t.includes(e.length))
|
|
269
269
|
throw new Error("Uint8Array expected of length " + t + ", got length=" + e.length);
|
|
@@ -274,7 +274,7 @@ function q(e, t = !0) {
|
|
|
274
274
|
if (t && e.finished)
|
|
275
275
|
throw new Error("Hash#digest() has already been called");
|
|
276
276
|
}
|
|
277
|
-
function
|
|
277
|
+
function Oe(e, t) {
|
|
278
278
|
w(e);
|
|
279
279
|
const s = t.outputLen;
|
|
280
280
|
if (e.length < s)
|
|
@@ -395,7 +395,7 @@ class P extends qe {
|
|
|
395
395
|
return H(t), this.xofInto(new Uint8Array(t));
|
|
396
396
|
}
|
|
397
397
|
digestInto(t) {
|
|
398
|
-
if (
|
|
398
|
+
if (Oe(t, this), this.finished)
|
|
399
399
|
throw new Error("digest() was already called");
|
|
400
400
|
return this.writeInto(t), this.destroy(), t;
|
|
401
401
|
}
|
|
@@ -412,7 +412,7 @@ class P extends qe {
|
|
|
412
412
|
}
|
|
413
413
|
const et = (e, t, s) => Ke(() => new P(t, e, s)), tt = et(1, 136, 256 / 8);
|
|
414
414
|
function st(e, t) {
|
|
415
|
-
return tt(
|
|
415
|
+
return tt(j(e, { strict: !1 }) ? De(e) : e);
|
|
416
416
|
}
|
|
417
417
|
class nt extends g {
|
|
418
418
|
constructor({ address: t }) {
|
|
@@ -640,37 +640,37 @@ function ut(e, t) {
|
|
|
640
640
|
return ct(e)?.tokens[t]?.address;
|
|
641
641
|
}
|
|
642
642
|
var Ie = /* @__PURE__ */ ((e) => (e.PRODUCTION = "production", e.STAGING = "staging", e))(Ie || {});
|
|
643
|
-
class
|
|
643
|
+
class u {
|
|
644
644
|
constructor({ api_key: t, env: s, seesion_token: n }) {
|
|
645
645
|
this.api_key = t || "", this.sessionToken = n || "", this.env = s ?? Ie.PRODUCTION;
|
|
646
646
|
}
|
|
647
647
|
static async config(t) {
|
|
648
|
-
if (!
|
|
648
|
+
if (!u.app) {
|
|
649
649
|
if (!t)
|
|
650
650
|
throw new Error("Please provide an api_key");
|
|
651
|
-
|
|
651
|
+
u.app = new u(t);
|
|
652
652
|
}
|
|
653
|
-
return t && (t.api_key !== void 0 && (
|
|
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;
|
|
654
654
|
}
|
|
655
655
|
static getApiKey() {
|
|
656
|
-
if (!
|
|
656
|
+
if (!u.app)
|
|
657
657
|
throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
|
|
658
|
-
return
|
|
658
|
+
return u.app.api_key;
|
|
659
659
|
}
|
|
660
660
|
static getSessionToken() {
|
|
661
|
-
if (!
|
|
661
|
+
if (!u.app)
|
|
662
662
|
throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
|
|
663
|
-
return
|
|
663
|
+
return u.app.sessionToken;
|
|
664
664
|
}
|
|
665
665
|
static getEnv() {
|
|
666
|
-
if (!
|
|
666
|
+
if (!u.app)
|
|
667
667
|
throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
|
|
668
|
-
return
|
|
668
|
+
return u.app.env === "internal" ? "staging" : u.app.env;
|
|
669
669
|
}
|
|
670
670
|
static getBaseUrl() {
|
|
671
|
-
if (!
|
|
671
|
+
if (!u.app)
|
|
672
672
|
throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
|
|
673
|
-
switch (
|
|
673
|
+
switch (u.app.env) {
|
|
674
674
|
case "production":
|
|
675
675
|
return "https://api.chainrails.io/api/v1";
|
|
676
676
|
case "staging":
|
|
@@ -682,23 +682,23 @@ class c {
|
|
|
682
682
|
}
|
|
683
683
|
}
|
|
684
684
|
static getPayModalUrl(t, s, n, i) {
|
|
685
|
-
if (!
|
|
685
|
+
if (!u.app)
|
|
686
686
|
throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
|
|
687
|
-
const r =
|
|
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
688
|
return r + o + a;
|
|
689
689
|
}
|
|
690
690
|
}
|
|
691
691
|
let M = null;
|
|
692
692
|
function lt() {
|
|
693
693
|
M = Ee.create({
|
|
694
|
-
prefixUrl:
|
|
694
|
+
prefixUrl: u.getBaseUrl(),
|
|
695
695
|
headers: {
|
|
696
696
|
"Content-Type": "application/json"
|
|
697
697
|
},
|
|
698
698
|
hooks: {
|
|
699
699
|
beforeRequest: [
|
|
700
700
|
(e) => {
|
|
701
|
-
const t =
|
|
701
|
+
const t = u.getSessionToken() || u.getApiKey();
|
|
702
702
|
e.headers.set("Authorization", `Bearer ${t}`);
|
|
703
703
|
}
|
|
704
704
|
],
|
|
@@ -709,80 +709,83 @@ function lt() {
|
|
|
709
709
|
}
|
|
710
710
|
});
|
|
711
711
|
}
|
|
712
|
-
function
|
|
712
|
+
function c() {
|
|
713
713
|
return M || lt(), M;
|
|
714
714
|
}
|
|
715
715
|
class ht {
|
|
716
716
|
async getById(t) {
|
|
717
|
-
return await
|
|
717
|
+
return await c().get("intents/" + t).json();
|
|
718
718
|
}
|
|
719
719
|
async getForSender(t) {
|
|
720
|
-
return await
|
|
720
|
+
return await c().get("intents/user/" + t).json();
|
|
721
721
|
}
|
|
722
722
|
async getForAddress(t) {
|
|
723
|
-
return await
|
|
723
|
+
return await c().get("intents/address/" + t).json();
|
|
724
724
|
}
|
|
725
725
|
async getForSession(t) {
|
|
726
|
-
return await
|
|
726
|
+
return await c().get("modal/sessions/intents/" + t).json();
|
|
727
727
|
}
|
|
728
728
|
async getAll(t) {
|
|
729
|
-
return await
|
|
729
|
+
return await c().get("intents", { searchParams: t }).json();
|
|
730
730
|
}
|
|
731
731
|
async create(t) {
|
|
732
|
-
return await
|
|
732
|
+
return await c().post("intents", { json: t }).json();
|
|
733
733
|
}
|
|
734
734
|
async createForSession(t) {
|
|
735
|
-
return await
|
|
735
|
+
return await c().post("modal/sessions/intents", { json: t }).json();
|
|
736
736
|
}
|
|
737
737
|
async update(t, s) {
|
|
738
|
-
return await
|
|
738
|
+
return await c().post("intents", { json: s }).json();
|
|
739
739
|
}
|
|
740
740
|
async triggerProcessing(t) {
|
|
741
|
-
return await
|
|
741
|
+
return await c().post(`intents/${t}/trigger-processing`).json();
|
|
742
742
|
}
|
|
743
743
|
async triggerProcessingForSession(t) {
|
|
744
|
-
return await
|
|
744
|
+
return await c().post(`modal/sessions/intents/${t}/process`).json();
|
|
745
745
|
}
|
|
746
746
|
}
|
|
747
747
|
class dt {
|
|
748
748
|
async getFromSpecificBridge(t) {
|
|
749
|
-
return await
|
|
749
|
+
return await c().get("quotes/single", { searchParams: t }).json();
|
|
750
750
|
}
|
|
751
751
|
async getFromAllBridges(t) {
|
|
752
|
-
return await
|
|
752
|
+
return await c().get("quotes/multiple", { searchParams: t }).json();
|
|
753
753
|
}
|
|
754
754
|
async getBestAcrossBridges(t) {
|
|
755
|
-
return await
|
|
755
|
+
return await c().get("quotes/best", { searchParams: t }).json();
|
|
756
756
|
}
|
|
757
757
|
async getAll(t) {
|
|
758
|
-
return await
|
|
758
|
+
return await c().get("quotes/multi-source", { searchParams: t }).json();
|
|
759
759
|
}
|
|
760
760
|
async getAllForSession(t) {
|
|
761
|
-
return await
|
|
761
|
+
return await c().get("modal/sessions/quotes", { searchParams: t }).json();
|
|
762
762
|
}
|
|
763
763
|
}
|
|
764
764
|
class pt {
|
|
765
765
|
async getOptimalRoutes(t) {
|
|
766
|
-
return await
|
|
766
|
+
return await c().get("router/optimal-route", { searchParams: t }).json();
|
|
767
767
|
}
|
|
768
768
|
async getAllSupportedBridges() {
|
|
769
|
-
return await
|
|
769
|
+
return await c().get("router/supported-bridges/all").json();
|
|
770
770
|
}
|
|
771
771
|
async getSupportedBridges(t) {
|
|
772
|
-
return await
|
|
772
|
+
return await c().get("router/supported-bridges/route", { searchParams: t }).json();
|
|
773
773
|
}
|
|
774
774
|
async getSupportedRoutes(t, s) {
|
|
775
|
-
return await
|
|
775
|
+
return await c().get("router/supported-bridges/bridge/" + t, { searchParams: s }).json();
|
|
776
776
|
}
|
|
777
777
|
}
|
|
778
778
|
class gt {
|
|
779
779
|
async getSupported(t) {
|
|
780
|
-
return await
|
|
780
|
+
return await c().get("chains", { searchParams: t }).json();
|
|
781
781
|
}
|
|
782
782
|
}
|
|
783
783
|
class ft {
|
|
784
784
|
async getClientInfo() {
|
|
785
|
-
return await
|
|
785
|
+
return await c().get("client/auth/client-info").json();
|
|
786
|
+
}
|
|
787
|
+
async getClientInfoForSession() {
|
|
788
|
+
return await c().get("modal/sessions/client").json();
|
|
786
789
|
}
|
|
787
790
|
}
|
|
788
791
|
class mt {
|
|
@@ -796,7 +799,7 @@ class mt {
|
|
|
796
799
|
destinationChain: z[t.destinationChain],
|
|
797
800
|
amount: t.amount
|
|
798
801
|
};
|
|
799
|
-
return
|
|
802
|
+
return c().post("modal/sessions", { json: s }).json();
|
|
800
803
|
}
|
|
801
804
|
}
|
|
802
805
|
const bt = {
|
|
@@ -808,7 +811,7 @@ const bt = {
|
|
|
808
811
|
auth: new mt()
|
|
809
812
|
};
|
|
810
813
|
export {
|
|
811
|
-
|
|
814
|
+
u as Chainrails,
|
|
812
815
|
z as chains,
|
|
813
816
|
bt as crapi,
|
|
814
817
|
Ie as environment,
|
|
@@ -62,11 +62,11 @@ const G = {
|
|
|
62
62
|
cctpDomain: null,
|
|
63
63
|
logoURI: "/images/chains/starknet.svg"
|
|
64
64
|
};
|
|
65
|
-
function
|
|
65
|
+
function j(e, { strict: t = !0 } = {}) {
|
|
66
66
|
return !e || typeof e != "string" ? !1 : t ? /^0x[0-9a-fA-F]*$/.test(e) : e.startsWith("0x");
|
|
67
67
|
}
|
|
68
68
|
function F(e) {
|
|
69
|
-
return
|
|
69
|
+
return j(e, { strict: !1 }) ? Math.ceil((e.length - 2) / 2) : e.length;
|
|
70
70
|
}
|
|
71
71
|
const ie = "2.43.4";
|
|
72
72
|
let S = {
|
|
@@ -169,7 +169,7 @@ class ve extends g {
|
|
|
169
169
|
super(`Size cannot exceed ${s} bytes. Given size: ${t} bytes.`, { name: "SizeOverflowError" });
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
|
-
function
|
|
172
|
+
function O(e, { size: t }) {
|
|
173
173
|
if (F(e) > t)
|
|
174
174
|
throw new ve({
|
|
175
175
|
givenSize: F(e),
|
|
@@ -196,11 +196,11 @@ function Ce(e, t = {}) {
|
|
|
196
196
|
}
|
|
197
197
|
const Te = /* @__PURE__ */ new TextEncoder();
|
|
198
198
|
function De(e, t = {}) {
|
|
199
|
-
return typeof e == "number" || typeof e == "bigint" ? ke(e, t) : typeof e == "boolean" ? xe(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);
|
|
200
200
|
}
|
|
201
201
|
function xe(e, t = {}) {
|
|
202
202
|
const s = new Uint8Array(1);
|
|
203
|
-
return s[0] = Number(e), typeof t.size == "number" ? (
|
|
203
|
+
return s[0] = Number(e), typeof t.size == "number" ? (O(s, { size: t.size }), E(s, { size: t.size })) : s;
|
|
204
204
|
}
|
|
205
205
|
const d = {
|
|
206
206
|
zero: 48,
|
|
@@ -220,7 +220,7 @@ function _(e) {
|
|
|
220
220
|
}
|
|
221
221
|
function ae(e, t = {}) {
|
|
222
222
|
let s = e;
|
|
223
|
-
t.size && (
|
|
223
|
+
t.size && (O(s, { size: t.size }), s = E(s, { dir: "right", size: t.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);
|
|
@@ -238,7 +238,7 @@ function ke(e, t) {
|
|
|
238
238
|
}
|
|
239
239
|
function ce(e, t = {}) {
|
|
240
240
|
const s = Te.encode(e);
|
|
241
|
-
return typeof t.size == "number" ? (
|
|
241
|
+
return typeof t.size == "number" ? (O(s, { size: t.size }), E(s, { dir: "right", size: t.size })) : s;
|
|
242
242
|
}
|
|
243
243
|
const b = /* @__PURE__ */ BigInt(2 ** 32 - 1), L = /* @__PURE__ */ BigInt(32);
|
|
244
244
|
function Re(e, t = !1) {
|
|
@@ -255,7 +255,7 @@ function Ne(e, t = !1) {
|
|
|
255
255
|
}
|
|
256
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;
|
|
257
257
|
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
258
|
-
function
|
|
258
|
+
function je(e) {
|
|
259
259
|
return e instanceof Uint8Array || ArrayBuffer.isView(e) && e.constructor.name === "Uint8Array";
|
|
260
260
|
}
|
|
261
261
|
function H(e) {
|
|
@@ -263,7 +263,7 @@ function H(e) {
|
|
|
263
263
|
throw new Error("positive integer expected, got " + e);
|
|
264
264
|
}
|
|
265
265
|
function w(e, ...t) {
|
|
266
|
-
if (!
|
|
266
|
+
if (!je(e))
|
|
267
267
|
throw new Error("Uint8Array expected");
|
|
268
268
|
if (t.length > 0 && !t.includes(e.length))
|
|
269
269
|
throw new Error("Uint8Array expected of length " + t + ", got length=" + e.length);
|
|
@@ -274,7 +274,7 @@ function q(e, t = !0) {
|
|
|
274
274
|
if (t && e.finished)
|
|
275
275
|
throw new Error("Hash#digest() has already been called");
|
|
276
276
|
}
|
|
277
|
-
function
|
|
277
|
+
function Oe(e, t) {
|
|
278
278
|
w(e);
|
|
279
279
|
const s = t.outputLen;
|
|
280
280
|
if (e.length < s)
|
|
@@ -395,7 +395,7 @@ class P extends qe {
|
|
|
395
395
|
return H(t), this.xofInto(new Uint8Array(t));
|
|
396
396
|
}
|
|
397
397
|
digestInto(t) {
|
|
398
|
-
if (
|
|
398
|
+
if (Oe(t, this), this.finished)
|
|
399
399
|
throw new Error("digest() was already called");
|
|
400
400
|
return this.writeInto(t), this.destroy(), t;
|
|
401
401
|
}
|
|
@@ -412,7 +412,7 @@ class P extends qe {
|
|
|
412
412
|
}
|
|
413
413
|
const et = (e, t, s) => Ke(() => new P(t, e, s)), tt = et(1, 136, 256 / 8);
|
|
414
414
|
function st(e, t) {
|
|
415
|
-
return tt(
|
|
415
|
+
return tt(j(e, { strict: !1 }) ? De(e) : e);
|
|
416
416
|
}
|
|
417
417
|
class nt extends g {
|
|
418
418
|
constructor({ address: t }) {
|
|
@@ -640,37 +640,37 @@ function ut(e, t) {
|
|
|
640
640
|
return ct(e)?.tokens[t]?.address;
|
|
641
641
|
}
|
|
642
642
|
var Ie = /* @__PURE__ */ ((e) => (e.PRODUCTION = "production", e.STAGING = "staging", e))(Ie || {});
|
|
643
|
-
class
|
|
643
|
+
class u {
|
|
644
644
|
constructor({ api_key: t, env: s, seesion_token: n }) {
|
|
645
645
|
this.api_key = t || "", this.sessionToken = n || "", this.env = s ?? Ie.PRODUCTION;
|
|
646
646
|
}
|
|
647
647
|
static async config(t) {
|
|
648
|
-
if (!
|
|
648
|
+
if (!u.app) {
|
|
649
649
|
if (!t)
|
|
650
650
|
throw new Error("Please provide an api_key");
|
|
651
|
-
|
|
651
|
+
u.app = new u(t);
|
|
652
652
|
}
|
|
653
|
-
return t && (t.api_key !== void 0 && (
|
|
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;
|
|
654
654
|
}
|
|
655
655
|
static getApiKey() {
|
|
656
|
-
if (!
|
|
656
|
+
if (!u.app)
|
|
657
657
|
throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
|
|
658
|
-
return
|
|
658
|
+
return u.app.api_key;
|
|
659
659
|
}
|
|
660
660
|
static getSessionToken() {
|
|
661
|
-
if (!
|
|
661
|
+
if (!u.app)
|
|
662
662
|
throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
|
|
663
|
-
return
|
|
663
|
+
return u.app.sessionToken;
|
|
664
664
|
}
|
|
665
665
|
static getEnv() {
|
|
666
|
-
if (!
|
|
666
|
+
if (!u.app)
|
|
667
667
|
throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
|
|
668
|
-
return
|
|
668
|
+
return u.app.env === "internal" ? "staging" : u.app.env;
|
|
669
669
|
}
|
|
670
670
|
static getBaseUrl() {
|
|
671
|
-
if (!
|
|
671
|
+
if (!u.app)
|
|
672
672
|
throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
|
|
673
|
-
switch (
|
|
673
|
+
switch (u.app.env) {
|
|
674
674
|
case "production":
|
|
675
675
|
return "https://api.chainrails.io/api/v1";
|
|
676
676
|
case "staging":
|
|
@@ -682,23 +682,23 @@ class c {
|
|
|
682
682
|
}
|
|
683
683
|
}
|
|
684
684
|
static getPayModalUrl(t, s, n, i) {
|
|
685
|
-
if (!
|
|
685
|
+
if (!u.app)
|
|
686
686
|
throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
|
|
687
|
-
const r =
|
|
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
688
|
return r + o + a;
|
|
689
689
|
}
|
|
690
690
|
}
|
|
691
691
|
let M = null;
|
|
692
692
|
function lt() {
|
|
693
693
|
M = Ee.create({
|
|
694
|
-
prefixUrl:
|
|
694
|
+
prefixUrl: u.getBaseUrl(),
|
|
695
695
|
headers: {
|
|
696
696
|
"Content-Type": "application/json"
|
|
697
697
|
},
|
|
698
698
|
hooks: {
|
|
699
699
|
beforeRequest: [
|
|
700
700
|
(e) => {
|
|
701
|
-
const t =
|
|
701
|
+
const t = u.getSessionToken() || u.getApiKey();
|
|
702
702
|
e.headers.set("Authorization", `Bearer ${t}`);
|
|
703
703
|
}
|
|
704
704
|
],
|
|
@@ -709,80 +709,83 @@ function lt() {
|
|
|
709
709
|
}
|
|
710
710
|
});
|
|
711
711
|
}
|
|
712
|
-
function
|
|
712
|
+
function c() {
|
|
713
713
|
return M || lt(), M;
|
|
714
714
|
}
|
|
715
715
|
class ht {
|
|
716
716
|
async getById(t) {
|
|
717
|
-
return await
|
|
717
|
+
return await c().get("intents/" + t).json();
|
|
718
718
|
}
|
|
719
719
|
async getForSender(t) {
|
|
720
|
-
return await
|
|
720
|
+
return await c().get("intents/user/" + t).json();
|
|
721
721
|
}
|
|
722
722
|
async getForAddress(t) {
|
|
723
|
-
return await
|
|
723
|
+
return await c().get("intents/address/" + t).json();
|
|
724
724
|
}
|
|
725
725
|
async getForSession(t) {
|
|
726
|
-
return await
|
|
726
|
+
return await c().get("modal/sessions/intents/" + t).json();
|
|
727
727
|
}
|
|
728
728
|
async getAll(t) {
|
|
729
|
-
return await
|
|
729
|
+
return await c().get("intents", { searchParams: t }).json();
|
|
730
730
|
}
|
|
731
731
|
async create(t) {
|
|
732
|
-
return await
|
|
732
|
+
return await c().post("intents", { json: t }).json();
|
|
733
733
|
}
|
|
734
734
|
async createForSession(t) {
|
|
735
|
-
return await
|
|
735
|
+
return await c().post("modal/sessions/intents", { json: t }).json();
|
|
736
736
|
}
|
|
737
737
|
async update(t, s) {
|
|
738
|
-
return await
|
|
738
|
+
return await c().post("intents", { json: s }).json();
|
|
739
739
|
}
|
|
740
740
|
async triggerProcessing(t) {
|
|
741
|
-
return await
|
|
741
|
+
return await c().post(`intents/${t}/trigger-processing`).json();
|
|
742
742
|
}
|
|
743
743
|
async triggerProcessingForSession(t) {
|
|
744
|
-
return await
|
|
744
|
+
return await c().post(`modal/sessions/intents/${t}/process`).json();
|
|
745
745
|
}
|
|
746
746
|
}
|
|
747
747
|
class dt {
|
|
748
748
|
async getFromSpecificBridge(t) {
|
|
749
|
-
return await
|
|
749
|
+
return await c().get("quotes/single", { searchParams: t }).json();
|
|
750
750
|
}
|
|
751
751
|
async getFromAllBridges(t) {
|
|
752
|
-
return await
|
|
752
|
+
return await c().get("quotes/multiple", { searchParams: t }).json();
|
|
753
753
|
}
|
|
754
754
|
async getBestAcrossBridges(t) {
|
|
755
|
-
return await
|
|
755
|
+
return await c().get("quotes/best", { searchParams: t }).json();
|
|
756
756
|
}
|
|
757
757
|
async getAll(t) {
|
|
758
|
-
return await
|
|
758
|
+
return await c().get("quotes/multi-source", { searchParams: t }).json();
|
|
759
759
|
}
|
|
760
760
|
async getAllForSession(t) {
|
|
761
|
-
return await
|
|
761
|
+
return await c().get("modal/sessions/quotes", { searchParams: t }).json();
|
|
762
762
|
}
|
|
763
763
|
}
|
|
764
764
|
class pt {
|
|
765
765
|
async getOptimalRoutes(t) {
|
|
766
|
-
return await
|
|
766
|
+
return await c().get("router/optimal-route", { searchParams: t }).json();
|
|
767
767
|
}
|
|
768
768
|
async getAllSupportedBridges() {
|
|
769
|
-
return await
|
|
769
|
+
return await c().get("router/supported-bridges/all").json();
|
|
770
770
|
}
|
|
771
771
|
async getSupportedBridges(t) {
|
|
772
|
-
return await
|
|
772
|
+
return await c().get("router/supported-bridges/route", { searchParams: t }).json();
|
|
773
773
|
}
|
|
774
774
|
async getSupportedRoutes(t, s) {
|
|
775
|
-
return await
|
|
775
|
+
return await c().get("router/supported-bridges/bridge/" + t, { searchParams: s }).json();
|
|
776
776
|
}
|
|
777
777
|
}
|
|
778
778
|
class gt {
|
|
779
779
|
async getSupported(t) {
|
|
780
|
-
return await
|
|
780
|
+
return await c().get("chains", { searchParams: t }).json();
|
|
781
781
|
}
|
|
782
782
|
}
|
|
783
783
|
class ft {
|
|
784
784
|
async getClientInfo() {
|
|
785
|
-
return await
|
|
785
|
+
return await c().get("client/auth/client-info").json();
|
|
786
|
+
}
|
|
787
|
+
async getClientInfoForSession() {
|
|
788
|
+
return await c().get("modal/sessions/client").json();
|
|
786
789
|
}
|
|
787
790
|
}
|
|
788
791
|
class mt {
|
|
@@ -796,7 +799,7 @@ class mt {
|
|
|
796
799
|
destinationChain: z[t.destinationChain],
|
|
797
800
|
amount: t.amount
|
|
798
801
|
};
|
|
799
|
-
return
|
|
802
|
+
return c().post("modal/sessions", { json: s }).json();
|
|
800
803
|
}
|
|
801
804
|
}
|
|
802
805
|
const bt = {
|
|
@@ -808,7 +811,7 @@ const bt = {
|
|
|
808
811
|
auth: new mt()
|
|
809
812
|
};
|
|
810
813
|
export {
|
|
811
|
-
|
|
814
|
+
u as Chainrails,
|
|
812
815
|
z as chains,
|
|
813
816
|
bt as crapi,
|
|
814
817
|
Ie as environment,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
(function(l,I){typeof exports=="object"&&typeof module<"u"?I(exports,require("ky")):typeof define=="function"&&define.amd?define(["exports","ky"],I):(l=typeof globalThis<"u"?globalThis:l||self,I(l.Chainrails={},l.Ky))})(this,(function(l,I){"use strict";var h=(e=>(e.USDC="USDC",e))(h||{});const q={type:"evm",chainId:42161,name:"Arbitrum",cctpDomain:3,logoURI:"/images/chains/arbitrum.svg"},K={type:"evm",chainId:421614,name:"Arbitrum Sepolia",cctpDomain:3,logoURI:"/images/chains/arbitrum.svg"},V={type:"evm",chainId:8453,name:"Base",cctpDomain:6,logoURI:"/images/chains/base.webp"},X={type:"evm",chainId:84532,name:"Base Sepolia",cctpDomain:6,logoURI:"/images/chains/base.webp"},G={type:"evm",chainId:56,name:"BNB Chain",cctpDomain:null,logoURI:"/images/chains/bsc.webp"},Q={type:"evm",chainId:1,name:"Ethereum",cctpDomain:0,logoURI:"/images/chains/ethereum.svg"},W={type:"evm",chainId:11155111,name:"Ethereum Sepolia",cctpDomain:0,logoURI:"/images/chains/ethereum.svg"},J={type:"evm",chainId:43114,name:"Avalanche",cctpDomain:1,logoURI:"/images/chains/avalanche.svg"},Y={type:"evm",chainId:43113,name:"Avalanche Fuji",cctpDomain:1,logoURI:"/images/chains/avalanche.svg"},Z={type:"starknet",chainId:"0x534e5f4d41494e",name:"Starknet",cctpDomain:null,logoURI:"/images/chains/starknet.svg"};function v(e,{strict:t=!0}={}){return!e||typeof e!="string"?!1:t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x")}function ee(e){return v(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}const te="2.43.4";let C={getDocsUrl:({docsBaseUrl:e,docsPath:t="",docsSlug:s})=>t?`${e??"https://viem.sh"}${t}${s?`#${s}`:""}`:void 0,version:`viem@${te}`};class f extends Error{constructor(t,s={}){const n=s.cause instanceof f?s.cause.details:s.cause?.message?s.cause.message:s.details,i=s.cause instanceof f&&s.cause.docsPath||s.docsPath,r=C.getDocsUrl?.({...s,docsPath:i}),o=[t||"An error occurred.","",...s.metaMessages?[...s.metaMessages,""]:[],...r?[`Docs: ${r}`]:[],...n?[`Details: ${n}`]:[],...C.version?[`Version: ${C.version}`]:[]].join(`
|
|
2
|
-
`);super(o,s.cause?{cause:s.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=n,this.docsPath=i,this.metaMessages=s.metaMessages,this.name=s.name??this.name,this.shortMessage=t,this.version=te}walk(t){return se(this,t)}}function se(e,t){return t?.(e)?e:e&&typeof e=="object"&&"cause"in e&&e.cause!==void 0?se(e.cause,t):t?null:e}class ne extends f{constructor({size:t,targetSize:s,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (${t}) exceeds padding size (${s}).`,{name:"SizeExceedsPaddingSizeError"})}}function w(e,{dir:t,size:s=32}={}){return typeof e=="string"?Ee(e,{dir:t,size:s}):Se(e,{dir:t,size:s})}function Ee(e,{dir:t,size:s=32}={}){if(s===null)return e;const n=e.replace("0x","");if(n.length>s*2)throw new ne({size:Math.ceil(n.length/2),targetSize:s,type:"hex"});return`0x${n[t==="right"?"padEnd":"padStart"](s*2,"0")}`}function Se(e,{dir:t,size:s=32}={}){if(s===null)return e;if(e.length>s)throw new ne({size:e.length,targetSize:s,type:"bytes"});const n=new Uint8Array(s);for(let i=0;i<s;i++){const r=t==="right";n[r?i:s-i-1]=e[r?i:e.length-i-1]}return n}class Ae extends f{constructor({max:t,min:s,signed:n,size:i,value:r}){super(`Number "${r}" is not in safe ${i?`${i*8}-bit ${n?"signed":"unsigned"} `:""}integer range ${t?`(${s} to ${t})`:`(above ${s})`}`,{name:"IntegerOutOfRangeError"})}}class Ue extends f{constructor({givenSize:t,maxSize:s}){super(`Size cannot exceed ${s} bytes. Given size: ${t} bytes.`,{name:"SizeOverflowError"})}}function T(e,{size:t}){if(ee(e)>t)throw new Ue({givenSize:ee(e),maxSize:t})}function ve(e,t={}){const{signed:s,size:n}=t,i=BigInt(e);let r;n?s?r=(1n<<BigInt(n)*8n-1n)-1n:r=2n**(BigInt(n)*8n)-1n:typeof e=="number"&&(r=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof r=="bigint"&&s?-r-1n:0;if(r&&i>r||i<o){const d=typeof e=="bigint"?"n":"";throw new Ae({max:r?`${r}${d}`:void 0,min:`${o}${d}`,signed:s,size:n,value:`${e}${d}`})}const a=`0x${(s&&i<0?(1n<<BigInt(n*8))+BigInt(i):i).toString(16)}`;return n?w(a,{size:n}):a}const Ce=new TextEncoder;function Te(e,t={}){return typeof e=="number"||typeof e=="bigint"?xe(e,t):typeof e=="boolean"?De(e,t):v(e)?oe(e,t):re(e,t)}function De(e,t={}){const s=new Uint8Array(1);return s[0]=Number(e),typeof t.size=="number"?(T(s,{size:t.size}),w(s,{size:t.size})):s}const p={zero:48,nine:57,A:65,F:70,a:97,f:102};function ie(e){if(e>=p.zero&&e<=p.nine)return e-p.zero;if(e>=p.A&&e<=p.F)return e-(p.A-10);if(e>=p.a&&e<=p.f)return e-(p.a-10)}function oe(e,t={}){let s=e;t.size&&(T(s,{size:t.size}),s=w(s,{dir:"right",size:t.size}));let n=s.slice(2);n.length%2&&(n=`0${n}`);const i=n.length/2,r=new Uint8Array(i);for(let o=0,a=0;o<i;o++){const d=ie(n.charCodeAt(a++)),m=ie(n.charCodeAt(a++));if(d===void 0||m===void 0)throw new f(`Invalid byte sequence ("${n[a-2]}${n[a-1]}" in "${n}").`);r[o]=d*16+m}return r}function xe(e,t){const s=ve(e,t);return oe(s)}function re(e,t={}){const s=Ce.encode(e);return typeof t.size=="number"?(T(s,{size:t.size}),w(s,{dir:"right",size:t.size})):s}const E=BigInt(2**32-1),ae=BigInt(32);function ke(e,t=!1){return t?{h:Number(e&E),l:Number(e>>ae&E)}:{h:Number(e>>ae&E)|0,l:Number(e&E)|0}}function Re(e,t=!1){const s=e.length;let n=new Uint32Array(s),i=new Uint32Array(s);for(let r=0;r<s;r++){const{h:o,l:a}=ke(e[r],t);[n[r],i[r]]=[o,a]}return[n,i]}const Ne=(e,t,s)=>e<<s|t>>>32-s,Be=(e,t,s)=>t<<s|e>>>32-s,$e=(e,t,s)=>t<<s-32|e>>>64-s,ze=(e,t,s)=>e<<s-32|t>>>64-s;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Me(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function ce(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function S(e,...t){if(!Me(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function ue(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function je(e,t){S(e);const s=t.outputLen;if(e.length<s)throw new Error("digestInto() expects output buffer of length at least "+s)}function Oe(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function le(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}const Pe=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Fe(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function _e(e){for(let t=0;t<e.length;t++)e[t]=Fe(e[t]);return e}const he=Pe?e=>e:_e;function Le(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function de(e){return typeof e=="string"&&(e=Le(e)),S(e),e}class He{}function qe(e){const t=n=>e().update(de(n)).digest(),s=e();return t.outputLen=s.outputLen,t.blockLen=s.blockLen,t.create=()=>e(),t}const Ke=BigInt(0),b=BigInt(1),Ve=BigInt(2),Xe=BigInt(7),Ge=BigInt(256),Qe=BigInt(113),pe=[],ge=[],fe=[];for(let e=0,t=b,s=1,n=0;e<24;e++){[s,n]=[n,(2*s+3*n)%5],pe.push(2*(5*n+s)),ge.push((e+1)*(e+2)/2%64);let i=Ke;for(let r=0;r<7;r++)t=(t<<b^(t>>Xe)*Qe)%Ge,t&Ve&&(i^=b<<(b<<BigInt(r))-b);fe.push(i)}const me=Re(fe,!0),We=me[0],Je=me[1],ye=(e,t,s)=>s>32?$e(e,t,s):Ne(e,t,s),Ie=(e,t,s)=>s>32?ze(e,t,s):Be(e,t,s);function Ye(e,t=24){const s=new Uint32Array(10);for(let n=24-t;n<24;n++){for(let o=0;o<10;o++)s[o]=e[o]^e[o+10]^e[o+20]^e[o+30]^e[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,d=(o+2)%10,m=s[d],y=s[d+1],It=ye(m,y,1)^s[a],bt=Ie(m,y,1)^s[a+1];for(let U=0;U<50;U+=10)e[o+U]^=It,e[o+U+1]^=bt}let i=e[2],r=e[3];for(let o=0;o<24;o++){const a=ge[o],d=ye(i,r,a),m=Ie(i,r,a),y=pe[o];i=e[y],r=e[y+1],e[y]=d,e[y+1]=m}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)s[a]=e[o+a];for(let a=0;a<10;a++)e[o+a]^=~s[(a+2)%10]&s[(a+4)%10]}e[0]^=We[n],e[1]^=Je[n]}le(s)}class D extends He{constructor(t,s,n,i=!1,r=24){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,ce(n),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=Oe(this.state)}clone(){return this._cloneInto()}keccak(){he(this.state32),Ye(this.state32,this.rounds),he(this.state32),this.posOut=0,this.pos=0}update(t){ue(this),t=de(t),S(t);const{blockLen:s,state:n}=this,i=t.length;for(let r=0;r<i;){const o=Math.min(s-this.pos,i-r);for(let a=0;a<o;a++)n[this.pos++]^=t[r++];this.pos===s&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:s,pos:n,blockLen:i}=this;t[n]^=s,(s&128)!==0&&n===i-1&&this.keccak(),t[i-1]^=128,this.keccak()}writeInto(t){ue(this,!1),S(t),this.finish();const s=this.state,{blockLen:n}=this;for(let i=0,r=t.length;i<r;){this.posOut>=n&&this.keccak();const o=Math.min(n-this.posOut,r-i);t.set(s.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=o}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return ce(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(je(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,le(this.state)}_cloneInto(t){const{blockLen:s,suffix:n,outputLen:i,rounds:r,enableXOF:o}=this;return t||(t=new D(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}}const Ze=(e,t,s)=>qe(()=>new D(t,e,s)),et=Ze(1,136,256/8);function tt(e,t){return et(v(e,{strict:!1})?Te(e):e)}class st extends f{constructor({address:t}){super(`Address "${t}" is invalid.`,{metaMessages:["- Address must be a hex value of 20 bytes (40 hex characters).","- Address must match its checksum counterpart."],name:"InvalidAddressError"})}}class be extends Map{constructor(t){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=t}get(t){const s=super.get(t);return super.has(t)&&s!==void 0&&(this.delete(t),super.set(t,s)),s}set(t,s){if(super.set(t,s),this.maxSize&&this.size>this.maxSize){const n=this.keys().next().value;n&&this.delete(n)}return this}}const x=new be(8192);function we(e,t){if(x.has(`${e}.${t}`))return x.get(`${e}.${t}`);const s=e.substring(2).toLowerCase(),n=tt(re(s)),i=s.split("");for(let o=0;o<40;o+=2)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());const r=`0x${i.join("")}`;return x.set(`${e}.${t}`,r),r}function g(e,t){if(!it(e,{strict:!1}))throw new st({address:e});return we(e,t)}const nt=/^0x[a-fA-F0-9]{40}$/,k=new be(8192);function it(e,t){const{strict:s=!0}=t??{},n=`${e}.${s}`;if(k.has(n))return k.get(n);const i=nt.test(e)?e.toLowerCase()===e?!0:s?we(e)===e:!0:!1;return k.set(n,i),i}const R={chainId:K.chainId,address:g("0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d"),symbol:"USDC",fiatISO:"USD",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},N={chainId:q.chainId,address:g("0xaf88d065e77c8cC2239327C5EDb3A432268e5831"),symbol:"USDC",name:"USD Coin",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png"},B={chainId:Y.chainId,address:g("0x5425890298aed601595a70ab815c96711a31bc65"),symbol:"USDC",fiatISO:"USD",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},$={chainId:J.chainId,address:g("0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E"),symbol:"USDC",fiatISO:"USD",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},z={chainId:X.chainId,address:g("0x036CbD53842c5426634e7929541eC2318f3dCF7e"),symbol:"USDC",fiatISO:"USD",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},M={chainId:V.chainId,address:g("0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"),symbol:"USDC",fiatISO:"USD",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},j={chainId:G.chainId,address:g("0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"),symbol:"USDC",decimals:18,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},O={chainId:W.chainId,address:g("0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238"),symbol:"USDC",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},P={chainId:Q.chainId,address:g("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"),symbol:"USDC",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},ot={chainId:Z.chainId,address:"0x053C91253BC9682c04929cA02ED00b3E423f6710D2ee7e0D5EBB06F3eCF368A8",symbol:"USDC",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},rt={[R.chainId]:R,[N.chainId]:N,[B.chainId]:B,[$.chainId]:$,[z.chainId]:z,[M.chainId]:M,[O.chainId]:O,[P.chainId]:P,[j.chainId]:j},F={ARBITRUM_MAINNET:{...q,tokens:{[h.USDC]:N},explorer:"https://arbiscan.io"},ARBITRUM_TESTNET:{...K,explorer:"https://sepolia.arbiscan.io",tokens:{[h.USDC]:R}},AVALANCHE_MAINNET:{...J,tokens:{[h.USDC]:$},explorer:"https://snowtrace.io"},AVALANCHE_TESTNET:{...Y,tokens:{[h.USDC]:B},explorer:"https://testnet.snowtrace.io"},BASE_MAINNET:{...V,tokens:{[h.USDC]:M},explorer:"https://basescan.org"},BASE_TESTNET:{...X,tokens:{[h.USDC]:z},explorer:"https://sepolia.basescan.org"},BSC_MAINNET:{...G,tokens:{[h.USDC]:j},explorer:"https://bscscan.com"},ETHEREUM_MAINNET:{...Q,tokens:{[h.USDC]:P},explorer:"https://etherscan.io"},ETHEREUM_TESTNET:{...W,tokens:{[h.USDC]:O},explorer:"https://sepolia.etherscan.io"},STARKNET_MAINNET:{...Z,tokens:{[h.USDC]:ot},explorer:""}};var A=(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))(A||{}),_=(e=>(e.USDC="USDC",e))(_||{});function at(e){return rt[F[e||""].chainId]?.decimals||6}const ct=e=>{const t=e?.trim().toUpperCase();if(F[t])return F[t]};function ut(e,t){return ct(e)?.tokens[t]?.address}var L=(e=>(e.PRODUCTION="production",e.STAGING="staging",e))(L||{});class c{constructor({api_key:t,env:s,seesion_token:n}){this.api_key=t||"",this.sessionToken=n||"",this.env=s??L.PRODUCTION}static async config(t){if(!c.app){if(!t)throw new Error("Please provide an api_key");c.app=new c(t)}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}static getApiKey(){if(!c.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return c.app.api_key}static getSessionToken(){if(!c.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return c.app.sessionToken}static getEnv(){if(!c.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return c.app.env==="internal"?"staging":c.app.env}static getBaseUrl(){if(!c.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");switch(c.app.env){case"production":return"https://api.chainrails.io/api/v1";case"staging":return"https://dev.chainrails.io/api/v1";case"internal":return"https://dev.chainrails.io/api/v1";default:return"https://api.chainrails.io/api/v1"}}static getPayModalUrl(t,s,n,i){if(!c.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");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:""}`;return r+o+a}}let H=null;function lt(){H=I.create({prefixUrl:c.getBaseUrl(),headers:{"Content-Type":"application/json"},hooks:{beforeRequest:[e=>{const t=c.getSessionToken()||c.getApiKey();e.headers.set("Authorization",`Bearer ${t}`)}],afterResponse:[(e,t,s)=>s]},retry:{limit:2}})}function u(){return H||lt(),H}class ht{async getById(t){return await u().get("intents/"+t).json()}async getForSender(t){return await u().get("intents/user/"+t).json()}async getForAddress(t){return await u().get("intents/address/"+t).json()}async getForSession(t){return await u().get("modal/sessions/intents/"+t).json()}async getAll(t){return await u().get("intents",{searchParams:t}).json()}async create(t){return await u().post("intents",{json:t}).json()}async createForSession(t){return await u().post("modal/sessions/intents",{json:t}).json()}async update(t,s){return await u().post("intents",{json:s}).json()}async triggerProcessing(t){return await u().post(`intents/${t}/trigger-processing`).json()}async triggerProcessingForSession(t){return await u().post(`modal/sessions/intents/${t}/process`).json()}}class dt{async getFromSpecificBridge(t){return await u().get("quotes/single",{searchParams:t}).json()}async getFromAllBridges(t){return await u().get("quotes/multiple",{searchParams:t}).json()}async getBestAcrossBridges(t){return await u().get("quotes/best",{searchParams:t}).json()}async getAll(t){return await u().get("quotes/multi-source",{searchParams:t}).json()}async getAllForSession(t){return await u().get("modal/sessions/quotes",{searchParams:t}).json()}}class pt{async getOptimalRoutes(t){return await u().get("router/optimal-route",{searchParams:t}).json()}async getAllSupportedBridges(){return await u().get("router/supported-bridges/all").json()}async getSupportedBridges(t){return await u().get("router/supported-bridges/route",{searchParams:t}).json()}async getSupportedRoutes(t,s){return await u().get("router/supported-bridges/bridge/"+t,{searchParams:s}).json()}}class gt{async getSupported(t){return await u().get("chains",{searchParams:t}).json()}}class ft{async getClientInfo(){return await u().get("client/auth/client-info").json()}}class mt{getSessionToken(t){const s={recipient:t.recipient,tokenOut:ut(A[t.destinationChain],_[t.token]),destinationChain:A[t.destinationChain],amount:t.amount};return u().post("modal/sessions",{json:s}).json()}}const yt={router:new pt,quotes:new dt,intents:new ht,chains:new gt,client:new ft,auth:new mt};l.Chainrails=c,l.chains=A,l.crapi=yt,l.environment=L,l.getTokenDecimals=at,l.tokens=_,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})}));
|
|
2
|
+
`);super(o,s.cause?{cause:s.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=n,this.docsPath=i,this.metaMessages=s.metaMessages,this.name=s.name??this.name,this.shortMessage=t,this.version=te}walk(t){return se(this,t)}}function se(e,t){return t?.(e)?e:e&&typeof e=="object"&&"cause"in e&&e.cause!==void 0?se(e.cause,t):t?null:e}class ne extends f{constructor({size:t,targetSize:s,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (${t}) exceeds padding size (${s}).`,{name:"SizeExceedsPaddingSizeError"})}}function w(e,{dir:t,size:s=32}={}){return typeof e=="string"?Se(e,{dir:t,size:s}):Ee(e,{dir:t,size:s})}function Se(e,{dir:t,size:s=32}={}){if(s===null)return e;const n=e.replace("0x","");if(n.length>s*2)throw new ne({size:Math.ceil(n.length/2),targetSize:s,type:"hex"});return`0x${n[t==="right"?"padEnd":"padStart"](s*2,"0")}`}function Ee(e,{dir:t,size:s=32}={}){if(s===null)return e;if(e.length>s)throw new ne({size:e.length,targetSize:s,type:"bytes"});const n=new Uint8Array(s);for(let i=0;i<s;i++){const r=t==="right";n[r?i:s-i-1]=e[r?i:e.length-i-1]}return n}class Ae extends f{constructor({max:t,min:s,signed:n,size:i,value:r}){super(`Number "${r}" is not in safe ${i?`${i*8}-bit ${n?"signed":"unsigned"} `:""}integer range ${t?`(${s} to ${t})`:`(above ${s})`}`,{name:"IntegerOutOfRangeError"})}}class Ue extends f{constructor({givenSize:t,maxSize:s}){super(`Size cannot exceed ${s} bytes. Given size: ${t} bytes.`,{name:"SizeOverflowError"})}}function T(e,{size:t}){if(ee(e)>t)throw new Ue({givenSize:ee(e),maxSize:t})}function ve(e,t={}){const{signed:s,size:n}=t,i=BigInt(e);let r;n?s?r=(1n<<BigInt(n)*8n-1n)-1n:r=2n**(BigInt(n)*8n)-1n:typeof e=="number"&&(r=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof r=="bigint"&&s?-r-1n:0;if(r&&i>r||i<o){const d=typeof e=="bigint"?"n":"";throw new Ae({max:r?`${r}${d}`:void 0,min:`${o}${d}`,signed:s,size:n,value:`${e}${d}`})}const a=`0x${(s&&i<0?(1n<<BigInt(n*8))+BigInt(i):i).toString(16)}`;return n?w(a,{size:n}):a}const Ce=new TextEncoder;function Te(e,t={}){return typeof e=="number"||typeof e=="bigint"?xe(e,t):typeof e=="boolean"?De(e,t):v(e)?oe(e,t):re(e,t)}function De(e,t={}){const s=new Uint8Array(1);return s[0]=Number(e),typeof t.size=="number"?(T(s,{size:t.size}),w(s,{size:t.size})):s}const p={zero:48,nine:57,A:65,F:70,a:97,f:102};function ie(e){if(e>=p.zero&&e<=p.nine)return e-p.zero;if(e>=p.A&&e<=p.F)return e-(p.A-10);if(e>=p.a&&e<=p.f)return e-(p.a-10)}function oe(e,t={}){let s=e;t.size&&(T(s,{size:t.size}),s=w(s,{dir:"right",size:t.size}));let n=s.slice(2);n.length%2&&(n=`0${n}`);const i=n.length/2,r=new Uint8Array(i);for(let o=0,a=0;o<i;o++){const d=ie(n.charCodeAt(a++)),m=ie(n.charCodeAt(a++));if(d===void 0||m===void 0)throw new f(`Invalid byte sequence ("${n[a-2]}${n[a-1]}" in "${n}").`);r[o]=d*16+m}return r}function xe(e,t){const s=ve(e,t);return oe(s)}function re(e,t={}){const s=Ce.encode(e);return typeof t.size=="number"?(T(s,{size:t.size}),w(s,{dir:"right",size:t.size})):s}const S=BigInt(2**32-1),ae=BigInt(32);function ke(e,t=!1){return t?{h:Number(e&S),l:Number(e>>ae&S)}:{h:Number(e>>ae&S)|0,l:Number(e&S)|0}}function Re(e,t=!1){const s=e.length;let n=new Uint32Array(s),i=new Uint32Array(s);for(let r=0;r<s;r++){const{h:o,l:a}=ke(e[r],t);[n[r],i[r]]=[o,a]}return[n,i]}const Ne=(e,t,s)=>e<<s|t>>>32-s,Be=(e,t,s)=>t<<s|e>>>32-s,$e=(e,t,s)=>t<<s-32|e>>>64-s,ze=(e,t,s)=>e<<s-32|t>>>64-s;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Me(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function ce(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function E(e,...t){if(!Me(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function ue(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function je(e,t){E(e);const s=t.outputLen;if(e.length<s)throw new Error("digestInto() expects output buffer of length at least "+s)}function Oe(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function le(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}const Pe=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Fe(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function _e(e){for(let t=0;t<e.length;t++)e[t]=Fe(e[t]);return e}const he=Pe?e=>e:_e;function Le(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function de(e){return typeof e=="string"&&(e=Le(e)),E(e),e}class He{}function qe(e){const t=n=>e().update(de(n)).digest(),s=e();return t.outputLen=s.outputLen,t.blockLen=s.blockLen,t.create=()=>e(),t}const Ke=BigInt(0),b=BigInt(1),Ve=BigInt(2),Xe=BigInt(7),Ge=BigInt(256),Qe=BigInt(113),pe=[],ge=[],fe=[];for(let e=0,t=b,s=1,n=0;e<24;e++){[s,n]=[n,(2*s+3*n)%5],pe.push(2*(5*n+s)),ge.push((e+1)*(e+2)/2%64);let i=Ke;for(let r=0;r<7;r++)t=(t<<b^(t>>Xe)*Qe)%Ge,t&Ve&&(i^=b<<(b<<BigInt(r))-b);fe.push(i)}const me=Re(fe,!0),We=me[0],Je=me[1],ye=(e,t,s)=>s>32?$e(e,t,s):Ne(e,t,s),Ie=(e,t,s)=>s>32?ze(e,t,s):Be(e,t,s);function Ye(e,t=24){const s=new Uint32Array(10);for(let n=24-t;n<24;n++){for(let o=0;o<10;o++)s[o]=e[o]^e[o+10]^e[o+20]^e[o+30]^e[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,d=(o+2)%10,m=s[d],y=s[d+1],It=ye(m,y,1)^s[a],bt=Ie(m,y,1)^s[a+1];for(let U=0;U<50;U+=10)e[o+U]^=It,e[o+U+1]^=bt}let i=e[2],r=e[3];for(let o=0;o<24;o++){const a=ge[o],d=ye(i,r,a),m=Ie(i,r,a),y=pe[o];i=e[y],r=e[y+1],e[y]=d,e[y+1]=m}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)s[a]=e[o+a];for(let a=0;a<10;a++)e[o+a]^=~s[(a+2)%10]&s[(a+4)%10]}e[0]^=We[n],e[1]^=Je[n]}le(s)}class D extends He{constructor(t,s,n,i=!1,r=24){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,ce(n),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=Oe(this.state)}clone(){return this._cloneInto()}keccak(){he(this.state32),Ye(this.state32,this.rounds),he(this.state32),this.posOut=0,this.pos=0}update(t){ue(this),t=de(t),E(t);const{blockLen:s,state:n}=this,i=t.length;for(let r=0;r<i;){const o=Math.min(s-this.pos,i-r);for(let a=0;a<o;a++)n[this.pos++]^=t[r++];this.pos===s&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:s,pos:n,blockLen:i}=this;t[n]^=s,(s&128)!==0&&n===i-1&&this.keccak(),t[i-1]^=128,this.keccak()}writeInto(t){ue(this,!1),E(t),this.finish();const s=this.state,{blockLen:n}=this;for(let i=0,r=t.length;i<r;){this.posOut>=n&&this.keccak();const o=Math.min(n-this.posOut,r-i);t.set(s.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=o}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return ce(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(je(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,le(this.state)}_cloneInto(t){const{blockLen:s,suffix:n,outputLen:i,rounds:r,enableXOF:o}=this;return t||(t=new D(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}}const Ze=(e,t,s)=>qe(()=>new D(t,e,s)),et=Ze(1,136,256/8);function tt(e,t){return et(v(e,{strict:!1})?Te(e):e)}class st extends f{constructor({address:t}){super(`Address "${t}" is invalid.`,{metaMessages:["- Address must be a hex value of 20 bytes (40 hex characters).","- Address must match its checksum counterpart."],name:"InvalidAddressError"})}}class be extends Map{constructor(t){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=t}get(t){const s=super.get(t);return super.has(t)&&s!==void 0&&(this.delete(t),super.set(t,s)),s}set(t,s){if(super.set(t,s),this.maxSize&&this.size>this.maxSize){const n=this.keys().next().value;n&&this.delete(n)}return this}}const x=new be(8192);function we(e,t){if(x.has(`${e}.${t}`))return x.get(`${e}.${t}`);const s=e.substring(2).toLowerCase(),n=tt(re(s)),i=s.split("");for(let o=0;o<40;o+=2)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());const r=`0x${i.join("")}`;return x.set(`${e}.${t}`,r),r}function g(e,t){if(!it(e,{strict:!1}))throw new st({address:e});return we(e,t)}const nt=/^0x[a-fA-F0-9]{40}$/,k=new be(8192);function it(e,t){const{strict:s=!0}=t??{},n=`${e}.${s}`;if(k.has(n))return k.get(n);const i=nt.test(e)?e.toLowerCase()===e?!0:s?we(e)===e:!0:!1;return k.set(n,i),i}const R={chainId:K.chainId,address:g("0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d"),symbol:"USDC",fiatISO:"USD",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},N={chainId:q.chainId,address:g("0xaf88d065e77c8cC2239327C5EDb3A432268e5831"),symbol:"USDC",name:"USD Coin",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png"},B={chainId:Y.chainId,address:g("0x5425890298aed601595a70ab815c96711a31bc65"),symbol:"USDC",fiatISO:"USD",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},$={chainId:J.chainId,address:g("0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E"),symbol:"USDC",fiatISO:"USD",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},z={chainId:X.chainId,address:g("0x036CbD53842c5426634e7929541eC2318f3dCF7e"),symbol:"USDC",fiatISO:"USD",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},M={chainId:V.chainId,address:g("0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"),symbol:"USDC",fiatISO:"USD",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},j={chainId:G.chainId,address:g("0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"),symbol:"USDC",decimals:18,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},O={chainId:W.chainId,address:g("0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238"),symbol:"USDC",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},P={chainId:Q.chainId,address:g("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"),symbol:"USDC",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},ot={chainId:Z.chainId,address:"0x053C91253BC9682c04929cA02ED00b3E423f6710D2ee7e0D5EBB06F3eCF368A8",symbol:"USDC",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},rt={[R.chainId]:R,[N.chainId]:N,[B.chainId]:B,[$.chainId]:$,[z.chainId]:z,[M.chainId]:M,[O.chainId]:O,[P.chainId]:P,[j.chainId]:j},F={ARBITRUM_MAINNET:{...q,tokens:{[h.USDC]:N},explorer:"https://arbiscan.io"},ARBITRUM_TESTNET:{...K,explorer:"https://sepolia.arbiscan.io",tokens:{[h.USDC]:R}},AVALANCHE_MAINNET:{...J,tokens:{[h.USDC]:$},explorer:"https://snowtrace.io"},AVALANCHE_TESTNET:{...Y,tokens:{[h.USDC]:B},explorer:"https://testnet.snowtrace.io"},BASE_MAINNET:{...V,tokens:{[h.USDC]:M},explorer:"https://basescan.org"},BASE_TESTNET:{...X,tokens:{[h.USDC]:z},explorer:"https://sepolia.basescan.org"},BSC_MAINNET:{...G,tokens:{[h.USDC]:j},explorer:"https://bscscan.com"},ETHEREUM_MAINNET:{...Q,tokens:{[h.USDC]:P},explorer:"https://etherscan.io"},ETHEREUM_TESTNET:{...W,tokens:{[h.USDC]:O},explorer:"https://sepolia.etherscan.io"},STARKNET_MAINNET:{...Z,tokens:{[h.USDC]:ot},explorer:""}};var A=(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))(A||{}),_=(e=>(e.USDC="USDC",e))(_||{});function at(e){return rt[F[e||""].chainId]?.decimals||6}const ct=e=>{const t=e?.trim().toUpperCase();if(F[t])return F[t]};function ut(e,t){return ct(e)?.tokens[t]?.address}var L=(e=>(e.PRODUCTION="production",e.STAGING="staging",e))(L||{});class c{constructor({api_key:t,env:s,seesion_token:n}){this.api_key=t||"",this.sessionToken=n||"",this.env=s??L.PRODUCTION}static async config(t){if(!c.app){if(!t)throw new Error("Please provide an api_key");c.app=new c(t)}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}static getApiKey(){if(!c.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return c.app.api_key}static getSessionToken(){if(!c.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return c.app.sessionToken}static getEnv(){if(!c.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return c.app.env==="internal"?"staging":c.app.env}static getBaseUrl(){if(!c.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");switch(c.app.env){case"production":return"https://api.chainrails.io/api/v1";case"staging":return"https://dev.chainrails.io/api/v1";case"internal":return"https://dev.chainrails.io/api/v1";default:return"https://api.chainrails.io/api/v1"}}static getPayModalUrl(t,s,n,i){if(!c.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");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:""}`;return r+o+a}}let H=null;function lt(){H=I.create({prefixUrl:c.getBaseUrl(),headers:{"Content-Type":"application/json"},hooks:{beforeRequest:[e=>{const t=c.getSessionToken()||c.getApiKey();e.headers.set("Authorization",`Bearer ${t}`)}],afterResponse:[(e,t,s)=>s]},retry:{limit:2}})}function u(){return H||lt(),H}class ht{async getById(t){return await u().get("intents/"+t).json()}async getForSender(t){return await u().get("intents/user/"+t).json()}async getForAddress(t){return await u().get("intents/address/"+t).json()}async getForSession(t){return await u().get("modal/sessions/intents/"+t).json()}async getAll(t){return await u().get("intents",{searchParams:t}).json()}async create(t){return await u().post("intents",{json:t}).json()}async createForSession(t){return await u().post("modal/sessions/intents",{json:t}).json()}async update(t,s){return await u().post("intents",{json:s}).json()}async triggerProcessing(t){return await u().post(`intents/${t}/trigger-processing`).json()}async triggerProcessingForSession(t){return await u().post(`modal/sessions/intents/${t}/process`).json()}}class dt{async getFromSpecificBridge(t){return await u().get("quotes/single",{searchParams:t}).json()}async getFromAllBridges(t){return await u().get("quotes/multiple",{searchParams:t}).json()}async getBestAcrossBridges(t){return await u().get("quotes/best",{searchParams:t}).json()}async getAll(t){return await u().get("quotes/multi-source",{searchParams:t}).json()}async getAllForSession(t){return await u().get("modal/sessions/quotes",{searchParams:t}).json()}}class pt{async getOptimalRoutes(t){return await u().get("router/optimal-route",{searchParams:t}).json()}async getAllSupportedBridges(){return await u().get("router/supported-bridges/all").json()}async getSupportedBridges(t){return await u().get("router/supported-bridges/route",{searchParams:t}).json()}async getSupportedRoutes(t,s){return await u().get("router/supported-bridges/bridge/"+t,{searchParams:s}).json()}}class gt{async getSupported(t){return await u().get("chains",{searchParams:t}).json()}}class ft{async getClientInfo(){return await u().get("client/auth/client-info").json()}async getClientInfoForSession(){return await u().get("modal/sessions/client").json()}}class mt{getSessionToken(t){const s={recipient:t.recipient,tokenOut:ut(A[t.destinationChain],_[t.token]),destinationChain:A[t.destinationChain],amount:t.amount};return u().post("modal/sessions",{json:s}).json()}}const yt={router:new pt,quotes:new dt,intents:new ht,chains:new gt,client:new ft,auth:new mt};l.Chainrails=c,l.chains=A,l.crapi=yt,l.environment=L,l.getTokenDecimals=at,l.tokens=_,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Client/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAE9C,MAAM,CAAC,OAAO,OAAO,MAAM;IACnB,aAAa;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Client/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAE9C,MAAM,CAAC,OAAO,OAAO,MAAM;IACnB,aAAa;IAIb,uBAAuB;CAG9B;AAED,cAAc,SAAS,CAAC"}
|