Skip to content

Commit 6b85d3c

Browse files
authored
Merge pull request #337 from pendulum-chain/fix-restore-offramp
Fix restoring offramp after a refresh
2 parents d632cb4 + 8b6e457 commit 6b85d3c

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

src/hooks/offramp/useMainProcess.ts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { OFFRAMPING_PHASE_SECONDS } from '../../pages/progress';
1010
import { createTransactionEvent, useEventsContext } from '../../contexts/events';
1111
import { useAssetHubNode, usePendulumNode } from '../../contexts/polkadotNode';
1212
import { usePolkadotWalletState } from '../../contexts/polkadotWallet';
13-
import { useNetwork } from '../../contexts/network';
13+
import { Networks, useNetwork } from '../../contexts/network';
1414

1515
import {
1616
clearOfframpingState,
@@ -129,10 +129,6 @@ export const useMainProcess = () => {
129129
setSigningPhase,
130130
]);
131131

132-
useEffect(() => {
133-
setOnSelectedNetworkChange(resetOfframpingState);
134-
}, [setOnSelectedNetworkChange, resetOfframpingState]);
135-
136132
const handleOnAnchorWindowOpen = useCallback(async () => {
137133
if (!pendulumNode) {
138134
console.error('Pendulum node not initialized');
@@ -144,7 +140,7 @@ export const useMainProcess = () => {
144140

145141
const finishOfframping = useCallback(() => {
146142
(async () => {
147-
await clearOfframpingState();
143+
clearOfframpingState();
148144
resetUniqueEvents();
149145
setOfframpingStarted(false);
150146
updateHookStateFromState(undefined);
@@ -157,7 +153,8 @@ export const useMainProcess = () => {
157153
}, [updateHookStateFromState, offrampingState]);
158154

159155
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;
161158

162159
(async () => {
163160
if (!pendulumNode || !assetHubNode) {
@@ -179,11 +176,17 @@ export const useMainProcess = () => {
179176
updateHookStateFromState(nextState);
180177
}
181178
})();
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.
185179
// 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+
]);
187190

188191
const maybeCancelSep24First = useCallback(() => {
189192
if (firstSep24IntervalRef.current !== undefined) {

src/services/phases/polkadot/spacewalk.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ export class VaultService {
151151
options.era = 0;
152152

153153
const stellarPkBytes = Uint8Array.from(stellarPkBytesBuffer);
154-
155154
return this.apiComponents!.api.tx.redeem.requestRedeem(amountRaw, stellarPkBytes, this.vaultId!).signAsync(
156155
addressOrPair,
157156
options,

0 commit comments

Comments
 (0)