Skip to content
Merged
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
4 changes: 4 additions & 0 deletions types/ethereum-block-by-date/ethereum-block-by-date-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@ dater.getDate(new Date());
dater.getDate('2016-07-20T13:20:40Z');
// $ExpectType BlockResult
dater.getDate('2016-07-20T13:20:40Z', false);
// $ExpectType BlockResult
dater.getDate('2016-07-20T13:20:40Z', false, true);

// $ExpectType BlockResult[]
dater.getEvery('weeks', '2019-09-02T12:00:00Z', '2019-09-30T12:00:00Z');
// $ExpectType BlockResult[]
dater.getEvery('weeks', '2019-09-02T12:00:00Z', '2019-09-30T12:00:00Z', 2);
// $ExpectType BlockResult[]
dater.getEvery('weeks', '2019-09-02T12:00:00Z', '2019-09-30T12:00:00Z', 3, false);
// $ExpectType BlockResult[]
dater.getEvery('weeks', '2019-09-02T12:00:00Z', '2019-09-30T12:00:00Z', 3, false, true);
28 changes: 16 additions & 12 deletions types/ethereum-block-by-date/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Type definitions for ethereum-block-by-date 1.4
// Project: https://github.com/monosux/ethereum-block-by-date
// Definitions by: Alexandre ABRIOUX <https://github.com/alexandre-abrioux>
// Definitions by: Alexandre Abrioux <https://github.com/alexandre-abrioux>
// Alexeev Sergey <https://github.com/monosux>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

import { DurationInputObject, MomentInput } from 'moment';
Expand All @@ -19,29 +20,32 @@ declare namespace EthDater {
}

declare class EthDater {
constructor(provider: EthersProviders.Provider | Web3);
constructor(web3: EthersProviders.Provider | Web3);

/**
* Search for the closest block on the chain corresponding to the input date.
* @param date Date, required. Any valid moment.js value: string, milliseconds, Date() object, moment() object.
* @param blockAfter Block after, optional. Search for the nearest block before or after the given date. By default, true.
* @param after Block after, optional. Search for the nearest block before or after the given date. By default, true.
* @param refresh Refresh boundaries, optional. Recheck the latest block before request. By default, false.
*/
getDate(date: MomentInput, blockAfter?: boolean): EthDater.BlockResult;
getDate(date: MomentInput, after?: boolean, refresh?: boolean): EthDater.BlockResult;

/**
* Returns an array of blocks corresponding to periods.
* For example: every first block of Monday's noons of October 2019.
* @param period Period, required. Valid value: years, quarters, months, weeks, days, hours, minutes.
* @param startDate Start date, required. Any valid moment.js value: string, milliseconds, Date() object, moment() object.
* @param endDate End date, required. Any valid moment.js value: string, milliseconds, Date() object, moment() object.
* @param duration Period, required. Valid value: years, quarters, months, weeks, days, hours, minutes.
* @param start Start date, required. Any valid moment.js value: string, milliseconds, Date() object, moment() object.
* @param end End date, required. Any valid moment.js value: string, milliseconds, Date() object, moment() object.
* @param every Duration, optional, integer. By default, 1.
* @param blockAfter Block after, optional. Search for the nearest block before or after the given date. By default, true.
* @param after Block after, optional. Search for the nearest block before or after the given date. By default, true.
* @param refresh Refresh boundaries, optional. Recheck the latest block before request. By default, false.
*/
getEvery(
period: keyof DurationInputObject,
startDate: MomentInput,
endDate: MomentInput,
duration: keyof DurationInputObject,
start: MomentInput,
end: MomentInput,
every?: number,
blockAfter?: boolean,
after?: boolean,
refresh?: boolean,
): EthDater.BlockResult[];
}