-
Notifications
You must be signed in to change notification settings - Fork 12
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
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) => { | ||
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() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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({ | ||
|
@@ -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() }, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line is the fix |
||
'ProposalQueued' | ||
) | ||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️