diff --git a/packages/keychain/src/components/session/CollapsibleRow.tsx b/packages/keychain/src/components/session/CollapsibleRow.tsx deleted file mode 100644 index 8ef1276fb..000000000 --- a/packages/keychain/src/components/session/CollapsibleRow.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import React, { PropsWithChildren, useState } from "react"; -import { - Accordion, - AccordionContent, - AccordionItem, - AccordionTrigger, - CheckboxIcon, -} from "@cartridge/ui-next"; - -interface CollapsibleRowProps extends PropsWithChildren { - title: string; -} - -export function CollapsibleRow({ title, children }: CollapsibleRowProps) { - const [value, setValue] = useState(""); - - return ( - - - -
- -
{title}
-
-
- - - {children} - -
-
- ); -} diff --git a/packages/keychain/src/components/session/ContractCard.tsx b/packages/keychain/src/components/session/ContractCard.tsx index be698621e..3ba0273be 100644 --- a/packages/keychain/src/components/session/ContractCard.tsx +++ b/packages/keychain/src/components/session/ContractCard.tsx @@ -1,4 +1,3 @@ -import React from "react"; import { Card, CardContent, @@ -7,17 +6,10 @@ import { AccordionContent, AccordionItem, AccordionTrigger, + CardIcon, + CodeIcon, } from "@cartridge/ui-next"; import { formatAddress } from "@cartridge/utils"; -import { - Divider, - HStack, - Link, - Spacer, - Stack, - Text, - VStack, -} from "@chakra-ui/react"; import { useExplorer } from "@starknet-react/core"; import { constants } from "starknet"; import { Method } from "@cartridge/presets"; @@ -41,20 +33,19 @@ export function ContractCard({ return ( - - - - {title} - - - + + + ) + } + > + + - - - - Approve{" "} - - {methods.length} {methods.length > 1 ? "methods" : "method"} - - + + + Approve{" "} + + {methods.length} {methods.length > 1 ? "methods" : "method"} + - - } - > - {methods.map((method) => ( - - - - {method.name ?? humanizeString(method.entrypoint)} - - - - {method.entrypoint} - - - {method.description && ( - - {method.description} - - )} - - ))} - + + {methods.map((method) => ( +
+
+
+ {method.name ?? humanizeString(method.entrypoint)} +
+
+ {method.entrypoint} +
+
+ {method.description && ( +
+ {method.description} +
+ )} +
+ ))}
diff --git a/packages/keychain/src/components/session/MessageCard.tsx b/packages/keychain/src/components/session/MessageCard.tsx index cab41f31f..0ce117c65 100644 --- a/packages/keychain/src/components/session/MessageCard.tsx +++ b/packages/keychain/src/components/session/MessageCard.tsx @@ -1,4 +1,4 @@ -import React from "react"; +import { PropsWithChildren, useState } from "react"; import { Card, CardContent, @@ -10,67 +10,17 @@ import { CardIcon, PencilIcon, AccordionTrigger, + CheckboxIcon, } from "@cartridge/ui-next"; import { ArrowTurnDownIcon, Badge } from "@cartridge/ui-next"; import { StarknetEnumType, StarknetMerkleType } from "@starknet-io/types-js"; import { SignMessagePolicy } from "@cartridge/presets"; -import { Text } from "@chakra-ui/react"; - -import { CollapsibleRow } from "./CollapsibleRow"; - -interface MessageContentProps { - message: SignMessagePolicy; -} - -function MessageContent({ message: m }: MessageContentProps) { - return ( - - {/* Domain section */} - {Object.values(m.domain).filter((f) => typeof f !== "undefined").length > - 0 && ( - - {m.domain.name && ( - - )} - {/* ... other domain fields ... */} - - )} - - - - - {Object.entries(m.types).map(([name, types]) => ( - - {types.map((t) => ( - - ))} - - ))} - - - ); -} interface MessageCardProps { - message: SignMessagePolicy; + messages: SignMessagePolicy[]; } -export function MessageCard({ message }: MessageCardProps) { +export function MessageCard({ messages }: MessageCardProps) { return ( Sign Message - - - - - - The application will be able to sign the following message on - your behalf - - - - - - - - - + + + ); } +interface MessageContentProps { + messages: SignMessagePolicy[]; +} + +function MessageContent({ messages }: MessageContentProps) { + return ( + + + + Approve{" "} + + {messages.length} {messages.length > 1 ? "messages" : "message"} + + + + + {messages.map((m, i) => ( +
+
{m.name ?? `Message ${i + 1}`}
+
+ {/* Domain section */} + {Object.values(m.domain).filter((f) => typeof f !== "undefined") + .length > 0 && ( + + {m.domain.name && ( + + )} + {/* ... other domain fields ... */} + + )} + + + + + {Object.entries(m.types).map(([name, types]) => ( + + {types.map((t) => ( + + ))} + + ))} + +
+
+ ))} +
+
+
+ ); +} +interface CollapsibleRowProps extends PropsWithChildren { + title: string; +} + +export function CollapsibleRow({ title, children }: CollapsibleRowProps) { + const [value, setValue] = useState(""); + + return ( + + + +
+ +
{title}
+
+
+ + + {children} + +
+
+ ); +} + interface ValueRowProps { values: { name: string; value: string | number }[]; } export function ValueRow({ values }: ValueRowProps) { return ( -
+
{values.map((f) => ( diff --git a/packages/keychain/src/components/session/UnverifiedSessionSummary.tsx b/packages/keychain/src/components/session/UnverifiedSessionSummary.tsx index f9c86e0dd..f65f1695d 100644 --- a/packages/keychain/src/components/session/UnverifiedSessionSummary.tsx +++ b/packages/keychain/src/components/session/UnverifiedSessionSummary.tsx @@ -1,4 +1,3 @@ -import React from "react"; import { toArray } from "@cartridge/controller"; import { ParsedSessionPolicies } from "@/hooks/session"; @@ -28,9 +27,9 @@ export function UnverifiedSessionSummary({ ); })} - {policies.messages?.map((message, index) => ( - - ))} + {policies.messages?.length && ( + + )}
); }