Add assertion that one cannot specify both blockHash & fromBlock/toBlock to getLogsAsync

This commit is contained in:
Fabio Berger 2018-09-21 13:43:06 +01:00
parent 4e8ec2359d
commit e6840c60c7

View File

@ -438,6 +438,10 @@ export class Web3Wrapper {
* @returns The corresponding log entries
*/
public async getLogsAsync(filter: FilterObject): Promise<LogEntry[]> {
if (!_.isUndefined(filter.blockHash) && (!_.isUndefined(filter.fromBlock) || !_.isUndefined(filter.toBlock))) {
throw new Error(`Cannot specify 'blockHash' as well as 'fromBlock'/'toBlock' in the filter supplied to 'getLogsAsync'`);
}
let fromBlock = filter.fromBlock;
if (_.isNumber(fromBlock)) {
fromBlock = utils.numberToHex(fromBlock);