diff options
Diffstat (limited to 'rpc/jeth.go')
-rw-r--r-- | rpc/jeth.go | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/rpc/jeth.go b/rpc/jeth.go index 158bfb64c..ae2603ae4 100644 --- a/rpc/jeth.go +++ b/rpc/jeth.go @@ -40,25 +40,16 @@ type Jeth struct { } func NewJeth(ethApi shared.EthereumApi, re *jsre.JSRE, client comms.EthereumClient, fe xeth.Frontend) *Jeth { - // enable the jeth as the user agent - req := shared.Request{ - Id: 0, - Method: useragent.EnableUserAgentMethod, - Jsonrpc: shared.JsonRpcVersion, - Params: []byte("[]"), - } - client.Send(&req) - client.Recv() - return &Jeth{ethApi, re, client, fe} } func (self *Jeth) err(call otto.FunctionCall, code int, msg string, id interface{}) (response otto.Value) { - errObj := fmt.Sprintf("{\"message\": \"%s\", \"code\": %d}", msg, code) - retResponse := fmt.Sprintf("ret_response = JSON.parse('{\"jsonrpc\": \"%s\", \"id\": %v, \"error\": %s}');", shared.JsonRpcVersion, id, errObj) + m := shared.NewRpcErrorResponse(id, shared.JsonRpcVersion, code, fmt.Errorf(msg)) + errObj, _ := json.Marshal(m.Error) + errRes, _ := json.Marshal(m) - call.Otto.Run("ret_error = " + errObj) - res, _ := call.Otto.Run(retResponse) + call.Otto.Run("ret_error = " + string(errObj)) + res, _ := call.Otto.Run("ret_response = " + string(errRes)) return res } |