proposeByDelegate support

This commit is contained in:
gozzy 2023-03-23 03:03:21 +00:00
parent 2b61afbafe
commit 4ecde79c86
2 changed files with 18 additions and 7 deletions

@ -59,8 +59,13 @@ export default {
}
},
computed: {
...mapState('governance/gov', ['lockedBalance', 'proposals']),
...mapGetters('governance/gov', ['isFetchingProposals', 'constants', 'isFetchingBalances']),
...mapState('governance/gov', ['proposals']),
...mapGetters('governance/gov', [
'isFetchingProposals',
'constants',
'isFetchingBalances',
'votingPower'
]),
...mapGetters('token', ['toDecimals']),
filteredProposals() {
return this.proposals
@ -74,7 +79,7 @@ export default {
},
hasProposalThreshold() {
const PROPOSAL_THRESHOLD = toBN(this.constants.PROPOSAL_THRESHOLD)
return toBN(this.lockedBalance).gte(PROPOSAL_THRESHOLD)
return toBN(this.votingPower).gte(PROPOSAL_THRESHOLD)
},
proposalThreshold() {
return this.toDecimals(this.constants.PROPOSAL_THRESHOLD, 18)

@ -179,15 +179,21 @@ const actions = {
) {
try {
const { ethAccount } = rootState.metamask
const { lockedBalance, constants } = state
const netId = rootGetters['metamask/netId']
const proposalThreshold = toBN(constants.PROPOSAL_THRESHOLD)
const proposeIndependently = lockedBalance.gte(proposalThreshold)
const govInstance = getters.govContract({ netId })
const json = JSON.stringify({ title, description })
const data = await govInstance.methods.propose(proposalAddress, json).encodeABI()
const fSelector = !proposeIndependently ? 'proposeByDelegate' : 'propose'
const data = await govInstance.methods[fSelector](proposalAddress, json).encodeABI()
const gas = await govInstance.methods
.propose(proposalAddress, json)
.estimateGas({ from: ethAccount, value: 0 })
const gas = await govInstance.methods[fSelector](proposalAddress, json).estimateGas({
from: ethAccount,
value: 0
})
const callParams = {
method: 'eth_sendTransaction',