1
0
mirror of https://github.com/oceanprotocol-archive/squid-js.git synced 2024-02-02 15:31:51 +01:00

Use the decimals of OceanToken to return the correct balance.

This commit is contained in:
Pedro Gutiérrez 2019-03-11 22:49:22 +01:00 committed by Pedro Gutiérrez
parent 44a611248e
commit ae070be011
2 changed files with 6 additions and 1 deletions

View File

@ -13,6 +13,10 @@ export default class OceanToken extends ContractBase {
return this.sendFrom("approve", [to, price], from)
}
public async decimals(): Promise<number> {
return this.call("decimals", [])
}
public async balanceOf(address: string): Promise<number> {
return this.call("balanceOf", [address])
.then((balance: string) => new BigNumber(balance).toNumber())

View File

@ -33,7 +33,8 @@ export default class Account extends OceanBase {
* @return {Promise<number>}
*/
public async getOceanBalance(): Promise<number> {
return (await Keeper.getInstance()).token.balanceOf(this.id)
const token = (await Keeper.getInstance()).token
return await token.balanceOf(this.id) / (10 ** await token.decimals())
}
/**