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

Merge pull request #429 from oceanprotocol/bug/fix_getPoolSharesByAddress

fix getPoolSharesByAddress
This commit is contained in:
Alex Coseru 2020-10-29 14:58:25 +02:00 committed by GitHub
commit fe5c99fa7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -913,23 +913,25 @@ export class OceanPool extends Pool {
const factory = new this.web3.eth.Contract(this.factoryABI, this.factoryAddress)
const events = await factory.getPastEvents('BPoolRegistered', {
filter: account ? { registeredBy: account } : {},
filter: {},
fromBlock: BPFACTORY_DEPLOY_BLOCK,
toBlock: 'latest'
})
for (let i = 0; i < events.length; i++) {
const shares = await super.sharesBalance(account, events[i].returnValues[0])
if (shares) {
const onePool: PoolShare = {
shares,
poolAddress: events[i].returnValues[0],
did: didPrefixed(didNoZeroX(await this.getDTAddress(events[i].returnValues[0])))
if (parseFloat(shares) > 0) {
const dtAddress = await this.getDTAddress(events[i].returnValues[0])
if (dtAddress) {
const onePool: PoolShare = {
shares,
poolAddress: events[i].returnValues[0],
did: didPrefixed(didNoZeroX(dtAddress))
}
result.push(onePool)
}
result.push(onePool)
}
}
console.log(result)
return result
}