@@ -130,21 +130,24 @@ export const IbcWithdraw = (): JSX.Element => {
130
130
}
131
131
} ;
132
132
133
- const updateDestinationChainAndAddress = ( chain : Chain | undefined ) : void => {
133
+ const updateDestinationChainAndAddress = async (
134
+ chain : Chain | undefined
135
+ ) : Promise < void > => {
134
136
setDestinationChain ( chain ) ;
135
137
if ( customAddress ) {
136
138
setCustomAddress ( "" ) ;
137
139
}
138
140
if ( chain ) {
139
- loadWalletAddress ( chain ?. chain_id ) ;
141
+ await connectToChainId ( chain . chain_id ) ;
142
+ await loadWalletAddress ( chain . chain_id ) ;
140
143
}
141
144
} ;
142
145
143
146
const {
144
147
data : ibcChannels ,
145
148
isError : unknownIbcChannels ,
146
149
isLoading : isLoadingIbcChannels ,
147
- } = useAtomValue ( ibcChannelsFamily ( registry ?. chain . chain_name ) ) ;
150
+ } = useAtomValue ( ibcChannelsFamily ( destinationChain ? .chain_name ) ) ;
148
151
149
152
useEffect ( ( ) => {
150
153
setSourceChannel ( ibcChannels ?. namadaChannel || "" ) ;
@@ -154,23 +157,25 @@ export const IbcWithdraw = (): JSX.Element => {
154
157
// to other chains different than the original one. Ex: OSMO should only be withdrew to Osmosis,
155
158
// ATOM to Cosmoshub, etc.
156
159
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
+ }
161
165
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
+ ) ;
165
169
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
+ }
172
176
173
- updateDestinationChainAndAddress ( undefined ) ;
177
+ await updateDestinationChainAndAddress ( undefined ) ;
178
+ } ) ( ) ;
174
179
} , [ selectedAsset , chainTokens . data ] ) ;
175
180
176
181
const {
0 commit comments