forked from qtumproject/janus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
eth_accounts.go
40 lines (31 loc) · 990 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/kaonone/eth-rpc-gate/pkg/eth"
"github.com/kaonone/eth-rpc-gate/pkg/kaon"
"github.com/kaonone/eth-rpc-gate/pkg/utils"
"github.com/labstack/echo"
)
// ProxyETHAccounts implements ETHProxy
type ProxyETHAccounts struct {
*kaon.Kaon
}
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 := kaon.Account{WIF: acc}
addr := acc.ToHexAddress()
accounts = append(accounts, utils.AddHexPrefix(addr))
}
return accounts, nil
}
func (p *ProxyETHAccounts) ToResponse(ethresp *kaon.CallContractResponse) *eth.CallResponse {
data := utils.AddHexPrefix(ethresp.ExecutionResult.Output)
kaonresp := eth.CallResponse(data)
return &kaonresp
}