@ardier16/q-js-sdk
Version:
Typescript Library to interact with Q System Contracts
137 lines • 5.51 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RootNodesInstance = void 0;
const SystemContractInstance_1 = require("../../SystemContractInstance");
const TimeLockHelperInstance_1 = require("../../TimeLockHelperInstance");
/**
* Root nodes instance to interact with Root nodes contract.
* See [onchain documentation](@system-contracts-repo/@network/Roots/) for more details.
* An instance of this class for a deployed network can be obtained via {@link ContractRegistryInstance.rootNodes}
*/
class RootNodesInstance extends SystemContractInstance_1.SystemContractInstance {
constructor(web3, address) {
super(web3, RootNodesInstance.abi, address);
this.timeLockHelper = new TimeLockHelperInstance_1.TimeLockHelperInstance(web3, RootNodesInstance.abi, address);
}
/**
* [External documentation](@system-contracts-repo/@network/Roots/#getlockinfo)
*/
async getLockInfo(who) {
return await this.votingWeightProxy.getLockInfo(this.address, who);
}
/**
* [External documentation](@system-contracts-repo/@network/Roots/#getslashingproposalids)
*/
async getSlashingProposalIds(root) {
return this.instance.methods.getSlashingProposalIds(root).call();
}
/**
* [External documentation](@system-contracts-repo/@network/Roots/#applyslashing)
*/
async applySlashing(proposalId, root, amountToSlash, txOptions) {
return this.submitTransaction(this.instance.methods.applySlashing(proposalId, root, amountToSlash), txOptions);
}
/**
* [External documentation](@system-contracts-repo/@network/Roots/#addslashingproposal)
*/
async addSlashingProposal(root, slashingProposalId, txOptions) {
return this.submitTransaction(this.instance.methods.addSlashingProposal(root, slashingProposalId), txOptions);
}
/**
* [External documentation](@system-contracts-repo/@network/Roots/#getmembers)
*/
async getMembers() {
return this.instance.methods.getMembers().call();
}
/**
* [External documentation](@system-contracts-repo/@network/Roots/#ismember)
*/
async isMember(user) {
return this.instance.methods.isMember(user).call();
}
/**
* [External documentation](@system-contracts-repo/@network/Roots/#getsize)
*/
async getSize() {
return this.instance.methods.getSize().call();
}
/**
* [External documentation](@system-contracts-repo/@network/Roots/#getlimit)
*/
async getLimit() {
return this.instance.methods.getLimit().call();
}
/**
* [External documentation](@system-contracts-repo/@network/Roots/#getrootnodestake)
*/
async getRootNodeStake(root) {
return this.instance.methods.getRootNodeStake(root).call();
}
/**
* [External documentation](@system-contracts-repo/@network/Roots/#getstakes)
*/
async getStakes() {
const rawStakes = await this.instance.methods.getStakes().call();
const stakes = rawStakes.map((stake) => { return { root: stake[0], value: stake[1] }; });
return stakes;
}
/**
* [External documentation](@system-contracts-repo/@network/Roots/#commitstake)
*/
async commitStake(txOptions) {
return this.submitTransaction(this.instance.methods.commitStake(), txOptions);
}
/**
* [External documentation](@system-contracts-repo/@network/Roots/#announcewithdrawal)
*/
async announceWithdrawal(amount, txOptions) {
return this.submitTransaction(this.instance.methods.announceWithdrawal(amount), txOptions);
}
/**
* [External documentation](@system-contracts-repo/@network/Roots/#withdraw)
*/
async withdraw(amount, payTo, txOptions) {
return this.submitTransaction(this.instance.methods.withdraw(amount, payTo), txOptions);
}
/**
* [External documentation](@system-contracts-repo/@network/Roots/#withdrawals)
*/
async getWithdrawalInfo(address) {
const withdrawalInfo = await this.instance.methods.withdrawals(address).call();
return withdrawalInfo;
}
/**
* {@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);
}
/**
* [External documentation](https://q-dev.gitlab.io/system-contracts/latest/Roots/#purgependingslashings)
*/
async purgePendingSlashings(root, txOptions) {
return this.submitTransaction(this.instance.methods.purgePendingSlashings(root), txOptions);
}
}
exports.RootNodesInstance = RootNodesInstance;
RootNodesInstance.registryKey = 'governance.rootNodes';
RootNodesInstance.abi = 'Roots.json';
//# sourceMappingURL=RootNodesInstance.js.map