@q-dev/q-js-sdk
Version:
Typescript Library to interact with Q System Contracts
66 lines • 2.64 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.VestingInstance = void 0;
const TimeLockHelperInstance_1 = require("../TimeLockHelperInstance");
/**
* 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 TimeLockHelperInstance_1.TimeLockHelperInstance {
constructor(signerOrProvider, address) {
super(signerOrProvider, VestingInstance.abi, address);
}
/**
* [External documentation](@system-contracts-repo/@network/Vesting/#lock)
*/
async lock(amount, txOptions) {
return this.submitTransaction('lock', [amount], txOptions);
}
/**
* [External documentation](@system-contracts-repo/@network/Vesting/#announceunlock)
*/
async announceUnlock(amount, txOptions) {
return this.submitTransaction('announceUnlock', [amount], txOptions);
}
/**
* [External documentation](@system-contracts-repo/@network/Vesting/#unlock)
*/
async unlock(amount, txOptions) {
return this.submitTransaction('unlock', [amount], txOptions);
}
/**
* [External documentation](@system-contracts-repo/@network/Vesting/#withdraw)
*/
async withdraw(amount, txOptions) {
return this.submitTransaction('withdraw', [amount], txOptions);
}
/**
* [External documentation](@system-contracts-repo/@network/Vesting/#balanceof)
*/
async balanceOf(userAddress) {
return (await this.instance.balanceOf(userAddress)).toString();
}
/**
* [External documentation](@system-contracts-repo/@network/Vesting/#withdrawablebalanceof)
*/
async withdrawableBalanceOf(account) {
return (await this.instance.withdrawableBalanceOf(account)).toString();
}
/**
* [External documentation](@system-contracts-repo/@network/Vesting/#getlockinfo)
*/
async getLockInfo(user) {
const result = await this.instance.getLockInfo({ from: user });
return {
lockedAmount: result.lockedAmount.toString(),
lockedUntil: result.lockedUntil.toString(),
pendingUnlockAmount: result.pendingUnlockAmount.toString(),
pendingUnlockTime: result.pendingUnlockTime.toString()
};
}
}
exports.VestingInstance = VestingInstance;
VestingInstance.registryKey = 'tokeneconomics.vesting';
VestingInstance.abi = 'Vesting.json';
//# sourceMappingURL=VestingInstance.js.map