@dcl/auth-site 4.21.1-30289583460.commit-46bdbdf → 5.0.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.
Files changed (118) hide show
  1. package/assets/{ConstantsUtil-Cw4CyveW.js → ConstantsUtil-Dg0DgKPJ.js} +1 -1
  2. package/assets/{ContentfulRichText-BT96-A7w.js → ContentfulRichText-DfW2Q0q7.js} +1 -1
  3. package/assets/{ExchangeController-BIE70uXJ.js → ExchangeController-CYA8JgbM.js} +1 -1
  4. package/assets/{HelpersUtil-COH6r2kA.js → HelpersUtil-dxZVQuN-.js} +1 -1
  5. package/assets/LoginPage-8RP9Q8et.js +1 -0
  6. package/assets/{NetworkUtil-BGKHKoaf.js → NetworkUtil-Cdd9AsyN.js} +1 -1
  7. package/assets/{SwapController-CYoV1KaM.js → SwapController-BlcGzBYp.js} +1 -1
  8. package/assets/{W3MFrameProviderSingleton-BKmP_oxD.js → W3MFrameProviderSingleton-DszZRKRh.js} +3 -3
  9. package/assets/{biconomy-C7o8zrOF.js → biconomy-DMDB2WCq.js} +1 -1
  10. package/assets/{browser-jyTXFcNa.js → browser-CDS4yNuG.js} +1 -1
  11. package/assets/browser-ponyfill-jVOY3rKN.js +1 -0
  12. package/assets/{ccip-0sHJmZED.js → ccip-CfOrstq6.js} +1 -1
  13. package/assets/{ccip-_D3P6GZf.js → ccip-SMYalGhL.js} +1 -1
  14. package/assets/{chains-DPTnBL64.js → chains-BSD1mUUF.js} +1 -1
  15. package/assets/{common-CHSeSCWT.js → common-BpnpH7bs.js} +1 -1
  16. package/assets/{controller-C64KTqP4.js → controller-B_OTdDKf.js} +2 -2
  17. package/assets/{data-capture-Cx4b9vYS.js → data-capture-BhiDpJ8l.js} +1 -1
  18. package/assets/{email-BQdM1ASh.js → email-Dz_1RIun.js} +1 -1
  19. package/assets/{embedded-wallet-CXUgkaij.js → embedded-wallet-Vq8AAsxz.js} +1 -1
  20. package/assets/{engine-DN05o7om.js → engine-CUXu1pAJ.js} +1 -1
  21. package/assets/{estimate-l1-fee--u86zfdZ.js → estimate-l1-fee-BbYg2jnm.js} +1 -1
  22. package/assets/{ethereum-CJbf5HCu.js → ethereum-DLnWj0TT.js} +1 -1
  23. package/assets/{extractIPFS-DJBAzpfR.js → extractIPFS-E6dbI5B3.js} +1 -1
  24. package/assets/{features-BaQq55bG.js → features-B5VCvl8a.js} +1 -1
  25. package/assets/{fetchTokenMetadata-C1ngO7HU.js → fetchTokenMetadata-_TSiSql-.js} +1 -1
  26. package/assets/{fortmatic-CM-36WpK.js → fortmatic-DeD4v7Wq.js} +1 -1
  27. package/assets/{get-ecosystem-wallet-info-D3mZ828S.js → get-ecosystem-wallet-info-BfODWfKc.js} +1 -1
  28. package/assets/{getBalance-DMdDUfLy.js → getBalance-CpIjM2cg.js} +1 -1
  29. package/assets/{getInstalledModules-DOdq5s84.js → getInstalledModules-C7OExu07.js} +1 -1
  30. package/assets/{getNFT-B8132wTr.js → getNFT-DUZCgW_v.js} +2 -2
  31. package/assets/{getNFT-Df4p3NnO.js → getNFT-NGH_lUB-.js} +1 -1
  32. package/assets/{if-defined-Bl8a4ab-.js → if-defined-B-CxqoOy.js} +1 -1
  33. package/assets/{in-app-DOg1gcN6.js → in-app-Dr0XnxnC.js} +2 -2
  34. package/assets/{in-app-wallet-calls-C3XXM2uK.js → in-app-wallet-calls-CVnjwSXD.js} +1 -1
  35. package/assets/{index-DKNEknrt.js → index-AtWUrs5K.js} +1 -1
  36. package/assets/{index-C8c8VNHR.js → index-B-AvExe7.js} +1 -1
  37. package/assets/{index-BCq7sn5F.js → index-B17222Rk.js} +1 -1
  38. package/assets/{index-DAclPpwc.js → index-B4XpHOJV.js} +3 -3
  39. package/assets/{index-Z08B4dd3.js → index-B71s3Unl.js} +1 -1
  40. package/assets/{index-aZ_z0i3j.js → index-BHr-h4IK.js} +1 -1
  41. package/assets/{index-BMLKyv2l.js → index-BMV5TwLV.js} +3 -3
  42. package/assets/{index-tF1SLBXL.js → index-BOTjRb-A.js} +1 -1
  43. package/assets/{index-DYaEHsOY.js → index-BQjhRxEw.js} +1 -1
  44. package/assets/{index-Bk62IJ7q.js → index-BSlDJ2rE.js} +1 -1
  45. package/assets/{index-Dk7lZXfn.js → index-BTCFHuS2.js} +1 -1
  46. package/assets/{index-DPWHpwh1.js → index-BVRqITf-.js} +9 -9
  47. package/assets/{index-CZmexbhB.js → index-BWA7Dnf9.js} +1 -1
  48. package/assets/{index-DAoXeY-7.js → index-Bbp98Yo4.js} +1 -1
  49. package/assets/{index-DkXO_kZj.js → index-By4Ejenx.js} +1 -1
  50. package/assets/{index-n7PJcE82.js → index-C8qBmpOs.js} +1 -1
  51. package/assets/{index-456fp1SV.js → index-C8sFl9y_.js} +1 -1
  52. package/assets/{index-Bc52X0iQ.js → index-CFOjd25G.js} +1 -1
  53. package/assets/{index-CTYL6USa.js → index-CFQ5zLHq.js} +1 -1
  54. package/assets/{index-CT312b_h.js → index-CGK33Zf3.js} +1 -1
  55. package/assets/{index-CwCHLbKJ.js → index-CIwcdVXz.js} +1 -1
  56. package/assets/{index-B1wz7Owl.js → index-CMurtdVK.js} +1 -1
  57. package/assets/{index-Cuhzd-33.js → index-CQTx6uje.js} +1 -1
  58. package/assets/{index-wL64_peq.js → index-CRTrW1Cr.js} +1 -1
  59. package/assets/{index-BKdNzTPl.js → index-CU7LDmTm.js} +3 -3
  60. package/assets/{index--khZ3g0E.js → index-CVaRPgqk.js} +2 -2
  61. package/assets/{index-DLDBtSCZ.js → index-CajP97ih.js} +1 -1
  62. package/assets/{index-Dhjx38e5.js → index-CguhMBVV.js} +1 -1
  63. package/assets/{index-BtsxTU_X.js → index-CiRr_FQj.js} +1 -1
  64. package/assets/index-CrsgkHzi.css +1 -0
  65. package/assets/{index-ZGp_PUF2.js → index-CsWu1J5q.js} +1 -1
  66. package/assets/{index-Bx5a0Vg2.js → index-CtSjOT3C.js} +1 -1
  67. package/assets/{index-CB0KMBUn.js → index-CyefDYRY.js} +1 -1
  68. package/assets/{index-DK67hOZb.js → index-D0-rCtUz.js} +1 -1
  69. package/assets/{index-BX3tZejP.js → index-DGDq3kyy.js} +1 -1
  70. package/assets/{index-D3ndDNzn.js → index-DTAN6EG4.js} +1 -1
  71. package/assets/{index-r-swI_-s.js → index-DgBqViSr.js} +1 -1
  72. package/assets/{index-BazvSf0U.js → index-Dgqfdyrb.js} +1 -1
  73. package/assets/{index-CBS6SUOD.js → index-DhlyurbW.js} +1 -1
  74. package/assets/{index-bW418N1D.js → index-DnAI-Tby.js} +1 -1
  75. package/assets/{index-DDa27cxc.js → index-DndmGjQP.js} +1 -1
  76. package/assets/{index-D2phLp5f.js → index-DoM5bFDD.js} +1 -1
  77. package/assets/{index-5JpvePdb.js → index-GhmakdXN.js} +1 -1
  78. package/assets/{index-CjOKquSH.js → index-U_AZIOYs.js} +1 -1
  79. package/assets/{index-D3gAQcpU.js → index-_3_jX9RC.js} +2 -2
  80. package/assets/{index-Di_Hl_iK.js → index-bgIfRIh2.js} +1 -1
  81. package/assets/{index-CPSrsrPD.js → index-jb4OCwoq.js} +1 -1
  82. package/assets/{index-CMn1rqzs.js → index-orYhT9Ul.js} +1 -1
  83. package/assets/{index-CfMamdHz.js → index-zguct6tW.js} +1 -1
  84. package/assets/{index.es-BOYbQise.js → index.es-BK3z8yc7.js} +1 -1
  85. package/assets/{index.es-DRRWBSJv.js → index.es-thRfdo4b.js} +1 -1
  86. package/assets/{linkAccount-C5bSjc1T.js → linkAccount-CYbxngjz.js} +1 -1
  87. package/assets/{native-CV5tv0TG.js → native-yw_E6q3K.js} +1 -1
  88. package/assets/{networks-C86eT1TG.js → networks-DvPy11h-.js} +3 -3
  89. package/assets/{onramp-BOODe8UW.js → onramp-C7JCWSIA.js} +1 -1
  90. package/assets/{openzeppelin-D68EAkgg.js → openzeppelin-3-DVb04n.js} +1 -1
  91. package/assets/{ownerOf-CursHafI.js → ownerOf-CXNoFK7Y.js} +1 -1
  92. package/assets/{parseNft-n7ZvU0Fd.js → parseNft-CkkgeIH7.js} +2 -2
  93. package/assets/{pay-with-exchange-WgJKv9uo.js → pay-with-exchange-Cp4dkwE4.js} +1 -1
  94. package/assets/{qr-overlay-D8U0fVP-.js → qr-overlay-DrtFZGBr.js} +3 -3
  95. package/assets/{receive-BqvjZCLR.js → receive-4Qe7X8hw.js} +1 -1
  96. package/assets/{ref-kgQxGa5I.js → ref-BJe9DjD9.js} +1 -1
  97. package/assets/{resolveImplementation-B4GM10am.js → resolveImplementation-CS9w_uBz.js} +1 -1
  98. package/assets/{secp256k1-CpwTLmAw.js → secp256k1-DELqHfAP.js} +1 -1
  99. package/assets/{send-BL378Uzh.js → send-CleviGUZ.js} +1 -1
  100. package/assets/{send-eip712-transaction-u41VUUSa.js → send-eip712-transaction-DfSGlPyc.js} +1 -1
  101. package/assets/{send-gasless-transaction-Bv-SeN6V.js → send-gasless-transaction-D2DAF9mu.js} +2 -2
  102. package/assets/{session-proposal-C8n_HnVT.js → session-proposal-CWVQUxfA.js} +1 -1
  103. package/assets/{session-request-CObMtvdb.js → session-request-BZyaz0LP.js} +2 -2
  104. package/assets/{socials-D4dvlXCA.js → socials-B-OKk3wj.js} +1 -1
  105. package/assets/{swaps-V4FJcglk.js → swaps-DZCBL8Az.js} +1 -1
  106. package/assets/{thirdweb-129NE2Ul.js → thirdweb-C3CcAvH8.js} +5 -5
  107. package/assets/{totalSupply-DO_2zgMa.js → totalSupply-igQJxRMC.js} +1 -1
  108. package/assets/{transactions-Bmdan2s3.js → transactions-D1wgMN3m.js} +1 -1
  109. package/assets/{ui-C5Ow-sF2.js → ui-vxy66sX5.js} +5 -5
  110. package/assets/{vendor-DTjic7dc.js → vendor-D1-TDtn2.js} +1 -1
  111. package/assets/{w3m-modal-CfVCaJKp.js → w3m-modal-DVVcPj5A.js} +1 -1
  112. package/assets/{wallets-B4VDiGHH.js → wallets-DBk4wc49.js} +4 -4
  113. package/assets/{web-connector-DNU9LISy.js → web-connector-C3XptM8L.js} +3 -3
  114. package/index.html +5 -5
  115. package/package.json +2 -2
  116. package/assets/LoginPage-fSUgfU4P.js +0 -1
  117. package/assets/browser-ponyfill-DoK0rGNS.js +0 -1
  118. package/assets/index-CujiQKjN.css +0 -1
