UNPKG

@ardier16/q-js-sdk

Version:

Typescript Library to interact with Q System Contracts

92 lines 4.26 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ConstitutionVotingInstance = void 0; const QthVotingHelperInstance_1 = require("../../QthVotingHelperInstance"); const param_voting_helper_1 = require("../../../utils/param-voting-helper"); const SystemVotingVetoableInstance_1 = require("../../SystemVotingVetoableInstance"); /** * Constitution voting instance to interact with Constitution voting contract. * See [onchain documentation](@system-contracts-repo/@network/ConstitutionVoting/) for more details. * An instance of this class for a deployed network can be obtained via {@link ContractRegistryInstance.constitutionVoting} */ class ConstitutionVotingInstance extends SystemVotingVetoableInstance_1.SystemVotingVetoableInstance { constructor(web3, address) { super(web3, ConstitutionVotingInstance.abi, address); this.helper = new param_voting_helper_1.ParamVotingHelper(); this.qthVotingHelper = new QthVotingHelperInstance_1.QthVotingHelperInstance(web3, ConstitutionVotingInstance.abi, address); } /** * [External documentation](@system-contracts-repo/@network/ConstitutionVoting/#hasrootvetoed) */ async hasRootVetoed(proposalId, address) { return this.instance.methods.hasRootVetoed(proposalId, address).call(); } /** * [External documentation](@system-contracts-repo/@network/ConstitutionVoting/#hasuservoted) */ async hasUserVoted(proposalId, address) { return this.instance.methods.hasUserVoted(proposalId, address).call(); } /** * [External documentation](@system-contracts-repo/@network/ConstitutionVoting/#proposalcounter) */ async proposalCount() { return this.instance.methods.proposalCounter().call(); } /** * [External documentation](@system-contracts-repo/@network/ConstitutionVoting/#createproposal) */ async createProposal(remark, classification, newConstitutionHash, parameters, txOptions) { const mappedParameters = parameters.map(p => this.helper.mapParameterToOnChainJson(p)); return this.submitTransaction(this.instance.methods.createProposal(remark, classification, newConstitutionHash, mappedParameters), txOptions); } /** * [External documentation](@system-contracts-repo/@network/ConstitutionVoting/#proposals) */ async getProposal(proposalId) { const proposal = await this.instance.methods.proposals(proposalId) .call(); return proposal; } /** * [External documentation](@system-contracts-repo/@network/ConstitutionVoting/#getparametersarr) */ async getParametersArr(proposalId) { const params = await this.instance.methods.getParametersArr(proposalId) .call(); return params; } /** * [External documentation](@system-contracts-repo/@network/ConstitutionVoting/#getconstitutionhash) */ async getConstitutionHash(proposalId) { return this.instance.methods.getConstitutionHash(proposalId).call(); } /** * [External documentation](@system-contracts-repo/@network/ConstitutionVoting/#getvotingweightinfo) */ async getVotingWeightInfo(proposalId, address) { return await this.qthVotingHelper.getVotingWeightInfo(this.votingWeightProxy, proposalId, address, this.hasUserVoted); } /** * Retrieve proposal parameters. * @param proposalId chosen proposal id * @returns Proposal parameters */ async getProposedParameters(proposalId) { const rawParameters = await this.getParametersArr(proposalId); const proposedParameters = rawParameters.map(raw => this.helper.mapOnChainJsonToParameter(raw)); return proposedParameters; } /** * [External documentation](@system-contracts-repo/@network/ConstitutionVoting/#constitutionhash) */ async constitutionHash() { return this.instance.methods.constitutionHash() .call(); } } exports.ConstitutionVotingInstance = ConstitutionVotingInstance; ConstitutionVotingInstance.registryKey = 'governance.constitution.parametersVoting'; ConstitutionVotingInstance.abi = 'ConstitutionVoting.json'; //# sourceMappingURL=ConstitutionVotingInstance.js.map