2018-10-05 12:34:31 +02:00
|
|
|
import BigNumber from "bignumber.js"
|
2018-10-18 13:12:23 +02:00
|
|
|
import ContractBase from "./ContractBase"
|
2018-10-01 18:10:26 +02:00
|
|
|
|
2018-10-18 13:12:23 +02:00
|
|
|
export default class OceanToken extends ContractBase {
|
2018-10-01 18:10:26 +02:00
|
|
|
|
2018-10-16 14:56:18 +02:00
|
|
|
public static async getInstance(): Promise<OceanToken> {
|
|
|
|
const token: OceanToken = new OceanToken("OceanToken")
|
2018-10-02 10:06:26 +02:00
|
|
|
await token.init()
|
|
|
|
return token
|
2018-10-01 18:10:26 +02:00
|
|
|
}
|
|
|
|
|
2019-03-01 13:24:04 +01:00
|
|
|
public async approve(to: string, price: number, from?: string) {
|
|
|
|
return this.sendFrom("approve", [to, price], from)
|
2018-10-01 18:10:26 +02:00
|
|
|
}
|
|
|
|
|
2018-10-05 12:34:31 +02:00
|
|
|
public async balanceOf(address: string): Promise<number> {
|
2018-10-17 18:24:01 +02:00
|
|
|
return this.call("balanceOf", [address])
|
2018-10-05 12:34:31 +02:00
|
|
|
.then((balance: string) => new BigNumber(balance).toNumber())
|
2018-10-01 18:10:26 +02:00
|
|
|
}
|
2019-02-15 14:44:48 +01:00
|
|
|
|
2019-03-01 13:24:04 +01:00
|
|
|
public async transfer(to: string, amount: number, from: string) {
|
2019-02-15 14:44:48 +01:00
|
|
|
return this.send("transfer", from, [to, amount])
|
|
|
|
}
|
2018-10-01 18:10:26 +02:00
|
|
|
}
|