forked from qtumproject/janus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
eth_accounts.go
40 lines (31 loc) · 974 Bytes
/
eth_accounts.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
40
package transformer
import (
"github.com/labstack/echo"
"github.com/qtumproject/janus/pkg/eth"
"github.com/qtumproject/janus/pkg/qtum"
"github.com/qtumproject/janus/pkg/utils"
)
// ProxyETHAccounts implements ETHProxy
type ProxyETHAccounts struct {
*qtum.Qtum
}
func (p *ProxyETHAccounts) Method() string {
return "eth_accounts"
}
func (p *ProxyETHAccounts) Request(_ *eth.JSONRPCRequest, c echo.Context) (interface{}, eth.JSONRPCError) {
return p.request()
}
func (p *ProxyETHAccounts) request() (eth.AccountsResponse, eth.JSONRPCError) {
var accounts eth.AccountsResponse
for _, acc := range p.Accounts {
acc := qtum.Account{acc}
addr := acc.ToHexAddress()
accounts = append(accounts, utils.AddHexPrefix(addr))
}
return accounts, nil
}
func (p *ProxyETHAccounts) ToResponse(ethresp *qtum.CallContractResponse) *eth.CallResponse {
data := utils.AddHexPrefix(ethresp.ExecutionResult.Output)
qtumresp := eth.CallResponse(data)
return &qtumresp
}