Skip to content

Commit 1ee6ee9

Browse files
fix: use correct destination chain and address for ibc withdraw (#2016)
1 parent 494e065 commit 1ee6ee9

File tree

3 files changed

+31
-24
lines changed

3 files changed

+31
-24
lines changed

apps/namadillo/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@namada/namadillo",
3-
"version": "1.20.0",
3+
"version": "1.20.0-hotfix2",
44
"description": "Namadillo",
55
"repository": "https://github.com/anoma/namada-interface/",
66
"author": "Heliax Dev <info@heliax.dev>",

apps/namadillo/src/App/Ibc/IbcWithdraw.tsx

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -130,21 +130,24 @@ export const IbcWithdraw = (): JSX.Element => {
130130
}
131131
};
132132

133-
const updateDestinationChainAndAddress = (chain: Chain | undefined): void => {
133+
const updateDestinationChainAndAddress = async (
134+
chain: Chain | undefined
135+
): Promise<void> => {
134136
setDestinationChain(chain);
135137
if (customAddress) {
136138
setCustomAddress("");
137139
}
138140
if (chain) {
139-
loadWalletAddress(chain?.chain_id);
141+
await connectToChainId(chain.chain_id);
142+
await loadWalletAddress(chain.chain_id);
140143
}
141144
};
142145

143146
const {
144147
data: ibcChannels,
145148
isError: unknownIbcChannels,
146149
isLoading: isLoadingIbcChannels,
147-
} = useAtomValue(ibcChannelsFamily(registry?.chain.chain_name));
150+
} = useAtomValue(ibcChannelsFamily(destinationChain?.chain_name));
148151

149152
useEffect(() => {
150153
setSourceChannel(ibcChannels?.namadaChannel || "");
@@ -154,23 +157,25 @@ export const IbcWithdraw = (): JSX.Element => {
154157
// to other chains different than the original one. Ex: OSMO should only be withdrew to Osmosis,
155158
// ATOM to Cosmoshub, etc.
156159
useEffect(() => {
157-
if (!selectedAsset || !chainTokens.data) {
158-
updateDestinationChainAndAddress(undefined);
159-
return;
160-
}
160+
(async () => {
161+
if (!selectedAsset || !chainTokens.data) {
162+
await updateDestinationChainAndAddress(undefined);
163+
return;
164+
}
161165

162-
const token = chainTokens.data.find(
163-
(token) => token.address === selectedAsset.originalAddress
164-
);
166+
const token = chainTokens.data.find(
167+
(token) => token.address === selectedAsset.originalAddress
168+
);
165169

166-
if (token && "trace" in token) {
167-
const denom = getDenomFromIbcTrace(token.trace);
168-
const chain = searchChainByDenom(denom);
169-
updateDestinationChainAndAddress(chain);
170-
return;
171-
}
170+
if (token && "trace" in token) {
171+
const denom = getDenomFromIbcTrace(token.trace);
172+
const chain = searchChainByDenom(denom);
173+
await updateDestinationChainAndAddress(chain);
174+
return;
175+
}
172176

173-
updateDestinationChainAndAddress(undefined);
177+
await updateDestinationChainAndAddress(undefined);
178+
})();
174179
}, [selectedAsset, chainTokens.data]);
175180

176181
const {

apps/namadillo/src/hooks/useWalletManager.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,14 @@ export const useWalletManager = (wallet: WalletConnector): UseWalletOutput => {
2929
const isConnected = connectedWallets[walletKey];
3030

3131
useEffect(() => {
32-
if (isConnected && chainId) {
33-
connectToChainId(chainId);
34-
} else {
35-
setWalletAddress(undefined);
36-
setRegistry(undefined);
37-
}
32+
(async () => {
33+
if (isConnected && chainId) {
34+
await connectToChainId(chainId);
35+
} else {
36+
setWalletAddress(undefined);
37+
setRegistry(undefined);
38+
}
39+
})();
3840
}, [isConnected, walletKey, chainId]);
3941

4042
const connectToChainId = async (chainId: string): Promise<void> => {

0 commit comments

Comments
 (0)