Skip to content

Commit

Permalink
CLI+ SDK PreRELEASE fixes (#10819)
Browse files Browse the repository at this point in the history
* do registry additions in sequence

* do parsing of proposals additions in sequence

* add changeset

* enter beta mode

* Version Packages (beta) (#10816)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* Complete beta mode

* add feedback about proposal transaction parsing

* ensure we clean before building and that cli is packed properly

* Version Packages (beta) (#10820)

* do registry additions in sequence

* do parsing of proposals additions in sequence

* add changeset

* enter beta mode

* Version Packages (beta) (#10816)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* Complete beta mode

* add feedback about proposal transaction parsing

* Version Packages (beta)

---------

Co-authored-by: Aaron DeRuvo <aaron@clabs.co>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* registry mapping updates are fine to do together

* add a minor changeset just so beta gets bump

* Version Packages (beta) (#10825)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* should fix pushing tags issue

* Revert "Remove granda mento + metatransaction wallet (#10822)"

This reverts commit 9ab9d00.

* rollback

* Version Packages (beta) (#10826)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* remove beta only changeset

* Complete beta mode

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Dec 12, 2023
1 parent b6a5215 commit 041fc92
Show file tree
Hide file tree
Showing 173 changed files with 7,290 additions and 3,093 deletions.
5 changes: 0 additions & 5 deletions .changeset/cold-jobs-pay.md

This file was deleted.

5 changes: 5 additions & 0 deletions .changeset/long-mangos-poke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@celo/governance': patch
---

Turn back on parallel registry updating for governance proposal views
6 changes: 6 additions & 0 deletions .changeset/loud-tips-design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@celo/governance': patch
'@celo/celocli': patch
---

Add textual feedback about parsing proposal
5 changes: 5 additions & 0 deletions .changeset/popular-numbers-fly.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@celo/governance': patch
---

Fix Proposal View Regression when it includes proxy updates
41 changes: 41 additions & 0 deletions .changeset/pre.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"mode": "exit",
"tag": "beta",
"initialVersions": {
"@celo/celotool": "2.0.0",
"@celo/celocli": "3.1.1",
"@celo/dev-utils": "0.0.1",
"@celo/env-tests": "1.0.2",
"@celo/metadata-crawler": "0.0.3",
"@celo/protocol": "1.0.2",
"@celo/base": "6.0.0",
"@celo/connect": "5.1.1",
"@celo/contractkit": "5.2.1",
"@celo/cryptographic-utils": "5.0.6",
"@celo/explorer": "5.0.6",
"@celo/governance": "5.0.6",
"@celo/keystores": "5.0.6",
"@celo/network-utils": "5.0.5",
"@celo/phone-utils": "6.0.0",
"@celo/transactions-uri": "5.0.6",
"@celo/utils": "5.0.6",
"@celo/wallet-base": "5.1.1",
"@celo/wallet-hsm": "5.1.1",
"@celo/wallet-hsm-aws": "5.1.1",
"@celo/wallet-hsm-azure": "5.1.1",
"@celo/wallet-hsm-gcp": "5.1.1",
"@celo/wallet-ledger": "5.1.1",
"@celo/wallet-local": "5.1.1",
"@celo/wallet-remote": "5.1.1",
"@celo/wallet-rpc": "5.1.1",
"@celo/typescript": "0.0.1"
},
"changesets": [
"cool-waves-switch",
"few-cycles-doubt",
"light-buses-love",
"long-mangos-poke",
"loud-tips-design",
"popular-numbers-fly"
]
}
6 changes: 0 additions & 6 deletions .changeset/tiny-chairs-poke.md

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"keys:decrypt": "bash scripts/key_placer.sh decrypt",
"keys:encrypt": "bash scripts/key_placer.sh encrypt",
"check:packages": "node ./scripts/check-packages.js",
"release": "yarn build && yarn cs publish",
"release": "yarn clean && yarn build && yarn --cwd packages/cli run prepack && yarn cs publish",
"beta-enter": "bash scripts/beta-mode.sh",
"beta-exit": "yarn changeset pre exit && git commit -am 'Complete beta mode'",
"version-and-reinstall": "yarn changeset version && yarn install",
Expand Down
11 changes: 11 additions & 0 deletions packages/celotool/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# @celo/celotool

## 2.0.1-beta.0

### Patch Changes

- Updated dependencies [1c9c844cf]
- Updated dependencies [86bbfddf1]
- @celo/contractkit@6.0.0-beta.0
- @celo/governance@5.0.7-beta.0
- @celo/env-tests@1.0.3-beta.0
- @celo/explorer@5.0.7-beta.0

## 2.0.0

### Major Changes
Expand Down
10 changes: 5 additions & 5 deletions packages/celotool/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@celo/celotool",
"version": "2.0.0",
"version": "2.0.1-beta.0",
"description": "Celotool is our hub for all scripts that people need to run within the monorepo",
"main": "index.js",
"author": "Celo",
Expand All @@ -9,10 +9,10 @@
"@celo/base": "^6.0.0",
"@celo/connect": "^5.1.1",
"@celo/cryptographic-utils": "^5.0.6",
"@celo/contractkit": "^5.2.0",
"@celo/env-tests": "1.0.2",
"@celo/explorer": "^5.0.6",
"@celo/governance": "^5.0.6",
"@celo/contractkit": "^6.0.0-beta.0",
"@celo/env-tests": "1.0.3-beta.0",
"@celo/explorer": "^5.0.7-beta.0",
"@celo/governance": "^5.0.7-beta.0",
"@celo/network-utils": "^5.0.5",
"@celo/utils": "^5.0.6",
"@ethereumjs/util": "8.0.5",
Expand Down
42 changes: 42 additions & 0 deletions packages/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,47 @@
# Changelog

## 3.1.2-beta.2

### Patch Changes

- ba27783ae: Revert removal of Contracts
- Updated dependencies [ba27783ae]
- @celo/contractkit@6.0.0-beta.2

## 4.0.0-beta.2

### Major Changes

- 9ab9d00eb: Removes Grandamento from cli and contractkit completely as it has become no op by mento team

### Patch Changes

- Updated dependencies [9ab9d00eb]
- Updated dependencies [444db6de9]
- Updated dependencies [9ab9d00eb]
- @celo/contractkit@6.0.0-beta.1
- @celo/governance@5.0.7-beta.2

## 3.1.2-beta.1

### Patch Changes

- e4da5a7a8: Add textual feedback about parsing proposal
- Updated dependencies [e4da5a7a8]
- @celo/governance@5.0.7-beta.1

## 3.1.2-beta.0

### Patch Changes

- bb3cf9f2e: update terminology: refer to celo not gold.
- bb3cf9f2e: Alias releasecelo to releasegold
- Updated dependencies [1c9c844cf]
- Updated dependencies [86bbfddf1]
- @celo/contractkit@6.0.0-beta.0
- @celo/governance@5.0.7-beta.0
- @celo/explorer@5.0.7-beta.0

## 3.1.1

### Patch Changes
Expand Down
8 changes: 4 additions & 4 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@celo/celocli",
"description": "CLI Tool for transacting with the Celo protocol",
"version": "3.1.1",
"version": "3.1.2-beta.2",
"author": "Celo",
"license": "Apache-2.0",
"repository": "celo-org/celo-monorepo",
Expand Down Expand Up @@ -33,9 +33,9 @@
"@celo/abis": "10.0.0",
"@celo/base": "^6.0.0",
"@celo/connect": "^5.1.1",
"@celo/contractkit": "^5.2.1",
"@celo/explorer": "^5.0.6",
"@celo/governance": "^5.0.6",
"@celo/contractkit": "^6.0.0-beta.2",
"@celo/explorer": "^5.0.7-beta.0",
"@celo/governance": "^5.0.7-beta.2",
"@celo/identity": "^5.1.1",
"@celo/phone-utils": "^6.0.0",
"@celo/utils": "^5.0.6",
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/commands/governance/show.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export default class Show extends BaseCommand {
await addExistingProposalJSONFileToBuilder(builder, res.flags.afterExecutingProposal)
}
try {
console.log(chalk.cyanBright(`Parsing ${proposal.length} proposal transactions...`))
const jsonproposal = await proposalToJSON(this.kit, proposal, builder.registryAdditions)
record.proposal = jsonproposal as any

Expand Down
54 changes: 54 additions & 0 deletions packages/cli/src/commands/grandamento/cancel.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { Address } from '@celo/base/lib/address'
import { newKitFromWeb3 } from '@celo/contractkit'
import { assumeOwnership } from '@celo/contractkit/lib/test-utils/transferownership'
import { GrandaMentoWrapper } from '@celo/contractkit/lib/wrappers/GrandaMento'
import { testWithGanache } from '@celo/dev-utils/lib/ganache-test'
import BigNumber from 'bignumber.js'
import Web3 from 'web3'
import { testLocally } from '../../test-utils/cliUtils'
import Cancel from './cancel'
import Propose from './propose'

testWithGanache('grandamento:cancel cmd', (web3: Web3) => {
const kit = newKitFromWeb3(web3)
let grandaMento: GrandaMentoWrapper
const newLimitMin = new BigNumber('1000')
const newLimitMax = new BigNumber('1000000000000')
let accounts: Address[] = []

const increaseLimits = async () => {
await grandaMento
.setStableTokenExchangeLimits('StableToken', newLimitMin.toString(), newLimitMax.toString())
.sendAndWaitForReceipt()
}

beforeAll(async () => {
accounts = await web3.eth.getAccounts()
kit.defaultAccount = accounts[0]
grandaMento = await kit.contracts.getGrandaMento()
})

beforeEach(async () => {
await assumeOwnership(web3, accounts[0])
await increaseLimits()
// create mock proposal
await testLocally(Propose, [
'--from',
accounts[0],
'--sellCelo',
'true',
'--stableToken',
'cUSD',
'--value',
'10000',
])
})

describe('cancel', () => {
it('left no proposal', async () => {
await testLocally(Cancel, ['--from', accounts[0], '--proposalID', '1'])
const activeProposals = await grandaMento.getActiveProposalIds()
expect(activeProposals).toEqual([])
})
})
})
38 changes: 38 additions & 0 deletions packages/cli/src/commands/grandamento/cancel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { flags } from '@oclif/command'
import { BaseCommand } from '../../base'
import { newCheckBuilder } from '../../utils/checks'
import { displaySendTx } from '../../utils/cli'
import { Flags } from '../../utils/command'

export default class Cancel extends BaseCommand {
static description = 'Cancels a Granda Mento exchange proposal'

static flags = {
...BaseCommand.flags,
from: Flags.address({
required: true,
description: 'The address allowed to cancel the proposal',
}),
proposalID: flags.string({
required: true,
exclusive: ['account', 'hotfix'],
description: 'UUID of proposal to view',
}),
}

async run() {
const grandaMento = await this.kit.contracts.getGrandaMento()

const res = this.parse(Cancel)
const proposalID = res.flags.proposalID

await newCheckBuilder(this).grandaMentoProposalExists(proposalID).runChecks()

await displaySendTx(
'cancelExchangeProposal',
grandaMento.cancelExchangeProposal(proposalID),
undefined,
'ExchangeProposalCancelled'
)
}
}
91 changes: 91 additions & 0 deletions packages/cli/src/commands/grandamento/execute.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import { Address } from '@celo/base/lib/address'
import { newKitFromWeb3 } from '@celo/contractkit'
import { assumeOwnership } from '@celo/contractkit/lib/test-utils/transferownership'
import { GrandaMentoWrapper } from '@celo/contractkit/lib/wrappers/GrandaMento'
import { testWithGanache, timeTravel } from '@celo/dev-utils/lib/ganache-test'
import BigNumber from 'bignumber.js'
import Web3 from 'web3'
import { testLocally } from '../../test-utils/cliUtils'
import Execute from './execute'
import Propose from './propose'

testWithGanache('grandamento:execute cmd', (web3: Web3) => {
const kit = newKitFromWeb3(web3)
let grandaMento: GrandaMentoWrapper
const newLimitMin = new BigNumber('1000')
const newLimitMax = new BigNumber('1000000000000')
let accounts: Address[] = []
const dateNowOriginal = Date.now
let originalNoSyncCheck: string | undefined

const increaseLimits = () => {
return grandaMento
.setStableTokenExchangeLimits('StableToken', newLimitMin.toString(), newLimitMax.toString())
.sendAndWaitForReceipt()
}

const createExchangeProposal = () => {
// create mock proposal
return testLocally(Propose, [
'--from',
accounts[0],
'--sellCelo',
'true',
'--stableToken',
'cUSD',
'--value',
'10000',
])
}

const approveExchangeProposal = async (proposalID: number | string) => {
await grandaMento.setApprover(accounts[0]).sendAndWaitForReceipt()
await grandaMento.approveExchangeProposal(proposalID).sendAndWaitForReceipt()
}

const timeTravelDateAndChain = async (seconds: number) => {
await timeTravel(seconds, web3)
jest.useFakeTimers().setSystemTime(dateNowOriginal() + seconds * 1000)
// Otherwise contractkit complains there is a difference between Date.now()
// and the timestamp of the last block
process.env.NO_SYNCCHECK = 'true'
}

beforeAll(async () => {
accounts = await web3.eth.getAccounts()
kit.defaultAccount = accounts[0]
grandaMento = await kit.contracts.getGrandaMento()
originalNoSyncCheck = process.env.NO_SYNCCHECK
})

afterEach(() => {
process.env.NO_SYNCCHECK = originalNoSyncCheck
})

beforeEach(async () => {
await assumeOwnership(web3, accounts[0])
await increaseLimits()
await createExchangeProposal()
// Approve it
await approveExchangeProposal(1)
// Wait the veto period plus some extra time to be safe
await timeTravelDateAndChain((await grandaMento.vetoPeriodSeconds()).toNumber() + 1000)
})

describe('execute', () => {
it('executes the proposal', async () => {
await testLocally(Execute, ['--from', accounts[0], '--proposalID', '1'])
const activeProposals = await grandaMento.getActiveProposalIds()
expect(activeProposals).toEqual([])
})

it('fails if the exchange proposal is not executable', async () => {
// Create a proposal with proposalID 2, but don't wait the veto period
await createExchangeProposal()
await approveExchangeProposal(2)
await expect(
testLocally(Execute, ['--from', accounts[0], '--proposalID', '2'])
).rejects.toThrow()
})
})
})
Loading

0 comments on commit 041fc92

Please sign in to comment.