react-web3-storage 2.0.3 → 2.0.22

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 (55) hide show
  1. package/dist/{ReownAuthentication-ZWJVb5u8.mjs → ReownAuthentication-7iIT4jS4.mjs} +5 -5
  2. package/dist/{ReownAuthentication-_EMKUe4O.js → ReownAuthentication-BEGlJitZ.js} +1 -1
  3. package/dist/{SwapController-CNHVjC6V.mjs → SwapController-CmWZu4cY.mjs} +16 -16
  4. package/dist/{SwapController-75y039lY.js → SwapController-DNucRoq5.js} +1 -1
  5. package/dist/{ccip-CQrFYKlN.mjs → ccip-BCIUIeQM.mjs} +6 -6
  6. package/dist/{ccip-BgoVuN3u.js → ccip-Cy73HTCR.js} +1 -1
  7. package/dist/{data-capture-CgKKCS0j.mjs → data-capture-CaxHvefN.mjs} +5 -5
  8. package/dist/{data-capture-hbDyOOyJ.js → data-capture-DbbP8JDT.js} +1 -1
  9. package/dist/{email-C2N4HkZQ.mjs → email-B3WQnC0b.mjs} +9 -9
  10. package/dist/{email-DYvAHYik.js → email-CYJMBkHW.js} +1 -1
  11. package/dist/{embedded-wallet-_7JcZAOC.mjs → embedded-wallet-Dlo0wBgH.mjs} +22 -22
  12. package/dist/{embedded-wallet-CYNDQvBG.js → embedded-wallet-t_Jd_LFV.js} +1 -1
  13. package/dist/{features-JvQHn7sG.mjs → features-5qKGISK9.mjs} +1 -1
  14. package/dist/{features-BA8f0aFu.js → features-B1ezv71b.js} +1 -1
  15. package/dist/{index-B--AiWBy.mjs → index-2WfSPp5U.mjs} +5 -5
  16. package/dist/{index-DVNi_N99.mjs → index-BBH4oh8q.mjs} +2 -2
  17. package/dist/{index-CASDFBE7.js → index-BCZXGGtc.js} +1 -1
  18. package/dist/{index-DIxai2A2.mjs → index-BR1aMNYm.mjs} +1 -1
  19. package/dist/{index-BNobBA-8.js → index-BhaYgUya.js} +281 -281
  20. package/dist/{index-Clu0wU1d.mjs → index-CAtS1mbf.mjs} +15 -15
  21. package/dist/{index-BHukHFIh.mjs → index-CFLg0HEy.mjs} +4171 -4250
  22. package/dist/{index-xYJPqvul.js → index-CZuajWCC.js} +1 -1
  23. package/dist/{index-CjS2YG3n.js → index-D1agTf42.js} +1 -1
  24. package/dist/{index-Ccy2zz9q.mjs → index-D3R3_EiN.mjs} +1 -1
  25. package/dist/{index-DnKQlXMR.mjs → index-D8W2bJl5.mjs} +1 -1
  26. package/dist/{index-CLUlCRLy.js → index-DAGaFidW.js} +1 -1
  27. package/dist/index-DWRWjePT.mjs +267 -0
  28. package/dist/{index-mvH0tD6I.js → index-Dk48RrmB.js} +8 -8
  29. package/dist/{index-DzjJtqrG.js → index-MeOSUHRy.js} +1 -1
  30. package/dist/index-R_8iHUbU.js +1 -0
  31. package/dist/{index-Bxg-paEQ.mjs → index-SXXuh_Wo.mjs} +394 -346
  32. package/dist/{index-C_fopi0u.js → index-VrnBQez9.js} +1 -1
  33. package/dist/index.cjs.js +1 -1
  34. package/dist/index.es.js +1 -1
  35. package/dist/{onramp-DlA5BSaX.js → onramp-BMMneL8g.js} +1 -1
  36. package/dist/{onramp-zhj-U9X5.mjs → onramp-qJaw31Jf.mjs} +31 -31
  37. package/dist/{parseSignature-CWAxHYP1.js → parseSignature-jZAFls5F.js} +6 -6
  38. package/dist/{parseSignature-ZB66mPGB.mjs → parseSignature-zKnspnY-.mjs} +74 -56
  39. package/dist/{pay-with-exchange-Czbx9cbv.mjs → pay-with-exchange-CTRrPVEx.mjs} +2 -2
  40. package/dist/{pay-with-exchange-BQaMDGKp.js → pay-with-exchange-CgjKtyDu.js} +1 -1
  41. package/dist/{receive-VPGRuO6J.mjs → receive-D9mYL7F2.mjs} +1 -1
  42. package/dist/{receive-BA736NNd.js → receive-eP1MrUw6.js} +1 -1
  43. package/dist/{send-xiZMc6dE.mjs → send-DmCwhyow.mjs} +21 -21
  44. package/dist/{send-BhagKj7q.js → send-tFHrHPh4.js} +1 -1
  45. package/dist/{socials-B-mhVCLM.js → socials-BXz_VcPl.js} +1 -1
  46. package/dist/{socials-BX3hluqS.mjs → socials-BbYHDCTQ.mjs} +13 -13
  47. package/dist/{swaps-DQYnz8sb.js → swaps-C9W-NxLv.js} +1 -1
  48. package/dist/{swaps-BFl7r_MZ.mjs → swaps-D06KGkWD.mjs} +3 -3
  49. package/dist/{transactions-BooVIWm5.mjs → transactions-B-bDj0J7.mjs} +1 -1
  50. package/dist/{transactions-DWsNckfd.js → transactions-CHNmwPaw.js} +1 -1
  51. package/dist/{w3m-modal-BLoHPTsO.mjs → w3m-modal-B82zwpqg.mjs} +18 -18
  52. package/dist/{w3m-modal-D6NKq8XS.js → w3m-modal-CaxvJDN5.js} +1 -1
  53. package/package.json +2 -2
  54. package/dist/index-B7Og0OLg.js +0 -1
  55. package/dist/index-CgI_Ukj5.mjs +0 -267
