Skip to content

Commit 3d42b6b

Browse files
committed
feat: add initial dummy rpc.discover method that returns a blank OpenRPC document
1 parent 1d18451 commit 3d42b6b

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/middlewares/methodWhitelist.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Request, Response, NextFunction } from 'express'
22
import { methods } from '../api'
33

4-
const allowedMethods = Object.keys(methods)
4+
const allowedMethods = [...Object.keys(methods), 'rpc.discover']
55

66
export const methodWhitelist = (req: Request, res: Response, next: NextFunction) => {
77
const body = req.body

src/server.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import { rateLimitMiddleware } from './middlewares/rateLimit'
3535
import requestLogger from './middlewares/requestLogger'
3636
import { loadFoundationNodes } from './utils/foundationNodes'
3737
import { setupNewHeadSubscriptionProviderConnectionStream } from './websocket/newhead_server'
38-
38+
import rpcDiscover from './methods/rpcDiscover'
3939
setDefaultResultOrder('ipv4first')
4040

4141
// const path = require('path');
@@ -51,6 +51,13 @@ setDefaultResultOrder('ipv4first')
5151
// }
5252
const app = express()
5353
const server = new jayson.Server(wrappedMethods)
54+
server._methods['rpc.discover'] = new jayson.Method((_args: unknown, done: jayson.JSONRPCCallbackTypePlain) => {
55+
rpcDiscover().then((res) => {
56+
done(null, res)
57+
}).catch((err) => {
58+
done(err, null)
59+
})
60+
});
5461
let port = config.port //8080
5562
const chainId = config.chainId //8080
5663
const verbose = config.verbose

0 commit comments

Comments
 (0)