Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions packages/relay/src/lib/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { MirrorNodeClient } from './clients';
import { IOpcode } from './clients/models/IOpcode';
import { IOpcodesResponse } from './clients/models/IOpcodesResponse';
import constants, { CallType, TracerType } from './constants';
import { cache, RPC_LAYOUT, rpcMethod, rpcParamLayoutConfig, rpcParamValidationRules } from './decorators';
import { cache, RPC_LAYOUT, rpcMethod, rpcParamLayoutConfig } from './decorators';
import { predefined } from './errors/JsonRpcError';
import { CommonService } from './services';
import { CACHE_LEVEL, CacheService } from './services/cacheService/cacheService';
Expand All @@ -20,11 +20,11 @@ import {
ICallTracerConfig,
IOpcodeLoggerConfig,
MirrorNodeContractResult,
ParamType,
RequestDetails,
TraceBlockByNumberTxResult,
TransactionTracerConfig,
} from './types';
import { rpcParamValidationRules } from './validators';

/**
* Represents a DebugService for tracing and debugging transactions.
Expand Down Expand Up @@ -105,8 +105,8 @@ export class DebugImpl implements Debug {
*/
@rpcMethod
@rpcParamValidationRules({
0: { type: ParamType.TRANSACTION_HASH_OR_ID, required: true },
1: { type: ParamType.TRACER_CONFIG_WRAPPER, required: false },
0: { type: 'transactionHash', required: true },
1: { type: 'tracerConfigWrapper', required: true },
})
@rpcParamLayoutConfig(RPC_LAYOUT.custom((params) => [params[0], params[1]]))
@cache(CacheService.getInstance(CACHE_LEVEL.L1))
Expand Down Expand Up @@ -161,8 +161,8 @@ export class DebugImpl implements Debug {
*/
@rpcMethod
@rpcParamValidationRules({
0: { type: ParamType.BLOCK_NUMBER, required: true },
1: { type: ParamType.TRACER_CONFIG_WRAPPER, required: false },
0: { type: 'blockNumber', required: true },
1: { type: 'tracerConfigWrapper', required: false },
})
@rpcParamLayoutConfig(RPC_LAYOUT.custom((params) => [params[0], params[1]]))
@cache(CacheService.getInstance(CACHE_LEVEL.L1), {
Expand Down
1 change: 0 additions & 1 deletion packages/relay/src/lib/decorators/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

export * from './rpcMethod.decorator';
export * from './rpcParamValidationRules.decorator';
export * from './rpcParamLayoutConfig.decorator';
export * from './cache.decorator';

This file was deleted.

5 changes: 2 additions & 3 deletions packages/relay/src/lib/dispatcher/rpcMethodDispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
import { Logger } from 'pino';

import { Utils } from '../../utils';
import { RPC_PARAM_VALIDATION_RULES_KEY } from '../decorators';
import { JsonRpcError } from '../errors/JsonRpcError';
import { predefined } from '../errors/JsonRpcError';
import { MirrorNodeClientError } from '../errors/MirrorNodeClientError';
import { SDKClientError } from '../errors/SDKClientError';
import { OperationHandler, RequestDetails, RpcMethodRegistry } from '../types';
import { Validator } from '../validators';
import { RPC_PARAM_VALIDATION_RULES_KEY, validateParams } from '../validators';

/**
* Dispatches JSON-RPC method calls to their appropriate handlers
Expand Down Expand Up @@ -105,7 +104,7 @@ export class RpcMethodDispatcher {
} Validating method parameters for ${rpcMethodName}, params: ${JSON.stringify(rpcMethodParams)}`,
);
}
Validator.validateParams(rpcMethodParams, methodParamSchemas);
validateParams(rpcMethodParams, methodParamSchemas);
}

return operationHandler;
Expand Down
74 changes: 37 additions & 37 deletions packages/relay/src/lib/eth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Logger } from 'pino';
import { Eth } from '../index';
import { MirrorNodeClient } from './clients';
import constants from './constants';
import { cache, RPC_LAYOUT, rpcMethod, rpcParamLayoutConfig, rpcParamValidationRules } from './decorators';
import { cache, RPC_LAYOUT, rpcMethod, rpcParamLayoutConfig } from './decorators';
import { JsonRpcError, predefined } from './errors/JsonRpcError';
import { Block, Log, Receipt, Transaction } from './model';
import {
Expand Down Expand Up @@ -34,7 +34,7 @@ import {
ITransactionReceipt,
RequestDetails,
} from './types';
import { ParamType } from './types/validation';
import { rpcParamValidationRules } from './validators';

/**
* Implementation of the "eth_" methods from the Ethereum JSON-RPC API.
Expand Down Expand Up @@ -175,9 +175,9 @@ export class EthImpl implements Eth {
*/
@rpcMethod
@rpcParamValidationRules({
0: { type: ParamType.HEX, required: true },
1: { type: ParamType.BLOCK_NUMBER, required: true },
2: { type: ParamType.ARRAY, required: false },
0: { type: 'hex', required: true },
1: { type: 'blockNumber', required: true },
2: { type: 'array', required: false },
})
@rpcParamLayoutConfig(RPC_LAYOUT.custom((params) => [Number(params[0]), params[1], params[2]]))
@cache(CacheService.getInstance(CACHE_LEVEL.L1), {
Expand Down Expand Up @@ -248,8 +248,8 @@ export class EthImpl implements Eth {
*/
@rpcMethod
@rpcParamValidationRules({
0: { type: ParamType.TRANSACTION, required: true },
1: { type: ParamType.BLOCK_NUMBER, required: false },
0: { type: 'transaction', required: true },
1: { type: 'blockNumber', required: false },
})
@rpcParamLayoutConfig(RPC_LAYOUT.custom((params) => [params[0], params[1]]))
async estimateGas(
Expand Down Expand Up @@ -322,7 +322,7 @@ export class EthImpl implements Eth {
*/
@rpcMethod
@rpcParamValidationRules({
0: { type: ParamType.FILTER, required: true },
0: { type: 'filter', required: true },
})
async newFilter(params: INewFilterParams, requestDetails: RequestDetails): Promise<string> {
const requestIdPrefix = requestDetails.formattedRequestId;
Expand All @@ -344,7 +344,7 @@ export class EthImpl implements Eth {
*/
@rpcMethod
@rpcParamValidationRules({
0: { type: ParamType.HEX, required: true },
0: { type: 'hex', required: true },
})
async getFilterLogs(filterId: string, requestDetails: RequestDetails): Promise<Log[]> {
if (this.logger.isLevelEnabled('trace')) {
Expand All @@ -365,7 +365,7 @@ export class EthImpl implements Eth {
*/
@rpcMethod
@rpcParamValidationRules({
0: { type: ParamType.HEX, required: true },
0: { type: 'hex', required: true },
})
async getFilterChanges(filterId: string, requestDetails: RequestDetails): Promise<string[] | Log[]> {
if (this.logger.isLevelEnabled('trace')) {
Expand Down Expand Up @@ -404,7 +404,7 @@ export class EthImpl implements Eth {
*/
@rpcMethod
@rpcParamValidationRules({
0: { type: ParamType.HEX, required: true },
0: { type: 'hex', required: true },
})
async uninstallFilter(filterId: string, requestDetails: RequestDetails): Promise<boolean> {
if (this.logger.isLevelEnabled('trace')) {
Expand Down Expand Up @@ -677,9 +677,9 @@ export class EthImpl implements Eth {
*/
@rpcMethod
@rpcParamValidationRules({
0: { type: ParamType.ADDRESS, required: true },
1: { type: ParamType.HEX64, required: true },
2: { type: ParamType.BLOCK_NUMBER_OR_HASH, required: true },
0: { type: 'address', required: true },
1: { type: 'hex64', required: true },
2: { type: ['blockNumber', 'blockHash'], required: true },
})
@rpcParamLayoutConfig(RPC_LAYOUT.custom((params) => [params[0], params[1], params[2]]))
@cache(CacheService.getInstance(CACHE_LEVEL.L1), {
Expand Down Expand Up @@ -708,8 +708,8 @@ export class EthImpl implements Eth {
*/
@rpcMethod
@rpcParamValidationRules({
0: { type: ParamType.ADDRESS, required: true },
1: { type: ParamType.BLOCK_NUMBER_OR_HASH, required: true },
0: { type: 'address', required: true },
1: { type: ['blockNumber', 'blockHash'], required: true },
})
@cache(CacheService.getInstance(CACHE_LEVEL.L1), {
skipParams: [{ index: '1', value: constants.NON_CACHABLE_BLOCK_PARAMS }],
Expand All @@ -736,8 +736,8 @@ export class EthImpl implements Eth {
*/
@rpcMethod
@rpcParamValidationRules({
0: { type: ParamType.ADDRESS, required: true },
1: { type: ParamType.BLOCK_NUMBER_OR_HASH, required: true },
0: { type: 'address', required: true },
1: { type: ['blockNumber', 'blockHash'], required: true },
})
@cache(CacheService.getInstance(CACHE_LEVEL.L1), {
skipParams: [{ index: '1', value: constants.NON_CACHABLE_BLOCK_PARAMS }],
Expand All @@ -763,8 +763,8 @@ export class EthImpl implements Eth {
*/
@rpcMethod
@rpcParamValidationRules({
0: { type: ParamType.BLOCK_HASH, required: true },
1: { type: ParamType.BOOLEAN, required: true },
0: { type: 'blockHash', required: true },
1: { type: 'boolean', required: true },
})
@cache(CacheService.getInstance(CACHE_LEVEL.L1))
async getBlockByHash(hash: string, showDetails: boolean, requestDetails: RequestDetails): Promise<Block | null> {
Expand All @@ -783,7 +783,7 @@ export class EthImpl implements Eth {
*/
@rpcMethod
@rpcParamValidationRules({
0: { type: ParamType.BLOCK_HASH, required: true },
0: { type: 'blockHash', required: true },
})
@cache(CacheService.getInstance(CACHE_LEVEL.L1))
async getBlockTransactionCountByHash(hash: string, requestDetails: RequestDetails): Promise<string | null> {
Expand All @@ -802,7 +802,7 @@ export class EthImpl implements Eth {
*/
@rpcMethod
@rpcParamValidationRules({
0: { type: ParamType.BLOCK_NUMBER, required: true },
0: { type: 'blockNumber', required: true },
})
@cache(CacheService.getInstance(CACHE_LEVEL.L1), {
skipParams: [{ index: '0', value: constants.NON_CACHABLE_BLOCK_PARAMS }],
Expand All @@ -827,8 +827,8 @@ export class EthImpl implements Eth {
*/
@rpcMethod
@rpcParamValidationRules({
0: { type: ParamType.BLOCK_HASH, required: true },
1: { type: ParamType.HEX, required: true },
0: { type: 'blockHash', required: true },
1: { type: 'hex', required: true },
})
@cache(CacheService.getInstance(CACHE_LEVEL.L1))
async getTransactionByBlockHashAndIndex(
Expand All @@ -852,8 +852,8 @@ export class EthImpl implements Eth {
*/
@rpcMethod
@rpcParamValidationRules({
0: { type: ParamType.BLOCK_NUMBER, required: true },
1: { type: ParamType.HEX, required: true },
0: { type: 'blockNumber', required: true },
1: { type: 'hex', required: true },
})
@cache(CacheService.getInstance(CACHE_LEVEL.L1), {
skipParams: [{ index: '0', value: constants.NON_CACHABLE_BLOCK_PARAMS }],
Expand Down Expand Up @@ -883,8 +883,8 @@ export class EthImpl implements Eth {
*/
@rpcMethod
@rpcParamValidationRules({
0: { type: ParamType.BLOCK_NUMBER, required: true },
1: { type: ParamType.BOOLEAN, required: true },
0: { type: 'blockNumber', required: true },
1: { type: 'boolean', required: true },
})
@cache(CacheService.getInstance(CACHE_LEVEL.L1), {
skipParams: [{ index: '0', value: constants.NON_CACHABLE_BLOCK_PARAMS }],
Expand Down Expand Up @@ -913,8 +913,8 @@ export class EthImpl implements Eth {
*/
@rpcMethod
@rpcParamValidationRules({
0: { type: ParamType.ADDRESS, required: true },
1: { type: ParamType.BLOCK_NUMBER_OR_HASH, required: true },
0: { type: 'address', required: true },
1: { type: ['blockNumber', 'blockHash'], required: true },
})
@cache(CacheService.getInstance(CACHE_LEVEL.L1), {
skipParams: [{ index: '1', value: constants.NON_CACHABLE_BLOCK_PARAMS }],
Expand All @@ -939,7 +939,7 @@ export class EthImpl implements Eth {
*/
@rpcMethod
@rpcParamValidationRules({
0: { type: ParamType.HEX, required: true },
0: { type: 'hex', required: true },
})
async sendRawTransaction(transaction: string, requestDetails: RequestDetails): Promise<string | JsonRpcError> {
return await this.transactionService.sendRawTransaction(transaction, requestDetails);
Expand All @@ -958,8 +958,8 @@ export class EthImpl implements Eth {
*/
@rpcMethod
@rpcParamValidationRules({
0: { type: ParamType.TRANSACTION, required: true },
1: { type: ParamType.BLOCK_PARAMS, required: true },
0: { type: 'transaction', required: true },
1: { type: 'blockParams', required: true },
})
@cache(CacheService.getInstance(CACHE_LEVEL.L1), {
skipParams: [{ index: '1', value: constants.NON_CACHABLE_BLOCK_PARAMS }],
Expand Down Expand Up @@ -1001,7 +1001,7 @@ export class EthImpl implements Eth {
*/
@rpcMethod
@rpcParamValidationRules({
0: { type: ParamType.TRANSACTION_HASH, required: true },
0: { type: 'transactionHash', required: true },
})
@cache(CacheService.getInstance(CACHE_LEVEL.L1))
async getTransactionByHash(hash: string, requestDetails: RequestDetails): Promise<Transaction | null> {
Expand All @@ -1019,7 +1019,7 @@ export class EthImpl implements Eth {
*/
@rpcMethod
@rpcParamValidationRules({
0: { type: ParamType.TRANSACTION_HASH, required: true },
0: { type: 'transactionHash', required: true },
})
@cache(CacheService.getInstance(CACHE_LEVEL.L1))
async getTransactionReceipt(hash: string, requestDetails: RequestDetails): Promise<any> {
Expand Down Expand Up @@ -1058,7 +1058,7 @@ export class EthImpl implements Eth {
*/
@rpcMethod
@rpcParamValidationRules({
0: { type: ParamType.FILTER, required: true },
0: { type: 'filter', required: true },
})
@cache(CacheService.getInstance(CACHE_LEVEL.L1), {
skipNamedParams: [
Expand Down Expand Up @@ -1106,7 +1106,7 @@ export class EthImpl implements Eth {
*/
@rpcMethod
@rpcParamValidationRules({
0: { type: ParamType.BLOCK_NUMBER_OR_HASH, required: true },
0: { type: ['blockNumber', 'blockHash'], required: true },
})
@cache(CacheService.getInstance(CACHE_LEVEL.L1), {
skipParams: [{ index: '0', value: constants.NON_CACHABLE_BLOCK_PARAMS }],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: Apache-2.0
import { RPC_METHOD_KEY, RPC_PARAM_LAYOUT_KEY, RPC_PARAM_VALIDATION_RULES_KEY } from '../../decorators';
import { RPC_METHOD_KEY, RPC_PARAM_LAYOUT_KEY } from '../../decorators';
import { RpcMethodRegistry, RpcNamespaceRegistry } from '../../types';
import { RPC_PARAM_VALIDATION_RULES_KEY } from '../../validators';

/**
* Registers RPC methods from the provided service implementations.
Expand Down
1 change: 0 additions & 1 deletion packages/relay/src/lib/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@ export * from './RequestDetails';
export * from './requestParams';
export * from './spendingPlanConfig';
export * from './registry';
export * from './validation';
export * from './debug';
export * from './rateLimiter';
Loading
Loading