diff --git a/web/src/features/EthWallet/hooks/useEvmChainSelection.tsx b/web/src/features/EthWallet/hooks/useEvmChainSelection.tsx index 786da29..ea180cd 100644 --- a/web/src/features/EthWallet/hooks/useEvmChainSelection.tsx +++ b/web/src/features/EthWallet/hooks/useEvmChainSelection.tsx @@ -37,11 +37,10 @@ export function useEvmChainSelection(evmChains: EvmChains) { null, ); useEffect(() => { - if (userAccount?.address) { + if (selectedEvmChain && userAccount?.address) { setEvmAccountAddress(userAccount.address); } - }, [userAccount.address]); - + }, [userAccount.address, selectedEvmChain, selectedEvmCurrency]); const resetState = useCallback(() => { setSelectedEvmChain(null); setSelectedEvmCurrency(null); diff --git a/web/src/features/KeplrWallet/hooks/useIbcChainSelection.tsx b/web/src/features/KeplrWallet/hooks/useIbcChainSelection.tsx index 8b358aa..9ebcb80 100644 --- a/web/src/features/KeplrWallet/hooks/useIbcChainSelection.tsx +++ b/web/src/features/KeplrWallet/hooks/useIbcChainSelection.tsx @@ -31,26 +31,23 @@ export function useIbcChainSelection(ibcChains: IbcChains) { selectedIbcChain?.chainId || defaultChainId, ); const { - address, + address: cosmosAddressFromWallet, openView: openCosmosWalletModal, - getSigningStargateClient, + getSigningStargateClient: getCosmosSigningClient, } = useChain(chainName); // we are keeping track of the address ourselves so that we can clear it if needed, // e.g. to allow for manual address entry - // FIXME - is this still needed? const [ibcAccountAddress, setIbcAccountAddress] = useState( null, ); - - // FIXME - is this still needed? useEffect(() => { - if (address) { - setIbcAccountAddress(address); + // make sure the address is set when + // the address, chain, or currency change + if (selectedIbcChain && cosmosAddressFromWallet) { + setIbcAccountAddress(cosmosAddressFromWallet); } - }, [address]); - - // FIXME - is this still needed? + }, [cosmosAddressFromWallet, selectedIbcChain, selectedIbcCurrency]); const resetState = useCallback(() => { setSelectedIbcChain(null); setSelectedIbcCurrency(null); @@ -166,7 +163,7 @@ export function useIbcChainSelection(ibcChains: IbcChains) { isLoadingIbcBalance, connectCosmosWallet, - getCosmosSigningClient: getSigningStargateClient, + getCosmosSigningClient, resetState, }; }