Skip to content

Commit

Permalink
Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
yuli-ferna committed May 28, 2024
1 parent d506253 commit 594fe36
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/components/Attest/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
selectAttestActiveStep,
selectAttestIsCreateComplete,
selectAttestIsCreating,
selectAttestIsRecovery,
selectAttestIsSendComplete,
selectAttestIsSending,
} from "../../store/selectors";
Expand Down Expand Up @@ -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(() => {
Expand Down Expand Up @@ -97,7 +99,7 @@ function Attest() {
2. Target
</StepButton>
<StepContent>
{activeStep === 1 ? <Target /> : <TargetPreview />}
{((activeStep === 1 || isRecovery) && !isCreating && !isCreateComplete) ? <Target /> : <TargetPreview />}
</StepContent>
</Step>
<Step expanded={activeStep >= 2} disabled={isSendComplete}>
Expand Down
5 changes: 3 additions & 2 deletions src/components/Recovery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
<>
Expand Down Expand Up @@ -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 (
Expand Down
6 changes: 6 additions & 0 deletions src/store/attestSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export interface AttestState {
signedVAAHex: string | undefined;
isSending: boolean;
isCreating: boolean;
isRecovery: boolean;
createTx: Transaction | undefined;
}

Expand All @@ -31,6 +32,7 @@ const initialState: AttestState = {
signedVAAHex: undefined,
isSending: false,
isCreating: false,
isRecovery: false,
createTx: undefined,
};

Expand Down Expand Up @@ -78,6 +80,9 @@ export const attestSlice = createSlice({
setIsSending: (state, action: PayloadAction<boolean>) => {
state.isSending = action.payload;
},
setIsRecovery: (state, action: PayloadAction<boolean>) => {
state.isRecovery = action.payload;
},
setIsCreating: (state, action: PayloadAction<boolean>) => {
state.isCreating = action.payload;
},
Expand All @@ -103,6 +108,7 @@ export const {
setAttestTx,
setSignedVAAHex,
setIsSending,
setIsRecovery,
setIsCreating,
setCreateTx,
reset,
Expand Down
4 changes: 3 additions & 1 deletion src/store/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down

0 comments on commit 594fe36

Please sign in to comment.