@dcl/explorer-website 2.6.1-25865517797.commit-b7a7cba → 2.7.0
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/assets/{ConstantsUtil-ByjAYmvC.js → ConstantsUtil-BYRHWuZV.js} +1 -1
- package/assets/{ExchangeController-Bp8ztJrX.js → ExchangeController-N42lbf3C.js} +1 -1
- package/assets/{HelpersUtil-Dp4e1zvd.js → HelpersUtil-DFmhrbIH.js} +1 -1
- package/assets/{NetworkUtil-DqGcuBfF.js → NetworkUtil-DM5H1DOt.js} +1 -1
- package/assets/{SwapController-DUCq2f7d.js → SwapController-SgAc8zJM.js} +1 -1
- package/assets/{W3MFrameProviderSingleton-9eitOT0j.js → W3MFrameProviderSingleton-dGwr0u32.js} +3 -3
- package/assets/{basic-C7tUDecp.js → basic-CDUVa7W3.js} +1 -1
- package/assets/{biconomy-plHCR2Qq.js → biconomy-Dj37CYYZ.js} +1 -1
- package/assets/{browser-VYI7gorG.js → browser-h4rN6CV4.js} +1 -1
- package/assets/browser-ponyfill-LG9Rjmfj.js +1 -0
- package/assets/{ccip-Bldffu31.js → ccip-Cv_5kGJ0.js} +1 -1
- package/assets/{ccip-CrAifiNa.js → ccip-TlIoUAte.js} +1 -1
- package/assets/{chains-DTVDhUwv.js → chains-CsuV2rnE.js} +1 -1
- package/assets/{common-BEf2T7Hi.js → common-C9wbti_7.js} +1 -1
- package/assets/{controller-B8Iy-6V9.js → controller-DpEeOSLx.js} +2 -2
- package/assets/{core-XFvzSI58.js → core-BGvtiIgG.js} +4 -4
- package/assets/{custom-cPmISGcH.js → custom-BbQhcg55.js} +1 -1
- package/assets/{data-capture-DnvAEYWK.js → data-capture-C5UoNnMk.js} +1 -1
- package/assets/decimals-DA8L6Gte.js +1 -0
- package/assets/{decimals-8g2-fBFa.js → decimals-mBEEumco.js} +1 -1
- package/assets/{detectExtension-yvI5WWZb.js → detectExtension-oDT7CrDk.js} +1 -1
- package/assets/{email-C8DRQjTT.js → email-CUatRSQC.js} +1 -1
- package/assets/{embedded-wallet-BxgtT1uV.js → embedded-wallet-DZAeJhJN.js} +1 -1
- package/assets/{engine-BERe87yT.js → engine-AXDB-0h6.js} +1 -1
- package/assets/{estimate-l1-fee-BTeKvFv5.js → estimate-l1-fee-Bxwscz8f.js} +1 -1
- package/assets/eth_estimateGas-DFXalA2X.js +1 -0
- package/assets/{eth_getStorageAt-SbVMAQY-.js → eth_getStorageAt-Dr4zmiJF.js} +1 -1
- package/assets/{eth_getTransactionCount-qv0oO1Md.js → eth_getTransactionCount-cZacEETx.js} +1 -1
- package/assets/{ethereum-BP59xYBe.js → ethereum-CIBzGnJl.js} +1 -1
- package/assets/{extractIPFS-BOFlZk7U.js → extractIPFS-Czsz8-sO.js} +1 -1
- package/assets/{features-DVWd8_kC.js → features-fx-atM_l.js} +1 -1
- package/assets/{fetchTokenMetadata-BaJXN6RH.js → fetchTokenMetadata-uG4nb_Kh.js} +2 -2
- package/assets/{fortmatic-DARkeYTE.js → fortmatic-boxtmFta.js} +1 -1
- package/assets/get-ecosystem-wallet-info-BI2Fd0Vd.js +1 -0
- package/assets/{getBalance-D6wpo61w.js → getBalance-CC2S0qtL.js} +2 -2
- package/assets/{getInstalledModules-Dkj379ys.js → getInstalledModules-53n5UYt2.js} +1 -1
- package/assets/{getNFT-HMkoXD7L.js → getNFT-C3FPakLN.js} +2 -2
- package/assets/{getNFT-Drn4rxrk.js → getNFT-CnaK4j2q.js} +1 -1
- package/assets/{hashTypedData-CMDSWYgs.js → hashTypedData-C4JiqOxU.js} +1 -1
- package/assets/{hashTypedData-B5shS-rs.js → hashTypedData-D1Ievn97.js} +1 -1
- package/assets/{in-app-wallet-calls-l9-2W_Em.js → in-app-wallet-calls-khLeeKNu.js} +1 -1
- package/assets/{index-BIPd_vR5.js → index-0P32tQWj.js} +1 -1
- package/assets/{index-DIlwNfpB.js → index-1quVm3wk.js} +1 -1
- package/assets/{index-DbAu4Peg.js → index-B2PoGJRP.js} +3 -3
- package/assets/{index-BaGjqMte.js → index-B5w_jZpc.js} +2 -2
- package/assets/{index-CE5G6IEJ.js → index-B6j-Tckn.js} +1 -1
- package/assets/{index-CjiwjbqL.js → index-BCiKer83.js} +1 -1
- package/assets/{index-C8NSq3HK.js → index-BCqrDgyR.js} +1 -1
- package/assets/{index-BXAxcybX.js → index-BE5nQY53.js} +1 -1
- package/assets/{index-C51HwlD0.js → index-BF9Yx_yV.js} +1 -1
- package/assets/{index-CWGeCZBJ.js → index-BJCYEGPg.js} +1 -1
- package/assets/{index-Cy1X3n_C.js → index-BT0xQ-Xd.js} +1 -1
- package/assets/{index-0ShVRzxt.js → index-BVi4iI8y.js} +1 -1
- package/assets/{index-BDgZ3gDE.js → index-BVvMg9ZB.js} +1 -1
- package/assets/{index-DFE6t65x.js → index-BpxeqYFx.js} +1 -1
- package/assets/{index-B5ECjSS9.js → index-Bv6LvzLS.js} +1 -1
- package/assets/{index-i4VBSYqA.js → index-BvCGPTHO.js} +1 -1
- package/assets/index-Bzi38pjx.css +1 -0
- package/assets/{index-CH0zI801.js → index-C5oPclal.js} +1 -1
- package/assets/{index-D2ZBQG8w.js → index-C6-AvlPm.js} +1 -1
- package/assets/{index-CWnFK_-0.js → index-C9EMW8qD.js} +1 -1
- package/assets/{index-C-uqursN.js → index-C9vcJp9T.js} +1 -1
- package/assets/{index-DK-ZMNLh.js → index-CO3lXLzl.js} +1 -1
- package/assets/{index-DS2Lm9tG.js → index-CYBDya_s.js} +1 -1
- package/assets/{index-okvlQSs2.js → index-Coj3uG35.js} +1 -1
- package/assets/{index-Cu4ZjLNb.js → index-CqbvjyBi.js} +5 -5
- package/assets/{index-wds8TuUm.js → index-CwfOYq8B.js} +1 -1
- package/assets/{index-aoxVkzFE.js → index-Cz0JdeQb.js} +1 -1
- package/assets/{index-C5ciuua_.js → index-D-YuFp2i.js} +1 -1
- package/assets/{index-I68folnJ.js → index-D4NLrlUn.js} +1 -1
- package/assets/{index-B7Jt3b4d.js → index-D8PaxcsI.js} +1 -1
- package/assets/{index-r_1z0VI_.js → index-D9ey6cqT.js} +1 -1
- package/assets/{index-B-vyBZw9.js → index-DRYOQXZX.js} +1 -1
- package/assets/{index-DOnRCLNP.js → index-DT1PkdGa.js} +2 -2
- package/assets/{index-DWRq2SN_.js → index-DXCSroqX.js} +1 -1
- package/assets/{index-mZa0UiRt.js → index-DXs78xw9.js} +1 -1
- package/assets/{index-kXKMGszW.js → index-DZ0punK7.js} +1 -1
- package/assets/{index-B9U0GcYk.js → index-D_m5AL3D.js} +1 -1
- package/assets/{index-BxdNwV86.js → index-Dc148hav.js} +1 -1
- package/assets/{index-DP1DuCnR.js → index-DgDxBH9m.js} +1 -1
- package/assets/{index-DfWsAOhN.js → index-Dm7tCcMc.js} +3 -3
- package/assets/{index-D0LvjNIX.js → index-DmIGOG39.js} +1 -1
- package/assets/{index-JfVynEph.js → index-DmK5ktNw.js} +1 -1
- package/assets/{index-Cp7mdTuR.js → index-Eyans5--.js} +1 -1
- package/assets/{index-DPxCDCvr.js → index-KK8ZylE4.js} +1 -1
- package/assets/{index-DvJmANzU.js → index-TUD0QlWP.js} +1 -1
- package/assets/{index-TBthDmkl.js → index-ak5cSl-l.js} +1 -1
- package/assets/{index-8M7OkBFm.js → index-bVr8-SEv.js} +1 -1
- package/assets/{index-BlykZ8Gp.js → index-prLj8b2x.js} +1 -1
- package/assets/{index-BKL7nv1p.js → index-vajj2FBo.js} +1 -1
- package/assets/{index.es-YpI01v2I.js → index.es-C85F8NOj.js} +1 -1
- package/assets/{index.es-CkxUaFYS.js → index.es-DYgSAVrd.js} +1 -1
- package/assets/{index.es-cEGj7JU0.js → index.es-XXBqJXMm.js} +4 -4
- package/assets/{localBatchGatewayRequest-CNIOIq-Z.js → localBatchGatewayRequest-DbQn1s0J.js} +1 -1
- package/assets/{networks-DJ72puSk.js → networks-DMqekeph.js} +1 -1
- package/assets/{onramp--l5ZLxWE.js → onramp-qvbxoSMm.js} +1 -1
- package/assets/{openzeppelin-CqtRqxtF.js → openzeppelin-B6Und3LJ.js} +1 -1
- package/assets/{ownerOf-cWkgEtd8.js → ownerOf-CUoSe2c5.js} +1 -1
- package/assets/{parseEventLogs-D1xiFnCH.js → parseEventLogs-BxtEI7tW.js} +3 -3
- package/assets/{parseNft-DH5KlHPI.js → parseNft-DB_pGzOu.js} +2 -2
- package/assets/{parseSignature-HAlgOHnm.js → parseSignature-Csyua1uA.js} +3 -3
- package/assets/{parseSignature-BYhcrVdX.js → parseSignature-O0fAqZoB.js} +1 -1
- package/assets/{pay-with-exchange-CiXPJJ6-.js → pay-with-exchange-1MlV9x6H.js} +1 -1
- package/assets/{qr-overlay-CmFgwJBd.js → qr-overlay-DA6htUdY.js} +3 -3
- package/assets/{receive-t2TxUItI.js → receive-JnpfZY7d.js} +1 -1
- package/assets/{resolveImplementation-iG9WRRnW.js → resolveImplementation-B8d2Q-Ro.js} +1 -1
- package/assets/{rpc-sIdV4wiJ.js → rpc-DkFFCBh9.js} +1 -1
- package/assets/{secp256k1-Rk5k9i7o.js → secp256k1-BCPsQ5nJ.js} +1 -1
- package/assets/{secp256k1-Co_Jve4c.js → secp256k1-BZmrY8e3.js} +1 -1
- package/assets/{secp256k1-Bg2aUJRs.js → secp256k1-TIizaas9.js} +1 -1
- package/assets/{send-ByB5fOtm.js → send-DsnDja5n.js} +1 -1
- package/assets/{send-batch-transaction-D79MC_wr.js → send-batch-transaction-jNcvidMH.js} +1 -1
- package/assets/{send-eip712-transaction-CB6qLgks.js → send-eip712-transaction-DDJVOUpU.js} +2 -2
- package/assets/{send-gasless-transaction-Dt1qtUR8.js → send-gasless-transaction-DXjarWmh.js} +2 -2
- package/assets/{session-proposal-CY0k9Jnm.js → session-proposal-xJguSOgr.js} +1 -1
- package/assets/{session-request-B_2glC9e.js → session-request-BhD4eDPG.js} +2 -2
- package/assets/{sha256-Dy8KQE_5.js → sha256-CbjS9vFa.js} +1 -1
- package/assets/{signing-gNn6SJWz.js → signing-tKzVzr3v.js} +5 -5
- package/assets/{socials-Dx84-PrV.js → socials-CER945jA.js} +1 -1
- package/assets/{swaps-CK9Sfcew.js → swaps-Dy4hNTFm.js} +1 -1
- package/assets/{thirdweb-Bx5V_C1s.js → thirdweb-CNCkvOQU.js} +3 -3
- package/assets/{totalSupply-O-VFDoRO.js → totalSupply-BQvZy7Uc.js} +1 -1
- package/assets/{transactionReceipt-BqEjx5q-.js → transactionReceipt-DA1xo-2g.js} +1 -1
- package/assets/{transactions-BLOC2qYE.js → transactions-CwEfhngY.js} +1 -1
- package/assets/{utils-h8VUSGPW.js → utils-BUWGRgBa.js} +1 -1
- package/assets/{verifyHash-CNJ6t8Wp.js → verifyHash-CX9Livyx.js} +1 -1
- package/assets/{w3m-modal-nzPxg0Fr.js → w3m-modal-B1spewtI.js} +1 -1
- package/assets/{w3m-modal-CCQuGDus.js → w3m-modal-B6M729n4.js} +1 -1
- package/assets/{wait-for-tx-receipt-5pSBMNe2.js → wait-for-tx-receipt-BLruoSfj.js} +1 -1
- package/assets/{wallets-Bz03-Btm.js → wallets-vCTTbbau.js} +6 -6
- package/assets/{web-connector-CAOe_uvv.js → web-connector-h9SB5qXs.js} +3 -3
- package/assets/{writeContract-CCar3Ocq.js → writeContract-C9KDDivM.js} +1 -1
- package/assets/{zora-sepolia-D6mjhB5j.js → zora-sepolia-pCyxGzqm.js} +1 -1
- package/assets/{zoraTestnet-WLSFziQl.js → zoraTestnet-ChmlUfs6.js} +1 -1
- package/index.html +4 -4
- package/package.json +3 -3
- package/assets/browser-ponyfill-BmgQyNz0.js +0 -1
- package/assets/decimals-DR6jraOc.js +0 -1
- package/assets/eth_estimateGas-DKKwG-Ue.js +0 -1
- package/assets/get-ecosystem-wallet-info-Cvjz8DFX.js +0 -1
- package/assets/index-829Uxa3Y.css +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as t}from"./index-
|
|
1
|
+
import{b as t}from"./index-CqbvjyBi.js";var e={};const o={ACCOUNT_TABS:[{label:"Tokens"},{label:"Activity"}],SECURE_SITE_ORIGIN:(typeof t<"u"&&typeof e<"u"?e.NEXT_PUBLIC_SECURE_SITE_ORIGIN:void 0)||"https://secure.walletconnect.org",VIEW_DIRECTION:{Next:"next",Prev:"prev"},ANIMATION_DURATIONS:{HeaderText:120},VIEWS_WITH_LEGAL_FOOTER:["Connect","ConnectWallets","OnRampTokenSelect","OnRampFiatSelect","OnRampProviders"],VIEWS_WITH_DEFAULT_FOOTER:["Networks"]};export{o as C};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as u,E as p,b as l,S as y,d as E,O as A,N as d,g,B as P,e as f,i as b,p as C}from"./W3MFrameProviderSingleton-
|
|
1
|
+
import{C as u,E as p,b as l,S as y,d as E,O as A,N as d,g,B as P,e as f,i as b,p as C}from"./W3MFrameProviderSingleton-dGwr0u32.js";import{g as S,a as k,f as h,b as U,c as x}from"./index-B2PoGJRP.js";const N=0,w={paymentAsset:null,amount:null,tokenAmount:0,priceLoading:!1,error:null,exchanges:[],isLoading:!1,currentPayment:void 0,isPaymentInProgress:!1,paymentId:"",assets:[]},e=C(w),o={state:e,subscribe(t){return b(e,()=>t(e))},subscribeKey(t,s){return f(e,t,s)},resetState(){Object.assign(e,{...w})},async getAssetsForNetwork(t){const s=x(t),r=await o.getAssetsImageAndPrice(s),n=s.map(a=>{const c=a.asset==="native"?g():`${a.network}:${a.asset}`,i=r.find(m=>m.fungibles?.[0]?.address?.toLowerCase()===c.toLowerCase());return{...a,price:i?.fungibles?.[0]?.price||1,metadata:{...a.metadata,iconUrl:i?.fungibles?.[0]?.iconUrl}}});return e.assets=n,n},async getAssetsImageAndPrice(t){const s=t.map(n=>n.asset==="native"?g():`${n.network}:${n.asset}`);return await Promise.all(s.map(n=>P.fetchTokenPrice({addresses:[n]})))},getTokenAmount(){if(!e?.paymentAsset?.price)throw new Error("Cannot get token price");const t=d.bigNumber(e.amount??0).round(8),s=d.bigNumber(e.paymentAsset.price).round(8);return t.div(s).round(8).toNumber()},setAmount(t){e.amount=t,e.paymentAsset?.price&&(e.tokenAmount=o.getTokenAmount())},setPaymentAsset(t){e.paymentAsset=t},isPayWithExchangeEnabled(){return A.state.remoteFeatures?.payWithExchange},isPayWithExchangeSupported(){return o.isPayWithExchangeEnabled()&&u.state.activeCaipNetwork&&E.PAY_WITH_EXCHANGE_SUPPORTED_CHAIN_NAMESPACES.includes(u.state.activeCaipNetwork.chainNamespace)},async fetchExchanges(){try{const t=o.isPayWithExchangeSupported();if(!e.paymentAsset||!t){e.exchanges=[],e.isLoading=!1;return}e.isLoading=!0;const s=await U({page:N,asset:h(e.paymentAsset.network,e.paymentAsset.asset),amount:e.amount?.toString()??"0"});e.exchanges=s.exchanges.slice(0,2)}catch{throw y.showError("Unable to get exchanges"),new Error("Unable to get exchanges")}finally{e.isLoading=!1}},async getPayUrl(t,s){try{const r=Number(s.amount),n=await k({exchangeId:t,asset:h(s.network,s.asset),amount:r.toString(),recipient:`${s.network}:${s.recipient}`});return p.sendEvent({type:"track",event:"PAY_EXCHANGE_SELECTED",properties:{exchange:{id:t},configuration:{network:s.network,asset:s.asset,recipient:s.recipient,amount:r},currentPayment:{type:"exchange",exchangeId:t},source:"fund-from-exchange",headless:!1}}),n}catch(r){throw r instanceof Error&&r.message.includes("is not supported")?new Error("Asset not supported"):new Error(r.message)}},async handlePayWithExchange(t){try{const s=u.getAccountData()?.address;if(!s)throw new Error("No account connected");if(!e.paymentAsset)throw new Error("No payment asset selected");const r=l.returnOpenHref("","popupWindow","scrollbar=yes,width=480,height=720");if(!r)throw new Error("Could not create popup window");e.isPaymentInProgress=!0,e.paymentId=crypto.randomUUID(),e.currentPayment={type:"exchange",exchangeId:t};const{network:n,asset:a}=e.paymentAsset,c={network:n,asset:a,amount:e.tokenAmount,recipient:s},i=await o.getPayUrl(t,c);if(!i){try{r.close()}catch(m){console.error("Unable to close popup window",m)}throw new Error("Unable to initiate payment")}e.currentPayment.sessionId=i.sessionId,e.currentPayment.status="IN_PROGRESS",e.currentPayment.exchangeId=t,r.location.href=i.url}catch{e.error="Unable to initiate payment",y.showError(e.error)}},async waitUntilComplete({exchangeId:t,sessionId:s,paymentId:r,retries:n=20}){const a=await o.getBuyStatus(t,s,r);if(a.status==="SUCCESS"||a.status==="FAILED")return a;if(n===0)throw new Error("Unable to get deposit status");return await new Promise(c=>{setTimeout(c,5e3)}),o.waitUntilComplete({exchangeId:t,sessionId:s,paymentId:r,retries:n-1})},async getBuyStatus(t,s,r){try{if(!e.currentPayment)throw new Error("No current payment");const n=await S({sessionId:s,exchangeId:t});if(e.currentPayment.status=n.status,n.status==="SUCCESS"||n.status==="FAILED"){const a=u.getAccountData()?.address;e.currentPayment.result=n.txHash,e.isPaymentInProgress=!1,p.sendEvent({type:"track",event:n.status==="SUCCESS"?"PAY_SUCCESS":"PAY_ERROR",properties:{message:n.status==="FAILED"?l.parseError(e.error):void 0,source:"fund-from-exchange",paymentId:r,configuration:{network:e.paymentAsset?.network||"",asset:e.paymentAsset?.asset||"",recipient:a||"",amount:e.amount??0},currentPayment:{type:"exchange",exchangeId:e.currentPayment?.exchangeId,sessionId:e.currentPayment?.sessionId,result:n.txHash}}})}return n}catch{return{status:"UNKNOWN",txHash:""}}},reset(){e.currentPayment=void 0,e.isPaymentInProgress=!1,e.paymentId="",e.paymentAsset=null,e.amount=0,e.tokenAmount=0,e.priceLoading=!1,e.error=null,e.exchanges=[],e.isLoading=!1}};export{o as E};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as f,b as h}from"./lit-element-Cn7T8F1W.js";import{n as m}from"./class-map-mFRv1nW8.js";import{c as p}from"./index-
|
|
1
|
+
import{i as f,b as h}from"./lit-element-Cn7T8F1W.js";import{n as m}from"./class-map-mFRv1nW8.js";import{c as p}from"./index-CwfOYq8B.js";import{d as g,r as v}from"./index-B2PoGJRP.js";import{C as c}from"./ConstantsUtil-BYRHWuZV.js";import{R as $,O as u}from"./W3MFrameProviderSingleton-dGwr0u32.js";import{ap as y}from"./NetworkUtil-DM5H1DOt.js";const b=g`
|
|
2
2
|
:host {
|
|
3
3
|
display: flex;
|
|
4
4
|
justify-content: center;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{l as Ce,m as Me,H as Se,e as re,u as Re,n as ne,b as se,t as Pe,d as ae,o as Ie,c as pe,p as _e,q as $e,v as Ue,w as Le}from"./sha2-D3ryOfi3.js";import{b as oe}from"./index-
|
|
1
|
+
import{l as Ce,m as Me,H as Se,e as re,u as Re,n as ne,b as se,t as Pe,d as ae,o as Ie,c as pe,p as _e,q as $e,v as Ue,w as Le}from"./sha2-D3ryOfi3.js";import{b as oe}from"./index-CqbvjyBi.js";const fe="2.48.11";let x={getDocsUrl:({docsBaseUrl:r,docsPath:e="",docsSlug:t})=>e?`${r??"https://viem.sh"}${e}${t?`#${t}`:""}`:void 0,version:`viem@${fe}`};class u extends Error{constructor(e,t={}){const n=t.cause instanceof u?t.cause.details:t.cause?.message?t.cause.message:t.details,s=t.cause instanceof u&&t.cause.docsPath||t.docsPath,a=x.getDocsUrl?.({...t,docsPath:s}),o=[e||"An error occurred.","",...t.metaMessages?[...t.metaMessages,""]:[],...a?[`Docs: ${a}`]:[],...n?[`Details: ${n}`]:[],...x.version?[`Version: ${x.version}`]:[]].join(`
|
|
2
2
|
`);super(o,t.cause?{cause:t.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=n,this.docsPath=s,this.metaMessages=t.metaMessages,this.name=t.name??this.name,this.shortMessage=e,this.version=fe}walk(e){return be(this,e)}}function be(r,e){return e?.(r)?r:r&&typeof r=="object"&&"cause"in r&&r.cause!==void 0?be(r.cause,e):e?null:r}class he extends u{constructor({max:e,min:t,signed:n,size:s,value:a}){super(`Number "${a}" is not in safe ${s?`${s*8}-bit ${n?"signed":"unsigned"} `:""}integer range ${e?`(${t} to ${e})`:`(above ${t})`}`,{name:"IntegerOutOfRangeError"})}}class At extends u{constructor(e){super(`Bytes value "${e}" is not a valid boolean. The bytes array must contain a single byte of either a 0 or 1 value.`,{name:"InvalidBytesBooleanError"})}}class De extends u{constructor(e){super(`Hex value "${e}" is not a valid boolean. The hex value must be "0x0" (false) or "0x1" (true).`,{name:"InvalidHexBooleanError"})}}class Be extends u{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed ${t} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function me(r,{strict:e=!0}={}){return!r||typeof r!="string"?!1:e?/^0x[0-9a-fA-F]*$/.test(r):r.startsWith("0x")}function ie(r){return me(r,{strict:!1})?Math.ceil((r.length-2)/2):r.length}function T(r,{dir:e="left"}={}){let t=typeof r=="string"?r.replace("0x",""):r,n=0;for(let s=0;s<t.length-1&&t[e==="left"?s:t.length-s-1].toString()==="0";s++)n++;return t=e==="left"?t.slice(n):t.slice(0,t.length-n),typeof r=="string"?(t.length===1&&e==="right"&&(t=`${t}0`),`0x${t.length%2===1?`0${t}`:t}`):t}class Ct extends u{constructor({offset:e,position:t,size:n}){super(`Slice ${t==="start"?"starting":"ending"} at offset "${e}" is out-of-bounds (size: ${n}).`,{name:"SliceOffsetOutOfBoundsError"})}}class ye extends u{constructor({size:e,targetSize:t,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (${e}) exceeds padding size (${t}).`,{name:"SizeExceedsPaddingSizeError"})}}class Mt extends u{constructor({size:e,targetSize:t,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} is expected to be ${t} ${n} long, but is ${e} ${n} long.`,{name:"InvalidBytesLengthError"})}}function E(r,{dir:e,size:t=32}={}){return typeof r=="string"?je(r,{dir:e,size:t}):ke(r,{dir:e,size:t})}function je(r,{dir:e,size:t=32}={}){if(t===null)return r;const n=r.replace("0x","");if(n.length>t*2)throw new ye({size:Math.ceil(n.length/2),targetSize:t,type:"hex"});return`0x${n[e==="right"?"padEnd":"padStart"](t*2,"0")}`}function ke(r,{dir:e,size:t=32}={}){if(t===null)return r;if(r.length>t)throw new ye({size:r.length,targetSize:t,type:"bytes"});const n=new Uint8Array(t);for(let s=0;s<t;s++){const a=e==="right";n[a?s:t-s-1]=r[a?s:r.length-s-1]}return n}const He=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function St(r,e={}){return typeof r=="number"||typeof r=="bigint"?Ee(r,e):typeof r=="string"?We(r,e):typeof r=="boolean"?ze(r,e):ge(r,e)}function ze(r,e={}){const t=`0x${Number(r)}`;return typeof e.size=="number"?(y(t,{size:e.size}),E(t,{size:e.size})):t}function ge(r,e={}){let t="";for(let s=0;s<r.length;s++)t+=He[r[s]];const n=`0x${t}`;return typeof e.size=="number"?(y(n,{size:e.size}),E(n,{dir:"right",size:e.size})):n}function Ee(r,e={}){const{signed:t,size:n}=e,s=BigInt(r);let a;n?t?a=(1n<<BigInt(n)*8n-1n)-1n:a=2n**(BigInt(n)*8n)-1n:typeof r=="number"&&(a=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof a=="bigint"&&t?-a-1n:0;if(a&&s>a||s<o){const l=typeof r=="bigint"?"n":"";throw new he({max:a?`${a}${l}`:void 0,min:`${o}${l}`,signed:t,size:n,value:`${r}${l}`})}const i=`0x${(t&&s<0?(1n<<BigInt(n*8))+BigInt(s):s).toString(16)}`;return n?E(i,{size:n}):i}const Fe=new TextEncoder;function We(r,e={}){const t=Fe.encode(r);return ge(t,e)}const qe=new TextEncoder;function Rt(r,e={}){return typeof r=="number"||typeof r=="bigint"?Ke(r,e):typeof r=="boolean"?Ge(r,e):me(r)?v(r,e):Ve(r,e)}function Ge(r,e={}){const t=new Uint8Array(1);return t[0]=Number(r),typeof e.size=="number"?(y(t,{size:e.size}),E(t,{size:e.size})):t}const m={zero:48,nine:57,A:65,F:70,a:97,f:102};function ue(r){if(r>=m.zero&&r<=m.nine)return r-m.zero;if(r>=m.A&&r<=m.F)return r-(m.A-10);if(r>=m.a&&r<=m.f)return r-(m.a-10)}function v(r,e={}){let t=r;e.size&&(y(t,{size:e.size}),t=E(t,{dir:"right",size:e.size}));let n=t.slice(2);n.length%2&&(n=`0${n}`);const s=n.length/2,a=new Uint8Array(s);for(let o=0,i=0;o<s;o++){const l=ue(n.charCodeAt(i++)),h=ue(n.charCodeAt(i++));if(l===void 0||h===void 0)throw new u(`Invalid byte sequence ("${n[i-2]}${n[i-1]}" in "${n}").`);a[o]=l*16+h}return a}function Ke(r,e){const t=Ee(r,e);return v(t)}function Ve(r,e={}){const t=qe.encode(r);return typeof e.size=="number"?(y(t,{size:e.size}),E(t,{dir:"right",size:e.size})):t}function y(r,{size:e}){if(ie(r)>e)throw new Be({givenSize:ie(r),maxSize:e})}function Pt(r,e){const t={to:e},n=t.to;return n==="number"?Ye(r,t):n==="bigint"?we(r,t):n==="string"?Je(r,t):n==="boolean"?Xe(r,t):v(r,t)}function we(r,e={}){const{signed:t}=e;e.size&&y(r,{size:e.size});const n=BigInt(r);if(!t)return n;const s=(r.length-2)/2,a=(1n<<BigInt(s)*8n-1n)-1n;return n<=a?n:n-BigInt(`0x${"f".padStart(s*2,"f")}`)-1n}function Xe(r,e={}){let t=r;if(e.size&&(y(t,{size:e.size}),t=T(t)),T(t)==="0x00")return!1;if(T(t)==="0x01")return!0;throw new De(t)}function Ye(r,e={}){const t=we(r,e),n=Number(t);if(!Number.isSafeInteger(n))throw new he({max:`${Number.MAX_SAFE_INTEGER}`,min:`${Number.MIN_SAFE_INTEGER}`,signed:e.signed,size:e.size,value:`${t}n`});return n}function Je(r,e={}){let t=v(r);return e.size&&(y(t,{size:e.size}),t=T(t,{dir:"right"})),new TextDecoder().decode(t)}const It={gwei:9,wei:18},Qe={ether:-9,wei:9};function Ze(r,e){let t=r.toString();const n=t.startsWith("-");n&&(t=t.slice(1)),t=t.padStart(e,"0");let[s,a]=[t.slice(0,t.length-e),t.slice(t.length-e)];return a=a.replace(/(0+)$/,""),`${n?"-":""}${s||"0"}${a?`.${a}`:""}`}function O(r,e="wei"){return Ze(r,Qe[e])}class Ne extends u{constructor({cause:e,message:t}={}){const n=t?.replace("execution reverted: ","")?.replace("execution reverted","");super(`Execution reverted ${n?`with reason: ${n}`:"for an unknown reason"}.`,{cause:e,name:"ExecutionRevertedError"})}}Object.defineProperty(Ne,"code",{enumerable:!0,configurable:!0,writable:!0,value:3});Object.defineProperty(Ne,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/execution reverted|gas required exceeds allowance/});class et extends u{constructor({cause:e,maxFeePerGas:t}={}){super(`The fee cap (\`maxFeePerGas\`${t?` = ${O(t)} gwei`:""}) cannot be higher than the maximum allowed value (2^256-1).`,{cause:e,name:"FeeCapTooHighError"})}}Object.defineProperty(et,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas higher than 2\^256-1|fee cap higher than 2\^256-1/});class tt extends u{constructor({cause:e,maxFeePerGas:t}={}){super(`The fee cap (\`maxFeePerGas\`${t?` = ${O(t)}`:""} gwei) cannot be lower than the block base fee.`,{cause:e,name:"FeeCapTooLowError"})}}Object.defineProperty(tt,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas less than block base fee|fee cap less than block base fee|transaction is outdated/});class rt extends u{constructor({cause:e,nonce:t}={}){super(`Nonce provided for the transaction ${t?`(${t}) `:""}is higher than the next one expected.`,{cause:e,name:"NonceTooHighError"})}}Object.defineProperty(rt,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too high/});class nt extends u{constructor({cause:e,nonce:t}={}){super([`Nonce provided for the transaction ${t?`(${t}) `:""}is lower than the current nonce of the account.`,"Try increasing the nonce or find the latest nonce with `getTransactionCount`."].join(`
|
|
3
3
|
`),{cause:e,name:"NonceTooLowError"})}}Object.defineProperty(nt,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too low|transaction already imported|already known/});class st extends u{constructor({cause:e,nonce:t}={}){super(`Nonce provided for the transaction ${t?`(${t}) `:""}exceeds the maximum allowed nonce.`,{cause:e,name:"NonceMaxValueError"})}}Object.defineProperty(st,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce has max value/});class at extends u{constructor({cause:e}={}){super(["The total cost (gas * gas fee + value) of executing this transaction exceeds the balance of the account."].join(`
|
|
4
4
|
`),{cause:e,metaMessages:["This error could arise when the account does not have enough funds to:"," - pay for the total gas fee,"," - pay for the value to send."," ","The cost of the transaction is calculated as `gas * gas fee + value`, where:"," - `gas` is the amount of gas needed for transaction to execute,"," - `gas fee` is the gas fee,"," - `value` is the amount of ether to send to the recipient."],name:"InsufficientFundsError"})}}Object.defineProperty(at,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/insufficient funds|exceeds transaction sender account balance/});class ot extends u{constructor({cause:e,gas:t}={}){super(`The amount of gas ${t?`(${t}) `:""}provided for the transaction exceeds the limit allowed for the block.`,{cause:e,name:"IntrinsicGasTooHighError"})}}Object.defineProperty(ot,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too high|gas limit reached/});class it extends u{constructor({cause:e,gas:t}={}){super(`The amount of gas ${t?`(${t}) `:""}provided for the transaction is too low.`,{cause:e,name:"IntrinsicGasTooLowError"})}}Object.defineProperty(it,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too low/});class ut extends u{constructor({cause:e}){super("The transaction type is not supported for this chain.",{cause:e,name:"TransactionTypeNotSupportedError"})}}Object.defineProperty(ut,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/transaction type not valid/});class ct extends u{constructor({cause:e,maxPriorityFeePerGas:t,maxFeePerGas:n}={}){super([`The provided tip (\`maxPriorityFeePerGas\`${t?` = ${O(t)} gwei`:""}) cannot be higher than the fee cap (\`maxFeePerGas\`${n?` = ${O(n)} gwei`:""}).`].join(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{N as d,j as B,R as p,S as k,k as P,E as I,l as h,W as y,C as T,B as f,b,m as A,A as D,n as M,d as C,g as F,o as L,e as _,i as W,p as G}from"./W3MFrameProviderSingleton-9eitOT0j.js";import{ap as m}from"./NetworkUtil-DqGcuBfF.js";const g={getGasPriceInEther(n,o){const t=o*n;return Number(t)/1e18},getGasPriceInUSD(n,o,t){const a=g.getGasPriceInEther(o,t);return d.bigNumber(n).times(a).toNumber()},getPriceImpact({sourceTokenAmount:n,sourceTokenPriceInUSD:o,toTokenPriceInUSD:t,toTokenAmount:a}){const i=d.bigNumber(n).times(o),r=d.bigNumber(a).times(t);return i.minus(r).div(i).times(100).toNumber()},getMaxSlippage(n,o){const t=d.bigNumber(n).div(100);return d.multiply(o,t).toNumber()},getProviderFee(n,o=.0085){return d.bigNumber(n).times(o).toString()},isInsufficientNetworkTokenForGas(n,o){const t=o||"0";return d.bigNumber(n).eq(0)?!0:d.bigNumber(d.bigNumber(t)).gt(n)},isInsufficientSourceTokenForSwap(n,o,t){const a=t?.find(r=>r.address===o)?.quantity?.numeric;return d.bigNumber(a||"0").lt(n)}},U=15e4,O=6,l={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:C.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=G({...l}),S={state:e,subscribe(n){return W(e,()=>n(e))},subscribeKey(n,o){return _(e,n,o)},getParams(){const n=T.state.activeChain,o=T.getAccountData(n)?.caipAddress??T.state.activeCaipAddress,t=b.getPlainAddress(o),a=F(),i=L.getConnectorId(T.state.activeChain);if(!t)throw new Error("No address found to swap the tokens from.");const r=!e.toToken?.address||!e.toToken?.decimals,c=!e.sourceToken?.address||!e.sourceToken?.decimals||!d.bigNumber(e.sourceTokenAmount).gt(0),u=!e.sourceTokenAmount;return{networkAddress:a,fromAddress:t,fromCaipAddress:o,sourceTokenAddress:e.sourceToken?.address,toTokenAddress:e.toToken?.address,toTokenAmount:e.toTokenAmount,toTokenDecimals:e.toToken?.decimals,sourceTokenAmount:e.sourceTokenAmount,sourceTokenDecimals:e.sourceToken?.decimals,invalidToToken:r,invalidSourceToken:c,invalidSourceTokenAmount:u,availableToSwap:o&&!r&&!c&&!u,isAuthConnector:i===m.CONNECTOR_ID.AUTH}},async setSourceToken(n){if(!n){e.sourceToken=n,e.sourceTokenAmount="",e.sourceTokenPriceInUSD=0;return}e.sourceToken=n,await s.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 s.setTokenPrice(n.address,"toToken")},setToTokenAmount(n){e.toTokenAmount=n?d.toFixed(n,O):""},async setTokenPrice(n,o){let t=e.tokensPriceMap[n]||0;t||(e.loadingPrices=!0,t=await s.getAddressPrice(n)),o==="sourceToken"?e.sourceTokenPriceInUSD=t:o==="toToken"&&(e.toTokenPriceInUSD=t),e.loadingPrices&&(e.loadingPrices=!1),s.getParams().availableToSwap&&!e.switchingTokens&&s.swapTokens()},async switchTokens(){if(!(e.initializing||!e.initialized||e.switchingTokens)){e.switchingTokens=!0;try{const n=e.toToken?{...e.toToken}:void 0,o=e.sourceToken?{...e.sourceToken}:void 0,t=n&&e.toTokenAmount===""?"1":e.toTokenAmount;s.setSourceTokenAmount(t),s.setToTokenAmount(""),await s.setSourceToken(n),await s.setToToken(o),e.switchingTokens=!1,s.swapTokens()}catch(n){throw e.switchingTokens=!1,n}}},resetState(){e.myTokensWithBalance=l.myTokensWithBalance,e.tokensPriceMap=l.tokensPriceMap,e.initialized=l.initialized,e.initializing=l.initializing,e.switchingTokens=l.switchingTokens,e.sourceToken=l.sourceToken,e.sourceTokenAmount=l.sourceTokenAmount,e.sourceTokenPriceInUSD=l.sourceTokenPriceInUSD,e.toToken=l.toToken,e.toTokenAmount=l.toTokenAmount,e.toTokenPriceInUSD=l.toTokenPriceInUSD,e.networkPrice=l.networkPrice,e.networkTokenSymbol=l.networkTokenSymbol,e.networkBalanceInUSD=l.networkBalanceInUSD,e.inputError=l.inputError},resetValues(){const{networkAddress:n}=s.getParams(),o=e.tokens?.find(t=>t.address===n);s.setSourceToken(o),s.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 s.fetchTokens(),e.initialized=!0}catch{e.initialized=!1,k.showError("Failed to initialize swap"),p.goBack()}e.initializing=!1}},async fetchTokens(){const{networkAddress:n}=s.getParams();await s.getNetworkTokenPrice(),await s.getMyTokensWithBalance();const o=e.myTokensWithBalance?.find(t=>t.address===n);o&&(e.networkTokenSymbol=o.symbol,s.setSourceToken(o),s.setSourceTokenAmount("0"))},async getTokenList(){const n=T.state.activeCaipNetwork?.caipNetworkId;if(!(e.caipNetworkId===n&&e.tokens))try{e.tokensLoading=!0;const o=await A.getTokenList(n);e.tokens=o,e.caipNetworkId=n,e.popularTokens=o.sort((c,u)=>c.symbol<u.symbol?-1:c.symbol>u.symbol?1:0);const a=(n&&C.SUGGESTED_TOKENS_BY_CHAIN?.[n]||[]).map(c=>o.find(u=>u.symbol===c)).filter(c=>!!c),r=(C.SWAP_SUGGESTED_TOKENS||[]).map(c=>o.find(u=>u.symbol===c)).filter(c=>!!c).filter(c=>!a.some(u=>u.address===c.address));e.suggestedTokens=[...a,...r]}catch{e.tokens=[],e.popularTokens=[],e.suggestedTokens=[]}finally{e.tokensLoading=!1}},async getAddressPrice(n){const o=e.tokensPriceMap[n];if(o)return o;const a=(await f.fetchTokenPrice({addresses:[n]}))?.fungibles||[],r=[...e.tokens||[],...e.myTokensWithBalance||[]]?.find(w=>w.address===n)?.symbol,c=a.find(w=>w.symbol.toLowerCase()===r?.toLowerCase())?.price||0,u=parseFloat(c.toString());return e.tokensPriceMap[n]=u,u},async getNetworkTokenPrice(){const{networkAddress:n}=s.getParams(),t=(await f.fetchTokenPrice({addresses:[n]}).catch(()=>(k.showError("Failed to fetch network token price"),{fungibles:[]}))).fungibles?.[0],a=t?.price.toString()||"0";e.tokensPriceMap[n]=parseFloat(a),e.networkTokenSymbol=t?.symbol||"",e.networkPrice=a},async getMyTokensWithBalance(n){const o=await M.getMyTokensWithBalance({forceUpdate:n,caipNetwork:T.state.activeCaipNetwork,address:T.getAccountData()?.address}),t=A.mapBalancesToSwapTokens(o);t&&(await s.getInitialGasPrice(),s.setBalances(t))},setBalances(n){const{networkAddress:o}=s.getParams(),t=T.state.activeCaipNetwork;if(!t)return;const a=n.find(i=>i.address===o);n.forEach(i=>{e.tokensPriceMap[i.address]=i.price||0}),e.myTokensWithBalance=n.filter(i=>i.address.startsWith(t.caipNetworkId)),e.networkBalanceInUSD=a?d.multiply(a.quantity.numeric,a.price).toString():"0"},async getInitialGasPrice(){const n=await A.fetchGasPrice();if(!n)return{gasPrice:null,gasPriceInUSD:null};switch(T.state?.activeCaipNetwork?.chainNamespace){case m.CHAIN.SOLANA:return e.gasFee=n.standard??"0",e.gasPriceInUSD=d.multiply(n.standard,e.networkPrice).div(1e9).toNumber(),{gasPrice:BigInt(e.gasFee),gasPriceInUSD:Number(e.gasPriceInUSD)};case m.CHAIN.EVM:default:const o=n.standard??"0",t=BigInt(o),a=BigInt(U),i=g.getGasPriceInUSD(e.networkPrice,a,t);return e.gasFee=o,e.gasPriceInUSD=i,{gasPrice:t,gasPriceInUSD:i}}},async swapTokens(){const n=T.getAccountData()?.address,o=e.sourceToken,t=e.toToken,a=d.bigNumber(e.sourceTokenAmount).gt(0);if(a||s.setToTokenAmount(""),!t||!o||e.loadingPrices||!a||!n)return;e.loadingQuote=!0;const i=d.bigNumber(e.sourceTokenAmount).times(10**o.decimals).round(0).toFixed(0);try{const r=await f.fetchSwapQuote({userAddress:n,from:o.address,to:t.address,gasPrice:e.gasFee,amount:i.toString()});e.loadingQuote=!1;const c=r?.quotes?.[0]?.toAmount;if(!c){D.open({displayMessage:"Incorrect amount",debugMessage:"Please enter a valid amount"},"error");return}const u=d.bigNumber(c).div(10**t.decimals).toString();s.setToTokenAmount(u),s.hasInsufficientToken(e.sourceTokenAmount,o.address)?e.inputError="Insufficient balance":(e.inputError=void 0,s.setTransactionDetails())}catch(r){const c=await A.handleSwapError(r);e.loadingQuote=!1,e.inputError=c||"Insufficient balance"}},async getTransaction(){const{fromCaipAddress:n,availableToSwap:o}=s.getParams(),t=e.sourceToken,a=e.toToken;if(!(!n||!o||!t||!a||e.loadingQuote))try{e.loadingBuildTransaction=!0;const i=await A.fetchSwapAllowance({userAddress:n,tokenAddress:t.address,sourceTokenAmount:e.sourceTokenAmount,sourceTokenDecimals:t.decimals});let r;return i?r=await s.createSwapTransaction():r=await s.createAllowanceTransaction(),e.loadingBuildTransaction=!1,e.fetchError=!1,r}catch{p.goBack(),k.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:o,toTokenAddress:t}=s.getParams();if(!(!n||!t)){if(!o)throw new Error("createAllowanceTransaction - No source token address found.");try{const a=await f.generateApproveCalldata({from:o,to:t,userAddress:n}),i=b.getPlainAddress(a.tx.from);if(!i)throw new Error("SwapController:createAllowanceTransaction - address is required");const r={data:a.tx.data,to:i,gasPrice:BigInt(a.tx.eip155.gasPrice),value:BigInt(a.tx.value),toAmount:e.toTokenAmount};return e.swapTransaction=void 0,e.approvalTransaction={data:r.data,to:r.to,gasPrice:r.gasPrice,value:r.value,toAmount:r.toAmount},{data:r.data,to:r.to,gasPrice:r.gasPrice,value:r.value,toAmount:r.toAmount}}catch{p.goBack(),k.showError("Failed to create approval transaction"),e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}}},async createSwapTransaction(){const{networkAddress:n,fromCaipAddress:o,sourceTokenAmount:t}=s.getParams(),a=e.sourceToken,i=e.toToken;if(!o||!t||!a||!i)return;const r=P.parseUnits(t,a.decimals)?.toString();try{const c=await f.generateSwapCalldata({userAddress:o,from:a.address,to:i.address,amount:r,disableEstimate:!0}),u=a.address===n,w=BigInt(c.tx.eip155.gas),N=BigInt(c.tx.eip155.gasPrice),v=b.getPlainAddress(c.tx.to);if(!v)throw new Error("SwapController:createSwapTransaction - address is required");const E={data:c.tx.data,to:v,gas:w,gasPrice:N,value:BigInt(u?r??"0":"0"),toAmount:e.toTokenAmount};return e.gasPriceInUSD=g.getGasPriceInUSD(e.networkPrice,w,N),e.approvalTransaction=void 0,e.swapTransaction=E,E}catch{p.goBack(),k.showError("Failed to create transaction"),e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}},onEmbeddedWalletApprovalSuccess(){k.showLoading("Approve limit increase in your wallet"),p.replace("SwapPreview")},async sendTransactionForApproval(n){const{fromAddress:o,isAuthConnector:t}=s.getParams();e.loadingApprovalTransaction=!0,t?p.pushTransactionStack({onSuccess:s.onEmbeddedWalletApprovalSuccess}):k.showLoading("Approve limit increase in your wallet");try{await P.sendTransaction({address:o,to:n.to,data:n.data,value:n.value,chainNamespace:m.CHAIN.EVM}),await s.swapTokens(),await s.getTransaction(),e.approvalTransaction=void 0,e.loadingApprovalTransaction=!1}catch(i){const r=i;e.transactionError=r?.displayMessage,e.loadingApprovalTransaction=!1,k.showError(r?.displayMessage||"Transaction error"),I.sendEvent({type:"track",event:"SWAP_APPROVAL_ERROR",properties:{message:r?.displayMessage||r?.message||"Unknown",network:T.state.activeCaipNetwork?.caipNetworkId||"",swapFromToken:s.state.sourceToken?.symbol||"",swapToToken:s.state.toToken?.symbol||"",swapFromAmount:s.state.sourceTokenAmount||"",swapToAmount:s.state.toTokenAmount||"",isSmartAccount:h(m.CHAIN.EVM)===y.ACCOUNT_TYPES.SMART_ACCOUNT}})}},async sendTransactionForSwap(n){if(!n)return;const{fromAddress:o,toTokenAmount:t,isAuthConnector:a}=s.getParams();e.loadingTransaction=!0;const i=`Swapping ${e.sourceToken?.symbol} to ${d.formatNumberToLocalString(t,3)} ${e.toToken?.symbol}`,r=`Swapped ${e.sourceToken?.symbol} to ${d.formatNumberToLocalString(t,3)} ${e.toToken?.symbol}`;a?p.pushTransactionStack({onSuccess(){p.replace("Account"),k.showLoading(i),S.resetState()}}):k.showLoading("Confirm transaction in your wallet");try{const c=[e.sourceToken?.address,e.toToken?.address].join(","),u=await P.sendTransaction({address:o,to:n.to,data:n.data,value:n.value,chainNamespace:m.CHAIN.EVM});return e.loadingTransaction=!1,k.showSuccess(r),I.sendEvent({type:"track",event:"SWAP_SUCCESS",properties:{network:T.state.activeCaipNetwork?.caipNetworkId||"",swapFromToken:s.state.sourceToken?.symbol||"",swapToToken:s.state.toToken?.symbol||"",swapFromAmount:s.state.sourceTokenAmount||"",swapToAmount:s.state.toTokenAmount||"",isSmartAccount:h(m.CHAIN.EVM)===y.ACCOUNT_TYPES.SMART_ACCOUNT}}),S.resetState(),a||p.replace("Account"),S.getMyTokensWithBalance(c),u}catch(c){const u=c;e.transactionError=u?.displayMessage,e.loadingTransaction=!1,k.showError(u?.displayMessage||"Transaction error"),I.sendEvent({type:"track",event:"SWAP_ERROR",properties:{message:u?.displayMessage||u?.message||"Unknown",network:T.state.activeCaipNetwork?.caipNetworkId||"",swapFromToken:s.state.sourceToken?.symbol||"",swapToToken:s.state.toToken?.symbol||"",swapFromAmount:s.state.sourceTokenAmount||"",swapToAmount:s.state.toTokenAmount||"",isSmartAccount:h(m.CHAIN.EVM)===y.ACCOUNT_TYPES.SMART_ACCOUNT}});return}},hasInsufficientToken(n,o){return g.isInsufficientSourceTokenForSwap(n,o,e.myTokensWithBalance)},setTransactionDetails(){const{toTokenAddress:n,toTokenDecimals:o}=s.getParams();!n||!o||(e.gasPriceInUSD=g.getGasPriceInUSD(e.networkPrice,BigInt(e.gasFee),BigInt(U)),e.priceImpact=g.getPriceImpact({sourceTokenAmount:e.sourceTokenAmount,sourceTokenPriceInUSD:e.sourceTokenPriceInUSD,toTokenPriceInUSD:e.toTokenPriceInUSD,toTokenAmount:e.toTokenAmount}),e.maxSlippage=g.getMaxSlippage(e.slippage,e.toTokenAmount),e.providerFee=g.getProviderFee(e.sourceTokenAmount))}},s=B(S);export{s as S};
|
|
1
|
+
import{N as d,j as B,R as p,S as k,k as P,E as I,l as h,W as y,C as T,B as f,b,m as A,A as D,n as M,d as C,g as F,o as L,e as _,i as W,p as G}from"./W3MFrameProviderSingleton-dGwr0u32.js";import{ap as m}from"./NetworkUtil-DM5H1DOt.js";const g={getGasPriceInEther(n,o){const t=o*n;return Number(t)/1e18},getGasPriceInUSD(n,o,t){const a=g.getGasPriceInEther(o,t);return d.bigNumber(n).times(a).toNumber()},getPriceImpact({sourceTokenAmount:n,sourceTokenPriceInUSD:o,toTokenPriceInUSD:t,toTokenAmount:a}){const i=d.bigNumber(n).times(o),r=d.bigNumber(a).times(t);return i.minus(r).div(i).times(100).toNumber()},getMaxSlippage(n,o){const t=d.bigNumber(n).div(100);return d.multiply(o,t).toNumber()},getProviderFee(n,o=.0085){return d.bigNumber(n).times(o).toString()},isInsufficientNetworkTokenForGas(n,o){const t=o||"0";return d.bigNumber(n).eq(0)?!0:d.bigNumber(d.bigNumber(t)).gt(n)},isInsufficientSourceTokenForSwap(n,o,t){const a=t?.find(r=>r.address===o)?.quantity?.numeric;return d.bigNumber(a||"0").lt(n)}},U=15e4,O=6,l={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:C.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=G({...l}),S={state:e,subscribe(n){return W(e,()=>n(e))},subscribeKey(n,o){return _(e,n,o)},getParams(){const n=T.state.activeChain,o=T.getAccountData(n)?.caipAddress??T.state.activeCaipAddress,t=b.getPlainAddress(o),a=F(),i=L.getConnectorId(T.state.activeChain);if(!t)throw new Error("No address found to swap the tokens from.");const r=!e.toToken?.address||!e.toToken?.decimals,c=!e.sourceToken?.address||!e.sourceToken?.decimals||!d.bigNumber(e.sourceTokenAmount).gt(0),u=!e.sourceTokenAmount;return{networkAddress:a,fromAddress:t,fromCaipAddress:o,sourceTokenAddress:e.sourceToken?.address,toTokenAddress:e.toToken?.address,toTokenAmount:e.toTokenAmount,toTokenDecimals:e.toToken?.decimals,sourceTokenAmount:e.sourceTokenAmount,sourceTokenDecimals:e.sourceToken?.decimals,invalidToToken:r,invalidSourceToken:c,invalidSourceTokenAmount:u,availableToSwap:o&&!r&&!c&&!u,isAuthConnector:i===m.CONNECTOR_ID.AUTH}},async setSourceToken(n){if(!n){e.sourceToken=n,e.sourceTokenAmount="",e.sourceTokenPriceInUSD=0;return}e.sourceToken=n,await s.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 s.setTokenPrice(n.address,"toToken")},setToTokenAmount(n){e.toTokenAmount=n?d.toFixed(n,O):""},async setTokenPrice(n,o){let t=e.tokensPriceMap[n]||0;t||(e.loadingPrices=!0,t=await s.getAddressPrice(n)),o==="sourceToken"?e.sourceTokenPriceInUSD=t:o==="toToken"&&(e.toTokenPriceInUSD=t),e.loadingPrices&&(e.loadingPrices=!1),s.getParams().availableToSwap&&!e.switchingTokens&&s.swapTokens()},async switchTokens(){if(!(e.initializing||!e.initialized||e.switchingTokens)){e.switchingTokens=!0;try{const n=e.toToken?{...e.toToken}:void 0,o=e.sourceToken?{...e.sourceToken}:void 0,t=n&&e.toTokenAmount===""?"1":e.toTokenAmount;s.setSourceTokenAmount(t),s.setToTokenAmount(""),await s.setSourceToken(n),await s.setToToken(o),e.switchingTokens=!1,s.swapTokens()}catch(n){throw e.switchingTokens=!1,n}}},resetState(){e.myTokensWithBalance=l.myTokensWithBalance,e.tokensPriceMap=l.tokensPriceMap,e.initialized=l.initialized,e.initializing=l.initializing,e.switchingTokens=l.switchingTokens,e.sourceToken=l.sourceToken,e.sourceTokenAmount=l.sourceTokenAmount,e.sourceTokenPriceInUSD=l.sourceTokenPriceInUSD,e.toToken=l.toToken,e.toTokenAmount=l.toTokenAmount,e.toTokenPriceInUSD=l.toTokenPriceInUSD,e.networkPrice=l.networkPrice,e.networkTokenSymbol=l.networkTokenSymbol,e.networkBalanceInUSD=l.networkBalanceInUSD,e.inputError=l.inputError},resetValues(){const{networkAddress:n}=s.getParams(),o=e.tokens?.find(t=>t.address===n);s.setSourceToken(o),s.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 s.fetchTokens(),e.initialized=!0}catch{e.initialized=!1,k.showError("Failed to initialize swap"),p.goBack()}e.initializing=!1}},async fetchTokens(){const{networkAddress:n}=s.getParams();await s.getNetworkTokenPrice(),await s.getMyTokensWithBalance();const o=e.myTokensWithBalance?.find(t=>t.address===n);o&&(e.networkTokenSymbol=o.symbol,s.setSourceToken(o),s.setSourceTokenAmount("0"))},async getTokenList(){const n=T.state.activeCaipNetwork?.caipNetworkId;if(!(e.caipNetworkId===n&&e.tokens))try{e.tokensLoading=!0;const o=await A.getTokenList(n);e.tokens=o,e.caipNetworkId=n,e.popularTokens=o.sort((c,u)=>c.symbol<u.symbol?-1:c.symbol>u.symbol?1:0);const a=(n&&C.SUGGESTED_TOKENS_BY_CHAIN?.[n]||[]).map(c=>o.find(u=>u.symbol===c)).filter(c=>!!c),r=(C.SWAP_SUGGESTED_TOKENS||[]).map(c=>o.find(u=>u.symbol===c)).filter(c=>!!c).filter(c=>!a.some(u=>u.address===c.address));e.suggestedTokens=[...a,...r]}catch{e.tokens=[],e.popularTokens=[],e.suggestedTokens=[]}finally{e.tokensLoading=!1}},async getAddressPrice(n){const o=e.tokensPriceMap[n];if(o)return o;const a=(await f.fetchTokenPrice({addresses:[n]}))?.fungibles||[],r=[...e.tokens||[],...e.myTokensWithBalance||[]]?.find(w=>w.address===n)?.symbol,c=a.find(w=>w.symbol.toLowerCase()===r?.toLowerCase())?.price||0,u=parseFloat(c.toString());return e.tokensPriceMap[n]=u,u},async getNetworkTokenPrice(){const{networkAddress:n}=s.getParams(),t=(await f.fetchTokenPrice({addresses:[n]}).catch(()=>(k.showError("Failed to fetch network token price"),{fungibles:[]}))).fungibles?.[0],a=t?.price.toString()||"0";e.tokensPriceMap[n]=parseFloat(a),e.networkTokenSymbol=t?.symbol||"",e.networkPrice=a},async getMyTokensWithBalance(n){const o=await M.getMyTokensWithBalance({forceUpdate:n,caipNetwork:T.state.activeCaipNetwork,address:T.getAccountData()?.address}),t=A.mapBalancesToSwapTokens(o);t&&(await s.getInitialGasPrice(),s.setBalances(t))},setBalances(n){const{networkAddress:o}=s.getParams(),t=T.state.activeCaipNetwork;if(!t)return;const a=n.find(i=>i.address===o);n.forEach(i=>{e.tokensPriceMap[i.address]=i.price||0}),e.myTokensWithBalance=n.filter(i=>i.address.startsWith(t.caipNetworkId)),e.networkBalanceInUSD=a?d.multiply(a.quantity.numeric,a.price).toString():"0"},async getInitialGasPrice(){const n=await A.fetchGasPrice();if(!n)return{gasPrice:null,gasPriceInUSD:null};switch(T.state?.activeCaipNetwork?.chainNamespace){case m.CHAIN.SOLANA:return e.gasFee=n.standard??"0",e.gasPriceInUSD=d.multiply(n.standard,e.networkPrice).div(1e9).toNumber(),{gasPrice:BigInt(e.gasFee),gasPriceInUSD:Number(e.gasPriceInUSD)};case m.CHAIN.EVM:default:const o=n.standard??"0",t=BigInt(o),a=BigInt(U),i=g.getGasPriceInUSD(e.networkPrice,a,t);return e.gasFee=o,e.gasPriceInUSD=i,{gasPrice:t,gasPriceInUSD:i}}},async swapTokens(){const n=T.getAccountData()?.address,o=e.sourceToken,t=e.toToken,a=d.bigNumber(e.sourceTokenAmount).gt(0);if(a||s.setToTokenAmount(""),!t||!o||e.loadingPrices||!a||!n)return;e.loadingQuote=!0;const i=d.bigNumber(e.sourceTokenAmount).times(10**o.decimals).round(0).toFixed(0);try{const r=await f.fetchSwapQuote({userAddress:n,from:o.address,to:t.address,gasPrice:e.gasFee,amount:i.toString()});e.loadingQuote=!1;const c=r?.quotes?.[0]?.toAmount;if(!c){D.open({displayMessage:"Incorrect amount",debugMessage:"Please enter a valid amount"},"error");return}const u=d.bigNumber(c).div(10**t.decimals).toString();s.setToTokenAmount(u),s.hasInsufficientToken(e.sourceTokenAmount,o.address)?e.inputError="Insufficient balance":(e.inputError=void 0,s.setTransactionDetails())}catch(r){const c=await A.handleSwapError(r);e.loadingQuote=!1,e.inputError=c||"Insufficient balance"}},async getTransaction(){const{fromCaipAddress:n,availableToSwap:o}=s.getParams(),t=e.sourceToken,a=e.toToken;if(!(!n||!o||!t||!a||e.loadingQuote))try{e.loadingBuildTransaction=!0;const i=await A.fetchSwapAllowance({userAddress:n,tokenAddress:t.address,sourceTokenAmount:e.sourceTokenAmount,sourceTokenDecimals:t.decimals});let r;return i?r=await s.createSwapTransaction():r=await s.createAllowanceTransaction(),e.loadingBuildTransaction=!1,e.fetchError=!1,r}catch{p.goBack(),k.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:o,toTokenAddress:t}=s.getParams();if(!(!n||!t)){if(!o)throw new Error("createAllowanceTransaction - No source token address found.");try{const a=await f.generateApproveCalldata({from:o,to:t,userAddress:n}),i=b.getPlainAddress(a.tx.from);if(!i)throw new Error("SwapController:createAllowanceTransaction - address is required");const r={data:a.tx.data,to:i,gasPrice:BigInt(a.tx.eip155.gasPrice),value:BigInt(a.tx.value),toAmount:e.toTokenAmount};return e.swapTransaction=void 0,e.approvalTransaction={data:r.data,to:r.to,gasPrice:r.gasPrice,value:r.value,toAmount:r.toAmount},{data:r.data,to:r.to,gasPrice:r.gasPrice,value:r.value,toAmount:r.toAmount}}catch{p.goBack(),k.showError("Failed to create approval transaction"),e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}}},async createSwapTransaction(){const{networkAddress:n,fromCaipAddress:o,sourceTokenAmount:t}=s.getParams(),a=e.sourceToken,i=e.toToken;if(!o||!t||!a||!i)return;const r=P.parseUnits(t,a.decimals)?.toString();try{const c=await f.generateSwapCalldata({userAddress:o,from:a.address,to:i.address,amount:r,disableEstimate:!0}),u=a.address===n,w=BigInt(c.tx.eip155.gas),N=BigInt(c.tx.eip155.gasPrice),v=b.getPlainAddress(c.tx.to);if(!v)throw new Error("SwapController:createSwapTransaction - address is required");const E={data:c.tx.data,to:v,gas:w,gasPrice:N,value:BigInt(u?r??"0":"0"),toAmount:e.toTokenAmount};return e.gasPriceInUSD=g.getGasPriceInUSD(e.networkPrice,w,N),e.approvalTransaction=void 0,e.swapTransaction=E,E}catch{p.goBack(),k.showError("Failed to create transaction"),e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}},onEmbeddedWalletApprovalSuccess(){k.showLoading("Approve limit increase in your wallet"),p.replace("SwapPreview")},async sendTransactionForApproval(n){const{fromAddress:o,isAuthConnector:t}=s.getParams();e.loadingApprovalTransaction=!0,t?p.pushTransactionStack({onSuccess:s.onEmbeddedWalletApprovalSuccess}):k.showLoading("Approve limit increase in your wallet");try{await P.sendTransaction({address:o,to:n.to,data:n.data,value:n.value,chainNamespace:m.CHAIN.EVM}),await s.swapTokens(),await s.getTransaction(),e.approvalTransaction=void 0,e.loadingApprovalTransaction=!1}catch(i){const r=i;e.transactionError=r?.displayMessage,e.loadingApprovalTransaction=!1,k.showError(r?.displayMessage||"Transaction error"),I.sendEvent({type:"track",event:"SWAP_APPROVAL_ERROR",properties:{message:r?.displayMessage||r?.message||"Unknown",network:T.state.activeCaipNetwork?.caipNetworkId||"",swapFromToken:s.state.sourceToken?.symbol||"",swapToToken:s.state.toToken?.symbol||"",swapFromAmount:s.state.sourceTokenAmount||"",swapToAmount:s.state.toTokenAmount||"",isSmartAccount:h(m.CHAIN.EVM)===y.ACCOUNT_TYPES.SMART_ACCOUNT}})}},async sendTransactionForSwap(n){if(!n)return;const{fromAddress:o,toTokenAmount:t,isAuthConnector:a}=s.getParams();e.loadingTransaction=!0;const i=`Swapping ${e.sourceToken?.symbol} to ${d.formatNumberToLocalString(t,3)} ${e.toToken?.symbol}`,r=`Swapped ${e.sourceToken?.symbol} to ${d.formatNumberToLocalString(t,3)} ${e.toToken?.symbol}`;a?p.pushTransactionStack({onSuccess(){p.replace("Account"),k.showLoading(i),S.resetState()}}):k.showLoading("Confirm transaction in your wallet");try{const c=[e.sourceToken?.address,e.toToken?.address].join(","),u=await P.sendTransaction({address:o,to:n.to,data:n.data,value:n.value,chainNamespace:m.CHAIN.EVM});return e.loadingTransaction=!1,k.showSuccess(r),I.sendEvent({type:"track",event:"SWAP_SUCCESS",properties:{network:T.state.activeCaipNetwork?.caipNetworkId||"",swapFromToken:s.state.sourceToken?.symbol||"",swapToToken:s.state.toToken?.symbol||"",swapFromAmount:s.state.sourceTokenAmount||"",swapToAmount:s.state.toTokenAmount||"",isSmartAccount:h(m.CHAIN.EVM)===y.ACCOUNT_TYPES.SMART_ACCOUNT}}),S.resetState(),a||p.replace("Account"),S.getMyTokensWithBalance(c),u}catch(c){const u=c;e.transactionError=u?.displayMessage,e.loadingTransaction=!1,k.showError(u?.displayMessage||"Transaction error"),I.sendEvent({type:"track",event:"SWAP_ERROR",properties:{message:u?.displayMessage||u?.message||"Unknown",network:T.state.activeCaipNetwork?.caipNetworkId||"",swapFromToken:s.state.sourceToken?.symbol||"",swapToToken:s.state.toToken?.symbol||"",swapFromAmount:s.state.sourceTokenAmount||"",swapToAmount:s.state.toTokenAmount||"",isSmartAccount:h(m.CHAIN.EVM)===y.ACCOUNT_TYPES.SMART_ACCOUNT}});return}},hasInsufficientToken(n,o){return g.isInsufficientSourceTokenForSwap(n,o,e.myTokensWithBalance)},setTransactionDetails(){const{toTokenAddress:n,toTokenDecimals:o}=s.getParams();!n||!o||(e.gasPriceInUSD=g.getGasPriceInUSD(e.networkPrice,BigInt(e.gasFee),BigInt(U)),e.priceImpact=g.getPriceImpact({sourceTokenAmount:e.sourceTokenAmount,sourceTokenPriceInUSD:e.sourceTokenPriceInUSD,toTokenPriceInUSD:e.toTokenPriceInUSD,toTokenAmount:e.toTokenAmount}),e.maxSlippage=g.getMaxSlippage(e.slippage,e.toTokenAmount),e.providerFee=g.getProviderFee(e.sourceTokenAmount))}},s=B(S);export{s as S};
|