@@ -6,7 +6,7 @@ import { Logger } from 'pino';
66import { Eth } from '../index' ;
77import { MirrorNodeClient } from './clients' ;
88import constants from './constants' ;
9- import { cache , RPC_LAYOUT , rpcMethod , rpcParamLayoutConfig , rpcParamValidationRules } from './decorators' ;
9+ import { cache , RPC_LAYOUT , rpcMethod , rpcParamLayoutConfig } from './decorators' ;
1010import { JsonRpcError , predefined } from './errors/JsonRpcError' ;
1111import { Block , Log , Receipt , Transaction } from './model' ;
1212import {
@@ -34,7 +34,7 @@ import {
3434 ITransactionReceipt ,
3535 RequestDetails ,
3636} from './types' ;
37- import { ParamType } from './types/validation ' ;
37+ import { rpcParamValidationRules } from './validators ' ;
3838
3939/**
4040 * Implementation of the "eth_" methods from the Ethereum JSON-RPC API.
@@ -175,9 +175,9 @@ export class EthImpl implements Eth {
175175 */
176176 @rpcMethod
177177 @rpcParamValidationRules ( {
178- 0 : { type : ParamType . HEX , required : true } ,
179- 1 : { type : ParamType . BLOCK_NUMBER , required : true } ,
180- 2 : { type : ParamType . ARRAY , required : false } ,
178+ 0 : { type : 'hex' , required : true } ,
179+ 1 : { type : 'blockNumber' , required : true } ,
180+ 2 : { type : 'array' , required : false } ,
181181 } )
182182 @rpcParamLayoutConfig ( RPC_LAYOUT . custom ( ( params ) => [ Number ( params [ 0 ] ) , params [ 1 ] , params [ 2 ] ] ) )
183183 @cache ( CacheService . getInstance ( CACHE_LEVEL . L1 ) , {
@@ -248,8 +248,8 @@ export class EthImpl implements Eth {
248248 */
249249 @rpcMethod
250250 @rpcParamValidationRules ( {
251- 0 : { type : ParamType . TRANSACTION , required : true } ,
252- 1 : { type : ParamType . BLOCK_NUMBER , required : false } ,
251+ 0 : { type : 'transaction' , required : true } ,
252+ 1 : { type : 'blockNumber' , required : false } ,
253253 } )
254254 @rpcParamLayoutConfig ( RPC_LAYOUT . custom ( ( params ) => [ params [ 0 ] , params [ 1 ] ] ) )
255255 async estimateGas (
@@ -322,7 +322,7 @@ export class EthImpl implements Eth {
322322 */
323323 @rpcMethod
324324 @rpcParamValidationRules ( {
325- 0 : { type : ParamType . FILTER , required : true } ,
325+ 0 : { type : 'filter' , required : true } ,
326326 } )
327327 async newFilter ( params : INewFilterParams , requestDetails : RequestDetails ) : Promise < string > {
328328 const requestIdPrefix = requestDetails . formattedRequestId ;
@@ -344,7 +344,7 @@ export class EthImpl implements Eth {
344344 */
345345 @rpcMethod
346346 @rpcParamValidationRules ( {
347- 0 : { type : ParamType . HEX , required : true } ,
347+ 0 : { type : 'hex' , required : true } ,
348348 } )
349349 async getFilterLogs ( filterId : string , requestDetails : RequestDetails ) : Promise < Log [ ] > {
350350 if ( this . logger . isLevelEnabled ( 'trace' ) ) {
@@ -365,7 +365,7 @@ export class EthImpl implements Eth {
365365 */
366366 @rpcMethod
367367 @rpcParamValidationRules ( {
368- 0 : { type : ParamType . HEX , required : true } ,
368+ 0 : { type : 'hex' , required : true } ,
369369 } )
370370 async getFilterChanges ( filterId : string , requestDetails : RequestDetails ) : Promise < string [ ] | Log [ ] > {
371371 if ( this . logger . isLevelEnabled ( 'trace' ) ) {
@@ -404,7 +404,7 @@ export class EthImpl implements Eth {
404404 */
405405 @rpcMethod
406406 @rpcParamValidationRules ( {
407- 0 : { type : ParamType . HEX , required : true } ,
407+ 0 : { type : 'hex' , required : true } ,
408408 } )
409409 async uninstallFilter ( filterId : string , requestDetails : RequestDetails ) : Promise < boolean > {
410410 if ( this . logger . isLevelEnabled ( 'trace' ) ) {
@@ -677,9 +677,9 @@ export class EthImpl implements Eth {
677677 */
678678 @rpcMethod
679679 @rpcParamValidationRules ( {
680- 0 : { type : ParamType . ADDRESS , required : true } ,
681- 1 : { type : ParamType . HEX64 , required : true } ,
682- 2 : { type : ParamType . BLOCK_NUMBER_OR_HASH , required : true } ,
680+ 0 : { type : 'address' , required : true } ,
681+ 1 : { type : 'hex64' , required : true } ,
682+ 2 : { type : [ 'blockNumber' , 'blockHash' ] , required : true } ,
683683 } )
684684 @rpcParamLayoutConfig ( RPC_LAYOUT . custom ( ( params ) => [ params [ 0 ] , params [ 1 ] , params [ 2 ] ] ) )
685685 @cache ( CacheService . getInstance ( CACHE_LEVEL . L1 ) , {
@@ -708,8 +708,8 @@ export class EthImpl implements Eth {
708708 */
709709 @rpcMethod
710710 @rpcParamValidationRules ( {
711- 0 : { type : ParamType . ADDRESS , required : true } ,
712- 1 : { type : ParamType . BLOCK_NUMBER_OR_HASH , required : true } ,
711+ 0 : { type : 'address' , required : true } ,
712+ 1 : { type : [ 'blockNumber' , 'blockHash' ] , required : true } ,
713713 } )
714714 @cache ( CacheService . getInstance ( CACHE_LEVEL . L1 ) , {
715715 skipParams : [ { index : '1' , value : constants . NON_CACHABLE_BLOCK_PARAMS } ] ,
@@ -736,8 +736,8 @@ export class EthImpl implements Eth {
736736 */
737737 @rpcMethod
738738 @rpcParamValidationRules ( {
739- 0 : { type : ParamType . ADDRESS , required : true } ,
740- 1 : { type : ParamType . BLOCK_NUMBER_OR_HASH , required : true } ,
739+ 0 : { type : 'address' , required : true } ,
740+ 1 : { type : [ 'blockNumber' , 'blockHash' ] , required : true } ,
741741 } )
742742 @cache ( CacheService . getInstance ( CACHE_LEVEL . L1 ) , {
743743 skipParams : [ { index : '1' , value : constants . NON_CACHABLE_BLOCK_PARAMS } ] ,
@@ -763,8 +763,8 @@ export class EthImpl implements Eth {
763763 */
764764 @rpcMethod
765765 @rpcParamValidationRules ( {
766- 0 : { type : ParamType . BLOCK_HASH , required : true } ,
767- 1 : { type : ParamType . BOOLEAN , required : true } ,
766+ 0 : { type : 'blockHash' , required : true } ,
767+ 1 : { type : 'boolean' , required : true } ,
768768 } )
769769 @cache ( CacheService . getInstance ( CACHE_LEVEL . L1 ) )
770770 async getBlockByHash ( hash : string , showDetails : boolean , requestDetails : RequestDetails ) : Promise < Block | null > {
@@ -783,7 +783,7 @@ export class EthImpl implements Eth {
783783 */
784784 @rpcMethod
785785 @rpcParamValidationRules ( {
786- 0 : { type : ParamType . BLOCK_HASH , required : true } ,
786+ 0 : { type : 'blockHash' , required : true } ,
787787 } )
788788 @cache ( CacheService . getInstance ( CACHE_LEVEL . L1 ) )
789789 async getBlockTransactionCountByHash ( hash : string , requestDetails : RequestDetails ) : Promise < string | null > {
@@ -802,7 +802,7 @@ export class EthImpl implements Eth {
802802 */
803803 @rpcMethod
804804 @rpcParamValidationRules ( {
805- 0 : { type : ParamType . BLOCK_NUMBER , required : true } ,
805+ 0 : { type : 'blockNumber' , required : true } ,
806806 } )
807807 @cache ( CacheService . getInstance ( CACHE_LEVEL . L1 ) , {
808808 skipParams : [ { index : '0' , value : constants . NON_CACHABLE_BLOCK_PARAMS } ] ,
@@ -827,8 +827,8 @@ export class EthImpl implements Eth {
827827 */
828828 @rpcMethod
829829 @rpcParamValidationRules ( {
830- 0 : { type : ParamType . BLOCK_HASH , required : true } ,
831- 1 : { type : ParamType . HEX , required : true } ,
830+ 0 : { type : 'blockHash' , required : true } ,
831+ 1 : { type : 'hex' , required : true } ,
832832 } )
833833 @cache ( CacheService . getInstance ( CACHE_LEVEL . L1 ) )
834834 async getTransactionByBlockHashAndIndex (
@@ -852,8 +852,8 @@ export class EthImpl implements Eth {
852852 */
853853 @rpcMethod
854854 @rpcParamValidationRules ( {
855- 0 : { type : ParamType . BLOCK_NUMBER , required : true } ,
856- 1 : { type : ParamType . HEX , required : true } ,
855+ 0 : { type : 'blockNumber' , required : true } ,
856+ 1 : { type : 'hex' , required : true } ,
857857 } )
858858 @cache ( CacheService . getInstance ( CACHE_LEVEL . L1 ) , {
859859 skipParams : [ { index : '0' , value : constants . NON_CACHABLE_BLOCK_PARAMS } ] ,
@@ -883,8 +883,8 @@ export class EthImpl implements Eth {
883883 */
884884 @rpcMethod
885885 @rpcParamValidationRules ( {
886- 0 : { type : ParamType . BLOCK_NUMBER , required : true } ,
887- 1 : { type : ParamType . BOOLEAN , required : true } ,
886+ 0 : { type : 'blockNumber' , required : true } ,
887+ 1 : { type : 'boolean' , required : true } ,
888888 } )
889889 @cache ( CacheService . getInstance ( CACHE_LEVEL . L1 ) , {
890890 skipParams : [ { index : '0' , value : constants . NON_CACHABLE_BLOCK_PARAMS } ] ,
@@ -913,8 +913,8 @@ export class EthImpl implements Eth {
913913 */
914914 @rpcMethod
915915 @rpcParamValidationRules ( {
916- 0 : { type : ParamType . ADDRESS , required : true } ,
917- 1 : { type : ParamType . BLOCK_NUMBER_OR_HASH , required : true } ,
916+ 0 : { type : 'address' , required : true } ,
917+ 1 : { type : [ 'blockNumber' , 'blockHash' ] , required : true } ,
918918 } )
919919 @cache ( CacheService . getInstance ( CACHE_LEVEL . L1 ) , {
920920 skipParams : [ { index : '1' , value : constants . NON_CACHABLE_BLOCK_PARAMS } ] ,
@@ -939,7 +939,7 @@ export class EthImpl implements Eth {
939939 */
940940 @rpcMethod
941941 @rpcParamValidationRules ( {
942- 0 : { type : ParamType . HEX , required : true } ,
942+ 0 : { type : 'hex' , required : true } ,
943943 } )
944944 async sendRawTransaction ( transaction : string , requestDetails : RequestDetails ) : Promise < string | JsonRpcError > {
945945 return await this . transactionService . sendRawTransaction ( transaction , requestDetails ) ;
@@ -958,8 +958,8 @@ export class EthImpl implements Eth {
958958 */
959959 @rpcMethod
960960 @rpcParamValidationRules ( {
961- 0 : { type : ParamType . TRANSACTION , required : true } ,
962- 1 : { type : ParamType . BLOCK_PARAMS , required : true } ,
961+ 0 : { type : 'transaction' , required : true } ,
962+ 1 : { type : 'blockParams' , required : true } ,
963963 } )
964964 @cache ( CacheService . getInstance ( CACHE_LEVEL . L1 ) , {
965965 skipParams : [ { index : '1' , value : constants . NON_CACHABLE_BLOCK_PARAMS } ] ,
@@ -1001,7 +1001,7 @@ export class EthImpl implements Eth {
10011001 */
10021002 @rpcMethod
10031003 @rpcParamValidationRules ( {
1004- 0 : { type : ParamType . TRANSACTION_HASH , required : true } ,
1004+ 0 : { type : 'transactionHash' , required : true } ,
10051005 } )
10061006 @cache ( CacheService . getInstance ( CACHE_LEVEL . L1 ) )
10071007 async getTransactionByHash ( hash : string , requestDetails : RequestDetails ) : Promise < Transaction | null > {
@@ -1019,7 +1019,7 @@ export class EthImpl implements Eth {
10191019 */
10201020 @rpcMethod
10211021 @rpcParamValidationRules ( {
1022- 0 : { type : ParamType . TRANSACTION_HASH , required : true } ,
1022+ 0 : { type : 'transactionHash' , required : true } ,
10231023 } )
10241024 @cache ( CacheService . getInstance ( CACHE_LEVEL . L1 ) )
10251025 async getTransactionReceipt ( hash : string , requestDetails : RequestDetails ) : Promise < any > {
@@ -1058,7 +1058,7 @@ export class EthImpl implements Eth {
10581058 */
10591059 @rpcMethod
10601060 @rpcParamValidationRules ( {
1061- 0 : { type : ParamType . FILTER , required : true } ,
1061+ 0 : { type : 'filter' , required : true } ,
10621062 } )
10631063 @cache ( CacheService . getInstance ( CACHE_LEVEL . L1 ) , {
10641064 skipNamedParams : [
@@ -1106,7 +1106,7 @@ export class EthImpl implements Eth {
11061106 */
11071107 @rpcMethod
11081108 @rpcParamValidationRules ( {
1109- 0 : { type : ParamType . BLOCK_NUMBER_OR_HASH , required : true } ,
1109+ 0 : { type : [ 'blockNumber' , 'blockHash' ] , required : true } ,
11101110 } )
11111111 @cache ( CacheService . getInstance ( CACHE_LEVEL . L1 ) , {
11121112 skipParams : [ { index : '0' , value : constants . NON_CACHABLE_BLOCK_PARAMS } ] ,
0 commit comments