Skip to content

Commit f492382

Browse files
minor fixes
1 parent 6204b4b commit f492382

File tree

14 files changed

+35
-32
lines changed

14 files changed

+35
-32
lines changed

packages/modal/src/react/Web3AuthProvider.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ import { Web3AuthInnerContext, Web3AuthInnerProvider } from "./context/Web3AuthI
55
import { Web3AuthProviderProps } from "./interfaces";
66

77
export function Web3AuthProvider({ config, children }: PropsWithChildren<Web3AuthProviderProps>) {
8-
return createElement(Web3AuthInnerProvider, { config }, createElement(WalletServicesContextProvider, { context: Web3AuthInnerContext }, children));
8+
const pluginChild = createElement(WalletServicesContextProvider, { context: Web3AuthInnerContext }, children);
9+
return createElement(Web3AuthInnerProvider, { config }, pluginChild);
910
}

packages/modal/src/react/context/WalletServicesInnerContext.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export function WalletServicesContextProvider({ children, context }: PropsWithCh
2424
useEffect(() => {
2525
if (isConnected) {
2626
const plugin = getPlugin(EVM_PLUGINS.WALLET_SERVICES) as WalletServicesPluginType;
27-
if (!walletServicesPlugin) setWalletServicesPlugin(plugin);
27+
setWalletServicesPlugin(plugin);
2828
// when rehydrating, the connectedListener may be registered after the connected event is emitted, we need to check the status here
2929
if (plugin?.status === CONNECTOR_STATUS.CONNECTED) setReady(true);
3030
}

packages/modal/src/react/hooks/useCheckout.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ export const useCheckout = (): IUseCheckout => {
1717

1818
const showCheckout = useCallback(
1919
async (showCheckoutParams?: BaseEmbedControllerState["showCheckout"]) => {
20-
if (!plugin) throw WalletServicesPluginError.notInitialized();
21-
if (!ready) throw WalletServicesPluginError.walletPluginNotConnected();
22-
2320
setLoading(true);
2421
setError(null);
2522
try {
23+
if (!plugin) throw WalletServicesPluginError.notInitialized();
24+
if (!ready) throw WalletServicesPluginError.walletPluginNotConnected();
25+
2626
await plugin.showCheckout(showCheckoutParams);
2727
} catch (error) {
2828
setError(error as Web3AuthError);

packages/modal/src/react/hooks/useSwap.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ export const useSwap = (): IUseSwap => {
1717

1818
const showSwap = useCallback(
1919
async (showSwapParams?: BaseEmbedControllerState["showSwap"]) => {
20-
if (!plugin) throw WalletServicesPluginError.notInitialized();
21-
if (!ready) throw WalletServicesPluginError.walletPluginNotConnected();
22-
2320
setLoading(true);
2421
setError(null);
2522
try {
23+
if (!plugin) throw WalletServicesPluginError.notInitialized();
24+
if (!ready) throw WalletServicesPluginError.walletPluginNotConnected();
25+
2626
await plugin.showSwap(showSwapParams);
2727
} catch (error) {
2828
setError(error as Web3AuthError);

packages/modal/src/react/hooks/useWalletConnectScanner.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ export const useWalletConnectScanner = (): IUseWalletConnectScanner => {
1717

1818
const showWalletConnectScanner = useCallback(
1919
async (showWalletConnectScannerParams?: BaseEmbedControllerState["showWalletConnect"]) => {
20-
if (!plugin) throw WalletServicesPluginError.notInitialized();
21-
if (!ready) throw WalletServicesPluginError.walletPluginNotConnected();
22-
2320
setLoading(true);
2421
setError(null);
2522
try {
23+
if (!plugin) throw WalletServicesPluginError.notInitialized();
24+
if (!ready) throw WalletServicesPluginError.walletPluginNotConnected();
25+
2626
await plugin.showWalletConnectScanner(showWalletConnectScannerParams);
2727
} catch (error) {
2828
setError(error as Web3AuthError);

packages/modal/src/react/hooks/useWalletUI.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ export const useWalletUI = (): IUseWalletUI => {
1717

1818
const showWalletUI = useCallback(
1919
async (showWalletUiParams?: BaseEmbedControllerState["showWalletUi"]) => {
20-
if (!plugin) throw WalletServicesPluginError.notInitialized();
21-
if (!ready) throw WalletServicesPluginError.walletPluginNotConnected();
22-
2320
setLoading(true);
2421
setError(null);
2522
try {
23+
if (!plugin) throw WalletServicesPluginError.notInitialized();
24+
if (!ready) throw WalletServicesPluginError.walletPluginNotConnected();
25+
2626
await plugin.showWalletUi(showWalletUiParams);
2727
} catch (error) {
2828
setError(error as Web3AuthError);

packages/modal/src/react/wagmi/provider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export function WagmiProvider({ children, ...props }: PropsWithChildren<WagmiPro
132132

133133
const wagmiChains: Chain[] = [];
134134
if (web3Auth?.coreOptions?.chains) {
135-
const defaultChainId = web3Auth.coreOptions.defaultChainId;
135+
const defaultChainId = web3Auth.currentChain?.chainId;
136136
const chains = web3Auth.coreOptions.chains;
137137
chains.forEach((chain) => {
138138
const wagmiChain = defineChain({

packages/modal/src/ui/components/ConnectWallet/ConnectWallet.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,12 @@ function ConnectWallet(props: ConnectWalletProps) {
8787

8888
const installedWalletButtons = useMemo(() => {
8989
const visibilityMap = connectorVisibilityMap;
90-
return Object.keys(config).reduce((acc, adapter) => {
91-
if (adapter !== WALLET_CONNECTORS.WALLET_CONNECT_V2 && visibilityMap[adapter]) {
90+
return Object.keys(config).reduce((acc, localConnector) => {
91+
if (localConnector !== WALLET_CONNECTORS.WALLET_CONNECT_V2 && visibilityMap[localConnector]) {
9292
acc.push({
93-
name: adapter,
94-
displayName: config[adapter as WALLET_CONNECTOR_TYPE].label || adapter,
95-
hasInjectedWallet: config[adapter as WALLET_CONNECTOR_TYPE].isInjected,
93+
name: localConnector,
94+
displayName: config[localConnector as WALLET_CONNECTOR_TYPE].label || localConnector,
95+
hasInjectedWallet: config[localConnector as WALLET_CONNECTOR_TYPE].isInjected,
9696
hasWalletConnect: false,
9797
hasInstallLinks: false,
9898
});

packages/no-modal/src/react/no-modal/Web3AuthProvider.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ import { Web3AuthInnerContext, Web3AuthInnerProvider } from "./context/Web3AuthI
55
import { Web3AuthProviderProps } from "./interfaces";
66

77
export function Web3AuthProvider({ config, children }: PropsWithChildren<Web3AuthProviderProps>) {
8-
return createElement(Web3AuthInnerProvider, { config }, createElement(WalletServicesContextProvider, { context: Web3AuthInnerContext }, children));
8+
const pluginChild = createElement(WalletServicesContextProvider, { context: Web3AuthInnerContext }, children);
9+
return createElement(Web3AuthInnerProvider, { config }, pluginChild);
910
}

packages/no-modal/src/react/no-modal/context/WalletServicesInnerContext.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export function WalletServicesContextProvider({ children, context }: PropsWithCh
2525
useEffect(() => {
2626
if (isConnected) {
2727
const plugin = getPlugin(EVM_PLUGINS.WALLET_SERVICES) as WalletServicesPluginType;
28-
if (!walletServicesPlugin) setWalletServicesPlugin(plugin);
28+
setWalletServicesPlugin(plugin);
2929
// when rehydrating, the connectedListener may be registered after the connected event is emitted, we need to check the status here
3030
if (plugin?.status === CONNECTOR_STATUS.CONNECTED) setReady(true);
3131
}

0 commit comments

Comments
 (0)