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

add ocean.pool.totalSupply()

This commit is contained in:
Matthias Kretschmann 2020-08-20 13:33:59 +02:00
parent 8667e3396d
commit 00257c3d60
Signed by: m
GPG Key ID: 606EEEF3C479A91F

View File

@ -89,7 +89,7 @@ export class Pool extends PoolFactory {
}
/**
* Get Pool shares
* Get user shares of pool tokens
* @param {String} account
* @param {String} poolAddress
* @return {String}
@ -132,6 +132,42 @@ export class Pool extends PoolFactory {
return result
}
/**
* Get total supply of pool tokens
* @param {String} poolAddress
* @return {String}
*/
async totalSupply(poolAddress: string): Promise<string> {
const minABI = [
{
constant: true,
name: 'totalSupply',
outputs: [
{
name: 'balance',
type: 'uint256'
}
],
payable: false,
stateMutability: 'view',
type: 'function'
}
] as AbiItem[]
const token = new this.web3.eth.Contract(minABI, poolAddress)
// const pool = new this.web3.eth.Contract(this.poolABI, poolAddress)
let result = null
try {
const totalSupply = await token.methods.totalSupply().call()
result = this.web3.utils.fromWei(totalSupply)
} catch (e) {
console.error(e)
}
return result
}
/**
* Adds tokens to pool
* @param {String} account