1
0
mirror of https://github.com/oceanprotocol/ocean.js.git synced 2024-11-26 20:39:05 +01:00

add optional fromBlock

This commit is contained in:
alexcos20 2020-10-01 06:23:56 -07:00
parent 4d00c882df
commit 386bb892ac

View File

@ -596,11 +596,13 @@ export class Assets extends Instantiable {
* get Order History * get Order History
* @param {Account} account * @param {Account} account
* @param {string} serviceType Optional, filter by * @param {string} serviceType Optional, filter by
* @param {number} fromBlock Optional, start at block
* @return {Promise<OrderHistory[]>} transactionHash of the payment * @return {Promise<OrderHistory[]>} transactionHash of the payment
*/ */
public async getOrderHistory( public async getOrderHistory(
account: Account, account: Account,
serviceType?: string serviceType?: string,
fromBlock?: number
): Promise<OrderHistory[]> { ): Promise<OrderHistory[]> {
const results: OrderHistory[] = [] const results: OrderHistory[] = []
const address = this.web3.utils.toChecksumAddress(account.getId()) const address = this.web3.utils.toChecksumAddress(account.getId())
@ -608,7 +610,7 @@ export class Assets extends Instantiable {
topics: [ topics: [
['0x24c95b9bea47f62df4b9eea32c98c597eccfc5cac47f8477647be875ad925eee', address] ['0x24c95b9bea47f62df4b9eea32c98c597eccfc5cac47f8477647be875ad925eee', address]
], ],
fromBlock: 0 fromBlock: fromBlock || 0
}) })
for (let i = 0; i < events.length; i++) { for (let i = 0; i < events.length; i++) {
const blockDetails = await this.web3.eth.getBlock(events[i].blockNumber) const blockDetails = await this.web3.eth.getBlock(events[i].blockNumber)