mirror of
https://github.com/cerc-io/watcher-ts
synced 2025-07-27 10:42:06 +00:00
Add a flag to enable ETH RPC server
This commit is contained in:
parent
7869b72aef
commit
36c56da467
@ -252,6 +252,9 @@ export interface ServerConfig {
|
||||
// Flag to specify whether RPC endpoint supports block hash as block tag parameter
|
||||
// https://ethereum.org/en/developers/docs/apis/json-rpc/#default-block
|
||||
rpcSupportsBlockHashParam: boolean;
|
||||
|
||||
// Enable ETH JSON RPC server at /rpc
|
||||
enableEthRPCServer: boolean;
|
||||
}
|
||||
|
||||
export interface FundingAmountsConfig {
|
||||
|
@ -24,6 +24,7 @@ import { PaymentsManager, paymentsPlugin } from './payments';
|
||||
const log = debug('vulcanize:server');
|
||||
|
||||
const DEFAULT_GQL_PATH = '/graphql';
|
||||
const ETH_RPC_PATH = '/rpc';
|
||||
|
||||
export const createAndStartServer = async (
|
||||
app: Application,
|
||||
@ -101,19 +102,25 @@ export const createAndStartServer = async (
|
||||
path: gqlPath
|
||||
});
|
||||
|
||||
// Create a JSON-RPC server to handle ETH RPC calls at /rpc
|
||||
if (serverConfig.enableEthRPCServer) {
|
||||
// Create a JSON-RPC server to handle ETH RPC calls
|
||||
const rpcServer = jayson.Server(ethRPCHandlers);
|
||||
|
||||
// Mount the JSON-RPC server to /rpc path
|
||||
// Mount the JSON-RPC server to ETH_RPC_PATH
|
||||
app.use(
|
||||
'/rpc',
|
||||
ETH_RPC_PATH,
|
||||
jsonParser(),
|
||||
// TODO: Handle GET requests as well to match Geth's behaviour
|
||||
rpcServer.middleware()
|
||||
);
|
||||
}
|
||||
|
||||
httpServer.listen(port, host, () => {
|
||||
log(`Server is listening on ${host}:${port}${server.graphqlPath}`);
|
||||
log(`GQL server is listening on http://${host}:${port}${server.graphqlPath}`);
|
||||
|
||||
if (serverConfig.enableEthRPCServer) {
|
||||
log(`ETH JSON RPC server is listening on http://${host}:${port}${ETH_RPC_PATH}`);
|
||||
}
|
||||
});
|
||||
|
||||
return server;
|
||||
|
Loading…
Reference in New Issue
Block a user