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:
parent
44a611248e
commit
ae070be011
@ -13,6 +13,10 @@ export default class OceanToken extends ContractBase {
|
|||||||
return this.sendFrom("approve", [to, price], from)
|
return this.sendFrom("approve", [to, price], from)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async decimals(): Promise<number> {
|
||||||
|
return this.call("decimals", [])
|
||||||
|
}
|
||||||
|
|
||||||
public async balanceOf(address: string): Promise<number> {
|
public async balanceOf(address: string): Promise<number> {
|
||||||
return this.call("balanceOf", [address])
|
return this.call("balanceOf", [address])
|
||||||
.then((balance: string) => new BigNumber(balance).toNumber())
|
.then((balance: string) => new BigNumber(balance).toNumber())
|
||||||
|
@ -33,7 +33,8 @@ export default class Account extends OceanBase {
|
|||||||
* @return {Promise<number>}
|
* @return {Promise<number>}
|
||||||
*/
|
*/
|
||||||
public async getOceanBalance(): 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())
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user