-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathapis.go
More file actions
92 lines (84 loc) · 2.78 KB
/
Copy pathapis.go
File metadata and controls
92 lines (84 loc) · 2.78 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package rpc
import (
"context"
ethRpc "github.com/ethereum/go-ethereum/rpc"
"github.com/oasisprotocol/oasis-core/go/common/logging"
"github.com/oasisprotocol/oasis-sdk/client-sdk/go/client"
"github.com/oasisprotocol/oasis-web3-gateway/archive"
"github.com/oasisprotocol/oasis-web3-gateway/conf"
eventFilters "github.com/oasisprotocol/oasis-web3-gateway/filters"
"github.com/oasisprotocol/oasis-web3-gateway/gas"
"github.com/oasisprotocol/oasis-web3-gateway/indexer"
"github.com/oasisprotocol/oasis-web3-gateway/rpc/eth"
"github.com/oasisprotocol/oasis-web3-gateway/rpc/eth/filters"
ethmetrics "github.com/oasisprotocol/oasis-web3-gateway/rpc/eth/metrics"
"github.com/oasisprotocol/oasis-web3-gateway/rpc/net"
"github.com/oasisprotocol/oasis-web3-gateway/rpc/oasis"
"github.com/oasisprotocol/oasis-web3-gateway/rpc/txpool"
"github.com/oasisprotocol/oasis-web3-gateway/rpc/web3"
)
// GetRPCAPIs returns the list of all APIs.
func GetRPCAPIs(
ctx context.Context,
client client.RuntimeClient,
archiveClient *archive.Client,
backend indexer.Backend,
gasPriceOracle gas.Backend,
config *conf.GatewayConfig,
eventSystem *eventFilters.EventSystem,
) []ethRpc.API {
var apis []ethRpc.API
web3Service := web3.NewPublicAPI()
ethService := eth.NewPublicAPI(client, archiveClient, logging.GetLogger("eth_rpc"), config.ChainID, backend, gasPriceOracle, config.MethodLimits, !config.ExposeOasisRPCs || config.AllowUnencryptedTxs)
netService := net.NewPublicAPI(config.ChainID)
txpoolService := txpool.NewPublicAPI()
filtersService := filters.NewPublicAPI(client, logging.GetLogger("eth_filters"), backend, eventSystem)
oasisService := oasis.NewPublicAPI(client, logging.GetLogger("oasis"))
if config.Monitoring.Enabled() {
web3Service = web3.NewMetricsWrapper(web3Service)
netService = net.NewMetricsWrapper(netService)
ethService = ethmetrics.NewMetricsWrapper(ethService, logging.GetLogger("eth_rpc_metrics"), backend)
txpoolService = txpool.NewMetricsWrapper(txpoolService)
filtersService = filters.NewMetricsWrapper(filtersService)
oasisService = oasis.NewMetricsWrapper(oasisService)
}
apis = append(apis,
ethRpc.API{
Namespace: "web3",
Version: "1.0",
Service: web3Service,
Public: true,
},
ethRpc.API{
Namespace: "net",
Version: "1.0",
Service: netService,
Public: true,
},
ethRpc.API{
Namespace: "eth",
Version: "1.0",
Service: ethService,
Public: true,
},
ethRpc.API{
Namespace: "txpool",
Version: "1.0",
Service: txpoolService,
Public: true,
},
ethRpc.API{
Namespace: "eth",
Version: "1.0",
Service: filtersService,
Public: true,
},
ethRpc.API{
Namespace: "oasis",
Version: "1.0",
Service: oasisService,
Public: config.ExposeOasisRPCs,
},
)
return apis
}