2019-06-20 00:20:09 +02:00
|
|
|
import BigNumber from 'bignumber.js'
|
|
|
|
import ContractBase from './ContractBase'
|
|
|
|
import { InstantiableConfig } from '../../Instantiable.abstract'
|
2018-10-01 18:10:26 +02:00
|
|
|
|
2018-10-18 13:12:23 +02:00
|
|
|
export default class OceanToken extends ContractBase {
|
2019-06-20 00:20:09 +02:00
|
|
|
public static async getInstance(
|
|
|
|
config: InstantiableConfig
|
|
|
|
): Promise<OceanToken> {
|
|
|
|
const token: OceanToken = new OceanToken('OceanToken')
|
2019-03-21 02:56:58 +01:00
|
|
|
await token.init(config)
|
2018-10-02 10:06:26 +02:00
|
|
|
return token
|
2018-10-01 18:10:26 +02:00
|
|
|
}
|
|
|
|
|
2019-05-23 11:52:36 +02:00
|
|
|
public async approve(to: string, price: number | string, from?: string) {
|
2019-06-20 00:20:09 +02:00
|
|
|
return this.sendFrom('approve', [to, String(price)], from)
|
2018-10-01 18:10:26 +02:00
|
|
|
}
|
|
|
|
|
2019-03-11 22:49:22 +01:00
|
|
|
public async decimals(): Promise<number> {
|
2019-06-20 00:20:09 +02:00
|
|
|
return this.call('decimals', [])
|
2019-03-11 22:49:22 +01:00
|
|
|
}
|
|
|
|
|
2018-10-05 12:34:31 +02:00
|
|
|
public async balanceOf(address: string): Promise<number> {
|
2019-06-20 00:20:09 +02:00
|
|
|
return this.call('balanceOf', [address]).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-06-20 00:20:09 +02:00
|
|
|
return this.send('transfer', from, [to, amount])
|
2019-02-15 14:44:48 +01:00
|
|
|
}
|
2018-10-01 18:10:26 +02:00
|
|
|
}
|