From 594fe36af15022b630a5216795c91bd8326dc9ad Mon Sep 17 00:00:00 2001 From: yuli-ferna Date: Tue, 28 May 2024 11:56:48 -0400 Subject: [PATCH] Changes --- src/components/Attest/index.tsx | 4 +++- src/components/Recovery.tsx | 5 +++-- src/store/attestSlice.ts | 6 ++++++ src/store/selectors.ts | 4 +++- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/components/Attest/index.tsx b/src/components/Attest/index.tsx index e7657e015..2ad8afc93 100644 --- a/src/components/Attest/index.tsx +++ b/src/components/Attest/index.tsx @@ -16,6 +16,7 @@ import { selectAttestActiveStep, selectAttestIsCreateComplete, selectAttestIsCreating, + selectAttestIsRecovery, selectAttestIsSendComplete, selectAttestIsSending, } from "../../store/selectors"; @@ -43,6 +44,7 @@ function Attest() { const isSendComplete = useSelector(selectAttestIsSendComplete); const isCreating = useSelector(selectAttestIsCreating); const isCreateComplete = useSelector(selectAttestIsCreateComplete); + const isRecovery = useSelector(selectAttestIsRecovery) const preventNavigation = (isSending || isSendComplete || isCreating) && !isCreateComplete; useEffect(() => { @@ -97,7 +99,7 @@ function Attest() { 2. Target - {activeStep === 1 ? : } + {((activeStep === 1 || isRecovery) && !isCreating && !isCreateComplete) ? : } = 2} disabled={isSendComplete}> diff --git a/src/components/Recovery.tsx b/src/components/Recovery.tsx index 2da2a2760..3b1864b4f 100644 --- a/src/components/Recovery.tsx +++ b/src/components/Recovery.tsx @@ -127,7 +127,7 @@ import { getSeiWasmClient, parseRawLog, searchInLogs } from "../utils/sei"; import { useVaaVerifier } from "../hooks/useVaaVerifier"; import ChainWarningMessage from "./ChainWarningMessage"; import { useDeepLinkRecoveryParams } from "../hooks/useDeepLinkRecoveryParams"; -import { setSignedVAAHex, setTargetChain } from "../store/attestSlice"; +import { setIsRecovery, setSignedVAAHex, setSourceChain } from "../store/attestSlice"; const NOT_SUPPORTED_VAA_WARNING_MESSAGE = ( <> @@ -951,7 +951,8 @@ export default function Recovery() { const handleRecoverClickBase = useCallback( (useRelayer: boolean) => { if (isTokenBridgetAttest) { - dispatch(setTargetChain(CHAIN_ID_SCROLL)); + dispatch(setSourceChain(recoverySourceChain)); + dispatch(setIsRecovery(true)); dispatch(setSignedVAAHex(recoverySignedVAA)); push("/register"); } else if ( diff --git a/src/store/attestSlice.ts b/src/store/attestSlice.ts index 17d664260..64cb747eb 100644 --- a/src/store/attestSlice.ts +++ b/src/store/attestSlice.ts @@ -19,6 +19,7 @@ export interface AttestState { signedVAAHex: string | undefined; isSending: boolean; isCreating: boolean; + isRecovery: boolean; createTx: Transaction | undefined; } @@ -31,6 +32,7 @@ const initialState: AttestState = { signedVAAHex: undefined, isSending: false, isCreating: false, + isRecovery: false, createTx: undefined, }; @@ -78,6 +80,9 @@ export const attestSlice = createSlice({ setIsSending: (state, action: PayloadAction) => { state.isSending = action.payload; }, + setIsRecovery: (state, action: PayloadAction) => { + state.isRecovery = action.payload; + }, setIsCreating: (state, action: PayloadAction) => { state.isCreating = action.payload; }, @@ -103,6 +108,7 @@ export const { setAttestTx, setSignedVAAHex, setIsSending, + setIsRecovery, setIsCreating, setCreateTx, reset, diff --git a/src/store/selectors.ts b/src/store/selectors.ts index ea26a4a51..905a97f43 100644 --- a/src/store/selectors.ts +++ b/src/store/selectors.ts @@ -29,6 +29,8 @@ export const selectAttestIsSending = (state: RootState) => state.attest.isSending; export const selectAttestIsCreating = (state: RootState) => state.attest.isCreating; +export const selectAttestIsRecovery = (state: RootState) => + state.attest.isRecovery; export const selectAttestCreateTx = (state: RootState) => state.attest.createTx; export const selectAttestIsSourceComplete = (state: RootState) => !!state.attest.sourceChain && !!state.attest.sourceAsset; @@ -40,7 +42,7 @@ export const selectAttestIsSendComplete = (state: RootState) => export const selectAttestIsCreateComplete = (state: RootState) => !!selectAttestCreateTx(state); export const selectAttestShouldLockFields = (state: RootState) => - selectAttestIsSending(state) || selectAttestIsSendComplete(state); + (selectAttestIsSending(state) || selectAttestIsSendComplete(state)) && !selectAttestIsRecovery(state); /* * NFT