File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ import (
3434 "github.com/ethereum/go-ethereum/internal/jsre"
3535 "github.com/ethereum/go-ethereum/internal/jsre/deps"
3636 "github.com/ethereum/go-ethereum/internal/web3ext"
37+ "github.com/ethereum/go-ethereum/log"
3738 "github.com/ethereum/go-ethereum/rpc"
3839 "github.com/mattn/go-colorable"
3940 "github.com/peterh/liner"
@@ -198,13 +199,22 @@ func (c *Console) initWeb3(bridge *bridge) error {
198199 return err
199200}
200201
202+ var defaultAPIs = map [string ]string {"eth" : "1.0" , "net" : "1.0" , "debug" : "1.0" }
203+
201204// initExtensions loads and registers web3.js extensions.
202205func (c * Console ) initExtensions () error {
203- // Compute aliases from server-provided modules.
206+ const methodNotFound = - 32601
204207 apis , err := c .client .SupportedModules ()
205208 if err != nil {
206- return fmt .Errorf ("api modules: %v" , err )
209+ if rpcErr , ok := err .(rpc.Error ); ok && rpcErr .ErrorCode () == methodNotFound {
210+ log .Warn ("Server does not support method rpc_modules, using default API list." )
211+ apis = defaultAPIs
212+ } else {
213+ return err
214+ }
207215 }
216+
217+ // Compute aliases from server-provided modules.
208218 aliases := map [string ]struct {}{"eth" : {}, "personal" : {}}
209219 for api := range apis {
210220 if api == "web3" {
You can’t perform that action at this time.
0 commit comments