@@ -15,6 +15,28 @@ const StyledPre = styled(Typography)(() => ({
1515 whiteSpace : 'pre-wrap' ,
1616} ) ) ;
1717
18+ function formatValue ( value : unknown ) : ReactNode {
19+ if ( value === null || value === undefined ) {
20+ return < Trans > Not Available</ Trans > ;
21+ }
22+
23+ const valueType = typeof value ;
24+ if ( valueType === 'string' || valueType === 'number' || valueType === 'boolean' || valueType === 'bigint' ) {
25+ return value . toString ( ) ;
26+ }
27+
28+ if ( valueType === 'object' ) {
29+ try {
30+ const formatted = JSON . stringify ( value , null , 2 ) ;
31+ return < StyledPre variant = "body2" > { formatted } </ StyledPre > ;
32+ } catch ( error ) {
33+ return value . toString ( ) ;
34+ }
35+ }
36+
37+ return value . toString ( ) ;
38+ }
39+
1840function formatStackTrace ( stack : StackFrame [ ] ) {
1941 const stackTrace = stack . map (
2042 ( { fileName, columnNumber, lineNumber, functionName } ) =>
@@ -133,15 +155,20 @@ export default function WalletConnectConfirmDialog(props: WalletConnectConfirmDi
133155 }
134156
135157 const value = values [ name ] ;
158+ const valueNode = displayComponent
159+ ? displayComponent ( value , params , values , handleChangeValues )
160+ : formatValue ( value ) ;
136161 return (
137162 < LocalErrorBoundary onError = { onError } >
138163 < Flex flexDirection = "column" key = { name } >
139164 < Typography color = "textPrimary" > { label ?? name } </ Typography >
140- < Typography color = "textSecondary" >
141- { displayComponent
142- ? displayComponent ( value , params , values , handleChangeValues )
143- : ( value ?. toString ( ) ?? < Trans > Not Available</ Trans > ) }
144- </ Typography >
165+ { typeof valueNode === 'string' ? (
166+ < Typography color = "textSecondary" > { valueNode } </ Typography >
167+ ) : (
168+ < Typography color = "textSecondary" component = "div" >
169+ { valueNode }
170+ </ Typography >
171+ ) }
145172 </ Flex >
146173 </ LocalErrorBoundary >
147174 ) ;
0 commit comments