55 walletStarknetkitNextAtom ,
66} from "@/state/connectedWalletStarknetkitNext"
77import { lastTxStatusAtom } from "@/state/transactionState"
8- import { Button , Flex , Heading , Input , Textarea } from "@chakra-ui/react"
8+ import { Button , Flex , Heading , Input , Text , Textarea } from "@chakra-ui/react"
99import { useAtomValue , useSetAtom } from "jotai"
1010import { FC , useState } from "react"
1111import { Account , AccountInterface , stark } from "starknet"
@@ -60,36 +60,38 @@ const SignMessage: FC<SignMessageProps> = ({ account, wallet }) => {
6060 }
6161
6262 return (
63- < Flex flex = { 1 } width = "full" >
64- < Flex
65- as = "form"
66- onSubmit = { ( e ) => {
67- e . preventDefault ( )
68- handleSignSubmit ( )
69- } }
70- direction = "column"
71- flex = { 1 }
72- p = "4"
73- gap = "3"
74- borderTopLeftRadius = "lg"
75- borderBottomLeftRadius = "lg"
76- >
77- < Heading as = "h2" > Sign Message</ Heading >
63+ < >
64+ < Flex flex = { 1 } width = "full" >
65+ < Flex
66+ as = "form"
67+ onSubmit = { ( e ) => {
68+ e . preventDefault ( )
69+ handleSignSubmit ( )
70+ } }
71+ direction = "column"
72+ flex = { 1 }
73+ p = "4"
74+ gap = "3"
75+ borderTopLeftRadius = "lg"
76+ borderBottomLeftRadius = "lg"
77+ >
78+ < Heading as = "h2" > Sign Message</ Heading >
7879
79- < Input
80- type = "text"
81- id = "short-text"
82- name = "short-text"
83- placeholder = "Short text"
84- value = { shortText }
85- onChange = { ( e ) => setShortText ( e . target . value ) }
86- />
80+ < Input
81+ type = "text"
82+ id = "short-text"
83+ name = "short-text"
84+ placeholder = "Short text"
85+ value = { shortText }
86+ onChange = { ( e ) => setShortText ( e . target . value ) }
87+ />
8788
88- < div style = { { display : "flex" , alignItems : "center" , gap : "1em" } } >
89- < Button colorScheme = "primary" type = "submit" w = "full" >
90- Sign
91- </ Button >
92- </ div >
89+ < div style = { { display : "flex" , alignItems : "center" , gap : "1em" } } >
90+ < Button colorScheme = "primary" type = "submit" w = "full" >
91+ Sign
92+ </ Button >
93+ </ div >
94+ </ Flex >
9395 </ Flex >
9496 < Flex
9597 as = "form"
@@ -102,12 +104,88 @@ const SignMessage: FC<SignMessageProps> = ({ account, wallet }) => {
102104 >
103105 < Heading as = "h2" > Sign results</ Heading >
104106
105- { /* Label and textarea for value r */ }
106- < Textarea id = "r" name = "r" placeholder = "r" value = { lastSig [ 0 ] } readOnly />
107- { /* Label and textarea for value s */ }
108- < Textarea id = "s" name = "s" placeholder = "s" value = { lastSig [ 1 ] } readOnly />
107+ { lastSig && lastSig . length > 0 && (
108+ < >
109+ { lastSig . length % 2 === 0 ? (
110+ < >
111+ { /* Label and textarea for value r */ }
112+ < Textarea
113+ id = "r"
114+ name = "r"
115+ placeholder = "r"
116+ value = { lastSig [ 0 ] }
117+ readOnly
118+ />
119+ { /* Label and textarea for value s */ }
120+ < Textarea
121+ id = "s"
122+ name = "s"
123+ placeholder = "s"
124+ value = { lastSig [ 1 ] }
125+ readOnly
126+ />
127+ </ >
128+ ) : (
129+ < >
130+ SignatureLength: { lastSig [ 0 ] }
131+ < Text mb = "4px" > Signer</ Text >
132+ < Textarea
133+ id = "signer"
134+ name = "signer"
135+ placeholder = "signer"
136+ value = { lastSig [ 2 ] }
137+ readOnly
138+ />
139+ < Text my = "4px" > r</ Text >
140+ < Textarea
141+ id = "r"
142+ name = "r"
143+ placeholder = "r"
144+ value = { lastSig [ 3 ] }
145+ readOnly
146+ />
147+ < Text my = "4px" > s</ Text >
148+ < Textarea
149+ id = "s"
150+ name = "s"
151+ placeholder = "s"
152+ value = { lastSig [ 4 ] }
153+ readOnly
154+ />
155+ { lastSig . length > 5 && (
156+ < >
157+ < Text mb = "4px" > Cosigner</ Text >
158+ < Textarea
159+ id = "signer"
160+ name = "signer"
161+ placeholder = "signer"
162+ value = { lastSig [ 6 ] }
163+ readOnly
164+ />
165+ < Text my = "4px" > r</ Text >
166+ < Textarea
167+ id = "r"
168+ name = "r"
169+ placeholder = "r"
170+ value = { lastSig [ 7 ] }
171+ readOnly
172+ />
173+ < Text my = "4px" > s</ Text >
174+ < Textarea
175+ id = "s"
176+ name = "s"
177+ placeholder = "s"
178+ value = { lastSig [ 8 ] }
179+ readOnly
180+ />
181+ </ >
182+ ) }
183+ </ >
184+ ) }
185+ </ >
186+ ) }
109187 </ Flex >
110- </ Flex >
188+ </ >
111189 )
112190}
113191
0 commit comments