@tokenz/tokens-smartcontract-sdk
Version:
Smart Contract SDK for Tokenz STO platform
73 lines (62 loc) • 2.61 kB
JavaScript
const coreLib = require('./Core');
class STODividentFactory{
constructor(){
this.STODividentFactory = new coreLib("STODivFactory");
this.setup = this.setup.bind(this);
this.setup();
this.fetchDividentCounter = this.fetchDividentCounter.bind(this);
this.fetchSTODividentContract = this.fetchSTODividentContract.bind(this);
this.initializeDivident = this.initializeDivident.bind(this);
}
async setup () {
return new Promise(async function (resolve, reject) {
try {
this.macContractAddress = await this.STODividentFactory.callData("maCAddr", []);
this.ruleEngineAddress = await this.STODividentFactory.callData("ruCAddr", []);
this.contractCategory = await this.STODividentFactory.callData("contractCategory", []);
this.contractType = await this.STODividentFactory.callData("contractType", []);
this.kycRegisAddress = await this.STODividentFactory.callData("kycAddr", []);
this.stoFactoryAddress = await this.STODividentFactory.callData("stfAddr", []);
resolve(0);
} catch (err) {
window.Sentry.captureException(err);
console.log(err);
reject(0)
}
}.bind(this))
}
async fetchDividentCounter( stoAddress ) {
return new Promise(async function (resolve, reject) {
try {
let result = await this.STODividentFactory.callData("divCtr", [ stoAddress]);
resolve(result);
} catch (err) {
window.Sentry.captureException(err);
reject(0)
}
}.bind(this))
}
async fetchSTODividentContract( stoAddress ) {
return new Promise(async function (resolve, reject) {
try {
let result = await this.STODividentFactory.callData("stoDiv", [ stoAddress ]);
resolve(result);
} catch (err) {
window.Sentry.captureException(err);
reject(0)
}
}.bind(this))
}
async initializeDivident( stoAddress ) {
return new Promise(async function (resolve, reject) {
try {
let result = await this.STODividentFactory.sendTx("initializeDivident", [ stoAddress ] ,0 );
resolve(result);
} catch (err) {
window.Sentry.captureException(err);
reject(0)
}
}.bind(this))
}
}
module.exports = STODividentFactory;