@@ -28,9 +28,27 @@ const main = async () => {
2828 ? await api . rpc . chain . getBlockHash ( argv . at )
2929 : await api . rpc . chain . getBlockHash ( ) ;
3030 const block = await api . rpc . chain . getBlock ( blockHash ) ;
31+ const apiAt = await api . at ( blockHash ) ;
3132
3233 block . block . extrinsics . forEach ( ( ex , index ) => {
33- console . log ( index , `${ ex . method . section . toString ( ) } .${ ex . method . method . toString ( ) } [${ ex . hash . toHex ( ) } ]\n${ ex . method . method . toString ( ) == "setValidationData" ? "..." : ex . toHex ( ) } ` ) ;
34+ const { method, signature, isSigned, signer, nonce } = ex ;
35+ console . log ( index , `${ ex . method . section . toString ( ) } .${ ex . method . method . toString ( ) } [${ ex . hash . toHex ( ) } ]` ) ;
36+ // if (method.args.length > 0) {
37+ // console.log(` Args: ${method.args.map((arg) => arg.toHex()).join(', ')}`);
38+ // }
39+
40+ if ( method . section === 'sudo' && method . method . startsWith ( 'sudo' ) ) {
41+ // Handle sudo extrinsics
42+ const nestedCall = method . args [ 0 ] ; // The "call" is the first argument in sudo methods
43+ const { section, method : nestedMethod , args : nestedArgs } = apiAt . registry . createType ( 'Call' , nestedCall ) ;
44+
45+ console . log ( ` Nested Call: ${ section } .${ nestedMethod } ` ) ;
46+ const nestedDecodedArgs = nestedArgs . map ( ( arg : any ) => arg . toHuman ( ) ) ;
47+ console . log ( ` Nested Args: ${ JSON . stringify ( nestedDecodedArgs , null , 2 ) } ` ) ;
48+ }
49+ console . log ( `${ ex . method . method . toString ( ) == "setValidationData" ? "..." : ex . toHex ( ) } ` ) ;
50+
51+
3452 } ) ;
3553
3654 await api . disconnect ( ) ;
0 commit comments