@chainrails/common 0.2.2 → 0.2.3
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.
|
@@ -310,28 +310,28 @@ function Pe(e) {
|
|
|
310
310
|
const t = (s) => e().update(ce(s)).digest(), n = e();
|
|
311
311
|
return t.outputLen = n.outputLen, t.blockLen = n.blockLen, t.create = () => e(), t;
|
|
312
312
|
}
|
|
313
|
-
const _e = BigInt(0), m = BigInt(1), Fe = BigInt(2),
|
|
313
|
+
const _e = BigInt(0), m = BigInt(1), Fe = BigInt(2), Ke = BigInt(7), je = BigInt(256), Ve = BigInt(113), ae = [], ue = [], le = [];
|
|
314
314
|
for (let e = 0, t = m, n = 1, s = 0; e < 24; e++) {
|
|
315
315
|
[n, s] = [s, (2 * n + 3 * s) % 5], ae.push(2 * (5 * s + n)), ue.push((e + 1) * (e + 2) / 2 % 64);
|
|
316
316
|
let o = _e;
|
|
317
317
|
for (let r = 0; r < 7; r++)
|
|
318
|
-
t = (t << m ^ (t >>
|
|
318
|
+
t = (t << m ^ (t >> Ke) * Ve) % je, t & Fe && (o ^= m << (m << /* @__PURE__ */ BigInt(r)) - m);
|
|
319
319
|
le.push(o);
|
|
320
320
|
}
|
|
321
|
-
const he = De(le, !0), Xe = he[0], Ge = he[1],
|
|
321
|
+
const he = De(le, !0), Xe = he[0], Ge = he[1], K = (e, t, n) => n > 32 ? Ne(e, t, n) : Ce(e, t, n), j = (e, t, n) => n > 32 ? Be(e, t, n) : ve(e, t, n);
|
|
322
322
|
function qe(e, t = 24) {
|
|
323
323
|
const n = new Uint32Array(10);
|
|
324
324
|
for (let s = 24 - t; s < 24; s++) {
|
|
325
325
|
for (let i = 0; i < 10; i++)
|
|
326
326
|
n[i] = e[i] ^ e[i + 10] ^ e[i + 20] ^ e[i + 30] ^ e[i + 40];
|
|
327
327
|
for (let i = 0; i < 10; i += 2) {
|
|
328
|
-
const c = (i + 8) % 10, u = (i + 2) % 10, p = n[u], g = n[u + 1], ge =
|
|
328
|
+
const c = (i + 8) % 10, u = (i + 2) % 10, p = n[u], g = n[u + 1], ge = K(p, g, 1) ^ n[c], me = j(p, g, 1) ^ n[c + 1];
|
|
329
329
|
for (let b = 0; b < 50; b += 10)
|
|
330
330
|
e[i + b] ^= ge, e[i + b + 1] ^= me;
|
|
331
331
|
}
|
|
332
332
|
let o = e[2], r = e[3];
|
|
333
333
|
for (let i = 0; i < 24; i++) {
|
|
334
|
-
const c = ue[i], u =
|
|
334
|
+
const c = ue[i], u = K(o, r, c), p = j(o, r, c), g = ae[i];
|
|
335
335
|
o = e[g], r = e[g + 1], e[g] = u, e[g + 1] = p;
|
|
336
336
|
}
|
|
337
337
|
for (let i = 0; i < 50; i += 10) {
|
|
@@ -640,8 +640,8 @@ function ct(e, t) {
|
|
|
640
640
|
}
|
|
641
641
|
var pe = /* @__PURE__ */ ((e) => (e.PRODUCTION = "production", e.STAGING = "staging", e))(pe || {});
|
|
642
642
|
class a {
|
|
643
|
-
constructor({ api_key: t, env: n, seesion_token: s }) {
|
|
644
|
-
this.api_key = t || "", this.sessionToken = s || "", this.env = n ?? pe.PRODUCTION;
|
|
643
|
+
constructor({ api_key: t, env: n, seesion_token: s, props: o }) {
|
|
644
|
+
this.api_key = t || "", this.sessionToken = s || "", this.env = n ?? pe.PRODUCTION, this.props = o;
|
|
645
645
|
}
|
|
646
646
|
static async config(t) {
|
|
647
647
|
if (!a.app) {
|
|
@@ -649,7 +649,7 @@ class a {
|
|
|
649
649
|
throw new Error("Please provide an api_key");
|
|
650
650
|
a.app = new a(t);
|
|
651
651
|
}
|
|
652
|
-
return t && (t.api_key !== void 0 && (a.app.api_key = t.api_key), t.seesion_token !== void 0 && (a.app.sessionToken = t.seesion_token), t.env !== void 0 && (a.app.env = t.env)), a.app;
|
|
652
|
+
return t && (t.api_key !== void 0 && (a.app.api_key = t.api_key), t.seesion_token !== void 0 && (a.app.sessionToken = t.seesion_token), t.env !== void 0 && (a.app.env = t.env), t.props !== void 0 && (a.app.props = t.props)), a.app;
|
|
653
653
|
}
|
|
654
654
|
static getApiKey() {
|
|
655
655
|
if (!a.app)
|
|
@@ -661,6 +661,11 @@ class a {
|
|
|
661
661
|
throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
|
|
662
662
|
return a.app.sessionToken;
|
|
663
663
|
}
|
|
664
|
+
static getProps() {
|
|
665
|
+
if (!a.app)
|
|
666
|
+
throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
|
|
667
|
+
return a.app.props;
|
|
668
|
+
}
|
|
664
669
|
static getEnv() {
|
|
665
670
|
if (!a.app)
|
|
666
671
|
throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
|
|
@@ -310,28 +310,28 @@ function Pe(e) {
|
|
|
310
310
|
const t = (s) => e().update(ce(s)).digest(), n = e();
|
|
311
311
|
return t.outputLen = n.outputLen, t.blockLen = n.blockLen, t.create = () => e(), t;
|
|
312
312
|
}
|
|
313
|
-
const _e = BigInt(0), m = BigInt(1), Fe = BigInt(2),
|
|
313
|
+
const _e = BigInt(0), m = BigInt(1), Fe = BigInt(2), Ke = BigInt(7), je = BigInt(256), Ve = BigInt(113), ae = [], ue = [], le = [];
|
|
314
314
|
for (let e = 0, t = m, n = 1, s = 0; e < 24; e++) {
|
|
315
315
|
[n, s] = [s, (2 * n + 3 * s) % 5], ae.push(2 * (5 * s + n)), ue.push((e + 1) * (e + 2) / 2 % 64);
|
|
316
316
|
let o = _e;
|
|
317
317
|
for (let r = 0; r < 7; r++)
|
|
318
|
-
t = (t << m ^ (t >>
|
|
318
|
+
t = (t << m ^ (t >> Ke) * Ve) % je, t & Fe && (o ^= m << (m << /* @__PURE__ */ BigInt(r)) - m);
|
|
319
319
|
le.push(o);
|
|
320
320
|
}
|
|
321
|
-
const he = De(le, !0), Xe = he[0], Ge = he[1],
|
|
321
|
+
const he = De(le, !0), Xe = he[0], Ge = he[1], K = (e, t, n) => n > 32 ? Ne(e, t, n) : Ce(e, t, n), j = (e, t, n) => n > 32 ? Be(e, t, n) : ve(e, t, n);
|
|
322
322
|
function qe(e, t = 24) {
|
|
323
323
|
const n = new Uint32Array(10);
|
|
324
324
|
for (let s = 24 - t; s < 24; s++) {
|
|
325
325
|
for (let i = 0; i < 10; i++)
|
|
326
326
|
n[i] = e[i] ^ e[i + 10] ^ e[i + 20] ^ e[i + 30] ^ e[i + 40];
|
|
327
327
|
for (let i = 0; i < 10; i += 2) {
|
|
328
|
-
const c = (i + 8) % 10, u = (i + 2) % 10, p = n[u], g = n[u + 1], ge =
|
|
328
|
+
const c = (i + 8) % 10, u = (i + 2) % 10, p = n[u], g = n[u + 1], ge = K(p, g, 1) ^ n[c], me = j(p, g, 1) ^ n[c + 1];
|
|
329
329
|
for (let b = 0; b < 50; b += 10)
|
|
330
330
|
e[i + b] ^= ge, e[i + b + 1] ^= me;
|
|
331
331
|
}
|
|
332
332
|
let o = e[2], r = e[3];
|
|
333
333
|
for (let i = 0; i < 24; i++) {
|
|
334
|
-
const c = ue[i], u =
|
|
334
|
+
const c = ue[i], u = K(o, r, c), p = j(o, r, c), g = ae[i];
|
|
335
335
|
o = e[g], r = e[g + 1], e[g] = u, e[g + 1] = p;
|
|
336
336
|
}
|
|
337
337
|
for (let i = 0; i < 50; i += 10) {
|
|
@@ -640,8 +640,8 @@ function ct(e, t) {
|
|
|
640
640
|
}
|
|
641
641
|
var pe = /* @__PURE__ */ ((e) => (e.PRODUCTION = "production", e.STAGING = "staging", e))(pe || {});
|
|
642
642
|
class a {
|
|
643
|
-
constructor({ api_key: t, env: n, seesion_token: s }) {
|
|
644
|
-
this.api_key = t || "", this.sessionToken = s || "", this.env = n ?? pe.PRODUCTION;
|
|
643
|
+
constructor({ api_key: t, env: n, seesion_token: s, props: o }) {
|
|
644
|
+
this.api_key = t || "", this.sessionToken = s || "", this.env = n ?? pe.PRODUCTION, this.props = o;
|
|
645
645
|
}
|
|
646
646
|
static async config(t) {
|
|
647
647
|
if (!a.app) {
|
|
@@ -649,7 +649,7 @@ class a {
|
|
|
649
649
|
throw new Error("Please provide an api_key");
|
|
650
650
|
a.app = new a(t);
|
|
651
651
|
}
|
|
652
|
-
return t && (t.api_key !== void 0 && (a.app.api_key = t.api_key), t.seesion_token !== void 0 && (a.app.sessionToken = t.seesion_token), t.env !== void 0 && (a.app.env = t.env)), a.app;
|
|
652
|
+
return t && (t.api_key !== void 0 && (a.app.api_key = t.api_key), t.seesion_token !== void 0 && (a.app.sessionToken = t.seesion_token), t.env !== void 0 && (a.app.env = t.env), t.props !== void 0 && (a.app.props = t.props)), a.app;
|
|
653
653
|
}
|
|
654
654
|
static getApiKey() {
|
|
655
655
|
if (!a.app)
|
|
@@ -661,6 +661,11 @@ class a {
|
|
|
661
661
|
throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
|
|
662
662
|
return a.app.sessionToken;
|
|
663
663
|
}
|
|
664
|
+
static getProps() {
|
|
665
|
+
if (!a.app)
|
|
666
|
+
throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
|
|
667
|
+
return a.app.props;
|
|
668
|
+
}
|
|
664
669
|
static getEnv() {
|
|
665
670
|
if (!a.app)
|
|
666
671
|
throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
(function(l,u){typeof exports=="object"&&typeof module<"u"?u(exports):typeof define=="function"&&define.amd?define(["exports"],u):(l=typeof globalThis<"u"?globalThis:l||self,u(l.Chainrails={}))})(this,(function(l){"use strict";var u=(e=>(e.USDC="USDC",e))(u||{});const H={type:"evm",chainId:42161,name:"Arbitrum",cctpDomain:3,logoURI:"/images/chains/arbitrum.svg"},P={type:"evm",chainId:421614,name:"Arbitrum Sepolia",cctpDomain:3,logoURI:"/images/chains/arbitrum.svg"},_={type:"evm",chainId:8453,name:"Base",cctpDomain:6,logoURI:"/images/chains/base.webp"},F={type:"evm",chainId:84532,name:"Base Sepolia",cctpDomain:6,logoURI:"/images/chains/base.webp"},j={type:"evm",chainId:56,name:"BNB Chain",cctpDomain:null,logoURI:"/images/chains/bsc.webp"},K={type:"evm",chainId:1,name:"Ethereum",cctpDomain:0,logoURI:"/images/chains/ethereum.svg"},V={type:"evm",chainId:11155111,name:"Ethereum Sepolia",cctpDomain:0,logoURI:"/images/chains/ethereum.svg"},X={type:"evm",chainId:43114,name:"Avalanche",cctpDomain:1,logoURI:"/images/chains/avalanche.svg"},G={type:"evm",chainId:43113,name:"Avalanche Fuji",cctpDomain:1,logoURI:"/images/chains/avalanche.svg"},q={type:"starknet",chainId:"0x534e5f4d41494e",name:"Starknet",cctpDomain:null,logoURI:"/images/chains/starknet.svg"};function U(e,{strict:t=!0}={}){return!e||typeof e!="string"?!1:t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x")}function W(e){return U(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}const J="2.43.4";let T={getDocsUrl:({docsBaseUrl:e,docsPath:t="",docsSlug:n})=>t?`${e??"https://viem.sh"}${t}${n?`#${n}`:""}`:void 0,version:`viem@${J}`};class p extends Error{constructor(t,n={}){const s=n.cause instanceof p?n.cause.details:n.cause?.message?n.cause.message:n.details,i=n.cause instanceof p&&n.cause.docsPath||n.docsPath,r=T.getDocsUrl?.({...n,docsPath:i}),o=[t||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...r?[`Docs: ${r}`]:[],...s?[`Details: ${s}`]:[],...T.version?[`Version: ${T.version}`]:[]].join(`
|
|
2
|
-
`);super(o,n.cause?{cause:n.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=s,this.docsPath=i,this.metaMessages=n.metaMessages,this.name=n.name??this.name,this.shortMessage=t,this.version=J}walk(t){return Q(this,t)}}function Q(e,t){return t?.(e)?e:e&&typeof e=="object"&&"cause"in e&&e.cause!==void 0?Q(e.cause,t):t?null:e}class Y extends p{constructor({size:t,targetSize:n,type:s}){super(`${s.charAt(0).toUpperCase()}${s.slice(1).toLowerCase()} size (${t}) exceeds padding size (${n}).`,{name:"SizeExceedsPaddingSizeError"})}}function I(e,{dir:t,size:n=32}={}){return typeof e=="string"?ye(e,{dir:t,size:n}):Ee(e,{dir:t,size:n})}function ye(e,{dir:t,size:n=32}={}){if(n===null)return e;const s=e.replace("0x","");if(s.length>n*2)throw new Y({size:Math.ceil(s.length/2),targetSize:n,type:"hex"});return`0x${s[t==="right"?"padEnd":"padStart"](n*2,"0")}`}function Ee(e,{dir:t,size:n=32}={}){if(n===null)return e;if(e.length>n)throw new Y({size:e.length,targetSize:n,type:"bytes"});const s=new Uint8Array(n);for(let i=0;i<n;i++){const r=t==="right";s[r?i:n-i-1]=e[r?i:e.length-i-1]}return s}class Se extends p{constructor({max:t,min:n,signed:s,size:i,value:r}){super(`Number "${r}" is not in safe ${i?`${i*8}-bit ${s?"signed":"unsigned"} `:""}integer range ${t?`(${n} to ${t})`:`(above ${n})`}`,{name:"IntegerOutOfRangeError"})}}class Ae extends p{constructor({givenSize:t,maxSize:n}){super(`Size cannot exceed ${n} bytes. Given size: ${t} bytes.`,{name:"SizeOverflowError"})}}function w(e,{size:t}){if(W(e)>t)throw new Ae({givenSize:W(e),maxSize:t})}function Ue(e,t={}){const{signed:n,size:s}=t,i=BigInt(e);let r;s?n?r=(1n<<BigInt(s)*8n-1n)-1n:r=2n**(BigInt(s)*8n)-1n:typeof e=="number"&&(r=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof r=="bigint"&&n?-r-1n:0;if(r&&i>r||i<o){const d=typeof e=="bigint"?"n":"";throw new Se({max:r?`${r}${d}`:void 0,min:`${o}${d}`,signed:n,size:s,value:`${e}${d}`})}const c=`0x${(n&&i<0?(1n<<BigInt(s*8))+BigInt(i):i).toString(16)}`;return s?I(c,{size:s}):c}const Te=new TextEncoder;function we(e,t={}){return typeof e=="number"||typeof e=="bigint"?Ce(e,t):typeof e=="boolean"?xe(e,t):U(e)?ee(e,t):te(e,t)}function xe(e,t={}){const n=new Uint8Array(1);return n[0]=Number(e),typeof t.size=="number"?(w(n,{size:t.size}),I(n,{size:t.size})):n}const h={zero:48,nine:57,A:65,F:70,a:97,f:102};function Z(e){if(e>=h.zero&&e<=h.nine)return e-h.zero;if(e>=h.A&&e<=h.F)return e-(h.A-10);if(e>=h.a&&e<=h.f)return e-(h.a-10)}function ee(e,t={}){let n=e;t.size&&(w(n,{size:t.size}),n=I(n,{dir:"right",size:t.size}));let s=n.slice(2);s.length%2&&(s=`0${s}`);const i=s.length/2,r=new Uint8Array(i);for(let o=0,c=0;o<i;o++){const d=Z(s.charCodeAt(c++)),g=Z(s.charCodeAt(c++));if(d===void 0||g===void 0)throw new p(`Invalid byte sequence ("${s[c-2]}${s[c-1]}" in "${s}").`);r[o]=d*16+g}return r}function Ce(e,t){const n=Ue(e,t);return ee(n)}function te(e,t={}){const n=Te.encode(e);return typeof t.size=="number"?(w(n,{size:t.size}),I(n,{dir:"right",size:t.size})):n}const y=BigInt(2**32-1),ne=BigInt(32);function De(e,t=!1){return t?{h:Number(e&y),l:Number(e>>ne&y)}:{h:Number(e>>ne&y)|0,l:Number(e&y)|0}}function ve(e,t=!1){const n=e.length;let s=new Uint32Array(n),i=new Uint32Array(n);for(let r=0;r<n;r++){const{h:o,l:c}=De(e[r],t);[s[r],i[r]]=[o,c]}return[s,i]}const Ne=(e,t,n)=>e<<n|t>>>32-n,ke=(e,t,n)=>t<<n|e>>>32-n,Be=(e,t,n)=>t<<n-32|e>>>64-n,Re=(e,t,n)=>e<<n-32|t>>>64-n;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function $e(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function se(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function E(e,...t){if(!$e(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 ie(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 Me(e,t){E(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function Oe(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function oe(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}const ze=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Le(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function He(e){for(let t=0;t<e.length;t++)e[t]=Le(e[t]);return e}const re=ze?e=>e:He;function Pe(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function ce(e){return typeof e=="string"&&(e=Pe(e)),E(e),e}class _e{}function Fe(e){const t=s=>e().update(ce(s)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}const je=BigInt(0),b=BigInt(1),Ke=BigInt(2),Ve=BigInt(7),Xe=BigInt(256),Ge=BigInt(113),ae=[],ue=[],le=[];for(let e=0,t=b,n=1,s=0;e<24;e++){[n,s]=[s,(2*n+3*s)%5],ae.push(2*(5*s+n)),ue.push((e+1)*(e+2)/2%64);let i=je;for(let r=0;r<7;r++)t=(t<<b^(t>>Ve)*Ge)%Xe,t&Ke&&(i^=b<<(b<<BigInt(r))-b);le.push(i)}const de=ve(le,!0),qe=de[0],We=de[1],he=(e,t,n)=>n>32?Be(e,t,n):Ne(e,t,n),fe=(e,t,n)=>n>32?Re(e,t,n):ke(e,t,n);function Je(e,t=24){const n=new Uint32Array(10);for(let s=24-t;s<24;s++){for(let o=0;o<10;o++)n[o]=e[o]^e[o+10]^e[o+20]^e[o+30]^e[o+40];for(let o=0;o<10;o+=2){const c=(o+8)%10,d=(o+2)%10,g=n[d],m=n[d+1],ct=he(g,m,1)^n[c],at=fe(g,m,1)^n[c+1];for(let A=0;A<50;A+=10)e[o+A]^=ct,e[o+A+1]^=at}let i=e[2],r=e[3];for(let o=0;o<24;o++){const c=ue[o],d=he(i,r,c),g=fe(i,r,c),m=ae[o];i=e[m],r=e[m+1],e[m]=d,e[m+1]=g}for(let o=0;o<50;o+=10){for(let c=0;c<10;c++)n[c]=e[o+c];for(let c=0;c<10;c++)e[o+c]^=~n[(c+2)%10]&n[(c+4)%10]}e[0]^=qe[s],e[1]^=We[s]}oe(n)}class x extends _e{constructor(t,n,s,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=n,this.outputLen=s,this.enableXOF=i,this.rounds=r,se(s),!(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(){re(this.state32),Je(this.state32,this.rounds),re(this.state32),this.posOut=0,this.pos=0}update(t){ie(this),t=ce(t),E(t);const{blockLen:n,state:s}=this,i=t.length;for(let r=0;r<i;){const o=Math.min(n-this.pos,i-r);for(let c=0;c<o;c++)s[this.pos++]^=t[r++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:n,pos:s,blockLen:i}=this;t[s]^=n,(n&128)!==0&&s===i-1&&this.keccak(),t[i-1]^=128,this.keccak()}writeInto(t){ie(this,!1),E(t),this.finish();const n=this.state,{blockLen:s}=this;for(let i=0,r=t.length;i<r;){this.posOut>=s&&this.keccak();const o=Math.min(s-this.posOut,r-i);t.set(n.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 se(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Me(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,oe(this.state)}_cloneInto(t){const{blockLen:n,suffix:s,outputLen:i,rounds:r,enableXOF:o}=this;return t||(t=new x(n,s,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=s,t.outputLen=i,t.enableXOF=o,t.destroyed=this.destroyed,t}}const Qe=(e,t,n)=>Fe(()=>new x(t,e,n)),Ye=Qe(1,136,256/8);function Ze(e,t){return Ye(U(e,{strict:!1})?we(e):e)}class et extends p{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 pe extends Map{constructor(t){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=t}get(t){const n=super.get(t);return super.has(t)&&n!==void 0&&(this.delete(t),super.set(t,n)),n}set(t,n){if(super.set(t,n),this.maxSize&&this.size>this.maxSize){const s=this.keys().next().value;s&&this.delete(s)}return this}}const C=new pe(8192);function ge(e,t){if(C.has(`${e}.${t}`))return C.get(`${e}.${t}`);const n=e.substring(2).toLowerCase(),s=Ze(te(n)),i=n.split("");for(let o=0;o<40;o+=2)s[o>>1]>>4>=8&&i[o]&&(i[o]=i[o].toUpperCase()),(s[o>>1]&15)>=8&&i[o+1]&&(i[o+1]=i[o+1].toUpperCase());const r=`0x${i.join("")}`;return C.set(`${e}.${t}`,r),r}function f(e,t){if(!nt(e,{strict:!1}))throw new et({address:e});return ge(e,t)}const tt=/^0x[a-fA-F0-9]{40}$/,D=new pe(8192);function nt(e,t){const{strict:n=!0}=t??{},s=`${e}.${n}`;if(D.has(s))return D.get(s);const i=tt.test(e)?e.toLowerCase()===e?!0:n?ge(e)===e:!0:!1;return D.set(s,i),i}const v={chainId:P.chainId,address:f("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:H.chainId,address:f("0xaf88d065e77c8cC2239327C5EDb3A432268e5831"),symbol:"USDC",name:"USD Coin",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png"},k={chainId:G.chainId,address:f("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"},B={chainId:X.chainId,address:f("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"},R={chainId:F.chainId,address:f("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"},$={chainId:_.chainId,address:f("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"},M={chainId:j.chainId,address:f("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:V.chainId,address:f("0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238"),symbol:"USDC",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},z={chainId:K.chainId,address:f("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"),symbol:"USDC",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},st={chainId:q.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"},it={[v.chainId]:v,[N.chainId]:N,[k.chainId]:k,[B.chainId]:B,[R.chainId]:R,[$.chainId]:$,[O.chainId]:O,[z.chainId]:z,[M.chainId]:M},S={ARBITRUM_MAINNET:{...H,tokens:{[u.USDC]:N},explorer:"https://arbiscan.io"},ARBITRUM_TESTNET:{...P,explorer:"https://sepolia.arbiscan.io",tokens:{[u.USDC]:v}},AVALANCHE_MAINNET:{...X,tokens:{[u.USDC]:B},explorer:"https://snowtrace.io"},AVALANCHE_TESTNET:{...G,tokens:{[u.USDC]:k},explorer:"https://testnet.snowtrace.io"},BASE_MAINNET:{..._,tokens:{[u.USDC]:$},explorer:"https://basescan.org"},BASE_TESTNET:{...F,tokens:{[u.USDC]:R},explorer:"https://sepolia.basescan.org"},BSC_MAINNET:{...j,tokens:{[u.USDC]:M},explorer:"https://bscscan.com"},ETHEREUM_MAINNET:{...K,tokens:{[u.USDC]:z},explorer:"https://etherscan.io"},ETHEREUM_TESTNET:{...V,tokens:{[u.USDC]:O},explorer:"https://sepolia.etherscan.io"},STARKNET_MAINNET:{...q,tokens:{[u.USDC]:st},explorer:""}};var me=(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))(me||{}),be=(e=>(e.USDC="USDC",e))(be||{});function ot(e){return it[S[e||""].chainId]?.decimals||6}const Ie=e=>{const t=e?.trim().toUpperCase();if(S[t])return S[t]};function rt(e,t){return Ie(e)?.tokens[t]?.address}var L=(e=>(e.PRODUCTION="production",e.STAGING="staging",e))(L||{});class a{constructor({api_key:t,env:n,seesion_token:s}){this.api_key=t||"",this.sessionToken=s||"",this.env=n??L.PRODUCTION}static async config(t){if(!a.app){if(!t)throw new Error("Please provide an api_key");a.app=new a(t)}return t&&(t.api_key!==void 0&&(a.app.api_key=t.api_key),t.seesion_token!==void 0&&(a.app.sessionToken=t.seesion_token),t.env!==void 0&&(a.app.env=t.env)),a.app}static getApiKey(){if(!a.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return a.app.api_key}static getSessionToken(){if(!a.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return a.app.sessionToken}static getEnv(){if(!a.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return a.app.env==="internal"?"staging":a.app.env}static getBaseUrl(){if(!a.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");switch(a.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){if(!a.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");const n=a.app.env==="internal"?"https://chainrails-frontend-git-staging-horus-labs.vercel.app":"https://app.chainrails.io",s=Number(t),i=t&&!isNaN(Number(t))&&s>0?"/pay/":"/deposit/",r=`${t&&!isNaN(Number(t))&&s>0?s*100:""}`;return n+i+r}}l.Chainrails=a,l.allChains=S,l.chains=me,l.environment=L,l.getChainByChainEnum=Ie,l.getTokenAddress=rt,l.getTokenDecimals=ot,l.tokens=be,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})}));
|
|
2
|
+
`);super(o,n.cause?{cause:n.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=s,this.docsPath=i,this.metaMessages=n.metaMessages,this.name=n.name??this.name,this.shortMessage=t,this.version=J}walk(t){return Q(this,t)}}function Q(e,t){return t?.(e)?e:e&&typeof e=="object"&&"cause"in e&&e.cause!==void 0?Q(e.cause,t):t?null:e}class Y extends p{constructor({size:t,targetSize:n,type:s}){super(`${s.charAt(0).toUpperCase()}${s.slice(1).toLowerCase()} size (${t}) exceeds padding size (${n}).`,{name:"SizeExceedsPaddingSizeError"})}}function I(e,{dir:t,size:n=32}={}){return typeof e=="string"?Ee(e,{dir:t,size:n}):ye(e,{dir:t,size:n})}function Ee(e,{dir:t,size:n=32}={}){if(n===null)return e;const s=e.replace("0x","");if(s.length>n*2)throw new Y({size:Math.ceil(s.length/2),targetSize:n,type:"hex"});return`0x${s[t==="right"?"padEnd":"padStart"](n*2,"0")}`}function ye(e,{dir:t,size:n=32}={}){if(n===null)return e;if(e.length>n)throw new Y({size:e.length,targetSize:n,type:"bytes"});const s=new Uint8Array(n);for(let i=0;i<n;i++){const r=t==="right";s[r?i:n-i-1]=e[r?i:e.length-i-1]}return s}class Se extends p{constructor({max:t,min:n,signed:s,size:i,value:r}){super(`Number "${r}" is not in safe ${i?`${i*8}-bit ${s?"signed":"unsigned"} `:""}integer range ${t?`(${n} to ${t})`:`(above ${n})`}`,{name:"IntegerOutOfRangeError"})}}class Ae extends p{constructor({givenSize:t,maxSize:n}){super(`Size cannot exceed ${n} bytes. Given size: ${t} bytes.`,{name:"SizeOverflowError"})}}function w(e,{size:t}){if(W(e)>t)throw new Ae({givenSize:W(e),maxSize:t})}function Ue(e,t={}){const{signed:n,size:s}=t,i=BigInt(e);let r;s?n?r=(1n<<BigInt(s)*8n-1n)-1n:r=2n**(BigInt(s)*8n)-1n:typeof e=="number"&&(r=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof r=="bigint"&&n?-r-1n:0;if(r&&i>r||i<o){const d=typeof e=="bigint"?"n":"";throw new Se({max:r?`${r}${d}`:void 0,min:`${o}${d}`,signed:n,size:s,value:`${e}${d}`})}const c=`0x${(n&&i<0?(1n<<BigInt(s*8))+BigInt(i):i).toString(16)}`;return s?I(c,{size:s}):c}const Te=new TextEncoder;function we(e,t={}){return typeof e=="number"||typeof e=="bigint"?De(e,t):typeof e=="boolean"?xe(e,t):U(e)?ee(e,t):te(e,t)}function xe(e,t={}){const n=new Uint8Array(1);return n[0]=Number(e),typeof t.size=="number"?(w(n,{size:t.size}),I(n,{size:t.size})):n}const f={zero:48,nine:57,A:65,F:70,a:97,f:102};function Z(e){if(e>=f.zero&&e<=f.nine)return e-f.zero;if(e>=f.A&&e<=f.F)return e-(f.A-10);if(e>=f.a&&e<=f.f)return e-(f.a-10)}function ee(e,t={}){let n=e;t.size&&(w(n,{size:t.size}),n=I(n,{dir:"right",size:t.size}));let s=n.slice(2);s.length%2&&(s=`0${s}`);const i=s.length/2,r=new Uint8Array(i);for(let o=0,c=0;o<i;o++){const d=Z(s.charCodeAt(c++)),g=Z(s.charCodeAt(c++));if(d===void 0||g===void 0)throw new p(`Invalid byte sequence ("${s[c-2]}${s[c-1]}" in "${s}").`);r[o]=d*16+g}return r}function De(e,t){const n=Ue(e,t);return ee(n)}function te(e,t={}){const n=Te.encode(e);return typeof t.size=="number"?(w(n,{size:t.size}),I(n,{dir:"right",size:t.size})):n}const E=BigInt(2**32-1),ne=BigInt(32);function Ce(e,t=!1){return t?{h:Number(e&E),l:Number(e>>ne&E)}:{h:Number(e>>ne&E)|0,l:Number(e&E)|0}}function ve(e,t=!1){const n=e.length;let s=new Uint32Array(n),i=new Uint32Array(n);for(let r=0;r<n;r++){const{h:o,l:c}=Ce(e[r],t);[s[r],i[r]]=[o,c]}return[s,i]}const Ne=(e,t,n)=>e<<n|t>>>32-n,ke=(e,t,n)=>t<<n|e>>>32-n,Be=(e,t,n)=>t<<n-32|e>>>64-n,Re=(e,t,n)=>e<<n-32|t>>>64-n;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function $e(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function se(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function y(e,...t){if(!$e(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 ie(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 Me(e,t){y(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function Oe(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function oe(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}const ze=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Le(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function He(e){for(let t=0;t<e.length;t++)e[t]=Le(e[t]);return e}const re=ze?e=>e:He;function Pe(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function ce(e){return typeof e=="string"&&(e=Pe(e)),y(e),e}class _e{}function Fe(e){const t=s=>e().update(ce(s)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}const je=BigInt(0),b=BigInt(1),Ke=BigInt(2),Ve=BigInt(7),Xe=BigInt(256),Ge=BigInt(113),ae=[],ue=[],le=[];for(let e=0,t=b,n=1,s=0;e<24;e++){[n,s]=[s,(2*n+3*s)%5],ae.push(2*(5*s+n)),ue.push((e+1)*(e+2)/2%64);let i=je;for(let r=0;r<7;r++)t=(t<<b^(t>>Ve)*Ge)%Xe,t&Ke&&(i^=b<<(b<<BigInt(r))-b);le.push(i)}const de=ve(le,!0),qe=de[0],We=de[1],fe=(e,t,n)=>n>32?Be(e,t,n):Ne(e,t,n),he=(e,t,n)=>n>32?Re(e,t,n):ke(e,t,n);function Je(e,t=24){const n=new Uint32Array(10);for(let s=24-t;s<24;s++){for(let o=0;o<10;o++)n[o]=e[o]^e[o+10]^e[o+20]^e[o+30]^e[o+40];for(let o=0;o<10;o+=2){const c=(o+8)%10,d=(o+2)%10,g=n[d],m=n[d+1],ct=fe(g,m,1)^n[c],at=he(g,m,1)^n[c+1];for(let A=0;A<50;A+=10)e[o+A]^=ct,e[o+A+1]^=at}let i=e[2],r=e[3];for(let o=0;o<24;o++){const c=ue[o],d=fe(i,r,c),g=he(i,r,c),m=ae[o];i=e[m],r=e[m+1],e[m]=d,e[m+1]=g}for(let o=0;o<50;o+=10){for(let c=0;c<10;c++)n[c]=e[o+c];for(let c=0;c<10;c++)e[o+c]^=~n[(c+2)%10]&n[(c+4)%10]}e[0]^=qe[s],e[1]^=We[s]}oe(n)}class x extends _e{constructor(t,n,s,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=n,this.outputLen=s,this.enableXOF=i,this.rounds=r,se(s),!(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(){re(this.state32),Je(this.state32,this.rounds),re(this.state32),this.posOut=0,this.pos=0}update(t){ie(this),t=ce(t),y(t);const{blockLen:n,state:s}=this,i=t.length;for(let r=0;r<i;){const o=Math.min(n-this.pos,i-r);for(let c=0;c<o;c++)s[this.pos++]^=t[r++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:n,pos:s,blockLen:i}=this;t[s]^=n,(n&128)!==0&&s===i-1&&this.keccak(),t[i-1]^=128,this.keccak()}writeInto(t){ie(this,!1),y(t),this.finish();const n=this.state,{blockLen:s}=this;for(let i=0,r=t.length;i<r;){this.posOut>=s&&this.keccak();const o=Math.min(s-this.posOut,r-i);t.set(n.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 se(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Me(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,oe(this.state)}_cloneInto(t){const{blockLen:n,suffix:s,outputLen:i,rounds:r,enableXOF:o}=this;return t||(t=new x(n,s,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=s,t.outputLen=i,t.enableXOF=o,t.destroyed=this.destroyed,t}}const Qe=(e,t,n)=>Fe(()=>new x(t,e,n)),Ye=Qe(1,136,256/8);function Ze(e,t){return Ye(U(e,{strict:!1})?we(e):e)}class et extends p{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 pe extends Map{constructor(t){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=t}get(t){const n=super.get(t);return super.has(t)&&n!==void 0&&(this.delete(t),super.set(t,n)),n}set(t,n){if(super.set(t,n),this.maxSize&&this.size>this.maxSize){const s=this.keys().next().value;s&&this.delete(s)}return this}}const D=new pe(8192);function ge(e,t){if(D.has(`${e}.${t}`))return D.get(`${e}.${t}`);const n=e.substring(2).toLowerCase(),s=Ze(te(n)),i=n.split("");for(let o=0;o<40;o+=2)s[o>>1]>>4>=8&&i[o]&&(i[o]=i[o].toUpperCase()),(s[o>>1]&15)>=8&&i[o+1]&&(i[o+1]=i[o+1].toUpperCase());const r=`0x${i.join("")}`;return D.set(`${e}.${t}`,r),r}function h(e,t){if(!nt(e,{strict:!1}))throw new et({address:e});return ge(e,t)}const tt=/^0x[a-fA-F0-9]{40}$/,C=new pe(8192);function nt(e,t){const{strict:n=!0}=t??{},s=`${e}.${n}`;if(C.has(s))return C.get(s);const i=tt.test(e)?e.toLowerCase()===e?!0:n?ge(e)===e:!0:!1;return C.set(s,i),i}const v={chainId:P.chainId,address:h("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:H.chainId,address:h("0xaf88d065e77c8cC2239327C5EDb3A432268e5831"),symbol:"USDC",name:"USD Coin",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png"},k={chainId:G.chainId,address:h("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"},B={chainId:X.chainId,address:h("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"},R={chainId:F.chainId,address:h("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"},$={chainId:_.chainId,address:h("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"},M={chainId:j.chainId,address:h("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:V.chainId,address:h("0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238"),symbol:"USDC",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},z={chainId:K.chainId,address:h("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"),symbol:"USDC",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},st={chainId:q.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"},it={[v.chainId]:v,[N.chainId]:N,[k.chainId]:k,[B.chainId]:B,[R.chainId]:R,[$.chainId]:$,[O.chainId]:O,[z.chainId]:z,[M.chainId]:M},S={ARBITRUM_MAINNET:{...H,tokens:{[u.USDC]:N},explorer:"https://arbiscan.io"},ARBITRUM_TESTNET:{...P,explorer:"https://sepolia.arbiscan.io",tokens:{[u.USDC]:v}},AVALANCHE_MAINNET:{...X,tokens:{[u.USDC]:B},explorer:"https://snowtrace.io"},AVALANCHE_TESTNET:{...G,tokens:{[u.USDC]:k},explorer:"https://testnet.snowtrace.io"},BASE_MAINNET:{..._,tokens:{[u.USDC]:$},explorer:"https://basescan.org"},BASE_TESTNET:{...F,tokens:{[u.USDC]:R},explorer:"https://sepolia.basescan.org"},BSC_MAINNET:{...j,tokens:{[u.USDC]:M},explorer:"https://bscscan.com"},ETHEREUM_MAINNET:{...K,tokens:{[u.USDC]:z},explorer:"https://etherscan.io"},ETHEREUM_TESTNET:{...V,tokens:{[u.USDC]:O},explorer:"https://sepolia.etherscan.io"},STARKNET_MAINNET:{...q,tokens:{[u.USDC]:st},explorer:""}};var me=(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))(me||{}),be=(e=>(e.USDC="USDC",e))(be||{});function ot(e){return it[S[e||""].chainId]?.decimals||6}const Ie=e=>{const t=e?.trim().toUpperCase();if(S[t])return S[t]};function rt(e,t){return Ie(e)?.tokens[t]?.address}var L=(e=>(e.PRODUCTION="production",e.STAGING="staging",e))(L||{});class a{constructor({api_key:t,env:n,seesion_token:s,props:i}){this.api_key=t||"",this.sessionToken=s||"",this.env=n??L.PRODUCTION,this.props=i}static async config(t){if(!a.app){if(!t)throw new Error("Please provide an api_key");a.app=new a(t)}return t&&(t.api_key!==void 0&&(a.app.api_key=t.api_key),t.seesion_token!==void 0&&(a.app.sessionToken=t.seesion_token),t.env!==void 0&&(a.app.env=t.env),t.props!==void 0&&(a.app.props=t.props)),a.app}static getApiKey(){if(!a.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return a.app.api_key}static getSessionToken(){if(!a.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return a.app.sessionToken}static getProps(){if(!a.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return a.app.props}static getEnv(){if(!a.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return a.app.env==="internal"?"staging":a.app.env}static getBaseUrl(){if(!a.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");switch(a.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){if(!a.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");const n=a.app.env==="internal"?"https://chainrails-frontend-git-staging-horus-labs.vercel.app":"https://app.chainrails.io",s=Number(t),i=t&&!isNaN(Number(t))&&s>0?"/pay/":"/deposit/",r=`${t&&!isNaN(Number(t))&&s>0?s*100:""}`;return n+i+r}}l.Chainrails=a,l.allChains=S,l.chains=me,l.environment=L,l.getChainByChainEnum=Ie,l.getTokenAddress=rt,l.getTokenDecimals=ot,l.tokens=be,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})}));
|
package/dist/src/app/index.d.ts
CHANGED
|
@@ -1,18 +1,25 @@
|
|
|
1
1
|
import { EnvType } from "../environment";
|
|
2
|
+
type Props = {
|
|
3
|
+
/** Comma-separated chains to exclude from results, example: 'BASE_TESTNET,STARKNET_TESTNET' */
|
|
4
|
+
excludeChains?: string;
|
|
5
|
+
};
|
|
2
6
|
interface ChainrailsConfig {
|
|
3
7
|
api_key?: string;
|
|
4
8
|
env?: EnvType;
|
|
5
9
|
seesion_token?: string;
|
|
10
|
+
props?: Props;
|
|
6
11
|
}
|
|
7
12
|
export declare class Chainrails {
|
|
8
13
|
private static app;
|
|
9
14
|
api_key: string;
|
|
10
15
|
env: EnvType;
|
|
11
16
|
sessionToken: string;
|
|
17
|
+
props: Props | undefined;
|
|
12
18
|
private constructor();
|
|
13
19
|
static config(props?: ChainrailsConfig): Promise<Chainrails>;
|
|
14
20
|
static getApiKey(): string;
|
|
15
21
|
static getSessionToken(): string;
|
|
22
|
+
static getProps(): Props | undefined;
|
|
16
23
|
static getEnv(): EnvType;
|
|
17
24
|
static getBaseUrl(): string;
|
|
18
25
|
static getPayModalUrl(_amount?: string): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/app/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEtD,UAAU,gBAAgB;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/app/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEtD,KAAK,KAAK,GAAG;IACX,+FAA+F;IAC/F,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,UAAU,gBAAgB;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AAED,qBAAa,UAAU;IACrB,OAAO,CAAC,MAAM,CAAC,GAAG,CAAa;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,OAAO,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,KAAK,GAAG,SAAS,CAAC;IAEzB,OAAO;WAOa,MAAM,CAAC,KAAK,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,UAAU,CAAC;WAwB3D,SAAS,IAAI,MAAM;WAOnB,eAAe,IAAI,MAAM;WAOzB,QAAQ,IAAI,KAAK,GAAG,SAAS;WAO7B,MAAM,IAAI,OAAO;WAQjB,UAAU,IAAI,MAAM;WAgBpB,cAAc,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM;CAgBvD"}
|