@@ -1 +1 @@
1
- import{p as t}from"./thirdweb-129NE2Ul.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
+ import{p as t}from"./thirdweb-C3CcAvH8.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{_ as m}from"./thirdweb-129NE2Ul.js";import{j as e}from"./ui-C5Ow-sF2.js";import{a as o}from"./vendor-DTjic7dc.js";const p=({document:t})=>{const[r,n]=o.useState(null);return o.useEffect(()=>{m(()=>import("./rich-text-react-renderer_decentraland-ui2-BIHI7g3E.js"),[]).then(s=>{n(s.documentToReactComponents(t))})},[t]),e.jsx(e.Fragment,{children:r})};export{p as ContentfulRichText};
1
+ import{_ as m}from"./thirdweb-C3CcAvH8.js";import{j as e}from"./ui-vxy66sX5.js";import{a as o}from"./vendor-D1-TDtn2.js";const p=({document:t})=>{const[r,n]=o.useState(null);return o.useEffect(()=>{m(()=>import("./rich-text-react-renderer_decentraland-ui2-BIHI7g3E.js"),[]).then(s=>{n(s.documentToReactComponents(t))})},[t]),e.jsx(e.Fragment,{children:r})};export{p as ContentfulRichText};
@@ -1 +1 @@
1
- import{p as k,C as l,E as w,a as E,S as A,b as U,O as x,N as P,g as f,B as N,s as I,c as L}from"./W3MFrameProviderSingleton-BKmP_oxD.js";import{g as T,a as W,f as b,b as _,c as v}from"./index-BKdNzTPl.js";const D=0,C={paymentAsset:null,amount:null,tokenAmount:0,priceLoading:!1,error:null,exchanges:[],isLoading:!1,currentPayment:void 0,isPaymentInProgress:!1,paymentId:"",assets:[]},e=k(C),m={state:e,subscribe(t){return L(e,()=>t(e))},subscribeKey(t,n){return I(e,t,n)},resetState(){Object.assign(e,{...C})},async getAssetsForNetwork(t){const n=v(t),s=await m.getAssetsImageAndPrice(n),r=n.map(a=>{var c,o,p,y;const u=a.asset==="native"?f():`${a.network}:${a.asset}`,i=s.find(S=>{var g,d,h;return((h=(d=(g=S.fungibles)==null?void 0:g[0])==null?void 0:d.address)==null?void 0:h.toLowerCase())===u.toLowerCase()});return{...a,price:((o=(c=i==null?void 0:i.fungibles)==null?void 0:c[0])==null?void 0:o.price)||1,metadata:{...a.metadata,iconUrl:(y=(p=i==null?void 0:i.fungibles)==null?void 0:p[0])==null?void 0:y.iconUrl}}});return e.assets=r,r},async getAssetsImageAndPrice(t){const n=t.map(r=>r.asset==="native"?f():`${r.network}:${r.asset}`);return await Promise.all(n.map(r=>N.fetchTokenPrice({addresses:[r]})))},getTokenAmount(){var s;if(!((s=e==null?void 0:e.paymentAsset)!=null&&s.price))throw new Error("Cannot get token price");const t=P.bigNumber(e.amount??0).round(8),n=P.bigNumber(e.paymentAsset.price).round(8);return t.div(n).round(8).toNumber()},setAmount(t){var n;e.amount=t,(n=e.paymentAsset)!=null&&n.price&&(e.tokenAmount=m.getTokenAmount())},setPaymentAsset(t){e.paymentAsset=t},isPayWithExchangeEnabled(){var t;return(t=x.state.remoteFeatures)==null?void 0:t.payWithExchange},isPayWithExchangeSupported(){return m.isPayWithExchangeEnabled()&&l.state.activeCaipNetwork&&U.PAY_WITH_EXCHANGE_SUPPORTED_CHAIN_NAMESPACES.includes(l.state.activeCaipNetwork.chainNamespace)},async fetchExchanges(){var t;try{const n=m.isPayWithExchangeSupported();if(!e.paymentAsset||!n){e.exchanges=[],e.isLoading=!1;return}e.isLoading=!0;const s=await _({page:D,asset:b(e.paymentAsset.network,e.paymentAsset.asset),amount:((t=e.amount)==null?void 0:t.toString())??"0"});e.exchanges=s.exchanges.slice(0,2)}catch{throw A.showError("Unable to get exchanges"),new Error("Unable to get exchanges")}finally{e.isLoading=!1}},async getPayUrl(t,n){try{const s=Number(n.amount),r=await W({exchangeId:t,asset:b(n.network,n.asset),amount:s.toString(),recipient:`${n.network}:${n.recipient}`});return w.sendEvent({type:"track",event:"PAY_EXCHANGE_SELECTED",properties:{exchange:{id:t},configuration:{network:n.network,asset:n.asset,recipient:n.recipient,amount:s},currentPayment:{type:"exchange",exchangeId:t},source:"fund-from-exchange",headless:!1}}),r}catch(s){throw s instanceof Error&&s.message.includes("is not supported")?new Error("Asset not supported"):new Error(s.message)}},async handlePayWithExchange(t){var n;try{const s=(n=l.getAccountData())==null?void 0:n.address;if(!s)throw new Error("No account connected");if(!e.paymentAsset)throw new Error("No payment asset selected");const r=E.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:a,asset:u}=e.paymentAsset,i={network:a,asset:u,amount:e.tokenAmount,recipient:s},c=await m.getPayUrl(t,i);if(!c){try{r.close()}catch(o){console.error("Unable to close popup window",o)}throw new Error("Unable to initiate payment")}e.currentPayment.sessionId=c.sessionId,e.currentPayment.status="IN_PROGRESS",e.currentPayment.exchangeId=t,r.location.href=c.url}catch{e.error="Unable to initiate payment",A.showError(e.error)}},async waitUntilComplete({exchangeId:t,sessionId:n,paymentId:s,retries:r=20}){const a=await m.getBuyStatus(t,n,s);if(a.status==="SUCCESS"||a.status==="FAILED")return a;if(r===0)throw new Error("Unable to get deposit status");return await new Promise(u=>{setTimeout(u,5e3)}),m.waitUntilComplete({exchangeId:t,sessionId:n,paymentId:s,retries:r-1})},async getBuyStatus(t,n,s){var r,a,u,i,c;try{if(!e.currentPayment)throw new Error("No current payment");const o=await T({sessionId:n,exchangeId:t});if(e.currentPayment.status=o.status,o.status==="SUCCESS"||o.status==="FAILED"){const p=(r=l.getAccountData())==null?void 0:r.address;e.currentPayment.result=o.txHash,e.isPaymentInProgress=!1,w.sendEvent({type:"track",event:o.status==="SUCCESS"?"PAY_SUCCESS":"PAY_ERROR",properties:{message:o.status==="FAILED"?E.parseError(e.error):void 0,source:"fund-from-exchange",paymentId:s,configuration:{network:((a=e.paymentAsset)==null?void 0:a.network)||"",asset:((u=e.paymentAsset)==null?void 0:u.asset)||"",recipient:p||"",amount:e.amount??0},currentPayment:{type:"exchange",exchangeId:(i=e.currentPayment)==null?void 0:i.exchangeId,sessionId:(c=e.currentPayment)==null?void 0:c.sessionId,result:o.txHash}}})}return o}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{m as E};
1
+ import{p as k,C as l,E as w,a as E,S as A,b as U,O as x,N as P,g as f,B as N,s as I,c as L}from"./W3MFrameProviderSingleton-DszZRKRh.js";import{g as T,a as W,f as b,b as _,c as v}from"./index-CU7LDmTm.js";const D=0,C={paymentAsset:null,amount:null,tokenAmount:0,priceLoading:!1,error:null,exchanges:[],isLoading:!1,currentPayment:void 0,isPaymentInProgress:!1,paymentId:"",assets:[]},e=k(C),m={state:e,subscribe(t){return L(e,()=>t(e))},subscribeKey(t,n){return I(e,t,n)},resetState(){Object.assign(e,{...C})},async getAssetsForNetwork(t){const n=v(t),s=await m.getAssetsImageAndPrice(n),r=n.map(a=>{var c,o,p,y;const u=a.asset==="native"?f():`${a.network}:${a.asset}`,i=s.find(S=>{var g,d,h;return((h=(d=(g=S.fungibles)==null?void 0:g[0])==null?void 0:d.address)==null?void 0:h.toLowerCase())===u.toLowerCase()});return{...a,price:((o=(c=i==null?void 0:i.fungibles)==null?void 0:c[0])==null?void 0:o.price)||1,metadata:{...a.metadata,iconUrl:(y=(p=i==null?void 0:i.fungibles)==null?void 0:p[0])==null?void 0:y.iconUrl}}});return e.assets=r,r},async getAssetsImageAndPrice(t){const n=t.map(r=>r.asset==="native"?f():`${r.network}:${r.asset}`);return await Promise.all(n.map(r=>N.fetchTokenPrice({addresses:[r]})))},getTokenAmount(){var s;if(!((s=e==null?void 0:e.paymentAsset)!=null&&s.price))throw new Error("Cannot get token price");const t=P.bigNumber(e.amount??0).round(8),n=P.bigNumber(e.paymentAsset.price).round(8);return t.div(n).round(8).toNumber()},setAmount(t){var n;e.amount=t,(n=e.paymentAsset)!=null&&n.price&&(e.tokenAmount=m.getTokenAmount())},setPaymentAsset(t){e.paymentAsset=t},isPayWithExchangeEnabled(){var t;return(t=x.state.remoteFeatures)==null?void 0:t.payWithExchange},isPayWithExchangeSupported(){return m.isPayWithExchangeEnabled()&&l.state.activeCaipNetwork&&U.PAY_WITH_EXCHANGE_SUPPORTED_CHAIN_NAMESPACES.includes(l.state.activeCaipNetwork.chainNamespace)},async fetchExchanges(){var t;try{const n=m.isPayWithExchangeSupported();if(!e.paymentAsset||!n){e.exchanges=[],e.isLoading=!1;return}e.isLoading=!0;const s=await _({page:D,asset:b(e.paymentAsset.network,e.paymentAsset.asset),amount:((t=e.amount)==null?void 0:t.toString())??"0"});e.exchanges=s.exchanges.slice(0,2)}catch{throw A.showError("Unable to get exchanges"),new Error("Unable to get exchanges")}finally{e.isLoading=!1}},async getPayUrl(t,n){try{const s=Number(n.amount),r=await W({exchangeId:t,asset:b(n.network,n.asset),amount:s.toString(),recipient:`${n.network}:${n.recipient}`});return w.sendEvent({type:"track",event:"PAY_EXCHANGE_SELECTED",properties:{exchange:{id:t},configuration:{network:n.network,asset:n.asset,recipient:n.recipient,amount:s},currentPayment:{type:"exchange",exchangeId:t},source:"fund-from-exchange",headless:!1}}),r}catch(s){throw s instanceof Error&&s.message.includes("is not supported")?new Error("Asset not supported"):new Error(s.message)}},async handlePayWithExchange(t){var n;try{const s=(n=l.getAccountData())==null?void 0:n.address;if(!s)throw new Error("No account connected");if(!e.paymentAsset)throw new Error("No payment asset selected");const r=E.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:a,asset:u}=e.paymentAsset,i={network:a,asset:u,amount:e.tokenAmount,recipient:s},c=await m.getPayUrl(t,i);if(!c){try{r.close()}catch(o){console.error("Unable to close popup window",o)}throw new Error("Unable to initiate payment")}e.currentPayment.sessionId=c.sessionId,e.currentPayment.status="IN_PROGRESS",e.currentPayment.exchangeId=t,r.location.href=c.url}catch{e.error="Unable to initiate payment",A.showError(e.error)}},async waitUntilComplete({exchangeId:t,sessionId:n,paymentId:s,retries:r=20}){const a=await m.getBuyStatus(t,n,s);if(a.status==="SUCCESS"||a.status==="FAILED")return a;if(r===0)throw new Error("Unable to get deposit status");return await new Promise(u=>{setTimeout(u,5e3)}),m.waitUntilComplete({exchangeId:t,sessionId:n,paymentId:s,retries:r-1})},async getBuyStatus(t,n,s){var r,a,u,i,c;try{if(!e.currentPayment)throw new Error("No current payment");const o=await T({sessionId:n,exchangeId:t});if(e.currentPayment.status=o.status,o.status==="SUCCESS"||o.status==="FAILED"){const p=(r=l.getAccountData())==null?void 0:r.address;e.currentPayment.result=o.txHash,e.isPaymentInProgress=!1,w.sendEvent({type:"track",event:o.status==="SUCCESS"?"PAY_SUCCESS":"PAY_ERROR",properties:{message:o.status==="FAILED"?E.parseError(e.error):void 0,source:"fund-from-exchange",paymentId:s,configuration:{network:((a=e.paymentAsset)==null?void 0:a.network)||"",asset:((u=e.paymentAsset)==null?void 0:u.asset)||"",recipient:p||"",amount:e.amount??0},currentPayment:{type:"exchange",exchangeId:(i=e.currentPayment)==null?void 0:i.exchangeId,sessionId:(c=e.currentPayment)==null?void 0:c.sessionId,result:o.txHash}}})}return o}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{m as E};
@@ -1,4 +1,4 @@
1
- import{d as f,r as p,i as g,h}from"./index-BKdNzTPl.js";import{n as m,c as v}from"./index-CZmexbhB.js";import{C as c}from"./ConstantsUtil-Cw4CyveW.js";import{R as $,O as u}from"./W3MFrameProviderSingleton-BKmP_oxD.js";import{C as y}from"./NetworkUtil-BGKHKoaf.js";const b=f`
1
+ import{d as f,r as p,i as g,h}from"./index-CU7LDmTm.js";import{n as m,c as v}from"./index-BWA7Dnf9.js";import{C as c}from"./ConstantsUtil-Dg0DgKPJ.js";import{R as $,O as u}from"./W3MFrameProviderSingleton-DszZRKRh.js";import{C as y}from"./NetworkUtil-Cdd9AsyN.js";const b=f`
2
2
  :host {
3
3
  display: flex;
4
4
  justify-content: center;
@@ -0,0 +1 @@
1
+ import{u as A,j as e,D as pe,C as xe,b as De,G as $e,L as ie,c as ke,e as ze}from"./ui-vxy66sX5.js";import{e as Fe,a}from"./vendor-D1-TDtn2.js";import{z as J,A as g,E as Ve,F as Ke,G as qe,J as He,K as Ze,M as Je,P as Qe,Q as Xe,V as Ye,X as en,Y as nn,Z as ye,_ as an,$ as tn,a0 as sn,a1 as on,a2 as rn,a3 as ln,a4 as cn,a5 as dn,a6 as un,a7 as gn,a8 as hn,a9 as mn,aa as Cn,ab as wn,ac as fn,ad as pn,ae as xn,af as kn,ag as yn,ah as En,ai as jn,aj as Sn,ak as bn,al as Ln,am as _n,an as In,ao as Tn,ap as Mn,aq as On,ar as le,as as ce,at as de,au as ue,av as vn,aw as An,ax as Rn,ay as j,az as Pn,aA as Wn,aB as Nn,aC as Bn,aD as Un,aE as Gn,aF as Dn,aG as $n,aH as zn,aI as Fn,aJ as F,aK as Vn,aL as Kn,aM as ge,aN as v,aO as qn,aP as Hn,aQ as Zn,aR as he,aS as me,aT as Jn,aU as Qn,aV as Ce,aW as Xn,aX as we,aY as Yn,aZ as ea,a_ as na,a$ as aa,b0 as ta,b1 as sa,b2 as oa}from"./index-BVRqITf-.js";import"./thirdweb-C3CcAvH8.js";const ra="https://cdn.decentraland.org/@dcl/auth-site/5.0.0/assets/image-new1-CpZnKbBW.webp",ia="https://cdn.decentraland.org/@dcl/auth-site/5.0.0/assets/image-new2-C5ihWkmR.webp",la="https://cdn.decentraland.org/@dcl/auth-site/5.0.0/assets/image-new3-DJx27VUM.webp",ca="https://cdn.decentraland.org/@dcl/auth-site/5.0.0/assets/image-new4-Dx5Lwr3m.webp",da="https://cdn.decentraland.org/@dcl/auth-site/5.0.0/assets/image-new5-CzVG1QYp.webp",ua="https://cdn.decentraland.org/@dcl/auth-site/5.0.0/assets/image-new6-DgBpE6FO.webp",ga=["email","metamask","google","discord","apple","x","fortmatic","coinbase","walletconnect"];function ha(t){switch(t){case"email":return g.EMAIL;case"metamask":return g.METAMASK;case"google":return g.GOOGLE;case"discord":return g.DISCORD;case"apple":return g.APPLE;case"x":return g.X;case"fortmatic":return g.FORTMATIC;case"coinbase":return g.COINBASE;case"walletconnect":return g.WALLET_CONNECT}}const ma=({isReady:t,onConnect:r})=>{var S;const[l]=Fe(),i=a.useRef(!1),d=(S=l.get("loginMethod"))==null?void 0:S.toLowerCase(),p=ga.includes(d)?d:null,x=a.useCallback(()=>p?ha(p):null,[p])();return a.useEffect(()=>{if(!t||i.current||!x||J(x)&&!window.ethereum)return;const E=setTimeout(()=>{i.current=!0,r(x)},100);return()=>clearTimeout(E)},[t,x,r]),{loginMethod:p,autoLoginTriggered:i.current,resolvedConnectionOption:x}},Ca=xe,wa=({open:t,onContinue:r,onClose:l})=>{const{t:i}=A();return e.jsxs(pe,{open:t,maxWidth:"xs",fullWidth:!0,children:[e.jsx(Ve,{onClick:l,"data-testid":"clock-sync-close-button",children:e.jsx(Ca,{})}),e.jsxs(Ke,{children:[e.jsx(qe,{src:He,alt:"warning"}),e.jsx(Ze,{children:i("clock_sync_modal.title")}),e.jsx(Je,{children:i("clock_sync_modal.message")}),e.jsx(Qe,{children:e.jsx(Xe,{variant:"contained",onClick:r,"data-testid":"clock-sync-continue-button",children:i("clock_sync_modal.continue_to_site")})})]})]})},fa=t=>{const{open:r,state:l,providerType:i,onClose:d,onTryAgain:p}=t;return e.jsx(De,{open:r,backgroundImage:Ye,backgroundSize:"cover",backgroundPosition:"center",backgroundRepeat:"no-repeat",size:"small",onClose:d,children:e.jsx(en,{state:l,providerType:i,onTryAgain:p})})},pa=async t=>{await ye(t)},xa=async(t,r)=>nn(t,r),ka=t=>{const{open:r,email:l,onClose:i,onBack:d,onSuccess:p}=t,{t:c}=A(),x=a.useCallback(async(_,f)=>{const y=await xa(_,f);return localStorage.setItem("dcl_thirdweb_user_email",_),{email:_,address:y}},[]),{otp:S,error:E,isLoading:h,hasError:m,otpInputRefs:k,handleOtpChange:R,handleOtpKeyDown:w,handleOtpPaste:P,handleResendOtp:b,isResendDisabled:L,resendText:W}=an({open:r,email:l,verify:x,resend:pa,onSuccess:p}),V=a.useCallback(()=>{h||i()},[h,i]),K=a.useCallback(()=>{h||d()},[h,d]),N=()=>e.jsxs(gn,{children:[e.jsx(hn,{children:e.jsx(mn,{src:Cn,alt:""})}),e.jsx(wn,{children:c("email_login_modal.title")}),e.jsxs(fn,{children:[c("email_login_modal.subtitle_prefix"),e.jsx("strong",{children:l}),c("email_login_modal.subtitle_suffix")]}),e.jsx(pn,{hasError:m,children:S.map((_,f)=>e.jsx(xn,{"data-testid":`otp-input-${f}`,ref:y=>{k.current[f]=y},type:"text",inputMode:"numeric",maxLength:1,value:_,onChange:y=>R(f,y.target.value),onKeyDown:y=>w(f,y),onPaste:P,hasError:m,disabled:h,autoComplete:"one-time-code"},f))}),h&&!E&&e.jsxs(kn,{children:[e.jsx(yn,{size:16}),e.jsx(En,{children:c("email_login_modal.verifying")})]}),E&&e.jsxs(e.Fragment,{children:[e.jsx(jn,{children:E}),e.jsx(Sn,{disabled:L,onClick:L?void 0:b,children:W})]}),!E&&e.jsxs(bn,{children:[c("email_login_modal.didnt_get_email"),e.jsx(Ln,{disabled:L,onClick:L?void 0:b,children:W})]})]});return e.jsxs(e.Fragment,{children:[r&&e.jsx($e,{styles:tn}),e.jsxs(sn,{open:r,maxWidth:"sm",fullWidth:!0,className:on,children:[e.jsxs(rn,{children:[e.jsxs(ln,{onClick:K,disabled:h,"data-testid":"email-login-back-button",children:[e.jsx(cn,{children:"‹"})," ",c("email_login_modal.back")]}),e.jsx(dn,{onClick:V,disabled:h,"data-testid":"email-login-close-button",children:"×"})]}),e.jsx(un,{children:N()})]})]})},ya=xe,Ea=({open:t,onTryAgain:r,onClose:l})=>{const{t:i}=A();return e.jsx(pe,{open:t,onClose:l,"aria-label":i("wallet_error_modal.title"),PaperProps:{sx:{background:"transparent",boxShadow:"none",overflow:"visible"}},slotProps:{backdrop:{sx:{backgroundColor:"rgba(0, 0, 0, 0.6)"}}},children:e.jsxs(_n,{children:[e.jsx(In,{onClick:l,"aria-label":i("common.close_window"),"data-testid":"wallet-error-close-button",children:e.jsx(ya,{sx:{fontSize:14}})}),e.jsx(Tn,{children:e.jsxs("svg",{width:"30",height:"27",viewBox:"0 0 30 27",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M13.268 1.5C14.0378 0.166667 15.9623 0.166667 16.7321 1.5L28.8565 22.5C29.6263 23.8333 28.664 25.5 27.1244 25.5H2.87565C1.33605 25.5 0.373749 23.8333 1.14355 22.5L13.268 1.5Z",fill:"white",fillOpacity:"0",stroke:"white",strokeWidth:"2"}),e.jsx("path",{d:"M15 9V16",stroke:"white",strokeWidth:"2.5",strokeLinecap:"round"}),e.jsx("circle",{cx:"15",cy:"20.5",r:"1.5",fill:"white"})]})}),e.jsx(Mn,{children:i("wallet_error_modal.message")}),e.jsx(On,{variant:"contained",onClick:r,"data-testid":"wallet-error-try-again-button",children:i("wallet_error_modal.try_again")})]})})},ja=({error:t,onError:r})=>{const{t:l}=A();return t?e.jsxs(le,{children:[e.jsx(ce,{variant:"absolute"}),e.jsxs(de,{children:[e.jsx(ie,{size:"huge"}),e.jsx(ue,{children:l("common.something_went_wrong")}),e.jsx(vn,{children:t}),r&&e.jsx(An,{onClick:r,"data-testid":"confirming-login-retry-button",children:l("common.try_again")})]})]}):e.jsxs(le,{children:[e.jsx(ce,{variant:"absolute"}),e.jsxs(de,{children:[e.jsx(ie,{size:"huge"}),e.jsx(ue,{children:l("login.confirming_login")}),e.jsx(Rn,{children:e.jsx(ke,{color:"inherit",size:40})})]})]})},fe=[ra,ia,la,ca,da,ua],Sa=["newUser","newuser","new-user","new_user"],Ma=()=>{const{t}=A(),[r,l]=a.useState(Sa.some(n=>new URLSearchParams(window.location.search).has(n))),[i,d]=a.useState(j.CONNECTING_WALLET),[p,c]=a.useState(!1),[x,S]=a.useState(!1),[E,h]=a.useState(!1),[m,k]=a.useState(),{redirect:R,redirectTo:w,skipSetup:P}=Pn(),{initialized:b,flags:L,variants:W}=a.useContext(Wn),V=Nn(W),[K,N]=a.useState(()=>new URLSearchParams(window.location.search).get("walletError")==="rejected"),[_,f]=a.useState(""),[y,Q]=a.useState(!1),[Ee,O]=a.useState(null),[je,B]=a.useState(!1),[X,q]=a.useState(null),Y=a.useMemo(()=>{if(!w)return"";try{const n=w.startsWith("/")?new URL(w,window.location.origin):new URL(w);return n.pathname.includes("/play")?(n.searchParams.append("guest","true"),n.toString()):""}catch{return""}},[w]),Se=!!Y,[H,be]=a.useState(0),[Le,ee]=a.useState(0),[Z,ne]=a.useState(!1),[_e]=Bn(),{ensureProfile:ae}=Un(),{identity:te,getIdentitySignature:U}=Gn(),{trackLoginClick:G,trackLoginSuccess:D,trackGuestLogin:se}=Dn(),Ie=a.useCallback(async()=>{await se()},[se]),I=a.useCallback(()=>{const n=new URLSearchParams(window.location.search);return $n(n)},[]),T=a.useCallback(async(n,s,o=null,C)=>{!P&&n&&!await ae(n,o??te,{redirectTo:w,referrer:s})||(zn(n),R(),C==null||C())},[P,w,te,ae,R]),$=a.useCallback(async()=>await Fn()?!0:(c(!1),S(!0),!1),[]),Te=a.useCallback(async n=>{f(n),Q(!0),O(null),k(g.EMAIL),G({method:g.EMAIL,type:F.WEB2});try{await Vn.disconnect(),await Kn()}catch{}ge({checkpointId:2,action:"reached",source:"auth",userIdentifier:n,identifierType:"email",email:n,metadata:{loginMethod:g.EMAIL}});try{await ye(n),h(!0)}catch(s){const o=v(s,"Error sending verification code");k(void 0),o==="Failed to fetch"||o!=null&&o.toLowerCase().includes("network")?O(t("login.errors.network_error")):o!=null&&o.toLowerCase().includes("invalid email")?O(t("login.errors.invalid_email")):O(o||t("login.errors.failed_send_code"))}finally{Q(!1)}},[G,t]),M=a.useCallback(async n=>{var C,z;if(!b)return;if(n===g.EMAIL){const u=document.getElementById("dcl-email-input");u&&(u.scrollIntoView({behavior:"smooth",block:"center"}),u.focus());return}const s=qn(n),o=s?F.WEB2:F.WEB3;k(n),G({method:n,type:o});try{if(s)c(!0),d(j.LOADING_MAGIC),await Hn(n,Zn(L[he.MAGIC_TEST]),w);else{if(J(n)&&!window.ethereum)throw new Error("No wallet extension detected. Please install MetaMask or another Ethereum wallet.");c(!0),d(j.CONNECTING_WALLET);const u=await me(n);ge({checkpointId:2,action:"reached",source:"auth",userIdentifier:((C=u.account)==null?void 0:C.toLowerCase())??"",identifierType:"wallet",wallet:(z=u.account)==null?void 0:z.toLowerCase(),metadata:{loginMethod:n}}),d(j.WAITING_FOR_SIGNATURE);const Ue=await U(u);localStorage.removeItem("dcl_thirdweb_user_email"),localStorage.removeItem("dcl_magic_user_email"),await D({ethAddress:u.account??void 0,type:o});const Ge=I();await $()&&await T(u.account??"",Ge,Ue,()=>c(!1))}}catch(u){Jn(u)?console.info("User rejected login signature in wallet — not reporting to Sentry"):v(u,"Error during login connection",{sentryTags:{isWeb2Wallet:s,connectionType:n}}),Qn(u)&&u.name==="ErrorUnlockingWallet"?d(j.ERROR_LOCKED_WALLET):d(j.ERROR)}},[d,c,k,w,L[he.MAGIC_TEST],G,D,T,b,$,I,U]),Me=a.useCallback(()=>{c(!1),k(void 0),d(j.CONNECTING_WALLET)},[c]),Oe=a.useCallback(()=>{N(!1);const n=new URLSearchParams(window.location.search);n.delete("walletError");const s=n.toString(),o=`${window.location.pathname}${s?`?${s}`:""}`;window.history.replaceState({},"",o)},[]),ve=a.useCallback(()=>{N(!1);const n=new URLSearchParams(window.location.search);n.delete("walletError");const s=n.toString(),o=`${window.location.pathname}${s?`?${s}`:""}`;window.history.replaceState({},"",o),M(g.METAMASK)},[M]),Ae=a.useCallback(()=>{h(!1),f(""),k(void 0)},[]),Re=a.useCallback(()=>{h(!1),f(""),k(void 0)},[]),Pe=a.useCallback(async n=>{h(!1),B(!0),q(null);try{const s=n.address.toLowerCase(),o=await U();await D({ethAddress:s,type:F.WEB2});const C=I();await $()?await T(s,C,o,()=>B(!1)):B(!1)}catch(s){const o=v(s,"Error completing email login",{sentryTags:{connectionType:g.EMAIL}});q(o||t("login.errors.something_went_wrong"))}},[D,$,T,I,U,t]),We=a.useCallback(()=>{O(null)},[]),Ne=a.useCallback(()=>{B(!1),q(null),h(!0)},[]);ma({isReady:b,onConnect:M});const Be=a.useCallback(()=>{m&&M(m)},[m,M]),oe=a.useCallback(async()=>{if(S(!1),!m)return;const n=I();if(J(m)&&!window.ethereum){v(new Error("No wallet extension detected"),"Wallet extension not available for clock sync continue");return}try{const s=await me(m);await T(s.account??"",n,null,()=>c(!1))}catch(s){v(s,"Error during clock sync continue flow"),d(j.ERROR),c(!0)}},[m,T,I]);if(a.useEffect(()=>{const s=fe.length-1,o=setInterval(()=>{be(C=>(ee(C),ne(!0),C>=s?0:C+1))},5e3);return()=>clearInterval(o)},[]),a.useEffect(()=>{if(!Z)return;const n=setTimeout(()=>{ee(H),ne(!1)},1e3);return()=>clearTimeout(n)},[Z,H]),!b)return e.jsx(Ce,{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(ke,{size:80})});const re=fe;return e.jsxs(Ce,{children:[e.jsx(ze,{children:e.jsxs(Xn,{children:[e.jsx(we,{isVisible:!0,style:{backgroundImage:`url(${re[Le]})`},"aria-hidden":!0}),e.jsx(we,{isVisible:Z,style:{backgroundImage:`url(${re[H]})`},"aria-hidden":!0})]})}),je&&!x&&e.jsx(ja,{error:X,onError:X?Ne:void 0}),e.jsx(Ea,{open:K,onTryAgain:ve,onClose:Oe}),e.jsx(wa,{open:x,onContinue:oe,onClose:oe}),e.jsx(fa,{open:p,state:i,onClose:Me,onTryAgain:Be,providerType:m?Yn(m):null}),e.jsx(ka,{open:E,email:_,onClose:Ae,onBack:Re,onSuccess:Pe}),e.jsx(ea,{children:e.jsxs(na,{children:[e.jsxs(aa,{children:[e.jsx(ta,{onConnect:M,onEmailSubmit:Te,onEmailChange:We,loadingOption:m,connectionOptions:_e.connectionOptions,isNewUser:r,signInOptionsMode:V,isEmailLoading:y,emailError:Ee}),r&&e.jsxs(sa,{children:[t("login.already_have_account")," ",e.jsx("span",{onClick:()=>l(!1),children:t("login.sign_in")})]})]}),Se&&e.jsxs(oa,{children:[t("login.quick_dive")," ",e.jsx("a",{href:Y,onClick:Ie,children:t("login.explore_as_guest")})]})]})})]})};export{Ma as LoginPage};
@@ -1 +1 @@
1
- import{p as N}from"./thirdweb-129NE2Ul.js";var o={};const s={WC_NAME_SUFFIX:".reown.id",WC_NAME_SUFFIX_LEGACY:".wcn.id",BLOCKCHAIN_API_RPC_URL:"https://rpc.walletconnect.org",PULSE_API_URL:"https://pulse.walletconnect.org",W3M_API_URL:"https://api.web3modal.org",CONNECTOR_ID:{WALLET_CONNECT:"walletConnect",INJECTED:"injected",WALLET_STANDARD:"announced",COINBASE:"coinbaseWallet",COINBASE_SDK:"coinbaseWalletSDK",BASE_ACCOUNT:"baseAccount",SAFE:"safe",LEDGER:"ledger",OKX:"okx",EIP6963:"eip6963",AUTH:"AUTH"},CONNECTOR_NAMES:{AUTH:"Auth"},AUTH_CONNECTOR_SUPPORTED_CHAINS:["eip155","solana"],LIMITS:{PENDING_TRANSACTIONS:99},CHAIN:{EVM:"eip155",SOLANA:"solana",POLKADOT:"polkadot",BITCOIN:"bip122",TON:"ton",TRON:"tron"},CHAIN_NAME_MAP:{eip155:"EVM Networks",solana:"Solana",polkadot:"Polkadot",bip122:"Bitcoin",cosmos:"Cosmos",sui:"Sui",stacks:"Stacks",ton:"TON",tron:"TRON"},ADAPTER_TYPES:{BITCOIN:"bitcoin",SOLANA:"solana",WAGMI:"wagmi",ETHERS:"ethers",ETHERS5:"ethers5",TON:"ton",TRON:"tron"},USDT_CONTRACT_ADDRESSES:["0xdac17f958d2ee523a2206206994597c13d831ec7","0xc2132d05d31c914a87c6611c10748aeb04b58e8f","0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7","0x919C1c267BC06a7039e03fcc2eF738525769109c","0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e","0x55d398326f99059fF775485246999027B3197955","0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9"],SOLANA_SPL_TOKEN_ADDRESSES:{SOL:"So11111111111111111111111111111111111111112"},NATIVE_IMAGE_IDS_BY_NAMESPACE:{eip155:"ba0ba0cd-17c6-4806-ad93-f9d174f17900",solana:"3e8119e5-2a6f-4818-c50c-1937011d5900",bip122:"0b4838db-0161-4ffe-022d-532bf03dba00"},TOKEN_SYMBOLS_BY_ADDRESS:{"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48":"USDC","0x833589fcd6edb6e08f4c7c32d4f71b54bda02913":"USDC","0x0b2c639c533813f4aa9d7837caf62653d097ff85":"USDC","0xaf88d065e77c8cc2239327c5edb3a432268e5831":"USDC","0x3c499c542cef5e3811e1192ce70d8cc03d5c3359":"USDC","0x2791bca1f2de4661ed88a30c99a7a9449aa84174":"USDC",EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v:"USDC","0xdac17f958d2ee523a2206206994597c13d831ec7":"USDT","0x94b008aa00579c1307b0ef2c499ad98a8ce58e58":"USDT","0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9":"USDT","0xc2132d05d31c914a87c6611c10748aeb04b58e8f":"USDT",Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB:"USDT"},HTTP_STATUS_CODES:{SERVER_ERROR:500,TOO_MANY_REQUESTS:429,SERVICE_UNAVAILABLE:503,FORBIDDEN:403},UNSUPPORTED_NETWORK_NAME:"Unknown Network",SECURE_SITE_SDK_ORIGIN:(typeof N<"u"&&typeof o<"u"?o.NEXT_PUBLIC_SECURE_SITE_ORIGIN:void 0)||"https://secure.walletconnect.org",REMOTE_FEATURES_ALERTS:{MULTI_WALLET_NOT_ENABLED:{DEFAULT:{displayMessage:"Multi-Wallet Not Enabled",debugMessage:"Multi-wallet support is not enabled. Please enable it in your AppKit configuration at cloud.reown.com."},CONNECTIONS_HOOK:{displayMessage:"Multi-Wallet Not Enabled",debugMessage:"Multi-wallet support is not enabled. Please enable it in your AppKit configuration at cloud.reown.com to use the useAppKitConnections hook."},CONNECTION_HOOK:{displayMessage:"Multi-Wallet Not Enabled",debugMessage:"Multi-wallet support is not enabled. Please enable it in your AppKit configuration at cloud.reown.com to use the useAppKitConnection hook."}},HEADLESS_NOT_ENABLED:{DEFAULT:{displayMessage:"",debugMessage:"Headless support is not enabled. Please enable it with the features.headless option in the AppKit configuration and make sure your current plan supports it."}}},IS_DEVELOPMENT:typeof N<"u"&&!1,DEFAULT_ALLOWED_ANCESTORS:["http://localhost:*","https://localhost:*","http://127.0.0.1:*","https://127.0.0.1:*","https://*.pages.dev","https://*.vercel.app","https://*.ngrok-free.app","https://secure-mobile.walletconnect.com","https://secure-mobile.walletconnect.org"],METMASK_CONNECTOR_NAME:"MetaMask",TRUST_CONNECTOR_NAME:"Trust Wallet",SOLFLARE_CONNECTOR_NAME:"Solflare",PHANTOM_CONNECTOR_NAME:"Phantom",COIN98_CONNECTOR_NAME:"Coin98",MAGIC_EDEN_CONNECTOR_NAME:"Magic Eden",BACKPACK_CONNECTOR_NAME:"Backpack",BITGET_CONNECTOR_NAME:"Bitget Wallet",FRONTIER_CONNECTOR_NAME:"Frontier",XVERSE_CONNECTOR_NAME:"Xverse Wallet",LEATHER_CONNECTOR_NAME:"Leather",OKX_CONNECTOR_NAME:"OKX Wallet",BINANCE_CONNECTOR_NAME:"Binance Wallet",EIP155:"eip155",ADD_CHAIN_METHOD:"wallet_addEthereumChain",EIP6963_ANNOUNCE_EVENT:"eip6963:announceProvider",EIP6963_REQUEST_EVENT:"eip6963:requestProvider",CONNECTOR_RDNS_MAP:{coinbaseWallet:"com.coinbase.wallet",coinbaseWalletSDK:"com.coinbase.wallet"},CONNECTOR_TYPE_EXTERNAL:"EXTERNAL",CONNECTOR_TYPE_WALLET_CONNECT:"WALLET_CONNECT",CONNECTOR_TYPE_INJECTED:"INJECTED",CONNECTOR_TYPE_ANNOUNCED:"ANNOUNCED",CONNECTOR_TYPE_AUTH:"AUTH",CONNECTOR_TYPE_MULTI_CHAIN:"MULTI_CHAIN",CONNECTOR_TYPE_W3M_AUTH:"AUTH"},C={caipNetworkIdToNumber(e){return e?Number(e.split(":")[1]):void 0},parseEvmChainId(e){return typeof e=="string"?this.caipNetworkIdToNumber(e):e},getNetworksByNamespace(e,a){return(e==null?void 0:e.filter(E=>E.chainNamespace===a))||[]},getFirstNetworkByNamespace(e,a){return this.getNetworksByNamespace(e,a)[0]},getNetworkNameByCaipNetworkId(e,a){var t;if(!a)return;const E=e.find(_=>_.caipNetworkId===a);if(E)return E.name;const[c]=a.split(":");return((t=s.CHAIN_NAME_MAP)==null?void 0:t[c])||void 0}},n=["eip155","solana","polkadot","bip122","cosmos","sui","stacks"];export{n as A,s as C,C as N};
1
+ import{p as N}from"./thirdweb-C3CcAvH8.js";var o={};const s={WC_NAME_SUFFIX:".reown.id",WC_NAME_SUFFIX_LEGACY:".wcn.id",BLOCKCHAIN_API_RPC_URL:"https://rpc.walletconnect.org",PULSE_API_URL:"https://pulse.walletconnect.org",W3M_API_URL:"https://api.web3modal.org",CONNECTOR_ID:{WALLET_CONNECT:"walletConnect",INJECTED:"injected",WALLET_STANDARD:"announced",COINBASE:"coinbaseWallet",COINBASE_SDK:"coinbaseWalletSDK",BASE_ACCOUNT:"baseAccount",SAFE:"safe",LEDGER:"ledger",OKX:"okx",EIP6963:"eip6963",AUTH:"AUTH"},CONNECTOR_NAMES:{AUTH:"Auth"},AUTH_CONNECTOR_SUPPORTED_CHAINS:["eip155","solana"],LIMITS:{PENDING_TRANSACTIONS:99},CHAIN:{EVM:"eip155",SOLANA:"solana",POLKADOT:"polkadot",BITCOIN:"bip122",TON:"ton",TRON:"tron"},CHAIN_NAME_MAP:{eip155:"EVM Networks",solana:"Solana",polkadot:"Polkadot",bip122:"Bitcoin",cosmos:"Cosmos",sui:"Sui",stacks:"Stacks",ton:"TON",tron:"TRON"},ADAPTER_TYPES:{BITCOIN:"bitcoin",SOLANA:"solana",WAGMI:"wagmi",ETHERS:"ethers",ETHERS5:"ethers5",TON:"ton",TRON:"tron"},USDT_CONTRACT_ADDRESSES:["0xdac17f958d2ee523a2206206994597c13d831ec7","0xc2132d05d31c914a87c6611c10748aeb04b58e8f","0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7","0x919C1c267BC06a7039e03fcc2eF738525769109c","0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e","0x55d398326f99059fF775485246999027B3197955","0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9"],SOLANA_SPL_TOKEN_ADDRESSES:{SOL:"So11111111111111111111111111111111111111112"},NATIVE_IMAGE_IDS_BY_NAMESPACE:{eip155:"ba0ba0cd-17c6-4806-ad93-f9d174f17900",solana:"3e8119e5-2a6f-4818-c50c-1937011d5900",bip122:"0b4838db-0161-4ffe-022d-532bf03dba00"},TOKEN_SYMBOLS_BY_ADDRESS:{"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48":"USDC","0x833589fcd6edb6e08f4c7c32d4f71b54bda02913":"USDC","0x0b2c639c533813f4aa9d7837caf62653d097ff85":"USDC","0xaf88d065e77c8cc2239327c5edb3a432268e5831":"USDC","0x3c499c542cef5e3811e1192ce70d8cc03d5c3359":"USDC","0x2791bca1f2de4661ed88a30c99a7a9449aa84174":"USDC",EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v:"USDC","0xdac17f958d2ee523a2206206994597c13d831ec7":"USDT","0x94b008aa00579c1307b0ef2c499ad98a8ce58e58":"USDT","0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9":"USDT","0xc2132d05d31c914a87c6611c10748aeb04b58e8f":"USDT",Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB:"USDT"},HTTP_STATUS_CODES:{SERVER_ERROR:500,TOO_MANY_REQUESTS:429,SERVICE_UNAVAILABLE:503,FORBIDDEN:403},UNSUPPORTED_NETWORK_NAME:"Unknown Network",SECURE_SITE_SDK_ORIGIN:(typeof N<"u"&&typeof o<"u"?o.NEXT_PUBLIC_SECURE_SITE_ORIGIN:void 0)||"https://secure.walletconnect.org",REMOTE_FEATURES_ALERTS:{MULTI_WALLET_NOT_ENABLED:{DEFAULT:{displayMessage:"Multi-Wallet Not Enabled",debugMessage:"Multi-wallet support is not enabled. Please enable it in your AppKit configuration at cloud.reown.com."},CONNECTIONS_HOOK:{displayMessage:"Multi-Wallet Not Enabled",debugMessage:"Multi-wallet support is not enabled. Please enable it in your AppKit configuration at cloud.reown.com to use the useAppKitConnections hook."},CONNECTION_HOOK:{displayMessage:"Multi-Wallet Not Enabled",debugMessage:"Multi-wallet support is not enabled. Please enable it in your AppKit configuration at cloud.reown.com to use the useAppKitConnection hook."}},HEADLESS_NOT_ENABLED:{DEFAULT:{displayMessage:"",debugMessage:"Headless support is not enabled. Please enable it with the features.headless option in the AppKit configuration and make sure your current plan supports it."}}},IS_DEVELOPMENT:typeof N<"u"&&!1,DEFAULT_ALLOWED_ANCESTORS:["http://localhost:*","https://localhost:*","http://127.0.0.1:*","https://127.0.0.1:*","https://*.pages.dev","https://*.vercel.app","https://*.ngrok-free.app","https://secure-mobile.walletconnect.com","https://secure-mobile.walletconnect.org"],METMASK_CONNECTOR_NAME:"MetaMask",TRUST_CONNECTOR_NAME:"Trust Wallet",SOLFLARE_CONNECTOR_NAME:"Solflare",PHANTOM_CONNECTOR_NAME:"Phantom",COIN98_CONNECTOR_NAME:"Coin98",MAGIC_EDEN_CONNECTOR_NAME:"Magic Eden",BACKPACK_CONNECTOR_NAME:"Backpack",BITGET_CONNECTOR_NAME:"Bitget Wallet",FRONTIER_CONNECTOR_NAME:"Frontier",XVERSE_CONNECTOR_NAME:"Xverse Wallet",LEATHER_CONNECTOR_NAME:"Leather",OKX_CONNECTOR_NAME:"OKX Wallet",BINANCE_CONNECTOR_NAME:"Binance Wallet",EIP155:"eip155",ADD_CHAIN_METHOD:"wallet_addEthereumChain",EIP6963_ANNOUNCE_EVENT:"eip6963:announceProvider",EIP6963_REQUEST_EVENT:"eip6963:requestProvider",CONNECTOR_RDNS_MAP:{coinbaseWallet:"com.coinbase.wallet",coinbaseWalletSDK:"com.coinbase.wallet"},CONNECTOR_TYPE_EXTERNAL:"EXTERNAL",CONNECTOR_TYPE_WALLET_CONNECT:"WALLET_CONNECT",CONNECTOR_TYPE_INJECTED:"INJECTED",CONNECTOR_TYPE_ANNOUNCED:"ANNOUNCED",CONNECTOR_TYPE_AUTH:"AUTH",CONNECTOR_TYPE_MULTI_CHAIN:"MULTI_CHAIN",CONNECTOR_TYPE_W3M_AUTH:"AUTH"},C={caipNetworkIdToNumber(e){return e?Number(e.split(":")[1]):void 0},parseEvmChainId(e){return typeof e=="string"?this.caipNetworkIdToNumber(e):e},getNetworksByNamespace(e,a){return(e==null?void 0:e.filter(E=>E.chainNamespace===a))||[]},getFirstNetworkByNamespace(e,a){return this.getNetworksByNamespace(e,a)[0]},getNetworkNameByCaipNetworkId(e,a){var t;if(!a)return;const E=e.find(_=>_.caipNetworkId===a);if(E)return E.name;const[c]=a.split(":");return((t=s.CHAIN_NAME_MAP)==null?void 0:t[c])||void 0}},n=["eip155","solana","polkadot","bip122","cosmos","sui","stacks"];export{n as A,s as C,C as N};
@@ -1 +1 @@
1
- import{N as T,w as O,p as x,R as A,S as w,d as B,E as D,e as M,W as F,C as g,B as N,a as L,f as v,A as z,h as R,b as _,g as H,i as V,s as $,c as q}from"./W3MFrameProviderSingleton-BKmP_oxD.js";import{C as P}from"./NetworkUtil-BGKHKoaf.js";const I={getGasPriceInEther(n,t){const o=t*n;return Number(o)/1e18},getGasPriceInUSD(n,t,o){const s=I.getGasPriceInEther(t,o);return T.bigNumber(n).times(s).toNumber()},getPriceImpact({sourceTokenAmount:n,sourceTokenPriceInUSD:t,toTokenPriceInUSD:o,toTokenAmount:s}){const c=T.bigNumber(n).times(t),r=T.bigNumber(s).times(o);return c.minus(r).div(c).times(100).toNumber()},getMaxSlippage(n,t){const o=T.bigNumber(n).div(100);return T.multiply(t,o).toNumber()},getProviderFee(n,t=.0085){return T.bigNumber(n).times(t).toString()},isInsufficientNetworkTokenForGas(n,t){const o=t||"0";return T.bigNumber(n).eq(0)?!0:T.bigNumber(T.bigNumber(o)).gt(n)},isInsufficientSourceTokenForSwap(n,t,o){var r,d;const s=(d=(r=o==null?void 0:o.find(l=>l.address===t))==null?void 0:r.quantity)==null?void 0:d.numeric;return T.bigNumber(s||"0").lt(n)}},G=15e4,Q=6,k={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:_.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=x({...k}),E={state:e,subscribe(n){return q(e,()=>n(e))},subscribeKey(n,t){return $(e,n,t)},getParams(){var i,u,p,f,S,h,y,C,b;const n=g.state.activeChain,t=((i=g.getAccountData(n))==null?void 0:i.caipAddress)??g.state.activeCaipAddress,o=L.getPlainAddress(t),s=H(),c=V.getConnectorId(g.state.activeChain);if(!o)throw new Error("No address found to swap the tokens from.");const r=!((u=e.toToken)!=null&&u.address)||!((p=e.toToken)!=null&&p.decimals),d=!((f=e.sourceToken)!=null&&f.address)||!((S=e.sourceToken)!=null&&S.decimals)||!T.bigNumber(e.sourceTokenAmount).gt(0),l=!e.sourceTokenAmount;return{networkAddress:s,fromAddress:o,fromCaipAddress:t,sourceTokenAddress:(h=e.sourceToken)==null?void 0:h.address,toTokenAddress:(y=e.toToken)==null?void 0:y.address,toTokenAmount:e.toTokenAmount,toTokenDecimals:(C=e.toToken)==null?void 0:C.decimals,sourceTokenAmount:e.sourceTokenAmount,sourceTokenDecimals:(b=e.sourceToken)==null?void 0:b.decimals,invalidToToken:r,invalidSourceToken:d,invalidSourceTokenAmount:l,availableToSwap:t&&!r&&!d&&!l,isAuthConnector:c===P.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?T.toFixed(n,Q):""},async setTokenPrice(n,t){let o=e.tokensPriceMap[n]||0;o||(e.loadingPrices=!0,o=await a.getAddressPrice(n)),t==="sourceToken"?e.sourceTokenPriceInUSD=o:t==="toToken"&&(e.toTokenPriceInUSD=o),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,t=e.sourceToken?{...e.sourceToken}:void 0,o=n&&e.toTokenAmount===""?"1":e.toTokenAmount;a.setSourceTokenAmount(o),a.setToTokenAmount(""),await a.setSourceToken(n),await a.setToToken(t),e.switchingTokens=!1,a.swapTokens()}catch(n){throw e.switchingTokens=!1,n}}},resetState(){e.myTokensWithBalance=k.myTokensWithBalance,e.tokensPriceMap=k.tokensPriceMap,e.initialized=k.initialized,e.initializing=k.initializing,e.switchingTokens=k.switchingTokens,e.sourceToken=k.sourceToken,e.sourceTokenAmount=k.sourceTokenAmount,e.sourceTokenPriceInUSD=k.sourceTokenPriceInUSD,e.toToken=k.toToken,e.toTokenAmount=k.toTokenAmount,e.toTokenPriceInUSD=k.toTokenPriceInUSD,e.networkPrice=k.networkPrice,e.networkTokenSymbol=k.networkTokenSymbol,e.networkBalanceInUSD=k.networkBalanceInUSD,e.inputError=k.inputError},resetValues(){var o;const{networkAddress:n}=a.getParams(),t=(o=e.tokens)==null?void 0:o.find(s=>s.address===n);a.setSourceToken(t),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,w.showError("Failed to initialize swap"),A.goBack()}e.initializing=!1}},async fetchTokens(){var o;const{networkAddress:n}=a.getParams();await a.getNetworkTokenPrice(),await a.getMyTokensWithBalance();const t=(o=e.myTokensWithBalance)==null?void 0:o.find(s=>s.address===n);t&&(e.networkTokenSymbol=t.symbol,a.setSourceToken(t),a.setSourceTokenAmount("0"))},async getTokenList(){var t,o;const n=(t=g.state.activeCaipNetwork)==null?void 0:t.caipNetworkId;if(!(e.caipNetworkId===n&&e.tokens))try{e.tokensLoading=!0;const s=await v.getTokenList(n);e.tokens=s,e.caipNetworkId=n,e.popularTokens=s.sort((i,u)=>i.symbol<u.symbol?-1:i.symbol>u.symbol?1:0);const r=(n&&((o=_.SUGGESTED_TOKENS_BY_CHAIN)==null?void 0:o[n])||[]).map(i=>s.find(u=>u.symbol===i)).filter(i=>!!i),l=(_.SWAP_SUGGESTED_TOKENS||[]).map(i=>s.find(u=>u.symbol===i)).filter(i=>!!i).filter(i=>!r.some(u=>u.address===i.address));e.suggestedTokens=[...r,...l]}catch{e.tokens=[],e.popularTokens=[],e.suggestedTokens=[]}finally{e.tokensLoading=!1}},async getAddressPrice(n){var i,u;const t=e.tokensPriceMap[n];if(t)return t;const o=await N.fetchTokenPrice({addresses:[n]}),s=(o==null?void 0:o.fungibles)||[],c=[...e.tokens||[],...e.myTokensWithBalance||[]],r=(i=c==null?void 0:c.find(p=>p.address===n))==null?void 0:i.symbol,d=((u=s.find(p=>p.symbol.toLowerCase()===(r==null?void 0:r.toLowerCase())))==null?void 0:u.price)||0,l=parseFloat(d.toString());return e.tokensPriceMap[n]=l,l},async getNetworkTokenPrice(){var c;const{networkAddress:n}=a.getParams(),o=(c=(await N.fetchTokenPrice({addresses:[n]}).catch(()=>(w.showError("Failed to fetch network token price"),{fungibles:[]}))).fungibles)==null?void 0:c[0],s=(o==null?void 0:o.price.toString())||"0";e.tokensPriceMap[n]=parseFloat(s),e.networkTokenSymbol=(o==null?void 0:o.symbol)||"",e.networkPrice=s},async getMyTokensWithBalance(n){var s;const t=await R.getMyTokensWithBalance({forceUpdate:n,caipNetwork:g.state.activeCaipNetwork,address:(s=g.getAccountData())==null?void 0:s.address}),o=v.mapBalancesToSwapTokens(t);o&&(await a.getInitialGasPrice(),a.setBalances(o))},setBalances(n){const{networkAddress:t}=a.getParams(),o=g.state.activeCaipNetwork;if(!o)return;const s=n.find(c=>c.address===t);n.forEach(c=>{e.tokensPriceMap[c.address]=c.price||0}),e.myTokensWithBalance=n.filter(c=>c.address.startsWith(o.caipNetworkId)),e.networkBalanceInUSD=s?T.multiply(s.quantity.numeric,s.price).toString():"0"},async getInitialGasPrice(){var t,o;const n=await v.fetchGasPrice();if(!n)return{gasPrice:null,gasPriceInUSD:null};switch((o=(t=g.state)==null?void 0:t.activeCaipNetwork)==null?void 0:o.chainNamespace){case P.CHAIN.SOLANA:return e.gasFee=n.standard??"0",e.gasPriceInUSD=T.multiply(n.standard,e.networkPrice).div(1e9).toNumber(),{gasPrice:BigInt(e.gasFee),gasPriceInUSD:Number(e.gasPriceInUSD)};case P.CHAIN.EVM:default:const s=n.standard??"0",c=BigInt(s),r=BigInt(G),d=I.getGasPriceInUSD(e.networkPrice,r,c);return e.gasFee=s,e.gasPriceInUSD=d,{gasPrice:c,gasPriceInUSD:d}}},async swapTokens(){var r,d,l;const n=(r=g.getAccountData())==null?void 0:r.address,t=e.sourceToken,o=e.toToken,s=T.bigNumber(e.sourceTokenAmount).gt(0);if(s||a.setToTokenAmount(""),!o||!t||e.loadingPrices||!s||!n)return;e.loadingQuote=!0;const c=T.bigNumber(e.sourceTokenAmount).times(10**t.decimals).round(0).toFixed(0);try{const i=await N.fetchSwapQuote({userAddress:n,from:t.address,to:o.address,gasPrice:e.gasFee,amount:c.toString()});e.loadingQuote=!1;const u=(l=(d=i==null?void 0:i.quotes)==null?void 0:d[0])==null?void 0:l.toAmount;if(!u){z.open({displayMessage:"Incorrect amount",debugMessage:"Please enter a valid amount"},"error");return}const p=T.bigNumber(u).div(10**o.decimals).toString();a.setToTokenAmount(p),a.hasInsufficientToken(e.sourceTokenAmount,t.address)?e.inputError="Insufficient balance":(e.inputError=void 0,a.setTransactionDetails())}catch(i){const u=await v.handleSwapError(i);e.loadingQuote=!1,e.inputError=u||"Insufficient balance"}},async getTransaction(){const{fromCaipAddress:n,availableToSwap:t}=a.getParams(),o=e.sourceToken,s=e.toToken;if(!(!n||!t||!o||!s||e.loadingQuote))try{e.loadingBuildTransaction=!0;const c=await v.fetchSwapAllowance({userAddress:n,tokenAddress:o.address,sourceTokenAmount:e.sourceTokenAmount,sourceTokenDecimals:o.decimals});let r;return c?r=await a.createSwapTransaction():r=await a.createAllowanceTransaction(),e.loadingBuildTransaction=!1,e.fetchError=!1,r}catch{A.goBack(),w.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:t,toTokenAddress:o}=a.getParams();if(!(!n||!o)){if(!t)throw new Error("createAllowanceTransaction - No source token address found.");try{const s=await N.generateApproveCalldata({from:t,to:o,userAddress:n}),c=L.getPlainAddress(s.tx.from);if(!c)throw new Error("SwapController:createAllowanceTransaction - address is required");const r={data:s.tx.data,to:c,gasPrice:BigInt(s.tx.eip155.gasPrice),value:BigInt(s.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{A.goBack(),w.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:t,sourceTokenAmount:o}=a.getParams(),s=e.sourceToken,c=e.toToken;if(!t||!o||!s||!c)return;const r=(d=B.parseUnits(o,s.decimals))==null?void 0:d.toString();try{const l=await N.generateSwapCalldata({userAddress:t,from:s.address,to:c.address,amount:r,disableEstimate:!0}),i=s.address===n,u=BigInt(l.tx.eip155.gas),p=BigInt(l.tx.eip155.gasPrice),f=L.getPlainAddress(l.tx.to);if(!f)throw new Error("SwapController:createSwapTransaction - address is required");const S={data:l.tx.data,to:f,gas:u,gasPrice:p,value:BigInt(i?r??"0":"0"),toAmount:e.toTokenAmount};return e.gasPriceInUSD=I.getGasPriceInUSD(e.networkPrice,u,p),e.approvalTransaction=void 0,e.swapTransaction=S,S}catch{A.goBack(),w.showError("Failed to create transaction"),e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}},onEmbeddedWalletApprovalSuccess(){w.showLoading("Approve limit increase in your wallet"),A.replace("SwapPreview")},async sendTransactionForApproval(n){var c,r,d;const{fromAddress:t,isAuthConnector:o}=a.getParams();e.loadingApprovalTransaction=!0,o?A.pushTransactionStack({onSuccess:a.onEmbeddedWalletApprovalSuccess}):w.showLoading("Approve limit increase in your wallet");try{await B.sendTransaction({address:t,to:n.to,data:n.data,value:n.value,chainNamespace:P.CHAIN.EVM}),await a.swapTokens(),await a.getTransaction(),e.approvalTransaction=void 0,e.loadingApprovalTransaction=!1}catch(l){const i=l;e.transactionError=i==null?void 0:i.displayMessage,e.loadingApprovalTransaction=!1,w.showError((i==null?void 0:i.displayMessage)||"Transaction error"),D.sendEvent({type:"track",event:"SWAP_APPROVAL_ERROR",properties:{message:(i==null?void 0:i.displayMessage)||(i==null?void 0:i.message)||"Unknown",network:((c=g.state.activeCaipNetwork)==null?void 0:c.caipNetworkId)||"",swapFromToken:((r=a.state.sourceToken)==null?void 0:r.symbol)||"",swapToToken:((d=a.state.toToken)==null?void 0:d.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:M(P.CHAIN.EVM)===F.ACCOUNT_TYPES.SMART_ACCOUNT}})}},async sendTransactionForSwap(n){var d,l,i,u,p,f,S,h,y,C,b,W;if(!n)return;const{fromAddress:t,toTokenAmount:o,isAuthConnector:s}=a.getParams();e.loadingTransaction=!0;const c=`Swapping ${(d=e.sourceToken)==null?void 0:d.symbol} to ${T.formatNumberToLocalString(o,3)} ${(l=e.toToken)==null?void 0:l.symbol}`,r=`Swapped ${(i=e.sourceToken)==null?void 0:i.symbol} to ${T.formatNumberToLocalString(o,3)} ${(u=e.toToken)==null?void 0:u.symbol}`;s?A.pushTransactionStack({onSuccess(){A.replace("Account"),w.showLoading(c),E.resetState()}}):w.showLoading("Confirm transaction in your wallet");try{const U=[(p=e.sourceToken)==null?void 0:p.address,(f=e.toToken)==null?void 0:f.address].join(","),m=await B.sendTransaction({address:t,to:n.to,data:n.data,value:n.value,chainNamespace:P.CHAIN.EVM});return e.loadingTransaction=!1,w.showSuccess(r),D.sendEvent({type:"track",event:"SWAP_SUCCESS",properties:{network:((S=g.state.activeCaipNetwork)==null?void 0:S.caipNetworkId)||"",swapFromToken:((h=a.state.sourceToken)==null?void 0:h.symbol)||"",swapToToken:((y=a.state.toToken)==null?void 0:y.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:M(P.CHAIN.EVM)===F.ACCOUNT_TYPES.SMART_ACCOUNT}}),E.resetState(),s||A.replace("Account"),E.getMyTokensWithBalance(U),m}catch(U){const m=U;e.transactionError=m==null?void 0:m.displayMessage,e.loadingTransaction=!1,w.showError((m==null?void 0:m.displayMessage)||"Transaction error"),D.sendEvent({type:"track",event:"SWAP_ERROR",properties:{message:(m==null?void 0:m.displayMessage)||(m==null?void 0:m.message)||"Unknown",network:((C=g.state.activeCaipNetwork)==null?void 0:C.caipNetworkId)||"",swapFromToken:((b=a.state.sourceToken)==null?void 0:b.symbol)||"",swapToToken:((W=a.state.toToken)==null?void 0:W.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:M(P.CHAIN.EVM)===F.ACCOUNT_TYPES.SMART_ACCOUNT}});return}},hasInsufficientToken(n,t){return I.isInsufficientSourceTokenForSwap(n,t,e.myTokensWithBalance)},setTransactionDetails(){const{toTokenAddress:n,toTokenDecimals:t}=a.getParams();!n||!t||(e.gasPriceInUSD=I.getGasPriceInUSD(e.networkPrice,BigInt(e.gasFee),BigInt(G)),e.priceImpact=I.getPriceImpact({sourceTokenAmount:e.sourceTokenAmount,sourceTokenPriceInUSD:e.sourceTokenPriceInUSD,toTokenPriceInUSD:e.toTokenPriceInUSD,toTokenAmount:e.toTokenAmount}),e.maxSlippage=I.getMaxSlippage(e.slippage,e.toTokenAmount),e.providerFee=I.getProviderFee(e.sourceTokenAmount))}},a=O(E);export{a as S};
1
+ import{N as T,w as O,p as x,R as A,S as w,d as B,E as D,e as M,W as F,C as g,B as N,a as L,f as v,A as z,h as R,b as _,g as H,i as V,s as $,c as q}from"./W3MFrameProviderSingleton-DszZRKRh.js";import{C as P}from"./NetworkUtil-Cdd9AsyN.js";const I={getGasPriceInEther(n,t){const o=t*n;return Number(o)/1e18},getGasPriceInUSD(n,t,o){const s=I.getGasPriceInEther(t,o);return T.bigNumber(n).times(s).toNumber()},getPriceImpact({sourceTokenAmount:n,sourceTokenPriceInUSD:t,toTokenPriceInUSD:o,toTokenAmount:s}){const c=T.bigNumber(n).times(t),r=T.bigNumber(s).times(o);return c.minus(r).div(c).times(100).toNumber()},getMaxSlippage(n,t){const o=T.bigNumber(n).div(100);return T.multiply(t,o).toNumber()},getProviderFee(n,t=.0085){return T.bigNumber(n).times(t).toString()},isInsufficientNetworkTokenForGas(n,t){const o=t||"0";return T.bigNumber(n).eq(0)?!0:T.bigNumber(T.bigNumber(o)).gt(n)},isInsufficientSourceTokenForSwap(n,t,o){var r,d;const s=(d=(r=o==null?void 0:o.find(l=>l.address===t))==null?void 0:r.quantity)==null?void 0:d.numeric;return T.bigNumber(s||"0").lt(n)}},G=15e4,Q=6,k={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:_.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=x({...k}),E={state:e,subscribe(n){return q(e,()=>n(e))},subscribeKey(n,t){return $(e,n,t)},getParams(){var i,u,p,f,S,h,y,C,b;const n=g.state.activeChain,t=((i=g.getAccountData(n))==null?void 0:i.caipAddress)??g.state.activeCaipAddress,o=L.getPlainAddress(t),s=H(),c=V.getConnectorId(g.state.activeChain);if(!o)throw new Error("No address found to swap the tokens from.");const r=!((u=e.toToken)!=null&&u.address)||!((p=e.toToken)!=null&&p.decimals),d=!((f=e.sourceToken)!=null&&f.address)||!((S=e.sourceToken)!=null&&S.decimals)||!T.bigNumber(e.sourceTokenAmount).gt(0),l=!e.sourceTokenAmount;return{networkAddress:s,fromAddress:o,fromCaipAddress:t,sourceTokenAddress:(h=e.sourceToken)==null?void 0:h.address,toTokenAddress:(y=e.toToken)==null?void 0:y.address,toTokenAmount:e.toTokenAmount,toTokenDecimals:(C=e.toToken)==null?void 0:C.decimals,sourceTokenAmount:e.sourceTokenAmount,sourceTokenDecimals:(b=e.sourceToken)==null?void 0:b.decimals,invalidToToken:r,invalidSourceToken:d,invalidSourceTokenAmount:l,availableToSwap:t&&!r&&!d&&!l,isAuthConnector:c===P.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?T.toFixed(n,Q):""},async setTokenPrice(n,t){let o=e.tokensPriceMap[n]||0;o||(e.loadingPrices=!0,o=await a.getAddressPrice(n)),t==="sourceToken"?e.sourceTokenPriceInUSD=o:t==="toToken"&&(e.toTokenPriceInUSD=o),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,t=e.sourceToken?{...e.sourceToken}:void 0,o=n&&e.toTokenAmount===""?"1":e.toTokenAmount;a.setSourceTokenAmount(o),a.setToTokenAmount(""),await a.setSourceToken(n),await a.setToToken(t),e.switchingTokens=!1,a.swapTokens()}catch(n){throw e.switchingTokens=!1,n}}},resetState(){e.myTokensWithBalance=k.myTokensWithBalance,e.tokensPriceMap=k.tokensPriceMap,e.initialized=k.initialized,e.initializing=k.initializing,e.switchingTokens=k.switchingTokens,e.sourceToken=k.sourceToken,e.sourceTokenAmount=k.sourceTokenAmount,e.sourceTokenPriceInUSD=k.sourceTokenPriceInUSD,e.toToken=k.toToken,e.toTokenAmount=k.toTokenAmount,e.toTokenPriceInUSD=k.toTokenPriceInUSD,e.networkPrice=k.networkPrice,e.networkTokenSymbol=k.networkTokenSymbol,e.networkBalanceInUSD=k.networkBalanceInUSD,e.inputError=k.inputError},resetValues(){var o;const{networkAddress:n}=a.getParams(),t=(o=e.tokens)==null?void 0:o.find(s=>s.address===n);a.setSourceToken(t),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,w.showError("Failed to initialize swap"),A.goBack()}e.initializing=!1}},async fetchTokens(){var o;const{networkAddress:n}=a.getParams();await a.getNetworkTokenPrice(),await a.getMyTokensWithBalance();const t=(o=e.myTokensWithBalance)==null?void 0:o.find(s=>s.address===n);t&&(e.networkTokenSymbol=t.symbol,a.setSourceToken(t),a.setSourceTokenAmount("0"))},async getTokenList(){var t,o;const n=(t=g.state.activeCaipNetwork)==null?void 0:t.caipNetworkId;if(!(e.caipNetworkId===n&&e.tokens))try{e.tokensLoading=!0;const s=await v.getTokenList(n);e.tokens=s,e.caipNetworkId=n,e.popularTokens=s.sort((i,u)=>i.symbol<u.symbol?-1:i.symbol>u.symbol?1:0);const r=(n&&((o=_.SUGGESTED_TOKENS_BY_CHAIN)==null?void 0:o[n])||[]).map(i=>s.find(u=>u.symbol===i)).filter(i=>!!i),l=(_.SWAP_SUGGESTED_TOKENS||[]).map(i=>s.find(u=>u.symbol===i)).filter(i=>!!i).filter(i=>!r.some(u=>u.address===i.address));e.suggestedTokens=[...r,...l]}catch{e.tokens=[],e.popularTokens=[],e.suggestedTokens=[]}finally{e.tokensLoading=!1}},async getAddressPrice(n){var i,u;const t=e.tokensPriceMap[n];if(t)return t;const o=await N.fetchTokenPrice({addresses:[n]}),s=(o==null?void 0:o.fungibles)||[],c=[...e.tokens||[],...e.myTokensWithBalance||[]],r=(i=c==null?void 0:c.find(p=>p.address===n))==null?void 0:i.symbol,d=((u=s.find(p=>p.symbol.toLowerCase()===(r==null?void 0:r.toLowerCase())))==null?void 0:u.price)||0,l=parseFloat(d.toString());return e.tokensPriceMap[n]=l,l},async getNetworkTokenPrice(){var c;const{networkAddress:n}=a.getParams(),o=(c=(await N.fetchTokenPrice({addresses:[n]}).catch(()=>(w.showError("Failed to fetch network token price"),{fungibles:[]}))).fungibles)==null?void 0:c[0],s=(o==null?void 0:o.price.toString())||"0";e.tokensPriceMap[n]=parseFloat(s),e.networkTokenSymbol=(o==null?void 0:o.symbol)||"",e.networkPrice=s},async getMyTokensWithBalance(n){var s;const t=await R.getMyTokensWithBalance({forceUpdate:n,caipNetwork:g.state.activeCaipNetwork,address:(s=g.getAccountData())==null?void 0:s.address}),o=v.mapBalancesToSwapTokens(t);o&&(await a.getInitialGasPrice(),a.setBalances(o))},setBalances(n){const{networkAddress:t}=a.getParams(),o=g.state.activeCaipNetwork;if(!o)return;const s=n.find(c=>c.address===t);n.forEach(c=>{e.tokensPriceMap[c.address]=c.price||0}),e.myTokensWithBalance=n.filter(c=>c.address.startsWith(o.caipNetworkId)),e.networkBalanceInUSD=s?T.multiply(s.quantity.numeric,s.price).toString():"0"},async getInitialGasPrice(){var t,o;const n=await v.fetchGasPrice();if(!n)return{gasPrice:null,gasPriceInUSD:null};switch((o=(t=g.state)==null?void 0:t.activeCaipNetwork)==null?void 0:o.chainNamespace){case P.CHAIN.SOLANA:return e.gasFee=n.standard??"0",e.gasPriceInUSD=T.multiply(n.standard,e.networkPrice).div(1e9).toNumber(),{gasPrice:BigInt(e.gasFee),gasPriceInUSD:Number(e.gasPriceInUSD)};case P.CHAIN.EVM:default:const s=n.standard??"0",c=BigInt(s),r=BigInt(G),d=I.getGasPriceInUSD(e.networkPrice,r,c);return e.gasFee=s,e.gasPriceInUSD=d,{gasPrice:c,gasPriceInUSD:d}}},async swapTokens(){var r,d,l;const n=(r=g.getAccountData())==null?void 0:r.address,t=e.sourceToken,o=e.toToken,s=T.bigNumber(e.sourceTokenAmount).gt(0);if(s||a.setToTokenAmount(""),!o||!t||e.loadingPrices||!s||!n)return;e.loadingQuote=!0;const c=T.bigNumber(e.sourceTokenAmount).times(10**t.decimals).round(0).toFixed(0);try{const i=await N.fetchSwapQuote({userAddress:n,from:t.address,to:o.address,gasPrice:e.gasFee,amount:c.toString()});e.loadingQuote=!1;const u=(l=(d=i==null?void 0:i.quotes)==null?void 0:d[0])==null?void 0:l.toAmount;if(!u){z.open({displayMessage:"Incorrect amount",debugMessage:"Please enter a valid amount"},"error");return}const p=T.bigNumber(u).div(10**o.decimals).toString();a.setToTokenAmount(p),a.hasInsufficientToken(e.sourceTokenAmount,t.address)?e.inputError="Insufficient balance":(e.inputError=void 0,a.setTransactionDetails())}catch(i){const u=await v.handleSwapError(i);e.loadingQuote=!1,e.inputError=u||"Insufficient balance"}},async getTransaction(){const{fromCaipAddress:n,availableToSwap:t}=a.getParams(),o=e.sourceToken,s=e.toToken;if(!(!n||!t||!o||!s||e.loadingQuote))try{e.loadingBuildTransaction=!0;const c=await v.fetchSwapAllowance({userAddress:n,tokenAddress:o.address,sourceTokenAmount:e.sourceTokenAmount,sourceTokenDecimals:o.decimals});let r;return c?r=await a.createSwapTransaction():r=await a.createAllowanceTransaction(),e.loadingBuildTransaction=!1,e.fetchError=!1,r}catch{A.goBack(),w.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:t,toTokenAddress:o}=a.getParams();if(!(!n||!o)){if(!t)throw new Error("createAllowanceTransaction - No source token address found.");try{const s=await N.generateApproveCalldata({from:t,to:o,userAddress:n}),c=L.getPlainAddress(s.tx.from);if(!c)throw new Error("SwapController:createAllowanceTransaction - address is required");const r={data:s.tx.data,to:c,gasPrice:BigInt(s.tx.eip155.gasPrice),value:BigInt(s.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{A.goBack(),w.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:t,sourceTokenAmount:o}=a.getParams(),s=e.sourceToken,c=e.toToken;if(!t||!o||!s||!c)return;const r=(d=B.parseUnits(o,s.decimals))==null?void 0:d.toString();try{const l=await N.generateSwapCalldata({userAddress:t,from:s.address,to:c.address,amount:r,disableEstimate:!0}),i=s.address===n,u=BigInt(l.tx.eip155.gas),p=BigInt(l.tx.eip155.gasPrice),f=L.getPlainAddress(l.tx.to);if(!f)throw new Error("SwapController:createSwapTransaction - address is required");const S={data:l.tx.data,to:f,gas:u,gasPrice:p,value:BigInt(i?r??"0":"0"),toAmount:e.toTokenAmount};return e.gasPriceInUSD=I.getGasPriceInUSD(e.networkPrice,u,p),e.approvalTransaction=void 0,e.swapTransaction=S,S}catch{A.goBack(),w.showError("Failed to create transaction"),e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}},onEmbeddedWalletApprovalSuccess(){w.showLoading("Approve limit increase in your wallet"),A.replace("SwapPreview")},async sendTransactionForApproval(n){var c,r,d;const{fromAddress:t,isAuthConnector:o}=a.getParams();e.loadingApprovalTransaction=!0,o?A.pushTransactionStack({onSuccess:a.onEmbeddedWalletApprovalSuccess}):w.showLoading("Approve limit increase in your wallet");try{await B.sendTransaction({address:t,to:n.to,data:n.data,value:n.value,chainNamespace:P.CHAIN.EVM}),await a.swapTokens(),await a.getTransaction(),e.approvalTransaction=void 0,e.loadingApprovalTransaction=!1}catch(l){const i=l;e.transactionError=i==null?void 0:i.displayMessage,e.loadingApprovalTransaction=!1,w.showError((i==null?void 0:i.displayMessage)||"Transaction error"),D.sendEvent({type:"track",event:"SWAP_APPROVAL_ERROR",properties:{message:(i==null?void 0:i.displayMessage)||(i==null?void 0:i.message)||"Unknown",network:((c=g.state.activeCaipNetwork)==null?void 0:c.caipNetworkId)||"",swapFromToken:((r=a.state.sourceToken)==null?void 0:r.symbol)||"",swapToToken:((d=a.state.toToken)==null?void 0:d.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:M(P.CHAIN.EVM)===F.ACCOUNT_TYPES.SMART_ACCOUNT}})}},async sendTransactionForSwap(n){var d,l,i,u,p,f,S,h,y,C,b,W;if(!n)return;const{fromAddress:t,toTokenAmount:o,isAuthConnector:s}=a.getParams();e.loadingTransaction=!0;const c=`Swapping ${(d=e.sourceToken)==null?void 0:d.symbol} to ${T.formatNumberToLocalString(o,3)} ${(l=e.toToken)==null?void 0:l.symbol}`,r=`Swapped ${(i=e.sourceToken)==null?void 0:i.symbol} to ${T.formatNumberToLocalString(o,3)} ${(u=e.toToken)==null?void 0:u.symbol}`;s?A.pushTransactionStack({onSuccess(){A.replace("Account"),w.showLoading(c),E.resetState()}}):w.showLoading("Confirm transaction in your wallet");try{const U=[(p=e.sourceToken)==null?void 0:p.address,(f=e.toToken)==null?void 0:f.address].join(","),m=await B.sendTransaction({address:t,to:n.to,data:n.data,value:n.value,chainNamespace:P.CHAIN.EVM});return e.loadingTransaction=!1,w.showSuccess(r),D.sendEvent({type:"track",event:"SWAP_SUCCESS",properties:{network:((S=g.state.activeCaipNetwork)==null?void 0:S.caipNetworkId)||"",swapFromToken:((h=a.state.sourceToken)==null?void 0:h.symbol)||"",swapToToken:((y=a.state.toToken)==null?void 0:y.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:M(P.CHAIN.EVM)===F.ACCOUNT_TYPES.SMART_ACCOUNT}}),E.resetState(),s||A.replace("Account"),E.getMyTokensWithBalance(U),m}catch(U){const m=U;e.transactionError=m==null?void 0:m.displayMessage,e.loadingTransaction=!1,w.showError((m==null?void 0:m.displayMessage)||"Transaction error"),D.sendEvent({type:"track",event:"SWAP_ERROR",properties:{message:(m==null?void 0:m.displayMessage)||(m==null?void 0:m.message)||"Unknown",network:((C=g.state.activeCaipNetwork)==null?void 0:C.caipNetworkId)||"",swapFromToken:((b=a.state.sourceToken)==null?void 0:b.symbol)||"",swapToToken:((W=a.state.toToken)==null?void 0:W.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:M(P.CHAIN.EVM)===F.ACCOUNT_TYPES.SMART_ACCOUNT}});return}},hasInsufficientToken(n,t){return I.isInsufficientSourceTokenForSwap(n,t,e.myTokensWithBalance)},setTransactionDetails(){const{toTokenAddress:n,toTokenDecimals:t}=a.getParams();!n||!t||(e.gasPriceInUSD=I.getGasPriceInUSD(e.networkPrice,BigInt(e.gasFee),BigInt(G)),e.priceImpact=I.getPriceImpact({sourceTokenAmount:e.sourceTokenAmount,sourceTokenPriceInUSD:e.sourceTokenPriceInUSD,toTokenPriceInUSD:e.toTokenPriceInUSD,toTokenAmount:e.toTokenAmount}),e.maxSlippage=I.getMaxSlippage(e.slippage,e.toTokenAmount),e.providerFee=I.getProviderFee(e.sourceTokenAmount))}},a=O(E);export{a as S};