Skip to content

Commit

Permalink
Merge pull request #381 from oceanprotocol/bug/fix_getOrderHistory
Browse files Browse the repository at this point in the history
fix getOrderHistory
  • Loading branch information
alexcos20 authored Oct 20, 2020
2 parents 75c0453 + efaa3f6 commit d685cb1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/ocean/Assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 6 additions & 2 deletions test/integration/Marketplaceflow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
})

0 comments on commit d685cb1

Please sign in to comment.