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

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