olympus-module
Version:
Module made by Olympus Labs for easier access to the Olympus protocol through Javascript/Typescript
53 lines (41 loc) • 1.56 kB
text/typescript
import Services from '../Services';
import { FUND_ABI } from './abi/Fund';
import Promisify from '../utils/Promisify';
import BigNumber from 'bignumber.js';
export class Derivative extends Services {
private contract;
public address;
public constructor(address: string, abi = FUND_ABI) {
super();
this.address = address;
this.contract = this.rpcService.contract(abi, address);
}
public get nativeContract() {
return this.contract;
}
public async getOwner(): Promise<string> {
return await Promisify<string>((cb: () => void) => this.contract.owner(cb));
}
public async getDerivativeType(): Promise<number> {
return (await this.contract.fundType()).toNumber();
}
public async getComponentAddress(componentName: string): Promise<string> {
return Promisify<string>(async (cb) =>
this.contract.getComponentByName(this.rpcService.fromAscii(componentName), cb));
}
public async getProductStatus(): Promise<number> {
return (await Promisify<BigNumber>(async (cb) => this.contract.productStatus(cb))).toNumber();
}
public async getStatus(): Promise<number> {
return (await Promisify<BigNumber>(async (cb) => this.contract.status(cb))).toNumber();
}
public async getName() {
return await Promisify<string>(async (cb) => this.contract.name(cb));
}
public async getDescription() {
return await Promisify<string>(async (cb) => this.contract.description(cb));
}
public async getVersion() {
return await Promisify<string>(async (cb) => this.contract.version(cb));
}
}