@chainrails/sdk 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chainrails-sdk.es.js +16 -16
- package/dist/chainrails-sdk.es.mjs +16 -16
- package/dist/chainrails-sdk.umd.js +2 -2
- package/package.json +2 -2
|
@@ -196,7 +196,7 @@ function Ce(t, e = {}) {
|
|
|
196
196
|
}
|
|
197
197
|
const Te = /* @__PURE__ */ new TextEncoder();
|
|
198
198
|
function De(t, e = {}) {
|
|
199
|
-
return typeof t == "number" || typeof t == "bigint" ?
|
|
199
|
+
return typeof t == "number" || typeof t == "bigint" ? Ne(t, e) : typeof t == "boolean" ? xe(t, e) : j(t) ? ae(t, e) : ce(t, e);
|
|
200
200
|
}
|
|
201
201
|
function xe(t, e = {}) {
|
|
202
202
|
const s = new Uint8Array(1);
|
|
@@ -232,7 +232,7 @@ function ae(t, e = {}) {
|
|
|
232
232
|
}
|
|
233
233
|
return r;
|
|
234
234
|
}
|
|
235
|
-
function
|
|
235
|
+
function Ne(t, e) {
|
|
236
236
|
const s = Ce(t, e);
|
|
237
237
|
return ae(s);
|
|
238
238
|
}
|
|
@@ -241,14 +241,14 @@ function ce(t, e = {}) {
|
|
|
241
241
|
return typeof e.size == "number" ? (O(s, { size: e.size }), E(s, { dir: "right", size: e.size })) : s;
|
|
242
242
|
}
|
|
243
243
|
const b = /* @__PURE__ */ BigInt(2 ** 32 - 1), _ = /* @__PURE__ */ BigInt(32);
|
|
244
|
-
function
|
|
244
|
+
function Re(t, e = !1) {
|
|
245
245
|
return e ? { h: Number(t & b), l: Number(t >> _ & b) } : { h: Number(t >> _ & b) | 0, l: Number(t & b) | 0 };
|
|
246
246
|
}
|
|
247
|
-
function
|
|
247
|
+
function ke(t, e = !1) {
|
|
248
248
|
const s = t.length;
|
|
249
249
|
let n = new Uint32Array(s), i = new Uint32Array(s);
|
|
250
250
|
for (let r = 0; r < s; r++) {
|
|
251
|
-
const { h: o, l: a } =
|
|
251
|
+
const { h: o, l: a } = Re(t[r], e);
|
|
252
252
|
[n[r], i[r]] = [o, a];
|
|
253
253
|
}
|
|
254
254
|
return [n, i];
|
|
@@ -319,7 +319,7 @@ for (let t = 0, e = y, s = 1, n = 0; t < 24; t++) {
|
|
|
319
319
|
e = (e << y ^ (e >> Ge) * We) % Qe, e & Xe && (i ^= y << (y << /* @__PURE__ */ BigInt(r)) - y);
|
|
320
320
|
pe.push(i);
|
|
321
321
|
}
|
|
322
|
-
const ge =
|
|
322
|
+
const ge = ke(pe, !0), Je = ge[0], Ye = ge[1], V = (t, e, s) => s > 32 ? $e(t, e, s) : Be(t, e, s), X = (t, e, s) => s > 32 ? Me(t, e, s) : ze(t, e, s);
|
|
323
323
|
function Ze(t, e = 24) {
|
|
324
324
|
const s = new Uint32Array(10);
|
|
325
325
|
for (let n = 24 - e; n < 24; n++) {
|
|
@@ -509,7 +509,7 @@ const v = {
|
|
|
509
509
|
decimals: 6,
|
|
510
510
|
logoURI: "https://pay.daimo.com/coin-logos/usdc.png",
|
|
511
511
|
logoSourceURI: "https://pay.daimo.com/coin-logos/usdc.png"
|
|
512
|
-
},
|
|
512
|
+
}, N = {
|
|
513
513
|
chainId: W.chainId,
|
|
514
514
|
address: p("0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"),
|
|
515
515
|
symbol: "USDC",
|
|
@@ -517,14 +517,14 @@ const v = {
|
|
|
517
517
|
decimals: 6,
|
|
518
518
|
logoURI: "https://pay.daimo.com/coin-logos/usdc.png",
|
|
519
519
|
logoSourceURI: "https://pay.daimo.com/coin-logos/usdc.png"
|
|
520
|
-
},
|
|
520
|
+
}, R = {
|
|
521
521
|
chainId: Y.chainId,
|
|
522
522
|
address: p("0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"),
|
|
523
523
|
symbol: "USDC",
|
|
524
524
|
decimals: 18,
|
|
525
525
|
logoURI: "https://pay.daimo.com/coin-logos/usdc.png",
|
|
526
526
|
logoSourceURI: "https://pay.daimo.com/coin-logos/usdc.png"
|
|
527
|
-
},
|
|
527
|
+
}, k = {
|
|
528
528
|
chainId: ee.chainId,
|
|
529
529
|
address: p("0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238"),
|
|
530
530
|
symbol: "USDC",
|
|
@@ -551,10 +551,10 @@ const v = {
|
|
|
551
551
|
[T.chainId]: T,
|
|
552
552
|
[D.chainId]: D,
|
|
553
553
|
[x.chainId]: x,
|
|
554
|
-
[R.chainId]: R,
|
|
555
554
|
[N.chainId]: N,
|
|
555
|
+
[k.chainId]: k,
|
|
556
556
|
[B.chainId]: B,
|
|
557
|
-
[
|
|
557
|
+
[R.chainId]: R
|
|
558
558
|
}, z = {
|
|
559
559
|
ARBITRUM_MAINNET: {
|
|
560
560
|
...G,
|
|
@@ -587,7 +587,7 @@ const v = {
|
|
|
587
587
|
BASE_MAINNET: {
|
|
588
588
|
...W,
|
|
589
589
|
tokens: {
|
|
590
|
-
[h.USDC]:
|
|
590
|
+
[h.USDC]: N
|
|
591
591
|
},
|
|
592
592
|
explorer: "https://basescan.org"
|
|
593
593
|
},
|
|
@@ -601,7 +601,7 @@ const v = {
|
|
|
601
601
|
BSC_MAINNET: {
|
|
602
602
|
...Y,
|
|
603
603
|
tokens: {
|
|
604
|
-
[h.USDC]:
|
|
604
|
+
[h.USDC]: R
|
|
605
605
|
},
|
|
606
606
|
explorer: "https://bscscan.com"
|
|
607
607
|
},
|
|
@@ -615,7 +615,7 @@ const v = {
|
|
|
615
615
|
ETHEREUM_TESTNET: {
|
|
616
616
|
...ee,
|
|
617
617
|
tokens: {
|
|
618
|
-
[h.USDC]:
|
|
618
|
+
[h.USDC]: k
|
|
619
619
|
},
|
|
620
620
|
explorer: "https://sepolia.etherscan.io"
|
|
621
621
|
},
|
|
@@ -684,8 +684,8 @@ class u {
|
|
|
684
684
|
static getPayModalUrl(e) {
|
|
685
685
|
if (!u.app)
|
|
686
686
|
throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
|
|
687
|
-
const s = u.app.env === "internal" ? "https://chainrails-frontend-git-staging-horus-labs.vercel.app" : "https://app.chainrails.io", n = e && e > 0 ? "/pay/" : "/deposit/",
|
|
688
|
-
return s +
|
|
687
|
+
const s = u.app.env === "internal" ? "https://chainrails-frontend-git-staging-horus-labs.vercel.app" : "https://app.chainrails.io", n = Number(e), i = e && !isNaN(Number(e)) && n > 0 ? "/pay/" : "/deposit/", r = `${e && !isNaN(Number(e)) && n > 0 ? n * 100 : ""}`;
|
|
688
|
+
return s + i + r;
|
|
689
689
|
}
|
|
690
690
|
}
|
|
691
691
|
let M = null;
|
|
@@ -196,7 +196,7 @@ function Ce(t, e = {}) {
|
|
|
196
196
|
}
|
|
197
197
|
const Te = /* @__PURE__ */ new TextEncoder();
|
|
198
198
|
function De(t, e = {}) {
|
|
199
|
-
return typeof t == "number" || typeof t == "bigint" ?
|
|
199
|
+
return typeof t == "number" || typeof t == "bigint" ? Ne(t, e) : typeof t == "boolean" ? xe(t, e) : j(t) ? ae(t, e) : ce(t, e);
|
|
200
200
|
}
|
|
201
201
|
function xe(t, e = {}) {
|
|
202
202
|
const s = new Uint8Array(1);
|
|
@@ -232,7 +232,7 @@ function ae(t, e = {}) {
|
|
|
232
232
|
}
|
|
233
233
|
return r;
|
|
234
234
|
}
|
|
235
|
-
function
|
|
235
|
+
function Ne(t, e) {
|
|
236
236
|
const s = Ce(t, e);
|
|
237
237
|
return ae(s);
|
|
238
238
|
}
|
|
@@ -241,14 +241,14 @@ function ce(t, e = {}) {
|
|
|
241
241
|
return typeof e.size == "number" ? (O(s, { size: e.size }), E(s, { dir: "right", size: e.size })) : s;
|
|
242
242
|
}
|
|
243
243
|
const b = /* @__PURE__ */ BigInt(2 ** 32 - 1), _ = /* @__PURE__ */ BigInt(32);
|
|
244
|
-
function
|
|
244
|
+
function Re(t, e = !1) {
|
|
245
245
|
return e ? { h: Number(t & b), l: Number(t >> _ & b) } : { h: Number(t >> _ & b) | 0, l: Number(t & b) | 0 };
|
|
246
246
|
}
|
|
247
|
-
function
|
|
247
|
+
function ke(t, e = !1) {
|
|
248
248
|
const s = t.length;
|
|
249
249
|
let n = new Uint32Array(s), i = new Uint32Array(s);
|
|
250
250
|
for (let r = 0; r < s; r++) {
|
|
251
|
-
const { h: o, l: a } =
|
|
251
|
+
const { h: o, l: a } = Re(t[r], e);
|
|
252
252
|
[n[r], i[r]] = [o, a];
|
|
253
253
|
}
|
|
254
254
|
return [n, i];
|
|
@@ -319,7 +319,7 @@ for (let t = 0, e = y, s = 1, n = 0; t < 24; t++) {
|
|
|
319
319
|
e = (e << y ^ (e >> Ge) * We) % Qe, e & Xe && (i ^= y << (y << /* @__PURE__ */ BigInt(r)) - y);
|
|
320
320
|
pe.push(i);
|
|
321
321
|
}
|
|
322
|
-
const ge =
|
|
322
|
+
const ge = ke(pe, !0), Je = ge[0], Ye = ge[1], V = (t, e, s) => s > 32 ? $e(t, e, s) : Be(t, e, s), X = (t, e, s) => s > 32 ? Me(t, e, s) : ze(t, e, s);
|
|
323
323
|
function Ze(t, e = 24) {
|
|
324
324
|
const s = new Uint32Array(10);
|
|
325
325
|
for (let n = 24 - e; n < 24; n++) {
|
|
@@ -509,7 +509,7 @@ const v = {
|
|
|
509
509
|
decimals: 6,
|
|
510
510
|
logoURI: "https://pay.daimo.com/coin-logos/usdc.png",
|
|
511
511
|
logoSourceURI: "https://pay.daimo.com/coin-logos/usdc.png"
|
|
512
|
-
},
|
|
512
|
+
}, N = {
|
|
513
513
|
chainId: W.chainId,
|
|
514
514
|
address: p("0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"),
|
|
515
515
|
symbol: "USDC",
|
|
@@ -517,14 +517,14 @@ const v = {
|
|
|
517
517
|
decimals: 6,
|
|
518
518
|
logoURI: "https://pay.daimo.com/coin-logos/usdc.png",
|
|
519
519
|
logoSourceURI: "https://pay.daimo.com/coin-logos/usdc.png"
|
|
520
|
-
},
|
|
520
|
+
}, R = {
|
|
521
521
|
chainId: Y.chainId,
|
|
522
522
|
address: p("0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"),
|
|
523
523
|
symbol: "USDC",
|
|
524
524
|
decimals: 18,
|
|
525
525
|
logoURI: "https://pay.daimo.com/coin-logos/usdc.png",
|
|
526
526
|
logoSourceURI: "https://pay.daimo.com/coin-logos/usdc.png"
|
|
527
|
-
},
|
|
527
|
+
}, k = {
|
|
528
528
|
chainId: ee.chainId,
|
|
529
529
|
address: p("0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238"),
|
|
530
530
|
symbol: "USDC",
|
|
@@ -551,10 +551,10 @@ const v = {
|
|
|
551
551
|
[T.chainId]: T,
|
|
552
552
|
[D.chainId]: D,
|
|
553
553
|
[x.chainId]: x,
|
|
554
|
-
[R.chainId]: R,
|
|
555
554
|
[N.chainId]: N,
|
|
555
|
+
[k.chainId]: k,
|
|
556
556
|
[B.chainId]: B,
|
|
557
|
-
[
|
|
557
|
+
[R.chainId]: R
|
|
558
558
|
}, z = {
|
|
559
559
|
ARBITRUM_MAINNET: {
|
|
560
560
|
...G,
|
|
@@ -587,7 +587,7 @@ const v = {
|
|
|
587
587
|
BASE_MAINNET: {
|
|
588
588
|
...W,
|
|
589
589
|
tokens: {
|
|
590
|
-
[h.USDC]:
|
|
590
|
+
[h.USDC]: N
|
|
591
591
|
},
|
|
592
592
|
explorer: "https://basescan.org"
|
|
593
593
|
},
|
|
@@ -601,7 +601,7 @@ const v = {
|
|
|
601
601
|
BSC_MAINNET: {
|
|
602
602
|
...Y,
|
|
603
603
|
tokens: {
|
|
604
|
-
[h.USDC]:
|
|
604
|
+
[h.USDC]: R
|
|
605
605
|
},
|
|
606
606
|
explorer: "https://bscscan.com"
|
|
607
607
|
},
|
|
@@ -615,7 +615,7 @@ const v = {
|
|
|
615
615
|
ETHEREUM_TESTNET: {
|
|
616
616
|
...ee,
|
|
617
617
|
tokens: {
|
|
618
|
-
[h.USDC]:
|
|
618
|
+
[h.USDC]: k
|
|
619
619
|
},
|
|
620
620
|
explorer: "https://sepolia.etherscan.io"
|
|
621
621
|
},
|
|
@@ -684,8 +684,8 @@ class u {
|
|
|
684
684
|
static getPayModalUrl(e) {
|
|
685
685
|
if (!u.app)
|
|
686
686
|
throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
|
|
687
|
-
const s = u.app.env === "internal" ? "https://chainrails-frontend-git-staging-horus-labs.vercel.app" : "https://app.chainrails.io", n = e && e > 0 ? "/pay/" : "/deposit/",
|
|
688
|
-
return s +
|
|
687
|
+
const s = u.app.env === "internal" ? "https://chainrails-frontend-git-staging-horus-labs.vercel.app" : "https://app.chainrails.io", n = Number(e), i = e && !isNaN(Number(e)) && n > 0 ? "/pay/" : "/deposit/", r = `${e && !isNaN(Number(e)) && n > 0 ? n * 100 : ""}`;
|
|
688
|
+
return s + i + r;
|
|
689
689
|
}
|
|
690
690
|
}
|
|
691
691
|
let M = null;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(l,
|
|
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=e,this.version=te}walk(e){return se(this,e)}}function se(t,e){return e?.(t)?t:t&&typeof t=="object"&&"cause"in t&&t.cause!==void 0?se(t.cause,e):e?null:t}class ne extends f{constructor({size:e,targetSize:s,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (${e}) exceeds padding size (${s}).`,{name:"SizeExceedsPaddingSizeError"})}}function w(t,{dir:e,size:s=32}={}){return typeof t=="string"?Se(t,{dir:e,size:s}):Ee(t,{dir:e,size:s})}function Se(t,{dir:e,size:s=32}={}){if(s===null)return t;const n=t.replace("0x","");if(n.length>s*2)throw new ne({size:Math.ceil(n.length/2),targetSize:s,type:"hex"});return`0x${n[e==="right"?"padEnd":"padStart"](s*2,"0")}`}function Ee(t,{dir:e,size:s=32}={}){if(s===null)return t;if(t.length>s)throw new ne({size:t.length,targetSize:s,type:"bytes"});const n=new Uint8Array(s);for(let i=0;i<s;i++){const r=e==="right";n[r?i:s-i-1]=t[r?i:t.length-i-1]}return n}class Ae extends f{constructor({max:e,min:s,signed:n,size:i,value:r}){super(`Number "${r}" is not in safe ${i?`${i*8}-bit ${n?"signed":"unsigned"} `:""}integer range ${e?`(${s} to ${e})`:`(above ${s})`}`,{name:"IntegerOutOfRangeError"})}}class Ue extends f{constructor({givenSize:e,maxSize:s}){super(`Size cannot exceed ${s} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function T(t,{size:e}){if(ee(t)>e)throw new Ue({givenSize:ee(t),maxSize:e})}function ve(t,e={}){const{signed:s,size:n}=e,i=BigInt(t);let r;n?s?r=(1n<<BigInt(n)*8n-1n)-1n:r=2n**(BigInt(n)*8n)-1n:typeof t=="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 t=="bigint"?"n":"";throw new Ae({max:r?`${r}${d}`:void 0,min:`${o}${d}`,signed:s,size:n,value:`${t}${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(t,e={}){return typeof t=="number"||typeof t=="bigint"?xe(t,e):typeof t=="boolean"?De(t,e):v(t)?oe(t,e):re(t,e)}function De(t,e={}){const s=new Uint8Array(1);return s[0]=Number(t),typeof e.size=="number"?(T(s,{size:e.size}),w(s,{size:e.size})):s}const p={zero:48,nine:57,A:65,F:70,a:97,f:102};function ie(t){if(t>=p.zero&&t<=p.nine)return t-p.zero;if(t>=p.A&&t<=p.F)return t-(p.A-10);if(t>=p.a&&t<=p.f)return t-(p.a-10)}function oe(t,e={}){let s=t;e.size&&(T(s,{size:e.size}),s=w(s,{dir:"right",size:e.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(t,e){const s=ve(t,e);return oe(s)}function re(t,e={}){const s=Ce.encode(t);return typeof e.size=="number"?(T(s,{size:e.size}),w(s,{dir:"right",size:e.size})):s}const S=BigInt(2**32-1),ae=BigInt(32);function ke(t,e=!1){return e?{h:Number(t&S),l:Number(t>>ae&S)}:{h:Number(t>>ae&S)|0,l:Number(t&S)|0}}function Re(t,e=!1){const s=t.length;let n=new Uint32Array(s),i=new Uint32Array(s);for(let r=0;r<s;r++){const{h:o,l:a}=ke(t[r],e);[n[r],i[r]]=[o,a]}return[n,i]}const Ne=(t,e,s)=>t<<s|e>>>32-s,Be=(t,e,s)=>e<<s|t>>>32-s,ze=(t,e,s)=>e<<s-32|t>>>64-s,$e=(t,e,s)=>t<<s-32|e>>>64-s;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Me(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function ce(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function E(t,...e){if(!Me(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function ue(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function je(t,e){E(t);const s=e.outputLen;if(t.length<s)throw new Error("digestInto() expects output buffer of length at least "+s)}function Oe(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function le(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}const Pe=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Fe(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function Le(t){for(let e=0;e<t.length;e++)t[e]=Fe(t[e]);return t}const he=Pe?t=>t:Le;function _e(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function de(t){return typeof t=="string"&&(t=_e(t)),E(t),t}class He{}function qe(t){const e=n=>t().update(de(n)).digest(),s=t();return e.outputLen=s.outputLen,e.blockLen=s.blockLen,e.create=()=>t(),e}const Ke=BigInt(0),b=BigInt(1),Ve=BigInt(2),Xe=BigInt(7),Ge=BigInt(256),Qe=BigInt(113),pe=[],ge=[],fe=[];for(let t=0,e=b,s=1,n=0;t<24;t++){[s,n]=[n,(2*s+3*n)%5],pe.push(2*(5*n+s)),ge.push((t+1)*(t+2)/2%64);let i=Ke;for(let r=0;r<7;r++)e=(e<<b^(e>>Xe)*Qe)%Ge,e&Ve&&(i^=b<<(b<<BigInt(r))-b);fe.push(i)}const me=Re(fe,!0),We=me[0],Je=me[1],ye=(t,e,s)=>s>32?ze(t,e,s):Ne(t,e,s),Ie=(t,e,s)=>s>32?$e(t,e,s):Be(t,e,s);function Ye(t,e=24){const s=new Uint32Array(10);for(let n=24-e;n<24;n++){for(let o=0;o<10;o++)s[o]=t[o]^t[o+10]^t[o+20]^t[o+30]^t[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)t[o+U]^=It,t[o+U+1]^=bt}let i=t[2],r=t[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=t[y],r=t[y+1],t[y]=d,t[y+1]=m}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)s[a]=t[o+a];for(let a=0;a<10;a++)t[o+a]^=~s[(a+2)%10]&s[(a+4)%10]}t[0]^=We[n],t[1]^=Je[n]}le(s)}class D extends He{constructor(e,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=e,this.suffix=s,this.outputLen=n,this.enableXOF=i,this.rounds=r,ce(n),!(0<e&&e<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(e){ue(this),e=de(e),E(e);const{blockLen:s,state:n}=this,i=e.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++]^=e[r++];this.pos===s&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:s,pos:n,blockLen:i}=this;e[n]^=s,(s&128)!==0&&n===i-1&&this.keccak(),e[i-1]^=128,this.keccak()}writeInto(e){ue(this,!1),E(e),this.finish();const s=this.state,{blockLen:n}=this;for(let i=0,r=e.length;i<r;){this.posOut>=n&&this.keccak();const o=Math.min(n-this.posOut,r-i);e.set(s.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return ce(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(je(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,le(this.state)}_cloneInto(e){const{blockLen:s,suffix:n,outputLen:i,rounds:r,enableXOF:o}=this;return e||(e=new D(s,n,i,o,r)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=r,e.suffix=n,e.outputLen=i,e.enableXOF=o,e.destroyed=this.destroyed,e}}const Ze=(t,e,s)=>qe(()=>new D(e,t,s)),et=Ze(1,136,256/8);function tt(t,e){return et(v(t,{strict:!1})?Te(t):t)}class st extends f{constructor({address:e}){super(`Address "${e}" 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(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const s=super.get(e);return super.has(e)&&s!==void 0&&(this.delete(e),super.set(e,s)),s}set(e,s){if(super.set(e,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(t,e){if(x.has(`${t}.${e}`))return x.get(`${t}.${e}`);const s=t.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(`${t}.${e}`,r),r}function g(t,e){if(!it(t,{strict:!1}))throw new st({address:t});return we(t,e)}const nt=/^0x[a-fA-F0-9]{40}$/,k=new be(8192);function it(t,e){const{strict:s=!0}=e??{},n=`${t}.${s}`;if(k.has(n))return k.get(n);const i=nt.test(t)?t.toLowerCase()===t?!0:s?we(t)===t:!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"},z={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"},$={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,[z.chainId]:z,[$.chainId]:$,[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]:z},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]:$},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=(t=>(t.ARBITRUM="ARBITRUM_MAINNET",t.ARBITRUM_TESTNET="ARBITRUM_TESTNET",t.AVALANCHE="AVALANCHE_MAINNET",t.AVALANCHE_TESTNET="AVALANCHE_TESTNET",t.BASE="BASE_MAINNET",t.BASE_TESTNET="BASE_TESTNET",t.BSC="BSC_MAINNET",t.ETHEREUM="ETHEREUM_MAINNET",t.ETHEREUM_TESTNET="ETHEREUM_TESTNET",t.STARKNET="STARKNET_MAINNET",t))(A||{}),L=(t=>(t.USDC="USDC",t))(L||{});function at(t){return rt[F[t||""].chainId]?.decimals||6}const ct=t=>{const e=t?.trim().toUpperCase();if(F[e])return F[e]};function ut(t,e){return ct(t)?.tokens[e]?.address}var _=(t=>(t.PRODUCTION="production",t.STAGING="staging",t))(_||{});class c{constructor({api_key:e,env:s,seesion_token:n}){this.api_key=e||"",this.sessionToken=n||"",this.env=s??_.PRODUCTION}static async config(e){if(!c.app){if(!e)throw new Error("Please provide an api_key");c.app=new c(e)}return e&&(e.api_key!==void 0&&(c.app.api_key=e.api_key),e.seesion_token!==void 0&&(c.app.sessionToken=e.seesion_token),e.env!==void 0&&(c.app.env=e.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(e){if(!c.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");const s=c.app.env==="internal"?"https://chainrails-frontend-git-staging-horus-labs.vercel.app":"https://app.chainrails.io",n=e&&e>0?"/pay/":"/deposit/",i=`${e?e*100:""}`;return s+n+i}}let H=null;function lt(){H=I.create({prefixUrl:c.getBaseUrl(),headers:{"Content-Type":"application/json"},hooks:{beforeRequest:[t=>{const e=c.getSessionToken()||c.getApiKey();t.headers.set("Authorization",`Bearer ${e}`)}],afterResponse:[(t,e,s)=>s]},retry:{limit:2}})}function u(){return H||lt(),H}class ht{async getById(e){return await u().get("intents/"+e).json()}async getForSender(e){return await u().get("intents/user/"+e).json()}async getForAddress(e){return await u().get("intents/address/"+e).json()}async getForSession(e){return await u().get("modal/sessions/intents/"+e).json()}async getAll(e){return await u().get("intents",{searchParams:e}).json()}async create(e){return await u().post("intents",{json:e}).json()}async createForSession(e){return await u().post("modal/sessions/intents",{json:e}).json()}async update(e,s){return await u().post("intents",{json:s}).json()}async triggerProcessing(e){return await u().post(`intents/${e}/trigger-processing`).json()}async triggerProcessingForSession(e){return await u().post(`modal/sessions/intents/${e}/process`).json()}}class dt{async getFromSpecificBridge(e){return await u().get("quotes/single",{searchParams:e}).json()}async getFromAllBridges(e){return await u().get("quotes/multiple",{searchParams:e}).json()}async getBestAcrossBridges(e){return await u().get("quotes/best",{searchParams:e}).json()}async getAll(e){return await u().get("quotes/multi-source",{searchParams:e}).json()}async getAllForSession(e){return await u().get("modal/sessions/quotes",{searchParams:e}).json()}}class pt{async getOptimalRoutes(e){return await u().get("router/optimal-route",{searchParams:e}).json()}async getAllSupportedBridges(){return await u().get("router/supported-bridges/all").json()}async getSupportedBridges(e){return await u().get("router/supported-bridges/route",{searchParams:e}).json()}async getSupportedRoutes(e,s){return await u().get("router/supported-bridges/bridge/"+e,{searchParams:s}).json()}}class gt{async getSupported(e){return await u().get("chains",{searchParams:e}).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(e){const s={recipient:e.recipient,tokenOut:ut(A[e.destinationChain],L[e.token]),destinationChain:A[e.destinationChain],amount:e.amount};return u().post("modal/sessions",{json:s}).json().then(n=>({...n,amount:s.amount}))}}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.getTokenDecimals=at,l.tokens=L,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(l,b){typeof exports=="object"&&typeof module<"u"?b(exports,require("ky")):typeof define=="function"&&define.amd?define(["exports","ky"],b):(l=typeof globalThis<"u"?globalThis:l||self,b(l.Chainrails={},l.Ky))})(this,(function(l,b){"use strict";var h=(t=>(t.USDC="USDC",t))(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(t,{strict:e=!0}={}){return!t||typeof t!="string"?!1:e?/^0x[0-9a-fA-F]*$/.test(t):t.startsWith("0x")}function ee(t){return v(t,{strict:!1})?Math.ceil((t.length-2)/2):t.length}const te="2.43.4";let C={getDocsUrl:({docsBaseUrl:t,docsPath:e="",docsSlug:s})=>e?`${t??"https://viem.sh"}${e}${s?`#${s}`:""}`:void 0,version:`viem@${te}`};class f extends Error{constructor(e,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=[e||"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=e,this.version=te}walk(e){return se(this,e)}}function se(t,e){return e?.(t)?t:t&&typeof t=="object"&&"cause"in t&&t.cause!==void 0?se(t.cause,e):e?null:t}class ne extends f{constructor({size:e,targetSize:s,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (${e}) exceeds padding size (${s}).`,{name:"SizeExceedsPaddingSizeError"})}}function w(t,{dir:e,size:s=32}={}){return typeof t=="string"?Se(t,{dir:e,size:s}):Ee(t,{dir:e,size:s})}function Se(t,{dir:e,size:s=32}={}){if(s===null)return t;const n=t.replace("0x","");if(n.length>s*2)throw new ne({size:Math.ceil(n.length/2),targetSize:s,type:"hex"});return`0x${n[e==="right"?"padEnd":"padStart"](s*2,"0")}`}function Ee(t,{dir:e,size:s=32}={}){if(s===null)return t;if(t.length>s)throw new ne({size:t.length,targetSize:s,type:"bytes"});const n=new Uint8Array(s);for(let i=0;i<s;i++){const r=e==="right";n[r?i:s-i-1]=t[r?i:t.length-i-1]}return n}class Ae extends f{constructor({max:e,min:s,signed:n,size:i,value:r}){super(`Number "${r}" is not in safe ${i?`${i*8}-bit ${n?"signed":"unsigned"} `:""}integer range ${e?`(${s} to ${e})`:`(above ${s})`}`,{name:"IntegerOutOfRangeError"})}}class Ue extends f{constructor({givenSize:e,maxSize:s}){super(`Size cannot exceed ${s} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function T(t,{size:e}){if(ee(t)>e)throw new Ue({givenSize:ee(t),maxSize:e})}function ve(t,e={}){const{signed:s,size:n}=e,i=BigInt(t);let r;n?s?r=(1n<<BigInt(n)*8n-1n)-1n:r=2n**(BigInt(n)*8n)-1n:typeof t=="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 t=="bigint"?"n":"";throw new Ae({max:r?`${r}${d}`:void 0,min:`${o}${d}`,signed:s,size:n,value:`${t}${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(t,e={}){return typeof t=="number"||typeof t=="bigint"?Ne(t,e):typeof t=="boolean"?De(t,e):v(t)?oe(t,e):re(t,e)}function De(t,e={}){const s=new Uint8Array(1);return s[0]=Number(t),typeof e.size=="number"?(T(s,{size:e.size}),w(s,{size:e.size})):s}const p={zero:48,nine:57,A:65,F:70,a:97,f:102};function ie(t){if(t>=p.zero&&t<=p.nine)return t-p.zero;if(t>=p.A&&t<=p.F)return t-(p.A-10);if(t>=p.a&&t<=p.f)return t-(p.a-10)}function oe(t,e={}){let s=t;e.size&&(T(s,{size:e.size}),s=w(s,{dir:"right",size:e.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 Ne(t,e){const s=ve(t,e);return oe(s)}function re(t,e={}){const s=Ce.encode(t);return typeof e.size=="number"?(T(s,{size:e.size}),w(s,{dir:"right",size:e.size})):s}const S=BigInt(2**32-1),ae=BigInt(32);function xe(t,e=!1){return e?{h:Number(t&S),l:Number(t>>ae&S)}:{h:Number(t>>ae&S)|0,l:Number(t&S)|0}}function ke(t,e=!1){const s=t.length;let n=new Uint32Array(s),i=new Uint32Array(s);for(let r=0;r<s;r++){const{h:o,l:a}=xe(t[r],e);[n[r],i[r]]=[o,a]}return[n,i]}const Re=(t,e,s)=>t<<s|e>>>32-s,Be=(t,e,s)=>e<<s|t>>>32-s,ze=(t,e,s)=>e<<s-32|t>>>64-s,$e=(t,e,s)=>t<<s-32|e>>>64-s;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Me(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function ce(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function E(t,...e){if(!Me(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function ue(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function je(t,e){E(t);const s=e.outputLen;if(t.length<s)throw new Error("digestInto() expects output buffer of length at least "+s)}function Oe(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function le(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}const Pe=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Fe(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function Le(t){for(let e=0;e<t.length;e++)t[e]=Fe(t[e]);return t}const he=Pe?t=>t:Le;function _e(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function de(t){return typeof t=="string"&&(t=_e(t)),E(t),t}class He{}function qe(t){const e=n=>t().update(de(n)).digest(),s=t();return e.outputLen=s.outputLen,e.blockLen=s.blockLen,e.create=()=>t(),e}const Ke=BigInt(0),I=BigInt(1),Ve=BigInt(2),Xe=BigInt(7),Ge=BigInt(256),Qe=BigInt(113),pe=[],ge=[],fe=[];for(let t=0,e=I,s=1,n=0;t<24;t++){[s,n]=[n,(2*s+3*n)%5],pe.push(2*(5*n+s)),ge.push((t+1)*(t+2)/2%64);let i=Ke;for(let r=0;r<7;r++)e=(e<<I^(e>>Xe)*Qe)%Ge,e&Ve&&(i^=I<<(I<<BigInt(r))-I);fe.push(i)}const me=ke(fe,!0),We=me[0],Je=me[1],ye=(t,e,s)=>s>32?ze(t,e,s):Re(t,e,s),be=(t,e,s)=>s>32?$e(t,e,s):Be(t,e,s);function Ye(t,e=24){const s=new Uint32Array(10);for(let n=24-e;n<24;n++){for(let o=0;o<10;o++)s[o]=t[o]^t[o+10]^t[o+20]^t[o+30]^t[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],bt=ye(m,y,1)^s[a],It=be(m,y,1)^s[a+1];for(let U=0;U<50;U+=10)t[o+U]^=bt,t[o+U+1]^=It}let i=t[2],r=t[3];for(let o=0;o<24;o++){const a=ge[o],d=ye(i,r,a),m=be(i,r,a),y=pe[o];i=t[y],r=t[y+1],t[y]=d,t[y+1]=m}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)s[a]=t[o+a];for(let a=0;a<10;a++)t[o+a]^=~s[(a+2)%10]&s[(a+4)%10]}t[0]^=We[n],t[1]^=Je[n]}le(s)}class D extends He{constructor(e,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=e,this.suffix=s,this.outputLen=n,this.enableXOF=i,this.rounds=r,ce(n),!(0<e&&e<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(e){ue(this),e=de(e),E(e);const{blockLen:s,state:n}=this,i=e.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++]^=e[r++];this.pos===s&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:s,pos:n,blockLen:i}=this;e[n]^=s,(s&128)!==0&&n===i-1&&this.keccak(),e[i-1]^=128,this.keccak()}writeInto(e){ue(this,!1),E(e),this.finish();const s=this.state,{blockLen:n}=this;for(let i=0,r=e.length;i<r;){this.posOut>=n&&this.keccak();const o=Math.min(n-this.posOut,r-i);e.set(s.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return ce(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(je(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,le(this.state)}_cloneInto(e){const{blockLen:s,suffix:n,outputLen:i,rounds:r,enableXOF:o}=this;return e||(e=new D(s,n,i,o,r)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=r,e.suffix=n,e.outputLen=i,e.enableXOF=o,e.destroyed=this.destroyed,e}}const Ze=(t,e,s)=>qe(()=>new D(e,t,s)),et=Ze(1,136,256/8);function tt(t,e){return et(v(t,{strict:!1})?Te(t):t)}class st extends f{constructor({address:e}){super(`Address "${e}" is invalid.`,{metaMessages:["- Address must be a hex value of 20 bytes (40 hex characters).","- Address must match its checksum counterpart."],name:"InvalidAddressError"})}}class Ie extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const s=super.get(e);return super.has(e)&&s!==void 0&&(this.delete(e),super.set(e,s)),s}set(e,s){if(super.set(e,s),this.maxSize&&this.size>this.maxSize){const n=this.keys().next().value;n&&this.delete(n)}return this}}const N=new Ie(8192);function we(t,e){if(N.has(`${t}.${e}`))return N.get(`${t}.${e}`);const s=t.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 N.set(`${t}.${e}`,r),r}function g(t,e){if(!it(t,{strict:!1}))throw new st({address:t});return we(t,e)}const nt=/^0x[a-fA-F0-9]{40}$/,x=new Ie(8192);function it(t,e){const{strict:s=!0}=e??{},n=`${t}.${s}`;if(x.has(n))return x.get(n);const i=nt.test(t)?t.toLowerCase()===t?!0:s?we(t)===t:!0:!1;return x.set(n,i),i}const k={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"},R={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"},z={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"},$={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={[k.chainId]:k,[R.chainId]:R,[B.chainId]:B,[z.chainId]:z,[$.chainId]:$,[M.chainId]:M,[O.chainId]:O,[P.chainId]:P,[j.chainId]:j},F={ARBITRUM_MAINNET:{...q,tokens:{[h.USDC]:R},explorer:"https://arbiscan.io"},ARBITRUM_TESTNET:{...K,explorer:"https://sepolia.arbiscan.io",tokens:{[h.USDC]:k}},AVALANCHE_MAINNET:{...J,tokens:{[h.USDC]:z},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]:$},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=(t=>(t.ARBITRUM="ARBITRUM_MAINNET",t.ARBITRUM_TESTNET="ARBITRUM_TESTNET",t.AVALANCHE="AVALANCHE_MAINNET",t.AVALANCHE_TESTNET="AVALANCHE_TESTNET",t.BASE="BASE_MAINNET",t.BASE_TESTNET="BASE_TESTNET",t.BSC="BSC_MAINNET",t.ETHEREUM="ETHEREUM_MAINNET",t.ETHEREUM_TESTNET="ETHEREUM_TESTNET",t.STARKNET="STARKNET_MAINNET",t))(A||{}),L=(t=>(t.USDC="USDC",t))(L||{});function at(t){return rt[F[t||""].chainId]?.decimals||6}const ct=t=>{const e=t?.trim().toUpperCase();if(F[e])return F[e]};function ut(t,e){return ct(t)?.tokens[e]?.address}var _=(t=>(t.PRODUCTION="production",t.STAGING="staging",t))(_||{});class c{constructor({api_key:e,env:s,seesion_token:n}){this.api_key=e||"",this.sessionToken=n||"",this.env=s??_.PRODUCTION}static async config(e){if(!c.app){if(!e)throw new Error("Please provide an api_key");c.app=new c(e)}return e&&(e.api_key!==void 0&&(c.app.api_key=e.api_key),e.seesion_token!==void 0&&(c.app.sessionToken=e.seesion_token),e.env!==void 0&&(c.app.env=e.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(e){if(!c.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");const s=c.app.env==="internal"?"https://chainrails-frontend-git-staging-horus-labs.vercel.app":"https://app.chainrails.io",n=Number(e),i=e&&!isNaN(Number(e))&&n>0?"/pay/":"/deposit/",r=`${e&&!isNaN(Number(e))&&n>0?n*100:""}`;return s+i+r}}let H=null;function lt(){H=b.create({prefixUrl:c.getBaseUrl(),headers:{"Content-Type":"application/json"},hooks:{beforeRequest:[t=>{const e=c.getSessionToken()||c.getApiKey();t.headers.set("Authorization",`Bearer ${e}`)}],afterResponse:[(t,e,s)=>s]},retry:{limit:2}})}function u(){return H||lt(),H}class ht{async getById(e){return await u().get("intents/"+e).json()}async getForSender(e){return await u().get("intents/user/"+e).json()}async getForAddress(e){return await u().get("intents/address/"+e).json()}async getForSession(e){return await u().get("modal/sessions/intents/"+e).json()}async getAll(e){return await u().get("intents",{searchParams:e}).json()}async create(e){return await u().post("intents",{json:e}).json()}async createForSession(e){return await u().post("modal/sessions/intents",{json:e}).json()}async update(e,s){return await u().post("intents",{json:s}).json()}async triggerProcessing(e){return await u().post(`intents/${e}/trigger-processing`).json()}async triggerProcessingForSession(e){return await u().post(`modal/sessions/intents/${e}/process`).json()}}class dt{async getFromSpecificBridge(e){return await u().get("quotes/single",{searchParams:e}).json()}async getFromAllBridges(e){return await u().get("quotes/multiple",{searchParams:e}).json()}async getBestAcrossBridges(e){return await u().get("quotes/best",{searchParams:e}).json()}async getAll(e){return await u().get("quotes/multi-source",{searchParams:e}).json()}async getAllForSession(e){return await u().get("modal/sessions/quotes",{searchParams:e}).json()}}class pt{async getOptimalRoutes(e){return await u().get("router/optimal-route",{searchParams:e}).json()}async getAllSupportedBridges(){return await u().get("router/supported-bridges/all").json()}async getSupportedBridges(e){return await u().get("router/supported-bridges/route",{searchParams:e}).json()}async getSupportedRoutes(e,s){return await u().get("router/supported-bridges/bridge/"+e,{searchParams:s}).json()}}class gt{async getSupported(e){return await u().get("chains",{searchParams:e}).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(e){const s={recipient:e.recipient,tokenOut:ut(A[e.destinationChain],L[e.token]),destinationChain:A[e.destinationChain],amount:e.amount};return u().post("modal/sessions",{json:s}).json().then(n=>({...n,amount:s.amount}))}}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.getTokenDecimals=at,l.tokens=L,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chainrails/sdk",
|
|
3
3
|
"sideEffects": false,
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.2",
|
|
5
5
|
"main": "./dist/chainrails-sdk.umd.js",
|
|
6
6
|
"module": "./dist/chainrails-sdk.es.mjs",
|
|
7
7
|
"license": "MIT",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@chainrails/common": "^0.2.
|
|
38
|
+
"@chainrails/common": "^0.2.2",
|
|
39
39
|
"ky": "^1.14.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|