@chainrails/sdk 0.0.31 → 0.0.33

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 +1,2 @@
1
- (function(s,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("ky")):typeof define=="function"&&define.amd?define(["exports","ky"],o):(s=typeof globalThis<"u"?globalThis:s||self,o(s.Chainrails={},s.Ky))})(this,(function(s,o){"use strict";var u=(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))(u||{}),l=(t=>(t.USDC="USDC",t))(l||{}),p=(t=>(t.PRODUCTION="production",t.STAGING="staging",t))(p||{});class n{constructor({api_key:e,env:i}){this.api_key=e,this.jwt="",this.env=i??p.PRODUCTION}static async config(e){if(!n.app){if(!e)throw new Error("Please provide an api_key");n.app=new n(e)}return e&&(n.app.api_key=e.api_key,e.env!==void 0&&(n.app.env=e.env),await this.updateJWT(),setInterval(this.updateJWT.bind(this),1500*1e3)),n.app}static async updateJWT(){try{const e=await(await fetch(this.getBaseUrl()+"/client/api-keys/session-token",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({apiKey:n.app.api_key})})).json();this.app.jwt=e.token}catch{}}static getApiKey(){if(!n.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return n.app.api_key}static getSessionKey(){return n.app.jwt}static getEnv(){if(!n.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return n.app.env==="internal"?"staging":n.app.env}static getBaseUrl(){if(!n.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");switch(n.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,i,A,r){if(!n.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");const S=n.app.env==="internal"?"https://chainrails-frontend-git-staging-horus-labs.vercel.app":"https://app.chainrails.io",g=r&&r>0?"/pay/":"/deposit/";console.log({mode:g,mode2:r?"/pay/":"/deposit/",amount:r});const N=`_chain_/${e}/_token_/${i}/_to_/${A}${r&&"/_amount_/"+r*100}`;return S+g+N}}let c=null;function h(){c=o.create({prefixUrl:n.getBaseUrl(),headers:{"Content-Type":"application/json"},hooks:{beforeRequest:[t=>{const e=n.getSessionKey();t.headers.set("Authorization",`Bearer ${e}`)}],afterResponse:[(t,e,i)=>i]},retry:{limit:2}})}function a(){return c||h(),c}class d{async getById(e){return await a().get("intents/"+e).json()}async getForSender(e){return await a().get("intents/user/"+e).json()}async getForAddress(e){return await a().get("intents/address/"+e).json()}async getAll(e){return await a().get("intents",{searchParams:e}).json()}async create(e){return await a().post("intents",{json:e}).json()}async update(e,i){return await a().post("intents",{json:i}).json()}async triggerProcessing(e){return await a().post(`intents/${e}/trigger-processing`).json()}}class T{async getFromSpecificBridge(e){return await a().get("quotes/single",{searchParams:e}).json()}async getFromAllBridges(e){return await a().get("quotes/multiple",{searchParams:e}).json()}async getBestAcrossBridges(e){return await a().get("quotes/best",{searchParams:e}).json()}async getAll(e){return await a().get("quotes/multi-source",{searchParams:e}).json()}}class E{async getOptimalRoutes(e){return await a().get("router/optimal-route",{searchParams:e}).json()}async getAllSupportedBridges(){return await a().get("router/supported-bridges/all").json()}async getSupportedBridges(e){return await a().get("router/supported-bridges/route",{searchParams:e}).json()}async getSupportedRoutes(e,i){return await a().get("router/supported-bridges/bridge/"+e,{searchParams:i}).json()}}class y{async getSupported(e){return await a().get("chains",{searchParams:e}).json()}}class f{async getClientInfo(){return await a().get("client/auth/client-info").json()}}const w={router:new E,quotes:new T,intents:new d,chains:new y,client:new f};s.Chainrails=n,s.chains=u,s.crapi=w,s.environment=p,s.tokens=l,Object.defineProperty(s,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 N={type:"evm",chainId:42161,name:"Arbitrum",cctpDomain:3,logoURI:"/images/chains/arbitrum.svg"},B={type:"evm",chainId:421614,name:"Arbitrum Sepolia",cctpDomain:3,logoURI:"/images/chains/arbitrum.svg"},$={type:"evm",chainId:8453,name:"Base",cctpDomain:6,logoURI:"/images/chains/base.webp"},z={type:"evm",chainId:84532,name:"Base Sepolia",cctpDomain:6,logoURI:"/images/chains/base.webp"},M={type:"evm",chainId:56,name:"BNB Chain",cctpDomain:null,logoURI:"/images/chains/bsc.webp"},O={type:"evm",chainId:1,name:"Ethereum",cctpDomain:0,logoURI:"/images/chains/ethereum.svg"},j={type:"evm",chainId:11155111,name:"Ethereum Sepolia",cctpDomain:0,logoURI:"/images/chains/ethereum.svg"},P={type:"evm",chainId:43114,name:"Avalanche",cctpDomain:1,logoURI:"/images/chains/avalanche.svg"},_={type:"evm",chainId:43113,name:"Avalanche Fuji",cctpDomain:1,logoURI:"/images/chains/avalanche.svg"},F={type:"starknet",chainId:"0x534e5f4d41494e",name:"Starknet",cctpDomain:null,logoURI:"/images/chains/starknet.svg"};function U(e,{strict:t=!0}={}){return!e||typeof e!="string"?!1:t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x")}function L(e){return U(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}const H="2.43.4";let v={getDocsUrl:({docsBaseUrl:e,docsPath:t="",docsSlug:s})=>t?`${e??"https://viem.sh"}${t}${s?`#${s}`:""}`:void 0,version:`viem@${H}`};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=v.getDocsUrl?.({...s,docsPath:i}),o=[t||"An error occurred.","",...s.metaMessages?[...s.metaMessages,""]:[],...r?[`Docs: ${r}`]:[],...n?[`Details: ${n}`]:[],...v.version?[`Version: ${v.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=H}walk(t){return K(this,t)}}function K(e,t){return t?.(e)?e:e&&typeof e=="object"&&"cause"in e&&e.cause!==void 0?K(e.cause,t):t?null:e}class q 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 E(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 q({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 q({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 C(e,{size:t}){if(L(e)>t)throw new fe({givenSize:L(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?E(a,{size:n}):a}const ye=new TextEncoder;function be(e,t={}){return typeof e=="number"||typeof e=="bigint"?Ee(e,t):typeof e=="boolean"?Ie(e,t):U(e)?X(e,t):G(e,t)}function Ie(e,t={}){const s=new Uint8Array(1);return s[0]=Number(e),typeof t.size=="number"?(C(s,{size:t.size}),E(s,{size:t.size})):s}const p={zero:48,nine:57,A:65,F:70,a:97,f:102};function V(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 X(e,t={}){let s=e;t.size&&(C(s,{size:t.size}),s=E(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=V(n.charCodeAt(a++)),m=V(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 Ee(e,t){const s=me(e,t);return X(s)}function G(e,t={}){const s=ye.encode(e);return typeof t.size=="number"?(C(s,{size:t.size}),E(s,{dir:"right",size:t.size})):s}const w=BigInt(2**32-1),Q=BigInt(32);function we(e,t=!1){return t?{h:Number(e&w),l:Number(e>>Q&w)}:{h:Number(e>>Q&w)|0,l:Number(e&w)|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}=we(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 W(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 J(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 Y(...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 Z=ke?e=>e:Ne;function Be(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function ee(e){return typeof e=="string"&&(e=Be(e)),S(e),e}class $e{}function ze(e){const t=n=>e().update(ee(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),_e=BigInt(113),te=[],se=[],ne=[];for(let e=0,t=I,s=1,n=0;e<24;e++){[s,n]=[n,(2*s+3*n)%5],te.push(2*(5*n+s)),se.push((e+1)*(e+2)/2%64);let i=Me;for(let r=0;r<7;r++)t=(t<<I^(t>>je)*_e)%Pe,t&Oe&&(i^=I<<(I<<BigInt(r))-I);ne.push(i)}const ie=Se(ne,!0),Fe=ie[0],Le=ie[1],oe=(e,t,s)=>s>32?ve(e,t,s):Ae(e,t,s),re=(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=oe(m,y,1)^s[a],yt=re(m,y,1)^s[a+1];for(let A=0;A<50;A+=10)e[o+A]^=mt,e[o+A+1]^=yt}let i=e[2],r=e[3];for(let o=0;o<24;o++){const a=se[o],d=oe(i,r,a),m=re(i,r,a),y=te[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]^=Fe[n],e[1]^=Le[n]}Y(s)}class T 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,W(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(){Z(this.state32),He(this.state32,this.rounds),Z(this.state32),this.posOut=0,this.pos=0}update(t){J(this),t=ee(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){J(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 W(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,Y(this.state)}_cloneInto(t){const{blockLen:s,suffix:n,outputLen:i,rounds:r,enableXOF:o}=this;return t||(t=new T(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 Ke=(e,t,s)=>ze(()=>new T(t,e,s)),qe=Ke(1,136,256/8);function Ve(e,t){return qe(U(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 ae 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 D=new ae(8192);function ce(e,t){if(D.has(`${e}.${t}`))return D.get(`${e}.${t}`);const s=e.substring(2).toLowerCase(),n=Ve(G(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 D.set(`${e}.${t}`,r),r}function g(e,t){if(!Qe(e,{strict:!1}))throw new Xe({address:e});return ce(e,t)}const Ge=/^0x[a-fA-F0-9]{40}$/,x=new ae(8192);function Qe(e,t){const{strict:s=!0}=t??{},n=`${e}.${s}`;if(x.has(n))return x.get(n);const i=Ge.test(e)?e.toLowerCase()===e?!0:s?ce(e)===e:!0:!1;return x.set(n,i),i}const We={chainId:B.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:N.chainId,address:g("0xaf88d065e77c8cC2239327C5EDb3A432268e5831"),symbol:"USDC",name:"USD Coin",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png"},Ye={chainId:_.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:P.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:z.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:$.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:M.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:j.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:O.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:F.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"},ue={ARBITRUM_MAINNET:{...N,tokens:{[h.USDC]:Je},explorer:"https://arbiscan.io"},ARBITRUM_TESTNET:{...B,explorer:"https://sepolia.arbiscan.io",tokens:{[h.USDC]:We}},AVALANCHE_MAINNET:{...P,tokens:{[h.USDC]:Ze},explorer:"https://snowtrace.io"},AVALANCHE_TESTNET:{..._,tokens:{[h.USDC]:Ye},explorer:"https://testnet.snowtrace.io"},BASE_MAINNET:{...$,tokens:{[h.USDC]:tt},explorer:"https://basescan.org"},BASE_TESTNET:{...z,tokens:{[h.USDC]:et},explorer:"https://sepolia.basescan.org"},BSC_MAINNET:{...M,tokens:{[h.USDC]:st},explorer:"https://bscscan.com"},ETHEREUM_MAINNET:{...O,tokens:{[h.USDC]:it},explorer:"https://etherscan.io"},ETHEREUM_TESTNET:{...j,tokens:{[h.USDC]:nt},explorer:"https://sepolia.etherscan.io"},STARKNET_MAINNET:{...F,tokens:{[h.USDC]:ot},explorer:""}};var le=(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))(le||{}),he=(e=>(e.USDC="USDC",e))(he||{});const rt=e=>{const t=e.trim().toUpperCase();if(ue[t])return ue[t]};function at(e,t){return rt(e)?.tokens[t]?.address}var k=(e=>(e.PRODUCTION="production",e.STAGING="staging",e))(k||{});class c{constructor({api_key:t,env:s,seesion_token:n}){this.api_key=t||"",this.sessionToken=n||"",this.env=s??k.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 R=null;function ct(){R=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 R||ct(),R}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 getAll(t){return await u().get("intents",{searchParams:t}).json()}async create(t){return await u().post("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()}}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()}}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{async getSessionToken(t){const s={recipient:t.recipient,tokenOut:at(t.destinationChain,t.token),destinationChain:t.destinationChain,amount:t.amount};return await u().post("modal/session",{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=le,l.crapi=ft,l.environment=k,l.tokens=he,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})}));
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ import Quotes from "./src/Quotes";
3
3
  import Router from "./src/Router";
4
4
  import Chains from "./src/Chains";
5
5
  import Client from "./src/Client";
6
+ import Auth from "./src/Auth";
6
7
  import { chains, tokens, Chainrails, environment } from "@chainrails/common";
7
8
  declare const crapi: {
8
9
  router: Router;
@@ -10,6 +11,7 @@ declare const crapi: {
10
11
  intents: Intents;
11
12
  chains: Chains;
12
13
  client: Client;
14
+ auth: Auth;
13
15
  };
14
16
  export * from "./src/types";
15
17
  export { crapi, chains, tokens, Chainrails, environment };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,eAAe,CAAC;AACpC,OAAO,MAAM,MAAM,cAAc,CAAC;AAClC,OAAO,MAAM,MAAM,cAAc,CAAC;AAClC,OAAO,MAAM,MAAM,cAAc,CAAC;AAClC,OAAO,MAAM,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAE7E,QAAA,MAAM,KAAK;;;;;;CAMV,CAAC;AAEF,cAAc,aAAa,CAAC;AAE5B,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,eAAe,CAAC;AACpC,OAAO,MAAM,MAAM,cAAc,CAAC;AAClC,OAAO,MAAM,MAAM,cAAc,CAAC;AAClC,OAAO,MAAM,MAAM,cAAc,CAAC;AAClC,OAAO,MAAM,MAAM,cAAc,CAAC;AAClC,OAAO,IAAI,MAAM,YAAY,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAE7E,QAAA,MAAM,KAAK;;;;;;;CAOV,CAAC;AAEF,cAAc,aAAa,CAAC;AAE5B,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { getSessionTokenInput, getSessionTokenOutput } from "./types";
2
+ export default class Auth {
3
+ getSessionToken(input: getSessionTokenInput): Promise<getSessionTokenOutput>;
4
+ }
5
+ export * from "./types";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Auth/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAEtE,MAAM,CAAC,OAAO,OAAO,IAAI;IACjB,eAAe,CAAC,KAAK,EAAE,oBAAoB;CASlD;AAED,cAAc,SAAS,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { chains, tokens } from "@chainrails/common";
2
+ export interface getSessionTokenInput {
3
+ recipient: string;
4
+ token: keyof typeof tokens;
5
+ destinationChain: keyof typeof chains;
6
+ amount: string;
7
+ }
8
+ export interface getSessionTokenOutput {
9
+ sessionToken: string;
10
+ }
11
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/Auth/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEpD,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,OAAO,MAAM,CAAC;IAC3B,gBAAgB,EAAE,MAAM,OAAO,MAAM,CAAC;IACtC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,qBAAqB;IACpC,YAAY,EAAE,MAAM,CAAC;CACtB"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@chainrails/sdk",
3
3
  "sideEffects": false,
4
- "version": "0.0.31",
4
+ "version": "0.0.33",
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.21",
38
+ "@chainrails/common": "^0.0.24",
39
39
  "ky": "^1.14.0"
40
40
  },
41
41
  "devDependencies": {