-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Apply contract/message card to DeployController and ConfirmTransaction (
#1220) * Sunset legacy Accordion * Apply contract/message card component to policies * Update snapshots --------- Co-authored-by: Tarrence van As <[email protected]>
- Loading branch information
1 parent
42d1d30
commit e52e690
Showing
15 changed files
with
127 additions
and
249 deletions.
There are no files selected for viewing
Binary file modified
BIN
+3.43 KB
(120%)
...eychain/__image_snapshots__/components-confirmtransaction--default-chromium.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-301 Bytes
(100%)
...snapshots__/components-connect-create-createcontroller--with-theme-chromium.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-550 Bytes
(76%)
.../keychain/__image_snapshots__/components-controllererroralert--all-chromium.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+21 Bytes
(100%)
packages/keychain/__image_snapshots__/components-erroralert--default-chromium.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-50 Bytes
(99%)
packages/keychain/__image_snapshots__/components-erroralert--error-chromium.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-72 Bytes
(99%)
packages/keychain/__image_snapshots__/components-erroralert--info-chromium.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+6 Bytes
(100%)
...ges/keychain/__image_snapshots__/components-erroralert--long-title-chromium.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-126 Bytes
(99%)
packages/keychain/__image_snapshots__/components-erroralert--warning-chromium.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,148 +1,35 @@ | ||
import { | ||
HStack, | ||
VStack, | ||
Text, | ||
AccordionButton, | ||
AccordionItem, | ||
Accordion, | ||
Spacer, | ||
AccordionPanel, | ||
Box, | ||
} from "@chakra-ui/react"; | ||
import { FnIcon, WedgeIcon, CopyAddress } from "@cartridge/ui-next"; | ||
import { SessionPolicies } from "@cartridge/presets"; | ||
import { ContractCard } from "./session/ContractCard"; | ||
import { useConnection } from "@/hooks/connection"; | ||
import { MessageCard } from "./session/MessageCard"; | ||
|
||
export function Policies({ | ||
title, | ||
policies, | ||
}: { | ||
title?: string; | ||
policies: SessionPolicies; | ||
}) { | ||
const connection = useConnection(); | ||
const parsedContracts = connection.policies?.contracts ?? {}; | ||
|
||
return ( | ||
<Box position="relative"> | ||
{title && ( | ||
<VStack | ||
align="flex-start" | ||
bg="solid.primary" | ||
p={3} | ||
position="sticky" | ||
top={0} | ||
borderTopRadius="base" | ||
> | ||
<Text | ||
color="text.secondaryAccent" | ||
fontSize="xs" | ||
fontWeight="bold" | ||
casing="uppercase" | ||
> | ||
{title} | ||
</Text> | ||
</VStack> | ||
<div className="flex flex-col gap-4"> | ||
{Object.entries(policies.contracts ?? {}).map(([address, p]) => { | ||
const c = parsedContracts[address]; | ||
return ( | ||
<ContractCard | ||
key={address} | ||
address={address} | ||
title={c?.meta?.name || "Contract"} | ||
icon={c?.meta?.icon} | ||
methods={p.methods} | ||
/> | ||
); | ||
})} | ||
|
||
{policies.messages && policies.messages.length > 0 && ( | ||
<MessageCard messages={policies.messages} /> | ||
)} | ||
|
||
<Accordion w="full" allowMultiple overflowY="auto"> | ||
{Object.entries(policies.contracts ?? {}).map(([contractAddress, p]) => | ||
p.methods.map((m) => ( | ||
<AccordionItem | ||
key={`${contractAddress}${m.entrypoint}`} | ||
// borderTopRadius={i === 0 && !title ? "base" : "none"} | ||
// // The container already set border radius (for top & bottom), but we | ||
// // set the bottom radius for the last item here because for certain | ||
// // browsers' scrolling behaviour (eg Firefox) just to make it look nicer. | ||
// borderBottomRadius={i === policies?.length - 1 ? "base" : "none"} | ||
> | ||
{({ isExpanded }) => ( | ||
<> | ||
<AccordionButton | ||
_disabled={{ | ||
cursor: "auto", | ||
opacity: 1, | ||
}} | ||
> | ||
<HStack> | ||
<FnIcon size="sm" /> | ||
<Text>{m.entrypoint}</Text> | ||
</HStack> | ||
|
||
<Spacer /> | ||
|
||
<WedgeIcon | ||
variant={isExpanded ? "down" : "right"} | ||
className="text-muted-foreground" | ||
/> | ||
</AccordionButton> | ||
|
||
<AccordionPanel> | ||
<VStack align="flex-start" w="full" p={3}> | ||
<CopyAddress address={contractAddress} /> | ||
{m.description && ( | ||
<Text w="full" color="inherit"> | ||
{m.description} | ||
</Text> | ||
)} | ||
</VStack> | ||
</AccordionPanel> | ||
</> | ||
)} | ||
</AccordionItem> | ||
)), | ||
)} | ||
{policies.messages?.map((p) => ( | ||
<AccordionItem | ||
key={`${p.domain.name}${p.primaryType}`} | ||
// borderTopRadius={i === 0 && !title ? "base" : "none"} | ||
// // The container already set border radius (for top & bottom), but we | ||
// // set the bottom radius for the last item here because for certain | ||
// // browsers' scrolling behaviour (eg Firefox) just to make it look nicer. | ||
// borderBottomRadius={i === policies?.length - 1 ? "base" : "none"} | ||
> | ||
{({ isExpanded }) => ( | ||
<> | ||
<AccordionButton | ||
_disabled={{ | ||
cursor: "auto", | ||
opacity: 1, | ||
}} | ||
> | ||
<HStack> | ||
<Text>Sign Message</Text> | ||
</HStack> | ||
|
||
<Spacer /> | ||
|
||
<WedgeIcon | ||
variant={isExpanded ? "down" : "right"} | ||
className="text-muted-foreground" | ||
/> | ||
</AccordionButton> | ||
|
||
<AccordionPanel> | ||
<VStack align="flex-start" w="full" p={3}> | ||
<Text w="full" color="inherit"> | ||
Domain: {p.domain.name} | ||
</Text> | ||
<Text w="full" color="inherit"> | ||
Primary Type: {p.primaryType} | ||
</Text> | ||
<Text w="full" color="inherit"> | ||
Types: | ||
</Text> | ||
{Object.keys(p.types).map((key) => | ||
key === "StarknetDomain" || | ||
key === "StarkNetDomain" ? null : ( | ||
<Text key={key} w="full" color="inherit"> | ||
{key}: {JSON.stringify(p.types[key])} | ||
</Text> | ||
), | ||
)} | ||
</VStack> | ||
</AccordionPanel> | ||
</> | ||
)} | ||
</AccordionItem> | ||
))} | ||
</Accordion> | ||
</Box> | ||
</div> | ||
); | ||
} |
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
Oops, something went wrong.