This repository has been archived by the owner on Sep 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #233 from wryonik/email-recovery-demo
Email recovery demo
- Loading branch information
Showing
19 changed files
with
917 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,56 @@ | ||
import './App.css' | ||
import { ConfigureSafeModule } from './components/ConfigureSafeModule'; | ||
import { PerformRecovery } from './components/PerformRecovery'; | ||
import { AppContextProvider } from './context/AppContextProvider'; | ||
import { createContext, useEffect, useState } from "react"; | ||
import "./App.css"; | ||
import ConnectWallets from "./components/ConnectWallets"; | ||
import Navbar from "./components/Navbar"; | ||
import RequestedRecoveries from "./components/RequestedRecoveries"; | ||
import RequestGuardian from "./components/RequestGuardian"; | ||
import SafeModuleRecovery from "./components/SafeModuleRecovery"; | ||
import TriggerAccountRecovery from "./components/TriggerAccountRecovery"; | ||
import { STEPS } from "./constants"; | ||
import { Web3Provider } from "./providers/Web3Provider"; | ||
import { ConnectKitButton } from "connectkit"; | ||
import { useAccount } from "wagmi"; | ||
import { AppContextProvider } from "./context/AppContextProvider"; | ||
|
||
export const StepsContext = createContext(null); | ||
|
||
function App() { | ||
const [step, setStep] = useState(STEPS.CONNECT_WALLETS); | ||
|
||
const renderBody = () => { | ||
switch (step) { | ||
case STEPS.CONNECT_WALLETS: | ||
return <ConnectWallets />; | ||
case STEPS.SAFE_MODULE_RECOVERY: | ||
return <SafeModuleRecovery />; | ||
case STEPS.REQUEST_GUARDIAN: | ||
return <RequestGuardian />; | ||
case STEPS.REQUESTED_RECOVERIES: | ||
return <RequestedRecoveries />; | ||
case STEPS.TRIGGER_ACCOUNT_RECOVERY: | ||
return <TriggerAccountRecovery />; | ||
default: | ||
return <ConnectWallets />; | ||
} | ||
}; | ||
|
||
return ( | ||
<> | ||
<h1>Safe Email Recovery Demo</h1> | ||
<Web3Provider> | ||
<AppContextProvider> | ||
<ConnectKitButton /> | ||
<ConfigureSafeModule /> | ||
<PerformRecovery /> | ||
</AppContextProvider> | ||
</Web3Provider> | ||
</> | ||
) | ||
<Web3Provider> | ||
<AppContextProvider> | ||
<StepsContext.Provider | ||
value={{ | ||
setStep, | ||
}} | ||
> | ||
<div className="app"> | ||
<Navbar /> | ||
<h1>Safe Email Recovery Demo</h1> | ||
{renderBody()} | ||
</div> | ||
</StepsContext.Provider>{" "} | ||
</AppContextProvider> | ||
</Web3Provider> | ||
); | ||
} | ||
|
||
export default App | ||
export default App; |
3 changes: 3 additions & 0 deletions
3
packages/demos/email-recovery/src/assets/cancelRecoveryIcon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
3 changes: 3 additions & 0 deletions
3
packages/demos/email-recovery/src/assets/completeRecoveryIcon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions
17
packages/demos/email-recovery/src/assets/recoveredIcon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,16 @@ | ||
import React from 'react'; | ||
import React from "react"; | ||
|
||
export function Button({ children, ...buttonProps }: React.ComponentPropsWithoutRef<"button">) { | ||
return ( | ||
<div className="card"> | ||
<button {...buttonProps}> | ||
{children} | ||
</button> | ||
</div> | ||
) | ||
export function Button({ | ||
children, | ||
...buttonProps | ||
}: React.ComponentPropsWithoutRef<"button">) { | ||
return ( | ||
<div className="button"> | ||
<button {...buttonProps}> | ||
{children} | ||
{buttonProps.endIcon ? buttonProps.endIcon : null} | ||
{buttonProps?.loading ? <div className="loader" /> : null} | ||
</button> | ||
</div> | ||
); | ||
} |
44 changes: 44 additions & 0 deletions
44
packages/demos/email-recovery/src/components/ConnectWallets.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { Button } from "./Button"; | ||
import walletIcon from "../assets/wallet.svg"; | ||
import infoIcon from "../assets/infoIcon.svg"; | ||
import { Web3Provider } from "../providers/Web3Provider"; | ||
import { ConnectKitButton } from "connectkit"; | ||
import { useAccount } from "wagmi"; | ||
import { useContext } from "react"; | ||
import { StepsContext } from "../App"; | ||
import { STEPS } from "../constants"; | ||
|
||
const ConnectWallets = () => { | ||
const { address } = useAccount(); | ||
const stepsContext = useContext(StepsContext); | ||
|
||
if (address) { | ||
console.log(stepsContext); | ||
stepsContext?.setStep(STEPS.SAFE_MODULE_RECOVERY); | ||
} | ||
|
||
return ( | ||
<div className="connect-wallets-container"> | ||
<Button endIcon={<img src={walletIcon} />}>Connect Genosis Safe</Button> | ||
|
||
<p color="#CECFD2" style={{ display: "flex", gap: "0.5rem" }}> | ||
<img src={infoIcon} alt="info" /> | ||
Copy the link and import into your safe wallet | ||
</p> | ||
<ConnectKitButton.Custom> | ||
{({ isConnected, show, truncatedAddress, ensName }) => { | ||
return ( | ||
<Button onClick={show} endIcon={<img src={walletIcon} />}> | ||
Connect Test Wallet | ||
</Button> | ||
); | ||
}} | ||
</ConnectKitButton.Custom> | ||
<p style={{ textDecoration: "underline" }}> | ||
Or, recover existing wallet instead ➔ | ||
</p> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ConnectWallets; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Web3Provider } from "../providers/Web3Provider"; | ||
import { ConnectKitButton } from "connectkit"; | ||
import { Button } from "./Button"; | ||
|
||
const Navbar = () => { | ||
return ( | ||
<nav className="navbar"> | ||
<ConnectKitButton /> | ||
</nav> | ||
); | ||
}; | ||
|
||
export default Navbar; |
Oops, something went wrong.