Skip to content

Commit

Permalink
fix: update ui for sign message
Browse files Browse the repository at this point in the history
  • Loading branch information
bluecco committed Oct 18, 2024
1 parent 9a92a00 commit 4b9b067
Showing 1 changed file with 112 additions and 34 deletions.
146 changes: 112 additions & 34 deletions src/components/Actions/SignMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
walletStarknetkitNextAtom,
} from "@/state/connectedWalletStarknetkitNext"
import { lastTxStatusAtom } from "@/state/transactionState"
import { Button, Flex, Heading, Input, Textarea } from "@chakra-ui/react"
import { Button, Flex, Heading, Input, Text, Textarea } from "@chakra-ui/react"
import { useAtomValue, useSetAtom } from "jotai"
import { FC, useState } from "react"
import { Account, AccountInterface, stark } from "starknet"
Expand Down Expand Up @@ -60,36 +60,38 @@ const SignMessage: FC<SignMessageProps> = ({ account, wallet }) => {
}

return (
<Flex flex={1} width="full">
<Flex
as="form"
onSubmit={(e) => {
e.preventDefault()
handleSignSubmit()
}}
direction="column"
flex={1}
p="4"
gap="3"
borderTopLeftRadius="lg"
borderBottomLeftRadius="lg"
>
<Heading as="h2">Sign Message</Heading>
<>
<Flex flex={1} width="full">
<Flex
as="form"
onSubmit={(e) => {
e.preventDefault()
handleSignSubmit()
}}
direction="column"
flex={1}
p="4"
gap="3"
borderTopLeftRadius="lg"
borderBottomLeftRadius="lg"
>
<Heading as="h2">Sign Message</Heading>

<Input
type="text"
id="short-text"
name="short-text"
placeholder="Short text"
value={shortText}
onChange={(e) => setShortText(e.target.value)}
/>
<Input
type="text"
id="short-text"
name="short-text"
placeholder="Short text"
value={shortText}
onChange={(e) => setShortText(e.target.value)}
/>

<div style={{ display: "flex", alignItems: "center", gap: "1em" }}>
<Button colorScheme="primary" type="submit" w="full">
Sign
</Button>
</div>
<div style={{ display: "flex", alignItems: "center", gap: "1em" }}>
<Button colorScheme="primary" type="submit" w="full">
Sign
</Button>
</div>
</Flex>
</Flex>
<Flex
as="form"
Expand All @@ -102,12 +104,88 @@ const SignMessage: FC<SignMessageProps> = ({ account, wallet }) => {
>
<Heading as="h2">Sign results</Heading>

{/* Label and textarea for value r */}
<Textarea id="r" name="r" placeholder="r" value={lastSig[0]} readOnly />
{/* Label and textarea for value s */}
<Textarea id="s" name="s" placeholder="s" value={lastSig[1]} readOnly />
{lastSig && lastSig.length > 0 && (
<>
{lastSig.length % 2 === 0 ? (
<>
{/* Label and textarea for value r */}
<Textarea
id="r"
name="r"
placeholder="r"
value={lastSig[0]}
readOnly
/>
{/* Label and textarea for value s */}
<Textarea
id="s"
name="s"
placeholder="s"
value={lastSig[1]}
readOnly
/>
</>
) : (
<>
SignatureLength: {lastSig[0]}
<Text mb="4px">Signer</Text>
<Textarea
id="signer"
name="signer"
placeholder="signer"
value={lastSig[2]}
readOnly
/>
<Text my="4px">r</Text>
<Textarea
id="r"
name="r"
placeholder="r"
value={lastSig[3]}
readOnly
/>
<Text my="4px">s</Text>
<Textarea
id="s"
name="s"
placeholder="s"
value={lastSig[4]}
readOnly
/>
{lastSig.length > 5 && (
<>
<Text mb="4px">Cosigner</Text>
<Textarea
id="signer"
name="signer"
placeholder="signer"
value={lastSig[6]}
readOnly
/>
<Text my="4px">r</Text>
<Textarea
id="r"
name="r"
placeholder="r"
value={lastSig[7]}
readOnly
/>
<Text my="4px">s</Text>
<Textarea
id="s"
name="s"
placeholder="s"
value={lastSig[8]}
readOnly
/>
</>
)}
</>
)}
</>
)}
</Flex>
</Flex>
</>
)
}

Expand Down

0 comments on commit 4b9b067

Please sign in to comment.