react-web3-storage 2.0.0 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/{ReownAuthentication-BTdnSW4c.mjs → ReownAuthentication-7iIT4jS4.mjs} +1 -1
  2. package/dist/{ReownAuthentication-Bi7oHuGf.js → ReownAuthentication-BEGlJitZ.js} +1 -1
  3. package/dist/{SwapController-CVrVI6fw.mjs → SwapController-CmWZu4cY.mjs} +1 -1
  4. package/dist/{SwapController-PZ_cUWEW.js → SwapController-DNucRoq5.js} +1 -1
  5. package/dist/{ccip-ClSy32fL.mjs → ccip-BCIUIeQM.mjs} +2 -2
  6. package/dist/{ccip-TDUuVnsR.js → ccip-Cy73HTCR.js} +1 -1
  7. package/dist/{data-capture-nJm8flD0.mjs → data-capture-CaxHvefN.mjs} +3 -3
  8. package/dist/{data-capture-plL1YmV9.js → data-capture-DbbP8JDT.js} +1 -1
  9. package/dist/{email-BIEjMkdp.mjs → email-B3WQnC0b.mjs} +2 -2
  10. package/dist/{email-Bb8TiksZ.js → email-CYJMBkHW.js} +1 -1
  11. package/dist/{embedded-wallet-BwfuLzcy.mjs → embedded-wallet-Dlo0wBgH.mjs} +1 -1
  12. package/dist/{embedded-wallet-Do1h12oF.js → embedded-wallet-t_Jd_LFV.js} +1 -1
  13. package/dist/{features-WgJ1ccjE.mjs → features-5qKGISK9.mjs} +1 -1
  14. package/dist/{features-3qQZVoJ9.js → features-B1ezv71b.js} +1 -1
  15. package/dist/{index-CWqapSt6.mjs → index-2WfSPp5U.mjs} +1 -1
  16. package/dist/{index-BDYtVois.mjs → index-BBH4oh8q.mjs} +2 -2
  17. package/dist/{index-1uaRGfNG.js → index-BCZXGGtc.js} +1 -1
  18. package/dist/{index-DuGTguVW.mjs → index-BR1aMNYm.mjs} +1 -1
  19. package/dist/{index-BTAZoMiJ.js → index-BhaYgUya.js} +4 -4
  20. package/dist/{index-mid89FTV.mjs → index-CAtS1mbf.mjs} +1 -1
  21. package/dist/{index-BKdw_1qM.mjs → index-CFLg0HEy.mjs} +7 -7
  22. package/dist/{index-CEc0pV8L.js → index-CZuajWCC.js} +1 -1
  23. package/dist/{index-DWz-QLrM.js → index-D1agTf42.js} +1 -1
  24. package/dist/{index-DMRaSYeI.mjs → index-D3R3_EiN.mjs} +1 -1
  25. package/dist/{index-Cx78ifGT.mjs → index-D8W2bJl5.mjs} +1 -1
  26. package/dist/{index-GJ5DCZOU.js → index-DAGaFidW.js} +1 -1
  27. package/dist/{index-ROIgf72J.mjs → index-DWRWjePT.mjs} +3 -3
  28. package/dist/{index-C4JlHMgz.js → index-Dk48RrmB.js} +1 -1
  29. package/dist/{index-BokidQQq.js → index-MeOSUHRy.js} +1 -1
  30. package/dist/{index-NFI34NW-.js → index-R_8iHUbU.js} +1 -1
  31. package/dist/{index-ByBvGUl7.mjs → index-SXXuh_Wo.mjs} +2 -2
  32. package/dist/{index-BF0RE6hb.js → index-VrnBQez9.js} +1 -1
  33. package/dist/index.cjs.js +1 -1
  34. package/dist/index.es.js +1 -1
  35. package/dist/{onramp-B6w59Uog.js → onramp-BMMneL8g.js} +1 -1
  36. package/dist/{onramp-C_QGimJZ.mjs → onramp-qJaw31Jf.mjs} +1 -1
  37. package/dist/{parseSignature-USiYfXGb.js → parseSignature-jZAFls5F.js} +2 -2
  38. package/dist/{parseSignature-BopOK20t.mjs → parseSignature-zKnspnY-.mjs} +2 -2
  39. package/dist/{pay-with-exchange-CBeg2Hon.mjs → pay-with-exchange-CTRrPVEx.mjs} +2 -2
  40. package/dist/{pay-with-exchange-CU_wbxzI.js → pay-with-exchange-CgjKtyDu.js} +1 -1
  41. package/dist/{receive-DzQ1FR7M.mjs → receive-D9mYL7F2.mjs} +1 -1
  42. package/dist/{receive-DI_BR-Kp.js → receive-eP1MrUw6.js} +1 -1
  43. package/dist/{send-DiU2PdFv.mjs → send-DmCwhyow.mjs} +4 -4
  44. package/dist/{send-B3h0xUoI.js → send-tFHrHPh4.js} +1 -1
  45. package/dist/{socials-Cu_B8mCk.js → socials-BXz_VcPl.js} +1 -1
  46. package/dist/{socials-iVCbnmhq.mjs → socials-BbYHDCTQ.mjs} +1 -1
  47. package/dist/{swaps-C9PoDZOv.js → swaps-C9W-NxLv.js} +1 -1
  48. package/dist/{swaps-DSWXYO4B.mjs → swaps-D06KGkWD.mjs} +3 -3
  49. package/dist/{transactions-vROLnPws.mjs → transactions-B-bDj0J7.mjs} +1 -1
  50. package/dist/{transactions-Clw8oIVh.js → transactions-CHNmwPaw.js} +1 -1
  51. package/dist/{w3m-modal-E2ouyDlT.mjs → w3m-modal-B82zwpqg.mjs} +3 -3
  52. package/dist/{w3m-modal-DagyNV6w.js → w3m-modal-CaxvJDN5.js} +1 -1
  53. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import { cb as g, cm as w, cn as y, co as A, c7 as k, cp as u, cc as N, cq as m } from "./index-BKdw_1qM.mjs";
