mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
fix namings and add did
This commit is contained in:
parent
087b021c17
commit
6ba0ae6808
@ -4,7 +4,7 @@ import { TransactionReceipt } from 'web3-core'
|
|||||||
import { Pool } from './Pool'
|
import { Pool } from './Pool'
|
||||||
import { EventData, Filter } from 'web3-eth-contract'
|
import { EventData, Filter } from 'web3-eth-contract'
|
||||||
import BigNumber from 'bignumber.js'
|
import BigNumber from 'bignumber.js'
|
||||||
import { SubscribablePromise, Logger } from '../utils'
|
import { SubscribablePromise, Logger, didNoZeroX, didPrefixed } from '../utils'
|
||||||
|
|
||||||
declare type PoolTransactionType = 'swap' | 'join' | 'exit'
|
declare type PoolTransactionType = 'swap' | 'join' | 'exit'
|
||||||
|
|
||||||
@ -16,9 +16,10 @@ export interface PoolDetails {
|
|||||||
tokens: string[]
|
tokens: string[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AllPoolsShares {
|
export interface PoolShare {
|
||||||
poolAddress: string
|
poolAddress: string
|
||||||
shares: string
|
shares: string
|
||||||
|
did: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TokensReceived {
|
export interface TokensReceived {
|
||||||
@ -907,8 +908,8 @@ export class OceanPool extends Pool {
|
|||||||
* @param {String} account
|
* @param {String} account
|
||||||
* @return {AllPoolsShares[]}
|
* @return {AllPoolsShares[]}
|
||||||
*/
|
*/
|
||||||
public async getPoolsSharesbyAddress(account: string): Promise<AllPoolsShares[]> {
|
public async getPoolSharesByAddress(account: string): Promise<PoolShare[]> {
|
||||||
const result: AllPoolsShares[] = []
|
const result: PoolShare[] = []
|
||||||
const factory = new this.web3.eth.Contract(this.factoryABI, this.factoryAddress)
|
const factory = new this.web3.eth.Contract(this.factoryABI, this.factoryAddress)
|
||||||
|
|
||||||
const events = await factory.getPastEvents('BPoolRegistered', {
|
const events = await factory.getPastEvents('BPoolRegistered', {
|
||||||
@ -920,7 +921,11 @@ export class OceanPool extends Pool {
|
|||||||
for (let i = 0; i < events.length; i++) {
|
for (let i = 0; i < events.length; i++) {
|
||||||
const shares = await super.sharesBalance(account, events[i].returnValues[0])
|
const shares = await super.sharesBalance(account, events[i].returnValues[0])
|
||||||
if (shares) {
|
if (shares) {
|
||||||
const onePool: AllPoolsShares = { shares, poolAddress: events[i].returnValues[0] }
|
const onePool: PoolShare = {
|
||||||
|
shares,
|
||||||
|
poolAddress: events[i].returnValues[0],
|
||||||
|
did: didPrefixed(didNoZeroX(await this.getDTAddress(events[i].returnValues[0])))
|
||||||
|
}
|
||||||
result.push(onePool)
|
result.push(onePool)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -418,7 +418,7 @@ describe('Balancer flow', () => {
|
|||||||
assert(parseFloat(amounts.oceanAmount) > 0)
|
assert(parseFloat(amounts.oceanAmount) > 0)
|
||||||
})
|
})
|
||||||
it('ALice should get all her shares for all the pools', async () => {
|
it('ALice should get all her shares for all the pools', async () => {
|
||||||
const aliceShares = await Pool.getPoolsSharesbyAddress(alice)
|
const aliceShares = await Pool.getPoolSharesByAddress(alice)
|
||||||
assert(aliceShares.length > 0)
|
assert(aliceShares.length > 0)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user