@@ -12,7 +12,7 @@ import type {
1212} from "viem" ;
1313import { createTestClient , publicActions , toHex , walletActions } from "viem" ;
1414
15- interface AnvilNodeInfo {
15+ export interface AnvilNodeInfo {
1616 currentBlockNumber : string ; // hexutil.Big is a big number in hex format
1717 currentBlockTimestamp : number ;
1818 currentBlockHash : string ;
@@ -31,7 +31,7 @@ interface AnvilNodeInfo {
3131 } ;
3232}
3333
34- type AnvilRPCSchema = [
34+ export type AnvilRPCSchema = [
3535 ...TestRpcSchema < "anvil" > ,
3636 {
3737 Method : "anvil_nodeInfo" ;
@@ -47,6 +47,7 @@ type AnvilRPCSchema = [
4747
4848// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
4949export type AnvilActions = {
50+ anvilNodeInfo : ( ) => Promise < AnvilNodeInfo > ;
5051 isAnvil : ( ) => Promise < boolean > ;
5152 evmMineDetailed : (
5253 /**
@@ -91,6 +92,7 @@ export function createAnvilClient({
9192 . extend ( publicActions )
9293 . extend ( walletActions )
9394 . extend ( client => ( {
95+ anvilNodeInfo : ( ) => anvilNodeInfo ( client ) ,
9496 isAnvil : ( ) => isAnvil ( client ) ,
9597 evmMineDetailed : ( timestamp : bigint | number ) =>
9698 evmMineDetailed ( client , timestamp ) ,
@@ -116,6 +118,20 @@ export async function isAnvil(
116118 }
117119}
118120
121+ /**
122+ * Anvil node info
123+ * @param client
124+ * @returns
125+ */
126+ export async function anvilNodeInfo (
127+ client : Client < any , any , any , AnvilRPCSchema , any > ,
128+ ) : Promise < AnvilNodeInfo > {
129+ return client . request ( {
130+ method : "anvil_nodeInfo" ,
131+ params : [ ] ,
132+ } ) ;
133+ }
134+
119135/**
120136 * Safely tries to mine block with given timestamp
121137 * @param client
0 commit comments