@dcl/auth-site 4.21.0 → 4.21.1-30282291998.commit-7741200

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 (117) hide show
  1. package/assets/{ConstantsUtil-SfeDQRNO.js → ConstantsUtil-B_1wG5vR.js} +1 -1
  2. package/assets/{ContentfulRichText-B493-l1G.js → ContentfulRichText-CVKevVe4.js} +1 -1
  3. package/assets/{ExchangeController-Cl7LpW_9.js → ExchangeController-DCZepsks.js} +1 -1
  4. package/assets/{HelpersUtil-BqxjBOsb.js → HelpersUtil-D4gwnK8D.js} +1 -1
  5. package/assets/LoginPage-huBKWGlx.js +1 -0
  6. package/assets/{NetworkUtil-WtQP9K5L.js → NetworkUtil-CBP75VjE.js} +1 -1
  7. package/assets/{SwapController-C3sOw1fb.js → SwapController-DbOnmtjm.js} +1 -1
  8. package/assets/{W3MFrameProviderSingleton-GariHyC1.js → W3MFrameProviderSingleton-6cmMN1JV.js} +3 -3
  9. package/assets/{biconomy-ok_Fev4O.js → biconomy-D1EXxA7F.js} +1 -1
  10. package/assets/browser-ponyfill-CfapXlLj.js +1 -0
  11. package/assets/{browser-CL7pc_C2.js → browser-wIrNP8-L.js} +1 -1
  12. package/assets/{ccip-CFiU7kCg.js → ccip-DVeSiGJW.js} +1 -1
  13. package/assets/{ccip-BlbxM0LQ.js → ccip-bk9Msknv.js} +1 -1
  14. package/assets/{chains-CGXwPY-w.js → chains-YJh_kwoG.js} +1 -1
  15. package/assets/{common-CvKtb4n1.js → common-DAd2b35c.js} +1 -1
  16. package/assets/{controller-BFbz0Wfy.js → controller-BL5ery_A.js} +2 -2
  17. package/assets/{data-capture-Bjp5qmbu.js → data-capture-B8eCUIcE.js} +1 -1
  18. package/assets/{email-dOZOTXLM.js → email-KCXiMYF3.js} +1 -1
  19. package/assets/{embedded-wallet-4C0zCBzD.js → embedded-wallet-B_wovPbN.js} +1 -1
  20. package/assets/{engine-BF4fgHph.js → engine-osc-auGv.js} +1 -1
  21. package/assets/{estimate-l1-fee-DFM9SNlY.js → estimate-l1-fee-D12BfRq0.js} +1 -1
  22. package/assets/{ethereum-D1IvEqvR.js → ethereum-CuwXPURS.js} +1 -1
  23. package/assets/{extractIPFS-DJ38044A.js → extractIPFS-JSayXYon.js} +1 -1
  24. package/assets/{features-Dq7eLLHj.js → features-cMphHD0m.js} +1 -1
  25. package/assets/{fetchTokenMetadata-DFbXfV36.js → fetchTokenMetadata-CzzqUD_C.js} +1 -1
  26. package/assets/{fortmatic-VXwlmn3x.js → fortmatic-BtfrNeKp.js} +1 -1
  27. package/assets/{get-ecosystem-wallet-info-7Lw-sZ_z.js → get-ecosystem-wallet-info-Cm-kfk0m.js} +1 -1
  28. package/assets/{getBalance-lwqG5BkA.js → getBalance-CwsaSxen.js} +1 -1
  29. package/assets/{getInstalledModules-BqEUrGDu.js → getInstalledModules-B-RsE287.js} +1 -1
  30. package/assets/{getNFT-CdoOvyuq.js → getNFT-BqbjDGbh.js} +2 -2
  31. package/assets/{getNFT-qEDnShr-.js → getNFT-ClUfSxlO.js} +1 -1
  32. package/assets/{if-defined-CqpJarBn.js → if-defined-Dwq8XpDA.js} +1 -1
  33. package/assets/{in-app-wallet-calls-DnbOJdqi.js → in-app-wallet-calls-CwwQ0VDY.js} +1 -1
  34. package/assets/index-9l0HFt0G.js +176 -0
  35. package/assets/{index-DhrbQM9o.js → index-B3SuCFE2.js} +1 -1
  36. package/assets/{index-B4nv3uRr.js → index-BD9BBG_e.js} +1 -1
  37. package/assets/{index-Bmtxr8ck.js → index-BF1p7C7k.js} +1 -1
  38. package/assets/{index-C0a8a3_a.js → index-BITcR_1M.js} +1 -1
  39. package/assets/{index-Dqf3E5Am.js → index-BJ89t_bW.js} +1 -1
  40. package/assets/{index-BgA11815.js → index-BU6y379O.js} +1 -1
  41. package/assets/{index-CJQ7XUF1.js → index-BVcKuMWZ.js} +1 -1
  42. package/assets/{index-BZnk5nGE.js → index-BYN2eN-f.js} +1 -1
  43. package/assets/{index-BehUnmBQ.js → index-BYtVMjMf.js} +1 -1
  44. package/assets/{index-DWhePAr8.js → index-Ba0jOwXj.js} +1 -1
  45. package/assets/{index-CusnlpEv.js → index-BdHhENX2.js} +1 -1
  46. package/assets/{index-BnMK4rtE.js → index-Bf_ty5ez.js} +1 -1
  47. package/assets/{index-aGypPCn4.js → index-BobruL3O.js} +1 -1
  48. package/assets/{index-C2wXt8bX.js → index-BqWHQlqc.js} +1 -1
  49. package/assets/{index-COjWxfCR.js → index-BruZTjHN.js} +1 -1
  50. package/assets/{index-DLztodpx.js → index-BsZyT53i.js} +3 -3
  51. package/assets/{index-CmYKoHtM.js → index-BsreR9g6.js} +1 -1
  52. package/assets/{index-MOkgM3CG.js → index-C9_jeDSj.js} +1 -1
  53. package/assets/index-C9iDQul-.css +1 -0
  54. package/assets/{index-4Rm21Jcs.js → index-CDvT4Q_g.js} +1 -1
  55. package/assets/{index-CSkZf6TU.js → index-CSX8lAoJ.js} +1 -1
  56. package/assets/{index-CMVgYvcj.js → index-CXiI9rXS.js} +1 -1
  57. package/assets/{index-Czf8Yu5V.js → index-CcViJ9mC.js} +1 -1
  58. package/assets/{index-BGzx8xC8.js → index-Ccb5UGcf.js} +1 -1
  59. package/assets/{index-BgjSH5C0.js → index-Cd2xcopx.js} +2 -2
  60. package/assets/{index-D28HIM1b.js → index-CdCvLGtn.js} +1 -1
  61. package/assets/{index-CNiv2JYH.js → index-CoAewCyo.js} +1 -1
  62. package/assets/{index-D3-eBZaP.js → index-CrfS5O-x.js} +1 -1
  63. package/assets/{index-BNctYT5W.js → index-D5fxp13X.js} +1 -1
  64. package/assets/{index-BnEh4tgY.js → index-D8Nn1xAf.js} +1 -1
  65. package/assets/{index-ltBsvN7l.js → index-DBw0yfGw.js} +1 -1
  66. package/assets/{index-C9zadnoP.js → index-DEq1ZWKa.js} +1 -1
  67. package/assets/{index-DxTxoCQ5.js → index-DPQoS-8z.js} +1 -1
  68. package/assets/{index-48_zL_8V.js → index-DSJjx9ay.js} +3 -3
  69. package/assets/index-DYa4iVZE.js +2 -0
  70. package/assets/{index-CZRVN2vE.js → index-D_t2cwDH.js} +1 -1
  71. package/assets/{index-DJKVllQq.js → index-DbZ3_lNw.js} +1 -1
  72. package/assets/{index-DpgCenmo.js → index-DfgJOosn.js} +1 -1
  73. package/assets/{index-CA_7NqLN.js → index-DmH4eVyc.js} +2 -2
  74. package/assets/{index-B90inivw.js → index-FZIobYEj.js} +1 -1
  75. package/assets/{index-CVYOFAvL.js → index-G5i3_Lok.js} +1 -1
  76. package/assets/{index-BxDS7YgF.js → index-IxWsvkDr.js} +1 -1
  77. package/assets/{index-CVqr-7Pt.js → index-K0isSq0K.js} +1 -1
  78. package/assets/{index-DkoCaWFP.js → index-V_1m0BwN.js} +1 -1
  79. package/assets/{index-lExqs17M.js → index-h6jcLaB2.js} +1 -1
  80. package/assets/{index-CgTPsSZC.js → index-rfFvOinV.js} +1 -1
  81. package/assets/{index-CpyBHHGL.js → index-uKJ0cyDb.js} +1 -1
  82. package/assets/{index.es-DnpWJXa6.js → index.es-B3Gbdgyi.js} +1 -1
  83. package/assets/{index.es-obcdOSPN.js → index.es-CB-yvhhh.js} +1 -1
  84. package/assets/{native-B7Tb9XD0.js → native-DjcSPn6B.js} +1 -1
  85. package/assets/{networks-xZgfuUkI.js → networks-CwDBKQsQ.js} +3 -3
  86. package/assets/{onramp-DRY-VmEl.js → onramp-DCE_9jgB.js} +1 -1
  87. package/assets/{openzeppelin-BZfSJIk4.js → openzeppelin-DXl3mu84.js} +1 -1
  88. package/assets/{ownerOf-Chv3cItD.js → ownerOf-DShKXZbk.js} +1 -1
  89. package/assets/{parseNft-d6d6Hp6d.js → parseNft-BszEZh2L.js} +2 -2
  90. package/assets/{pay-with-exchange-Fws3sgDP.js → pay-with-exchange-BWZMELae.js} +1 -1
  91. package/assets/{qr-overlay-CRwPPsut.js → qr-overlay-Def5vMYS.js} +3 -3
  92. package/assets/{receive-ENeHUThj.js → receive-B4cKA7x5.js} +1 -1
  93. package/assets/{ref-BJXu_ix1.js → ref-jo_MQhC5.js} +1 -1
  94. package/assets/{resolveImplementation-BDMCDrvF.js → resolveImplementation-uCCZnkqv.js} +1 -1
  95. package/assets/{secp256k1-CAuxtucr.js → secp256k1-CKK4gwjJ.js} +1 -1
  96. package/assets/{send-BVveMXEO.js → send-Cpin8S8F.js} +1 -1
  97. package/assets/{send-eip712-transaction-BLYLbaE2.js → send-eip712-transaction-fuVr-0Wu.js} +1 -1
  98. package/assets/{send-gasless-transaction-H5yovUSA.js → send-gasless-transaction-U_MTNGJG.js} +2 -2
  99. package/assets/{session-proposal-BOVuEqZb.js → session-proposal-BCeFOzD0.js} +1 -1
  100. package/assets/{session-request-u0q6IDVU.js → session-request-CSPRWfOh.js} +2 -2
  101. package/assets/{socials-CT51nzyt.js → socials-DHfbWrjU.js} +1 -1
  102. package/assets/{swaps-DcnyL-aF.js → swaps-DcK0ETDM.js} +1 -1
  103. package/assets/{thirdweb-RfTGDewD.js → thirdweb-CS6G_ZNe.js} +5 -5
  104. package/assets/{totalSupply-D1tOGyvE.js → totalSupply-CrDdlqEX.js} +1 -1
  105. package/assets/{transactions-LbE_YtGz.js → transactions-vDZ5yeRz.js} +1 -1
  106. package/assets/{ui-CUXWd4jk.js → ui-Bc2xTSCT.js} +24 -24
  107. package/assets/{vendor-DlkLYSlV.js → vendor-DgCFzUFU.js} +1 -1
  108. package/assets/{w3m-modal-BSFcMGCh.js → w3m-modal-w4bBHHnI.js} +1 -1
  109. package/assets/{wallets-OS7LlF3P.js → wallets-CUOtYiA7.js} +5 -5
  110. package/assets/{web-connector-3zdQreYv.js → web-connector-B_ZD1CLE.js} +3 -3
  111. package/index.html +5 -5
  112. package/package.json +3 -3
  113. package/assets/LoginPage-3mBiytHd.js +0 -1
  114. package/assets/browser-ponyfill-B9OjpPGs.js +0 -1
  115. package/assets/index-C_o5O_iU.js +0 -284
  116. package/assets/index-DO37X-UR.js +0 -2
  117. package/assets/index-DdAb4cgP.css +0 -1
