@@ -18,11 +18,12 @@ interface FormProps {
1818 chainID : number
1919 decoded ?: DecodedTransaction
2020 currentHash ?: string
21+ error ?: string
2122}
2223
2324const PATH = 'interpret'
2425
25- export default function DecodingForm ( { decoded, currentHash, chainID } : FormProps ) {
26+ export default function DecodingForm ( { decoded, currentHash, chainID, error } : FormProps ) {
2627 const [ result , setResult ] = React . useState < Interpretation > ( )
2728 const [ persistedSchema , setSchema ] = useLocalStorage ( decoded ?. toAddress ?? 'unknown' , '' )
2829
@@ -109,47 +110,51 @@ export default function DecodingForm({ decoded, currentHash, chainID }: FormProp
109110 </ div >
110111 </ form >
111112
112- < div className = "grid gap-6 grid-cols-1 lg:grid-cols-2 h-full" >
113- < div className = "flex flex-col gap-2 lg:col-span-2 min-h-[40vh] lg:min-h-[initial]" >
114- < Label >
115- Interpretation:{ ' ' }
116- < a
117- href = { interpreterSourceLink }
118- target = "_blank"
119- rel = "noopener noreferrer"
120- className = "text-xs text-blue-500 hover:underline"
121- >
122- (Source Code)
123- </ a >
124- </ Label >
125-
126- < CodeBlock
127- language = "javascript"
128- value = { schema ?? '' }
129- onChange = { ( value ) => setSchema ( value ) }
130- lineNumbers = { true }
131- readonly = { false }
132- />
133- </ div >
134-
135- < div className = "flex flex-col gap-2 min-h-[40vh] lg:min-h-[initial]" >
136- < Label > Decoded transaction:</ Label >
137- < CodeBlock language = "json" value = { JSON . stringify ( decoded , null , 2 ) } readonly = { true } lineNumbers = { false } />
138- </ div >
113+ { error ? (
114+ < div className = "text-red-500 p-4 bg-red-50 rounded-md whitespace-pre-line" > { error } </ div >
115+ ) : (
116+ < div className = "grid gap-6 grid-cols-1 lg:grid-cols-2 h-full" >
117+ < div className = "flex flex-col gap-2 lg:col-span-2 min-h-[40vh] lg:min-h-[initial]" >
118+ < Label >
119+ Interpretation:{ ' ' }
120+ < a
121+ href = { interpreterSourceLink }
122+ target = "_blank"
123+ rel = "noopener noreferrer"
124+ className = "text-xs text-blue-500 hover:underline"
125+ >
126+ (Source Code)
127+ </ a >
128+ </ Label >
129+
130+ < CodeBlock
131+ language = "javascript"
132+ value = { schema ?? '' }
133+ onChange = { ( value ) => setSchema ( value ) }
134+ lineNumbers = { true }
135+ readonly = { false }
136+ />
137+ </ div >
139138
140- < div className = "flex flex-col gap-2 min-h-[40vh] lg:min-h-[initial]" >
141- < div className = "flex flex-row justify-between items-center" >
142- < Label > Result: </ Label >
139+ < div className = "flex flex-col gap-2 min-h-[40vh] lg:min-h-[initial]" >
140+ < Label > Decoded transaction: </ Label >
141+ < CodeBlock language = "json" value = { JSON . stringify ( decoded , null , 2 ) } readonly = { true } lineNumbers = { false } / >
143142 </ div >
144143
145- < CodeBlock
146- language = "json"
147- value = { result ?. error ? result ?. error : JSON . stringify ( result ?. interpretation , null , 2 ) }
148- readonly = { true }
149- lineNumbers = { false }
150- />
144+ < div className = "flex flex-col gap-2 min-h-[40vh] lg:min-h-[initial]" >
145+ < div className = "flex flex-row justify-between items-center" >
146+ < Label > Result:</ Label >
147+ </ div >
148+
149+ < CodeBlock
150+ language = "json"
151+ value = { result ?. error ? result ?. error : JSON . stringify ( result ?. interpretation , null , 2 ) }
152+ readonly = { true }
153+ lineNumbers = { false }
154+ />
155+ </ div >
151156 </ div >
152- </ div >
157+ ) }
153158 </ div >
154159
155160 < div className = "md:order-2" >
0 commit comments