@@ -10,7 +10,7 @@ import { OFFRAMPING_PHASE_SECONDS } from '../../pages/progress';
10
10
import { createTransactionEvent , useEventsContext } from '../../contexts/events' ;
11
11
import { useAssetHubNode , usePendulumNode } from '../../contexts/polkadotNode' ;
12
12
import { usePolkadotWalletState } from '../../contexts/polkadotWallet' ;
13
- import { useNetwork } from '../../contexts/network' ;
13
+ import { Networks , useNetwork } from '../../contexts/network' ;
14
14
15
15
import {
16
16
clearOfframpingState ,
@@ -129,10 +129,6 @@ export const useMainProcess = () => {
129
129
setSigningPhase ,
130
130
] ) ;
131
131
132
- useEffect ( ( ) => {
133
- setOnSelectedNetworkChange ( resetOfframpingState ) ;
134
- } , [ setOnSelectedNetworkChange , resetOfframpingState ] ) ;
135
-
136
132
const handleOnAnchorWindowOpen = useCallback ( async ( ) => {
137
133
if ( ! pendulumNode ) {
138
134
console . error ( 'Pendulum node not initialized' ) ;
@@ -144,7 +140,7 @@ export const useMainProcess = () => {
144
140
145
141
const finishOfframping = useCallback ( ( ) => {
146
142
( async ( ) => {
147
- await clearOfframpingState ( ) ;
143
+ clearOfframpingState ( ) ;
148
144
resetUniqueEvents ( ) ;
149
145
setOfframpingStarted ( false ) ;
150
146
updateHookStateFromState ( undefined ) ;
@@ -157,7 +153,8 @@ export const useMainProcess = () => {
157
153
} , [ updateHookStateFromState , offrampingState ] ) ;
158
154
159
155
useEffect ( ( ) => {
160
- if ( wagmiConfig . state . status !== 'connected' ) return ;
156
+ if ( selectedNetwork == Networks . Polygon && wagmiConfig . state . status !== 'connected' ) return ;
157
+ if ( selectedNetwork == Networks . AssetHub && ! walletAccount ?. address ) return ;
161
158
162
159
( async ( ) => {
163
160
if ( ! pendulumNode || ! assetHubNode ) {
@@ -179,11 +176,17 @@ export const useMainProcess = () => {
179
176
updateHookStateFromState ( nextState ) ;
180
177
}
181
178
} ) ( ) ;
182
- // This effect has dependencies that are used inside the async function (assetHubNode, pendulumNode, walletAccount)
183
- // but we intentionally exclude them from the dependency array to prevent unnecessary re-renders.
184
- // These dependencies are stable and won't change during the lifecycle of this hook.
185
179
// eslint-disable-next-line react-hooks/exhaustive-deps
186
- } , [ offrampingState , trackEvent , updateHookStateFromState , wagmiConfig ] ) ;
180
+ } , [
181
+ offrampingState ,
182
+ trackEvent ,
183
+ updateHookStateFromState ,
184
+ wagmiConfig ,
185
+ pendulumNode ,
186
+ assetHubNode ,
187
+ wagmiConfig . state . status ,
188
+ walletAccount ?. address ,
189
+ ] ) ;
187
190
188
191
const maybeCancelSep24First = useCallback ( ( ) => {
189
192
if ( firstSep24IntervalRef . current !== undefined ) {
0 commit comments