diff --git a/packages/demos/email-recovery/src/components/RequestGuardian.tsx b/packages/demos/email-recovery/src/components/RequestGuardian.tsx index 10c11d4a..a24aa6b4 100644 --- a/packages/demos/email-recovery/src/components/RequestGuardian.tsx +++ b/packages/demos/email-recovery/src/components/RequestGuardian.tsx @@ -106,28 +106,29 @@ const RequestGuardian = () => { subject ); - let checkGuardianAcceptanceInterval = null + // TODO Use polling instead + stepsContext?.setStep(STEPS.REQUESTED_RECOVERIES); - const checkGuardianAcceptance = async () => { - if (!requestId) { - throw new Error("missing guardian request id"); - } + // let checkGuardianAcceptanceInterval = null - const resBody = await relayer.requestStatus(requestId); - console.debug("guardian req res body", resBody); + // const checkGuardianAcceptance = async () => { + // if (!requestId) { + // throw new Error("missing guardian request id"); + // } - if(resBody?.is_success) { - stepsContext?.setStep(STEPS.REQUESTED_RECOVERIES); - checkGuardianAcceptanceInterval?.clearInterval() - } - } + // const resBody = await relayer.requestStatus(requestId); + // console.debug("guardian req res body", resBody); - checkGuardianAcceptanceInterval = setInterval(async () => { - const res = await checkGuardianAcceptance(); - console.log(res) - }, 5000); + // if(resBody?.is_success) { + // stepsContext?.setStep(STEPS.REQUESTED_RECOVERIES); + // checkGuardianAcceptanceInterval?.clearInterval() + // } + // } - // TODO poll until guard req is complete or fails + // checkGuardianAcceptanceInterval = setInterval(async () => { + // const res = await checkGuardianAcceptance(); + // console.log(res) + // }, 5000); }, [ address, firstSafeOwner, @@ -195,7 +196,7 @@ const RequestGuardian = () => { setRecoveryDelay(e.target.value)} /> diff --git a/packages/demos/email-recovery/src/components/RequestedRecoveries.tsx b/packages/demos/email-recovery/src/components/RequestedRecoveries.tsx index 42957c96..8a10d462 100644 --- a/packages/demos/email-recovery/src/components/RequestedRecoveries.tsx +++ b/packages/demos/email-recovery/src/components/RequestedRecoveries.tsx @@ -25,7 +25,7 @@ const BUTTON_STATES = { const RequestedRecoveries = () => { const isMobile = window.innerWidth < 768; const { address } = useAccount(); - const { guardianEmail, setGuardianEmail } = useAppContext(); + const { guardianEmail } = useAppContext(); const stepsContext = useContext(StepsContext); const [newOwner, setNewOwner] = useState(); @@ -71,31 +71,28 @@ const RequestedRecoveries = () => { setGuardianRequestId(requestId); + setLoading(false); + setButtonState(BUTTON_STATES.COMPLETE_RECOVERY); - let checkRequestRecoveryStatusInterval = null - - const checkGuardianAcceptance = async () => { - if (!requestId) { - throw new Error("missing guardian request id"); - } - - const resBody = await relayer.requestStatus(requestId); - console.debug("guardian req res body", resBody); + // let checkRequestRecoveryStatusInterval = null - if(resBody?.is_success) { - stepsContext?.setStep(STEPS.REQUESTED_RECOVERIES); - checkRequestRecoveryStatusInterval?.clearInterval() - } - } + // const checkGuardianAcceptance = async () => { + // if (!requestId) { + // throw new Error("missing guardian request id"); + // } - checkRequestRecoveryStatusInterval = setInterval(async () => { - const res = await checkGuardianAcceptance(); - console.log(res) - }, 5000); + // const resBody = await relayer.requestStatus(requestId); + // console.debug("guardian req res body", resBody); + // if(resBody?.is_success) { + // checkRequestRecoveryStatusInterval?.clearInterval() + // } + // } - setLoading(false); - setButtonState(BUTTON_STATES.COMPLETE_RECOVERY); + // checkRequestRecoveryStatusInterval = setInterval(async () => { + // const res = await checkGuardianAcceptance(); + // console.log(res) + // }, 5000); }, [recoveryRouterAddr, address, guardianEmail, newOwner]); const completeRecovery = useCallback(async () => { @@ -112,14 +109,14 @@ const RequestedRecoveries = () => { setButtonState(BUTTON_STATES.RECOVERY_COMPLETED); }, [recoveryRouterAddr]); - const checkGuardianAcceptance = useCallback(async () => { - if (!gurdianRequestId) { - throw new Error("missing guardian request id"); - } + // const checkGuardianAcceptance = useCallback(async () => { + // if (!gurdianRequestId) { + // throw new Error("missing guardian request id"); + // } - const resBody = await relayer.requestStatus(gurdianRequestId); - console.debug("guardian req res body", resBody); - }, [gurdianRequestId]); + // const resBody = await relayer.requestStatus(gurdianRequestId); + // console.debug("guardian req res body", resBody); + // }, [gurdianRequestId]); const getButtonComponent = () => { switch (buttonState) { @@ -236,7 +233,7 @@ const RequestedRecoveries = () => { style={{ width: "100%" }} type="email" value={guardianEmail} - onChange={(e) => setGuardianEmail(e.target.value)} + readOnly={true} />