@@ -45,10 +45,14 @@ const getStatusStyle = (status: LogStatus) => {
4545 }
4646}
4747
48+ // Wagmi uses bigints in query keys and args, so need to add support for serialization of bigints
49+ const bigIntStringify = ( obj : unknown ) =>
50+ JSON . stringify ( obj , ( _ , value ) => ( typeof value === 'bigint' ? value . toString ( ) : value ) )
51+
4852function argToString ( i : unknown , max = 200 , trailing = 3 ) {
4953 let str
5054 try {
51- str = JSON . stringify ( i )
55+ str = bigIntStringify ( i )
5256 } catch {
5357 return String ( i )
5458 }
@@ -78,7 +82,7 @@ export function log(key: LogKey, status?: LogStatus | unknown, ...args: unknown[
7882 formattedString += '%c → '
7983 styles . push ( 'color: #666; font-size: 0.75em;' )
8084 }
81- formattedString += `%c${ typeof part === 'string' ? part : JSON . stringify ( part ) } `
85+ formattedString += `%c${ typeof part === 'string' ? part : bigIntStringify ( part ) } `
8286 styles . push ( 'color: #4CAF50; font-weight: bold;' )
8387 } )
8488
@@ -98,7 +102,7 @@ export function log(key: LogKey, status?: LogStatus | unknown, ...args: unknown[
98102 }
99103 if ( isCypress || typeof window === 'undefined' ) {
100104 // disable formatting when on cypress or server side. Electron prints logs to the output, but formatting breaks.
101- return logMethod ( status ) ( JSON . stringify ( { status, keyArray, args } ) . slice ( 0 , 300 ) )
105+ return logMethod ( status ) ( bigIntStringify ( { status, keyArray, args } ) . slice ( 0 , 300 ) )
102106 }
103107
104108 const hasDefinedStatus = status && Object . values ( LogStatus ) . includes ( status as LogStatus )
0 commit comments