@chainrails/common 0.0.24 → 0.0.25

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.
@@ -618,7 +618,7 @@ const Xe = {
618
618
  };
619
619
  var nt = /* @__PURE__ */ ((e) => (e.ARBITRUM = "ARBITRUM_MAINNET", e.ARBITRUM_TESTNET = "ARBITRUM_TESTNET", e.AVALANCHE = "AVALANCHE_MAINNET", e.AVALANCHE_TESTNET = "AVALANCHE_TESTNET", e.BASE = "BASE_MAINNET", e.BASE_TESTNET = "BASE_TESTNET", e.BSC = "BSC_MAINNET", e.ETHEREUM = "ETHEREUM_MAINNET", e.ETHEREUM_TESTNET = "ETHEREUM_TESTNET", e.STARKNET = "STARKNET_MAINNET", e))(nt || {}), st = /* @__PURE__ */ ((e) => (e.USDC = "USDC", e))(st || {});
620
620
  const ot = (e) => {
621
- const t = e.trim().toUpperCase();
621
+ const t = e?.trim().toUpperCase();
622
622
  if (M[t])
623
623
  return M[t];
624
624
  };
@@ -618,7 +618,7 @@ const Xe = {
618
618
  };
619
619
  var nt = /* @__PURE__ */ ((e) => (e.ARBITRUM = "ARBITRUM_MAINNET", e.ARBITRUM_TESTNET = "ARBITRUM_TESTNET", e.AVALANCHE = "AVALANCHE_MAINNET", e.AVALANCHE_TESTNET = "AVALANCHE_TESTNET", e.BASE = "BASE_MAINNET", e.BASE_TESTNET = "BASE_TESTNET", e.BSC = "BSC_MAINNET", e.ETHEREUM = "ETHEREUM_MAINNET", e.ETHEREUM_TESTNET = "ETHEREUM_TESTNET", e.STARKNET = "STARKNET_MAINNET", e))(nt || {}), st = /* @__PURE__ */ ((e) => (e.USDC = "USDC", e))(st || {});
620
620
  const ot = (e) => {
621
- const t = e.trim().toUpperCase();
621
+ const t = e?.trim().toUpperCase();
622
622
  if (M[t])
623
623
  return M[t];
624
624
  };
