@q-dev/q-js-sdk
Version:
Typescript Library to interact with Q System Contracts
78 lines • 3.56 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.VotingWeightProxyInstance = void 0;
const SystemContractInstance_1 = require("../SystemContractInstance");
/**
* Voting weight proxy instance to interact with Voting weight proxy contract.
* See [onchain documentation](@system-contracts-repo/@network/VotingWeightProxy/) for more details.
* An instance of this class for a deployed network can be obtained via {@link ContractRegistryInstance.votingWeightProxy}
*/
class VotingWeightProxyInstance extends SystemContractInstance_1.SystemContractInstance {
constructor(signerOrProvider, address) {
super(signerOrProvider, VotingWeightProxyInstance.abi, address);
}
/**
* [External documentation](@system-contracts-repo/@network/VotingWeightProxy/#announcenewvotingagent)
*/
async announceNewVotingAgent(newVotingAgentAddr, txOptions) {
return this.submitTransaction('announceNewVotingAgent', [newVotingAgentAddr], txOptions);
}
/**
* [External documentation](@system-contracts-repo/@network/VotingWeightProxy/#setnewvotingagent)
*/
async setNewVotingAgent(txOptions) {
return this.submitTransaction('setNewVotingAgent', [], txOptions);
}
/**
* [External documentation](@system-contracts-repo/@network/VotingWeightProxy/#getbasevotingweightinfo)
*/
async getBaseVotingWeightInfo(address, votingEndTime) {
const result = await this.instance.getBaseVotingWeightInfo(address, votingEndTime);
return {
ownWeight: result.ownWeight.toString(),
votingAgent: result.votingAgent,
delegationStatus: result.delegationStatus.toString(),
lockedUntil: result.lockedUntil.toString()
};
}
/**
* [External documentation](@system-contracts-repo/@network/VotingWeightProxy/#delegationinfos)
*/
async getDelegationInfo(address) {
const result = await this.instance.delegationInfos(address);
return {
receivedWeight: result.receivedWeight.toString(),
votingAgent: result.votingAgent,
isPending: result.isPending,
votingAgentPassOverTime: result.votingAgentPassOverTime.toString(),
};
}
/**
* [External documentation](@system-contracts-repo/@network/VotingWeightProxy/#getlockedamount)
*/
async getLockedAmount(address) {
return (await this.instance.getLockedAmount(address)).toString();
}
/**
* [External documentation](@system-contracts-repo/@network/VotingWeightProxy/#getlockinfo)
*/
async getLockInfo(tokenLockSource, who) {
const rawLockInfo = await this.instance.getLockInfo(tokenLockSource, who);
return {
lockedAmount: rawLockInfo.lockedAmount.toString(),
lockedUntil: rawLockInfo.lockedUntil.toString(),
pendingUnlockAmount: rawLockInfo.pendingUnlockAmount.toString(),
pendingUnlockTime: rawLockInfo.pendingUnlockTime.toString()
};
}
/**
* [External documentation](@system-contracts-repo/@network/VotingWeightProxy/#getvotingweight)
*/
async getVotingWeight(address, votingEndTime) {
return (await this.instance.getVotingWeight(address, votingEndTime)).toString();
}
}
exports.VotingWeightProxyInstance = VotingWeightProxyInstance;
VotingWeightProxyInstance.registryKey = 'governance.votingWeightProxy';
VotingWeightProxyInstance.abi = 'VotingWeightProxy.json';
//# sourceMappingURL=VotingWeightProxyInstance.js.map