diff --git a/.changeset/eighty-clowns-buy.md b/.changeset/eighty-clowns-buy.md new file mode 100644 index 00000000..a05e488f --- /dev/null +++ b/.changeset/eighty-clowns-buy.md @@ -0,0 +1,5 @@ +--- +"@cartesi/cli": major +--- + +DEPRECATED: cartesi deploy build diff --git a/.changeset/flat-ears-explain.md b/.changeset/flat-ears-explain.md new file mode 100644 index 00000000..242e8359 --- /dev/null +++ b/.changeset/flat-ears-explain.md @@ -0,0 +1,5 @@ +--- +"@cartesi/cli": minor +--- + +improve doctor command diff --git a/.changeset/floppy-eggs-rescue.md b/.changeset/floppy-eggs-rescue.md new file mode 100644 index 00000000..63d3613c --- /dev/null +++ b/.changeset/floppy-eggs-rescue.md @@ -0,0 +1,5 @@ +--- +"@cartesi/cli": major +--- + +new: cartesi rollups deploy diff --git a/.changeset/huge-jeans-love.md b/.changeset/huge-jeans-love.md new file mode 100644 index 00000000..f348eabf --- /dev/null +++ b/.changeset/huge-jeans-love.md @@ -0,0 +1,5 @@ +--- +"@cartesi/cli": major +--- + +DEPRECATED: cartesi run diff --git a/.changeset/kind-mice-help.md b/.changeset/kind-mice-help.md new file mode 100644 index 00000000..51f34fa6 --- /dev/null +++ b/.changeset/kind-mice-help.md @@ -0,0 +1,5 @@ +--- +"@cartesi/cli": major +--- + +new: cartesi rollups stop diff --git a/.changeset/soft-bats-pump.md b/.changeset/soft-bats-pump.md new file mode 100644 index 00000000..f94397bf --- /dev/null +++ b/.changeset/soft-bats-pump.md @@ -0,0 +1,5 @@ +--- +"@cartesi/cli": major +--- + +new: cartesi rollups start diff --git a/.changeset/solid-owls-burn.md b/.changeset/solid-owls-burn.md new file mode 100644 index 00000000..afd29626 --- /dev/null +++ b/.changeset/solid-owls-burn.md @@ -0,0 +1,5 @@ +--- +"@cartesi/cli": major +--- + +new: cartesi rollups status diff --git a/.changeset/upset-news-ask.md b/.changeset/upset-news-ask.md new file mode 100644 index 00000000..8458f004 --- /dev/null +++ b/.changeset/upset-news-ask.md @@ -0,0 +1,5 @@ +--- +"@cartesi/cli": major +--- + +DEPRECATED: cartesi deploy diff --git a/apps/cli/package.json b/apps/cli/package.json index c8f519c2..53894783 100644 --- a/apps/cli/package.json +++ b/apps/cli/package.json @@ -18,50 +18,50 @@ ], "dependencies": { "@commander-js/extra-typings": "^13.1.0", - "@inquirer/confirm": "^5.0.0", - "@inquirer/core": "^10.0.0", - "@inquirer/input": "^4.0.0", - "@inquirer/select": "^4.0.0", - "@inquirer/type": "^3.0.0", + "@inquirer/confirm": "^5.1.6", + "@inquirer/core": "^10.1.7", + "@inquirer/input": "^4.1.6", + "@inquirer/select": "^4.0.9", + "@inquirer/type": "^3.0.4", "bytes": "^3.1.2", - "chalk": "^5.3.0", + "chalk": "^5.4.1", "cli-table3": "^0.6.5", "commander": "^13.1.0", - "execa": "^9.4.1", - "fs-extra": "^11.2.0", - "giget": "^1.2.3", - "lookpath": "^1.2.2", + "execa": "^9.5.2", + "fs-extra": "^11.3.0", + "giget": "^2.0.0", + "lookpath": "^1.2.3", "open": "^10.1.0", - "ora": "^8.1.0", + "ora": "^8.2.0", "progress-stream": "^2.0.0", - "semver": "^7.6.3", - "smol-toml": "^1.3.0", + "semver": "^7.7.1", + "smol-toml": "^1.3.1", "tmp": "^0.2.3", - "viem": "^2.21.27" + "viem": "^2.23.6" }, "devDependencies": { "@cartesi/devnet": "workspace:*", "@cartesi/eslint-config": "workspace:*", "@sunodo/wagmi-plugin-hardhat-deploy": "^0.3.0", - "@types/bytes": "^3.1.4", + "@types/bytes": "^3.1.5", "@types/fs-extra": "^11.0.4", "@types/inquirer": "^9.0.7", - "@types/node": "^22.7.6", - "@types/node-fetch": "^2.6.11", + "@types/node": "^22.13.9", + "@types/node-fetch": "^2.6.12", "@types/progress-stream": "^2.0.5", "@types/prompts": "^2.4.9", "@types/semver": "^7.5.8", "@types/tmp": "^0.2.6", "@vitest/coverage-istanbul": "^2.1.3", - "@wagmi/cli": "^2.1.16", + "@wagmi/cli": "^2.2.0", "copyfiles": "^2.4.1", "eslint": "^8.57.0", "npm-run-all": "^4.1.5", "rimraf": "^6.0.1", "ts-node": "^10.9.2", "tsconfig": "workspace:*", - "tslib": "^2.8.0", - "typescript": "^5.6.3", + "tslib": "^2.8.1", + "typescript": "^5.8.2", "vitest": "^2.1.3" }, "scripts": { diff --git a/apps/cli/src/base.ts b/apps/cli/src/base.ts index dfef2eca..54cab2ea 100644 --- a/apps/cli/src/base.ts +++ b/apps/cli/src/base.ts @@ -1,8 +1,9 @@ +import { InvalidArgumentError } from "@commander-js/extra-typings"; import chalk from "chalk"; import { execa } from "execa"; import fs from "fs"; import path from "path"; -import { Address, getAddress, Hash, isHash } from "viem"; +import { Address, getAddress, Hash, isAddress, isHash, zeroHash } from "viem"; import { Config, parse } from "./config.js"; import { applicationFactoryAddress, @@ -18,6 +19,7 @@ import { testNftAddress, testTokenAddress, } from "./contracts.js"; +import { getApplicationAddress } from "./exec/rollups.js"; import { PsResponse } from "./types/docker.js"; export const getContextPath = (...paths: string[]): string => { @@ -42,11 +44,6 @@ export const getApplicationConfig = (configPath: string): Config => { : parse(""); }; -export const getApplicationAddress = async (): Promise
=> { - // fixed value, as we do deterministic deployment with a zero hash - return getAddress("0xab7528bb862fb57e8a2bcd567a2e929a0be56a5e"); -}; - export type AddressBook = Record; export const getAddressBook = async (): Promise => { @@ -54,7 +51,6 @@ export const getAddressBook = async (): Promise => { // build rollups contracts address book const contracts: AddressBook = { - Application: applicationAddress, ApplicationFactory: applicationFactoryAddress, AuthorityFactory: authorityFactoryAddress, EntryPointV06: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789", @@ -79,6 +75,10 @@ export const getAddressBook = async (): Promise => { VerifyingPaymasterV07: "0xc5c97885C67F7361aBAfD2B95067a5bBdA603608", }; + if (applicationAddress) { + contracts.Application = applicationAddress; + } + return contracts; }; @@ -109,3 +109,28 @@ export const getServiceState = async ( const ps = stdout ? (JSON.parse(stdout) as PsResponse) : undefined; return ps?.State; }; + +export const parseAddress = ( + value: string, + _previous: Address | undefined, +): Address | undefined => { + if (isAddress(value)) { + return getAddress(value); + } else { + if (value !== "") { + throw new InvalidArgumentError(`Invalid address: ${value}`); + } + return undefined; + } +}; + +export const parseHash = (value: string, _previous: Hash): Hash => { + if (isHash(value)) { + return value; + } else { + if (value !== "") { + throw new InvalidArgumentError(`Invalid hash: ${value}`); + } + return zeroHash; + } +}; diff --git a/apps/cli/src/commands/address-book.ts b/apps/cli/src/commands/address-book.ts index 609b6a62..cca474df 100755 --- a/apps/cli/src/commands/address-book.ts +++ b/apps/cli/src/commands/address-book.ts @@ -2,9 +2,8 @@ import { Command } from "@commander-js/extra-typings"; import Table from "cli-table3"; import { getAddressBook } from "../base.js"; -export const registerAddressBookCommand = (program: Command) => { - program - .command("address-book") +export const createAddressBookCommand = () => { + return new Command("address-book") .description( "Prints the addresses of all smart contracts deployed to the runtime environment of the application.", ) diff --git a/apps/cli/src/commands/build.ts b/apps/cli/src/commands/build.ts index 73c4c106..58a776b5 100755 --- a/apps/cli/src/commands/build.ts +++ b/apps/cli/src/commands/build.ts @@ -38,9 +38,8 @@ const buildDrive = async ( } }; -export const registerBuildCommand = (program: Command) => { - program - .command("build") +export const createBuildCommand = () => { + return new Command("build") .description( "Build application by building Cartesi machine drives, configuring a machine and booting it.", ) diff --git a/apps/cli/src/commands/clean.ts b/apps/cli/src/commands/clean.ts index 7deccfc9..71bd0824 100755 --- a/apps/cli/src/commands/clean.ts +++ b/apps/cli/src/commands/clean.ts @@ -2,9 +2,8 @@ import { Command } from "@commander-js/extra-typings"; import fs from "fs-extra"; import { getContextPath } from "../base.js"; -export const registerCleanCommand = (program: Command) => { - program - .command("clean") +export const createCleanCommand = () => { + return new Command("clean") .description("Deletes all cached build artifacts of application.") .action(async () => { await fs.emptyDir(getContextPath()); diff --git a/apps/cli/src/commands/create.ts b/apps/cli/src/commands/create.ts index d3370d48..ce3af435 100755 --- a/apps/cli/src/commands/create.ts +++ b/apps/cli/src/commands/create.ts @@ -39,9 +39,8 @@ const download = async ( }); }; -export const registerCreateCommand = (program: Command) => { - program - .command("create") +export const createCreateCommand = () => { + return new Command("create") .argument("", "application and directory name") .addOption( new Option("-t, --template