@@ -1,2 +1,2 @@
1
1
  (function(l,u){typeof exports=="object"&&typeof module<"u"?u(exports):typeof define=="function"&&define.amd?define(["exports"],u):(l=typeof globalThis<"u"?globalThis:l||self,u(l.Chainrails={}))})(this,(function(l){"use strict";var u=(e=>(e.USDC="USDC",e))(u||{});const B={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"},R={type:"evm",chainId:8453,name:"Base",cctpDomain:6,logoURI:"/images/chains/base.webp"},N={type:"evm",chainId:84532,name:"Base Sepolia",cctpDomain:6,logoURI:"/images/chains/base.webp"},$={type:"evm",chainId:56,name:"BNB Chain",cctpDomain:null,logoURI:"/images/chains/bsc.webp"},M={type:"evm",chainId:1,name:"Ethereum",cctpDomain:0,logoURI:"/images/chains/ethereum.svg"},O={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"},z={type:"evm",chainId:43113,name:"Avalanche Fuji",cctpDomain:1,logoURI:"/images/chains/avalanche.svg"},L={type:"starknet",chainId:"0x534e5f4d41494e",name:"Starknet",cctpDomain:null,logoURI:"/images/chains/starknet.svg"};function A(e,{strict:t=!0}={}){return!e||typeof e!="string"?!1:t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x")}function H(e){return A(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}const P="2.43.4";let U={getDocsUrl:({docsBaseUrl:e,docsPath:t="",docsSlug:n})=>t?`${e??"https://viem.sh"}${t}${n?`#${n}`:""}`:void 0,version:`viem@${P}`};class p extends Error{constructor(t,n={}){const s=n.cause instanceof p?n.cause.details:n.cause?.message?n.cause.message:n.details,o=n.cause instanceof p&&n.cause.docsPath||n.docsPath,r=U.getDocsUrl?.({...n,docsPath:o}),i=[t||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...r?[`Docs: ${r}`]:[],...s?[`Details: ${s}`]:[],...U.version?[`Version: ${U.version}`]:[]].join(`
2
- `);super(i,n.cause?{cause:n.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=s,this.docsPath=o,this.metaMessages=n.metaMessages,this.name=n.name??this.name,this.shortMessage=t,this.version=P}walk(t){return F(this,t)}}function F(e,t){return t?.(e)?e:e&&typeof e=="object"&&"cause"in e&&e.cause!==void 0?F(e.cause,t):t?null:e}class j extends p{constructor({size:t,targetSize:n,type:s}){super(`${s.charAt(0).toUpperCase()}${s.slice(1).toLowerCase()} size (${t}) exceeds padding size (${n}).`,{name:"SizeExceedsPaddingSizeError"})}}function y(e,{dir:t,size:n=32}={}){return typeof e=="string"?le(e,{dir:t,size:n}):fe(e,{dir:t,size:n})}function le(e,{dir:t,size:n=32}={}){if(n===null)return e;const s=e.replace("0x","");if(s.length>n*2)throw new j({size:Math.ceil(s.length/2),targetSize:n,type:"hex"});return`0x${s[t==="right"?"padEnd":"padStart"](n*2,"0")}`}function fe(e,{dir:t,size:n=32}={}){if(n===null)return e;if(e.length>n)throw new j({size:e.length,targetSize:n,type:"bytes"});const s=new Uint8Array(n);for(let o=0;o<n;o++){const r=t==="right";s[r?o:n-o-1]=e[r?o:e.length-o-1]}return s}class de extends p{constructor({max:t,min:n,signed:s,size:o,value:r}){super(`Number "${r}" is not in safe ${o?`${o*8}-bit ${s?"signed":"unsigned"} `:""}integer range ${t?`(${n} to ${t})`:`(above ${n})`}`,{name:"IntegerOutOfRangeError"})}}class he extends p{constructor({givenSize:t,maxSize:n}){super(`Size cannot exceed ${n} bytes. Given size: ${t} bytes.`,{name:"SizeOverflowError"})}}function T(e,{size:t}){if(H(e)>t)throw new he({givenSize:H(e),maxSize:t})}function pe(e,t={}){const{signed:n,size:s}=t,o=BigInt(e);let r;s?n?r=(1n<<BigInt(s)*8n-1n)-1n:r=2n**(BigInt(s)*8n)-1n:typeof e=="number"&&(r=BigInt(Number.MAX_SAFE_INTEGER));const i=typeof r=="bigint"&&n?-r-1n:0;if(r&&o>r||o<i){const f=typeof e=="bigint"?"n":"";throw new de({max:r?`${r}${f}`:void 0,min:`${i}${f}`,signed:n,size:s,value:`${e}${f}`})}const c=`0x${(n&&o<0?(1n<<BigInt(s*8))+BigInt(o):o).toString(16)}`;return s?y(c,{size:s}):c}const ge=new TextEncoder;function me(e,t={}){return typeof e=="number"||typeof e=="bigint"?ye(e,t):typeof e=="boolean"?be(e,t):A(e)?V(e,t):X(e,t)}function be(e,t={}){const n=new Uint8Array(1);return n[0]=Number(e),typeof t.size=="number"?(T(n,{size:t.size}),y(n,{size:t.size})):n}const d={zero:48,nine:57,A:65,F:70,a:97,f:102};function K(e){if(e>=d.zero&&e<=d.nine)return e-d.zero;if(e>=d.A&&e<=d.F)return e-(d.A-10);if(e>=d.a&&e<=d.f)return e-(d.a-10)}function V(e,t={}){let n=e;t.size&&(T(n,{size:t.size}),n=y(n,{dir:"right",size:t.size}));let s=n.slice(2);s.length%2&&(s=`0${s}`);const o=s.length/2,r=new Uint8Array(o);for(let i=0,c=0;i<o;i++){const f=K(s.charCodeAt(c++)),g=K(s.charCodeAt(c++));if(f===void 0||g===void 0)throw new p(`Invalid byte sequence ("${s[c-2]}${s[c-1]}" in "${s}").`);r[i]=f*16+g}return r}function ye(e,t){const n=pe(e,t);return V(n)}function X(e,t={}){const n=ge.encode(e);return typeof t.size=="number"?(T(n,{size:t.size}),y(n,{dir:"right",size:t.size})):n}const E=BigInt(2**32-1),G=BigInt(32);function Ee(e,t=!1){return t?{h:Number(e&E),l:Number(e>>G&E)}:{h:Number(e>>G&E)|0,l:Number(e&E)|0}}function Ie(e,t=!1){const n=e.length;let s=new Uint32Array(n),o=new Uint32Array(n);for(let r=0;r<n;r++){const{h:i,l:c}=Ee(e[r],t);[s[r],o[r]]=[i,c]}return[s,o]}const Se=(e,t,n)=>e<<n|t>>>32-n,Ae=(e,t,n)=>t<<n|e>>>32-n,Ue=(e,t,n)=>t<<n-32|e>>>64-n,Te=(e,t,n)=>e<<n-32|t>>>64-n;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function we(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function q(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function I(e,...t){if(!we(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 W(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 xe(e,t){I(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function Ce(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function J(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}const De=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function ve(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function Be(e){for(let t=0;t<e.length;t++)e[t]=ve(e[t]);return e}const Q=De?e=>e:Be;function ke(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function Y(e){return typeof e=="string"&&(e=ke(e)),I(e),e}class Re{}function Ne(e){const t=s=>e().update(Y(s)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}const $e=BigInt(0),b=BigInt(1),Me=BigInt(2),Oe=BigInt(7),_e=BigInt(256),ze=BigInt(113),Z=[],ee=[],te=[];for(let e=0,t=b,n=1,s=0;e<24;e++){[n,s]=[s,(2*n+3*s)%5],Z.push(2*(5*s+n)),ee.push((e+1)*(e+2)/2%64);let o=$e;for(let r=0;r<7;r++)t=(t<<b^(t>>Oe)*ze)%_e,t&Me&&(o^=b<<(b<<BigInt(r))-b);te.push(o)}const ne=Ie(te,!0),Le=ne[0],He=ne[1],se=(e,t,n)=>n>32?Ue(e,t,n):Se(e,t,n),oe=(e,t,n)=>n>32?Te(e,t,n):Ae(e,t,n);function Pe(e,t=24){const n=new Uint32Array(10);for(let s=24-t;s<24;s++){for(let i=0;i<10;i++)n[i]=e[i]^e[i+10]^e[i+20]^e[i+30]^e[i+40];for(let i=0;i<10;i+=2){const c=(i+8)%10,f=(i+2)%10,g=n[f],m=n[f+1],it=se(g,m,1)^n[c],rt=oe(g,m,1)^n[c+1];for(let S=0;S<50;S+=10)e[i+S]^=it,e[i+S+1]^=rt}let o=e[2],r=e[3];for(let i=0;i<24;i++){const c=ee[i],f=se(o,r,c),g=oe(o,r,c),m=Z[i];o=e[m],r=e[m+1],e[m]=f,e[m+1]=g}for(let i=0;i<50;i+=10){for(let c=0;c<10;c++)n[c]=e[i+c];for(let c=0;c<10;c++)e[i+c]^=~n[(c+2)%10]&n[(c+4)%10]}e[0]^=Le[s],e[1]^=He[s]}J(n)}class w extends Re{constructor(t,n,s,o=!1,r=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=t,this.suffix=n,this.outputLen=s,this.enableXOF=o,this.rounds=r,q(s),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=Ce(this.state)}clone(){return this._cloneInto()}keccak(){Q(this.state32),Pe(this.state32,this.rounds),Q(this.state32),this.posOut=0,this.pos=0}update(t){W(this),t=Y(t),I(t);const{blockLen:n,state:s}=this,o=t.length;for(let r=0;r<o;){const i=Math.min(n-this.pos,o-r);for(let c=0;c<i;c++)s[this.pos++]^=t[r++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:n,pos:s,blockLen:o}=this;t[s]^=n,(n&128)!==0&&s===o-1&&this.keccak(),t[o-1]^=128,this.keccak()}writeInto(t){W(this,!1),I(t),this.finish();const n=this.state,{blockLen:s}=this;for(let o=0,r=t.length;o<r;){this.posOut>=s&&this.keccak();const i=Math.min(s-this.posOut,r-o);t.set(n.subarray(this.posOut,this.posOut+i),o),this.posOut+=i,o+=i}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return q(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(xe(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,J(this.state)}_cloneInto(t){const{blockLen:n,suffix:s,outputLen:o,rounds:r,enableXOF:i}=this;return t||(t=new w(n,s,o,i,r)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=r,t.suffix=s,t.outputLen=o,t.enableXOF=i,t.destroyed=this.destroyed,t}}const Fe=(e,t,n)=>Ne(()=>new w(t,e,n)),je=Fe(1,136,256/8);function Ke(e,t){return je(A(e,{strict:!1})?me(e):e)}class Ve extends p{constructor({address:t}){super(`Address "${t}" is invalid.`,{metaMessages:["- Address must be a hex value of 20 bytes (40 hex characters).","- Address must match its checksum counterpart."],name:"InvalidAddressError"})}}class ie extends Map{constructor(t){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=t}get(t){const n=super.get(t);return super.has(t)&&n!==void 0&&(this.delete(t),super.set(t,n)),n}set(t,n){if(super.set(t,n),this.maxSize&&this.size>this.maxSize){const s=this.keys().next().value;s&&this.delete(s)}return this}}const x=new ie(8192);function re(e,t){if(x.has(`${e}.${t}`))return x.get(`${e}.${t}`);const n=e.substring(2).toLowerCase(),s=Ke(X(n)),o=n.split("");for(let i=0;i<40;i+=2)s[i>>1]>>4>=8&&o[i]&&(o[i]=o[i].toUpperCase()),(s[i>>1]&15)>=8&&o[i+1]&&(o[i+1]=o[i+1].toUpperCase());const r=`0x${o.join("")}`;return x.set(`${e}.${t}`,r),r}function h(e,t){if(!Ge(e,{strict:!1}))throw new Ve({address:e});return re(e,t)}const Xe=/^0x[a-fA-F0-9]{40}$/,C=new ie(8192);function Ge(e,t){const{strict:n=!0}=t??{},s=`${e}.${n}`;if(C.has(s))return C.get(s);const o=Xe.test(e)?e.toLowerCase()===e?!0:n?re(e)===e:!0:!1;return C.set(s,o),o}const qe={chainId:k.chainId,address:h("0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d"),symbol:"USDC",fiatISO:"USD",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},We={chainId:B.chainId,address:h("0xaf88d065e77c8cC2239327C5EDb3A432268e5831"),symbol:"USDC",name:"USD Coin",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png"},Je={chainId:z.chainId,address:h("0x5425890298aed601595a70ab815c96711a31bc65"),symbol:"USDC",fiatISO:"USD",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},Qe={chainId:_.chainId,address:h("0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E"),symbol:"USDC",fiatISO:"USD",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},Ye={chainId:N.chainId,address:h("0x036CbD53842c5426634e7929541eC2318f3dCF7e"),symbol:"USDC",fiatISO:"USD",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},Ze={chainId:R.chainId,address:h("0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"),symbol:"USDC",fiatISO:"USD",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},et={chainId:$.chainId,address:h("0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"),symbol:"USDC",decimals:18,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},tt={chainId:O.chainId,address:h("0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238"),symbol:"USDC",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},nt={chainId:M.chainId,address:h("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"),symbol:"USDC",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},st={chainId:L.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"},D={ARBITRUM_MAINNET:{...B,tokens:{[u.USDC]:We},explorer:"https://arbiscan.io"},ARBITRUM_TESTNET:{...k,explorer:"https://sepolia.arbiscan.io",tokens:{[u.USDC]:qe}},AVALANCHE_MAINNET:{..._,tokens:{[u.USDC]:Qe},explorer:"https://snowtrace.io"},AVALANCHE_TESTNET:{...z,tokens:{[u.USDC]:Je},explorer:"https://testnet.snowtrace.io"},BASE_MAINNET:{...R,tokens:{[u.USDC]:Ze},explorer:"https://basescan.org"},BASE_TESTNET:{...N,tokens:{[u.USDC]:Ye},explorer:"https://sepolia.basescan.org"},BSC_MAINNET:{...$,tokens:{[u.USDC]:et},explorer:"https://bscscan.com"},ETHEREUM_MAINNET:{...M,tokens:{[u.USDC]:nt},explorer:"https://etherscan.io"},ETHEREUM_TESTNET:{...O,tokens:{[u.USDC]:tt},explorer:"https://sepolia.etherscan.io"},STARKNET_MAINNET:{...L,tokens:{[u.USDC]:st},explorer:""}};var ce=(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))(ce||{}),ae=(e=>(e.USDC="USDC",e))(ae||{});const ue=e=>{const t=e.trim().toUpperCase();if(D[t])return D[t]};function ot(e,t){return ue(e)?.tokens[t]?.address}var v=(e=>(e.PRODUCTION="production",e.STAGING="staging",e))(v||{});class a{constructor({api_key:t,env:n,seesion_token:s}){this.api_key=t||"",this.sessionToken=s||"",this.env=n??v.PRODUCTION}static async config(t){if(!a.app){if(!t)throw new Error("Please provide an api_key");a.app=new a(t)}return t&&(t.api_key!==void 0&&(a.app.api_key=t.api_key),t.seesion_token!==void 0&&(a.app.sessionToken=t.seesion_token),t.env!==void 0&&(a.app.env=t.env)),a.app}static getApiKey(){if(!a.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return a.app.api_key}static getSessionToken(){if(!a.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return a.app.sessionToken}static getEnv(){if(!a.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return a.app.env==="internal"?"staging":a.app.env}static getBaseUrl(){if(!a.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");switch(a.app.env){case"production":return"https://api.chainrails.io/api/v1";case"staging":return"https://dev.chainrails.io/api/v1";case"internal":return"https://dev.chainrails.io/api/v1";default:return"https://api.chainrails.io/api/v1"}}static getPayModalUrl(t,n,s,o){if(!a.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");const r=a.app.env==="internal"?"https://chainrails-frontend-git-staging-horus-labs.vercel.app":"https://app.chainrails.io",i=o&&o>0?"/pay/":"/deposit/",c=`_chain_/${t}/_token_/${n}/_to_/${s}${o?"/_amount_/"+o*100:""}`;return r+i+c}}l.Chainrails=a,l.allChains=D,l.chains=ce,l.environment=v,l.getChainByChainEnum=ue,l.getTokenAddress=ot,l.tokens=ae,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})}));
2
+ `);super(i,n.cause?{cause:n.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=s,this.docsPath=o,this.metaMessages=n.metaMessages,this.name=n.name??this.name,this.shortMessage=t,this.version=P}walk(t){return F(this,t)}}function F(e,t){return t?.(e)?e:e&&typeof e=="object"&&"cause"in e&&e.cause!==void 0?F(e.cause,t):t?null:e}class j extends p{constructor({size:t,targetSize:n,type:s}){super(`${s.charAt(0).toUpperCase()}${s.slice(1).toLowerCase()} size (${t}) exceeds padding size (${n}).`,{name:"SizeExceedsPaddingSizeError"})}}function y(e,{dir:t,size:n=32}={}){return typeof e=="string"?le(e,{dir:t,size:n}):fe(e,{dir:t,size:n})}function le(e,{dir:t,size:n=32}={}){if(n===null)return e;const s=e.replace("0x","");if(s.length>n*2)throw new j({size:Math.ceil(s.length/2),targetSize:n,type:"hex"});return`0x${s[t==="right"?"padEnd":"padStart"](n*2,"0")}`}function fe(e,{dir:t,size:n=32}={}){if(n===null)return e;if(e.length>n)throw new j({size:e.length,targetSize:n,type:"bytes"});const s=new Uint8Array(n);for(let o=0;o<n;o++){const r=t==="right";s[r?o:n-o-1]=e[r?o:e.length-o-1]}return s}class de extends p{constructor({max:t,min:n,signed:s,size:o,value:r}){super(`Number "${r}" is not in safe ${o?`${o*8}-bit ${s?"signed":"unsigned"} `:""}integer range ${t?`(${n} to ${t})`:`(above ${n})`}`,{name:"IntegerOutOfRangeError"})}}class he extends p{constructor({givenSize:t,maxSize:n}){super(`Size cannot exceed ${n} bytes. Given size: ${t} bytes.`,{name:"SizeOverflowError"})}}function T(e,{size:t}){if(H(e)>t)throw new he({givenSize:H(e),maxSize:t})}function pe(e,t={}){const{signed:n,size:s}=t,o=BigInt(e);let r;s?n?r=(1n<<BigInt(s)*8n-1n)-1n:r=2n**(BigInt(s)*8n)-1n:typeof e=="number"&&(r=BigInt(Number.MAX_SAFE_INTEGER));const i=typeof r=="bigint"&&n?-r-1n:0;if(r&&o>r||o<i){const f=typeof e=="bigint"?"n":"";throw new de({max:r?`${r}${f}`:void 0,min:`${i}${f}`,signed:n,size:s,value:`${e}${f}`})}const c=`0x${(n&&o<0?(1n<<BigInt(s*8))+BigInt(o):o).toString(16)}`;return s?y(c,{size:s}):c}const ge=new TextEncoder;function me(e,t={}){return typeof e=="number"||typeof e=="bigint"?ye(e,t):typeof e=="boolean"?be(e,t):A(e)?V(e,t):X(e,t)}function be(e,t={}){const n=new Uint8Array(1);return n[0]=Number(e),typeof t.size=="number"?(T(n,{size:t.size}),y(n,{size:t.size})):n}const d={zero:48,nine:57,A:65,F:70,a:97,f:102};function K(e){if(e>=d.zero&&e<=d.nine)return e-d.zero;if(e>=d.A&&e<=d.F)return e-(d.A-10);if(e>=d.a&&e<=d.f)return e-(d.a-10)}function V(e,t={}){let n=e;t.size&&(T(n,{size:t.size}),n=y(n,{dir:"right",size:t.size}));let s=n.slice(2);s.length%2&&(s=`0${s}`);const o=s.length/2,r=new Uint8Array(o);for(let i=0,c=0;i<o;i++){const f=K(s.charCodeAt(c++)),g=K(s.charCodeAt(c++));if(f===void 0||g===void 0)throw new p(`Invalid byte sequence ("${s[c-2]}${s[c-1]}" in "${s}").`);r[i]=f*16+g}return r}function ye(e,t){const n=pe(e,t);return V(n)}function X(e,t={}){const n=ge.encode(e);return typeof t.size=="number"?(T(n,{size:t.size}),y(n,{dir:"right",size:t.size})):n}const E=BigInt(2**32-1),G=BigInt(32);function Ee(e,t=!1){return t?{h:Number(e&E),l:Number(e>>G&E)}:{h:Number(e>>G&E)|0,l:Number(e&E)|0}}function Ie(e,t=!1){const n=e.length;let s=new Uint32Array(n),o=new Uint32Array(n);for(let r=0;r<n;r++){const{h:i,l:c}=Ee(e[r],t);[s[r],o[r]]=[i,c]}return[s,o]}const Se=(e,t,n)=>e<<n|t>>>32-n,Ae=(e,t,n)=>t<<n|e>>>32-n,Ue=(e,t,n)=>t<<n-32|e>>>64-n,Te=(e,t,n)=>e<<n-32|t>>>64-n;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function we(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function q(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function I(e,...t){if(!we(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 W(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 xe(e,t){I(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function Ce(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function J(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}const De=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function ve(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function Be(e){for(let t=0;t<e.length;t++)e[t]=ve(e[t]);return e}const Q=De?e=>e:Be;function ke(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function Y(e){return typeof e=="string"&&(e=ke(e)),I(e),e}class Re{}function Ne(e){const t=s=>e().update(Y(s)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}const $e=BigInt(0),b=BigInt(1),Me=BigInt(2),Oe=BigInt(7),_e=BigInt(256),ze=BigInt(113),Z=[],ee=[],te=[];for(let e=0,t=b,n=1,s=0;e<24;e++){[n,s]=[s,(2*n+3*s)%5],Z.push(2*(5*s+n)),ee.push((e+1)*(e+2)/2%64);let o=$e;for(let r=0;r<7;r++)t=(t<<b^(t>>Oe)*ze)%_e,t&Me&&(o^=b<<(b<<BigInt(r))-b);te.push(o)}const ne=Ie(te,!0),Le=ne[0],He=ne[1],se=(e,t,n)=>n>32?Ue(e,t,n):Se(e,t,n),oe=(e,t,n)=>n>32?Te(e,t,n):Ae(e,t,n);function Pe(e,t=24){const n=new Uint32Array(10);for(let s=24-t;s<24;s++){for(let i=0;i<10;i++)n[i]=e[i]^e[i+10]^e[i+20]^e[i+30]^e[i+40];for(let i=0;i<10;i+=2){const c=(i+8)%10,f=(i+2)%10,g=n[f],m=n[f+1],it=se(g,m,1)^n[c],rt=oe(g,m,1)^n[c+1];for(let S=0;S<50;S+=10)e[i+S]^=it,e[i+S+1]^=rt}let o=e[2],r=e[3];for(let i=0;i<24;i++){const c=ee[i],f=se(o,r,c),g=oe(o,r,c),m=Z[i];o=e[m],r=e[m+1],e[m]=f,e[m+1]=g}for(let i=0;i<50;i+=10){for(let c=0;c<10;c++)n[c]=e[i+c];for(let c=0;c<10;c++)e[i+c]^=~n[(c+2)%10]&n[(c+4)%10]}e[0]^=Le[s],e[1]^=He[s]}J(n)}class w extends Re{constructor(t,n,s,o=!1,r=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=t,this.suffix=n,this.outputLen=s,this.enableXOF=o,this.rounds=r,q(s),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=Ce(this.state)}clone(){return this._cloneInto()}keccak(){Q(this.state32),Pe(this.state32,this.rounds),Q(this.state32),this.posOut=0,this.pos=0}update(t){W(this),t=Y(t),I(t);const{blockLen:n,state:s}=this,o=t.length;for(let r=0;r<o;){const i=Math.min(n-this.pos,o-r);for(let c=0;c<i;c++)s[this.pos++]^=t[r++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:n,pos:s,blockLen:o}=this;t[s]^=n,(n&128)!==0&&s===o-1&&this.keccak(),t[o-1]^=128,this.keccak()}writeInto(t){W(this,!1),I(t),this.finish();const n=this.state,{blockLen:s}=this;for(let o=0,r=t.length;o<r;){this.posOut>=s&&this.keccak();const i=Math.min(s-this.posOut,r-o);t.set(n.subarray(this.posOut,this.posOut+i),o),this.posOut+=i,o+=i}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return q(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(xe(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,J(this.state)}_cloneInto(t){const{blockLen:n,suffix:s,outputLen:o,rounds:r,enableXOF:i}=this;return t||(t=new w(n,s,o,i,r)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=r,t.suffix=s,t.outputLen=o,t.enableXOF=i,t.destroyed=this.destroyed,t}}const Fe=(e,t,n)=>Ne(()=>new w(t,e,n)),je=Fe(1,136,256/8);function Ke(e,t){return je(A(e,{strict:!1})?me(e):e)}class Ve extends p{constructor({address:t}){super(`Address "${t}" is invalid.`,{metaMessages:["- Address must be a hex value of 20 bytes (40 hex characters).","- Address must match its checksum counterpart."],name:"InvalidAddressError"})}}class ie extends Map{constructor(t){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=t}get(t){const n=super.get(t);return super.has(t)&&n!==void 0&&(this.delete(t),super.set(t,n)),n}set(t,n){if(super.set(t,n),this.maxSize&&this.size>this.maxSize){const s=this.keys().next().value;s&&this.delete(s)}return this}}const x=new ie(8192);function re(e,t){if(x.has(`${e}.${t}`))return x.get(`${e}.${t}`);const n=e.substring(2).toLowerCase(),s=Ke(X(n)),o=n.split("");for(let i=0;i<40;i+=2)s[i>>1]>>4>=8&&o[i]&&(o[i]=o[i].toUpperCase()),(s[i>>1]&15)>=8&&o[i+1]&&(o[i+1]=o[i+1].toUpperCase());const r=`0x${o.join("")}`;return x.set(`${e}.${t}`,r),r}function h(e,t){if(!Ge(e,{strict:!1}))throw new Ve({address:e});return re(e,t)}const Xe=/^0x[a-fA-F0-9]{40}$/,C=new ie(8192);function Ge(e,t){const{strict:n=!0}=t??{},s=`${e}.${n}`;if(C.has(s))return C.get(s);const o=Xe.test(e)?e.toLowerCase()===e?!0:n?re(e)===e:!0:!1;return C.set(s,o),o}const qe={chainId:k.chainId,address:h("0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d"),symbol:"USDC",fiatISO:"USD",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},We={chainId:B.chainId,address:h("0xaf88d065e77c8cC2239327C5EDb3A432268e5831"),symbol:"USDC",name:"USD Coin",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png"},Je={chainId:z.chainId,address:h("0x5425890298aed601595a70ab815c96711a31bc65"),symbol:"USDC",fiatISO:"USD",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},Qe={chainId:_.chainId,address:h("0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E"),symbol:"USDC",fiatISO:"USD",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},Ye={chainId:N.chainId,address:h("0x036CbD53842c5426634e7929541eC2318f3dCF7e"),symbol:"USDC",fiatISO:"USD",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},Ze={chainId:R.chainId,address:h("0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"),symbol:"USDC",fiatISO:"USD",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},et={chainId:$.chainId,address:h("0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"),symbol:"USDC",decimals:18,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},tt={chainId:O.chainId,address:h("0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238"),symbol:"USDC",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},nt={chainId:M.chainId,address:h("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"),symbol:"USDC",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},st={chainId:L.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"},D={ARBITRUM_MAINNET:{...B,tokens:{[u.USDC]:We},explorer:"https://arbiscan.io"},ARBITRUM_TESTNET:{...k,explorer:"https://sepolia.arbiscan.io",tokens:{[u.USDC]:qe}},AVALANCHE_MAINNET:{..._,tokens:{[u.USDC]:Qe},explorer:"https://snowtrace.io"},AVALANCHE_TESTNET:{...z,tokens:{[u.USDC]:Je},explorer:"https://testnet.snowtrace.io"},BASE_MAINNET:{...R,tokens:{[u.USDC]:Ze},explorer:"https://basescan.org"},BASE_TESTNET:{...N,tokens:{[u.USDC]:Ye},explorer:"https://sepolia.basescan.org"},BSC_MAINNET:{...$,tokens:{[u.USDC]:et},explorer:"https://bscscan.com"},ETHEREUM_MAINNET:{...M,tokens:{[u.USDC]:nt},explorer:"https://etherscan.io"},ETHEREUM_TESTNET:{...O,tokens:{[u.USDC]:tt},explorer:"https://sepolia.etherscan.io"},STARKNET_MAINNET:{...L,tokens:{[u.USDC]:st},explorer:""}};var ce=(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))(ce||{}),ae=(e=>(e.USDC="USDC",e))(ae||{});const ue=e=>{const t=e?.trim().toUpperCase();if(D[t])return D[t]};function ot(e,t){return ue(e)?.tokens[t]?.address}var v=(e=>(e.PRODUCTION="production",e.STAGING="staging",e))(v||{});class a{constructor({api_key:t,env:n,seesion_token:s}){this.api_key=t||"",this.sessionToken=s||"",this.env=n??v.PRODUCTION}static async config(t){if(!a.app){if(!t)throw new Error("Please provide an api_key");a.app=new a(t)}return t&&(t.api_key!==void 0&&(a.app.api_key=t.api_key),t.seesion_token!==void 0&&(a.app.sessionToken=t.seesion_token),t.env!==void 0&&(a.app.env=t.env)),a.app}static getApiKey(){if(!a.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return a.app.api_key}static getSessionToken(){if(!a.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return a.app.sessionToken}static getEnv(){if(!a.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return a.app.env==="internal"?"staging":a.app.env}static getBaseUrl(){if(!a.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");switch(a.app.env){case"production":return"https://api.chainrails.io/api/v1";case"staging":return"https://dev.chainrails.io/api/v1";case"internal":return"https://dev.chainrails.io/api/v1";default:return"https://api.chainrails.io/api/v1"}}static getPayModalUrl(t,n,s,o){if(!a.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");const r=a.app.env==="internal"?"https://chainrails-frontend-git-staging-horus-labs.vercel.app":"https://app.chainrails.io",i=o&&o>0?"/pay/":"/deposit/",c=`_chain_/${t}/_token_/${n}/_to_/${s}${o?"/_amount_/"+o*100:""}`;return r+i+c}}l.Chainrails=a,l.allChains=D,l.chains=ce,l.environment=v,l.getChainByChainEnum=ue,l.getTokenAddress=ot,l.tokens=ae,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@chainrails/common",
3
3
  "sideEffects": false,
4
- "version": "0.0.24",
4
+ "version": "0.0.25",
5
5
  "main": "./dist/chainrails-common.umd.js",
6
6
  "module": "./dist/chainrails-common.es.mjs",
7
7
  "license": "MIT",