hedera-json-rpc-relay
hedera-json-rpc-relay copied to clipboard
Batch Requests - Method not allowed for batch request
trafficstars
Problem
Some methods should not be allowed to be requested as part of a batch.
Debug and Filter APIs to start with, but we might want to leave them in a configurable property that we can extend if needed.
Solution
-
New error
code: -32007 message: Method<method>is not permitted as part of batch requests -
New Configurable property with the list of the methods that are not allowed for batch.
-
Add a validation on each request, right before calling
getRequestResultCurrent:
const promises = body.map((item: any) => this.getRequestResult(item, ctx.ip));
Proposed:
const promises = body.map((item: any) => {
//validate method is allowed for batch requests
if(this.methodIsAllowed(item.method)) {
this.getRequestResult(item, ctx.ip)
} else {
return jsonResp(item.id, new MethodNotAllowedForBatch(item.method), undefined);
}
});
Alternatives
No response