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

Merge pull request #381 from oceanprotocol/bug/fix_getOrderHistory

fix getOrderHistory
This commit is contained in:
Alex Coseru 2020-10-20 16:32:24 +03:00 committed by GitHub
commit d685cb1f5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View File

@ -598,11 +598,13 @@ export class Assets extends Instantiable {
const address = account.getId().toLowerCase()
const { datatokens } = this.ocean
const topic1 = '0x000000000000000000000000' + address.substring(2)
const topic0 = datatokens.getStartOrderEventSignature()
const events = await this.web3.eth.getPastLogs({
topics: [[datatokens.getStartOrderEventSignature(), null, topic1]],
topics: [topic0, null, topic1],
fromBlock: fromBlock || 0,
toBlock: 'latest'
})
for (let i = 0; i < events.length; i++) {
const order: Order = {
dtAddress: events[i].address,

View File

@ -252,8 +252,12 @@ describe('Marketplace flow', () => {
ddo = await ocean.assets.create(asset, alice, [service1])
assert.equal(ddo, null)
})
it('Alice gets hers order History', async () => {
const history = await ocean.assets.getOrderHistory(alice)
it('Bob should get his order History', async () => {
const history = await ocean.assets.getOrderHistory(bob)
assert(history.length > 0)
})
it('Alice should not get any order History', async () => {
const history = await ocean.assets.getOrderHistory(alice)
assert(history.length === 0)
})
})