forked from dcb9/janus
-
Notifications
You must be signed in to change notification settings - Fork 26
/
eth_getTransactionCount.go
39 lines (31 loc) · 1.01 KB
/
eth_getTransactionCount.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package transformer
import (
"math/big"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/labstack/echo"
"github.com/qtumproject/janus/pkg/eth"
"github.com/qtumproject/janus/pkg/qtum"
)
// ProxyETHEstimateGas implements ETHProxy
type ProxyETHTxCount struct {
*qtum.Qtum
}
func (p *ProxyETHTxCount) Method() string {
return "eth_getTransactionCount"
}
func (p *ProxyETHTxCount) Request(rawreq *eth.JSONRPCRequest, c echo.Context) (interface{}, eth.JSONRPCError) {
/* not sure we need this. Need to figure out how to best unmarshal this in the future. For now this will work.
var req eth.GetTransactionCountRequest
if err := unmarshalRequest(rawreq.Params, &req); err != nil {
return nil, err
}*/
qtumresp, err := p.Qtum.GetTransactionCount(c.Request().Context(), "", "")
if err != nil {
return nil, eth.NewCallbackError(err.Error())
}
// qtum res -> eth res
return p.response(qtumresp), nil
}
func (p *ProxyETHTxCount) response(qtumresp *big.Int) string {
return hexutil.EncodeBig(qtumresp)
}