@web3auth/modal 10.0.0-beta.1 → 10.0.0-beta.2

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.
@@ -63,13 +63,16 @@ class Web3Auth extends noModal.Web3AuthNoModal {
63
63
  }
64
64
  }
65
65
  });
66
+ _defineProperty(this, "getChainNamespaces", () => {
67
+ var _this$coreOptions$cha;
68
+ return [...new Set(((_this$coreOptions$cha = this.coreOptions.chains) === null || _this$coreOptions$cha === void 0 ? void 0 : _this$coreOptions$cha.map(x => x.chainNamespace)) || [])];
69
+ });
66
70
  this.options = _objectSpread({}, options);
67
71
  if (!this.options.uiConfig) this.options.uiConfig = {};
68
72
  if (this.options.modalConfig) this.modalConfig = this.options.modalConfig;
69
73
  noModal.log.info("modalConfig", this.modalConfig);
70
74
  }
71
75
  async initModal() {
72
- var _this$coreOptions$cha;
73
76
  super.checkInitRequirements();
74
77
  // get project config and wallet registry
75
78
  const {
@@ -93,7 +96,7 @@ class Web3Auth extends noModal.Web3AuthNoModal {
93
96
  connectorListener: this,
94
97
  web3authClientId: this.options.clientId,
95
98
  web3authNetwork: this.options.web3AuthNetwork,
96
- chainNamespaces: [...new Set(((_this$coreOptions$cha = this.coreOptions.chains) === null || _this$coreOptions$cha === void 0 ? void 0 : _this$coreOptions$cha.map(x => x.chainNamespace)) || [])],
99
+ chainNamespaces: this.getChainNamespaces(),
97
100
  walletRegistry: filteredWalletRegistry
98
101
  }), {
99
102
  onInitExternalWallets: this.onInitExternalWallets,
@@ -417,13 +420,21 @@ class Web3Auth extends noModal.Web3AuthNoModal {
417
420
  }
418
421
  async initExternalConnectors(externalConnectors, options) {
419
422
  const connectorsConfig = {};
423
+ const connectorChainNamespaceMap = {};
420
424
  // we do it like this because we don't want one slow connector to delay the load of the entire external wallet section.
421
425
  externalConnectors.forEach(async connector => {
422
426
  const connectorName = connector.name;
423
427
  noModal.log.debug("init external wallet", this.cachedConnector, connectorName, connector.status);
424
- if (connector.status === noModal.CONNECTOR_STATUS.NOT_READY) {
425
- // we are not initializing cached connector here as it is already being initialized in initModal before.
426
- if (this.cachedConnector === connectorName) return;
428
+ // a wallet can support multiple chain namespaces e.g. Phantom has EvmInjected connector and WalletStandard connector.
429
+ if (!connectorChainNamespaceMap[connectorName]) connectorChainNamespaceMap[connectorName] = new Set();
430
+ if (connector.connectorNamespace === noModal.CONNECTOR_NAMESPACES.MULTICHAIN) {
431
+ this.getChainNamespaces().forEach(x => connectorChainNamespaceMap[connectorName].add(x));
432
+ } else {
433
+ connectorChainNamespaceMap[connectorName].add(connector.connectorNamespace);
434
+ }
435
+ // initialize connectors
436
+ // skip initializing cached connector here as it is already being initialized in initModal before.
437
+ if (connector.status === noModal.CONNECTOR_STATUS.NOT_READY && this.cachedConnector !== connectorName) {
427
438
  try {
428
439
  this.subscribeToConnectorEvents(connector);
429
440
  const initialChain = this.getInitialChainIdForConnector(connector);
@@ -431,33 +442,23 @@ class Web3Auth extends noModal.Web3AuthNoModal {
431
442
  autoConnect: this.cachedConnector === connectorName,
432
443
  chainId: initialChain.chainId
433
444
  });
434
- const connectorModalConfig = this.modalConfig.connectors[connectorName];
435
- connectorsConfig[connectorName] = _objectSpread(_objectSpread({}, connectorModalConfig), {}, {
436
- isInjected: connector.isInjected,
437
- icon: connector.icon
438
- });
439
- this.loginModal.addWalletLogins(connectorsConfig, {
440
- showExternalWalletsOnly: !!options.showExternalWalletsOnly,
441
- externalWalletsVisibility: !!options.externalWalletsVisibility,
442
- externalWalletsInitialized: !!options.externalWalletsInitialized
443
- });
444
445
  } catch (error) {
445
446
  noModal.log.error(error, "error while initializing connector", connectorName);
446
447
  }
447
- } else {
448
- if (connector.status === noModal.CONNECTOR_STATUS.READY || connector.status === noModal.CONNECTOR_STATUS.CONNECTING) {
449
- // we use connecting status for wallet connect
450
- const connectorModalConfig = this.modalConfig.connectors[connectorName];
451
- connectorsConfig[connectorName] = _objectSpread(_objectSpread({}, connectorModalConfig), {}, {
452
- isInjected: connector.isInjected,
453
- icon: connector.icon
454
- });
455
- this.loginModal.addWalletLogins(connectorsConfig, {
456
- showExternalWalletsOnly: !!options.showExternalWalletsOnly,
457
- externalWalletsVisibility: !!options.externalWalletsVisibility,
458
- externalWalletsInitialized: !!options.externalWalletsInitialized
459
- });
460
- }
448
+ }
449
+ // update connector config
450
+ if ([noModal.CONNECTOR_STATUS.NOT_READY, noModal.CONNECTOR_STATUS.READY, noModal.CONNECTOR_STATUS.CONNECTING].includes(connector.status)) {
451
+ const connectorModalConfig = this.modalConfig.connectors[connectorName];
452
+ connectorsConfig[connectorName] = _objectSpread(_objectSpread({}, connectorModalConfig), {}, {
453
+ isInjected: connector.isInjected,
454
+ icon: connector.icon,
455
+ chainNamespaces: Array.from(connectorChainNamespaceMap[connectorName])
456
+ });
457
+ this.loginModal.addWalletLogins(connectorsConfig, {
458
+ showExternalWalletsOnly: !!options.showExternalWalletsOnly,
459
+ externalWalletsVisibility: !!options.externalWalletsVisibility,
460
+ externalWalletsInitialized: !!options.externalWalletsInitialized
461
+ });
461
462
  }
462
463
  });
463
464
  }
@@ -14,7 +14,7 @@ function BottomSheet({
14
14
  uiConfig
15
15
  }) {
16
16
  const {
17
- borderRadiusType
17
+ borderRadiusType = "large"
18
18
  } = uiConfig;
19
19
  return jsxRuntime.jsxs(jsxRuntime.Fragment, {
20
20
  children: [jsxRuntime.jsx("div", {
@@ -28,7 +28,7 @@ function BottomSheet({
28
28
  role: "button"
29
29
  }), jsxRuntime.jsxs("div", {
30
30
  className: utils.cn(`w3a--fixed w3a--bottom-2 w3a--left-2 w3a--mx-auto w3a--flex w3a--w-[96%] w3a--flex-col
31
- w3a--gap-y-2 w3a--rounded-3xl w3a--border w3a--border-app-gray-100 w3a--bg-app-white w3a--p-4 w3a--shadow-lg w3a--transition-transform w3a--duration-500
31
+ w3a--gap-y-2 w3a--border w3a--border-app-gray-100 w3a--bg-app-white w3a--p-4 w3a--shadow-lg w3a--transition-transform w3a--duration-500
32
32
  w3a--ease-out dark:w3a--border-app-gray-600 dark:w3a--bg-app-dark-surface-main
33
33
  ${isShown ? "w3a--translate-y-0 w3a--delay-700" : "w3a--translate-y-full"}`, {
34
34
  "w3a--rounded-[30px]": borderRadiusType === "large",
@@ -46,15 +46,18 @@ function ConnectWalletChainFilter(props) {
46
46
  className: "w3a--flex w3a--items-center w3a--justify-items-start w3a--gap-x-2",
47
47
  children: chains.map(chain => jsxRuntime.jsxs("button", {
48
48
  type: "button",
49
- className: utils.cn("w3a--flex w3a--items-center w3a--justify-center w3a--gap-x-1 w3a--text-xs w3a--font-medium w3a--px-4 w3a--py-3 w3a--text-app-gray-500 dark:w3a--text-app-gray-300 w3a--h-12", {
50
- "w3a--bg-app-gray-100 dark:w3a--bg-app-gray-800 w3a--border w3a--border-app-gray-200 dark:w3a--border-app-gray-700 w3a--rounded-2xl hover:w3a--bg-app-gray-200 dark:hover:w3a--bg-app-gray-700 w3a--text-app-gray-900 dark:w3a--text-app-white": selectedChain === chain.id
49
+ className: utils.cn("w3a--flex w3a--items-center w3a--justify-center w3a--gap-x-1 w3a--text-xs w3a--font-medium w3a--px-4 w3a--py-3 w3a--text-app-gray-500 dark:w3a--text-app-gray-300 hover:w3a--bg-app-gray-200 dark:hover:w3a--bg-app-gray-700 w3a--h-12 w3a--rounded-2xl", {
50
+ "w3a--bg-app-gray-100 dark:w3a--bg-app-gray-800 w3a--border w3a--border-app-gray-200 dark:w3a--border-app-gray-700 w3a--text-app-gray-900 dark:w3a--text-app-white": selectedChain === chain.id
51
51
  }),
52
52
  onClick: () => setSelectedChain(chain.id),
53
53
  children: [chain.icon && jsxRuntime.jsx("img", {
54
54
  src: utils.getIcons(isDark ? `${chain.icon}-dark` : `${chain.icon}-light`),
55
55
  alt: chain.name,
56
56
  className: "w3a--size-5 w3a--object-contain"
57
- }), t(chain.name)]
57
+ }), jsxRuntime.jsx("span", {
58
+ className: "first-letter:w3a--capitalize",
59
+ children: t(chain.name)
60
+ })]
58
61
  }, chain.id))
59
62
  });
60
63
  }
@@ -56,7 +56,7 @@ const ConnectWalletChainNamespaceSelect = props => {
56
56
  }) => jsxRuntime.jsx("li", {
57
57
  children: jsxRuntime.jsxs("button", {
58
58
  type: "button",
59
- className: "w3a--btn w3a--size-xl w3a--w-full w3a--items-center !w3a--justify-between w3a--rounded-full",
59
+ className: "w3a--btn w3a-external-wallet-btn w3a--h-12 w3a--w-full w3a--items-center !w3a--justify-between w3a--rounded-full",
60
60
  onClick: () => handleExternalWalletClick({
61
61
  connector: wallet.name,
62
62
  chainNamespace
@@ -77,6 +77,7 @@ const ConnectWalletChainNamespaceSelect = props => {
77
77
  })]
78
78
  }), jsxRuntime.jsx("img", {
79
79
  id: "external-wallet-arrow",
80
+ className: "w3a--icon-animation",
80
81
  src: utils.getIcons(isDark ? "chevron-right-dark" : "chevron-right-light"),
81
82
  alt: "arrow"
82
83
  })]
@@ -224,20 +224,22 @@ function Root(props) {
224
224
  const deepLink = walletRegistryItem === null || walletRegistryItem === void 0 || (_walletRegistryItem$m2 = walletRegistryItem.mobile) === null || _walletRegistryItem$m2 === void 0 ? void 0 : _walletRegistryItem$m2.native;
225
225
  href = universalLink || deepLink;
226
226
  }
227
+ // determine the chain namespaces supported by the wallet
228
+ const connectorConfig = config[wallet];
229
+ const connectorChainNamespaces = (connectorConfig === null || connectorConfig === void 0 ? void 0 : connectorConfig.chainNamespaces) || [];
227
230
  const registryNamespaces = new Set((_walletRegistryItem$c = walletRegistryItem.chains) === null || _walletRegistryItem$c === void 0 ? void 0 : _walletRegistryItem$c.map(chain => chain.split(":")[0]));
228
231
  const injectedChainNamespaces = new Set((_walletRegistryItem$i = walletRegistryItem.injected) === null || _walletRegistryItem$i === void 0 ? void 0 : _walletRegistryItem$i.map(injected => injected.namespace));
229
- const availableChainNamespaces = chainNamespaces.filter(x => registryNamespaces.has(x) || injectedChainNamespaces.has(x));
230
- const connector = config[wallet];
232
+ const availableChainNamespaces = chainNamespaces.filter(x => registryNamespaces.has(x) || injectedChainNamespaces.has(x) || connectorChainNamespaces.includes(x));
231
233
  const button = {
232
234
  name: wallet,
233
235
  displayName: walletRegistryItem.name,
234
236
  href,
235
- hasInjectedWallet: (connector === null || connector === void 0 ? void 0 : connector.isInjected) || false,
237
+ hasInjectedWallet: (connectorConfig === null || connectorConfig === void 0 ? void 0 : connectorConfig.isInjected) || false,
236
238
  hasWalletConnect: isWalletConnectConnectorIncluded && ((_walletRegistryItem$w = walletRegistryItem.walletConnect) === null || _walletRegistryItem$w === void 0 || (_walletRegistryItem$w = _walletRegistryItem$w.sdks) === null || _walletRegistryItem$w === void 0 ? void 0 : _walletRegistryItem$w.includes("sign_v2")),
237
239
  hasInstallLinks: Object.keys(walletRegistryItem.app || {}).length > 0,
238
240
  walletRegistryItem,
239
241
  imgExtension: walletRegistryItem.imgExtension || "svg",
240
- icon: connector === null || connector === void 0 ? void 0 : connector.icon,
242
+ icon: connectorConfig === null || connectorConfig === void 0 ? void 0 : connectorConfig.icon,
241
243
  chainNamespaces: availableChainNamespaces
242
244
  };
243
245
  if (!button.hasInjectedWallet && !button.hasWalletConnect && !button.hasInstallLinks) return acc;
@@ -248,28 +250,22 @@ function Root(props) {
248
250
  }, [connectorVisibilityMap, chainNamespaces, config, deviceDetails.platform, isWalletConnectConnectorIncluded]);
249
251
  const installedConnectorButtons = react.useMemo(() => {
250
252
  const installedConnectors = Object.keys(config).reduce((acc, connector) => {
251
- var _walletRegistryItem$c2, _walletRegistryItem$i2, _config$connector, _config$connector2;
252
253
  if ([noModal.WALLET_CONNECTORS.WALLET_CONNECT_V2].includes(connector) || !connectorVisibilityMap[connector]) return acc;
253
- // determine chain namespaces based on wallet registry
254
- const walletRegistryItem = walletRegistry.default[connector];
255
- const registryNamespaces = new Set(walletRegistryItem === null || walletRegistryItem === void 0 || (_walletRegistryItem$c2 = walletRegistryItem.chains) === null || _walletRegistryItem$c2 === void 0 ? void 0 : _walletRegistryItem$c2.map(chain => chain.split(":")[0]));
256
- const injectedChainNamespaces = new Set(walletRegistryItem === null || walletRegistryItem === void 0 || (_walletRegistryItem$i2 = walletRegistryItem.injected) === null || _walletRegistryItem$i2 === void 0 ? void 0 : _walletRegistryItem$i2.map(injected => injected.namespace));
257
- const availableChainNamespaces = chainNamespaces.filter(x => registryNamespaces.has(x) || injectedChainNamespaces.has(x));
254
+ const connectorConfig = config[connector];
258
255
  acc.push({
259
256
  name: connector,
260
- displayName: config[connector].label || connector,
261
- hasInjectedWallet: ((_config$connector = config[connector]) === null || _config$connector === void 0 ? void 0 : _config$connector.isInjected) || false,
257
+ displayName: (connectorConfig === null || connectorConfig === void 0 ? void 0 : connectorConfig.label) || connector,
258
+ hasInjectedWallet: (connectorConfig === null || connectorConfig === void 0 ? void 0 : connectorConfig.isInjected) || false,
262
259
  hasWalletConnect: false,
263
260
  hasInstallLinks: false,
264
- walletRegistryItem,
265
- icon: (_config$connector2 = config[connector]) === null || _config$connector2 === void 0 ? void 0 : _config$connector2.icon,
266
- chainNamespaces: availableChainNamespaces
261
+ icon: connectorConfig === null || connectorConfig === void 0 ? void 0 : connectorConfig.icon,
262
+ chainNamespaces: (connectorConfig === null || connectorConfig === void 0 ? void 0 : connectorConfig.chainNamespaces) || []
267
263
  });
268
264
  return acc;
269
265
  }, []);
270
266
  // make metamask the first button and limit the number of buttons
271
267
  return installedConnectors;
272
- }, [config, connectorVisibilityMap, walletRegistry.default, chainNamespaces]);
268
+ }, [config, connectorVisibilityMap]);
273
269
  const customConnectorButtons = react.useMemo(() => {
274
270
  return installedConnectorButtons.filter(button => !button.hasInjectedWallet);
275
271
  }, [installedConnectorButtons]);
@@ -331,7 +327,7 @@ function Root(props) {
331
327
  }
332
328
  // Default
333
329
  return "539px";
334
- }, [isWalletDetailsExpanded, modalState.currentPage, isSocialLoginsExpanded, installedConnectorButtons, privacyPolicy, tncLink, enableMainSocialLoginButton, modalState.status]);
330
+ }, [privacyPolicy, tncLink, enableMainSocialLoginButton, modalState.status, modalState.currentPage, isWalletDetailsExpanded, isSocialLoginsExpanded, topInstalledConnectorButtons.length]);
335
331
  const contextValue = react.useMemo(() => ({
336
332
  bodyState,
337
333
  setBodyState,
@@ -61,7 +61,9 @@ function Widget(props) {
61
61
  stateListener.on("STATE_UPDATED", newModalState => {
62
62
  noModal.log.debug("state updated", newModalState);
63
63
  setModalState(prevState => {
64
- const mergedState = noModal.cloneDeep(deepmerge(prevState, newModalState));
64
+ const mergedState = noModal.cloneDeep(deepmerge(prevState, newModalState, {
65
+ arrayMerge: (_prevState, newState) => newState
66
+ }));
65
67
  return mergedState;
66
68
  });
67
69
  });
@@ -1,5 +1,5 @@
1
1
  import type { BaseConnectorConfig, IProvider, IWeb3Auth, LoginMethodConfig, WALLET_CONNECTOR_TYPE } from "@web3auth/no-modal";
2
- export interface ModalConfig extends Omit<BaseConnectorConfig, "isInjected"> {
2
+ export interface ModalConfig extends Omit<BaseConnectorConfig, "isInjected" | "chainNamespaces"> {
3
3
  loginMethods?: LoginMethodConfig;
4
4
  }
5
5
  export interface ConnectorsModalConfig {
@@ -29,4 +29,5 @@ export declare class Web3Auth extends Web3AuthNoModal implements IWeb3AuthModal
29
29
  private onSocialLogin;
30
30
  private onExternalWalletLogin;
31
31
  private onModalVisibility;
32
+ private getChainNamespaces;
32
33
  }
@@ -1,6 +1,6 @@
1
1
  import _objectSpread from '@babel/runtime/helpers/objectSpread2';
2
2
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
3
- import { Web3AuthNoModal, cloneDeep, WALLET_CONNECTORS, log, CONNECTOR_STATUS, CONNECTOR_EVENTS, WalletInitializationError, fetchProjectConfig, fetchWalletRegistry, CONNECTOR_CATEGORY, CONNECTOR_NAMES } from '@web3auth/no-modal';
3
+ import { Web3AuthNoModal, cloneDeep, WALLET_CONNECTORS, log, CONNECTOR_STATUS, CONNECTOR_EVENTS, WalletInitializationError, fetchProjectConfig, fetchWalletRegistry, CONNECTOR_CATEGORY, CONNECTOR_NAMES, CONNECTOR_NAMESPACES } from '@web3auth/no-modal';
4
4
  import deepmerge from 'deepmerge';
5
5
  import { defaultConnectorsModalConfig, walletRegistryUrl } from './config.js';
6
6
  import { AUTH_PROVIDERS_NAMES, AUTH_PROVIDERS, capitalizeFirstLetter } from './ui/config.js';
@@ -62,13 +62,16 @@ class Web3Auth extends Web3AuthNoModal {
62
62
  }
63
63
  }
64
64
  });
65
+ _defineProperty(this, "getChainNamespaces", () => {
66
+ var _this$coreOptions$cha;
67
+ return [...new Set(((_this$coreOptions$cha = this.coreOptions.chains) === null || _this$coreOptions$cha === void 0 ? void 0 : _this$coreOptions$cha.map(x => x.chainNamespace)) || [])];
68
+ });
65
69
  this.options = _objectSpread({}, options);
66
70
  if (!this.options.uiConfig) this.options.uiConfig = {};
67
71
  if (this.options.modalConfig) this.modalConfig = this.options.modalConfig;
68
72
  log.info("modalConfig", this.modalConfig);
69
73
  }
70
74
  async initModal() {
71
- var _this$coreOptions$cha;
72
75
  super.checkInitRequirements();
73
76
  // get project config and wallet registry
74
77
  const {
@@ -94,7 +97,7 @@ class Web3Auth extends Web3AuthNoModal {
94
97
  connectorListener: this,
95
98
  web3authClientId: this.options.clientId,
96
99
  web3authNetwork: this.options.web3AuthNetwork,
97
- chainNamespaces: [...new Set(((_this$coreOptions$cha = this.coreOptions.chains) === null || _this$coreOptions$cha === void 0 ? void 0 : _this$coreOptions$cha.map(x => x.chainNamespace)) || [])],
100
+ chainNamespaces: this.getChainNamespaces(),
98
101
  walletRegistry: filteredWalletRegistry
99
102
  }), {
100
103
  onInitExternalWallets: this.onInitExternalWallets,
@@ -437,13 +440,24 @@ class Web3Auth extends Web3AuthNoModal {
437
440
  }
438
441
  async initExternalConnectors(externalConnectors, options) {
439
442
  const connectorsConfig = {};
443
+ const connectorChainNamespaceMap = {};
444
+
440
445
  // we do it like this because we don't want one slow connector to delay the load of the entire external wallet section.
441
446
  externalConnectors.forEach(async connector => {
442
447
  const connectorName = connector.name;
443
448
  log.debug("init external wallet", this.cachedConnector, connectorName, connector.status);
444
- if (connector.status === CONNECTOR_STATUS.NOT_READY) {
445
- // we are not initializing cached connector here as it is already being initialized in initModal before.
446
- if (this.cachedConnector === connectorName) return;
449
+
450
+ // a wallet can support multiple chain namespaces e.g. Phantom has EvmInjected connector and WalletStandard connector.
451
+ if (!connectorChainNamespaceMap[connectorName]) connectorChainNamespaceMap[connectorName] = new Set();
452
+ if (connector.connectorNamespace === CONNECTOR_NAMESPACES.MULTICHAIN) {
453
+ this.getChainNamespaces().forEach(x => connectorChainNamespaceMap[connectorName].add(x));
454
+ } else {
455
+ connectorChainNamespaceMap[connectorName].add(connector.connectorNamespace);
456
+ }
457
+
458
+ // initialize connectors
459
+ // skip initializing cached connector here as it is already being initialized in initModal before.
460
+ if (connector.status === CONNECTOR_STATUS.NOT_READY && this.cachedConnector !== connectorName) {
447
461
  try {
448
462
  this.subscribeToConnectorEvents(connector);
449
463
  const initialChain = this.getInitialChainIdForConnector(connector);
@@ -451,33 +465,24 @@ class Web3Auth extends Web3AuthNoModal {
451
465
  autoConnect: this.cachedConnector === connectorName,
452
466
  chainId: initialChain.chainId
453
467
  });
454
- const connectorModalConfig = this.modalConfig.connectors[connectorName];
455
- connectorsConfig[connectorName] = _objectSpread(_objectSpread({}, connectorModalConfig), {}, {
456
- isInjected: connector.isInjected,
457
- icon: connector.icon
458
- });
459
- this.loginModal.addWalletLogins(connectorsConfig, {
460
- showExternalWalletsOnly: !!options.showExternalWalletsOnly,
461
- externalWalletsVisibility: !!options.externalWalletsVisibility,
462
- externalWalletsInitialized: !!options.externalWalletsInitialized
463
- });
464
468
  } catch (error) {
465
469
  log.error(error, "error while initializing connector", connectorName);
466
470
  }
467
- } else {
468
- if (connector.status === CONNECTOR_STATUS.READY || connector.status === CONNECTOR_STATUS.CONNECTING) {
469
- // we use connecting status for wallet connect
470
- const connectorModalConfig = this.modalConfig.connectors[connectorName];
471
- connectorsConfig[connectorName] = _objectSpread(_objectSpread({}, connectorModalConfig), {}, {
472
- isInjected: connector.isInjected,
473
- icon: connector.icon
474
- });
475
- this.loginModal.addWalletLogins(connectorsConfig, {
476
- showExternalWalletsOnly: !!options.showExternalWalletsOnly,
477
- externalWalletsVisibility: !!options.externalWalletsVisibility,
478
- externalWalletsInitialized: !!options.externalWalletsInitialized
479
- });
480
- }
471
+ }
472
+
473
+ // update connector config
474
+ if ([CONNECTOR_STATUS.NOT_READY, CONNECTOR_STATUS.READY, CONNECTOR_STATUS.CONNECTING].includes(connector.status)) {
475
+ const connectorModalConfig = this.modalConfig.connectors[connectorName];
476
+ connectorsConfig[connectorName] = _objectSpread(_objectSpread({}, connectorModalConfig), {}, {
477
+ isInjected: connector.isInjected,
478
+ icon: connector.icon,
479
+ chainNamespaces: Array.from(connectorChainNamespaceMap[connectorName])
480
+ });
481
+ this.loginModal.addWalletLogins(connectorsConfig, {
482
+ showExternalWalletsOnly: !!options.showExternalWalletsOnly,
483
+ externalWalletsVisibility: !!options.externalWalletsVisibility,
484
+ externalWalletsInitialized: !!options.externalWalletsInitialized
485
+ });
481
486
  }
482
487
  });
483
488
  }
@@ -12,7 +12,7 @@ function BottomSheet({
12
12
  uiConfig
13
13
  }) {
14
14
  const {
15
- borderRadiusType
15
+ borderRadiusType = "large"
16
16
  } = uiConfig;
17
17
  return /*#__PURE__*/jsxs(Fragment, {
18
18
  children: [/*#__PURE__*/jsx("div", {
@@ -26,7 +26,7 @@ function BottomSheet({
26
26
  role: "button"
27
27
  }), /*#__PURE__*/jsxs("div", {
28
28
  className: cn(`w3a--fixed w3a--bottom-2 w3a--left-2 w3a--mx-auto w3a--flex w3a--w-[96%] w3a--flex-col
29
- w3a--gap-y-2 w3a--rounded-3xl w3a--border w3a--border-app-gray-100 w3a--bg-app-white w3a--p-4 w3a--shadow-lg w3a--transition-transform w3a--duration-500
29
+ w3a--gap-y-2 w3a--border w3a--border-app-gray-100 w3a--bg-app-white w3a--p-4 w3a--shadow-lg w3a--transition-transform w3a--duration-500
30
30
  w3a--ease-out dark:w3a--border-app-gray-600 dark:w3a--bg-app-dark-surface-main
31
31
  ${isShown ? "w3a--translate-y-0 w3a--delay-700" : "w3a--translate-y-full"}`, {
32
32
  "w3a--rounded-[30px]": borderRadiusType === "large",
@@ -44,15 +44,18 @@ function ConnectWalletChainFilter(props) {
44
44
  className: "w3a--flex w3a--items-center w3a--justify-items-start w3a--gap-x-2",
45
45
  children: chains.map(chain => /*#__PURE__*/jsxs("button", {
46
46
  type: "button",
47
- className: cn("w3a--flex w3a--items-center w3a--justify-center w3a--gap-x-1 w3a--text-xs w3a--font-medium w3a--px-4 w3a--py-3 w3a--text-app-gray-500 dark:w3a--text-app-gray-300 w3a--h-12", {
48
- "w3a--bg-app-gray-100 dark:w3a--bg-app-gray-800 w3a--border w3a--border-app-gray-200 dark:w3a--border-app-gray-700 w3a--rounded-2xl hover:w3a--bg-app-gray-200 dark:hover:w3a--bg-app-gray-700 w3a--text-app-gray-900 dark:w3a--text-app-white": selectedChain === chain.id
47
+ className: cn("w3a--flex w3a--items-center w3a--justify-center w3a--gap-x-1 w3a--text-xs w3a--font-medium w3a--px-4 w3a--py-3 w3a--text-app-gray-500 dark:w3a--text-app-gray-300 hover:w3a--bg-app-gray-200 dark:hover:w3a--bg-app-gray-700 w3a--h-12 w3a--rounded-2xl", {
48
+ "w3a--bg-app-gray-100 dark:w3a--bg-app-gray-800 w3a--border w3a--border-app-gray-200 dark:w3a--border-app-gray-700 w3a--text-app-gray-900 dark:w3a--text-app-white": selectedChain === chain.id
49
49
  }),
50
50
  onClick: () => setSelectedChain(chain.id),
51
51
  children: [chain.icon && /*#__PURE__*/jsx("img", {
52
52
  src: getIcons(isDark ? `${chain.icon}-dark` : `${chain.icon}-light`),
53
53
  alt: chain.name,
54
54
  className: "w3a--size-5 w3a--object-contain"
55
- }), t(chain.name)]
55
+ }), /*#__PURE__*/jsx("span", {
56
+ className: "first-letter:w3a--capitalize",
57
+ children: t(chain.name)
58
+ })]
56
59
  }, chain.id))
57
60
  });
58
61
  }
@@ -54,7 +54,7 @@ const ConnectWalletChainNamespaceSelect = props => {
54
54
  }) => /*#__PURE__*/jsx("li", {
55
55
  children: /*#__PURE__*/jsxs("button", {
56
56
  type: "button",
57
- className: "w3a--btn w3a--size-xl w3a--w-full w3a--items-center !w3a--justify-between w3a--rounded-full",
57
+ className: "w3a--btn w3a-external-wallet-btn w3a--h-12 w3a--w-full w3a--items-center !w3a--justify-between w3a--rounded-full",
58
58
  onClick: () => handleExternalWalletClick({
59
59
  connector: wallet.name,
60
60
  chainNamespace
@@ -75,6 +75,7 @@ const ConnectWalletChainNamespaceSelect = props => {
75
75
  })]
76
76
  }), /*#__PURE__*/jsx("img", {
77
77
  id: "external-wallet-arrow",
78
+ className: "w3a--icon-animation",
78
79
  src: getIcons(isDark ? "chevron-right-dark" : "chevron-right-light"),
79
80
  alt: "arrow"
80
81
  })]
@@ -225,20 +225,23 @@ function Root(props) {
225
225
  const deepLink = walletRegistryItem === null || walletRegistryItem === void 0 || (_walletRegistryItem$m2 = walletRegistryItem.mobile) === null || _walletRegistryItem$m2 === void 0 ? void 0 : _walletRegistryItem$m2.native;
226
226
  href = universalLink || deepLink;
227
227
  }
228
+
229
+ // determine the chain namespaces supported by the wallet
230
+ const connectorConfig = config[wallet];
231
+ const connectorChainNamespaces = (connectorConfig === null || connectorConfig === void 0 ? void 0 : connectorConfig.chainNamespaces) || [];
228
232
  const registryNamespaces = new Set((_walletRegistryItem$c = walletRegistryItem.chains) === null || _walletRegistryItem$c === void 0 ? void 0 : _walletRegistryItem$c.map(chain => chain.split(":")[0]));
229
233
  const injectedChainNamespaces = new Set((_walletRegistryItem$i = walletRegistryItem.injected) === null || _walletRegistryItem$i === void 0 ? void 0 : _walletRegistryItem$i.map(injected => injected.namespace));
230
- const availableChainNamespaces = chainNamespaces.filter(x => registryNamespaces.has(x) || injectedChainNamespaces.has(x));
231
- const connector = config[wallet];
234
+ const availableChainNamespaces = chainNamespaces.filter(x => registryNamespaces.has(x) || injectedChainNamespaces.has(x) || connectorChainNamespaces.includes(x));
232
235
  const button = {
233
236
  name: wallet,
234
237
  displayName: walletRegistryItem.name,
235
238
  href,
236
- hasInjectedWallet: (connector === null || connector === void 0 ? void 0 : connector.isInjected) || false,
239
+ hasInjectedWallet: (connectorConfig === null || connectorConfig === void 0 ? void 0 : connectorConfig.isInjected) || false,
237
240
  hasWalletConnect: isWalletConnectConnectorIncluded && ((_walletRegistryItem$w = walletRegistryItem.walletConnect) === null || _walletRegistryItem$w === void 0 || (_walletRegistryItem$w = _walletRegistryItem$w.sdks) === null || _walletRegistryItem$w === void 0 ? void 0 : _walletRegistryItem$w.includes("sign_v2")),
238
241
  hasInstallLinks: Object.keys(walletRegistryItem.app || {}).length > 0,
239
242
  walletRegistryItem,
240
243
  imgExtension: walletRegistryItem.imgExtension || "svg",
241
- icon: connector === null || connector === void 0 ? void 0 : connector.icon,
244
+ icon: connectorConfig === null || connectorConfig === void 0 ? void 0 : connectorConfig.icon,
242
245
  chainNamespaces: availableChainNamespaces
243
246
  };
244
247
  if (!button.hasInjectedWallet && !button.hasWalletConnect && !button.hasInstallLinks) return acc;
@@ -249,30 +252,23 @@ function Root(props) {
249
252
  }, [connectorVisibilityMap, chainNamespaces, config, deviceDetails.platform, isWalletConnectConnectorIncluded]);
250
253
  const installedConnectorButtons = useMemo(() => {
251
254
  const installedConnectors = Object.keys(config).reduce((acc, connector) => {
252
- var _walletRegistryItem$c2, _walletRegistryItem$i2, _config$connector, _config$connector2;
253
255
  if ([WALLET_CONNECTORS.WALLET_CONNECT_V2].includes(connector) || !connectorVisibilityMap[connector]) return acc;
254
-
255
- // determine chain namespaces based on wallet registry
256
- const walletRegistryItem = walletRegistry.default[connector];
257
- const registryNamespaces = new Set(walletRegistryItem === null || walletRegistryItem === void 0 || (_walletRegistryItem$c2 = walletRegistryItem.chains) === null || _walletRegistryItem$c2 === void 0 ? void 0 : _walletRegistryItem$c2.map(chain => chain.split(":")[0]));
258
- const injectedChainNamespaces = new Set(walletRegistryItem === null || walletRegistryItem === void 0 || (_walletRegistryItem$i2 = walletRegistryItem.injected) === null || _walletRegistryItem$i2 === void 0 ? void 0 : _walletRegistryItem$i2.map(injected => injected.namespace));
259
- const availableChainNamespaces = chainNamespaces.filter(x => registryNamespaces.has(x) || injectedChainNamespaces.has(x));
256
+ const connectorConfig = config[connector];
260
257
  acc.push({
261
258
  name: connector,
262
- displayName: config[connector].label || connector,
263
- hasInjectedWallet: ((_config$connector = config[connector]) === null || _config$connector === void 0 ? void 0 : _config$connector.isInjected) || false,
259
+ displayName: (connectorConfig === null || connectorConfig === void 0 ? void 0 : connectorConfig.label) || connector,
260
+ hasInjectedWallet: (connectorConfig === null || connectorConfig === void 0 ? void 0 : connectorConfig.isInjected) || false,
264
261
  hasWalletConnect: false,
265
262
  hasInstallLinks: false,
266
- walletRegistryItem,
267
- icon: (_config$connector2 = config[connector]) === null || _config$connector2 === void 0 ? void 0 : _config$connector2.icon,
268
- chainNamespaces: availableChainNamespaces
263
+ icon: connectorConfig === null || connectorConfig === void 0 ? void 0 : connectorConfig.icon,
264
+ chainNamespaces: (connectorConfig === null || connectorConfig === void 0 ? void 0 : connectorConfig.chainNamespaces) || []
269
265
  });
270
266
  return acc;
271
267
  }, []);
272
268
 
273
269
  // make metamask the first button and limit the number of buttons
274
270
  return installedConnectors;
275
- }, [config, connectorVisibilityMap, walletRegistry.default, chainNamespaces]);
271
+ }, [config, connectorVisibilityMap]);
276
272
  const customConnectorButtons = useMemo(() => {
277
273
  return installedConnectorButtons.filter(button => !button.hasInjectedWallet);
278
274
  }, [installedConnectorButtons]);
@@ -341,7 +337,7 @@ function Root(props) {
341
337
  }
342
338
  // Default
343
339
  return "539px";
344
- }, [isWalletDetailsExpanded, modalState.currentPage, isSocialLoginsExpanded, installedConnectorButtons, privacyPolicy, tncLink, enableMainSocialLoginButton, modalState.status]);
340
+ }, [privacyPolicy, tncLink, enableMainSocialLoginButton, modalState.status, modalState.currentPage, isWalletDetailsExpanded, isSocialLoginsExpanded, topInstalledConnectorButtons.length]);
345
341
  const contextValue = useMemo(() => ({
346
342
  bodyState,
347
343
  setBodyState,
@@ -59,7 +59,9 @@ function Widget(props) {
59
59
  stateListener.on("STATE_UPDATED", newModalState => {
60
60
  log.debug("state updated", newModalState);
61
61
  setModalState(prevState => {
62
- const mergedState = cloneDeep(deepmerge(prevState, newModalState));
62
+ const mergedState = cloneDeep(deepmerge(prevState, newModalState, {
63
+ arrayMerge: (_prevState, newState) => newState
64
+ }));
63
65
  return mergedState;
64
66
  });
65
67
  });