diff --git a/providers/abstract-provider.d.ts b/providers/abstract-provider.d.ts index b93953897c..1c05b95f04 100644 --- a/providers/abstract-provider.d.ts +++ b/providers/abstract-provider.d.ts @@ -18,12 +18,18 @@ export interface Block { transactions: Array; } export declare type BlockTag = string | number; -export declare type Filter = { +export declare type FilterByBlockHash = { + blockHash: string; + address?: string; + topics?: Array>; +}; +export declare type FilterByBlockRange = { fromBlock?: BlockTag; toBlock?: BlockTag; address?: string; topics?: Array>; }; +export declare type Filter = FilterByBlockHash | FilterByBlockRange; export interface Log { blockNumber?: number; blockHash?: string; diff --git a/providers/base-provider.js b/providers/base-provider.js index 950934f44a..8cc97e0eef 100644 --- a/providers/base-provider.js +++ b/providers/base-provider.js @@ -321,6 +321,7 @@ function checkTopics(topics) { return topics; } var formatFilter = { + blockHash: allowNull(checkHash, undefined), fromBlock: allowNull(checkBlockTag, undefined), toBlock: allowNull(checkBlockTag, undefined), address: allowNull(address_1.getAddress, undefined), diff --git a/src.ts/providers/abstract-provider.ts b/src.ts/providers/abstract-provider.ts index e70730e764..d41be97200 100644 --- a/src.ts/providers/abstract-provider.ts +++ b/src.ts/providers/abstract-provider.ts @@ -34,13 +34,21 @@ export interface Block { export type BlockTag = string | number; -export type Filter = { +export type FilterByBlockHash = { + blockHash: string; + address?: string, + topics?: Array>, +} + +export type FilterByBlockRange = { fromBlock?: BlockTag, toBlock?: BlockTag, address?: string, topics?: Array>, } +export type Filter = FilterByBlockHash | FilterByBlockRange; + export interface Log { blockNumber?: number; blockHash?: string; diff --git a/src.ts/providers/base-provider.ts b/src.ts/providers/base-provider.ts index 625a0439f9..7b887aa58d 100644 --- a/src.ts/providers/base-provider.ts +++ b/src.ts/providers/base-provider.ts @@ -360,6 +360,7 @@ function checkTopics(topics: any): any { } const formatFilter = { + blockHash: allowNull(checkHash, undefined), fromBlock: allowNull(checkBlockTag, undefined), toBlock: allowNull(checkBlockTag, undefined), address: allowNull(getAddress, undefined),