Skip to content

Commit

Permalink
fix bug where clearing manual recipient address input would keep cosm…
Browse files Browse the repository at this point in the history
…os address from updating
  • Loading branch information
steezeburger committed Dec 11, 2024
1 parent 8a7e4da commit ffc0b04
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
5 changes: 2 additions & 3 deletions web/src/features/EthWallet/hooks/useEvmChainSelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
19 changes: 8 additions & 11 deletions web/src/features/KeplrWallet/hooks/useIbcChainSelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<string | null>(
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);
Expand Down Expand Up @@ -166,7 +163,7 @@ export function useIbcChainSelection(ibcChains: IbcChains) {
isLoadingIbcBalance,

connectCosmosWallet,
getCosmosSigningClient: getSigningStargateClient,
getCosmosSigningClient,
resetState,
};
}

0 comments on commit ffc0b04

Please sign in to comment.