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

fix history

This commit is contained in:
alexcos20 2020-10-12 12:01:54 -07:00
parent 190785f9cd
commit ea352125e2
2 changed files with 23 additions and 22 deletions

View File

@ -420,7 +420,10 @@ export class DataTokens {
public getStartOrderEventSignature(): string {
const abi = this.datatokensABI as AbiItem[]
const eventdata = abi.find((o) => (o.name = 'OrderStarted'))
return this.web3.eth.abi.encodeEventSignature(eventdata as any)
const eventdata = abi.find(function (o) {
if (o.name === 'OrderStarted' && o.type === 'event') return o
})
const topic = this.web3.eth.abi.encodeEventSignature(eventdata as any)
return topic
}
}

View File

@ -613,15 +613,11 @@ export class Assets extends Instantiable {
const results: Order[] = []
const address = account.getId().toLowerCase()
const { datatokens } = this.ocean
const topic1 = '0x000000000000000000000000' + address.substring(2)
const events = await this.web3.eth.getPastLogs({
topics: [
[
datatokens.getStartOrderEventSignature(),
null,
'0x000000000000000000000000' + address.substring(address.length - 40)
]
],
fromBlock: fromBlock || 0
topics: [[datatokens.getStartOrderEventSignature(), null, topic1]],
fromBlock: fromBlock || 0,
toBlock: 'latest'
})
for (let i = 0; i < events.length; i++) {
const order: Order = {
@ -632,6 +628,7 @@ export class Assets extends Instantiable {
consumer: '0x' + events[i].topics[1].substring(events[i].topics[1].length - 40),
payer: '0x' + events[i].topics[2].substring(events[i].topics[2].length - 40)
}
try {
const params = this.web3.eth.abi.decodeParameters(
['uint256', 'uint256', 'uint256', 'uint256'],
events[i].data
@ -644,6 +641,7 @@ export class Assets extends Instantiable {
order.serviceType = service.type
if (!serviceType || (serviceType && serviceType === service.type))
results.push(order)
} catch (e) {}
}
return results
}