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 (
34
34
"github.com/ethereum/go-ethereum/internal/jsre"
35
35
"github.com/ethereum/go-ethereum/internal/jsre/deps"
36
36
"github.com/ethereum/go-ethereum/internal/web3ext"
37
+ "github.com/ethereum/go-ethereum/log"
37
38
"github.com/ethereum/go-ethereum/rpc"
38
39
"github.com/mattn/go-colorable"
39
40
"github.com/peterh/liner"
@@ -198,13 +199,22 @@ func (c *Console) initWeb3(bridge *bridge) error {
198
199
return err
199
200
}
200
201
202
+ var defaultAPIs = map [string ]string {"eth" : "1.0" , "net" : "1.0" , "debug" : "1.0" }
203
+
201
204
// initExtensions loads and registers web3.js extensions.
202
205
func (c * Console ) initExtensions () error {
203
- // Compute aliases from server-provided modules.
206
+ const methodNotFound = - 32601
204
207
apis , err := c .client .SupportedModules ()
205
208
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
+ }
207
215
}
216
+
217
+ // Compute aliases from server-provided modules.
208
218
aliases := map [string ]struct {}{"eth" : {}, "personal" : {}}
209
219
for api := range apis {
210
220
if api == "web3" {
You can’t perform that action at this time.
0 commit comments