Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #155 -- allow passing large deposit amounts #157

Merged
merged 2 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/gentle-clocks-beam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@celo/celocli': patch
---

Fix not being able to submit governance proposals due to mishandling of 10K minimum deposit
1 change: 1 addition & 0 deletions packages/cli/exampleProposal.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
79 changes: 79 additions & 0 deletions packages/cli/src/commands/governance/propose.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import { Address } from '@celo/connect'
import { newKitFromWeb3 } from '@celo/contractkit'
import { NetworkConfig, testWithGanache } from '@celo/dev-utils/lib/ganache-test'
import { ux } from '@oclif/core'
import Web3 from 'web3'
import { testLocally } from '../../test-utils/cliUtils'
import Propose from './propose'
process.env.NO_SYNCCHECK = 'true'

const expConfig = NetworkConfig.governance

testWithGanache('governance:propose cmd', (web3: Web3) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

const minDeposit = web3.utils.toWei(expConfig.minDeposit.toString(), 'ether')
const kit = newKitFromWeb3(web3)

let accounts: Address[] = []

beforeEach(async () => {
accounts = await web3.eth.getAccounts()
kit.defaultAccount = accounts[0]
})
test('fails when descriptionURl is missing', async () => {
await expect(
testLocally(Propose, [
'--from',
accounts[0],
'--deposit',
'0',
'--jsonTransactions',
'./exampleProposal.json',
])
).rejects.toThrow('Missing required flag descriptionURL')
})
test('can submit empty proposal', async () => {
await testLocally(Propose, [
'--from',
accounts[0],
'--deposit',
minDeposit,
'--jsonTransactions',
'./exampleProposal.json',
'--descriptionURL',
'https://example.com',
])
})
test('can submit proposal using e notion for deposit', async () => {
const spyStart = jest.spyOn(ux.action, 'start')
const spyStop = jest.spyOn(ux.action, 'stop')
await testLocally(Propose, [
'--from',
accounts[0],
'--deposit',
'10000e18',
'--jsonTransactions',
'./exampleProposal.json',
'--descriptionURL',
'https://example.com',
])
expect(spyStart).toHaveBeenCalledWith('Sending Transaction: proposeTx')
expect(spyStop).toHaveBeenCalled()
})
test('when deposit is 10K it succeeds', async () => {
const spyStart = jest.spyOn(ux.action, 'start')
const spyStop = jest.spyOn(ux.action, 'stop')

await testLocally(Propose, [
'--from',
accounts[0],
'--deposit',
'10000000000000000000000',
'--jsonTransactions',
'./exampleProposal.json',
'--descriptionURL',
'https://example.com',
])
expect(spyStart).toHaveBeenCalledWith('Sending Transaction: proposeTx')
expect(spyStop).toHaveBeenCalled()
})
})
7 changes: 5 additions & 2 deletions packages/cli/src/commands/governance/propose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ export default class Propose extends BaseCommand {
required: true,
description: 'Path to json transactions',
}),
deposit: Flags.string({ required: true, description: 'Amount of Gold to attach to proposal' }),
deposit: Flags.string({
required: true,
description: 'Amount of Celo to attach to proposal',
}),
from: CustomFlags.address({ required: true, description: "Proposer's address" }),
force: Flags.boolean({ description: 'Skip execution check', default: false }),
descriptionURL: Flags.string({
Expand Down Expand Up @@ -88,7 +91,7 @@ export default class Propose extends BaseCommand {
await displaySendTx(
'proposeTx',
governance.propose(proposal, res.flags.descriptionURL),
{ value: deposit.toString() },
{ value: deposit.toFixed() },
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is the fix

'ProposalQueued'
)
}
Expand Down
Loading