-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: eth_signTypedDataV4 implementation
- Loading branch information
1 parent
863d901
commit 544181a
Showing
4 changed files
with
76 additions
and
14 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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import React from "react"; | ||
import { Theme, Box, Heading, ScrollArea, Text } from "@radix-ui/themes"; | ||
|
||
interface EIP712Data { | ||
domain: Record<string, any>; | ||
message: Record<string, any>; | ||
primaryType: string; | ||
types: Record<string, { name: string; type: string }[]>; | ||
} | ||
|
||
const EIP712Renderer: React.FC<{ data: EIP712Data }> = ({ data }) => { | ||
const renderValue = (value: any, depth = 0): JSX.Element => { | ||
if (typeof value !== "object" || value === null) { | ||
return <Text>{JSON.stringify(value)}</Text>; | ||
} | ||
|
||
return ( | ||
<Box style={{ paddingLeft: `${depth * 8}px` }}> | ||
{Object.entries(value).map(([key, val]) => ( | ||
<Box key={key}> | ||
<Text weight="bold">{key}:</Text> {renderValue(val, depth + 1)} | ||
</Box> | ||
))} | ||
</Box> | ||
); | ||
}; | ||
|
||
return ( | ||
<Theme> | ||
<ScrollArea style={{ height: "300px", width: "100%" }}> | ||
<Box p="4"> | ||
<Box> | ||
<Heading size="3">Domain</Heading> | ||
{renderValue(data.domain)} | ||
</Box> | ||
<Box mt="4"> | ||
<Heading size="3">Message</Heading> | ||
{renderValue(data.message)} | ||
</Box> | ||
</Box> | ||
</ScrollArea> | ||
</Theme> | ||
); | ||
}; | ||
|
||
export default EIP712Renderer; |
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