aboutsummaryrefslogtreecommitdiffstats
path: root/rpc
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2015-03-23 04:45:56 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2015-03-23 04:45:56 +0800
commit3133372a6a81c91528afbde58e22b3f9df257d03 (patch)
tree16778611a22c9fd249a94c88660cb0c6d297ce9b /rpc
parent59eab49cb849ca93b9608763f4842654e8044d0f (diff)
parent85acdadcfa99ea5c74907029cb63919cc0302c1a (diff)
downloaddexon-3133372a6a81c91528afbde58e22b3f9df257d03.tar.gz
dexon-3133372a6a81c91528afbde58e22b3f9df257d03.tar.zst
dexon-3133372a6a81c91528afbde58e22b3f9df257d03.zip
Merge pull request #536 from zsfelfoldi/develop
using robertkrimen/otto, godeps updated
Diffstat (limited to 'rpc')
-rw-r--r--rpc/jeth.go27
1 files changed, 19 insertions, 8 deletions
diff --git a/rpc/jeth.go b/rpc/jeth.go
index 11d4599c9..4e83be8a6 100644
--- a/rpc/jeth.go
+++ b/rpc/jeth.go
@@ -3,22 +3,29 @@ package rpc
import (
"encoding/json"
// "fmt"
- "github.com/obscuren/otto"
+ "github.com/ethereum/go-ethereum/jsre"
+ "github.com/robertkrimen/otto"
)
type Jeth struct {
ethApi *EthereumApi
toVal func(interface{}) otto.Value
+ re *jsre.JSRE
}
-func NewJeth(ethApi *EthereumApi, toVal func(interface{}) otto.Value) *Jeth {
- return &Jeth{ethApi, toVal}
+func NewJeth(ethApi *EthereumApi, toVal func(interface{}) otto.Value, re *jsre.JSRE) *Jeth {
+ return &Jeth{ethApi, toVal, re}
}
-func (self *Jeth) err(code int, msg string, id interface{}) otto.Value {
+func (self *Jeth) err(code int, msg string, id interface{}) (response otto.Value) {
rpcerr := &RpcErrorObject{code, msg}
- rpcresponse := &RpcErrorResponse{Jsonrpc: jsonrpcver, Id: id, Error: rpcerr}
- return self.toVal(rpcresponse)
+ self.re.Set("ret_jsonrpc", jsonrpcver)
+ self.re.Set("ret_id", id)
+ self.re.Set("ret_error", rpcerr)
+ response, _ = self.re.Run(`
+ ret_response = { jsonrpc: ret_jsonrpc, id: ret_id, error: ret_error };
+ `)
+ return
}
func (self *Jeth) Send(call otto.FunctionCall) (response otto.Value) {
@@ -37,7 +44,11 @@ func (self *Jeth) Send(call otto.FunctionCall) (response otto.Value) {
if err != nil {
return self.err(-32603, err.Error(), req.Id)
}
- rpcresponse := &RpcSuccessResponse{Jsonrpc: jsonrpcver, Id: req.Id, Result: respif}
- response = self.toVal(rpcresponse)
+ self.re.Set("ret_jsonrpc", jsonrpcver)
+ self.re.Set("ret_id", req.Id)
+ self.re.Set("ret_result", respif)
+ response, err = self.re.Run(`
+ ret_response = { jsonrpc: ret_jsonrpc, id: ret_id, result: ret_result };
+ `)
return
}