@ardier16/q-js-sdk
Version:
Typescript Library to interact with Q System Contracts
95 lines • 3.83 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.VestingInstance = void 0;
const unit_converter_1 = require("../../utils/unit-converter");
const TimeLockHelperInstance_1 = require("../TimeLockHelperInstance");
const SystemContractInstance_1 = require("../SystemContractInstance");
/**
* Vesting instance to interact with Vesting contract.
* See [onchain documentation](@system-contracts-repo/@network/Vesting/) for more details.
* An instance of this class for a deployed network can be obtained via {@link ContractRegistryInstance.vesting}
*/
class VestingInstance extends SystemContractInstance_1.SystemContractInstance {
constructor(web3, address) {
super(web3, VestingInstance.abi, address);
this.c = new unit_converter_1.UnitConverter();
this.timeLockHelper = new TimeLockHelperInstance_1.TimeLockHelperInstance(web3, VestingInstance.abi, address);
}
/**
* [External documentation](@system-contracts-repo/@network/Vesting/#lock)
*/
async lock(amount, txOptions) {
return this.submitTransaction(this.instance.methods.lock(amount), txOptions);
}
/**
* [External documentation](@system-contracts-repo/@network/Vesting/#announceunlock)
*/
async announceUnlock(amount, txOptions) {
return this.submitTransaction(this.instance.methods.announceUnlock(amount), txOptions);
}
/**
* [External documentation](@system-contracts-repo/@network/Vesting/#unlock)
*/
async unlock(amount, txOptions) {
return this.submitTransaction(this.instance.methods.unlock(amount), txOptions);
}
/**
* [External documentation](@system-contracts-repo/@network/Vesting/#withdraw)
*/
async withdraw(amount, txOptions) {
return this.submitTransaction(this.instance.methods.withdraw(amount), txOptions);
}
/**
* [External documentation](@system-contracts-repo/@network/Vesting/#balanceof)
*/
async balanceOf(userAddress) {
return this.instance.methods.balanceOf(userAddress).call();
}
/**
* [External documentation](@system-contracts-repo/@network/Vesting/#withdrawablebalanceof)
*/
async withdrawableBalanceOf(account) {
return this.instance.methods.withdrawableBalanceOf(account).call();
}
/**
* [External documentation](@system-contracts-repo/@network/Vesting/#getlockinfo)
*/
async getLockInfo(user) {
const result = await this.instance.methods.getLockInfo().call({ from: user });
const lockInfo = {
lockedAmount: result[0],
lockedUntil: result[1],
pendingUnlockAmount: result[2],
pendingUnlockTime: result[3]
};
return lockInfo;
}
/**
* {@link TimeLockHelperInstance.depositOnBehalfOf | Internal documentation}
*/
async depositOnBehalfOf(account, start, end, txOptions) {
return this.timeLockHelper.depositOnBehalfOf(account, start, end, txOptions);
}
/**
* {@link TimeLockHelperInstance.getTimeLocks | Internal documentation}
*/
async getTimeLocks(account) {
return this.timeLockHelper.getTimeLocks(account);
}
/**
* {@link TimeLockHelperInstance.getMinimumBalance | Internal documentation}
*/
async getMinimumBalance(account, timestamp) {
return this.timeLockHelper.getMinimumBalance(account, timestamp);
}
/**
* {@link TimeLockHelperInstance.purgeTimeLocks | Internal documentation}
*/
async purgeTimeLocks(account, txOptions) {
return this.timeLockHelper.purgeTimeLocks(account, txOptions);
}
}
exports.VestingInstance = VestingInstance;
VestingInstance.registryKey = 'tokeneconomics.vesting';
VestingInstance.abi = 'Vesting.json';
//# sourceMappingURL=VestingInstance.js.map