Skip to content

Commit d90f6db

Browse files
authored
docs: indicate proper error codes for unsupported methods (#4192)
Signed-off-by: Luis Mastrangelo <[email protected]>
1 parent 768a773 commit d90f6db

File tree

6 files changed

+121
-182
lines changed

6 files changed

+121
-182
lines changed

docs/openrpc.json

Lines changed: 42 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -118,17 +118,17 @@
118118
"name": "eth_coinbase",
119119
"summary": "Always returns UNSUPPORTED_METHOD error.",
120120
"params": [],
121-
"result": {
122-
"$ref": "#/components/schemas/unsupportedError"
123-
}
121+
"errors": [{
122+
"$ref": "#/components/errors/unsupportedError"
123+
}]
124124
},
125125
{
126126
"name": "eth_blobBaseFee",
127127
"summary": "Always returns UNSUPPORTED_METHOD error.",
128128
"params": [],
129-
"result": {
130-
"$ref": "#/components/schemas/unsupportedError"
131-
}
129+
"errors": [{
130+
"$ref": "#/components/errors/unsupportedError"
131+
}]
132132
},
133133
{
134134
"name": "eth_estimateGas",
@@ -671,9 +671,9 @@
671671
"name": "eth_getWork",
672672
"summary": "Always returns UNSUPPORTED_METHOD error.",
673673
"params": [],
674-
"result": {
675-
"$ref": "#/components/schemas/unsupportedError"
676-
}
674+
"errors": [{
675+
"$ref": "#/components/errors/unsupportedError"
676+
}]
677677
},
678678
{
679679
"name": "eth_hashrate",
@@ -786,9 +786,9 @@
786786
"name": "eth_newPendingTransactionFilter",
787787
"summary": "Always returns UNSUPPORTED_METHOD error.",
788788
"params": [],
789-
"result": {
790-
"$ref": "#/components/schemas/unsupportedError"
791-
},
789+
"errors": [{
790+
"$ref": "#/components/errors/unsupportedError"
791+
}],
792792
"tags": [
793793
{
794794
"name": "alpha API"
@@ -863,9 +863,9 @@
863863
"name": "eth_protocolVersion",
864864
"summary": "Always returns UNSUPPORTED_METHOD error.",
865865
"params": [],
866-
"result": {
867-
"$ref": "#/components/schemas/unsupportedError"
868-
}
866+
"errors": [{
867+
"$ref": "#/components/errors/unsupportedError"
868+
}]
869869
},
870870
{
871871
"name": "eth_sendRawTransaction",
@@ -891,33 +891,33 @@
891891
"name": "eth_sendTransaction",
892892
"summary": "Always returns UNSUPPORTED_METHOD error.",
893893
"params": [],
894-
"result": {
895-
"$ref": "#/components/schemas/unsupportedError"
896-
}
894+
"errors": [{
895+
"$ref": "#/components/errors/unsupportedError"
896+
}]
897897
},
898898
{
899899
"name": "eth_signTransaction",
900900
"summary": "Always returns UNSUPPORTED_METHOD error.",
901901
"params": [],
902-
"result": {
903-
"$ref": "#/components/schemas/unsupportedError"
904-
}
902+
"errors": [{
903+
"$ref": "#/components/errors/unsupportedError"
904+
}]
905905
},
906906
{
907907
"name": "eth_sign",
908908
"summary": "Always returns UNSUPPORTED_METHOD error.",
909909
"params": [],
910-
"result": {
911-
"$ref": "#/components/schemas/unsupportedError"
912-
}
910+
"errors": [{
911+
"$ref": "#/components/errors/unsupportedError"
912+
}]
913913
},
914914
{
915915
"name": "eth_submitHashrate",
916916
"summary": "Always returns UNSUPPORTED_METHOD error.",
917917
"params": [],
918-
"result": {
919-
"$ref": "#/components/schemas/unsupportedError"
920-
}
918+
"errors": [{
919+
"$ref": "#/components/errors/unsupportedError"
920+
}]
921921
},
922922
{
923923
"name": "eth_submitWork",
@@ -977,9 +977,9 @@
977977
"name": "net_peerCount",
978978
"summary": "Always returns UNSUPPORTED_METHOD error.",
979979
"params": [],
980-
"result": {
981-
"$ref": "#/components/schemas/unsupportedError"
982-
}
980+
"errors": [{
981+
"$ref": "#/components/errors/unsupportedError"
982+
}]
983983
},
984984
{
985985
"name": "web3_clientVersion",
@@ -1253,20 +1253,26 @@
12531253
"name": "eth_getProof",
12541254
"summary": "Always returns UNSUPPORTED_METHOD error.",
12551255
"params": [],
1256-
"result": {
1257-
"$ref": "#/components/schemas/unsupportedError"
1258-
}
1256+
"errors": [{
1257+
"$ref": "#/components/errors/unsupportedError"
1258+
}]
12591259
},
12601260
{
12611261
"name": "eth_createAccessList",
12621262
"summary": "Always returns UNSUPPORTED_METHOD error.",
12631263
"params": [],
1264-
"result": {
1265-
"$ref": "#/components/schemas/unsupportedError"
1266-
}
1264+
"errors": [{
1265+
"$ref": "#/components/errors/unsupportedError"
1266+
}]
12671267
}
12681268
],
12691269
"components": {
1270+
"errors": {
1271+
"unsupportedError": {
1272+
"code": -32601,
1273+
"message": "Unsupported JSON-RPC method"
1274+
}
1275+
},
12701276
"schemas": {
12711277
"address": {
12721278
"title": "hex encoded address",
@@ -2133,24 +2139,6 @@
21332139
}
21342140
}
21352141
},
2136-
"unsupportedError": {
2137-
"name": "Unsupported Error",
2138-
"schema": {
2139-
"type": "object",
2140-
"properties": {
2141-
"code": {
2142-
"title": "Error code",
2143-
"type": "number",
2144-
"pattern": "-32601"
2145-
},
2146-
"message": {
2147-
"title": "Error message",
2148-
"type": "string",
2149-
"pattern": "Unsupported JSON-RPC method"
2150-
}
2151-
}
2152-
}
2153-
},
21542142
"callframe": {
21552143
"type": "object",
21562144
"properties": {

packages/relay/src/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ export interface Eth {
144144

145145
getFilterChanges(filterId: string, requestDetails: RequestDetails): Promise<string[] | Log[]>;
146146

147-
newPendingTransactionFilter(): Promise<JsonRpcError>;
147+
newPendingTransactionFilter(): JsonRpcError;
148148

149149
uninstallFilter(filterId: string, requestDetails: RequestDetails): Promise<boolean>;
150150

@@ -167,4 +167,6 @@ export interface Eth {
167167
accounts(requestDetails: RequestDetails): Array<any>;
168168

169169
getProof(): JsonRpcError;
170+
171+
createAccessList(): JsonRpcError;
170172
}

packages/relay/src/lib/eth.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,11 +415,11 @@ export class EthImpl implements Eth {
415415
*/
416416
@rpcMethod
417417
@rpcParamLayoutConfig(RPC_LAYOUT.REQUEST_DETAILS_ONLY)
418-
async newPendingTransactionFilter(): Promise<JsonRpcError> {
418+
newPendingTransactionFilter(): JsonRpcError {
419419
if (this.logger.isLevelEnabled('trace')) {
420420
this.logger.trace('newPendingTransactionFilter()');
421421
}
422-
return this.filterService.newPendingTransactionFilter();
422+
return predefined.UNSUPPORTED_METHOD;
423423
}
424424

425425
/**

packages/relay/src/lib/services/ethService/ethFilterService/FilterService.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Logger } from 'pino';
66
import { generateRandomHex, toHash32 } from '../../../../formatters';
77
import { MirrorNodeClient } from '../../../clients';
88
import constants from '../../../constants';
9-
import { JsonRpcError, predefined } from '../../../errors/JsonRpcError';
9+
import { predefined } from '../../../errors/JsonRpcError';
1010
import { Log } from '../../../model';
1111
import { RequestDetails } from '../../../types';
1212
import { INewFilterParams } from '../../../types/requestParams';
@@ -174,10 +174,6 @@ export class FilterService implements IFilterService {
174174
return false;
175175
}
176176

177-
public newPendingTransactionFilter(): JsonRpcError {
178-
return predefined.UNSUPPORTED_METHOD;
179-
}
180-
181177
public async getFilterLogs(filterId: string, requestDetails: RequestDetails): Promise<Log[]> {
182178
FilterService.requireFiltersEnabled();
183179

packages/relay/src/lib/services/ethService/ethFilterService/IFilterService.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ export interface IFilterService {
1111

1212
uninstallFilter(filterId: string, requestDetails: RequestDetails): Promise<boolean>;
1313

14-
newPendingTransactionFilter(requestDetails: RequestDetails): JsonRpcError;
15-
1614
getFilterLogs(filterId: string, requestDetails: RequestDetails): Promise<any>;
1715

1816
getFilterChanges(filterId: string, requestDetails: RequestDetails): Promise<string[] | Log[] | JsonRpcError>;

0 commit comments

Comments
 (0)