Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support blockHash in getLogs (EIP-234) #412

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all 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
8 changes: 7 additions & 1 deletion providers/abstract-provider.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,18 @@ export interface Block {
transactions: Array<string>;
}
export declare type BlockTag = string | number;
export declare type Filter = {
export declare type FilterByBlockHash = {
blockHash: string;
address?: string;
topics?: Array<string | Array<string>>;
};
export declare type FilterByBlockRange = {
fromBlock?: BlockTag;
toBlock?: BlockTag;
address?: string;
topics?: Array<string | Array<string>>;
};
export declare type Filter = FilterByBlockHash | FilterByBlockRange;
export interface Log {
blockNumber?: number;
blockHash?: string;
Expand Down
1 change: 1 addition & 0 deletions providers/base-provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
10 changes: 9 additions & 1 deletion src.ts/providers/abstract-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,21 @@ export interface Block {

export type BlockTag = string | number;

export type Filter = {
export type FilterByBlockHash = {
blockHash: string;
address?: string,
topics?: Array<string | Array<string>>,
}

export type FilterByBlockRange = {
fromBlock?: BlockTag,
toBlock?: BlockTag,
address?: string,
topics?: Array<string | Array<string>>,
}

export type Filter = FilterByBlockHash | FilterByBlockRange;

export interface Log {
blockNumber?: number;
blockHash?: string;
Expand Down
1 change: 1 addition & 0 deletions src.ts/providers/base-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down