diff --git a/.changeset/curly-pianos-applaud.md b/.changeset/curly-pianos-applaud.md new file mode 100644 index 000000000..eda17edfc --- /dev/null +++ b/.changeset/curly-pianos-applaud.md @@ -0,0 +1,7 @@ +--- +'@celo/contractkit': patch +--- + +Re-removes MetaTransaction wallets, as previously removed in 6.0.0 (9ab9d00eb). + +Remove support for deprecated `MetaTransactionWallet` and `MetaTransactionWalletDeployer`. If absolutely needed the contracts can be accessed directly or an alternative such as account abstraction should be used. \ No newline at end of file diff --git a/.changeset/plenty-bananas-shop.md b/.changeset/plenty-bananas-shop.md new file mode 100644 index 000000000..584e75ee6 --- /dev/null +++ b/.changeset/plenty-bananas-shop.md @@ -0,0 +1,9 @@ +--- +'@celo/contractkit': patch +--- + +Re-removes `grandamento` + + While 6.0.0 (9ab9d00eb) previously removed `grandamento` it was added back temporarily because `@celo/celocli` required the wrappers to be available in order to execute the proposal to remove it from governance. It is now gone for good. RIP. + + Due to previous removal this is not considered a breaking change. \ No newline at end of file diff --git a/.changeset/pre.json b/.changeset/pre.json new file mode 100644 index 000000000..5afc3862d --- /dev/null +++ b/.changeset/pre.json @@ -0,0 +1,34 @@ +{ + "mode": "pre", + "tag": "beta", + "initialVersions": { + "@celo/celocli": "3.1.3", + "@celo/base": "6.0.0", + "@celo/connect": "5.1.1", + "@celo/contractkit": "6.0.0", + "@celo/cryptographic-utils": "5.0.6", + "@celo/explorer": "5.0.7", + "@celo/governance": "5.0.8", + "@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": [ + "curly-pianos-applaud", + "plenty-bananas-shop", + "real-rabbits-grab", + "tough-gorillas-invent" + ] +} diff --git a/.changeset/real-rabbits-grab.md b/.changeset/real-rabbits-grab.md index 597bb6530..b7544826a 100644 --- a/.changeset/real-rabbits-grab.md +++ b/.changeset/real-rabbits-grab.md @@ -2,4 +2,4 @@ '@celo/celocli': major --- -Removes releasegold commnand topic. use releasecelo +Removes the `releasegold` command in favour of `releasecelo`. \ No newline at end of file diff --git a/.changeset/tough-gorillas-invent.md b/.changeset/tough-gorillas-invent.md index 4b95c0c25..a8fc84968 100644 --- a/.changeset/tough-gorillas-invent.md +++ b/.changeset/tough-gorillas-invent.md @@ -2,4 +2,4 @@ '@celo/celocli': major --- -Remove Grandamento from CLI +Remove `grandamento` commands from CLI. \ No newline at end of file diff --git a/.github/actions/sync-workspace/action.yml b/.github/actions/sync-workspace/action.yml index 85a993483..27eff964a 100644 --- a/.github/actions/sync-workspace/action.yml +++ b/.github/actions/sync-workspace/action.yml @@ -11,14 +11,14 @@ inputs: runs: using: "composite" steps: - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v4 with: node-version: '18' - name: "enable corepack for yarn" run : sudo corepack enable yarn shell: bash # must call twice because of chicken and egg problem with yarn and node - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v4 with: node-version: '18' cache: 'yarn' diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7a626cf28..44b8187d3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,14 +45,14 @@ jobs: runs-on: ['self-hosted', 'org', '8-cpu'] timeout-minutes: 30 steps: - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v4 with: node-version: '18' - name: "enable corepack for yarn" run : sudo corepack enable yarn - uses: actions/checkout@v4 # must call twice because of chicken and egg problem with yarn and node - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v4 with: node-version: '18' cache: 'yarn' @@ -77,7 +77,7 @@ jobs: run: yarn run postinstall if: steps.cache_node.outputs.cache-hit == 'true' - name: Build packages - run: yarn build --ignore docs --include-dependencies + run: yarn build - name: Check licenses if: steps.cache_node.outputs.cache-hit != 'true' run: | @@ -152,10 +152,11 @@ jobs: run: | mkdir -p test-results/jest # Skipping packages that are tested in a specific job below - yarn run lerna \ - --ignore @celo/contractkit \ - --ignore @celo/celocli \ - --ignore '@celo/wallet-*' \ + yarn workspaces foreach \ + --all \ + --exclude celo \ + --exclude "@celo/{celocli,contractkit,wallet-*}" \ + -ip \ run test - name: Upload Jest Test Results uses: actions/upload-artifact@v3 @@ -176,7 +177,7 @@ jobs: - run: sudo corepack enable yarn - name: Run Wallet tests run: | - yarn run lerna --scope '@celo/wallet-*' run test + yarn workspaces foreach -ip --all --include '@celo/wallet-*' run test contractkit-tests: name: ContractKit Tests diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index f35eca079..4b105db8b 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -20,7 +20,7 @@ jobs: repository-projects: write steps: - name: Checkout Repo - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Akeyless Get Secrets id: get_auth_token @@ -31,14 +31,17 @@ jobs: access-id: p-kf9vjzruht6l static-secrets: '{"/static-secrets/NPM/npm-publish-token":"NPM_TOKEN"}' - name: Setup Node.js 18.x - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: 18.x - - name: 'Setup yarn' + - name: "enable corepack for yarn" + run : sudo corepack enable yarn shell: bash - run: | - npm install --global yarn - source ~/.bashrc + # must call twice because of chicken and egg problem with yarn and node + - uses: actions/setup-node@v4 + with: + node-version: '18' + cache: 'yarn' - name: Install Dependencies shell: bash run: yarn diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index b82acff10..c59032a7f 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -18,7 +18,7 @@ jobs: pull-requests: write steps: - - uses: actions/stale@v8 + - uses: actions/stale@v9 with: repo-token: ${{ secrets.GITHUB_TOKEN }} stale-issue-message: 'This issue is stale and will be closed in 30 days without activity' diff --git a/lerna.json b/lerna.json deleted file mode 100644 index 6186a6723..000000000 --- a/lerna.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "lerna": "2.10.1", - "packages": [ - "packages/*", - "packages/sdk/*", - "packages/sdk/wallets/*" - ], - "npmClient": "yarn", - "useWorkspaces": true, - "version": "independent" -} diff --git a/package.json b/package.json index c5fc7c4fa..c74aa2395 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "private": true, "scripts": { "preinstall": "git config --global url.\"https://\".insteadOf ssh://", - "lint": "yarn lerna run lint", + "lint": "yarn workspaces foreach -piv --all run lint", "prettify": "yarn run prettier --config .prettierrc.js --write '**/*.+(ts|tsx|js|jsx|sol|java)'", "prettify:diff": "yarn run prettier --config .prettierrc.js --list-different '**/*.+(ts|tsx|js|jsx|sol|java)'", "reset": "yarn reset-modules && yarn reset-cache", @@ -15,20 +15,20 @@ "reset-rn": "watchman watch-del-all; rm -rf $TMPDIR/metro-cache-*; rm -rf $TMPDIR/haste-map-*; rm -rf $TMPDIR/metro-symbolicate*", "reset-yarn": "yarn cache clean", "test": "yarn test-pure && yarn test-needing-ganache", - "test-pure": "yarn run lerna run test --ignore @celo/contractkit --ignore @celo/celocli --ignore @celo/transactions-uri", + "test-pure": "yarn workspaces foreach -piv --all --exclude celo --exclude \"@celo/{celocli,contractkit,transactions-uri}\" run test", "test-needing-ganache": "yarn workspace @celo/contractkit test && yarn workspace @celo/celocli test && yarn workspace @celo/transactions-uri test", - "build": "yarn run lerna run build", - "clean": "yarn run lerna run clean", - "docs": "yarn run lerna run docs", + "build": "yarn workspaces foreach -pitv --all run build", + "clean": "yarn workspaces foreach -piv --all run clean", + "docs": "yarn workspaces foreach -piv --all run docs", "cs": "yarn changeset", "check-licenses": "yarn licenses list --prod | grep '\\(─ GPL\\|─ (GPL-[1-9]\\.[0-9]\\+ OR GPL-[1-9]\\.[0-9]\\+)\\)' && echo 'Found GPL license(s). Use 'yarn licenses list --prod' to look up the offending package' || echo 'No GPL licenses found'", - "report-coverage": "yarn run lerna run test-coverage", + "report-coverage": "yarn workspaces foreach -piv --all run test-coverage", "test:watch": "node node_modules/jest/bin/jest.js --watch", - "postinstall": "husky install && yarn run lerna run postinstall", + "postinstall": "husky install && yarn workspaces foreach -piv --all run postinstall", "release": "yarn clean && yarn build && yarn workspace @celo/celocli 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", + "version-and-reinstall": "yarn changeset version && yarn install --no-immutable", "celocli": "yarn workspace @celo/celocli run --silent celocli", "deprecate-sdks": "ts-node ./scripts/unpublish-sdks.ts" }, @@ -56,12 +56,10 @@ "eslint-plugin-unicorn": "^50.0.1", "husky": "^8.0.0", "jest": "^29.0.2", - "lerna": "^5.5.0", "prettier": "^2.7.1", "pretty-quick": "^2.0.1", "prompt": "1.2.0", - "semver": "7.3.5", - "solc": "0.5.8", + "semver": "7.5.2", "ts-jest": "^29.0.0", "ts-node": "^10.9.1", "tsconfig-paths": "^3.8.0", @@ -69,7 +67,7 @@ }, "resolutions": { "ganache": "npm:@soloseng/ganache@7.8.0-beta.1", - "bip39": "https://github.com/bitcoinjs/bip39#d8ea080a18b40f301d4e2219a2991cd2417e83c2", + "bip39": "https://github.com/bitcoinjs/bip39#a7ecbfe2e60d0214ce17163d610cad9f7b23140c", "blind-threshold-bls": "npm:@celo/blind-threshold-bls@1.0.0-beta", "@types/bn.js": "4.11.6", "bignumber.js": "9.0.0" diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index 60d792f40..7c5f272ae 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -1,5 +1,20 @@ # Changelog +## 4.0.0-beta.0 + +### Major Changes + +- [#21](https://github.com/celo-org/developer-tooling/pull/21) [`f167758`](https://github.com/celo-org/developer-tooling/commit/f1677581b90675e37a4846ce53b29d8615a056e6) Thanks [@aaronmgdr](https://github.com/aaronmgdr)! - Removes releasegold commnand topic. use releasecelo + +- [#21](https://github.com/celo-org/developer-tooling/pull/21) [`f167758`](https://github.com/celo-org/developer-tooling/commit/f1677581b90675e37a4846ce53b29d8615a056e6) Thanks [@aaronmgdr](https://github.com/aaronmgdr)! - Remove Grandamento from CLI + +### Patch Changes + +- Updated dependencies [[`8fb6c76`](https://github.com/celo-org/developer-tooling/commit/8fb6c76e4fada71c91f516ed151c4519ff2fe0fd)]: + - @celo/contractkit@6.0.1-beta.0 + - @celo/explorer@5.0.8-beta.0 + - @celo/governance@5.0.9-beta.0 + ## 3.1.3 ### Patch Changes diff --git a/packages/cli/bin/dev.js b/packages/cli/bin/dev.js index 73d168f5c..ad39b1eae 100644 --- a/packages/cli/bin/dev.js +++ b/packages/cli/bin/dev.js @@ -2,5 +2,6 @@ // eslint-disable-next-line node/shebang, unicorn/prefer-top-level-await ;(async () => { const oclif = await import('@oclif/core') + console.info('Running in development mode') await oclif.execute({ development: true, dir: __dirname }) })() diff --git a/packages/cli/jest.config.js b/packages/cli/jest.config.js index c0e61a403..5c8609ee3 100644 --- a/packages/cli/jest.config.js +++ b/packages/cli/jest.config.js @@ -1,6 +1,7 @@ module.exports = { preset: 'ts-jest', testMatch: ['/src/**/?(*.)+(spec|test).ts'], + setupFiles: ['/src/test-utils/setup.ts'], setupFilesAfterEnv: ['@celo/dev-utils/lib/matchers'], globalSetup: '/src/test-utils/setup.global.ts', globalTeardown: '/src/test-utils/teardown.global.ts', diff --git a/packages/cli/package.json b/packages/cli/package.json index e06cfb443..5ed8db620 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,7 +1,7 @@ { "name": "@celo/celocli", "description": "CLI Tool for transacting with the Celo protocol", - "version": "3.1.3", + "version": "4.0.0-beta.0", "author": "Celo", "license": "Apache-2.0", "repository": "celo-org/developer-tooling", @@ -9,7 +9,10 @@ "bugs": "https://github.com/celo-org/developer-tooling/issues?utf8=%E2%9C%93&q=label%3Acli+", "types": "lib/index.d.ts", "main": "lib/index.js", - "bin": "./bin/run", + "bin": { + "celocli": "./bin/run.js", + "dev": ".bin/dev.js" + }, "keywords": [ "celo", "celocli", @@ -20,21 +23,22 @@ }, "scripts": { "clean": "tsc -b . --clean", + "dev": "ts-node ./bin/dev.js", "build": "tsc -b .", "docs": "./generate_docs.sh", "lint": "yarn run --top-level eslint -c .eslintrc.js ", "prepublish": "", "prepack": "yarn run build && oclif manifest && oclif readme", - "test": "TZ=UTC jest --runInBand" + "test": "TZ=UTC yarn jest --runInBand" }, "dependencies": { "@celo/abis": "10.0.0", "@celo/base": "^6.0.0", "@celo/connect": "^5.1.1", - "@celo/contractkit": "^6.0.0", + "@celo/contractkit": "^6.0.1-beta.0", "@celo/cryptographic-utils": "^5.0.6", - "@celo/explorer": "^5.0.7", - "@celo/governance": "^5.0.8", + "@celo/explorer": "^5.0.8-beta.0", + "@celo/governance": "^5.0.9-beta.0", "@celo/identity": "^5.1.1", "@celo/phone-utils": "^6.0.0", "@celo/utils": "^5.0.6", @@ -43,18 +47,17 @@ "@celo/wallet-local": "^5.1.1", "@ethereumjs/util": "8.0.5", "@ledgerhq/hw-transport-node-hid": "^6.27.4", - "@oclif/core": "^3.15.0", - "@oclif/plugin-autocomplete": "^3.0.4", - "@oclif/plugin-commands": "^3.1.0", - "@oclif/plugin-help": "^6.0.9", - "@oclif/plugin-not-found": "^3.0.7", - "@oclif/plugin-plugins": "^4.1.14", - "@oclif/plugin-warn-if-update-available": "^3.0.8", - "@types/command-exists": "^1.2.0", + "@oclif/core": "^3.18.1", + "@oclif/plugin-autocomplete": "^3.0.5", + "@oclif/plugin-commands": "^3.1.1", + "@oclif/plugin-help": "^6.0.12", + "@oclif/plugin-not-found": "^3.0.9", + "@oclif/plugin-plugins": "^4.1.17", + "@oclif/plugin-warn-if-update-available": "^3.0.9", + "@types/command-exists": "^1.2.3", "bignumber.js": "9.0.0", "bip32": "3.1.0", "chalk": "^2.4.2", - "cli-table": "^0.3.1", "command-exists": "^1.2.9", "debug": "^4.1.1", "events": "^3.0.0", @@ -63,14 +66,13 @@ "path": "^0.12.7", "prompts": "^2.0.1", "randombytes": "^2.0.1", - "tslib": "^1", "web3": "1.10.0", "web3-utils": "^1.10.0" }, "devDependencies": { "@celo/celo-devchain": "^6.0.3", "@celo/dev-utils": "0.0.1-beta.1", - "@types/cli-table": "^0.3.0", + "@celo/typescript": "workspace:^", "@types/debug": "^4.1.4", "@types/fs-extra": "^8.0.0", "@types/humanize-duration": "^3.27.0", @@ -79,9 +81,8 @@ "@types/node": "^18.7.16", "@types/prompts": "^1.1.1", "@types/web3": "^1.0.18", - "globby": "^8", "jest": "^29.0.2", - "oclif": "^4.1.3", + "oclif": "^4.3.4", "prettier": "1.19.1", "ts-jest": "^29.0.0", "ts-node": "^10.9.1", diff --git a/packages/cli/src/base.ts b/packages/cli/src/base.ts index c56f7917b..190f0cfd7 100644 --- a/packages/cli/src/base.ts +++ b/packages/cli/src/base.ts @@ -4,13 +4,13 @@ import { stableTokenInfos } from '@celo/contractkit/lib/celo-tokens' import { AzureHSMWallet } from '@celo/wallet-hsm-azure' import { AddressValidation, newLedgerWalletWithSetup } from '@celo/wallet-ledger' import { LocalWallet } from '@celo/wallet-local' +import _TransportNodeHid from '@ledgerhq/hw-transport-node-hid' import { Command, Flags } from '@oclif/core' import chalk from 'chalk' import net from 'net' import Web3 from 'web3' import { getGasCurrency, getNodeUrl } from './utils/config' import { enumEntriesDupWithLowercase, requireNodeIsSynced } from './utils/helpers' - export const gasOptions = { auto: 'auto', Auto: 'auto', @@ -100,7 +100,6 @@ export abstract class BaseCommand extends Command { private _web3: Web3 | null = null private _kit: ContractKit | null = null - private _wallet?: ReadOnlyWallet async getWeb3() { if (!this._web3) { @@ -114,6 +113,14 @@ export abstract class BaseCommand extends Command { return this._web3 } + get _wallet(): ReadOnlyWallet | undefined { + return this._wallet + } + + set _wallet(wallet: ReadOnlyWallet | undefined) { + this._kit!.connection.wallet = wallet + } + async newWeb3() { const res = await this.parse() const nodeUrl = (res.flags && res.flags.node) || getNodeUrl(this.config.configDir) @@ -125,7 +132,6 @@ export abstract class BaseCommand extends Command { async getKit() { if (!this._kit) { this._kit = newKitFromWeb3(await this.getWeb3()) - this._kit.connection.wallet = this._wallet } const res = await this.parse() @@ -151,14 +157,12 @@ export abstract class BaseCommand extends Command { } if (res.flags.useLedger) { - let transport try { - // Importing for ledger uses only fixes running jest tests - const _TransportNodeHid = (await import('@ledgerhq/hw-transport-node-hid')).default // types seem to be suggesting 2 defaults but js is otherwise for TransportNodeHid - const TransportNodeHid: typeof _TransportNodeHid.default = + const TransportNodeHid: typeof _TransportNodeHid = + // @ts-expect-error _TransportNodeHid.default || _TransportNodeHid - transport = await TransportNodeHid.open('') + const transport = await TransportNodeHid.open('') const derivationPathIndexes = res.raw.some( (value) => (value as any).flag === 'ledgerCustomAddresses' ) diff --git a/packages/cli/src/commands/account/list.test.ts b/packages/cli/src/commands/account/list.test.ts new file mode 100644 index 000000000..30bc0a992 --- /dev/null +++ b/packages/cli/src/commands/account/list.test.ts @@ -0,0 +1,55 @@ +import { ContractKit, newKitFromWeb3 } from '@celo/contractkit' +import { testWithGanache } from '@celo/dev-utils/lib/ganache-test' +import { AddressValidation } from '@celo/wallet-ledger/lib/ledger-wallet' +import { LocalWallet } from '@celo/wallet-local' +import Web3 from 'web3' +import { testLocally } from '../../test-utils/cliUtils' +import List from './list' +process.env.NO_SYNCCHECK = 'true' + +jest.mock('@celo/wallet-ledger', () => { + return { + AddressValidation, + newLedgerWalletWithSetup: jest.fn(() => { + const wallet = new LocalWallet() + jest.spyOn(wallet, 'getAccounts').mockImplementation(() => { + return [ + '0x7457d5E02197480Db681D3fdF256c7acA21bDc12', + '0x91c987bf62D25945dB517BDAa840A6c661374402', + ] + }) + return wallet + }), + } +}) + +testWithGanache('account:list', (web3: Web3) => { + let account: string + let accounts: string[] + let kit: ContractKit + + beforeEach(async () => { + accounts = await web3.eth.getAccounts() + kit = newKitFromWeb3(web3) + account = accounts[0] + + const accountsInstance = await kit.contracts.getAccounts() + await accountsInstance.createAccount().sendAndWaitForReceipt({ from: account }) + }) + test('shows the list of accounts', async () => { + const spy = jest.spyOn(console, 'log') + + await testLocally(List, []) + expect(spy).toHaveBeenCalledWith('All Addresses: ', accounts) + }) + + test('shows the list of accounts when --useLedger given', async () => { + const spy = jest.spyOn(console, 'log') + + await testLocally(List, ['--useLedger']) + expect(spy).toHaveBeenCalledWith('Ledger Addresses: ', [ + '0x7457d5E02197480Db681D3fdF256c7acA21bDc12', + '0x91c987bf62D25945dB517BDAa840A6c661374402', + ]) + }) +}) diff --git a/packages/cli/src/commands/account/list.ts b/packages/cli/src/commands/account/list.ts index 86817a6d5..f7faf1b17 100644 --- a/packages/cli/src/commands/account/list.ts +++ b/packages/cli/src/commands/account/list.ts @@ -16,12 +16,11 @@ export default class AccountList extends BaseCommand { async run() { const kit = await this.getKit() const res = await this.parse(AccountList) - - // Retreive accounts from the connected Celo node. + // Retrieve accounts from the connected Celo node. const allAddresses = !res.flags.local ? await kit.connection.getAccounts() : [] // Get addresses from the local wallet. - const localAddresses = res.flags.local ?? true ? await kit.connection.getLocalAccounts() : [] + const localAddresses = res.flags.local ?? true ? kit.connection.getLocalAccounts() : [] // Display the addresses. const localName = res.flags.useLedger ? 'Ledger' : 'Local' diff --git a/packages/cli/src/commands/validator/status.ts b/packages/cli/src/commands/validator/status.ts index 0398678d4..942ed1602 100644 --- a/packages/cli/src/commands/validator/status.ts +++ b/packages/cli/src/commands/validator/status.ts @@ -138,7 +138,7 @@ export default class ValidatorStatus extends BaseCommand { const bar = ux.progress({ format: 'counting block signatures [{bar}] {percentage}% | ETA: {eta}s | {value}/{total}', }) - bar.start(end - start) + bar.start(end, start) const countsBySigner = new Map() const incrementSignatureCounts = async (blockNumber: number) => { if ((blockNumber - start) % 10 === 0 || blockNumber === end) { diff --git a/packages/cli/src/test-utils/grandaMento.ts b/packages/cli/src/test-utils/grandaMento.ts deleted file mode 100644 index 28869b922..000000000 --- a/packages/cli/src/test-utils/grandaMento.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { GrandaMentoWrapper } from '@celo/contractkit/lib/wrappers/GrandaMento' -import BigNumber from 'bignumber.js' - -export const setGrandaMentoLimits = async ( - grandaMento: GrandaMentoWrapper, - newLimitMin: BigNumber = new BigNumber('1000'), - newLimitMax: BigNumber = new BigNumber('1000000000000'), - stableToken: string = 'StableToken' -) => { - await grandaMento - .setStableTokenExchangeLimits(stableToken, newLimitMin.toString(), newLimitMax.toString()) - .sendAndWaitForReceipt() -} diff --git a/packages/cli/src/test-utils/setup.ts b/packages/cli/src/test-utils/setup.ts new file mode 100644 index 000000000..5dbb83c4f --- /dev/null +++ b/packages/cli/src/test-utils/setup.ts @@ -0,0 +1,13 @@ +jest.mock('@ledgerhq/hw-transport-node-hid', () => { + return { + default: { + open: jest.fn(() => { + return { + send: jest.fn(() => new Promise(() => {})), + decorateAppAPIMethods: jest.fn(), + close: jest.fn(), + } + }), + }, + } +}) diff --git a/packages/cli/src/utils/checks.ts b/packages/cli/src/utils/checks.ts index f0726fc11..0ecb986a3 100644 --- a/packages/cli/src/utils/checks.ts +++ b/packages/cli/src/utils/checks.ts @@ -3,10 +3,6 @@ import { Address } from '@celo/connect' import { StableToken } from '@celo/contractkit' import { AccountsWrapper } from '@celo/contractkit/lib/wrappers/Accounts' import { GovernanceWrapper, ProposalStage } from '@celo/contractkit/lib/wrappers/Governance' -import { - ExchangeProposalState, - GrandaMentoWrapper, -} from '@celo/contractkit/lib/wrappers/GrandaMento' import { LockedGoldWrapper } from '@celo/contractkit/lib/wrappers/LockedGold' import { MultiSigWrapper } from '@celo/contractkit/lib/wrappers/MultiSig' import { ValidatorsWrapper } from '@celo/contractkit/lib/wrappers/Validators' @@ -103,14 +99,6 @@ class CheckBuilder { } } - withGrandaMento(f: (accounts: GrandaMentoWrapper) => A): () => Promise> { - return async () => { - const kit = await this.getKit() - const accounts = await kit.contracts.getGrandaMento() - return f(accounts) as Resolve - } - } - withGovernance( f: (governance: GovernanceWrapper, signer: Address, account: Address, ctx: CheckBuilder) => A ): () => Promise> { @@ -150,34 +138,6 @@ class CheckBuilder { this.withGovernance((governance) => governance.proposalExists(proposalID)) ) - grandaMentoProposalExists = (proposalID: string) => - this.addCheck( - `${proposalID} is an existing proposal`, - this.withGrandaMento((grandaMento) => grandaMento.exchangeProposalExists(proposalID)) - ) - - grandaMentoProposalHasState = (proposalID: string, state: ExchangeProposalState) => - this.addCheck( - `${proposalID} has state ${ExchangeProposalState[state]}`, - this.withGrandaMento(async (grandaMento) => { - const exchangeProposal = await grandaMento.getExchangeProposal(proposalID) - return exchangeProposal.state === state - }) - ) - - grandaMentoProposalIsExecutable = (proposalID: string) => { - this.grandaMentoProposalHasState(proposalID, ExchangeProposalState.Approved) - return this.addCheck( - `${proposalID} veto period has elapsed`, - this.withGrandaMento(async (grandaMento) => { - const exchangeProposal = await grandaMento.getExchangeProposal(proposalID) - return exchangeProposal.approvalTimestamp - .plus(exchangeProposal.vetoPeriodSeconds) - .isLessThanOrEqualTo(Date.now() / 1000) - }) - ) - } - proposalInStage = (proposalID: string, stage: keyof typeof ProposalStage) => this.addCheck( `${proposalID} is in stage ${stage}`, diff --git a/packages/cli/src/utils/cli.ts b/packages/cli/src/utils/cli.ts index 16d5e73dd..ebad41ff2 100644 --- a/packages/cli/src/utils/cli.ts +++ b/packages/cli/src/utils/cli.ts @@ -2,7 +2,6 @@ import { CeloTransactionObject, CeloTx, EventLog, parseDecodedParams } from '@ce import { Errors, ux } from '@oclif/core' import BigNumber from 'bignumber.js' import chalk from 'chalk' -import Table from 'cli-table' const CLIError = Errors.CLIError @@ -84,14 +83,6 @@ function toStringValueMapRecursive(valueMap: Record, prefix: string .join('\n') } -export function printVTable(valueMap: Record) { - const table = new Table() - Object.keys(valueMap).forEach((key) => { - table.push({ [key]: valueMap[key] }) - }) - console.log(table.toString()) -} - export function failWith(msg: string): never { throw new CLIError(msg) } diff --git a/packages/cli/tsconfig.json b/packages/cli/tsconfig.json index e8e4a0251..a40f800e9 100644 --- a/packages/cli/tsconfig.json +++ b/packages/cli/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "@celo/typescript/tsconfig.library.json", + "extends": "../typescript/tsconfig.library.json", "compilerOptions": { "resolveJsonModule": true, "moduleResolution": "node16", diff --git a/packages/docs/command-line-interface/autocomplete.md b/packages/docs/command-line-interface/autocomplete.md index 56d9d9903..5e4e803be 100644 --- a/packages/docs/command-line-interface/autocomplete.md +++ b/packages/docs/command-line-interface/autocomplete.md @@ -34,4 +34,4 @@ EXAMPLES $ celocli autocomplete --refresh-cache ``` -_See code: [@oclif/plugin-autocomplete](https://github.com/oclif/plugin-autocomplete/blob/v3.0.4/lib/commands/autocomplete/index.ts)_ +_See code: [@oclif/plugin-autocomplete](https://github.com/oclif/plugin-autocomplete/blob/v3.0.5/src/commands/autocomplete/index.ts)_ diff --git a/packages/docs/command-line-interface/commands.md b/packages/docs/command-line-interface/commands.md index 8c7279189..2d2b0657d 100644 --- a/packages/docs/command-line-interface/commands.md +++ b/packages/docs/command-line-interface/commands.md @@ -37,4 +37,4 @@ DESCRIPTION list all the commands ``` -_See code: [@oclif/plugin-commands](https://github.com/oclif/plugin-commands/blob/v3.1.0/lib/commands/commands.ts)_ +_See code: [@oclif/plugin-commands](https://github.com/oclif/plugin-commands/blob/v3.1.1/src/commands/commands.ts)_ diff --git a/packages/docs/command-line-interface/grandamento.md b/packages/docs/command-line-interface/grandamento.md deleted file mode 100644 index 2963beccb..000000000 --- a/packages/docs/command-line-interface/grandamento.md +++ /dev/null @@ -1,125 +0,0 @@ -`celocli grandamento` -===================== - -Cancels a Granda Mento exchange proposal - -* [`celocli grandamento:cancel`](#celocli-grandamentocancel) -* [`celocli grandamento:execute`](#celocli-grandamentoexecute) -* [`celocli grandamento:get-buy-amount`](#celocli-grandamentoget-buy-amount) -* [`celocli grandamento:list`](#celocli-grandamentolist) -* [`celocli grandamento:propose`](#celocli-grandamentopropose) -* [`celocli grandamento:show`](#celocli-grandamentoshow) - -## `celocli grandamento:cancel` - -Cancels a Granda Mento exchange proposal - -``` -USAGE - $ celocli grandamento:cancel --from (--proposalID | | ) - [--globalHelp] - -FLAGS - --from=0xc1912fEE45d61C87Cc5EA59DaE31190FFFFf232d (required) The address allowed to - cancel the proposal - --globalHelp View all available global flags - --proposalID= (required) UUID of proposal to view - -DESCRIPTION - Cancels a Granda Mento exchange proposal -``` - -## `celocli grandamento:execute` - -Executes a Granda Mento exchange proposal - -``` -USAGE - $ celocli grandamento:execute --from --proposalID [--globalHelp] - -FLAGS - --from=0xc1912fEE45d61C87Cc5EA59DaE31190FFFFf232d (required) The address to execute - the exchange proposal - --globalHelp View all available global flags - --proposalID= (required) UUID of proposal to view - -DESCRIPTION - Executes a Granda Mento exchange proposal -``` - -## `celocli grandamento:get-buy-amount` - -Gets the buy amount for a prospective Granda Mento exchange - -``` -USAGE - $ celocli grandamento:get-buy-amount --value --stableToken - cUSD|cusd|cEUR|ceur|cREAL|creal --sellCelo [--globalHelp] - -FLAGS - --globalHelp View all available global flags - --sellCelo (required) Sell or buy CELO - --stableToken=