Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Commit

Permalink
Remove status checks, few other tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
jacque006 committed Apr 10, 2024
1 parent 2e9ed6b commit eed9cba
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 47 deletions.
37 changes: 19 additions & 18 deletions packages/demos/email-recovery/src/components/RequestGuardian.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -195,7 +196,7 @@ const RequestGuardian = () => {
<input
style={{ width: "1.875rem", marginLeft: "1rem" }}
type="number"
min={0}
min={1}
value={recoveryDelay}
onChange={(e) => setRecoveryDelay(e.target.value)}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>();
Expand Down Expand Up @@ -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 () => {
Expand All @@ -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) {
Expand Down Expand Up @@ -236,7 +233,7 @@ const RequestedRecoveries = () => {
style={{ width: "100%" }}
type="email"
value={guardianEmail}
onChange={(e) => setGuardianEmail(e.target.value)}
readOnly={true}
/>
</div>
<div
Expand Down

0 comments on commit eed9cba

Please sign in to comment.