@@ -8,6 +8,20 @@ import (
88 "github.com/ethereum/go-ethereum/rpc"
99)
1010
11+ type NodeInfo struct {
12+ AvailableAccounts []string `json:"available_accounts"`
13+ BaseFee string `json:"base_fee"`
14+ GasLimit string `json:"gas_limit"`
15+ GasPrice string `json:"gas_price"`
16+ PrivateKeys []string `json:"private_keys"`
17+ Wallet Wallet `json:"wallet"`
18+ }
19+
20+ type Wallet struct {
21+ DerivationPath string `json:"derivation_path"`
22+ Mnemonic string `json:"mnemonic"`
23+ }
24+
1125// Client is an RPC client for anvil specific functions
1226type Client struct {
1327 cli * rpc.Client
@@ -98,15 +112,24 @@ func (c *Client) Reset(forkURL string) error {
98112 if forkURL == "" {
99113 return c .cli .Call (nil , "anvil_reset" )
100114 }
115+
116+ // @TODO block number
117+
101118 config := map [string ]interface {}{"forking" : map [string ]string {"jsonRpcUrl" : forkURL }}
102119 return c .cli .Call (nil , "anvil_reset" , config )
103120}
104121
105122// DumpState returns a hex-encoded snapshot of the entire chain state.
106123//
107124// Equivalent to the `anvil_dumpState` RPC call.
108- func (c * Client ) DumpState (out * string ) error {
109- return c .cli .Call (out , "anvil_dumpState" )
125+ func (c * Client ) DumpState () ([]byte , error ) {
126+ var data []byte
127+ err := c .cli .Call (data , "anvil_dumpState" )
128+ if err != nil {
129+ return nil , err
130+ }
131+
132+ return data , nil
110133}
111134
112135// LoadState merges a previously dumped state into the current chain state.
@@ -119,6 +142,12 @@ func (c *Client) LoadState(state string) error {
119142// NodeInfo retrieves the current node configuration parameters.
120143//
121144// Equivalent to the `anvil_nodeInfo` RPC call.
122- func (c * Client ) NodeInfo (info * map [string ]interface {}) error {
123- return c .cli .Call (info , "anvil_nodeInfo" )
145+ func (c * Client ) NodeInfo () (* NodeInfo , error ) {
146+ info := & NodeInfo {}
147+ err := c .cli .Call (info , "anvil_nodeInfo" )
148+ if err != nil {
149+ return nil , err
150+ }
151+
152+ return info , nil
124153}
0 commit comments