-
Notifications
You must be signed in to change notification settings - Fork 2
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 #13 from ourzora/add-transaction-view
Smol Safe UI updates
- Loading branch information
Showing
7 changed files
with
216 additions
and
168 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 was deleted.
Oops, something went wrong.
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,19 @@ | ||
import { Button, View } from "reshaped"; | ||
import { SafeInformation } from "../components/SafeInformation"; | ||
import { Link, useNavigate, useParams } from "react-router-dom"; | ||
|
||
export const SafeInformationPage = () => { | ||
const { networkId, safeAddress } = useParams(); | ||
const navigate = useNavigate(); | ||
|
||
const onNewProposalClick = () => { | ||
navigate(`/safe/${networkId}/${safeAddress}/new`); | ||
}; | ||
|
||
return ( | ||
<View gap={4}> | ||
<SafeInformation /> | ||
<Button onClick={onNewProposalClick}>New Proposal</Button> | ||
</View> | ||
); | ||
}; |
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
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,118 @@ | ||
import { useContext, useState } from "react"; | ||
import { SafeInformationContext } from "../app/ViewSafe"; | ||
import { Button, Card, Text, View } from "reshaped"; | ||
import { allowedNetworks } from "../chains"; | ||
import { InfoBox } from "../components/InfoBox"; | ||
import { Address } from "viem"; | ||
import { AddressView } from "../components/AddressView"; | ||
import { OwnerAction, SetOwnerModal } from "../components/SetOwnerModal"; | ||
|
||
const SafeInformationItem = ({ | ||
title, | ||
description, | ||
children, | ||
}: { | ||
title: string; | ||
description: string; | ||
children: React.ReactNode; | ||
}) => ( | ||
<> | ||
<View direction="row" align="center"> | ||
<Text variant="body-2">{title}:</Text> <InfoBox>{description}</InfoBox> | ||
</View> | ||
{children} | ||
</> | ||
); | ||
|
||
export const SafeInformation = ({ | ||
children, | ||
}: { | ||
children?: React.ReactNode; | ||
}) => { | ||
const [ownerAction, setOwnerAction] = useState<OwnerAction>(); | ||
|
||
const safeInformation = useContext(SafeInformationContext); | ||
|
||
if (!safeInformation) return <div></div>; | ||
return ( | ||
<div> | ||
{ownerAction && ( | ||
<SetOwnerModal | ||
onClose={() => { | ||
setOwnerAction(undefined); | ||
}} | ||
action={ownerAction} | ||
/> | ||
)} | ||
<Card> | ||
<View divided gap={2}> | ||
<View.Item> | ||
<SafeInformationItem | ||
title="Network" | ||
description="Chain for the Safe" | ||
> | ||
{allowedNetworks[safeInformation.chainId]?.name || | ||
safeInformation.chainId.toString()} | ||
</SafeInformationItem> | ||
</View.Item> | ||
<View.Item> | ||
<SafeInformationItem | ||
title="Threshold" | ||
description="Number of signers that need to approve a transaction before | ||
execution" | ||
> | ||
{safeInformation.threshold} | ||
</SafeInformationItem> | ||
</View.Item> | ||
<View.Item> | ||
<SafeInformationItem | ||
title="Signers" | ||
description="Signers are the list of addresses for the signers of the multisig" | ||
> | ||
<View paddingTop={1}> | ||
{safeInformation.owners.map((owner) => ( | ||
<View.Item key={owner}> | ||
<View align="center" direction="row"> | ||
<AddressView address={owner as Address} /> | ||
<Button | ||
onClick={() => { | ||
setOwnerAction({ type: "remove", address: owner }); | ||
}} | ||
variant="ghost" | ||
> | ||
{" "} | ||
x{" "} | ||
</Button> | ||
</View> | ||
</View.Item> | ||
))} | ||
<View.Item> | ||
<View justify="end" direction="row"> | ||
<View> | ||
<Button | ||
onClick={() => { | ||
setOwnerAction({ type: "add" }); | ||
}} | ||
> | ||
Add | ||
</Button> | ||
</View> | ||
</View> | ||
</View.Item> | ||
</View> | ||
</SafeInformationItem> | ||
</View.Item> | ||
<View.Item> | ||
<SafeInformationItem | ||
title="Nonce" | ||
description="Nonce is the index of the current transaction of the safe" | ||
> | ||
{safeInformation.nonce} | ||
</SafeInformationItem> | ||
</View.Item> | ||
</View> | ||
</Card> | ||
{children} | ||
</div> | ||
); | ||
}; |
Oops, something went wrong.