@chainrails/sdk 0.0.43 → 0.0.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import pe from "ky";
1
+ import de from "ky";
2
2
  var h = /* @__PURE__ */ ((e) => (e.USDC = "USDC", e))(h || {});
3
3
  const P = {
4
4
  type: "evm",
@@ -129,9 +129,9 @@ class J extends g {
129
129
  }
130
130
  }
131
131
  function E(e, { dir: t, size: s = 32 } = {}) {
132
- return typeof e == "string" ? de(e, { dir: t, size: s }) : ge(e, { dir: t, size: s });
132
+ return typeof e == "string" ? pe(e, { dir: t, size: s }) : ge(e, { dir: t, size: s });
133
133
  }
134
- function de(e, { dir: t, size: s = 32 } = {}) {
134
+ function pe(e, { dir: t, size: s = 32 } = {}) {
135
135
  if (s === null)
136
136
  return e;
137
137
  const n = e.replace("0x", "");
@@ -202,7 +202,7 @@ function we(e, t = {}) {
202
202
  const s = new Uint8Array(1);
203
203
  return s[0] = Number(e), typeof t.size == "number" ? (x(s, { size: t.size }), E(s, { size: t.size })) : s;
204
204
  }
205
- const p = {
205
+ const d = {
206
206
  zero: 48,
207
207
  nine: 57,
208
208
  A: 65,
@@ -211,12 +211,12 @@ const p = {
211
211
  f: 102
212
212
  };
213
213
  function k(e) {
214
- if (e >= p.zero && e <= p.nine)
215
- return e - p.zero;
216
- if (e >= p.A && e <= p.F)
217
- return e - (p.A - 10);
218
- if (e >= p.a && e <= p.f)
219
- return e - (p.a - 10);
214
+ if (e >= d.zero && e <= d.nine)
215
+ return e - d.zero;
216
+ if (e >= d.A && e <= d.F)
217
+ return e - (d.A - 10);
218
+ if (e >= d.a && e <= d.f)
219
+ return e - (d.a - 10);
220
220
  }
221
221
  function Y(e, t = {}) {
222
222
  let s = e;
@@ -456,7 +456,7 @@ function ae(e, t) {
456
456
  const r = `0x${i.join("")}`;
457
457
  return A.set(`${e}.${t}`, r), r;
458
458
  }
459
- function d(e, t) {
459
+ function p(e, t) {
460
460
  if (!We(e, { strict: !1 }))
461
461
  throw new Ge({ address: e });
462
462
  return ae(e, t);
@@ -471,7 +471,7 @@ function We(e, t) {
471
471
  }
472
472
  const Je = {
473
473
  chainId: F.chainId,
474
- address: d("0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d"),
474
+ address: p("0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d"),
475
475
  symbol: "USDC",
476
476
  fiatISO: "USD",
477
477
  decimals: 6,
@@ -479,7 +479,7 @@ const Je = {
479
479
  logoSourceURI: "https://pay.daimo.com/coin-logos/usdc.png"
480
480
  }, Ye = {
481
481
  chainId: P.chainId,
482
- address: d("0xaf88d065e77c8cC2239327C5EDb3A432268e5831"),
482
+ address: p("0xaf88d065e77c8cC2239327C5EDb3A432268e5831"),
483
483
  symbol: "USDC",
484
484
  name: "USD Coin",
485
485
  decimals: 6,
@@ -487,7 +487,7 @@ const Je = {
487
487
  /* USDC */
488
488
  }, Ze = {
489
489
  chainId: X.chainId,
490
- address: d("0x5425890298aed601595a70ab815c96711a31bc65"),
490
+ address: p("0x5425890298aed601595a70ab815c96711a31bc65"),
491
491
  symbol: "USDC",
492
492
  fiatISO: "USD",
493
493
  decimals: 6,
@@ -495,7 +495,7 @@ const Je = {
495
495
  logoSourceURI: "https://pay.daimo.com/coin-logos/usdc.png"
496
496
  }, et = {
497
497
  chainId: V.chainId,
498
- address: d("0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E"),
498
+ address: p("0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E"),
499
499
  symbol: "USDC",
500
500
  fiatISO: "USD",
501
501
  decimals: 6,
@@ -503,7 +503,7 @@ const Je = {
503
503
  logoSourceURI: "https://pay.daimo.com/coin-logos/usdc.png"
504
504
  }, tt = {
505
505
  chainId: L.chainId,
506
- address: d("0x036CbD53842c5426634e7929541eC2318f3dCF7e"),
506
+ address: p("0x036CbD53842c5426634e7929541eC2318f3dCF7e"),
507
507
  symbol: "USDC",
508
508
  fiatISO: "USD",
509
509
  decimals: 6,
@@ -511,7 +511,7 @@ const Je = {
511
511
  logoSourceURI: "https://pay.daimo.com/coin-logos/usdc.png"
512
512
  }, st = {
513
513
  chainId: _.chainId,
514
- address: d("0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"),
514
+ address: p("0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"),
515
515
  symbol: "USDC",
516
516
  fiatISO: "USD",
517
517
  decimals: 6,
@@ -519,21 +519,21 @@ const Je = {
519
519
  logoSourceURI: "https://pay.daimo.com/coin-logos/usdc.png"
520
520
  }, nt = {
521
521
  chainId: H.chainId,
522
- address: d("0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"),
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
  }, it = {
528
528
  chainId: K.chainId,
529
- address: d("0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238"),
529
+ address: p("0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238"),
530
530
  symbol: "USDC",
531
531
  decimals: 6,
532
532
  logoURI: "https://pay.daimo.com/coin-logos/usdc.png",
533
533
  logoSourceURI: "https://pay.daimo.com/coin-logos/usdc.png"
534
534
  }, ot = {
535
535
  chainId: q.chainId,
536
- address: d("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"),
536
+ address: p("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"),
537
537
  symbol: "USDC",
538
538
  decimals: 6,
539
539
  logoURI: "https://pay.daimo.com/coin-logos/usdc.png",
@@ -677,7 +677,7 @@ class c {
677
677
  }
678
678
  let C = null;
679
679
  function ut() {
680
- C = pe.create({
680
+ C = de.create({
681
681
  prefixUrl: c.getBaseUrl(),
682
682
  headers: {
683
683
  "Content-Type": "application/json"
@@ -748,7 +748,7 @@ class ht {
748
748
  return await u().get("modal/sessions/quotes", { searchParams: t }).json();
749
749
  }
750
750
  }
751
- class pt {
751
+ class dt {
752
752
  async getOptimalRoutes(t) {
753
753
  return await u().get("router/optimal-route", { searchParams: t }).json();
754
754
  }
@@ -762,7 +762,7 @@ class pt {
762
762
  return await u().get("router/supported-bridges/bridge/" + t, { searchParams: s }).json();
763
763
  }
764
764
  }
765
- class dt {
765
+ class pt {
766
766
  async getSupported(t) {
767
767
  return await u().get("chains", { searchParams: t }).json();
768
768
  }
@@ -787,10 +787,10 @@ class ft {
787
787
  }
788
788
  }
789
789
  const yt = {
790
- router: new pt(),
790
+ router: new dt(),
791
791
  quotes: new ht(),
792
792
  intents: new lt(),
793
- chains: new dt(),
793
+ chains: new pt(),
794
794
  client: new gt(),
795
795
  auth: new ft()
796
796
  };
@@ -1,4 +1,4 @@
1
- import pe from "ky";
1
+ import de from "ky";
2
2
  var h = /* @__PURE__ */ ((e) => (e.USDC = "USDC", e))(h || {});
3
3
  const P = {
4
4
  type: "evm",
@@ -129,9 +129,9 @@ class J extends g {
129
129
  }
130
130
  }
131
131
  function E(e, { dir: t, size: s = 32 } = {}) {
132
- return typeof e == "string" ? de(e, { dir: t, size: s }) : ge(e, { dir: t, size: s });
132
+ return typeof e == "string" ? pe(e, { dir: t, size: s }) : ge(e, { dir: t, size: s });
133
133
  }
134
- function de(e, { dir: t, size: s = 32 } = {}) {
134
+ function pe(e, { dir: t, size: s = 32 } = {}) {
135
135
  if (s === null)
136
136
  return e;
137
137
  const n = e.replace("0x", "");
@@ -202,7 +202,7 @@ function we(e, t = {}) {
202
202
  const s = new Uint8Array(1);
203
203
  return s[0] = Number(e), typeof t.size == "number" ? (x(s, { size: t.size }), E(s, { size: t.size })) : s;
204
204
  }
205
- const p = {
205
+ const d = {
206
206
  zero: 48,
207
207
  nine: 57,
208
208
  A: 65,
@@ -211,12 +211,12 @@ const p = {
211
211
  f: 102
212
212
  };
213
213
  function k(e) {
214
- if (e >= p.zero && e <= p.nine)
215
- return e - p.zero;
216
- if (e >= p.A && e <= p.F)
217
- return e - (p.A - 10);
218
- if (e >= p.a && e <= p.f)
219
- return e - (p.a - 10);
214
+ if (e >= d.zero && e <= d.nine)
215
+ return e - d.zero;
216
+ if (e >= d.A && e <= d.F)
217
+ return e - (d.A - 10);
218
+ if (e >= d.a && e <= d.f)
219
+ return e - (d.a - 10);
220
220
  }
221
221
  function Y(e, t = {}) {
222
222
  let s = e;
@@ -456,7 +456,7 @@ function ae(e, t) {
456
456
  const r = `0x${i.join("")}`;
457
457
  return A.set(`${e}.${t}`, r), r;
458
458
  }
459
- function d(e, t) {
459
+ function p(e, t) {
460
460
  if (!We(e, { strict: !1 }))
461
461
  throw new Ge({ address: e });
462
462
  return ae(e, t);
@@ -471,7 +471,7 @@ function We(e, t) {
471
471
  }
472
472
  const Je = {
473
473
  chainId: F.chainId,
474
- address: d("0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d"),
474
+ address: p("0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d"),
475
475
  symbol: "USDC",
476
476
  fiatISO: "USD",
477
477
  decimals: 6,
@@ -479,7 +479,7 @@ const Je = {
479
479
  logoSourceURI: "https://pay.daimo.com/coin-logos/usdc.png"
480
480
  }, Ye = {
481
481
  chainId: P.chainId,
482
- address: d("0xaf88d065e77c8cC2239327C5EDb3A432268e5831"),
482
+ address: p("0xaf88d065e77c8cC2239327C5EDb3A432268e5831"),
483
483
  symbol: "USDC",
484
484
  name: "USD Coin",
485
485
  decimals: 6,
@@ -487,7 +487,7 @@ const Je = {
487
487
  /* USDC */
488
488
  }, Ze = {
489
489
  chainId: X.chainId,
490
- address: d("0x5425890298aed601595a70ab815c96711a31bc65"),
490
+ address: p("0x5425890298aed601595a70ab815c96711a31bc65"),
491
491
  symbol: "USDC",
492
492
  fiatISO: "USD",
493
493
  decimals: 6,
@@ -495,7 +495,7 @@ const Je = {
495
495
  logoSourceURI: "https://pay.daimo.com/coin-logos/usdc.png"
496
496
  }, et = {
497
497
  chainId: V.chainId,
498
- address: d("0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E"),
498
+ address: p("0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E"),
499
499
  symbol: "USDC",
500
500
  fiatISO: "USD",
501
501
  decimals: 6,
@@ -503,7 +503,7 @@ const Je = {
503
503
  logoSourceURI: "https://pay.daimo.com/coin-logos/usdc.png"
504
504
  }, tt = {
505
505
  chainId: L.chainId,
506
- address: d("0x036CbD53842c5426634e7929541eC2318f3dCF7e"),
506
+ address: p("0x036CbD53842c5426634e7929541eC2318f3dCF7e"),
507
507
  symbol: "USDC",
508
508
  fiatISO: "USD",
509
509
  decimals: 6,
@@ -511,7 +511,7 @@ const Je = {
511
511
  logoSourceURI: "https://pay.daimo.com/coin-logos/usdc.png"
512
512
  }, st = {
513
513
  chainId: _.chainId,
514
- address: d("0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"),
514
+ address: p("0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"),
515
515
  symbol: "USDC",
516
516
  fiatISO: "USD",
517
517
  decimals: 6,
@@ -519,21 +519,21 @@ const Je = {
519
519
  logoSourceURI: "https://pay.daimo.com/coin-logos/usdc.png"
520
520
  }, nt = {
521
521
  chainId: H.chainId,
522
- address: d("0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"),
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
  }, it = {
528
528
  chainId: K.chainId,
529
- address: d("0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238"),
529
+ address: p("0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238"),
530
530
  symbol: "USDC",
531
531
  decimals: 6,
532
532
  logoURI: "https://pay.daimo.com/coin-logos/usdc.png",
533
533
  logoSourceURI: "https://pay.daimo.com/coin-logos/usdc.png"
534
534
  }, ot = {
535
535
  chainId: q.chainId,
536
- address: d("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"),
536
+ address: p("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"),
537
537
  symbol: "USDC",
538
538
  decimals: 6,
539
539
  logoURI: "https://pay.daimo.com/coin-logos/usdc.png",
@@ -677,7 +677,7 @@ class c {
677
677
  }
678
678
  let C = null;
679
679
  function ut() {
680
- C = pe.create({
680
+ C = de.create({
681
681
  prefixUrl: c.getBaseUrl(),
682
682
  headers: {
683
683
  "Content-Type": "application/json"
@@ -748,7 +748,7 @@ class ht {
748
748
  return await u().get("modal/sessions/quotes", { searchParams: t }).json();
749
749
  }
750
750
  }
751
- class pt {
751
+ class dt {
752
752
  async getOptimalRoutes(t) {
753
753
  return await u().get("router/optimal-route", { searchParams: t }).json();
754
754
  }
@@ -762,7 +762,7 @@ class pt {
762
762
  return await u().get("router/supported-bridges/bridge/" + t, { searchParams: s }).json();
763
763
  }
764
764
  }
765
- class dt {
765
+ class pt {
766
766
  async getSupported(t) {
767
767
  return await u().get("chains", { searchParams: t }).json();
768
768
  }
@@ -787,10 +787,10 @@ class ft {
787
787
  }
788
788
  }
789
789
  const yt = {
790
- router: new pt(),
790
+ router: new dt(),
791
791
  quotes: new ht(),
792
792
  intents: new lt(),
793
- chains: new dt(),
793
+ chains: new pt(),
794
794
  client: new gt(),
795
795
  auth: new ft()
796
796
  };
@@ -1,2 +1,2 @@
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=(e=>(e.USDC="USDC",e))(h||{});const $={type:"evm",chainId:42161,name:"Arbitrum",cctpDomain:3,logoURI:"/images/chains/arbitrum.svg"},z={type:"evm",chainId:421614,name:"Arbitrum Sepolia",cctpDomain:3,logoURI:"/images/chains/arbitrum.svg"},M={type:"evm",chainId:8453,name:"Base",cctpDomain:6,logoURI:"/images/chains/base.webp"},O={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"},P={type:"evm",chainId:1,name:"Ethereum",cctpDomain:0,logoURI:"/images/chains/ethereum.svg"},F={type:"evm",chainId:11155111,name:"Ethereum Sepolia",cctpDomain:0,logoURI:"/images/chains/ethereum.svg"},_={type:"evm",chainId:43114,name:"Avalanche",cctpDomain:1,logoURI:"/images/chains/avalanche.svg"},L={type:"evm",chainId:43113,name:"Avalanche Fuji",cctpDomain:1,logoURI:"/images/chains/avalanche.svg"},H={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 q(e){return v(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}const K="2.43.4";let C={getDocsUrl:({docsBaseUrl:e,docsPath:t="",docsSlug:s})=>t?`${e??"https://viem.sh"}${t}${s?`#${s}`:""}`:void 0,version:`viem@${K}`};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=K}walk(t){return V(this,t)}}function V(e,t){return t?.(e)?e:e&&typeof e=="object"&&"cause"in e&&e.cause!==void 0?V(e.cause,t):t?null:e}class X 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"?de(e,{dir:t,size:s}):pe(e,{dir:t,size:s})}function de(e,{dir:t,size:s=32}={}){if(s===null)return e;const n=e.replace("0x","");if(n.length>s*2)throw new X({size:Math.ceil(n.length/2),targetSize:s,type:"hex"});return`0x${n[t==="right"?"padEnd":"padStart"](s*2,"0")}`}function pe(e,{dir:t,size:s=32}={}){if(s===null)return e;if(e.length>s)throw new X({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 ge 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 fe 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(q(e)>t)throw new fe({givenSize:q(e),maxSize:t})}function me(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 ge({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 ye=new TextEncoder;function be(e,t={}){return typeof e=="number"||typeof e=="bigint"?we(e,t):typeof e=="boolean"?Ie(e,t):v(e)?Q(e,t):W(e,t)}function Ie(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 G(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 Q(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=G(n.charCodeAt(a++)),m=G(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 we(e,t){const s=me(e,t);return Q(s)}function W(e,t={}){const s=ye.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),J=BigInt(32);function Ee(e,t=!1){return t?{h:Number(e&E),l:Number(e>>J&E)}:{h:Number(e>>J&E)|0,l:Number(e&E)|0}}function Se(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}=Ee(e[r],t);[n[r],i[r]]=[o,a]}return[n,i]}const Ae=(e,t,s)=>e<<s|t>>>32-s,Ue=(e,t,s)=>t<<s|e>>>32-s,ve=(e,t,s)=>t<<s-32|e>>>64-s,Ce=(e,t,s)=>e<<s-32|t>>>64-s;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Te(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Y(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function S(e,...t){if(!Te(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 Z(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 De(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 xe(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function ee(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}const ke=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Re(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function Ne(e){for(let t=0;t<e.length;t++)e[t]=Re(e[t]);return e}const te=ke?e=>e:Ne;function Be(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function se(e){return typeof e=="string"&&(e=Be(e)),S(e),e}class $e{}function ze(e){const t=n=>e().update(se(n)).digest(),s=e();return t.outputLen=s.outputLen,t.blockLen=s.blockLen,t.create=()=>e(),t}const Me=BigInt(0),I=BigInt(1),Oe=BigInt(2),je=BigInt(7),Pe=BigInt(256),Fe=BigInt(113),ne=[],ie=[],oe=[];for(let e=0,t=I,s=1,n=0;e<24;e++){[s,n]=[n,(2*s+3*n)%5],ne.push(2*(5*n+s)),ie.push((e+1)*(e+2)/2%64);let i=Me;for(let r=0;r<7;r++)t=(t<<I^(t>>je)*Fe)%Pe,t&Oe&&(i^=I<<(I<<BigInt(r))-I);oe.push(i)}const re=Se(oe,!0),_e=re[0],Le=re[1],ae=(e,t,s)=>s>32?ve(e,t,s):Ae(e,t,s),ce=(e,t,s)=>s>32?Ce(e,t,s):Ue(e,t,s);function He(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],mt=ae(m,y,1)^s[a],yt=ce(m,y,1)^s[a+1];for(let U=0;U<50;U+=10)e[o+U]^=mt,e[o+U+1]^=yt}let i=e[2],r=e[3];for(let o=0;o<24;o++){const a=ie[o],d=ae(i,r,a),m=ce(i,r,a),y=ne[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]^=_e[n],e[1]^=Le[n]}ee(s)}class D extends $e{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,Y(n),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=xe(this.state)}clone(){return this._cloneInto()}keccak(){te(this.state32),He(this.state32,this.rounds),te(this.state32),this.posOut=0,this.pos=0}update(t){Z(this),t=se(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){Z(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 Y(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(De(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,ee(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 qe=(e,t,s)=>ze(()=>new D(t,e,s)),Ke=qe(1,136,256/8);function Ve(e,t){return Ke(v(e,{strict:!1})?be(e):e)}class Xe 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 ue 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 ue(8192);function le(e,t){if(x.has(`${e}.${t}`))return x.get(`${e}.${t}`);const s=e.substring(2).toLowerCase(),n=Ve(W(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(!Qe(e,{strict:!1}))throw new Xe({address:e});return le(e,t)}const Ge=/^0x[a-fA-F0-9]{40}$/,k=new ue(8192);function Qe(e,t){const{strict:s=!0}=t??{},n=`${e}.${s}`;if(k.has(n))return k.get(n);const i=Ge.test(e)?e.toLowerCase()===e?!0:s?le(e)===e:!0:!1;return k.set(n,i),i}const We={chainId:z.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"},Je={chainId:$.chainId,address:g("0xaf88d065e77c8cC2239327C5EDb3A432268e5831"),symbol:"USDC",name:"USD Coin",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png"},Ye={chainId:L.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"},Ze={chainId:_.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"},et={chainId:O.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"},tt={chainId:M.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"},st={chainId:j.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"},nt={chainId:F.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"},it={chainId:P.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:H.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"},he={ARBITRUM_MAINNET:{...$,tokens:{[h.USDC]:Je},explorer:"https://arbiscan.io"},ARBITRUM_TESTNET:{...z,explorer:"https://sepolia.arbiscan.io",tokens:{[h.USDC]:We}},AVALANCHE_MAINNET:{..._,tokens:{[h.USDC]:Ze},explorer:"https://snowtrace.io"},AVALANCHE_TESTNET:{...L,tokens:{[h.USDC]:Ye},explorer:"https://testnet.snowtrace.io"},BASE_MAINNET:{...M,tokens:{[h.USDC]:tt},explorer:"https://basescan.org"},BASE_TESTNET:{...O,tokens:{[h.USDC]:et},explorer:"https://sepolia.basescan.org"},BSC_MAINNET:{...j,tokens:{[h.USDC]:st},explorer:"https://bscscan.com"},ETHEREUM_MAINNET:{...P,tokens:{[h.USDC]:it},explorer:"https://etherscan.io"},ETHEREUM_TESTNET:{...F,tokens:{[h.USDC]:nt},explorer:"https://sepolia.etherscan.io"},STARKNET_MAINNET:{...H,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||{}),R=(e=>(e.USDC="USDC",e))(R||{});const rt=e=>{const t=e?.trim().toUpperCase();if(he[t])return he[t]};function at(e,t){return rt(e)?.tokens[t]?.address}var N=(e=>(e.PRODUCTION="production",e.STAGING="staging",e))(N||{});class c{constructor({api_key:t,env:s,seesion_token:n}){this.api_key=t||"",this.sessionToken=n||"",this.env=s??N.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 B=null;function ct(){B=b.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 B||ct(),B}class ut{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 lt{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 ht{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 dt{async getSupported(t){return await u().get("chains",{searchParams:t}).json()}}class pt{async getClientInfo(){return await u().get("client/auth/client-info").json()}}class gt{getSessionToken(t){const s={recipient:t.recipient,tokenOut:at(A[t.destinationChain],R[t.token]),destinationChain:A[t.destinationChain],amount:t.amount};return u().post("modal/sessions",{json:s}).json()}}const ft={router:new ht,quotes:new lt,intents:new ut,chains:new dt,client:new pt,auth:new gt};l.Chainrails=c,l.chains=A,l.crapi=ft,l.environment=N,l.tokens=R,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=(e=>(e.USDC="USDC",e))(h||{});const $={type:"evm",chainId:42161,name:"Arbitrum",cctpDomain:3,logoURI:"/images/chains/arbitrum.svg"},z={type:"evm",chainId:421614,name:"Arbitrum Sepolia",cctpDomain:3,logoURI:"/images/chains/arbitrum.svg"},M={type:"evm",chainId:8453,name:"Base",cctpDomain:6,logoURI:"/images/chains/base.webp"},j={type:"evm",chainId:84532,name:"Base Sepolia",cctpDomain:6,logoURI:"/images/chains/base.webp"},O={type:"evm",chainId:56,name:"BNB Chain",cctpDomain:null,logoURI:"/images/chains/bsc.webp"},P={type:"evm",chainId:1,name:"Ethereum",cctpDomain:0,logoURI:"/images/chains/ethereum.svg"},F={type:"evm",chainId:11155111,name:"Ethereum Sepolia",cctpDomain:0,logoURI:"/images/chains/ethereum.svg"},_={type:"evm",chainId:43114,name:"Avalanche",cctpDomain:1,logoURI:"/images/chains/avalanche.svg"},L={type:"evm",chainId:43113,name:"Avalanche Fuji",cctpDomain:1,logoURI:"/images/chains/avalanche.svg"},H={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 q(e){return v(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}const K="2.43.4";let C={getDocsUrl:({docsBaseUrl:e,docsPath:t="",docsSlug:s})=>t?`${e??"https://viem.sh"}${t}${s?`#${s}`:""}`:void 0,version:`viem@${K}`};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=K}walk(t){return V(this,t)}}function V(e,t){return t?.(e)?e:e&&typeof e=="object"&&"cause"in e&&e.cause!==void 0?V(e.cause,t):t?null:e}class X 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"?de(e,{dir:t,size:s}):pe(e,{dir:t,size:s})}function de(e,{dir:t,size:s=32}={}){if(s===null)return e;const n=e.replace("0x","");if(n.length>s*2)throw new X({size:Math.ceil(n.length/2),targetSize:s,type:"hex"});return`0x${n[t==="right"?"padEnd":"padStart"](s*2,"0")}`}function pe(e,{dir:t,size:s=32}={}){if(s===null)return e;if(e.length>s)throw new X({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 ge 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 fe 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(q(e)>t)throw new fe({givenSize:q(e),maxSize:t})}function me(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 ge({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 ye=new TextEncoder;function be(e,t={}){return typeof e=="number"||typeof e=="bigint"?we(e,t):typeof e=="boolean"?Ie(e,t):v(e)?Q(e,t):W(e,t)}function Ie(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 G(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 Q(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=G(n.charCodeAt(a++)),m=G(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 we(e,t){const s=me(e,t);return Q(s)}function W(e,t={}){const s=ye.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),J=BigInt(32);function Ee(e,t=!1){return t?{h:Number(e&E),l:Number(e>>J&E)}:{h:Number(e>>J&E)|0,l:Number(e&E)|0}}function Se(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}=Ee(e[r],t);[n[r],i[r]]=[o,a]}return[n,i]}const Ae=(e,t,s)=>e<<s|t>>>32-s,Ue=(e,t,s)=>t<<s|e>>>32-s,ve=(e,t,s)=>t<<s-32|e>>>64-s,Ce=(e,t,s)=>e<<s-32|t>>>64-s;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Te(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Y(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function S(e,...t){if(!Te(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 Z(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 De(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 xe(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function ee(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}const ke=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Re(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function Ne(e){for(let t=0;t<e.length;t++)e[t]=Re(e[t]);return e}const te=ke?e=>e:Ne;function Be(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function se(e){return typeof e=="string"&&(e=Be(e)),S(e),e}class $e{}function ze(e){const t=n=>e().update(se(n)).digest(),s=e();return t.outputLen=s.outputLen,t.blockLen=s.blockLen,t.create=()=>e(),t}const Me=BigInt(0),I=BigInt(1),je=BigInt(2),Oe=BigInt(7),Pe=BigInt(256),Fe=BigInt(113),ne=[],ie=[],oe=[];for(let e=0,t=I,s=1,n=0;e<24;e++){[s,n]=[n,(2*s+3*n)%5],ne.push(2*(5*n+s)),ie.push((e+1)*(e+2)/2%64);let i=Me;for(let r=0;r<7;r++)t=(t<<I^(t>>Oe)*Fe)%Pe,t&je&&(i^=I<<(I<<BigInt(r))-I);oe.push(i)}const re=Se(oe,!0),_e=re[0],Le=re[1],ae=(e,t,s)=>s>32?ve(e,t,s):Ae(e,t,s),ce=(e,t,s)=>s>32?Ce(e,t,s):Ue(e,t,s);function He(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],mt=ae(m,y,1)^s[a],yt=ce(m,y,1)^s[a+1];for(let U=0;U<50;U+=10)e[o+U]^=mt,e[o+U+1]^=yt}let i=e[2],r=e[3];for(let o=0;o<24;o++){const a=ie[o],d=ae(i,r,a),m=ce(i,r,a),y=ne[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]^=_e[n],e[1]^=Le[n]}ee(s)}class D extends $e{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,Y(n),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=xe(this.state)}clone(){return this._cloneInto()}keccak(){te(this.state32),He(this.state32,this.rounds),te(this.state32),this.posOut=0,this.pos=0}update(t){Z(this),t=se(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){Z(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 Y(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(De(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,ee(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 qe=(e,t,s)=>ze(()=>new D(t,e,s)),Ke=qe(1,136,256/8);function Ve(e,t){return Ke(v(e,{strict:!1})?be(e):e)}class Xe 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 ue 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 ue(8192);function le(e,t){if(x.has(`${e}.${t}`))return x.get(`${e}.${t}`);const s=e.substring(2).toLowerCase(),n=Ve(W(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(!Qe(e,{strict:!1}))throw new Xe({address:e});return le(e,t)}const Ge=/^0x[a-fA-F0-9]{40}$/,k=new ue(8192);function Qe(e,t){const{strict:s=!0}=t??{},n=`${e}.${s}`;if(k.has(n))return k.get(n);const i=Ge.test(e)?e.toLowerCase()===e?!0:s?le(e)===e:!0:!1;return k.set(n,i),i}const We={chainId:z.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"},Je={chainId:$.chainId,address:g("0xaf88d065e77c8cC2239327C5EDb3A432268e5831"),symbol:"USDC",name:"USD Coin",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png"},Ye={chainId:L.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"},Ze={chainId:_.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"},et={chainId:j.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"},tt={chainId:M.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"},st={chainId:O.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"},nt={chainId:F.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"},it={chainId:P.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:H.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"},he={ARBITRUM_MAINNET:{...$,tokens:{[h.USDC]:Je},explorer:"https://arbiscan.io"},ARBITRUM_TESTNET:{...z,explorer:"https://sepolia.arbiscan.io",tokens:{[h.USDC]:We}},AVALANCHE_MAINNET:{..._,tokens:{[h.USDC]:Ze},explorer:"https://snowtrace.io"},AVALANCHE_TESTNET:{...L,tokens:{[h.USDC]:Ye},explorer:"https://testnet.snowtrace.io"},BASE_MAINNET:{...M,tokens:{[h.USDC]:tt},explorer:"https://basescan.org"},BASE_TESTNET:{...j,tokens:{[h.USDC]:et},explorer:"https://sepolia.basescan.org"},BSC_MAINNET:{...O,tokens:{[h.USDC]:st},explorer:"https://bscscan.com"},ETHEREUM_MAINNET:{...P,tokens:{[h.USDC]:it},explorer:"https://etherscan.io"},ETHEREUM_TESTNET:{...F,tokens:{[h.USDC]:nt},explorer:"https://sepolia.etherscan.io"},STARKNET_MAINNET:{...H,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||{}),R=(e=>(e.USDC="USDC",e))(R||{});const rt=e=>{const t=e?.trim().toUpperCase();if(he[t])return he[t]};function at(e,t){return rt(e)?.tokens[t]?.address}var N=(e=>(e.PRODUCTION="production",e.STAGING="staging",e))(N||{});class c{constructor({api_key:t,env:s,seesion_token:n}){this.api_key=t||"",this.sessionToken=n||"",this.env=s??N.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 B=null;function ct(){B=b.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 B||ct(),B}class ut{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 lt{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 ht{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 dt{async getSupported(t){return await u().get("chains",{searchParams:t}).json()}}class pt{async getClientInfo(){return await u().get("client/auth/client-info").json()}}class gt{getSessionToken(t){const s={recipient:t.recipient,tokenOut:at(A[t.destinationChain],R[t.token]),destinationChain:A[t.destinationChain],amount:t.amount};return u().post("modal/sessions",{json:s}).json()}}const ft={router:new ht,quotes:new lt,intents:new ut,chains:new dt,client:new pt,auth:new gt};l.Chainrails=c,l.chains=A,l.crapi=ft,l.environment=N,l.tokens=R,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.0.43",
4
+ "version": "0.0.44",
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.0.25",
38
+ "@chainrails/common": "^0.0.26",
39
39
  "ky": "^1.14.0"
40
40
  },
41
41
  "devDependencies": {