Skip to content

Commit

Permalink
Refactoring changes and bug fixes
Browse files Browse the repository at this point in the history
- Add error message on 502
- Fix refresh of page on polling
  • Loading branch information
wryonik committed Sep 14, 2024
1 parent 824e12e commit 462c278
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 109 deletions.
2 changes: 1 addition & 1 deletion src/components/GuardianSetup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ const GuardianSetup = () => {
);
return (
<Box sx={{ marginX: "auto", marginTop: "100px", marginBottom: "100px" }}>
<Typography variant="h1" sx={{ paddingBottom: "1.5rem" }}>
<Typography variant="h2" sx={{ paddingBottom: "1.5rem" }}>
Set Up Guardian Details
</Typography>
<Typography variant="h6" sx={{ paddingBottom: "5rem" }}>
Expand Down
16 changes: 4 additions & 12 deletions src/components/burnerWallet/GuardianSetup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ const GuardianSetup = () => {

const checkIfRecoveryIsConfigured = async () => {
if (!address) {
toast.error("Please connect wallet");
return;
}
setIsAccountInitializedLoading(true);
Expand Down Expand Up @@ -318,7 +317,7 @@ const GuardianSetup = () => {
}, 5000); // Adjust the interval time (in milliseconds) as needed
} catch (err) {
console.log(err);
toast.error(err.shortMessage);
toast.error(err?.shortMessage ?? "Something went wrong, please try again.");
setLoading(false);
}
}, [
Expand All @@ -333,16 +332,9 @@ const GuardianSetup = () => {
stepsContext,
]);

if (isAccountInitializedLoading) {
return <Loader />;
}
console.log(
recoveryDelay * TIME_UNITS[recoveryDelayUnit].multiplier,
recoveryExpiry * TIME_UNITS[recoveryExpiryUnit].multiplier
);
return (
<Box sx={{ marginX: "auto", marginTop: "100px", marginBottom: "100px" }}>
<Typography variant="h1" sx={{ paddingBottom: "1.5rem" }}>
<Typography variant="h2" sx={{ paddingBottom: "1.5rem" }}>
Set Up Guardian Details
</Typography>
<Typography variant="h6" sx={{ paddingBottom: "5rem" }}>
Expand Down Expand Up @@ -430,7 +422,7 @@ const GuardianSetup = () => {
/>
</Box> */}

<Grid
{/* <Grid
item
container
gap="1rem"
Expand All @@ -439,7 +431,7 @@ const GuardianSetup = () => {
>
<Typography variant="body1">Connected Wallet:</Typography>
<ConnectKitButton />
</Grid>
</Grid> */}
</Grid>
<Grid item sx={{ borderRight: { md: "1px solid #EBEBEB" } }} />

Expand Down
65 changes: 0 additions & 65 deletions src/components/burnerWallet/RequestedRecoveries.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -342,71 +342,6 @@ const RequestedRecoveries = () => {
gap: "2rem",
}}
>
<div
style={{
display: "flex",
width: "100%",
flexDirection: "column",
gap: "1rem",
}}
>
<div
style={{
display: "flex",
flexDirection: "row",
justifyContent: "center",
alignItems: "center",
gap: "1rem",
}}
>
{buttonState === BUTTON_STATES.RECOVERY_COMPLETED ? (
<Box
width="100%"
height="100px"
alignContent="center"
justifyItems="center"
borderRadius={3}
sx={{
position: "relative",
}}
>
<ConnectedWalletCard address={address} />
<div
style={{
display: "flex",
background: "#E7FDED",
border: "1px solid #6DD88B",
color: "#0A6825",
padding: "0.25rem 0.75rem",
borderRadius: "26px",
width: "fit-content",
height: "18px",
justifyContent: "center",
alignItems: "center",
position: "absolute",
top: "-10px",
right: "-12px",
}}
>
<Typography
sx={{
marginLeft: "0.5rem",
fontSize: "12px",
color: "#0A6825",
}}
>
Recovered
</Typography>
<MonetizationOnIcon
sx={{ padding: "6px", fontSize: "12px" }}
/>
</div>
</Box>
) : (
<ConnectedWalletCard address={address} />
)}
</div>
</div>
{buttonState === BUTTON_STATES.RECOVERY_COMPLETED ? null : (
<div
style={{
Expand Down
35 changes: 4 additions & 31 deletions src/pages/burnerWalletFlow.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,17 @@
import { useContext, useEffect, useState } from "react";
import { useContext } from "react";
import { BurnerWalletProvider } from "../providers/BurnerWalletProvider";
import { createBurnerSafeConfig } from "../providers/burnerWalletConfig";
import { StepsContext } from "../App";
import { STEPS } from "../constants";
import SafeModuleRecovery from "../components/burnerWallet/SafeModuleRecovery";
import GuardianSetup from "../components/burnerWallet/GuardianSetup";
import RequestedRecoveries from "../components/burnerWallet/RequestedRecoveries";
import TriggerAccountRecovery from "../components/TriggerAccountRecovery";
import Loader from "../components/Loader";
import toast from "react-hot-toast";
import { install, run } from "../utils/burnerWalletUtils";
import ConnectBurnerWallet from "./burnerWalletFlow/ConnectBurnerWallet";
import { Web3Provider } from "../providers/Web3Provider";

const BurnerWalletFlow = () => {
const stepsContext = useContext(StepsContext);
const [isBurnerWalletCreating, setIsBurnerWalletCreating] = useState(false);
const [burnerWalletConfig, setBurnerWalletConfig] = useState();

// useEffect(() => {
// run();
// install()
// }, []);

console.log(stepsContext?.step, STEPS);

const renderBody = () => {
switch (stepsContext?.step) {
// case STEPS.CONNECT_WALLETS:
// return <ConnectBurnerWallet />;
case STEPS.REQUEST_GUARDIAN:
return <GuardianSetup />;
case STEPS.REQUESTED_RECOVERIES:
Expand All @@ -39,21 +23,10 @@ const BurnerWalletFlow = () => {
}
};

if (isBurnerWalletCreating) {
return (
<div className="app">
<Loader />
</div>
);
}
// if (!burnerWalletConfig) {
// return <div className="app">Could not configure burner wallet</div>;
// }

return (
<BurnerWalletProvider config={burnerWalletConfig}>
<Web3Provider>
<div className="app">{renderBody()}</div>
</BurnerWalletProvider>
</Web3Provider>
);
};

Expand Down
2 changes: 2 additions & 0 deletions src/pages/landingPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ const LandingPage = () => {
case "SAFE_WALLET":
return navigate("/safe-wallet");
case "BURNER_WALLET":
await localStorage.removeItem('accountCode')
await localStorage.removeItem('burnerWalletConfig')
return navigate("/burner-wallet");
case "WALLET_RECOVERY":
return navigate("/wallet-recovery");
Expand Down

0 comments on commit 462c278

Please sign in to comment.