@@ -1 +1 @@
1
- import{p as t}from"./thirdweb-RfTGDewD.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-CS6G_ZNe.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-RfTGDewD.js";import{j as e}from"./ui-CUXWd4jk.js";import{a as o}from"./vendor-DlkLYSlV.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-CS6G_ZNe.js";import{j as e}from"./ui-Bc2xTSCT.js";import{a as o}from"./vendor-DgCFzUFU.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-GariHyC1.js";import{g as T,a as W,f as b,b as _,c as v}from"./index-48_zL_8V.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-6cmMN1JV.js";import{g as T,a as W,f as b,b as _,c as v}from"./index-DSJjx9ay.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-48_zL_8V.js";import{n as m,c as v}from"./index-BgA11815.js";import{C as c}from"./ConstantsUtil-SfeDQRNO.js";import{R as $,O as u}from"./W3MFrameProviderSingleton-GariHyC1.js";import{C as y}from"./NetworkUtil-WtQP9K5L.js";const b=f`
1
+ import{d as f,r as p,i as g,h}from"./index-DSJjx9ay.js";import{n as m,c as v}from"./index-BU6y379O.js";import{C as c}from"./ConstantsUtil-B_1wG5vR.js";import{R as $,O as u}from"./W3MFrameProviderSingleton-6cmMN1JV.js";import{C as y}from"./NetworkUtil-CBP75VjE.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-Bc2xTSCT.js";import{e as Fe,a}from"./vendor-DgCFzUFU.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-9l0HFt0G.js";import"./thirdweb-CS6G_ZNe.js";const ra="https://cdn.decentraland.org/@dcl/auth-site/4.21.1-30282291998.commit-7741200/assets/image-new1-CpZnKbBW.webp",ia="https://cdn.decentraland.org/@dcl/auth-site/4.21.1-30282291998.commit-7741200/assets/image-new2-C5ihWkmR.webp",la="https://cdn.decentraland.org/@dcl/auth-site/4.21.1-30282291998.commit-7741200/assets/image-new3-DJx27VUM.webp",ca="https://cdn.decentraland.org/@dcl/auth-site/4.21.1-30282291998.commit-7741200/assets/image-new4-Dx5Lwr3m.webp",da="https://cdn.decentraland.org/@dcl/auth-site/4.21.1-30282291998.commit-7741200/assets/image-new5-CzVG1QYp.webp",ua="https://cdn.decentraland.org/@dcl/auth-site/4.21.1-30282291998.commit-7741200/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-RfTGDewD.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-CS6G_ZNe.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-GariHyC1.js";import{C as P}from"./NetworkUtil-WtQP9K5L.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-6cmMN1JV.js";import{C as P}from"./NetworkUtil-CBP75VjE.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};