1
+ import { cb as g, cm as w, cn as y, co as A, c7 as k, cp as u, cc as N, cq as m } from "./index-CFLg0HEy.mjs";
2
2
  class p {
3
3
  constructor(e) {
4
4
  this.getNonce = e.getNonce;
@@ -1,4 +1,4 @@
1
- "use strict";const s=require("./index-BTAZoMiJ.js");class f{constructor(e){this.getNonce=e.getNonce}async createMessage(e){const t={accountAddress:e.accountAddress,chainId:e.chainId,version:"1",domain:typeof document>"u"?"Unknown Domain":document.location.host,uri:typeof document>"u"?"Unknown URI":document.location.href,resources:this.resources,nonce:await this.getNonce(e),issuedAt:this.stringifyDate(new Date),statement:void 0,expirationTime:void 0,notBefore:void 0};return Object.assign(t,{toString:()=>this.stringify(t)})}stringify(e){var n;const t=this.getNetworkName(e.chainId);return[`${e.domain} wants you to sign in with your ${t} account:`,e.accountAddress,e.statement?`
1
+ "use strict";const s=require("./index-BhaYgUya.js");class f{constructor(e){this.getNonce=e.getNonce}async createMessage(e){const t={accountAddress:e.accountAddress,chainId:e.chainId,version:"1",domain:typeof document>"u"?"Unknown Domain":document.location.host,uri:typeof document>"u"?"Unknown URI":document.location.href,resources:this.resources,nonce:await this.getNonce(e),issuedAt:this.stringifyDate(new Date),statement:void 0,expirationTime:void 0,notBefore:void 0};return Object.assign(t,{toString:()=>this.stringify(t)})}stringify(e){var n;const t=this.getNetworkName(e.chainId);return[`${e.domain} wants you to sign in with your ${t} account:`,e.accountAddress,e.statement?`
2
2
  ${e.statement}
3
3
  `:"",`URI: ${e.uri}`,`Version: ${e.version}`,`Chain ID: ${e.chainId}`,`Nonce: ${e.nonce}`,e.issuedAt&&`Issued At: ${e.issuedAt}`,e.expirationTime&&`Expiration Time: ${e.expirationTime}`,e.notBefore&&`Not Before: ${e.notBefore}`,e.requestId&&`Request ID: ${e.requestId}`,((n=e.resources)==null?void 0:n.length)&&e.resources.reduce((o,r)=>`${o}
4
4
  - ${r}`,"Resources:")].filter(o=>typeof o=="string").join(`
@@ -1,4 +1,4 @@
1
- import { c1 as T, c2 as W, c3 as x, c4 as A, c5 as w, c6 as D, c7 as P, c8 as B, c9 as M, ca as F, cb as m, cc as v, cd as L, ce as N, cf as z, cg as R, ch as _, ci as H, cj as V, ck as $, cl as q } from "./index-BKdw_1qM.mjs";
1
+ import { c1 as T, c2 as W, c3 as x, c4 as A, c5 as w, c6 as D, c7 as P, c8 as B, c9 as M, ca as F, cb as m, cc as v, cd as L, ce as N, cf as z, cg as R, ch as _, ci as H, cj as V, ck as $, cl as q } from "./index-CFLg0HEy.mjs";
2
2
  const I = {
3
3
  getGasPriceInEther(n, t) {
4
4
  const o = t * n;
@@ -1 +1 @@
1
- "use strict";const o=require("./index-BTAZoMiJ.js"),A={getGasPriceInEther(n,r){const t=r*n;return Number(t)/1e18},getGasPriceInUSD(n,r,t){const s=A.getGasPriceInEther(r,t);return o.NumberUtil.bigNumber(n).times(s).toNumber()},getPriceImpact({sourceTokenAmount:n,sourceTokenPriceInUSD:r,toTokenPriceInUSD:t,toTokenAmount:s}){const l=o.NumberUtil.bigNumber(n).times(r),i=o.NumberUtil.bigNumber(s).times(t);return l.minus(i).div(l).times(100).toNumber()},getMaxSlippage(n,r){const t=o.NumberUtil.bigNumber(n).div(100);return o.NumberUtil.multiply(r,t).toNumber()},getProviderFee(n,r=.0085){return o.NumberUtil.bigNumber(n).times(r).toString()},isInsufficientNetworkTokenForGas(n,r){const t=r||"0";return o.NumberUtil.bigNumber(n).eq(0)?!0:o.NumberUtil.bigNumber(o.NumberUtil.bigNumber(t)).gt(n)},isInsufficientSourceTokenForSwap(n,r,t){var i,d;const s=(d=(i=t==null?void 0:t.find(k=>k.address===r))==null?void 0:i.quantity)==null?void 0:d.numeric;return o.NumberUtil.bigNumber(s||"0").lt(n)}},N=15e4,y=6,T={initializing:!1,initialized:!1,loadingPrices:!1,loadingQuote:!1,loadingApprovalTransaction:!1,loadingBuildTransaction:!1,loadingTransaction:!1,switchingTokens:!1,fetchError:!1,approvalTransaction:void 0,swapTransaction:void 0,transactionError:void 0,sourceToken:void 0,sourceTokenAmount:"",sourceTokenPriceInUSD:0,toToken:void 0,toTokenAmount:"",toTokenPriceInUSD:0,networkPrice:"0",networkBalanceInUSD:"0",networkTokenSymbol:"",inputError:void 0,slippage:o.ConstantsUtil$1.CONVERT_SLIPPAGE_TOLERANCE,tokens:void 0,popularTokens:void 0,suggestedTokens:void 0,foundTokens:void 0,myTokensWithBalance:void 0,tokensPriceMap:{},gasFee:"0",gasPriceInUSD:0,priceImpact:void 0,maxSlippage:void 0,providerFee:void 0},e=o.proxy({...T}),h={state:e,subscribe(n){return o.subscribe(e,()=>n(e))},subscribeKey(n,r){return o.subscribeKey(e,n,r)},getParams(){var c,u,p,g,w,f,S,C,P;const n=o.ChainController.state.activeChain,r=((c=o.ChainController.getAccountData(n))==null?void 0:c.caipAddress)??o.ChainController.state.activeCaipAddress,t=o.CoreHelperUtil.getPlainAddress(r),s=o.getActiveNetworkTokenAddress(),l=o.ConnectorController.getConnectorId(o.ChainController.state.activeChain);if(!t)throw new Error("No address found to swap the tokens from.");const i=!((u=e.toToken)!=null&&u.address)||!((p=e.toToken)!=null&&p.decimals),d=!((g=e.sourceToken)!=null&&g.address)||!((w=e.sourceToken)!=null&&w.decimals)||!o.NumberUtil.bigNumber(e.sourceTokenAmount).gt(0),k=!e.sourceTokenAmount;return{networkAddress:s,fromAddress:t,fromCaipAddress:r,sourceTokenAddress:(f=e.sourceToken)==null?void 0:f.address,toTokenAddress:(S=e.toToken)==null?void 0:S.address,toTokenAmount:e.toTokenAmount,toTokenDecimals:(C=e.toToken)==null?void 0:C.decimals,sourceTokenAmount:e.sourceTokenAmount,sourceTokenDecimals:(P=e.sourceToken)==null?void 0:P.decimals,invalidToToken:i,invalidSourceToken:d,invalidSourceTokenAmount:k,availableToSwap:r&&!i&&!d&&!k,isAuthConnector:l===o.ConstantsUtil.CONNECTOR_ID.AUTH}},async setSourceToken(n){if(!n){e.sourceToken=n,e.sourceTokenAmount="",e.sourceTokenPriceInUSD=0;return}e.sourceToken=n,await a.setTokenPrice(n.address,"sourceToken")},setSourceTokenAmount(n){e.sourceTokenAmount=n},async setToToken(n){if(!n){e.toToken=n,e.toTokenAmount="",e.toTokenPriceInUSD=0;return}e.toToken=n,await a.setTokenPrice(n.address,"toToken")},setToTokenAmount(n){e.toTokenAmount=n?o.NumberUtil.toFixed(n,y):""},async setTokenPrice(n,r){let t=e.tokensPriceMap[n]||0;t||(e.loadingPrices=!0,t=await a.getAddressPrice(n)),r==="sourceToken"?e.sourceTokenPriceInUSD=t:r==="toToken"&&(e.toTokenPriceInUSD=t),e.loadingPrices&&(e.loadingPrices=!1),a.getParams().availableToSwap&&!e.switchingTokens&&a.swapTokens()},async switchTokens(){if(!(e.initializing||!e.initialized||e.switchingTokens)){e.switchingTokens=!0;try{const n=e.toToken?{...e.toToken}:void 0,r=e.sourceToken?{...e.sourceToken}:void 0,t=n&&e.toTokenAmount===""?"1":e.toTokenAmount;a.setSourceTokenAmount(t),a.setToTokenAmount(""),await a.setSourceToken(n),await a.setToToken(r),e.switchingTokens=!1,a.swapTokens()}catch(n){throw e.switchingTokens=!1,n}}},resetState(){e.myTokensWithBalance=T.myTokensWithBalance,e.tokensPriceMap=T.tokensPriceMap,e.initialized=T.initialized,e.initializing=T.initializing,e.switchingTokens=T.switchingTokens,e.sourceToken=T.sourceToken,e.sourceTokenAmount=T.sourceTokenAmount,e.sourceTokenPriceInUSD=T.sourceTokenPriceInUSD,e.toToken=T.toToken,e.toTokenAmount=T.toTokenAmount,e.toTokenPriceInUSD=T.toTokenPriceInUSD,e.networkPrice=T.networkPrice,e.networkTokenSymbol=T.networkTokenSymbol,e.networkBalanceInUSD=T.networkBalanceInUSD,e.inputError=T.inputError},resetValues(){var t;const{networkAddress:n}=a.getParams(),r=(t=e.tokens)==null?void 0:t.find(s=>s.address===n);a.setSourceToken(r),a.setToToken(void 0)},getApprovalLoadingState(){return e.loadingApprovalTransaction},clearError(){e.transactionError=void 0},async initializeState(){if(!e.initializing){if(e.initializing=!0,!e.initialized)try{await a.fetchTokens(),e.initialized=!0}catch{e.initialized=!1,o.SnackController.showError("Failed to initialize swap"),o.RouterController.goBack()}e.initializing=!1}},async fetchTokens(){var t;const{networkAddress:n}=a.getParams();await a.getNetworkTokenPrice(),await a.getMyTokensWithBalance();const r=(t=e.myTokensWithBalance)==null?void 0:t.find(s=>s.address===n);r&&(e.networkTokenSymbol=r.symbol,a.setSourceToken(r),a.setSourceTokenAmount("0"))},async getTokenList(){var r,t;const n=(r=o.ChainController.state.activeCaipNetwork)==null?void 0:r.caipNetworkId;if(!(e.caipNetworkId===n&&e.tokens))try{e.tokensLoading=!0;const s=await o.SwapApiUtil.getTokenList(n);e.tokens=s,e.caipNetworkId=n,e.popularTokens=s.sort((c,u)=>c.symbol<u.symbol?-1:c.symbol>u.symbol?1:0);const i=(n&&((t=o.ConstantsUtil$1.SUGGESTED_TOKENS_BY_CHAIN)==null?void 0:t[n])||[]).map(c=>s.find(u=>u.symbol===c)).filter(c=>!!c),k=(o.ConstantsUtil$1.SWAP_SUGGESTED_TOKENS||[]).map(c=>s.find(u=>u.symbol===c)).filter(c=>!!c).filter(c=>!i.some(u=>u.address===c.address));e.suggestedTokens=[...i,...k]}catch{e.tokens=[],e.popularTokens=[],e.suggestedTokens=[]}finally{e.tokensLoading=!1}},async getAddressPrice(n){var c,u;const r=e.tokensPriceMap[n];if(r)return r;const t=await o.BlockchainApiController.fetchTokenPrice({addresses:[n]}),s=(t==null?void 0:t.fungibles)||[],l=[...e.tokens||[],...e.myTokensWithBalance||[]],i=(c=l==null?void 0:l.find(p=>p.address===n))==null?void 0:c.symbol,d=((u=s.find(p=>p.symbol.toLowerCase()===(i==null?void 0:i.toLowerCase())))==null?void 0:u.price)||0,k=parseFloat(d.toString());return e.tokensPriceMap[n]=k,k},async getNetworkTokenPrice(){var l;const{networkAddress:n}=a.getParams(),t=(l=(await o.BlockchainApiController.fetchTokenPrice({addresses:[n]}).catch(()=>(o.SnackController.showError("Failed to fetch network token price"),{fungibles:[]}))).fungibles)==null?void 0:l[0],s=(t==null?void 0:t.price.toString())||"0";e.tokensPriceMap[n]=parseFloat(s),e.networkTokenSymbol=(t==null?void 0:t.symbol)||"",e.networkPrice=s},async getMyTokensWithBalance(n){var s;const r=await o.BalanceUtil.getMyTokensWithBalance({forceUpdate:n,caipNetwork:o.ChainController.state.activeCaipNetwork,address:(s=o.ChainController.getAccountData())==null?void 0:s.address}),t=o.SwapApiUtil.mapBalancesToSwapTokens(r);t&&(await a.getInitialGasPrice(),a.setBalances(t))},setBalances(n){const{networkAddress:r}=a.getParams(),t=o.ChainController.state.activeCaipNetwork;if(!t)return;const s=n.find(l=>l.address===r);n.forEach(l=>{e.tokensPriceMap[l.address]=l.price||0}),e.myTokensWithBalance=n.filter(l=>l.address.startsWith(t.caipNetworkId)),e.networkBalanceInUSD=s?o.NumberUtil.multiply(s.quantity.numeric,s.price).toString():"0"},async getInitialGasPrice(){var r,t;const n=await o.SwapApiUtil.fetchGasPrice();if(!n)return{gasPrice:null,gasPriceInUSD:null};switch((t=(r=o.ChainController.state)==null?void 0:r.activeCaipNetwork)==null?void 0:t.chainNamespace){case o.ConstantsUtil.CHAIN.SOLANA:return e.gasFee=n.standard??"0",e.gasPriceInUSD=o.NumberUtil.multiply(n.standard,e.networkPrice).div(1e9).toNumber(),{gasPrice:BigInt(e.gasFee),gasPriceInUSD:Number(e.gasPriceInUSD)};case o.ConstantsUtil.CHAIN.EVM:default:const s=n.standard??"0",l=BigInt(s),i=BigInt(N),d=A.getGasPriceInUSD(e.networkPrice,i,l);return e.gasFee=s,e.gasPriceInUSD=d,{gasPrice:l,gasPriceInUSD:d}}},async swapTokens(){var i,d,k;const n=(i=o.ChainController.getAccountData())==null?void 0:i.address,r=e.sourceToken,t=e.toToken,s=o.NumberUtil.bigNumber(e.sourceTokenAmount).gt(0);if(s||a.setToTokenAmount(""),!t||!r||e.loadingPrices||!s||!n)return;e.loadingQuote=!0;const l=o.NumberUtil.bigNumber(e.sourceTokenAmount).times(10**r.decimals).round(0);try{const c=await o.BlockchainApiController.fetchSwapQuote({userAddress:n,from:r.address,to:t.address,gasPrice:e.gasFee,amount:l.toString()});e.loadingQuote=!1;const u=(k=(d=c==null?void 0:c.quotes)==null?void 0:d[0])==null?void 0:k.toAmount;if(!u){o.AlertController.open({displayMessage:"Incorrect amount",debugMessage:"Please enter a valid amount"},"error");return}const p=o.NumberUtil.bigNumber(u).div(10**t.decimals).toString();a.setToTokenAmount(p),a.hasInsufficientToken(e.sourceTokenAmount,r.address)?e.inputError="Insufficient balance":(e.inputError=void 0,a.setTransactionDetails())}catch(c){const u=await o.SwapApiUtil.handleSwapError(c);e.loadingQuote=!1,e.inputError=u||"Insufficient balance"}},async getTransaction(){const{fromCaipAddress:n,availableToSwap:r}=a.getParams(),t=e.sourceToken,s=e.toToken;if(!(!n||!r||!t||!s||e.loadingQuote))try{e.loadingBuildTransaction=!0;const l=await o.SwapApiUtil.fetchSwapAllowance({userAddress:n,tokenAddress:t.address,sourceTokenAmount:e.sourceTokenAmount,sourceTokenDecimals:t.decimals});let i;return l?i=await a.createSwapTransaction():i=await a.createAllowanceTransaction(),e.loadingBuildTransaction=!1,e.fetchError=!1,i}catch{o.RouterController.goBack(),o.SnackController.showError("Failed to check allowance"),e.loadingBuildTransaction=!1,e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}},async createAllowanceTransaction(){const{fromCaipAddress:n,sourceTokenAddress:r,toTokenAddress:t}=a.getParams();if(!(!n||!t)){if(!r)throw new Error("createAllowanceTransaction - No source token address found.");try{const s=await o.BlockchainApiController.generateApproveCalldata({from:r,to:t,userAddress:n}),l=o.CoreHelperUtil.getPlainAddress(s.tx.from);if(!l)throw new Error("SwapController:createAllowanceTransaction - address is required");const i={data:s.tx.data,to:l,gasPrice:BigInt(s.tx.eip155.gasPrice),value:BigInt(s.tx.value),toAmount:e.toTokenAmount};return e.swapTransaction=void 0,e.approvalTransaction={data:i.data,to:i.to,gasPrice:i.gasPrice,value:i.value,toAmount:i.toAmount},{data:i.data,to:i.to,gasPrice:i.gasPrice,value:i.value,toAmount:i.toAmount}}catch{o.RouterController.goBack(),o.SnackController.showError("Failed to create approval transaction"),e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}}},async createSwapTransaction(){var d;const{networkAddress:n,fromCaipAddress:r,sourceTokenAmount:t}=a.getParams(),s=e.sourceToken,l=e.toToken;if(!r||!t||!s||!l)return;const i=(d=o.ConnectionController.parseUnits(t,s.decimals))==null?void 0:d.toString();try{const k=await o.BlockchainApiController.generateSwapCalldata({userAddress:r,from:s.address,to:l.address,amount:i,disableEstimate:!0}),c=s.address===n,u=BigInt(k.tx.eip155.gas),p=BigInt(k.tx.eip155.gasPrice),g=o.CoreHelperUtil.getPlainAddress(k.tx.to);if(!g)throw new Error("SwapController:createSwapTransaction - address is required");const w={data:k.tx.data,to:g,gas:u,gasPrice:p,value:BigInt(c?i??"0":"0"),toAmount:e.toTokenAmount};return e.gasPriceInUSD=A.getGasPriceInUSD(e.networkPrice,u,p),e.approvalTransaction=void 0,e.swapTransaction=w,w}catch{o.RouterController.goBack(),o.SnackController.showError("Failed to create transaction"),e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}},onEmbeddedWalletApprovalSuccess(){o.SnackController.showLoading("Approve limit increase in your wallet"),o.RouterController.replace("SwapPreview")},async sendTransactionForApproval(n){var l,i,d;const{fromAddress:r,isAuthConnector:t}=a.getParams();e.loadingApprovalTransaction=!0,t?o.RouterController.pushTransactionStack({onSuccess:a.onEmbeddedWalletApprovalSuccess}):o.SnackController.showLoading("Approve limit increase in your wallet");try{await o.ConnectionController.sendTransaction({address:r,to:n.to,data:n.data,value:n.value,chainNamespace:o.ConstantsUtil.CHAIN.EVM}),await a.swapTokens(),await a.getTransaction(),e.approvalTransaction=void 0,e.loadingApprovalTransaction=!1}catch(k){const c=k;e.transactionError=c==null?void 0:c.displayMessage,e.loadingApprovalTransaction=!1,o.SnackController.showError((c==null?void 0:c.displayMessage)||"Transaction error"),o.EventsController.sendEvent({type:"track",event:"SWAP_APPROVAL_ERROR",properties:{message:(c==null?void 0:c.displayMessage)||(c==null?void 0:c.message)||"Unknown",network:((l=o.ChainController.state.activeCaipNetwork)==null?void 0:l.caipNetworkId)||"",swapFromToken:((i=a.state.sourceToken)==null?void 0:i.symbol)||"",swapToToken:((d=a.state.toToken)==null?void 0:d.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:o.getPreferredAccountType(o.ConstantsUtil.CHAIN.EVM)===o.W3mFrameRpcConstants.ACCOUNT_TYPES.SMART_ACCOUNT}})}},async sendTransactionForSwap(n){var d,k,c,u,p,g,w,f,S,C,P,b;if(!n)return;const{fromAddress:r,toTokenAmount:t,isAuthConnector:s}=a.getParams();e.loadingTransaction=!0;const l=`Swapping ${(d=e.sourceToken)==null?void 0:d.symbol} to ${o.NumberUtil.formatNumberToLocalString(t,3)} ${(k=e.toToken)==null?void 0:k.symbol}`,i=`Swapped ${(c=e.sourceToken)==null?void 0:c.symbol} to ${o.NumberUtil.formatNumberToLocalString(t,3)} ${(u=e.toToken)==null?void 0:u.symbol}`;s?o.RouterController.pushTransactionStack({onSuccess(){o.RouterController.replace("Account"),o.SnackController.showLoading(l),h.resetState()}}):o.SnackController.showLoading("Confirm transaction in your wallet");try{const I=[(p=e.sourceToken)==null?void 0:p.address,(g=e.toToken)==null?void 0:g.address].join(","),m=await o.ConnectionController.sendTransaction({address:r,to:n.to,data:n.data,value:n.value,chainNamespace:o.ConstantsUtil.CHAIN.EVM});return e.loadingTransaction=!1,o.SnackController.showSuccess(i),o.EventsController.sendEvent({type:"track",event:"SWAP_SUCCESS",properties:{network:((w=o.ChainController.state.activeCaipNetwork)==null?void 0:w.caipNetworkId)||"",swapFromToken:((f=a.state.sourceToken)==null?void 0:f.symbol)||"",swapToToken:((S=a.state.toToken)==null?void 0:S.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:o.getPreferredAccountType(o.ConstantsUtil.CHAIN.EVM)===o.W3mFrameRpcConstants.ACCOUNT_TYPES.SMART_ACCOUNT}}),h.resetState(),s||o.RouterController.replace("Account"),h.getMyTokensWithBalance(I),m}catch(I){const m=I;e.transactionError=m==null?void 0:m.displayMessage,e.loadingTransaction=!1,o.SnackController.showError((m==null?void 0:m.displayMessage)||"Transaction error"),o.EventsController.sendEvent({type:"track",event:"SWAP_ERROR",properties:{message:(m==null?void 0:m.displayMessage)||(m==null?void 0:m.message)||"Unknown",network:((C=o.ChainController.state.activeCaipNetwork)==null?void 0:C.caipNetworkId)||"",swapFromToken:((P=a.state.sourceToken)==null?void 0:P.symbol)||"",swapToToken:((b=a.state.toToken)==null?void 0:b.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:o.getPreferredAccountType(o.ConstantsUtil.CHAIN.EVM)===o.W3mFrameRpcConstants.ACCOUNT_TYPES.SMART_ACCOUNT}});return}},hasInsufficientToken(n,r){return A.isInsufficientSourceTokenForSwap(n,r,e.myTokensWithBalance)},setTransactionDetails(){const{toTokenAddress:n,toTokenDecimals:r}=a.getParams();!n||!r||(e.gasPriceInUSD=A.getGasPriceInUSD(e.networkPrice,BigInt(e.gasFee),BigInt(N)),e.priceImpact=A.getPriceImpact({sourceTokenAmount:e.sourceTokenAmount,sourceTokenPriceInUSD:e.sourceTokenPriceInUSD,toTokenPriceInUSD:e.toTokenPriceInUSD,toTokenAmount:e.toTokenAmount}),e.maxSlippage=A.getMaxSlippage(e.slippage,e.toTokenAmount),e.providerFee=A.getProviderFee(e.sourceTokenAmount))}},a=o.withErrorBoundary(h);exports.SwapController=a;
1
+ "use strict";const o=require("./index-BhaYgUya.js"),A={getGasPriceInEther(n,r){const t=r*n;return Number(t)/1e18},getGasPriceInUSD(n,r,t){const s=A.getGasPriceInEther(r,t);return o.NumberUtil.bigNumber(n).times(s).toNumber()},getPriceImpact({sourceTokenAmount:n,sourceTokenPriceInUSD:r,toTokenPriceInUSD:t,toTokenAmount:s}){const l=o.NumberUtil.bigNumber(n).times(r),i=o.NumberUtil.bigNumber(s).times(t);return l.minus(i).div(l).times(100).toNumber()},getMaxSlippage(n,r){const t=o.NumberUtil.bigNumber(n).div(100);return o.NumberUtil.multiply(r,t).toNumber()},getProviderFee(n,r=.0085){return o.NumberUtil.bigNumber(n).times(r).toString()},isInsufficientNetworkTokenForGas(n,r){const t=r||"0";return o.NumberUtil.bigNumber(n).eq(0)?!0:o.NumberUtil.bigNumber(o.NumberUtil.bigNumber(t)).gt(n)},isInsufficientSourceTokenForSwap(n,r,t){var i,d;const s=(d=(i=t==null?void 0:t.find(k=>k.address===r))==null?void 0:i.quantity)==null?void 0:d.numeric;return o.NumberUtil.bigNumber(s||"0").lt(n)}},N=15e4,y=6,T={initializing:!1,initialized:!1,loadingPrices:!1,loadingQuote:!1,loadingApprovalTransaction:!1,loadingBuildTransaction:!1,loadingTransaction:!1,switchingTokens:!1,fetchError:!1,approvalTransaction:void 0,swapTransaction:void 0,transactionError:void 0,sourceToken:void 0,sourceTokenAmount:"",sourceTokenPriceInUSD:0,toToken:void 0,toTokenAmount:"",toTokenPriceInUSD:0,networkPrice:"0",networkBalanceInUSD:"0",networkTokenSymbol:"",inputError:void 0,slippage:o.ConstantsUtil$1.CONVERT_SLIPPAGE_TOLERANCE,tokens:void 0,popularTokens:void 0,suggestedTokens:void 0,foundTokens:void 0,myTokensWithBalance:void 0,tokensPriceMap:{},gasFee:"0",gasPriceInUSD:0,priceImpact:void 0,maxSlippage:void 0,providerFee:void 0},e=o.proxy({...T}),h={state:e,subscribe(n){return o.subscribe(e,()=>n(e))},subscribeKey(n,r){return o.subscribeKey(e,n,r)},getParams(){var c,u,p,g,w,f,S,C,P;const n=o.ChainController.state.activeChain,r=((c=o.ChainController.getAccountData(n))==null?void 0:c.caipAddress)??o.ChainController.state.activeCaipAddress,t=o.CoreHelperUtil.getPlainAddress(r),s=o.getActiveNetworkTokenAddress(),l=o.ConnectorController.getConnectorId(o.ChainController.state.activeChain);if(!t)throw new Error("No address found to swap the tokens from.");const i=!((u=e.toToken)!=null&&u.address)||!((p=e.toToken)!=null&&p.decimals),d=!((g=e.sourceToken)!=null&&g.address)||!((w=e.sourceToken)!=null&&w.decimals)||!o.NumberUtil.bigNumber(e.sourceTokenAmount).gt(0),k=!e.sourceTokenAmount;return{networkAddress:s,fromAddress:t,fromCaipAddress:r,sourceTokenAddress:(f=e.sourceToken)==null?void 0:f.address,toTokenAddress:(S=e.toToken)==null?void 0:S.address,toTokenAmount:e.toTokenAmount,toTokenDecimals:(C=e.toToken)==null?void 0:C.decimals,sourceTokenAmount:e.sourceTokenAmount,sourceTokenDecimals:(P=e.sourceToken)==null?void 0:P.decimals,invalidToToken:i,invalidSourceToken:d,invalidSourceTokenAmount:k,availableToSwap:r&&!i&&!d&&!k,isAuthConnector:l===o.ConstantsUtil.CONNECTOR_ID.AUTH}},async setSourceToken(n){if(!n){e.sourceToken=n,e.sourceTokenAmount="",e.sourceTokenPriceInUSD=0;return}e.sourceToken=n,await a.setTokenPrice(n.address,"sourceToken")},setSourceTokenAmount(n){e.sourceTokenAmount=n},async setToToken(n){if(!n){e.toToken=n,e.toTokenAmount="",e.toTokenPriceInUSD=0;return}e.toToken=n,await a.setTokenPrice(n.address,"toToken")},setToTokenAmount(n){e.toTokenAmount=n?o.NumberUtil.toFixed(n,y):""},async setTokenPrice(n,r){let t=e.tokensPriceMap[n]||0;t||(e.loadingPrices=!0,t=await a.getAddressPrice(n)),r==="sourceToken"?e.sourceTokenPriceInUSD=t:r==="toToken"&&(e.toTokenPriceInUSD=t),e.loadingPrices&&(e.loadingPrices=!1),a.getParams().availableToSwap&&!e.switchingTokens&&a.swapTokens()},async switchTokens(){if(!(e.initializing||!e.initialized||e.switchingTokens)){e.switchingTokens=!0;try{const n=e.toToken?{...e.toToken}:void 0,r=e.sourceToken?{...e.sourceToken}:void 0,t=n&&e.toTokenAmount===""?"1":e.toTokenAmount;a.setSourceTokenAmount(t),a.setToTokenAmount(""),await a.setSourceToken(n),await a.setToToken(r),e.switchingTokens=!1,a.swapTokens()}catch(n){throw e.switchingTokens=!1,n}}},resetState(){e.myTokensWithBalance=T.myTokensWithBalance,e.tokensPriceMap=T.tokensPriceMap,e.initialized=T.initialized,e.initializing=T.initializing,e.switchingTokens=T.switchingTokens,e.sourceToken=T.sourceToken,e.sourceTokenAmount=T.sourceTokenAmount,e.sourceTokenPriceInUSD=T.sourceTokenPriceInUSD,e.toToken=T.toToken,e.toTokenAmount=T.toTokenAmount,e.toTokenPriceInUSD=T.toTokenPriceInUSD,e.networkPrice=T.networkPrice,e.networkTokenSymbol=T.networkTokenSymbol,e.networkBalanceInUSD=T.networkBalanceInUSD,e.inputError=T.inputError},resetValues(){var t;const{networkAddress:n}=a.getParams(),r=(t=e.tokens)==null?void 0:t.find(s=>s.address===n);a.setSourceToken(r),a.setToToken(void 0)},getApprovalLoadingState(){return e.loadingApprovalTransaction},clearError(){e.transactionError=void 0},async initializeState(){if(!e.initializing){if(e.initializing=!0,!e.initialized)try{await a.fetchTokens(),e.initialized=!0}catch{e.initialized=!1,o.SnackController.showError("Failed to initialize swap"),o.RouterController.goBack()}e.initializing=!1}},async fetchTokens(){var t;const{networkAddress:n}=a.getParams();await a.getNetworkTokenPrice(),await a.getMyTokensWithBalance();const r=(t=e.myTokensWithBalance)==null?void 0:t.find(s=>s.address===n);r&&(e.networkTokenSymbol=r.symbol,a.setSourceToken(r),a.setSourceTokenAmount("0"))},async getTokenList(){var r,t;const n=(r=o.ChainController.state.activeCaipNetwork)==null?void 0:r.caipNetworkId;if(!(e.caipNetworkId===n&&e.tokens))try{e.tokensLoading=!0;const s=await o.SwapApiUtil.getTokenList(n);e.tokens=s,e.caipNetworkId=n,e.popularTokens=s.sort((c,u)=>c.symbol<u.symbol?-1:c.symbol>u.symbol?1:0);const i=(n&&((t=o.ConstantsUtil$1.SUGGESTED_TOKENS_BY_CHAIN)==null?void 0:t[n])||[]).map(c=>s.find(u=>u.symbol===c)).filter(c=>!!c),k=(o.ConstantsUtil$1.SWAP_SUGGESTED_TOKENS||[]).map(c=>s.find(u=>u.symbol===c)).filter(c=>!!c).filter(c=>!i.some(u=>u.address===c.address));e.suggestedTokens=[...i,...k]}catch{e.tokens=[],e.popularTokens=[],e.suggestedTokens=[]}finally{e.tokensLoading=!1}},async getAddressPrice(n){var c,u;const r=e.tokensPriceMap[n];if(r)return r;const t=await o.BlockchainApiController.fetchTokenPrice({addresses:[n]}),s=(t==null?void 0:t.fungibles)||[],l=[...e.tokens||[],...e.myTokensWithBalance||[]],i=(c=l==null?void 0:l.find(p=>p.address===n))==null?void 0:c.symbol,d=((u=s.find(p=>p.symbol.toLowerCase()===(i==null?void 0:i.toLowerCase())))==null?void 0:u.price)||0,k=parseFloat(d.toString());return e.tokensPriceMap[n]=k,k},async getNetworkTokenPrice(){var l;const{networkAddress:n}=a.getParams(),t=(l=(await o.BlockchainApiController.fetchTokenPrice({addresses:[n]}).catch(()=>(o.SnackController.showError("Failed to fetch network token price"),{fungibles:[]}))).fungibles)==null?void 0:l[0],s=(t==null?void 0:t.price.toString())||"0";e.tokensPriceMap[n]=parseFloat(s),e.networkTokenSymbol=(t==null?void 0:t.symbol)||"",e.networkPrice=s},async getMyTokensWithBalance(n){var s;const r=await o.BalanceUtil.getMyTokensWithBalance({forceUpdate:n,caipNetwork:o.ChainController.state.activeCaipNetwork,address:(s=o.ChainController.getAccountData())==null?void 0:s.address}),t=o.SwapApiUtil.mapBalancesToSwapTokens(r);t&&(await a.getInitialGasPrice(),a.setBalances(t))},setBalances(n){const{networkAddress:r}=a.getParams(),t=o.ChainController.state.activeCaipNetwork;if(!t)return;const s=n.find(l=>l.address===r);n.forEach(l=>{e.tokensPriceMap[l.address]=l.price||0}),e.myTokensWithBalance=n.filter(l=>l.address.startsWith(t.caipNetworkId)),e.networkBalanceInUSD=s?o.NumberUtil.multiply(s.quantity.numeric,s.price).toString():"0"},async getInitialGasPrice(){var r,t;const n=await o.SwapApiUtil.fetchGasPrice();if(!n)return{gasPrice:null,gasPriceInUSD:null};switch((t=(r=o.ChainController.state)==null?void 0:r.activeCaipNetwork)==null?void 0:t.chainNamespace){case o.ConstantsUtil.CHAIN.SOLANA:return e.gasFee=n.standard??"0",e.gasPriceInUSD=o.NumberUtil.multiply(n.standard,e.networkPrice).div(1e9).toNumber(),{gasPrice:BigInt(e.gasFee),gasPriceInUSD:Number(e.gasPriceInUSD)};case o.ConstantsUtil.CHAIN.EVM:default:const s=n.standard??"0",l=BigInt(s),i=BigInt(N),d=A.getGasPriceInUSD(e.networkPrice,i,l);return e.gasFee=s,e.gasPriceInUSD=d,{gasPrice:l,gasPriceInUSD:d}}},async swapTokens(){var i,d,k;const n=(i=o.ChainController.getAccountData())==null?void 0:i.address,r=e.sourceToken,t=e.toToken,s=o.NumberUtil.bigNumber(e.sourceTokenAmount).gt(0);if(s||a.setToTokenAmount(""),!t||!r||e.loadingPrices||!s||!n)return;e.loadingQuote=!0;const l=o.NumberUtil.bigNumber(e.sourceTokenAmount).times(10**r.decimals).round(0);try{const c=await o.BlockchainApiController.fetchSwapQuote({userAddress:n,from:r.address,to:t.address,gasPrice:e.gasFee,amount:l.toString()});e.loadingQuote=!1;const u=(k=(d=c==null?void 0:c.quotes)==null?void 0:d[0])==null?void 0:k.toAmount;if(!u){o.AlertController.open({displayMessage:"Incorrect amount",debugMessage:"Please enter a valid amount"},"error");return}const p=o.NumberUtil.bigNumber(u).div(10**t.decimals).toString();a.setToTokenAmount(p),a.hasInsufficientToken(e.sourceTokenAmount,r.address)?e.inputError="Insufficient balance":(e.inputError=void 0,a.setTransactionDetails())}catch(c){const u=await o.SwapApiUtil.handleSwapError(c);e.loadingQuote=!1,e.inputError=u||"Insufficient balance"}},async getTransaction(){const{fromCaipAddress:n,availableToSwap:r}=a.getParams(),t=e.sourceToken,s=e.toToken;if(!(!n||!r||!t||!s||e.loadingQuote))try{e.loadingBuildTransaction=!0;const l=await o.SwapApiUtil.fetchSwapAllowance({userAddress:n,tokenAddress:t.address,sourceTokenAmount:e.sourceTokenAmount,sourceTokenDecimals:t.decimals});let i;return l?i=await a.createSwapTransaction():i=await a.createAllowanceTransaction(),e.loadingBuildTransaction=!1,e.fetchError=!1,i}catch{o.RouterController.goBack(),o.SnackController.showError("Failed to check allowance"),e.loadingBuildTransaction=!1,e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}},async createAllowanceTransaction(){const{fromCaipAddress:n,sourceTokenAddress:r,toTokenAddress:t}=a.getParams();if(!(!n||!t)){if(!r)throw new Error("createAllowanceTransaction - No source token address found.");try{const s=await o.BlockchainApiController.generateApproveCalldata({from:r,to:t,userAddress:n}),l=o.CoreHelperUtil.getPlainAddress(s.tx.from);if(!l)throw new Error("SwapController:createAllowanceTransaction - address is required");const i={data:s.tx.data,to:l,gasPrice:BigInt(s.tx.eip155.gasPrice),value:BigInt(s.tx.value),toAmount:e.toTokenAmount};return e.swapTransaction=void 0,e.approvalTransaction={data:i.data,to:i.to,gasPrice:i.gasPrice,value:i.value,toAmount:i.toAmount},{data:i.data,to:i.to,gasPrice:i.gasPrice,value:i.value,toAmount:i.toAmount}}catch{o.RouterController.goBack(),o.SnackController.showError("Failed to create approval transaction"),e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}}},async createSwapTransaction(){var d;const{networkAddress:n,fromCaipAddress:r,sourceTokenAmount:t}=a.getParams(),s=e.sourceToken,l=e.toToken;if(!r||!t||!s||!l)return;const i=(d=o.ConnectionController.parseUnits(t,s.decimals))==null?void 0:d.toString();try{const k=await o.BlockchainApiController.generateSwapCalldata({userAddress:r,from:s.address,to:l.address,amount:i,disableEstimate:!0}),c=s.address===n,u=BigInt(k.tx.eip155.gas),p=BigInt(k.tx.eip155.gasPrice),g=o.CoreHelperUtil.getPlainAddress(k.tx.to);if(!g)throw new Error("SwapController:createSwapTransaction - address is required");const w={data:k.tx.data,to:g,gas:u,gasPrice:p,value:BigInt(c?i??"0":"0"),toAmount:e.toTokenAmount};return e.gasPriceInUSD=A.getGasPriceInUSD(e.networkPrice,u,p),e.approvalTransaction=void 0,e.swapTransaction=w,w}catch{o.RouterController.goBack(),o.SnackController.showError("Failed to create transaction"),e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}},onEmbeddedWalletApprovalSuccess(){o.SnackController.showLoading("Approve limit increase in your wallet"),o.RouterController.replace("SwapPreview")},async sendTransactionForApproval(n){var l,i,d;const{fromAddress:r,isAuthConnector:t}=a.getParams();e.loadingApprovalTransaction=!0,t?o.RouterController.pushTransactionStack({onSuccess:a.onEmbeddedWalletApprovalSuccess}):o.SnackController.showLoading("Approve limit increase in your wallet");try{await o.ConnectionController.sendTransaction({address:r,to:n.to,data:n.data,value:n.value,chainNamespace:o.ConstantsUtil.CHAIN.EVM}),await a.swapTokens(),await a.getTransaction(),e.approvalTransaction=void 0,e.loadingApprovalTransaction=!1}catch(k){const c=k;e.transactionError=c==null?void 0:c.displayMessage,e.loadingApprovalTransaction=!1,o.SnackController.showError((c==null?void 0:c.displayMessage)||"Transaction error"),o.EventsController.sendEvent({type:"track",event:"SWAP_APPROVAL_ERROR",properties:{message:(c==null?void 0:c.displayMessage)||(c==null?void 0:c.message)||"Unknown",network:((l=o.ChainController.state.activeCaipNetwork)==null?void 0:l.caipNetworkId)||"",swapFromToken:((i=a.state.sourceToken)==null?void 0:i.symbol)||"",swapToToken:((d=a.state.toToken)==null?void 0:d.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:o.getPreferredAccountType(o.ConstantsUtil.CHAIN.EVM)===o.W3mFrameRpcConstants.ACCOUNT_TYPES.SMART_ACCOUNT}})}},async sendTransactionForSwap(n){var d,k,c,u,p,g,w,f,S,C,P,b;if(!n)return;const{fromAddress:r,toTokenAmount:t,isAuthConnector:s}=a.getParams();e.loadingTransaction=!0;const l=`Swapping ${(d=e.sourceToken)==null?void 0:d.symbol} to ${o.NumberUtil.formatNumberToLocalString(t,3)} ${(k=e.toToken)==null?void 0:k.symbol}`,i=`Swapped ${(c=e.sourceToken)==null?void 0:c.symbol} to ${o.NumberUtil.formatNumberToLocalString(t,3)} ${(u=e.toToken)==null?void 0:u.symbol}`;s?o.RouterController.pushTransactionStack({onSuccess(){o.RouterController.replace("Account"),o.SnackController.showLoading(l),h.resetState()}}):o.SnackController.showLoading("Confirm transaction in your wallet");try{const I=[(p=e.sourceToken)==null?void 0:p.address,(g=e.toToken)==null?void 0:g.address].join(","),m=await o.ConnectionController.sendTransaction({address:r,to:n.to,data:n.data,value:n.value,chainNamespace:o.ConstantsUtil.CHAIN.EVM});return e.loadingTransaction=!1,o.SnackController.showSuccess(i),o.EventsController.sendEvent({type:"track",event:"SWAP_SUCCESS",properties:{network:((w=o.ChainController.state.activeCaipNetwork)==null?void 0:w.caipNetworkId)||"",swapFromToken:((f=a.state.sourceToken)==null?void 0:f.symbol)||"",swapToToken:((S=a.state.toToken)==null?void 0:S.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:o.getPreferredAccountType(o.ConstantsUtil.CHAIN.EVM)===o.W3mFrameRpcConstants.ACCOUNT_TYPES.SMART_ACCOUNT}}),h.resetState(),s||o.RouterController.replace("Account"),h.getMyTokensWithBalance(I),m}catch(I){const m=I;e.transactionError=m==null?void 0:m.displayMessage,e.loadingTransaction=!1,o.SnackController.showError((m==null?void 0:m.displayMessage)||"Transaction error"),o.EventsController.sendEvent({type:"track",event:"SWAP_ERROR",properties:{message:(m==null?void 0:m.displayMessage)||(m==null?void 0:m.message)||"Unknown",network:((C=o.ChainController.state.activeCaipNetwork)==null?void 0:C.caipNetworkId)||"",swapFromToken:((P=a.state.sourceToken)==null?void 0:P.symbol)||"",swapToToken:((b=a.state.toToken)==null?void 0:b.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:o.getPreferredAccountType(o.ConstantsUtil.CHAIN.EVM)===o.W3mFrameRpcConstants.ACCOUNT_TYPES.SMART_ACCOUNT}});return}},hasInsufficientToken(n,r){return A.isInsufficientSourceTokenForSwap(n,r,e.myTokensWithBalance)},setTransactionDetails(){const{toTokenAddress:n,toTokenDecimals:r}=a.getParams();!n||!r||(e.gasPriceInUSD=A.getGasPriceInUSD(e.networkPrice,BigInt(e.gasFee),BigInt(N)),e.priceImpact=A.getPriceImpact({sourceTokenAmount:e.sourceTokenAmount,sourceTokenPriceInUSD:e.sourceTokenPriceInUSD,toTokenPriceInUSD:e.toTokenPriceInUSD,toTokenAmount:e.toTokenAmount}),e.maxSlippage=A.getMaxSlippage(e.slippage,e.toTokenAmount),e.providerFee=A.getProviderFee(e.sourceTokenAmount))}},a=o.withErrorBoundary(h);exports.SwapController=a;
@@ -1,5 +1,5 @@
1
- import { a1 as g, ab as k, aS as L, aT as O, aU as E } from "./parseSignature-BopOK20t.mjs";
2
- import { ad as p, cr as y, bM as w, ba as x, b3 as R, aw as m, bd as M } from "./index-BKdw_1qM.mjs";
1
+ import { a1 as g, ab as k, aS as L, aT as O, aU as E } from "./parseSignature-zKnspnY-.mjs";
2
+ import { ad as p, cr as y, bM as w, ba as x, b3 as R, aw as m, bd as M } from "./index-CFLg0HEy.mjs";
3
3
  class S extends p {
4
4
  constructor({ callbackSelector: r, cause: a, data: n, extraData: i, sender: f, urls: t }) {
5
5
  var o;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./parseSignature-USiYfXGb.js"),s=require("./index-BTAZoMiJ.js");class k extends s.BaseError{constructor({callbackSelector:o,cause:t,data:c,extraData:u,sender:d,urls:a}){var n;super(t.shortMessage||"An error occurred while fetching for an offchain result.",{cause:t,metaMessages:[...t.metaMessages||[],(n=t.metaMessages)!=null&&n.length?"":[],"Offchain Gateway Call:",a&&[" Gateway URL(s):",...a.map(f=>` ${s.getUrl(f)}`)],` Sender: ${d}`,` Data: ${c}`,` Callback selector: ${o}`,` Extra data: ${u}`].flat(),name:"OffchainLookupError"})}}class b extends s.BaseError{constructor({result:o,url:t}){super("Offchain gateway response is malformed. Response data must be a hex value.",{metaMessages:[`Gateway URL: ${s.getUrl(t)}`,`Response: ${s.stringify(o)}`],name:"OffchainLookupResponseMalformedError"})}}class L extends s.BaseError{constructor({sender:o,to:t}){super("Reverted sender address does not match target contract address (`to`).",{metaMessages:[`Contract address: ${t}`,`OffchainLookup sender address: ${o}`],name:"OffchainLookupSenderMismatchError"})}}const E="0x556f1830",m={name:"OffchainLookup",type:"error",inputs:[{name:"sender",type:"address"},{name:"urls",type:"string[]"},{name:"callData",type:"bytes"},{name:"callbackFunction",type:"bytes4"},{name:"extraData",type:"bytes"}]};async function O(i,{blockNumber:o,blockTag:t,data:c,to:u}){const{args:d}=l.decodeErrorResult({data:c,abi:[m]}),[a,n,f,p,r]=d,{ccipRead:e}=i,y=e&&typeof(e==null?void 0:e.request)=="function"?e.request:g;try{if(!l.isAddressEqual(u,a))throw new L({sender:a,to:u});const h=n.includes(l.localBatchGatewayUrl)?await l.localBatchGatewayRequest({data:f,ccipRequest:y}):await y({data:f,sender:a,urls:n}),{data:w}=await l.call(i,{blockNumber:o,blockTag:t,data:s.concat([p,s.encodeAbiParameters([{type:"bytes"},{type:"bytes"}],[h,r])]),to:u});return w}catch(h){throw new k({callbackSelector:p,cause:h,data:c,extraData:r,sender:a,urls:n})}}async function g({data:i,sender:o,urls:t}){var u;let c=new Error("An unknown error occurred.");for(let d=0;d<t.length;d++){const a=t[d],n=a.includes("{data}")?"GET":"POST",f=n==="POST"?{data:i,sender:o}:void 0,p=n==="POST"?{"Content-Type":"application/json"}:{};try{const r=await fetch(a.replace("{sender}",o.toLowerCase()).replace("{data}",i),{body:JSON.stringify(f),headers:p,method:n});let e;if((u=r.headers.get("Content-Type"))!=null&&u.startsWith("application/json")?e=(await r.json()).data:e=await r.text(),!r.ok){c=new s.HttpRequestError({body:f,details:e!=null&&e.error?s.stringify(e.error):r.statusText,headers:r.headers,status:r.status,url:a});continue}if(!s.isHex(e)){c=new b({result:e,url:a});continue}return e}catch(r){c=new s.HttpRequestError({body:f,details:r.message,url:a})}}throw c}exports.ccipRequest=g;exports.offchainLookup=O;exports.offchainLookupAbiItem=m;exports.offchainLookupSignature=E;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./parseSignature-jZAFls5F.js"),s=require("./index-BhaYgUya.js");class k extends s.BaseError{constructor({callbackSelector:o,cause:t,data:c,extraData:u,sender:d,urls:a}){var n;super(t.shortMessage||"An error occurred while fetching for an offchain result.",{cause:t,metaMessages:[...t.metaMessages||[],(n=t.metaMessages)!=null&&n.length?"":[],"Offchain Gateway Call:",a&&[" Gateway URL(s):",...a.map(f=>` ${s.getUrl(f)}`)],` Sender: ${d}`,` Data: ${c}`,` Callback selector: ${o}`,` Extra data: ${u}`].flat(),name:"OffchainLookupError"})}}class b extends s.BaseError{constructor({result:o,url:t}){super("Offchain gateway response is malformed. Response data must be a hex value.",{metaMessages:[`Gateway URL: ${s.getUrl(t)}`,`Response: ${s.stringify(o)}`],name:"OffchainLookupResponseMalformedError"})}}class L extends s.BaseError{constructor({sender:o,to:t}){super("Reverted sender address does not match target contract address (`to`).",{metaMessages:[`Contract address: ${t}`,`OffchainLookup sender address: ${o}`],name:"OffchainLookupSenderMismatchError"})}}const E="0x556f1830",m={name:"OffchainLookup",type:"error",inputs:[{name:"sender",type:"address"},{name:"urls",type:"string[]"},{name:"callData",type:"bytes"},{name:"callbackFunction",type:"bytes4"},{name:"extraData",type:"bytes"}]};async function O(i,{blockNumber:o,blockTag:t,data:c,to:u}){const{args:d}=l.decodeErrorResult({data:c,abi:[m]}),[a,n,f,p,r]=d,{ccipRead:e}=i,y=e&&typeof(e==null?void 0:e.request)=="function"?e.request:g;try{if(!l.isAddressEqual(u,a))throw new L({sender:a,to:u});const h=n.includes(l.localBatchGatewayUrl)?await l.localBatchGatewayRequest({data:f,ccipRequest:y}):await y({data:f,sender:a,urls:n}),{data:w}=await l.call(i,{blockNumber:o,blockTag:t,data:s.concat([p,s.encodeAbiParameters([{type:"bytes"},{type:"bytes"}],[h,r])]),to:u});return w}catch(h){throw new k({callbackSelector:p,cause:h,data:c,extraData:r,sender:a,urls:n})}}async function g({data:i,sender:o,urls:t}){var u;let c=new Error("An unknown error occurred.");for(let d=0;d<t.length;d++){const a=t[d],n=a.includes("{data}")?"GET":"POST",f=n==="POST"?{data:i,sender:o}:void 0,p=n==="POST"?{"Content-Type":"application/json"}:{};try{const r=await fetch(a.replace("{sender}",o.toLowerCase()).replace("{data}",i),{body:JSON.stringify(f),headers:p,method:n});let e;if((u=r.headers.get("Content-Type"))!=null&&u.startsWith("application/json")?e=(await r.json()).data:e=await r.text(),!r.ok){c=new s.HttpRequestError({body:f,details:e!=null&&e.error?s.stringify(e.error):r.statusText,headers:r.headers,status:r.status,url:a});continue}if(!s.isHex(e)){c=new b({result:e,url:a});continue}return e}catch(r){c=new s.HttpRequestError({body:f,details:r.message,url:a})}}throw c}exports.ccipRequest=g;exports.offchainLookup=O;exports.offchainLookupAbiItem=m;exports.offchainLookupSignature=E;
@@ -1,6 +1,6 @@
1
- import { c0 as y, bW as $, bX as l, bU as S, bV as x, cy as m, c4 as p, cb as f, c5 as h, cv as u, b$ as _, cp as E, cn as R } from "./index-BKdw_1qM.mjs";
2
- import { W as C } from "./index-CWqapSt6.mjs";
3
- import { R as v } from "./ReownAuthentication-BTdnSW4c.mjs";
1
+ import { c0 as y, bW as $, bX as l, bU as S, bV as x, cy as m, c4 as p, cb as f, c5 as h, cv as u, b$ as _, cp as E, cn as R } from "./index-CFLg0HEy.mjs";
2
+ import { W as C } from "./index-2WfSPp5U.mjs";
3
+ import { R as v } from "./ReownAuthentication-7iIT4jS4.mjs";
4
4
  const D = y`
5
5
  .email-sufixes {
6
6
  display: flex;
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-BTAZoMiJ.js"),d=require("./index-CEc0pV8L.js"),u=require("./ReownAuthentication-Bi7oHuGf.js"),g=e.i$1`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-BhaYgUya.js"),d=require("./index-CZuajWCC.js"),u=require("./ReownAuthentication-BEGlJitZ.js"),g=e.i$1`
2
2
  .email-sufixes {
3
3
  display: flex;
4
4
  flex-direction: row;
@@ -1,5 +1,5 @@
1
- import { cb as S, c6 as g, cy as p, c8 as c, cz as _, c4 as s, c5 as f, cd as b, bV as u, bR as D, bW as C, cj as d, bX as m, cv as E, c0 as W, bY as $, b_ as P, cA as N, c7 as T } from "./index-BKdw_1qM.mjs";
2
- import { W as y } from "./index-CWqapSt6.mjs";
1
+ import { cb as S, c6 as g, cy as p, c8 as c, cz as _, c4 as s, c5 as f, cd as b, bV as u, bR as D, bW as C, cj as d, bX as m, cv as E, c0 as W, bY as $, b_ as P, cA as N, c7 as T } from "./index-CFLg0HEy.mjs";
2
+ import { W as y } from "./index-2WfSPp5U.mjs";
3
3
  var j = function(a, e, t, r) {
4
4
  var n = arguments.length, i = n < 3 ? e : r === null ? r = Object.getOwnPropertyDescriptor(e, t) : r, o;
5
5
  if (typeof Reflect == "object" && typeof Reflect.decorate == "function") i = Reflect.decorate(a, e, t, r);
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-BTAZoMiJ.js"),c=require("./index-CEc0pV8L.js");var p=function(l,e,i,o){var n=arguments.length,r=n<3?e:o===null?o=Object.getOwnPropertyDescriptor(e,i):o,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(l,e,i,o);else for(var s=l.length-1;s>=0;s--)(a=l[s])&&(r=(n<3?a(r):n>3?a(e,i,r):a(e,i))||r);return n>3&&r&&Object.defineProperty(e,i,r),r};exports.W3mEmailVerifyOtpView=class extends c.W3mEmailOtpWidget{constructor(){super(...arguments),this.onOtpSubmit=async e=>{var i,o;try{if(this.authConnector){const n=t.ChainController.state.activeChain,r=t.ConnectionController.getConnections(n),a=(i=t.OptionsController.state.remoteFeatures)==null?void 0:i.multiWallet,s=r.length>0;if(await this.authConnector.provider.connectOtp({otp:e}),t.EventsController.sendEvent({type:"track",event:"EMAIL_VERIFICATION_CODE_PASS"}),n)await t.ConnectionController.connectExternal(this.authConnector,n);else throw new Error("Active chain is not set on ChainController");if((o=t.OptionsController.state.remoteFeatures)!=null&&o.emailCapture)return;if(t.OptionsController.state.siwx){t.ModalController.close();return}if(s&&a){t.RouterController.replace("ProfileWallets"),t.SnackController.showSuccess("New Wallet Added");return}t.ModalController.close()}}catch(n){throw t.EventsController.sendEvent({type:"track",event:"EMAIL_VERIFICATION_CODE_FAIL",properties:{message:t.CoreHelperUtil.parseError(n)}}),n}},this.onOtpResend=async e=>{this.authConnector&&(await this.authConnector.provider.connectEmail({email:e}),t.EventsController.sendEvent({type:"track",event:"EMAIL_VERIFICATION_CODE_SENT"}))}}};exports.W3mEmailVerifyOtpView=p([t.customElement("w3m-email-verify-otp-view")],exports.W3mEmailVerifyOtpView);const h=t.css`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-BhaYgUya.js"),c=require("./index-CZuajWCC.js");var p=function(l,e,i,o){var n=arguments.length,r=n<3?e:o===null?o=Object.getOwnPropertyDescriptor(e,i):o,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(l,e,i,o);else for(var s=l.length-1;s>=0;s--)(a=l[s])&&(r=(n<3?a(r):n>3?a(e,i,r):a(e,i))||r);return n>3&&r&&Object.defineProperty(e,i,r),r};exports.W3mEmailVerifyOtpView=class extends c.W3mEmailOtpWidget{constructor(){super(...arguments),this.onOtpSubmit=async e=>{var i,o;try{if(this.authConnector){const n=t.ChainController.state.activeChain,r=t.ConnectionController.getConnections(n),a=(i=t.OptionsController.state.remoteFeatures)==null?void 0:i.multiWallet,s=r.length>0;if(await this.authConnector.provider.connectOtp({otp:e}),t.EventsController.sendEvent({type:"track",event:"EMAIL_VERIFICATION_CODE_PASS"}),n)await t.ConnectionController.connectExternal(this.authConnector,n);else throw new Error("Active chain is not set on ChainController");if((o=t.OptionsController.state.remoteFeatures)!=null&&o.emailCapture)return;if(t.OptionsController.state.siwx){t.ModalController.close();return}if(s&&a){t.RouterController.replace("ProfileWallets"),t.SnackController.showSuccess("New Wallet Added");return}t.ModalController.close()}}catch(n){throw t.EventsController.sendEvent({type:"track",event:"EMAIL_VERIFICATION_CODE_FAIL",properties:{message:t.CoreHelperUtil.parseError(n)}}),n}},this.onOtpResend=async e=>{this.authConnector&&(await this.authConnector.provider.connectEmail({email:e}),t.EventsController.sendEvent({type:"track",event:"EMAIL_VERIFICATION_CODE_SENT"}))}}};exports.W3mEmailVerifyOtpView=p([t.customElement("w3m-email-verify-otp-view")],exports.W3mEmailVerifyOtpView);const h=t.css`
2
2
  wui-icon-box {
3
3
  height: ${({spacing:l})=>l[16]};
4
4
  width: ${({spacing:l})=>l[16]};
@@ -1,4 +1,4 @@
1
- import { c0 as H, bW as g, cz as W, cy as K, bX as c, cj as _, ct as j, cH as G, cv as d, bV as w, bR as E, bS as z, bT as B, bU as l, ch as N, cb as h, cI as V, c7 as k, c9 as C, ca as m, c6 as L, cJ as X, cu as q, bY as J, cK as v, cd as U, cL as O, b_ as Q, c8 as I, c5 as Z, cM as ee, c4 as te } from "./index-BKdw_1qM.mjs";
1
+ import { c0 as H, bW as g, cz as W, cy as K, bX as c, cj as _, ct as j, cH as G, cv as d, bV as w, bR as E, bS as z, bT as B, bU as l, ch as N, cb as h, cI as V, c7 as k, c9 as C, ca as m, c6 as L, cJ as X, cu as q, bY as J, cK as v, cd as U, cL as O, b_ as Q, c8 as I, c5 as Z, cM as ee, c4 as te } from "./index-CFLg0HEy.mjs";
2
2
  const ie = H`
3
3
  div {
4
4
  width: 100%;
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-BTAZoMiJ.js"),x=e.i$1`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-BhaYgUya.js"),x=e.i$1`
2
2
  div {
3
3
  width: 100%;
4
4
  }
@@ -1,4 +1,4 @@
1
- import { R as t, a as o } from "./ReownAuthentication-BTdnSW4c.mjs";
1
+ import { R as t, a as o } from "./ReownAuthentication-7iIT4jS4.mjs";
2
2
  export {
3
3
  t as ReownAuthentication,
4
4
  o as ReownAuthenticationMessenger
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./ReownAuthentication-Bi7oHuGf.js");exports.ReownAuthentication=e.ReownAuthentication;exports.ReownAuthenticationMessenger=e.ReownAuthenticationMessenger;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./ReownAuthentication-BEGlJitZ.js");exports.ReownAuthentication=e.ReownAuthentication;exports.ReownAuthenticationMessenger=e.ReownAuthenticationMessenger;
@@ -1,4 +1,4 @@
1
- import { bR as C, bS as O, bT as P, bU as h, bV as w, bW as v, bX as l, c0 as E, cv as d, b$ as x, cw as g, c4 as S, cj as $, cd as R, c5 as T } from "./index-BKdw_1qM.mjs";
1
+ import { bR as C, bS as O, bT as P, bU as h, bV as w, bW as v, bX as l, c0 as E, cv as d, b$ as x, cw as g, c4 as S, cj as $, cd as R, c5 as T } from "./index-CFLg0HEy.mjs";
2
2
  const L = C`
3
3
  :host {
4
4
  position: relative;
@@ -1,5 +1,5 @@
1
- import { P as t, A as m, a as d } from "./index-mid89FTV.mjs";
2
- import { b as z, c as B, W as G } from "./index-mid89FTV.mjs";
1
+ import { P as t, A as m, a as d } from "./index-CAtS1mbf.mjs";
2
+ import { b as z, c as B, W as G } from "./index-CAtS1mbf.mjs";
3
3
  const U = 3e5;
4
4
  async function E(e) {
5
5
  return t.handleOpenPay(e);
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-GJ5DCZOU.js"),P=3e5;async function u(t){return e.PayController.handleOpenPay(t)}async function D(t,s=P){if(s<=0)throw new e.AppKitPayError(e.AppKitPayErrorCodes.INVALID_PAYMENT_CONFIG,"Timeout must be greater than 0");try{await u(t)}catch(r){throw r instanceof e.AppKitPayError?r:new e.AppKitPayError(e.AppKitPayErrorCodes.UNABLE_TO_INITIATE_PAYMENT,r.message)}return new Promise((r,y)=>{let n=!1;const i=setTimeout(()=>{n||(n=!0,c(),y(new e.AppKitPayError(e.AppKitPayErrorCodes.GENERIC_PAYMENT_ERROR,"Payment timeout")))},s);function o(){if(n)return;const a=e.PayController.state.currentPayment,m=e.PayController.state.error,C=e.PayController.state.isPaymentInProgress;if((a==null?void 0:a.status)==="SUCCESS"){n=!0,c(),clearTimeout(i),r({success:!0,result:a.result});return}if((a==null?void 0:a.status)==="FAILED"){n=!0,c(),clearTimeout(i),r({success:!1,error:m||"Payment failed"});return}m&&!C&&!a&&(n=!0,c(),clearTimeout(i),r({success:!1,error:m}))}const d=l("currentPayment",o),b=l("error",o),S=l("isPaymentInProgress",o),c=f([d,b,S]);o()})}function p(){return e.PayController.getExchanges()}function U(){var t;return(t=e.PayController.state.currentPayment)==null?void 0:t.result}function E(){return e.PayController.state.error}function T(){return e.PayController.state.isPaymentInProgress}function l(t,s){return e.PayController.subscribeKey(t,s)}function f(t){return()=>{t.forEach(s=>{try{s()}catch{}})}}const g={network:"eip155:8453",asset:"native",metadata:{name:"Ethereum",symbol:"ETH",decimals:18}},w={network:"eip155:8453",asset:"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",metadata:{name:"USD Coin",symbol:"USDC",decimals:6}},h={network:"eip155:84532",asset:"native",metadata:{name:"Ethereum",symbol:"ETH",decimals:18}},A={network:"eip155:1",asset:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",metadata:{name:"USD Coin",symbol:"USDC",decimals:6}},k={network:"eip155:10",asset:"0x0b2c639c533813f4aa9d7837caf62653d097ff85",metadata:{name:"USD Coin",symbol:"USDC",decimals:6}},I={network:"eip155:42161",asset:"0xaf88d065e77c8cC2239327C5EDb3A432268e5831",metadata:{name:"USD Coin",symbol:"USDC",decimals:6}},K={network:"eip155:137",asset:"0x3c499c542cef5e3811e1192ce70d8cc03d5c3359",metadata:{name:"USD Coin",symbol:"USDC",decimals:6}},N={network:"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",asset:"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",metadata:{name:"USD Coin",symbol:"USDC",decimals:6}},v={network:"eip155:1",asset:"0xdAC17F958D2ee523a2206206994597C13D831ec7",metadata:{name:"Tether USD",symbol:"USDT",decimals:6}},x={network:"eip155:10",asset:"0x94b008aA00579c1307B0EF2c499aD98a8ce58e58",metadata:{name:"Tether USD",symbol:"USDT",decimals:6}},F={network:"eip155:42161",asset:"0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",metadata:{name:"Tether USD",symbol:"USDT",decimals:6}},O={network:"eip155:137",asset:"0xc2132d05d31c914a87c6611c10748aeb04b58e8f",metadata:{name:"Tether USD",symbol:"USDT",decimals:6}},R={network:"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",asset:"Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB",metadata:{name:"Tether USD",symbol:"USDT",decimals:6}},q={network:"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",asset:"native",metadata:{name:"Solana",symbol:"SOL",decimals:9}};exports.PayController=e.PayController;Object.defineProperty(exports,"W3mPayLoadingView",{enumerable:!0,get:()=>e.W3mPayLoadingView});Object.defineProperty(exports,"W3mPayQuoteView",{enumerable:!0,get:()=>e.W3mPayQuoteView});Object.defineProperty(exports,"W3mPayView",{enumerable:!0,get:()=>e.W3mPayView});exports.arbitrumUSDC=I;exports.arbitrumUSDT=F;exports.baseETH=g;exports.baseSepoliaETH=h;exports.baseUSDC=w;exports.ethereumUSDC=A;exports.ethereumUSDT=v;exports.getExchanges=p;exports.getIsPaymentInProgress=T;exports.getPayError=E;exports.getPayResult=U;exports.openPay=u;exports.optimismUSDC=k;exports.optimismUSDT=x;exports.pay=D;exports.polygonUSDC=K;exports.polygonUSDT=O;exports.solanaSOL=q;exports.solanaUSDC=N;exports.solanaUSDT=R;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-DAGaFidW.js"),P=3e5;async function u(t){return e.PayController.handleOpenPay(t)}async function D(t,s=P){if(s<=0)throw new e.AppKitPayError(e.AppKitPayErrorCodes.INVALID_PAYMENT_CONFIG,"Timeout must be greater than 0");try{await u(t)}catch(r){throw r instanceof e.AppKitPayError?r:new e.AppKitPayError(e.AppKitPayErrorCodes.UNABLE_TO_INITIATE_PAYMENT,r.message)}return new Promise((r,y)=>{let n=!1;const i=setTimeout(()=>{n||(n=!0,c(),y(new e.AppKitPayError(e.AppKitPayErrorCodes.GENERIC_PAYMENT_ERROR,"Payment timeout")))},s);function o(){if(n)return;const a=e.PayController.state.currentPayment,m=e.PayController.state.error,C=e.PayController.state.isPaymentInProgress;if((a==null?void 0:a.status)==="SUCCESS"){n=!0,c(),clearTimeout(i),r({success:!0,result:a.result});return}if((a==null?void 0:a.status)==="FAILED"){n=!0,c(),clearTimeout(i),r({success:!1,error:m||"Payment failed"});return}m&&!C&&!a&&(n=!0,c(),clearTimeout(i),r({success:!1,error:m}))}const d=l("currentPayment",o),b=l("error",o),S=l("isPaymentInProgress",o),c=f([d,b,S]);o()})}function p(){return e.PayController.getExchanges()}function U(){var t;return(t=e.PayController.state.currentPayment)==null?void 0:t.result}function E(){return e.PayController.state.error}function T(){return e.PayController.state.isPaymentInProgress}function l(t,s){return e.PayController.subscribeKey(t,s)}function f(t){return()=>{t.forEach(s=>{try{s()}catch{}})}}const g={network:"eip155:8453",asset:"native",metadata:{name:"Ethereum",symbol:"ETH",decimals:18}},w={network:"eip155:8453",asset:"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",metadata:{name:"USD Coin",symbol:"USDC",decimals:6}},h={network:"eip155:84532",asset:"native",metadata:{name:"Ethereum",symbol:"ETH",decimals:18}},A={network:"eip155:1",asset:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",metadata:{name:"USD Coin",symbol:"USDC",decimals:6}},k={network:"eip155:10",asset:"0x0b2c639c533813f4aa9d7837caf62653d097ff85",metadata:{name:"USD Coin",symbol:"USDC",decimals:6}},I={network:"eip155:42161",asset:"0xaf88d065e77c8cC2239327C5EDb3A432268e5831",metadata:{name:"USD Coin",symbol:"USDC",decimals:6}},K={network:"eip155:137",asset:"0x3c499c542cef5e3811e1192ce70d8cc03d5c3359",metadata:{name:"USD Coin",symbol:"USDC",decimals:6}},N={network:"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",asset:"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",metadata:{name:"USD Coin",symbol:"USDC",decimals:6}},v={network:"eip155:1",asset:"0xdAC17F958D2ee523a2206206994597C13D831ec7",metadata:{name:"Tether USD",symbol:"USDT",decimals:6}},x={network:"eip155:10",asset:"0x94b008aA00579c1307B0EF2c499aD98a8ce58e58",metadata:{name:"Tether USD",symbol:"USDT",decimals:6}},F={network:"eip155:42161",asset:"0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",metadata:{name:"Tether USD",symbol:"USDT",decimals:6}},O={network:"eip155:137",asset:"0xc2132d05d31c914a87c6611c10748aeb04b58e8f",metadata:{name:"Tether USD",symbol:"USDT",decimals:6}},R={network:"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",asset:"Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB",metadata:{name:"Tether USD",symbol:"USDT",decimals:6}},q={network:"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",asset:"native",metadata:{name:"Solana",symbol:"SOL",decimals:9}};exports.PayController=e.PayController;Object.defineProperty(exports,"W3mPayLoadingView",{enumerable:!0,get:()=>e.W3mPayLoadingView});Object.defineProperty(exports,"W3mPayQuoteView",{enumerable:!0,get:()=>e.W3mPayQuoteView});Object.defineProperty(exports,"W3mPayView",{enumerable:!0,get:()=>e.W3mPayView});exports.arbitrumUSDC=I;exports.arbitrumUSDT=F;exports.baseETH=g;exports.baseSepoliaETH=h;exports.baseUSDC=w;exports.ethereumUSDC=A;exports.ethereumUSDT=v;exports.getExchanges=p;exports.getIsPaymentInProgress=T;exports.getPayError=E;exports.getPayResult=U;exports.openPay=u;exports.optimismUSDC=k;exports.optimismUSDT=x;exports.pay=D;exports.polygonUSDC=K;exports.polygonUSDT=O;exports.solanaSOL=q;exports.solanaUSDC=N;exports.solanaUSDT=R;
@@ -1,4 +1,4 @@
1
- import { bR as d, bS as c, bT as m, bU as r, bV as f, bW as v, bY as b, bZ as y, bX as h, b_ as g, b$ as w } from "./index-BKdw_1qM.mjs";
1
+ import { bR as d, bS as c, bT as m, bU as r, bV as f, bW as v, bY as b, bZ as y, bX as h, b_ as g, b$ as w } from "./index-CFLg0HEy.mjs";
2
2
  const x = d`
3
3
  :host {
4
4
  position: relative;