-
Notifications
You must be signed in to change notification settings - Fork 0
/
apis.go
66 lines (59 loc) · 1.65 KB
/
apis.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package rpc
import (
"github.com/ethereum/go-ethereum/rpc"
"github.com/cosmos/cosmos-sdk/client/context"
"github.com/fastock/fastock-chain/app/crypto/ethsecp256k1"
"github.com/fastock/fastock-chain/app/rpc/backend"
"github.com/fastock/fastock-chain/app/rpc/namespaces/eth"
"github.com/fastock/fastock-chain/app/rpc/namespaces/eth/filters"
"github.com/fastock/fastock-chain/app/rpc/namespaces/net"
"github.com/fastock/fastock-chain/app/rpc/namespaces/personal"
"github.com/fastock/fastock-chain/app/rpc/namespaces/web3"
rpctypes "github.com/fastock/fastock-chain/app/rpc/types"
)
// RPC namespaces and API version
const (
Web3Namespace = "web3"
EthNamespace = "eth"
PersonalNamespace = "personal"
NetNamespace = "net"
apiVersion = "1.0"
)
// GetAPIs returns the list of all APIs from the Ethereum namespaces
func GetAPIs(clientCtx context.CLIContext, keys ...ethsecp256k1.PrivKey) []rpc.API {
nonceLock := new(rpctypes.AddrLocker)
backend := backend.New(clientCtx)
ethAPI := eth.NewAPI(clientCtx, backend, nonceLock, keys...)
return []rpc.API{
{
Namespace: Web3Namespace,
Version: apiVersion,
Service: web3.NewAPI(),
Public: true,
},
{
Namespace: EthNamespace,
Version: apiVersion,
Service: ethAPI,
Public: true,
},
{
Namespace: EthNamespace,
Version: apiVersion,
Service: filters.NewAPI(clientCtx, backend),
Public: true,
},
{
Namespace: PersonalNamespace,
Version: apiVersion,
Service: personal.NewAPI(ethAPI),
Public: false,
},
{
Namespace: NetNamespace,
Version: apiVersion,
Service: net.NewAPI(clientCtx),
Public: true,
},
}
}