react-web3-storage 2.0.34 → 2.0.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ReownAuthentication-ZWJVb5u8.mjs → ReownAuthentication-DmF4FwpI.mjs} +1 -1
- package/dist/{ReownAuthentication-_EMKUe4O.js → ReownAuthentication-DrsRiFsw.js} +1 -1
- package/dist/{SwapController-CNHVjC6V.mjs → SwapController-BA3Mmv6U.mjs} +1 -1
- package/dist/{SwapController-75y039lY.js → SwapController-CtDqSBuk.js} +1 -1
- package/dist/{ccip-CQrFYKlN.mjs → ccip-CCRxV7f9.mjs} +2 -2
- package/dist/{ccip-BgoVuN3u.js → ccip-CsiJPpjq.js} +1 -1
- package/dist/{data-capture-CgKKCS0j.mjs → data-capture-CbMqPjB2.mjs} +3 -3
- package/dist/{data-capture-hbDyOOyJ.js → data-capture-D111beXH.js} +1 -1
- package/dist/{email-DYvAHYik.js → email-BGJ1Ik0N.js} +1 -1
- package/dist/{email-C2N4HkZQ.mjs → email-Dz0MnmCa.mjs} +2 -2
- package/dist/{embedded-wallet-CYNDQvBG.js → embedded-wallet-0JIxQupj.js} +1 -1
- package/dist/{embedded-wallet-_7JcZAOC.mjs → embedded-wallet-DSMT0c30.mjs} +1 -1
- package/dist/{features-JvQHn7sG.mjs → features-7finTk-r.mjs} +1 -1
- package/dist/{features-BA8f0aFu.js → features-BPWLVd9S.js} +1 -1
- package/dist/{index-DVNi_N99.mjs → index-B1-7XCca.mjs} +2 -2
- package/dist/{index-DzjJtqrG.js → index-B6SqR5X-.js} +1 -1
- package/dist/{index-BNobBA-8.js → index-BOmQiHqX.js} +12 -12
- package/dist/{index-BHukHFIh.mjs → index-Bs5Hwpeg.mjs} +260 -262
- package/dist/{index-CgI_Ukj5.mjs → index-BsfA-fqT.mjs} +3 -3
- package/dist/{index-Ccy2zz9q.mjs → index-C2D_2aWG.mjs} +1 -1
- package/dist/{index-Clu0wU1d.mjs → index-CI9nHJVP.mjs} +1 -1
- package/dist/{index-B7Og0OLg.js → index-Cgiw4K6H.js} +1 -1
- package/dist/{index-Bxg-paEQ.mjs → index-Cladcvka.mjs} +2 -2
- package/dist/{index-xYJPqvul.js → index-DGVySovA.js} +1 -1
- package/dist/{index-C_fopi0u.js → index-DQhltFzy.js} +1 -1
- package/dist/{index-CLUlCRLy.js → index-Hg-8iV6d.js} +1 -1
- package/dist/{index-mvH0tD6I.js → index-LzMGj7o_.js} +1 -1
- package/dist/{index-CjS2YG3n.js → index-Up6jA_y_.js} +1 -1
- package/dist/{index-DnKQlXMR.mjs → index-VObUciYl.mjs} +1 -1
- package/dist/{index-B--AiWBy.mjs → index-_gmT4On6.mjs} +1 -1
- package/dist/{index-CASDFBE7.js → index-_rRS63pB.js} +1 -1
- package/dist/{index-DIxai2A2.mjs → index-hHQk_s8g.mjs} +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +1 -1
- package/dist/{onramp-zhj-U9X5.mjs → onramp-CgVWa28A.mjs} +1 -1
- package/dist/{onramp-DlA5BSaX.js → onramp-IcZXc2i3.js} +1 -1
- package/dist/{parseSignature-ZB66mPGB.mjs → parseSignature-By8PXVDg.mjs} +2 -2
- package/dist/{parseSignature-CWAxHYP1.js → parseSignature-DVr70VMP.js} +2 -2
- package/dist/{pay-with-exchange-Czbx9cbv.mjs → pay-with-exchange-47ISCMF6.mjs} +2 -2
- package/dist/{pay-with-exchange-BQaMDGKp.js → pay-with-exchange-p7mOOlIN.js} +1 -1
- package/dist/{receive-VPGRuO6J.mjs → receive-F0-tt1hK.mjs} +1 -1
- package/dist/{receive-BA736NNd.js → receive-lImJlquq.js} +1 -1
- package/dist/{send-xiZMc6dE.mjs → send-CLnW7rK9.mjs} +4 -4
- package/dist/{send-BhagKj7q.js → send-D4xktOzX.js} +1 -1
- package/dist/{socials-BX3hluqS.mjs → socials-BFktHcGP.mjs} +1 -1
- package/dist/{socials-B-mhVCLM.js → socials-NSZL9FjG.js} +1 -1
- package/dist/{swaps-DQYnz8sb.js → swaps-BexZV1do.js} +1 -1
- package/dist/{swaps-BFl7r_MZ.mjs → swaps-DXtK1J0M.mjs} +3 -3
- package/dist/{transactions-BooVIWm5.mjs → transactions-BfYEKby4.mjs} +1 -1
- package/dist/{transactions-DWsNckfd.js → transactions-CpJxKjut.js} +1 -1
- package/dist/{w3m-modal-BLoHPTsO.mjs → w3m-modal-BLXtQ_or.mjs} +3 -3
- package/dist/{w3m-modal-D6NKq8XS.js → w3m-modal-CwMsjoil.js} +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { cc as g, cn as w, co as y, cp as A, c8 as k, cq as u, cd as N, cr as p } from "./index-
|
|
1
|
+
import { cc as g, cn as w, co as y, cp as A, c8 as k, cq as u, cd as N, cr as p } from "./index-Bs5Hwpeg.mjs";
|
|
2
2
|
class m {
|
|
3
3
|
constructor(e) {
|
|
4
4
|
this.getNonce = e.getNonce;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const s=require("./index-
|
|
1
|
+
"use strict";const s=require("./index-BOmQiHqX.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 { c2 as T, c3 as W, c4 as x, c5 as A, c6 as w, c7 as D, c8 as P, c9 as B, ca as M, cb as F, cc as g, cd as v, ce as L, cf as N, cg as z, ch as R, ci as _, cj as H, ck as V, cl as $, cm as q } from "./index-
|
|
1
|
+
import { c2 as T, c3 as W, c4 as x, c5 as A, c6 as w, c7 as D, c8 as P, c9 as B, ca as M, cb as F, cc as g, cd as v, ce as L, cf as N, cg as z, ch as R, ci as _, cj as H, ck as V, cl as $, cm as q } from "./index-Bs5Hwpeg.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-BNobBA-8.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-BOmQiHqX.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, aR as L, aS as O, aT as E } from "./parseSignature-
|
|
2
|
-
import { ad as p, cs as y, bN as w, bb as R, b3 as x, aw as m, be as M } from "./index-
|
|
1
|
+
import { a1 as g, ab as k, aR as L, aS as O, aT as E } from "./parseSignature-By8PXVDg.mjs";
|
|
2
|
+
import { ad as p, cs as y, bN as w, bb as R, b3 as x, aw as m, be as M } from "./index-Bs5Hwpeg.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-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./parseSignature-DVr70VMP.js"),s=require("./index-BOmQiHqX.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 { c1 as y, bX as $, bY as l, bV as S, bW as x, cz as m, c5 as p, cc as f, c6 as h, cw as u, c0 as _, cq as E, co as R } from "./index-
|
|
2
|
-
import { W as C } from "./index-
|
|
3
|
-
import { R as v } from "./ReownAuthentication-
|
|
1
|
+
import { c1 as y, bX as $, bY as l, bV as S, bW as x, cz as m, c5 as p, cc as f, c6 as h, cw as u, c0 as _, cq as E, co as R } from "./index-Bs5Hwpeg.mjs";
|
|
2
|
+
import { W as C } from "./index-_gmT4On6.mjs";
|
|
3
|
+
import { R as v } from "./ReownAuthentication-DmF4FwpI.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-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-BOmQiHqX.js"),d=require("./index-DGVySovA.js"),u=require("./ReownAuthentication-DrsRiFsw.js"),g=e.i$1`
|
|
2
2
|
.email-sufixes {
|
|
3
3
|
display: flex;
|
|
4
4
|
flex-direction: row;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-BOmQiHqX.js"),c=require("./index-DGVySovA.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,5 +1,5 @@
|
|
|
1
|
-
import { cc as S, c7 as g, cz as p, c9 as c, cA as _, c5 as s, c6 as f, ce as b, bW as u, bS as D, bX as C, ck as d, bY as m, cw as E, c1 as $, bZ as W, b$ as P, cB as N, c8 as T } from "./index-
|
|
2
|
-
import { W as y } from "./index-
|
|
1
|
+
import { cc as S, c7 as g, cz as p, c9 as c, cA as _, c5 as s, c6 as f, ce as b, bW as u, bS as D, bX as C, ck as d, bY as m, cw as E, c1 as $, bZ as W, b$ as P, cB as N, c8 as T } from "./index-Bs5Hwpeg.mjs";
|
|
2
|
+
import { W as y } from "./index-_gmT4On6.mjs";
|
|
3
3
|
var F = 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 e=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-BOmQiHqX.js"),x=e.i$1`
|
|
2
2
|
div {
|
|
3
3
|
width: 100%;
|
|
4
4
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c1 as B, bX as g, cA as W, cz as K, bY as c, ck as _, cu as V, cI as G, cw as d, bW as w, bS as E, bT as z, bU as H, bV as l, ci as N, cc as h, cJ as j, c8 as k, ca as A, cb as m, c7 as L, cK as X, cv as q, bZ as Z, cL as v, ce as U, cM as O, b$ as J, c9 as I, c6 as Q, cN as ee, c5 as te } from "./index-
|
|
1
|
+
import { c1 as B, bX as g, cA as W, cz as K, bY as c, ck as _, cu as V, cI as G, cw as d, bW as w, bS as E, bT as z, bU as H, bV as l, ci as N, cc as h, cJ as j, c8 as k, ca as A, cb as m, c7 as L, cK as X, cv as q, bZ as Z, cL as v, ce as U, cM as O, b$ as J, c9 as I, c6 as Q, cN as ee, c5 as te } from "./index-Bs5Hwpeg.mjs";
|
|
2
2
|
const ie = B`
|
|
3
3
|
div {
|
|
4
4
|
width: 100%;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./ReownAuthentication-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./ReownAuthentication-DrsRiFsw.js");exports.ReownAuthentication=e.ReownAuthentication;exports.ReownAuthenticationMessenger=e.ReownAuthenticationMessenger;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as t, A as m, a as d } from "./index-
|
|
2
|
-
import { b as z, c as B, W as G } from "./index-
|
|
1
|
+
import { P as t, A as m, a as d } from "./index-CI9nHJVP.mjs";
|
|
2
|
+
import { b as z, c as B, W as G } from "./index-CI9nHJVP.mjs";
|
|
3
3
|
const U = 3e5;
|
|
4
4
|
async function E(e) {
|
|
5
5
|
return t.handleOpenPay(e);
|