@@ -1,5 +1,5 @@
1
- import { cc as g, cn as w, co as y, cp as A, c8 as k, cq as u, cd as N, cr as p } from "./index-BHukHFIh.mjs";
2
- class m {
1
+ import { cb as g, cm as w, cn as y, co as A, c7 as k, cp as u, cc as N, cq as m } from "./index-CFLg0HEy.mjs";
2
+ class p {
3
3
  constructor(e) {
4
4
  this.getNonce = e.getNonce;
5
5
  }
@@ -55,7 +55,7 @@ class E {
55
55
  constructor(e = {}) {
56
56
  this.otpUuid = null, this.listeners = {
57
57
  sessionChanged: []
58
- }, this.localAuthStorageKey = e.localAuthStorageKey || y.SIWX_AUTH_TOKEN, this.localNonceStorageKey = e.localNonceStorageKey || y.SIWX_NONCE_TOKEN, this.required = e.required ?? !0, this.messenger = new m({
58
+ }, this.localAuthStorageKey = e.localAuthStorageKey || y.SIWX_AUTH_TOKEN, this.localNonceStorageKey = e.localNonceStorageKey || y.SIWX_NONCE_TOKEN, this.required = e.required ?? !0, this.messenger = new p({
59
59
  getNonce: this.getNonce.bind(this)
60
60
  });
61
61
  }
@@ -246,7 +246,7 @@ class E {
246
246
  };
247
247
  }
248
248
  getSDKProperties() {
249
- return p._getSdkProperties();
249
+ return m._getSdkProperties();
250
250
  }
251
251
  emit(e, t) {
252
252
  this.listeners[e].forEach((s) => s(t));
@@ -270,5 +270,5 @@ function I(d) {
270
270
  }
271
271
  export {
272
272
  E as R,
273
- m as a
273
+ p as a
274
274
  };
@@ -1,4 +1,4 @@
1
- "use strict";const s=require("./index-BNobBA-8.js");class f{constructor(e){this.getNonce=e.getNonce}async createMessage(e){const t={accountAddress:e.accountAddress,chainId:e.chainId,version:"1",domain:typeof document>"u"?"Unknown Domain":document.location.host,uri:typeof document>"u"?"Unknown URI":document.location.href,resources:this.resources,nonce:await this.getNonce(e),issuedAt:this.stringifyDate(new Date),statement:void 0,expirationTime:void 0,notBefore:void 0};return Object.assign(t,{toString:()=>this.stringify(t)})}stringify(e){var n;const t=this.getNetworkName(e.chainId);return[`${e.domain} wants you to sign in with your ${t} account:`,e.accountAddress,e.statement?`
1
+ "use strict";const s=require("./index-BhaYgUya.js");class f{constructor(e){this.getNonce=e.getNonce}async createMessage(e){const t={accountAddress:e.accountAddress,chainId:e.chainId,version:"1",domain:typeof document>"u"?"Unknown Domain":document.location.host,uri:typeof document>"u"?"Unknown URI":document.location.href,resources:this.resources,nonce:await this.getNonce(e),issuedAt:this.stringifyDate(new Date),statement:void 0,expirationTime:void 0,notBefore:void 0};return Object.assign(t,{toString:()=>this.stringify(t)})}stringify(e){var n;const t=this.getNetworkName(e.chainId);return[`${e.domain} wants you to sign in with your ${t} account:`,e.accountAddress,e.statement?`
2
2
  ${e.statement}
3
3
  `:"",`URI: ${e.uri}`,`Version: ${e.version}`,`Chain ID: ${e.chainId}`,`Nonce: ${e.nonce}`,e.issuedAt&&`Issued At: ${e.issuedAt}`,e.expirationTime&&`Expiration Time: ${e.expirationTime}`,e.notBefore&&`Not Before: ${e.notBefore}`,e.requestId&&`Request ID: ${e.requestId}`,((n=e.resources)==null?void 0:n.length)&&e.resources.reduce((o,r)=>`${o}
4
4
  - ${r}`,"Resources:")].filter(o=>typeof o=="string").join(`
@@ -1,4 +1,4 @@
1
- import { c2 as T, c3 as W, c4 as x, c5 as A, c6 as w, c7 as D, c8 as P, c9 as B, ca as M, cb as F, cc as g, cd as v, ce as L, cf as N, cg as z, ch as R, ci as _, cj as H, ck as V, cl as $, cm as q } from "./index-BHukHFIh.mjs";
1
+ import { c1 as T, c2 as W, c3 as x, c4 as A, c5 as w, c6 as D, c7 as P, c8 as B, c9 as M, ca as F, cb as m, cc as v, cd as L, ce as N, cf as z, cg as R, ch as _, ci as H, cj as V, ck as $, cl as q } from "./index-CFLg0HEy.mjs";
2
2
  const I = {
3
3
  getGasPriceInEther(n, t) {
4
4
  const o = t * n;
@@ -81,7 +81,7 @@ const I = {
81
81
  },
82
82
  getParams() {
83
83
  var i, u, p, f, S, h, y, b, C;
84
- 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);
84
+ const n = m.state.activeChain, t = ((i = m.getAccountData(n)) == null ? void 0 : i.caipAddress) ?? m.state.activeCaipAddress, o = L.getPlainAddress(t), s = H(), c = V.getConnectorId(m.state.activeChain);
85
85
  if (!o)
86
86
  throw new Error("No address found to swap the tokens from.");
87
87
  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;
@@ -171,7 +171,7 @@ const I = {
171
171
  },
172
172
  async getTokenList() {
173
173
  var t, o;
174
- const n = (t = g.state.activeCaipNetwork) == null ? void 0 : t.caipNetworkId;
174
+ const n = (t = m.state.activeCaipNetwork) == null ? void 0 : t.caipNetworkId;
175
175
  if (!(e.caipNetworkId === n && e.tokens))
176
176
  try {
177
177
  e.tokensLoading = !0;
@@ -206,13 +206,13 @@ const I = {
206
206
  var s;
207
207
  const t = await R.getMyTokensWithBalance({
208
208
  forceUpdate: n,
209
- caipNetwork: g.state.activeCaipNetwork,
210
- address: (s = g.getAccountData()) == null ? void 0 : s.address
209
+ caipNetwork: m.state.activeCaipNetwork,
210
+ address: (s = m.getAccountData()) == null ? void 0 : s.address
211
211
  }), o = N.mapBalancesToSwapTokens(t);
212
212
  o && (await a.getInitialGasPrice(), a.setBalances(o));
213
213
  },
214
214
  setBalances(n) {
215
- const { networkAddress: t } = a.getParams(), o = g.state.activeCaipNetwork;
215
+ const { networkAddress: t } = a.getParams(), o = m.state.activeCaipNetwork;
216
216
  if (!o)
217
217
  return;
218
218
  const s = n.find((c) => c.address === t);
@@ -225,7 +225,7 @@ const I = {
225
225
  const n = await N.fetchGasPrice();
226
226
  if (!n)
227
227
  return { gasPrice: null, gasPriceInUSD: null };
228
- switch ((o = (t = g.state) == null ? void 0 : t.activeCaipNetwork) == null ? void 0 : o.chainNamespace) {
228
+ switch ((o = (t = m.state) == null ? void 0 : t.activeCaipNetwork) == null ? void 0 : o.chainNamespace) {
229
229
  case P.CHAIN.SOLANA:
230
230
  return e.gasFee = n.standard ?? "0", e.gasPriceInUSD = T.multiply(n.standard, e.networkPrice).div(1e9).toNumber(), {
231
231
  gasPrice: BigInt(e.gasFee),
@@ -240,7 +240,7 @@ const I = {
240
240
  // -- Swap -------------------------------------- //
241
241
  async swapTokens() {
242
242
  var r, d, l;
243
- const n = (r = g.getAccountData()) == null ? void 0 : r.address, t = e.sourceToken, o = e.toToken, s = T.bigNumber(e.sourceTokenAmount).gt(0);
243
+ const n = (r = m.getAccountData()) == null ? void 0 : r.address, t = e.sourceToken, o = e.toToken, s = T.bigNumber(e.sourceTokenAmount).gt(0);
244
244
  if (s || a.setToTokenAmount(""), !o || !t || e.loadingPrices || !s || !n)
245
245
  return;
246
246
  e.loadingQuote = !0;
@@ -382,7 +382,7 @@ const I = {
382
382
  event: "SWAP_APPROVAL_ERROR",
383
383
  properties: {
384
384
  message: (i == null ? void 0 : i.displayMessage) || (i == null ? void 0 : i.message) || "Unknown",
385
- network: ((c = g.state.activeCaipNetwork) == null ? void 0 : c.caipNetworkId) || "",
385
+ network: ((c = m.state.activeCaipNetwork) == null ? void 0 : c.caipNetworkId) || "",
386
386
  swapFromToken: ((r = a.state.sourceToken) == null ? void 0 : r.symbol) || "",
387
387
  swapToToken: ((d = a.state.toToken) == null ? void 0 : d.symbol) || "",
388
388
  swapFromAmount: a.state.sourceTokenAmount || "",
@@ -405,7 +405,7 @@ const I = {
405
405
  }
406
406
  }) : w.showLoading("Confirm transaction in your wallet");
407
407
  try {
408
- const U = [(p = e.sourceToken) == null ? void 0 : p.address, (f = e.toToken) == null ? void 0 : f.address].join(","), m = await D.sendTransaction({
408
+ const U = [(p = e.sourceToken) == null ? void 0 : p.address, (f = e.toToken) == null ? void 0 : f.address].join(","), g = await D.sendTransaction({
409
409
  address: t,
410
410
  to: n.to,
411
411
  data: n.data,
@@ -416,22 +416,22 @@ const I = {
416
416
  type: "track",
417
417
  event: "SWAP_SUCCESS",
418
418
  properties: {
419
- network: ((S = g.state.activeCaipNetwork) == null ? void 0 : S.caipNetworkId) || "",
419
+ network: ((S = m.state.activeCaipNetwork) == null ? void 0 : S.caipNetworkId) || "",
420
420
  swapFromToken: ((h = a.state.sourceToken) == null ? void 0 : h.symbol) || "",
421
421
  swapToToken: ((y = a.state.toToken) == null ? void 0 : y.symbol) || "",
422
422
  swapFromAmount: a.state.sourceTokenAmount || "",
423
423
  swapToAmount: a.state.toTokenAmount || "",
424
424
  isSmartAccount: M(P.CHAIN.EVM) === F.ACCOUNT_TYPES.SMART_ACCOUNT
425
425
  }
426
- }), E.resetState(), s || A.replace("Account"), E.getMyTokensWithBalance(U), m;
426
+ }), E.resetState(), s || A.replace("Account"), E.getMyTokensWithBalance(U), g;
427
427
  } catch (U) {
428
- const m = U;
429
- e.transactionError = m == null ? void 0 : m.displayMessage, e.loadingTransaction = !1, w.showError((m == null ? void 0 : m.displayMessage) || "Transaction error"), B.sendEvent({
428
+ const g = U;
429
+ e.transactionError = g == null ? void 0 : g.displayMessage, e.loadingTransaction = !1, w.showError((g == null ? void 0 : g.displayMessage) || "Transaction error"), B.sendEvent({
430
430
  type: "track",
431
431
  event: "SWAP_ERROR",
432
432
  properties: {
433
- message: (m == null ? void 0 : m.displayMessage) || (m == null ? void 0 : m.message) || "Unknown",
434
- network: ((b = g.state.activeCaipNetwork) == null ? void 0 : b.caipNetworkId) || "",
433
+ message: (g == null ? void 0 : g.displayMessage) || (g == null ? void 0 : g.message) || "Unknown",
434
+ network: ((b = m.state.activeCaipNetwork) == null ? void 0 : b.caipNetworkId) || "",
435
435
  swapFromToken: ((C = a.state.sourceToken) == null ? void 0 : C.symbol) || "",
436
436
  swapToToken: ((G = a.state.toToken) == null ? void 0 : G.symbol) || "",
437
437
  swapFromAmount: a.state.sourceTokenAmount || "",
@@ -1 +1 @@
1
- "use strict";const o=require("./index-BNobBA-8.js"),A={getGasPriceInEther(n,r){const t=r*n;return Number(t)/1e18},getGasPriceInUSD(n,r,t){const s=A.getGasPriceInEther(r,t);return o.NumberUtil.bigNumber(n).times(s).toNumber()},getPriceImpact({sourceTokenAmount:n,sourceTokenPriceInUSD:r,toTokenPriceInUSD:t,toTokenAmount:s}){const l=o.NumberUtil.bigNumber(n).times(r),i=o.NumberUtil.bigNumber(s).times(t);return l.minus(i).div(l).times(100).toNumber()},getMaxSlippage(n,r){const t=o.NumberUtil.bigNumber(n).div(100);return o.NumberUtil.multiply(r,t).toNumber()},getProviderFee(n,r=.0085){return o.NumberUtil.bigNumber(n).times(r).toString()},isInsufficientNetworkTokenForGas(n,r){const t=r||"0";return o.NumberUtil.bigNumber(n).eq(0)?!0:o.NumberUtil.bigNumber(o.NumberUtil.bigNumber(t)).gt(n)},isInsufficientSourceTokenForSwap(n,r,t){var i,d;const s=(d=(i=t==null?void 0:t.find(k=>k.address===r))==null?void 0:i.quantity)==null?void 0:d.numeric;return o.NumberUtil.bigNumber(s||"0").lt(n)}},N=15e4,y=6,T={initializing:!1,initialized:!1,loadingPrices:!1,loadingQuote:!1,loadingApprovalTransaction:!1,loadingBuildTransaction:!1,loadingTransaction:!1,switchingTokens:!1,fetchError:!1,approvalTransaction:void 0,swapTransaction:void 0,transactionError:void 0,sourceToken:void 0,sourceTokenAmount:"",sourceTokenPriceInUSD:0,toToken:void 0,toTokenAmount:"",toTokenPriceInUSD:0,networkPrice:"0",networkBalanceInUSD:"0",networkTokenSymbol:"",inputError:void 0,slippage:o.ConstantsUtil$1.CONVERT_SLIPPAGE_TOLERANCE,tokens:void 0,popularTokens:void 0,suggestedTokens:void 0,foundTokens:void 0,myTokensWithBalance:void 0,tokensPriceMap:{},gasFee:"0",gasPriceInUSD:0,priceImpact:void 0,maxSlippage:void 0,providerFee:void 0},e=o.proxy({...T}),h={state:e,subscribe(n){return o.subscribe(e,()=>n(e))},subscribeKey(n,r){return o.subscribeKey(e,n,r)},getParams(){var c,u,p,g,w,f,S,C,P;const n=o.ChainController.state.activeChain,r=((c=o.ChainController.getAccountData(n))==null?void 0:c.caipAddress)??o.ChainController.state.activeCaipAddress,t=o.CoreHelperUtil.getPlainAddress(r),s=o.getActiveNetworkTokenAddress(),l=o.ConnectorController.getConnectorId(o.ChainController.state.activeChain);if(!t)throw new Error("No address found to swap the tokens from.");const i=!((u=e.toToken)!=null&&u.address)||!((p=e.toToken)!=null&&p.decimals),d=!((g=e.sourceToken)!=null&&g.address)||!((w=e.sourceToken)!=null&&w.decimals)||!o.NumberUtil.bigNumber(e.sourceTokenAmount).gt(0),k=!e.sourceTokenAmount;return{networkAddress:s,fromAddress:t,fromCaipAddress:r,sourceTokenAddress:(f=e.sourceToken)==null?void 0:f.address,toTokenAddress:(S=e.toToken)==null?void 0:S.address,toTokenAmount:e.toTokenAmount,toTokenDecimals:(C=e.toToken)==null?void 0:C.decimals,sourceTokenAmount:e.sourceTokenAmount,sourceTokenDecimals:(P=e.sourceToken)==null?void 0:P.decimals,invalidToToken:i,invalidSourceToken:d,invalidSourceTokenAmount:k,availableToSwap:r&&!i&&!d&&!k,isAuthConnector:l===o.ConstantsUtil.CONNECTOR_ID.AUTH}},async setSourceToken(n){if(!n){e.sourceToken=n,e.sourceTokenAmount="",e.sourceTokenPriceInUSD=0;return}e.sourceToken=n,await a.setTokenPrice(n.address,"sourceToken")},setSourceTokenAmount(n){e.sourceTokenAmount=n},async setToToken(n){if(!n){e.toToken=n,e.toTokenAmount="",e.toTokenPriceInUSD=0;return}e.toToken=n,await a.setTokenPrice(n.address,"toToken")},setToTokenAmount(n){e.toTokenAmount=n?o.NumberUtil.toFixed(n,y):""},async setTokenPrice(n,r){let t=e.tokensPriceMap[n]||0;t||(e.loadingPrices=!0,t=await a.getAddressPrice(n)),r==="sourceToken"?e.sourceTokenPriceInUSD=t:r==="toToken"&&(e.toTokenPriceInUSD=t),e.loadingPrices&&(e.loadingPrices=!1),a.getParams().availableToSwap&&!e.switchingTokens&&a.swapTokens()},async switchTokens(){if(!(e.initializing||!e.initialized||e.switchingTokens)){e.switchingTokens=!0;try{const n=e.toToken?{...e.toToken}:void 0,r=e.sourceToken?{...e.sourceToken}:void 0,t=n&&e.toTokenAmount===""?"1":e.toTokenAmount;a.setSourceTokenAmount(t),a.setToTokenAmount(""),await a.setSourceToken(n),await a.setToToken(r),e.switchingTokens=!1,a.swapTokens()}catch(n){throw e.switchingTokens=!1,n}}},resetState(){e.myTokensWithBalance=T.myTokensWithBalance,e.tokensPriceMap=T.tokensPriceMap,e.initialized=T.initialized,e.initializing=T.initializing,e.switchingTokens=T.switchingTokens,e.sourceToken=T.sourceToken,e.sourceTokenAmount=T.sourceTokenAmount,e.sourceTokenPriceInUSD=T.sourceTokenPriceInUSD,e.toToken=T.toToken,e.toTokenAmount=T.toTokenAmount,e.toTokenPriceInUSD=T.toTokenPriceInUSD,e.networkPrice=T.networkPrice,e.networkTokenSymbol=T.networkTokenSymbol,e.networkBalanceInUSD=T.networkBalanceInUSD,e.inputError=T.inputError},resetValues(){var t;const{networkAddress:n}=a.getParams(),r=(t=e.tokens)==null?void 0:t.find(s=>s.address===n);a.setSourceToken(r),a.setToToken(void 0)},getApprovalLoadingState(){return e.loadingApprovalTransaction},clearError(){e.transactionError=void 0},async initializeState(){if(!e.initializing){if(e.initializing=!0,!e.initialized)try{await a.fetchTokens(),e.initialized=!0}catch{e.initialized=!1,o.SnackController.showError("Failed to initialize swap"),o.RouterController.goBack()}e.initializing=!1}},async fetchTokens(){var t;const{networkAddress:n}=a.getParams();await a.getNetworkTokenPrice(),await a.getMyTokensWithBalance();const r=(t=e.myTokensWithBalance)==null?void 0:t.find(s=>s.address===n);r&&(e.networkTokenSymbol=r.symbol,a.setSourceToken(r),a.setSourceTokenAmount("0"))},async getTokenList(){var r,t;const n=(r=o.ChainController.state.activeCaipNetwork)==null?void 0:r.caipNetworkId;if(!(e.caipNetworkId===n&&e.tokens))try{e.tokensLoading=!0;const s=await o.SwapApiUtil.getTokenList(n);e.tokens=s,e.caipNetworkId=n,e.popularTokens=s.sort((c,u)=>c.symbol<u.symbol?-1:c.symbol>u.symbol?1:0);const i=(n&&((t=o.ConstantsUtil$1.SUGGESTED_TOKENS_BY_CHAIN)==null?void 0:t[n])||[]).map(c=>s.find(u=>u.symbol===c)).filter(c=>!!c),k=(o.ConstantsUtil$1.SWAP_SUGGESTED_TOKENS||[]).map(c=>s.find(u=>u.symbol===c)).filter(c=>!!c).filter(c=>!i.some(u=>u.address===c.address));e.suggestedTokens=[...i,...k]}catch{e.tokens=[],e.popularTokens=[],e.suggestedTokens=[]}finally{e.tokensLoading=!1}},async getAddressPrice(n){var c,u;const r=e.tokensPriceMap[n];if(r)return r;const t=await o.BlockchainApiController.fetchTokenPrice({addresses:[n]}),s=(t==null?void 0:t.fungibles)||[],l=[...e.tokens||[],...e.myTokensWithBalance||[]],i=(c=l==null?void 0:l.find(p=>p.address===n))==null?void 0:c.symbol,d=((u=s.find(p=>p.symbol.toLowerCase()===(i==null?void 0:i.toLowerCase())))==null?void 0:u.price)||0,k=parseFloat(d.toString());return e.tokensPriceMap[n]=k,k},async getNetworkTokenPrice(){var l;const{networkAddress:n}=a.getParams(),t=(l=(await o.BlockchainApiController.fetchTokenPrice({addresses:[n]}).catch(()=>(o.SnackController.showError("Failed to fetch network token price"),{fungibles:[]}))).fungibles)==null?void 0:l[0],s=(t==null?void 0:t.price.toString())||"0";e.tokensPriceMap[n]=parseFloat(s),e.networkTokenSymbol=(t==null?void 0:t.symbol)||"",e.networkPrice=s},async getMyTokensWithBalance(n){var s;const r=await o.BalanceUtil.getMyTokensWithBalance({forceUpdate:n,caipNetwork:o.ChainController.state.activeCaipNetwork,address:(s=o.ChainController.getAccountData())==null?void 0:s.address}),t=o.SwapApiUtil.mapBalancesToSwapTokens(r);t&&(await a.getInitialGasPrice(),a.setBalances(t))},setBalances(n){const{networkAddress:r}=a.getParams(),t=o.ChainController.state.activeCaipNetwork;if(!t)return;const s=n.find(l=>l.address===r);n.forEach(l=>{e.tokensPriceMap[l.address]=l.price||0}),e.myTokensWithBalance=n.filter(l=>l.address.startsWith(t.caipNetworkId)),e.networkBalanceInUSD=s?o.NumberUtil.multiply(s.quantity.numeric,s.price).toString():"0"},async getInitialGasPrice(){var r,t;const n=await o.SwapApiUtil.fetchGasPrice();if(!n)return{gasPrice:null,gasPriceInUSD:null};switch((t=(r=o.ChainController.state)==null?void 0:r.activeCaipNetwork)==null?void 0:t.chainNamespace){case o.ConstantsUtil.CHAIN.SOLANA:return e.gasFee=n.standard??"0",e.gasPriceInUSD=o.NumberUtil.multiply(n.standard,e.networkPrice).div(1e9).toNumber(),{gasPrice:BigInt(e.gasFee),gasPriceInUSD:Number(e.gasPriceInUSD)};case o.ConstantsUtil.CHAIN.EVM:default:const s=n.standard??"0",l=BigInt(s),i=BigInt(N),d=A.getGasPriceInUSD(e.networkPrice,i,l);return e.gasFee=s,e.gasPriceInUSD=d,{gasPrice:l,gasPriceInUSD:d}}},async swapTokens(){var i,d,k;const n=(i=o.ChainController.getAccountData())==null?void 0:i.address,r=e.sourceToken,t=e.toToken,s=o.NumberUtil.bigNumber(e.sourceTokenAmount).gt(0);if(s||a.setToTokenAmount(""),!t||!r||e.loadingPrices||!s||!n)return;e.loadingQuote=!0;const l=o.NumberUtil.bigNumber(e.sourceTokenAmount).times(10**r.decimals).round(0);try{const c=await o.BlockchainApiController.fetchSwapQuote({userAddress:n,from:r.address,to:t.address,gasPrice:e.gasFee,amount:l.toString()});e.loadingQuote=!1;const u=(k=(d=c==null?void 0:c.quotes)==null?void 0:d[0])==null?void 0:k.toAmount;if(!u){o.AlertController.open({displayMessage:"Incorrect amount",debugMessage:"Please enter a valid amount"},"error");return}const p=o.NumberUtil.bigNumber(u).div(10**t.decimals).toString();a.setToTokenAmount(p),a.hasInsufficientToken(e.sourceTokenAmount,r.address)?e.inputError="Insufficient balance":(e.inputError=void 0,a.setTransactionDetails())}catch(c){const u=await o.SwapApiUtil.handleSwapError(c);e.loadingQuote=!1,e.inputError=u||"Insufficient balance"}},async getTransaction(){const{fromCaipAddress:n,availableToSwap:r}=a.getParams(),t=e.sourceToken,s=e.toToken;if(!(!n||!r||!t||!s||e.loadingQuote))try{e.loadingBuildTransaction=!0;const l=await o.SwapApiUtil.fetchSwapAllowance({userAddress:n,tokenAddress:t.address,sourceTokenAmount:e.sourceTokenAmount,sourceTokenDecimals:t.decimals});let i;return l?i=await a.createSwapTransaction():i=await a.createAllowanceTransaction(),e.loadingBuildTransaction=!1,e.fetchError=!1,i}catch{o.RouterController.goBack(),o.SnackController.showError("Failed to check allowance"),e.loadingBuildTransaction=!1,e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}},async createAllowanceTransaction(){const{fromCaipAddress:n,sourceTokenAddress:r,toTokenAddress:t}=a.getParams();if(!(!n||!t)){if(!r)throw new Error("createAllowanceTransaction - No source token address found.");try{const s=await o.BlockchainApiController.generateApproveCalldata({from:r,to:t,userAddress:n}),l=o.CoreHelperUtil.getPlainAddress(s.tx.from);if(!l)throw new Error("SwapController:createAllowanceTransaction - address is required");const i={data:s.tx.data,to:l,gasPrice:BigInt(s.tx.eip155.gasPrice),value:BigInt(s.tx.value),toAmount:e.toTokenAmount};return e.swapTransaction=void 0,e.approvalTransaction={data:i.data,to:i.to,gasPrice:i.gasPrice,value:i.value,toAmount:i.toAmount},{data:i.data,to:i.to,gasPrice:i.gasPrice,value:i.value,toAmount:i.toAmount}}catch{o.RouterController.goBack(),o.SnackController.showError("Failed to create approval transaction"),e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}}},async createSwapTransaction(){var d;const{networkAddress:n,fromCaipAddress:r,sourceTokenAmount:t}=a.getParams(),s=e.sourceToken,l=e.toToken;if(!r||!t||!s||!l)return;const i=(d=o.ConnectionController.parseUnits(t,s.decimals))==null?void 0:d.toString();try{const k=await o.BlockchainApiController.generateSwapCalldata({userAddress:r,from:s.address,to:l.address,amount:i,disableEstimate:!0}),c=s.address===n,u=BigInt(k.tx.eip155.gas),p=BigInt(k.tx.eip155.gasPrice),g=o.CoreHelperUtil.getPlainAddress(k.tx.to);if(!g)throw new Error("SwapController:createSwapTransaction - address is required");const w={data:k.tx.data,to:g,gas:u,gasPrice:p,value:BigInt(c?i??"0":"0"),toAmount:e.toTokenAmount};return e.gasPriceInUSD=A.getGasPriceInUSD(e.networkPrice,u,p),e.approvalTransaction=void 0,e.swapTransaction=w,w}catch{o.RouterController.goBack(),o.SnackController.showError("Failed to create transaction"),e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}},onEmbeddedWalletApprovalSuccess(){o.SnackController.showLoading("Approve limit increase in your wallet"),o.RouterController.replace("SwapPreview")},async sendTransactionForApproval(n){var l,i,d;const{fromAddress:r,isAuthConnector:t}=a.getParams();e.loadingApprovalTransaction=!0,t?o.RouterController.pushTransactionStack({onSuccess:a.onEmbeddedWalletApprovalSuccess}):o.SnackController.showLoading("Approve limit increase in your wallet");try{await o.ConnectionController.sendTransaction({address:r,to:n.to,data:n.data,value:n.value,chainNamespace:o.ConstantsUtil.CHAIN.EVM}),await a.swapTokens(),await a.getTransaction(),e.approvalTransaction=void 0,e.loadingApprovalTransaction=!1}catch(k){const c=k;e.transactionError=c==null?void 0:c.displayMessage,e.loadingApprovalTransaction=!1,o.SnackController.showError((c==null?void 0:c.displayMessage)||"Transaction error"),o.EventsController.sendEvent({type:"track",event:"SWAP_APPROVAL_ERROR",properties:{message:(c==null?void 0:c.displayMessage)||(c==null?void 0:c.message)||"Unknown",network:((l=o.ChainController.state.activeCaipNetwork)==null?void 0:l.caipNetworkId)||"",swapFromToken:((i=a.state.sourceToken)==null?void 0:i.symbol)||"",swapToToken:((d=a.state.toToken)==null?void 0:d.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:o.getPreferredAccountType(o.ConstantsUtil.CHAIN.EVM)===o.W3mFrameRpcConstants.ACCOUNT_TYPES.SMART_ACCOUNT}})}},async sendTransactionForSwap(n){var d,k,c,u,p,g,w,f,S,C,P,b;if(!n)return;const{fromAddress:r,toTokenAmount:t,isAuthConnector:s}=a.getParams();e.loadingTransaction=!0;const l=`Swapping ${(d=e.sourceToken)==null?void 0:d.symbol} to ${o.NumberUtil.formatNumberToLocalString(t,3)} ${(k=e.toToken)==null?void 0:k.symbol}`,i=`Swapped ${(c=e.sourceToken)==null?void 0:c.symbol} to ${o.NumberUtil.formatNumberToLocalString(t,3)} ${(u=e.toToken)==null?void 0:u.symbol}`;s?o.RouterController.pushTransactionStack({onSuccess(){o.RouterController.replace("Account"),o.SnackController.showLoading(l),h.resetState()}}):o.SnackController.showLoading("Confirm transaction in your wallet");try{const I=[(p=e.sourceToken)==null?void 0:p.address,(g=e.toToken)==null?void 0:g.address].join(","),m=await o.ConnectionController.sendTransaction({address:r,to:n.to,data:n.data,value:n.value,chainNamespace:o.ConstantsUtil.CHAIN.EVM});return e.loadingTransaction=!1,o.SnackController.showSuccess(i),o.EventsController.sendEvent({type:"track",event:"SWAP_SUCCESS",properties:{network:((w=o.ChainController.state.activeCaipNetwork)==null?void 0:w.caipNetworkId)||"",swapFromToken:((f=a.state.sourceToken)==null?void 0:f.symbol)||"",swapToToken:((S=a.state.toToken)==null?void 0:S.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:o.getPreferredAccountType(o.ConstantsUtil.CHAIN.EVM)===o.W3mFrameRpcConstants.ACCOUNT_TYPES.SMART_ACCOUNT}}),h.resetState(),s||o.RouterController.replace("Account"),h.getMyTokensWithBalance(I),m}catch(I){const m=I;e.transactionError=m==null?void 0:m.displayMessage,e.loadingTransaction=!1,o.SnackController.showError((m==null?void 0:m.displayMessage)||"Transaction error"),o.EventsController.sendEvent({type:"track",event:"SWAP_ERROR",properties:{message:(m==null?void 0:m.displayMessage)||(m==null?void 0:m.message)||"Unknown",network:((C=o.ChainController.state.activeCaipNetwork)==null?void 0:C.caipNetworkId)||"",swapFromToken:((P=a.state.sourceToken)==null?void 0:P.symbol)||"",swapToToken:((b=a.state.toToken)==null?void 0:b.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:o.getPreferredAccountType(o.ConstantsUtil.CHAIN.EVM)===o.W3mFrameRpcConstants.ACCOUNT_TYPES.SMART_ACCOUNT}});return}},hasInsufficientToken(n,r){return A.isInsufficientSourceTokenForSwap(n,r,e.myTokensWithBalance)},setTransactionDetails(){const{toTokenAddress:n,toTokenDecimals:r}=a.getParams();!n||!r||(e.gasPriceInUSD=A.getGasPriceInUSD(e.networkPrice,BigInt(e.gasFee),BigInt(N)),e.priceImpact=A.getPriceImpact({sourceTokenAmount:e.sourceTokenAmount,sourceTokenPriceInUSD:e.sourceTokenPriceInUSD,toTokenPriceInUSD:e.toTokenPriceInUSD,toTokenAmount:e.toTokenAmount}),e.maxSlippage=A.getMaxSlippage(e.slippage,e.toTokenAmount),e.providerFee=A.getProviderFee(e.sourceTokenAmount))}},a=o.withErrorBoundary(h);exports.SwapController=a;
1
+ "use strict";const o=require("./index-BhaYgUya.js"),A={getGasPriceInEther(n,r){const t=r*n;return Number(t)/1e18},getGasPriceInUSD(n,r,t){const s=A.getGasPriceInEther(r,t);return o.NumberUtil.bigNumber(n).times(s).toNumber()},getPriceImpact({sourceTokenAmount:n,sourceTokenPriceInUSD:r,toTokenPriceInUSD:t,toTokenAmount:s}){const l=o.NumberUtil.bigNumber(n).times(r),i=o.NumberUtil.bigNumber(s).times(t);return l.minus(i).div(l).times(100).toNumber()},getMaxSlippage(n,r){const t=o.NumberUtil.bigNumber(n).div(100);return o.NumberUtil.multiply(r,t).toNumber()},getProviderFee(n,r=.0085){return o.NumberUtil.bigNumber(n).times(r).toString()},isInsufficientNetworkTokenForGas(n,r){const t=r||"0";return o.NumberUtil.bigNumber(n).eq(0)?!0:o.NumberUtil.bigNumber(o.NumberUtil.bigNumber(t)).gt(n)},isInsufficientSourceTokenForSwap(n,r,t){var i,d;const s=(d=(i=t==null?void 0:t.find(k=>k.address===r))==null?void 0:i.quantity)==null?void 0:d.numeric;return o.NumberUtil.bigNumber(s||"0").lt(n)}},N=15e4,y=6,T={initializing:!1,initialized:!1,loadingPrices:!1,loadingQuote:!1,loadingApprovalTransaction:!1,loadingBuildTransaction:!1,loadingTransaction:!1,switchingTokens:!1,fetchError:!1,approvalTransaction:void 0,swapTransaction:void 0,transactionError:void 0,sourceToken:void 0,sourceTokenAmount:"",sourceTokenPriceInUSD:0,toToken:void 0,toTokenAmount:"",toTokenPriceInUSD:0,networkPrice:"0",networkBalanceInUSD:"0",networkTokenSymbol:"",inputError:void 0,slippage:o.ConstantsUtil$1.CONVERT_SLIPPAGE_TOLERANCE,tokens:void 0,popularTokens:void 0,suggestedTokens:void 0,foundTokens:void 0,myTokensWithBalance:void 0,tokensPriceMap:{},gasFee:"0",gasPriceInUSD:0,priceImpact:void 0,maxSlippage:void 0,providerFee:void 0},e=o.proxy({...T}),h={state:e,subscribe(n){return o.subscribe(e,()=>n(e))},subscribeKey(n,r){return o.subscribeKey(e,n,r)},getParams(){var c,u,p,g,w,f,S,C,P;const n=o.ChainController.state.activeChain,r=((c=o.ChainController.getAccountData(n))==null?void 0:c.caipAddress)??o.ChainController.state.activeCaipAddress,t=o.CoreHelperUtil.getPlainAddress(r),s=o.getActiveNetworkTokenAddress(),l=o.ConnectorController.getConnectorId(o.ChainController.state.activeChain);if(!t)throw new Error("No address found to swap the tokens from.");const i=!((u=e.toToken)!=null&&u.address)||!((p=e.toToken)!=null&&p.decimals),d=!((g=e.sourceToken)!=null&&g.address)||!((w=e.sourceToken)!=null&&w.decimals)||!o.NumberUtil.bigNumber(e.sourceTokenAmount).gt(0),k=!e.sourceTokenAmount;return{networkAddress:s,fromAddress:t,fromCaipAddress:r,sourceTokenAddress:(f=e.sourceToken)==null?void 0:f.address,toTokenAddress:(S=e.toToken)==null?void 0:S.address,toTokenAmount:e.toTokenAmount,toTokenDecimals:(C=e.toToken)==null?void 0:C.decimals,sourceTokenAmount:e.sourceTokenAmount,sourceTokenDecimals:(P=e.sourceToken)==null?void 0:P.decimals,invalidToToken:i,invalidSourceToken:d,invalidSourceTokenAmount:k,availableToSwap:r&&!i&&!d&&!k,isAuthConnector:l===o.ConstantsUtil.CONNECTOR_ID.AUTH}},async setSourceToken(n){if(!n){e.sourceToken=n,e.sourceTokenAmount="",e.sourceTokenPriceInUSD=0;return}e.sourceToken=n,await a.setTokenPrice(n.address,"sourceToken")},setSourceTokenAmount(n){e.sourceTokenAmount=n},async setToToken(n){if(!n){e.toToken=n,e.toTokenAmount="",e.toTokenPriceInUSD=0;return}e.toToken=n,await a.setTokenPrice(n.address,"toToken")},setToTokenAmount(n){e.toTokenAmount=n?o.NumberUtil.toFixed(n,y):""},async setTokenPrice(n,r){let t=e.tokensPriceMap[n]||0;t||(e.loadingPrices=!0,t=await a.getAddressPrice(n)),r==="sourceToken"?e.sourceTokenPriceInUSD=t:r==="toToken"&&(e.toTokenPriceInUSD=t),e.loadingPrices&&(e.loadingPrices=!1),a.getParams().availableToSwap&&!e.switchingTokens&&a.swapTokens()},async switchTokens(){if(!(e.initializing||!e.initialized||e.switchingTokens)){e.switchingTokens=!0;try{const n=e.toToken?{...e.toToken}:void 0,r=e.sourceToken?{...e.sourceToken}:void 0,t=n&&e.toTokenAmount===""?"1":e.toTokenAmount;a.setSourceTokenAmount(t),a.setToTokenAmount(""),await a.setSourceToken(n),await a.setToToken(r),e.switchingTokens=!1,a.swapTokens()}catch(n){throw e.switchingTokens=!1,n}}},resetState(){e.myTokensWithBalance=T.myTokensWithBalance,e.tokensPriceMap=T.tokensPriceMap,e.initialized=T.initialized,e.initializing=T.initializing,e.switchingTokens=T.switchingTokens,e.sourceToken=T.sourceToken,e.sourceTokenAmount=T.sourceTokenAmount,e.sourceTokenPriceInUSD=T.sourceTokenPriceInUSD,e.toToken=T.toToken,e.toTokenAmount=T.toTokenAmount,e.toTokenPriceInUSD=T.toTokenPriceInUSD,e.networkPrice=T.networkPrice,e.networkTokenSymbol=T.networkTokenSymbol,e.networkBalanceInUSD=T.networkBalanceInUSD,e.inputError=T.inputError},resetValues(){var t;const{networkAddress:n}=a.getParams(),r=(t=e.tokens)==null?void 0:t.find(s=>s.address===n);a.setSourceToken(r),a.setToToken(void 0)},getApprovalLoadingState(){return e.loadingApprovalTransaction},clearError(){e.transactionError=void 0},async initializeState(){if(!e.initializing){if(e.initializing=!0,!e.initialized)try{await a.fetchTokens(),e.initialized=!0}catch{e.initialized=!1,o.SnackController.showError("Failed to initialize swap"),o.RouterController.goBack()}e.initializing=!1}},async fetchTokens(){var t;const{networkAddress:n}=a.getParams();await a.getNetworkTokenPrice(),await a.getMyTokensWithBalance();const r=(t=e.myTokensWithBalance)==null?void 0:t.find(s=>s.address===n);r&&(e.networkTokenSymbol=r.symbol,a.setSourceToken(r),a.setSourceTokenAmount("0"))},async getTokenList(){var r,t;const n=(r=o.ChainController.state.activeCaipNetwork)==null?void 0:r.caipNetworkId;if(!(e.caipNetworkId===n&&e.tokens))try{e.tokensLoading=!0;const s=await o.SwapApiUtil.getTokenList(n);e.tokens=s,e.caipNetworkId=n,e.popularTokens=s.sort((c,u)=>c.symbol<u.symbol?-1:c.symbol>u.symbol?1:0);const i=(n&&((t=o.ConstantsUtil$1.SUGGESTED_TOKENS_BY_CHAIN)==null?void 0:t[n])||[]).map(c=>s.find(u=>u.symbol===c)).filter(c=>!!c),k=(o.ConstantsUtil$1.SWAP_SUGGESTED_TOKENS||[]).map(c=>s.find(u=>u.symbol===c)).filter(c=>!!c).filter(c=>!i.some(u=>u.address===c.address));e.suggestedTokens=[...i,...k]}catch{e.tokens=[],e.popularTokens=[],e.suggestedTokens=[]}finally{e.tokensLoading=!1}},async getAddressPrice(n){var c,u;const r=e.tokensPriceMap[n];if(r)return r;const t=await o.BlockchainApiController.fetchTokenPrice({addresses:[n]}),s=(t==null?void 0:t.fungibles)||[],l=[...e.tokens||[],...e.myTokensWithBalance||[]],i=(c=l==null?void 0:l.find(p=>p.address===n))==null?void 0:c.symbol,d=((u=s.find(p=>p.symbol.toLowerCase()===(i==null?void 0:i.toLowerCase())))==null?void 0:u.price)||0,k=parseFloat(d.toString());return e.tokensPriceMap[n]=k,k},async getNetworkTokenPrice(){var l;const{networkAddress:n}=a.getParams(),t=(l=(await o.BlockchainApiController.fetchTokenPrice({addresses:[n]}).catch(()=>(o.SnackController.showError("Failed to fetch network token price"),{fungibles:[]}))).fungibles)==null?void 0:l[0],s=(t==null?void 0:t.price.toString())||"0";e.tokensPriceMap[n]=parseFloat(s),e.networkTokenSymbol=(t==null?void 0:t.symbol)||"",e.networkPrice=s},async getMyTokensWithBalance(n){var s;const r=await o.BalanceUtil.getMyTokensWithBalance({forceUpdate:n,caipNetwork:o.ChainController.state.activeCaipNetwork,address:(s=o.ChainController.getAccountData())==null?void 0:s.address}),t=o.SwapApiUtil.mapBalancesToSwapTokens(r);t&&(await a.getInitialGasPrice(),a.setBalances(t))},setBalances(n){const{networkAddress:r}=a.getParams(),t=o.ChainController.state.activeCaipNetwork;if(!t)return;const s=n.find(l=>l.address===r);n.forEach(l=>{e.tokensPriceMap[l.address]=l.price||0}),e.myTokensWithBalance=n.filter(l=>l.address.startsWith(t.caipNetworkId)),e.networkBalanceInUSD=s?o.NumberUtil.multiply(s.quantity.numeric,s.price).toString():"0"},async getInitialGasPrice(){var r,t;const n=await o.SwapApiUtil.fetchGasPrice();if(!n)return{gasPrice:null,gasPriceInUSD:null};switch((t=(r=o.ChainController.state)==null?void 0:r.activeCaipNetwork)==null?void 0:t.chainNamespace){case o.ConstantsUtil.CHAIN.SOLANA:return e.gasFee=n.standard??"0",e.gasPriceInUSD=o.NumberUtil.multiply(n.standard,e.networkPrice).div(1e9).toNumber(),{gasPrice:BigInt(e.gasFee),gasPriceInUSD:Number(e.gasPriceInUSD)};case o.ConstantsUtil.CHAIN.EVM:default:const s=n.standard??"0",l=BigInt(s),i=BigInt(N),d=A.getGasPriceInUSD(e.networkPrice,i,l);return e.gasFee=s,e.gasPriceInUSD=d,{gasPrice:l,gasPriceInUSD:d}}},async swapTokens(){var i,d,k;const n=(i=o.ChainController.getAccountData())==null?void 0:i.address,r=e.sourceToken,t=e.toToken,s=o.NumberUtil.bigNumber(e.sourceTokenAmount).gt(0);if(s||a.setToTokenAmount(""),!t||!r||e.loadingPrices||!s||!n)return;e.loadingQuote=!0;const l=o.NumberUtil.bigNumber(e.sourceTokenAmount).times(10**r.decimals).round(0);try{const c=await o.BlockchainApiController.fetchSwapQuote({userAddress:n,from:r.address,to:t.address,gasPrice:e.gasFee,amount:l.toString()});e.loadingQuote=!1;const u=(k=(d=c==null?void 0:c.quotes)==null?void 0:d[0])==null?void 0:k.toAmount;if(!u){o.AlertController.open({displayMessage:"Incorrect amount",debugMessage:"Please enter a valid amount"},"error");return}const p=o.NumberUtil.bigNumber(u).div(10**t.decimals).toString();a.setToTokenAmount(p),a.hasInsufficientToken(e.sourceTokenAmount,r.address)?e.inputError="Insufficient balance":(e.inputError=void 0,a.setTransactionDetails())}catch(c){const u=await o.SwapApiUtil.handleSwapError(c);e.loadingQuote=!1,e.inputError=u||"Insufficient balance"}},async getTransaction(){const{fromCaipAddress:n,availableToSwap:r}=a.getParams(),t=e.sourceToken,s=e.toToken;if(!(!n||!r||!t||!s||e.loadingQuote))try{e.loadingBuildTransaction=!0;const l=await o.SwapApiUtil.fetchSwapAllowance({userAddress:n,tokenAddress:t.address,sourceTokenAmount:e.sourceTokenAmount,sourceTokenDecimals:t.decimals});let i;return l?i=await a.createSwapTransaction():i=await a.createAllowanceTransaction(),e.loadingBuildTransaction=!1,e.fetchError=!1,i}catch{o.RouterController.goBack(),o.SnackController.showError("Failed to check allowance"),e.loadingBuildTransaction=!1,e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}},async createAllowanceTransaction(){const{fromCaipAddress:n,sourceTokenAddress:r,toTokenAddress:t}=a.getParams();if(!(!n||!t)){if(!r)throw new Error("createAllowanceTransaction - No source token address found.");try{const s=await o.BlockchainApiController.generateApproveCalldata({from:r,to:t,userAddress:n}),l=o.CoreHelperUtil.getPlainAddress(s.tx.from);if(!l)throw new Error("SwapController:createAllowanceTransaction - address is required");const i={data:s.tx.data,to:l,gasPrice:BigInt(s.tx.eip155.gasPrice),value:BigInt(s.tx.value),toAmount:e.toTokenAmount};return e.swapTransaction=void 0,e.approvalTransaction={data:i.data,to:i.to,gasPrice:i.gasPrice,value:i.value,toAmount:i.toAmount},{data:i.data,to:i.to,gasPrice:i.gasPrice,value:i.value,toAmount:i.toAmount}}catch{o.RouterController.goBack(),o.SnackController.showError("Failed to create approval transaction"),e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}}},async createSwapTransaction(){var d;const{networkAddress:n,fromCaipAddress:r,sourceTokenAmount:t}=a.getParams(),s=e.sourceToken,l=e.toToken;if(!r||!t||!s||!l)return;const i=(d=o.ConnectionController.parseUnits(t,s.decimals))==null?void 0:d.toString();try{const k=await o.BlockchainApiController.generateSwapCalldata({userAddress:r,from:s.address,to:l.address,amount:i,disableEstimate:!0}),c=s.address===n,u=BigInt(k.tx.eip155.gas),p=BigInt(k.tx.eip155.gasPrice),g=o.CoreHelperUtil.getPlainAddress(k.tx.to);if(!g)throw new Error("SwapController:createSwapTransaction - address is required");const w={data:k.tx.data,to:g,gas:u,gasPrice:p,value:BigInt(c?i??"0":"0"),toAmount:e.toTokenAmount};return e.gasPriceInUSD=A.getGasPriceInUSD(e.networkPrice,u,p),e.approvalTransaction=void 0,e.swapTransaction=w,w}catch{o.RouterController.goBack(),o.SnackController.showError("Failed to create transaction"),e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}},onEmbeddedWalletApprovalSuccess(){o.SnackController.showLoading("Approve limit increase in your wallet"),o.RouterController.replace("SwapPreview")},async sendTransactionForApproval(n){var l,i,d;const{fromAddress:r,isAuthConnector:t}=a.getParams();e.loadingApprovalTransaction=!0,t?o.RouterController.pushTransactionStack({onSuccess:a.onEmbeddedWalletApprovalSuccess}):o.SnackController.showLoading("Approve limit increase in your wallet");try{await o.ConnectionController.sendTransaction({address:r,to:n.to,data:n.data,value:n.value,chainNamespace:o.ConstantsUtil.CHAIN.EVM}),await a.swapTokens(),await a.getTransaction(),e.approvalTransaction=void 0,e.loadingApprovalTransaction=!1}catch(k){const c=k;e.transactionError=c==null?void 0:c.displayMessage,e.loadingApprovalTransaction=!1,o.SnackController.showError((c==null?void 0:c.displayMessage)||"Transaction error"),o.EventsController.sendEvent({type:"track",event:"SWAP_APPROVAL_ERROR",properties:{message:(c==null?void 0:c.displayMessage)||(c==null?void 0:c.message)||"Unknown",network:((l=o.ChainController.state.activeCaipNetwork)==null?void 0:l.caipNetworkId)||"",swapFromToken:((i=a.state.sourceToken)==null?void 0:i.symbol)||"",swapToToken:((d=a.state.toToken)==null?void 0:d.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:o.getPreferredAccountType(o.ConstantsUtil.CHAIN.EVM)===o.W3mFrameRpcConstants.ACCOUNT_TYPES.SMART_ACCOUNT}})}},async sendTransactionForSwap(n){var d,k,c,u,p,g,w,f,S,C,P,b;if(!n)return;const{fromAddress:r,toTokenAmount:t,isAuthConnector:s}=a.getParams();e.loadingTransaction=!0;const l=`Swapping ${(d=e.sourceToken)==null?void 0:d.symbol} to ${o.NumberUtil.formatNumberToLocalString(t,3)} ${(k=e.toToken)==null?void 0:k.symbol}`,i=`Swapped ${(c=e.sourceToken)==null?void 0:c.symbol} to ${o.NumberUtil.formatNumberToLocalString(t,3)} ${(u=e.toToken)==null?void 0:u.symbol}`;s?o.RouterController.pushTransactionStack({onSuccess(){o.RouterController.replace("Account"),o.SnackController.showLoading(l),h.resetState()}}):o.SnackController.showLoading("Confirm transaction in your wallet");try{const I=[(p=e.sourceToken)==null?void 0:p.address,(g=e.toToken)==null?void 0:g.address].join(","),m=await o.ConnectionController.sendTransaction({address:r,to:n.to,data:n.data,value:n.value,chainNamespace:o.ConstantsUtil.CHAIN.EVM});return e.loadingTransaction=!1,o.SnackController.showSuccess(i),o.EventsController.sendEvent({type:"track",event:"SWAP_SUCCESS",properties:{network:((w=o.ChainController.state.activeCaipNetwork)==null?void 0:w.caipNetworkId)||"",swapFromToken:((f=a.state.sourceToken)==null?void 0:f.symbol)||"",swapToToken:((S=a.state.toToken)==null?void 0:S.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:o.getPreferredAccountType(o.ConstantsUtil.CHAIN.EVM)===o.W3mFrameRpcConstants.ACCOUNT_TYPES.SMART_ACCOUNT}}),h.resetState(),s||o.RouterController.replace("Account"),h.getMyTokensWithBalance(I),m}catch(I){const m=I;e.transactionError=m==null?void 0:m.displayMessage,e.loadingTransaction=!1,o.SnackController.showError((m==null?void 0:m.displayMessage)||"Transaction error"),o.EventsController.sendEvent({type:"track",event:"SWAP_ERROR",properties:{message:(m==null?void 0:m.displayMessage)||(m==null?void 0:m.message)||"Unknown",network:((C=o.ChainController.state.activeCaipNetwork)==null?void 0:C.caipNetworkId)||"",swapFromToken:((P=a.state.sourceToken)==null?void 0:P.symbol)||"",swapToToken:((b=a.state.toToken)==null?void 0:b.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:o.getPreferredAccountType(o.ConstantsUtil.CHAIN.EVM)===o.W3mFrameRpcConstants.ACCOUNT_TYPES.SMART_ACCOUNT}});return}},hasInsufficientToken(n,r){return A.isInsufficientSourceTokenForSwap(n,r,e.myTokensWithBalance)},setTransactionDetails(){const{toTokenAddress:n,toTokenDecimals:r}=a.getParams();!n||!r||(e.gasPriceInUSD=A.getGasPriceInUSD(e.networkPrice,BigInt(e.gasFee),BigInt(N)),e.priceImpact=A.getPriceImpact({sourceTokenAmount:e.sourceTokenAmount,sourceTokenPriceInUSD:e.sourceTokenPriceInUSD,toTokenPriceInUSD:e.toTokenPriceInUSD,toTokenAmount:e.toTokenAmount}),e.maxSlippage=A.getMaxSlippage(e.slippage,e.toTokenAmount),e.providerFee=A.getProviderFee(e.sourceTokenAmount))}},a=o.withErrorBoundary(h);exports.SwapController=a;
@@ -1,5 +1,5 @@
1
- import { a1 as g, ab as k, aR as L, aS as O, aT as E } from "./parseSignature-ZB66mPGB.mjs";
2
- import { ad as p, cs as y, bN as w, bb as R, b3 as x, aw as m, be as M } from "./index-BHukHFIh.mjs";
1
+ import { a1 as g, ab as k, aS as L, aT as O, aU as E } from "./parseSignature-zKnspnY-.mjs";
2
+ import { ad as p, cr as y, bM as w, ba as x, b3 as R, aw as m, bd as M } from "./index-CFLg0HEy.mjs";
3
3
  class S extends p {
4
4
  constructor({ callbackSelector: r, cause: a, data: n, extraData: i, sender: f, urls: t }) {
5
5
  var o;
@@ -70,7 +70,7 @@ const D = "0x556f1830", T = {
70
70
  }
71
71
  ]
72
72
  };
73
- async function P(c, { blockNumber: r, blockTag: a, data: n, to: i }) {
73
+ async function U(c, { blockNumber: r, blockTag: a, data: n, to: i }) {
74
74
  const { args: f } = g({
75
75
  data: n,
76
76
  abi: [T]
@@ -84,9 +84,9 @@ async function P(c, { blockNumber: r, blockTag: a, data: n, to: i }) {
84
84
  }) : await h({ data: d, sender: t, urls: o }), { data: b } = await E(c, {
85
85
  blockNumber: r,
86
86
  blockTag: a,
87
- data: R([
87
+ data: x([
88
88
  l,
89
- x([{ type: "bytes" }, { type: "bytes" }], [u, s])
89
+ R([{ type: "bytes" }, { type: "bytes" }], [u, s])
90
90
  ]),
91
91
  to: i
92
92
  });
@@ -144,7 +144,7 @@ async function C({ data: c, sender: r, urls: a }) {
144
144
  }
145
145
  export {
146
146
  C as ccipRequest,
147
- P as offchainLookup,
147
+ U as offchainLookup,
148
148
  T as offchainLookupAbiItem,
149
149
  D as offchainLookupSignature
150
150
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./parseSignature-CWAxHYP1.js"),s=require("./index-BNobBA-8.js");class k extends s.BaseError{constructor({callbackSelector:o,cause:t,data:c,extraData:u,sender:d,urls:a}){var n;super(t.shortMessage||"An error occurred while fetching for an offchain result.",{cause:t,metaMessages:[...t.metaMessages||[],(n=t.metaMessages)!=null&&n.length?"":[],"Offchain Gateway Call:",a&&[" Gateway URL(s):",...a.map(f=>` ${s.getUrl(f)}`)],` Sender: ${d}`,` Data: ${c}`,` Callback selector: ${o}`,` Extra data: ${u}`].flat(),name:"OffchainLookupError"})}}class b extends s.BaseError{constructor({result:o,url:t}){super("Offchain gateway response is malformed. Response data must be a hex value.",{metaMessages:[`Gateway URL: ${s.getUrl(t)}`,`Response: ${s.stringify(o)}`],name:"OffchainLookupResponseMalformedError"})}}class L extends s.BaseError{constructor({sender:o,to:t}){super("Reverted sender address does not match target contract address (`to`).",{metaMessages:[`Contract address: ${t}`,`OffchainLookup sender address: ${o}`],name:"OffchainLookupSenderMismatchError"})}}const E="0x556f1830",m={name:"OffchainLookup",type:"error",inputs:[{name:"sender",type:"address"},{name:"urls",type:"string[]"},{name:"callData",type:"bytes"},{name:"callbackFunction",type:"bytes4"},{name:"extraData",type:"bytes"}]};async function O(i,{blockNumber:o,blockTag:t,data:c,to:u}){const{args:d}=l.decodeErrorResult({data:c,abi:[m]}),[a,n,f,p,r]=d,{ccipRead:e}=i,y=e&&typeof(e==null?void 0:e.request)=="function"?e.request:g;try{if(!l.isAddressEqual(u,a))throw new L({sender:a,to:u});const h=n.includes(l.localBatchGatewayUrl)?await l.localBatchGatewayRequest({data:f,ccipRequest:y}):await y({data:f,sender:a,urls:n}),{data:w}=await l.call(i,{blockNumber:o,blockTag:t,data:s.concat([p,s.encodeAbiParameters([{type:"bytes"},{type:"bytes"}],[h,r])]),to:u});return w}catch(h){throw new k({callbackSelector:p,cause:h,data:c,extraData:r,sender:a,urls:n})}}async function g({data:i,sender:o,urls:t}){var u;let c=new Error("An unknown error occurred.");for(let d=0;d<t.length;d++){const a=t[d],n=a.includes("{data}")?"GET":"POST",f=n==="POST"?{data:i,sender:o}:void 0,p=n==="POST"?{"Content-Type":"application/json"}:{};try{const r=await fetch(a.replace("{sender}",o.toLowerCase()).replace("{data}",i),{body:JSON.stringify(f),headers:p,method:n});let e;if((u=r.headers.get("Content-Type"))!=null&&u.startsWith("application/json")?e=(await r.json()).data:e=await r.text(),!r.ok){c=new s.HttpRequestError({body:f,details:e!=null&&e.error?s.stringify(e.error):r.statusText,headers:r.headers,status:r.status,url:a});continue}if(!s.isHex(e)){c=new b({result:e,url:a});continue}return e}catch(r){c=new s.HttpRequestError({body:f,details:r.message,url:a})}}throw c}exports.ccipRequest=g;exports.offchainLookup=O;exports.offchainLookupAbiItem=m;exports.offchainLookupSignature=E;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./parseSignature-jZAFls5F.js"),s=require("./index-BhaYgUya.js");class k extends s.BaseError{constructor({callbackSelector:o,cause:t,data:c,extraData:u,sender:d,urls:a}){var n;super(t.shortMessage||"An error occurred while fetching for an offchain result.",{cause:t,metaMessages:[...t.metaMessages||[],(n=t.metaMessages)!=null&&n.length?"":[],"Offchain Gateway Call:",a&&[" Gateway URL(s):",...a.map(f=>` ${s.getUrl(f)}`)],` Sender: ${d}`,` Data: ${c}`,` Callback selector: ${o}`,` Extra data: ${u}`].flat(),name:"OffchainLookupError"})}}class b extends s.BaseError{constructor({result:o,url:t}){super("Offchain gateway response is malformed. Response data must be a hex value.",{metaMessages:[`Gateway URL: ${s.getUrl(t)}`,`Response: ${s.stringify(o)}`],name:"OffchainLookupResponseMalformedError"})}}class L extends s.BaseError{constructor({sender:o,to:t}){super("Reverted sender address does not match target contract address (`to`).",{metaMessages:[`Contract address: ${t}`,`OffchainLookup sender address: ${o}`],name:"OffchainLookupSenderMismatchError"})}}const E="0x556f1830",m={name:"OffchainLookup",type:"error",inputs:[{name:"sender",type:"address"},{name:"urls",type:"string[]"},{name:"callData",type:"bytes"},{name:"callbackFunction",type:"bytes4"},{name:"extraData",type:"bytes"}]};async function O(i,{blockNumber:o,blockTag:t,data:c,to:u}){const{args:d}=l.decodeErrorResult({data:c,abi:[m]}),[a,n,f,p,r]=d,{ccipRead:e}=i,y=e&&typeof(e==null?void 0:e.request)=="function"?e.request:g;try{if(!l.isAddressEqual(u,a))throw new L({sender:a,to:u});const h=n.includes(l.localBatchGatewayUrl)?await l.localBatchGatewayRequest({data:f,ccipRequest:y}):await y({data:f,sender:a,urls:n}),{data:w}=await l.call(i,{blockNumber:o,blockTag:t,data:s.concat([p,s.encodeAbiParameters([{type:"bytes"},{type:"bytes"}],[h,r])]),to:u});return w}catch(h){throw new k({callbackSelector:p,cause:h,data:c,extraData:r,sender:a,urls:n})}}async function g({data:i,sender:o,urls:t}){var u;let c=new Error("An unknown error occurred.");for(let d=0;d<t.length;d++){const a=t[d],n=a.includes("{data}")?"GET":"POST",f=n==="POST"?{data:i,sender:o}:void 0,p=n==="POST"?{"Content-Type":"application/json"}:{};try{const r=await fetch(a.replace("{sender}",o.toLowerCase()).replace("{data}",i),{body:JSON.stringify(f),headers:p,method:n});let e;if((u=r.headers.get("Content-Type"))!=null&&u.startsWith("application/json")?e=(await r.json()).data:e=await r.text(),!r.ok){c=new s.HttpRequestError({body:f,details:e!=null&&e.error?s.stringify(e.error):r.statusText,headers:r.headers,status:r.status,url:a});continue}if(!s.isHex(e)){c=new b({result:e,url:a});continue}return e}catch(r){c=new s.HttpRequestError({body:f,details:r.message,url:a})}}throw c}exports.ccipRequest=g;exports.offchainLookup=O;exports.offchainLookupAbiItem=m;exports.offchainLookupSignature=E;
@@ -1,6 +1,6 @@
1
- import { c1 as y, bX as $, bY as l, bV as S, bW as x, cz as m, c5 as p, cc as f, c6 as h, cw as u, c0 as _, cq as E, co as R } from "./index-BHukHFIh.mjs";
2
- import { W as C } from "./index-B--AiWBy.mjs";
3
- import { R as v } from "./ReownAuthentication-ZWJVb5u8.mjs";
1
+ import { c0 as y, bW as $, bX as l, bU as S, bV as x, cy as m, c4 as p, cb as f, c5 as h, cv as u, b$ as _, cp as E, cn as R } from "./index-CFLg0HEy.mjs";
2
+ import { W as C } from "./index-2WfSPp5U.mjs";
3
+ import { R as v } from "./ReownAuthentication-7iIT4jS4.mjs";
4
4
  const D = y`
5
5
  .email-sufixes {
6
6
  display: flex;
@@ -168,7 +168,7 @@ A([
168
168
  b = A([
169
169
  x("w3m-data-capture-otp-confirm-view")
170
170
  ], b);
171
- const q = y`
171
+ const P = y`
172
172
  .hero {
173
173
  display: flex;
174
174
  flex-direction: column;
@@ -456,7 +456,7 @@ let c = class extends $ {
456
456
  return /^\S+@\S+\.\S+$/u.test(t);
457
457
  }
458
458
  };
459
- c.styles = [q];
459
+ c.styles = [P];
460
460
  d([
461
461
  u()
462
462
  ], c.prototype, "email", void 0);
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-BNobBA-8.js"),d=require("./index-xYJPqvul.js"),u=require("./ReownAuthentication-_EMKUe4O.js"),g=e.i$1`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-BhaYgUya.js"),d=require("./index-CZuajWCC.js"),u=require("./ReownAuthentication-BEGlJitZ.js"),g=e.i$1`
2
2
  .email-sufixes {
3
3
  display: flex;
4
4
  flex-direction: row;
@@ -1,6 +1,6 @@
1
- import { cc as S, c7 as g, cz as p, c9 as c, cA as _, c5 as s, c6 as f, ce as b, bW as u, bS as D, bX as C, ck as d, bY as m, cw as E, c1 as $, bZ as W, b$ as P, cB as N, c8 as T } from "./index-BHukHFIh.mjs";
2
- import { W as y } from "./index-B--AiWBy.mjs";
3
- var F = function(a, e, t, r) {
1
+ import { cb as S, c6 as g, cy as p, c8 as c, cz as _, c4 as s, c5 as f, cd as b, bV as u, bR as D, bW as C, cj as d, bX as m, cv as E, c0 as W, bY as $, b_ as P, cA as N, c7 as T } from "./index-CFLg0HEy.mjs";
2
+ import { W as y } from "./index-2WfSPp5U.mjs";
3
+ var j = function(a, e, t, r) {
4
4
  var n = arguments.length, i = n < 3 ? e : r === null ? r = Object.getOwnPropertyDescriptor(e, t) : r, o;
5
5
  if (typeof Reflect == "object" && typeof Reflect.decorate == "function") i = Reflect.decorate(a, e, t, r);
6
6
  else for (var l = a.length - 1; l >= 0; l--) (o = a[l]) && (i = (n < 3 ? o(i) : n > 3 ? o(e, t, i) : o(e, t)) || i);
@@ -41,10 +41,10 @@ let I = class extends y {
41
41
  };
42
42
  }
43
43
  };
44
- I = F([
44
+ I = j([
45
45
  u("w3m-email-verify-otp-view")
46
46
  ], I);
47
- const U = D`
47
+ const F = D`
48
48
  wui-icon-box {
49
49
  height: ${({ spacing: a }) => a[16]};
50
50
  width: ${({ spacing: a }) => a[16]};
@@ -121,14 +121,14 @@ let w = class extends C {
121
121
  }
122
122
  }
123
123
  };
124
- w.styles = U;
124
+ w.styles = F;
125
125
  x([
126
126
  E()
127
127
  ], w.prototype, "loading", void 0);
128
128
  w = x([
129
129
  u("w3m-email-verify-device-view")
130
130
  ], w);
131
- const j = $`
131
+ const U = W`
132
132
  wui-email-input {
133
133
  width: 100%;
134
134
  }
@@ -148,7 +148,7 @@ var O = function(a, e, t, r) {
148
148
  let h = class extends C {
149
149
  constructor() {
150
150
  var e, t;
151
- super(...arguments), this.formRef = W(), this.initialEmail = ((e = s.state.data) == null ? void 0 : e.email) ?? "", this.redirectView = (t = s.state.data) == null ? void 0 : t.redirectView, this.email = "", this.loading = !1;
151
+ super(...arguments), this.formRef = $(), this.initialEmail = ((e = s.state.data) == null ? void 0 : e.email) ?? "", this.redirectView = (t = s.state.data) == null ? void 0 : t.redirectView, this.email = "", this.loading = !1;
152
152
  }
153
153
  firstUpdated() {
154
154
  var e;
@@ -230,7 +230,7 @@ let h = class extends C {
230
230
  `;
231
231
  }
232
232
  };
233
- h.styles = j;
233
+ h.styles = U;
234
234
  O([
235
235
  E()
236
236
  ], h.prototype, "email", void 0);
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-BNobBA-8.js"),c=require("./index-xYJPqvul.js");var p=function(l,e,i,o){var n=arguments.length,r=n<3?e:o===null?o=Object.getOwnPropertyDescriptor(e,i):o,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(l,e,i,o);else for(var s=l.length-1;s>=0;s--)(a=l[s])&&(r=(n<3?a(r):n>3?a(e,i,r):a(e,i))||r);return n>3&&r&&Object.defineProperty(e,i,r),r};exports.W3mEmailVerifyOtpView=class extends c.W3mEmailOtpWidget{constructor(){super(...arguments),this.onOtpSubmit=async e=>{var i,o;try{if(this.authConnector){const n=t.ChainController.state.activeChain,r=t.ConnectionController.getConnections(n),a=(i=t.OptionsController.state.remoteFeatures)==null?void 0:i.multiWallet,s=r.length>0;if(await this.authConnector.provider.connectOtp({otp:e}),t.EventsController.sendEvent({type:"track",event:"EMAIL_VERIFICATION_CODE_PASS"}),n)await t.ConnectionController.connectExternal(this.authConnector,n);else throw new Error("Active chain is not set on ChainController");if((o=t.OptionsController.state.remoteFeatures)!=null&&o.emailCapture)return;if(t.OptionsController.state.siwx){t.ModalController.close();return}if(s&&a){t.RouterController.replace("ProfileWallets"),t.SnackController.showSuccess("New Wallet Added");return}t.ModalController.close()}}catch(n){throw t.EventsController.sendEvent({type:"track",event:"EMAIL_VERIFICATION_CODE_FAIL",properties:{message:t.CoreHelperUtil.parseError(n)}}),n}},this.onOtpResend=async e=>{this.authConnector&&(await this.authConnector.provider.connectEmail({email:e}),t.EventsController.sendEvent({type:"track",event:"EMAIL_VERIFICATION_CODE_SENT"}))}}};exports.W3mEmailVerifyOtpView=p([t.customElement("w3m-email-verify-otp-view")],exports.W3mEmailVerifyOtpView);const h=t.css`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-BhaYgUya.js"),c=require("./index-CZuajWCC.js");var p=function(l,e,i,o){var n=arguments.length,r=n<3?e:o===null?o=Object.getOwnPropertyDescriptor(e,i):o,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(l,e,i,o);else for(var s=l.length-1;s>=0;s--)(a=l[s])&&(r=(n<3?a(r):n>3?a(e,i,r):a(e,i))||r);return n>3&&r&&Object.defineProperty(e,i,r),r};exports.W3mEmailVerifyOtpView=class extends c.W3mEmailOtpWidget{constructor(){super(...arguments),this.onOtpSubmit=async e=>{var i,o;try{if(this.authConnector){const n=t.ChainController.state.activeChain,r=t.ConnectionController.getConnections(n),a=(i=t.OptionsController.state.remoteFeatures)==null?void 0:i.multiWallet,s=r.length>0;if(await this.authConnector.provider.connectOtp({otp:e}),t.EventsController.sendEvent({type:"track",event:"EMAIL_VERIFICATION_CODE_PASS"}),n)await t.ConnectionController.connectExternal(this.authConnector,n);else throw new Error("Active chain is not set on ChainController");if((o=t.OptionsController.state.remoteFeatures)!=null&&o.emailCapture)return;if(t.OptionsController.state.siwx){t.ModalController.close();return}if(s&&a){t.RouterController.replace("ProfileWallets"),t.SnackController.showSuccess("New Wallet Added");return}t.ModalController.close()}}catch(n){throw t.EventsController.sendEvent({type:"track",event:"EMAIL_VERIFICATION_CODE_FAIL",properties:{message:t.CoreHelperUtil.parseError(n)}}),n}},this.onOtpResend=async e=>{this.authConnector&&(await this.authConnector.provider.connectEmail({email:e}),t.EventsController.sendEvent({type:"track",event:"EMAIL_VERIFICATION_CODE_SENT"}))}}};exports.W3mEmailVerifyOtpView=p([t.customElement("w3m-email-verify-otp-view")],exports.W3mEmailVerifyOtpView);const h=t.css`
2
2
  wui-icon-box {
3
3
  height: ${({spacing:l})=>l[16]};
4
4
  width: ${({spacing:l})=>l[16]};
@@ -1,5 +1,5 @@
1
- import { c1 as B, bX as g, cA as W, cz as K, bY as c, ck as _, cu as V, cI as G, cw as d, bW as w, bS as E, bT as z, bU as H, bV as l, ci as N, cc as h, cJ as j, c8 as k, ca as A, cb as m, c7 as L, cK as X, cv as q, bZ as Z, cL as v, ce as U, cM as O, b$ as J, c9 as I, c6 as Q, cN as ee, c5 as te } from "./index-BHukHFIh.mjs";
2
- const ie = B`
1
+ import { c0 as H, bW as g, cz as W, cy as K, bX as c, cj as _, ct as j, cH as G, cv as d, bV as w, bR as E, bS as z, bT as B, bU as l, ch as N, cb as h, cI as V, c7 as k, c9 as C, ca as m, c6 as L, cJ as X, cu as q, bY as J, cK as v, cd as U, cL as O, b_ as Q, c8 as I, c5 as Z, cM as ee, c4 as te } from "./index-CFLg0HEy.mjs";
2
+ const ie = H`
3
3
  div {
4
4
  width: 100%;
5
5
  }
@@ -56,7 +56,7 @@ let R = class extends g {
56
56
  async syncTheme() {
57
57
  const t = _.getAuthConnector();
58
58
  if (t) {
59
- const i = V.getSnapshot().themeMode, n = V.getSnapshot().themeVariables;
59
+ const i = j.getSnapshot().themeMode, n = j.getSnapshot().themeVariables;
60
60
  await t.provider.syncTheme({
61
61
  themeVariables: n,
62
62
  w3mThemeVariables: G(n, i)
@@ -244,7 +244,7 @@ let u = class extends g {
244
244
  ></wui-icon>`;
245
245
  }
246
246
  };
247
- u.styles = [z, H, ne];
247
+ u.styles = [z, B, ne];
248
248
  y([
249
249
  l()
250
250
  ], u.prototype, "type", void 0);
@@ -296,7 +296,7 @@ let Y = class extends g {
296
296
  Y = ae([
297
297
  w("w3m-upgrade-wallet-view")
298
298
  ], Y);
299
- var C = function(e, t, i, n) {
299
+ var A = function(e, t, i, n) {
300
300
  var r = arguments.length, o = r < 3 ? t : n === null ? n = Object.getOwnPropertyDescriptor(t, i) : n, s;
301
301
  if (typeof Reflect == "object" && typeof Reflect.decorate == "function") o = Reflect.decorate(e, t, i, n);
302
302
  else for (var a = e.length - 1; a >= 0; a--) (s = e[a]) && (o = (r < 3 ? s(o) : r > 3 ? s(t, i, o) : s(t, i)) || o);
@@ -331,16 +331,16 @@ let $ = class extends g {
331
331
  `;
332
332
  }
333
333
  isV6() {
334
- return (j.get("dapp_smart_account_version") || "v6") === "v6";
334
+ return (V.get("dapp_smart_account_version") || "v6") === "v6";
335
335
  }
336
336
  toggleSmartAccountVersion() {
337
337
  var t;
338
- j.set("dapp_smart_account_version", this.isV6() ? "v7" : "v6"), typeof window < "u" && ((t = window == null ? void 0 : window.location) == null || t.reload());
338
+ V.set("dapp_smart_account_version", this.isV6() ? "v7" : "v6"), typeof window < "u" && ((t = window == null ? void 0 : window.location) == null || t.reload());
339
339
  }
340
340
  togglePreferredAccountTypeTemplate() {
341
341
  var o;
342
342
  const t = (o = this.network) == null ? void 0 : o.chainNamespace, i = h.checkIfSmartAccountEnabled(), n = _.getConnectorId(t);
343
- return !_.getAuthConnector() || n !== k.CONNECTOR_ID.AUTH || !i ? null : (this.switched || (this.text = A(t) === m.ACCOUNT_TYPES.SMART_ACCOUNT ? "Switch to your EOA" : "Switch to your Smart Account"), c`
343
+ return !_.getAuthConnector() || n !== k.CONNECTOR_ID.AUTH || !i ? null : (this.switched || (this.text = C(t) === m.ACCOUNT_TYPES.SMART_ACCOUNT ? "Switch to your EOA" : "Switch to your Smart Account"), c`
344
344
  <wui-list-item
345
345
  icon="swapHorizontal"
346
346
  ?rounded=${!0}
@@ -355,23 +355,23 @@ let $ = class extends g {
355
355
  }
356
356
  async changePreferredAccountType() {
357
357
  var o;
358
- const t = (o = this.network) == null ? void 0 : o.chainNamespace, i = h.checkIfSmartAccountEnabled(), n = A(t) === m.ACCOUNT_TYPES.SMART_ACCOUNT || !i ? m.ACCOUNT_TYPES.EOA : m.ACCOUNT_TYPES.SMART_ACCOUNT;
358
+ const t = (o = this.network) == null ? void 0 : o.chainNamespace, i = h.checkIfSmartAccountEnabled(), n = C(t) === m.ACCOUNT_TYPES.SMART_ACCOUNT || !i ? m.ACCOUNT_TYPES.EOA : m.ACCOUNT_TYPES.SMART_ACCOUNT;
359
359
  _.getAuthConnector() && (this.loading = !0, await L.setPreferredAccountType(n, t), this.text = n === m.ACCOUNT_TYPES.SMART_ACCOUNT ? "Switch to your EOA" : "Switch to your Smart Account", this.switched = !0, X.resetSend(), this.loading = !1, this.requestUpdate());
360
360
  }
361
361
  };
362
- C([
362
+ A([
363
363
  d()
364
364
  ], $.prototype, "loading", void 0);
365
- C([
365
+ A([
366
366
  d()
367
367
  ], $.prototype, "switched", void 0);
368
- C([
368
+ A([
369
369
  d()
370
370
  ], $.prototype, "text", void 0);
371
- C([
371
+ A([
372
372
  d()
373
373
  ], $.prototype, "network", void 0);
374
- $ = C([
374
+ $ = A([
375
375
  w("w3m-smart-account-settings-view")
376
376
  ], $);
377
377
  const ce = E`
@@ -436,7 +436,7 @@ let b = class extends g {
436
436
  return this.loading ? c`<wui-loading-spinner size="lg" color="primary"></wui-loading-spinner>` : this.registered ? c`<wui-tag variant="info" size="sm">Registered</wui-tag>` : c`<wui-tag variant="success" size="sm">Available</wui-tag>`;
437
437
  }
438
438
  };
439
- b.styles = [z, H, ce];
439
+ b.styles = [z, B, ce];
440
440
  T([
441
441
  l()
442
442
  ], b.prototype, "name", void 0);
@@ -579,7 +579,7 @@ var x = function(e, t, i, n) {
579
579
  let p = class extends g {
580
580
  constructor() {
581
581
  var t;
582
- super(), this.formRef = Z(), this.usubscribe = [], this.name = "", this.error = "", this.loading = v.state.loading, this.suggestions = v.state.suggestions, this.profileName = (t = h.getAccountData()) == null ? void 0 : t.profileName, this.onDebouncedNameInputChange = U.debounce((i) => {
582
+ super(), this.formRef = J(), this.usubscribe = [], this.name = "", this.error = "", this.loading = v.state.loading, this.suggestions = v.state.suggestions, this.profileName = (t = h.getAccountData()) == null ? void 0 : t.profileName, this.onDebouncedNameInputChange = U.debounce((i) => {
583
583
  i.length < 4 ? this.error = "Name must be at least 4 characters long" : O.isValidReownName(i) ? (this.error = "", v.getSuggestions(i)) : this.error = "The value is not a valid username";
584
584
  }), this.usubscribe.push(v.subscribe((i) => {
585
585
  this.suggestions = i.suggestions, this.loading = i.loading;
@@ -603,7 +603,7 @@ let p = class extends g {
603
603
  gap="4"
604
604
  .padding=${["1", "3", "4", "3"]}
605
605
  >
606
- <form ${J(this.formRef)} @submit=${this.onSubmitName.bind(this)}>
606
+ <form ${Q(this.formRef)} @submit=${this.onSubmitName.bind(this)}>
607
607
  <wui-ens-input
608
608
  @inputChange=${this.onNameInputChange.bind(this)}
609
609
  .errorMessage=${this.error}
@@ -676,23 +676,23 @@ let p = class extends g {
676
676
  type: "track",
677
677
  event: "REGISTER_NAME_INITIATED",
678
678
  properties: {
679
- isSmartAccount: A(h.state.activeChain) === m.ACCOUNT_TYPES.SMART_ACCOUNT,
679
+ isSmartAccount: C(h.state.activeChain) === m.ACCOUNT_TYPES.SMART_ACCOUNT,
680
680
  ensName: t
681
681
  }
682
682
  }), await v.registerName(t), I.sendEvent({
683
683
  type: "track",
684
684
  event: "REGISTER_NAME_SUCCESS",
685
685
  properties: {
686
- isSmartAccount: A(h.state.activeChain) === m.ACCOUNT_TYPES.SMART_ACCOUNT,
686
+ isSmartAccount: C(h.state.activeChain) === m.ACCOUNT_TYPES.SMART_ACCOUNT,
687
687
  ensName: t
688
688
  }
689
689
  });
690
690
  } catch (i) {
691
- Q.showError(i.message), I.sendEvent({
691
+ Z.showError(i.message), I.sendEvent({
692
692
  type: "track",
693
693
  event: "REGISTER_NAME_ERROR",
694
694
  properties: {
695
- isSmartAccount: A(h.state.activeChain) === m.ACCOUNT_TYPES.SMART_ACCOUNT,
695
+ isSmartAccount: C(h.state.activeChain) === m.ACCOUNT_TYPES.SMART_ACCOUNT,
696
696
  ensName: t,
697
697
  error: U.parseError(i)
698
698
  }
@@ -728,7 +728,7 @@ x([
728
728
  p = x([
729
729
  w("w3m-register-account-name-view")
730
730
  ], p);
731
- const ue = B`
731
+ const ue = H`
732
732
  .continue-button-container {
733
733
  width: 100%;
734
734
  }
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-BNobBA-8.js"),x=e.i$1`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-BhaYgUya.js"),x=e.i$1`
2
2
  div {
3
3
  width: 100%;
4
4
  }
@@ -1,4 +1,4 @@
1
- import { R as t, a as o } from "./ReownAuthentication-ZWJVb5u8.mjs";
1
+ import { R as t, a as o } from "./ReownAuthentication-7iIT4jS4.mjs";
2
2
  export {
3
3
  t as ReownAuthentication,
4
4
  o as ReownAuthenticationMessenger
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./ReownAuthentication-_EMKUe4O.js");exports.ReownAuthentication=e.ReownAuthentication;exports.ReownAuthenticationMessenger=e.ReownAuthenticationMessenger;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./ReownAuthentication-BEGlJitZ.js");exports.ReownAuthentication=e.ReownAuthentication;exports.ReownAuthenticationMessenger=e.ReownAuthenticationMessenger;
@@ -1,4 +1,4 @@
1
- import { bS as C, bT as O, bU as P, bV as h, bW as w, bX as v, bY as l, c1 as E, cw as d, c0 as I, cx as g, c5 as S, ck as $, ce as R, c6 as T } from "./index-BHukHFIh.mjs";
1
+ import { bR as C, bS as O, bT as P, bU as h, bV as w, bW as v, bX as l, c0 as E, cv as d, b$ as x, cw as g, c4 as S, cj as $, cd as R, c5 as T } from "./index-CFLg0HEy.mjs";
2
2
  const L = C`
3
3
  :host {
4
4
  position: relative;
@@ -172,18 +172,18 @@ let c = class extends v {
172
172
  const i = t.target, s = this.getInputElement(i);
173
173
  if (s) {
174
174
  const o = s.value;
175
- t.inputType === "insertFromPaste" ? this.handlePaste(s, o, e) : I.isNumber(o) && t.data ? (this.updateInput(s, e, t.data), this.focusInputField("next", e)) : this.updateInput(s, e, "");
175
+ t.inputType === "insertFromPaste" ? this.handlePaste(s, o, e) : x.isNumber(o) && t.data ? (this.updateInput(s, e, t.data), this.focusInputField("next", e)) : this.updateInput(s, e, "");
176
176
  }
177
177
  this.dispatchInputChangeEvent();
178
178
  }
179
179
  handlePaste(t, e, i) {
180
180
  const s = e[0];
181
- if (s && I.isNumber(s)) {
181
+ if (s && x.isNumber(s)) {
182
182
  this.updateInput(t, i, s);
183
183
  const r = e.substring(1);
184
184
  if (i + 1 < this.length && r.length) {
185
- const a = this.numerics[i + 1], x = a ? this.getInputElement(a) : void 0;
186
- x && this.handlePaste(x, r, i + 1);
185
+ const a = this.numerics[i + 1], I = a ? this.getInputElement(a) : void 0;
186
+ I && this.handlePaste(I, r, i + 1);
187
187
  } else
188
188
  this.focusInputField("next", i);
189
189
  } else
@@ -1,5 +1,5 @@
1
- import { P as t, A as m, a as d } from "./index-Clu0wU1d.mjs";
2
- import { b as z, c as B, W as G } from "./index-Clu0wU1d.mjs";
1
+ import { P as t, A as m, a as d } from "./index-CAtS1mbf.mjs";
2
+ import { b as z, c as B, W as G } from "./index-CAtS1mbf.mjs";
3
3
  const U = 3e5;
4
4
  async function E(e) {
5
5
  return t.handleOpenPay(e);