mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
add optional filter
This commit is contained in:
parent
2c3c8bb04e
commit
4d00c882df
@ -595,9 +595,13 @@ export class Assets extends Instantiable {
|
||||
/**
|
||||
* get Order History
|
||||
* @param {Account} account
|
||||
* @param {string} serviceType Optional, filter by
|
||||
* @return {Promise<OrderHistory[]>} transactionHash of the payment
|
||||
*/
|
||||
public async getOrderHistory(account: Account): Promise<OrderHistory[]> {
|
||||
public async getOrderHistory(
|
||||
account: Account,
|
||||
serviceType?: string
|
||||
): Promise<OrderHistory[]> {
|
||||
const results: OrderHistory[] = []
|
||||
const address = this.web3.utils.toChecksumAddress(account.getId())
|
||||
const events = await this.web3.eth.getPastLogs({
|
||||
@ -623,6 +627,7 @@ export class Assets extends Instantiable {
|
||||
order.did = didPrefixed(didNoZeroX(order.dtAddress))
|
||||
const service = await this.getServiceByIndex(order.did, order.serviceId)
|
||||
order.serviceType = service.type
|
||||
if (!serviceType || (serviceType && serviceType === service.type))
|
||||
results.push(order)
|
||||
}
|
||||
return results
|
||||
|
Loading…
x
Reference in New Issue
Block a user