Skip to content

refactor(cli): generate contracts with @cartesi/wagmi-plugin - #520

Open
brunomenezes wants to merge 2 commits into
prerelease/v2-alphafrom
refactor/cli-replace-devnet
Open

refactor(cli): generate contracts with @cartesi/wagmi-plugin#520
brunomenezes wants to merge 2 commits into
prerelease/v2-alphafrom
refactor/cli-replace-devnet

Conversation

@brunomenezes

@brunomenezes brunomenezes commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Summary

Code changes that replace the use of @sunodo/wagmi-plugin-hardhat-deploy + @cartesi/devnet package in favour of @cartesi/wagmi-plugin from rollups-ts repository.

export default defineConfig({
    out: "src/contracts.ts",
    plugins: [rollupsContracts()],
});

apps/cli no longer depends on @cartesi/devnet at all.

Changes

file change
apps/cli/wagmi.config.ts hardhatDeploy({ directory: … })rollupsContracts(); rollupsPrtContracts() left commented out
apps/cli/package.json drop @cartesi/devnet and @sunodo/wagmi-plugin-hardhat-deploy, add @cartesi/wagmi-plugin@1.0.0-alpha.6
apps/cli/src/base.ts surface three contracts the new codegen provides in cartesi address-book

@cartesi/wagmi-plugin is pinned exactly, as @cartesi/devnet was — the plugin version determines codegen output. 1.0.0-alpha.6 is the newest published version.

What the generated file looks like now

rollupsContracts() with no options defaults to rollups-contracts v3.0.0-alpha.10, and reads the release's anvil tarball too, so chain 31337 is covered out of the box.

Address book additions

Three contracts the release now provides are added to cartesi address-book:

entry where notes
TestUsdc devnet only a devnet test token new in alpha.9, alongside the existing TestToken / TestNFT / TestMultiToken
RefundOutputBuilder devnet and live chains new in rollups-contracts between alpha.6 and alpha.9, so @cartesi/devnet never had it
UsdWithdrawalOutputBuilderFactory devnet and live chains already generated before, just never surfaced in the address book — it is the factory behind the existing TestUsdWithdrawalOutputBuilder entry

Only five contracts in alpha.9 are genuinely devnet-only — TestFungibleToken, TestMultiToken, TestNonFungibleToken, TestUsdc and TestUsdWithdrawalOutputBuilder. The other two above are deployed at the same address on all nine chains, which is why they go in commonContracts.

This changes cartesi address-book output: 14 devnet rows become 17, and the fork output gains 2.

Merge blockers

1. Version alignment with the SDK image

The devnet Anvil state the CLI actually talks to is baked into the SDK image, and it is built from dave v3.0.0-alpha.3, i.e. rollups-contracts v3.0.0-alpha.6. Codegen now emits v3.0.0-alpha.10 addresses. Until the image catches up, cartesi run on devnet would talk to addresses that hold no code.

#515 is the other half: it moves the SDK image off @cartesi/devnet too, pulling anvil_state.json straight from the dave release (CARTESI_PRT_VERSION = 3.0.0-alpha.4, FOUNDRY_VERSION = 1.5.1), and it stops shipping /usr/share/cartesi/deployments and printing the address list from the devnet script — "use cartesi address-book". It depends on dave v3.0.0-alpha.4.

So this PR and #515 must land together, with DEFAULT_SDK_VERSION in src/config.ts:93 bumped to the resulting image, and the generated 31337 addresses re-checked against deployments/31337/ in the dave anvil tarball that image loads. That check also confirms dave alpha.4 is built against rollups-contracts alpha.9 rather than an earlier release — the matching anvil version (1.5.1 in both) is suggestive but not proof.

Worth knowing: after #515, this generated file is the only place devnet addresses are printed, so a codegen mistake is no longer cross-checkable at runtime.

Checklist before merge

  • dave releases v3.0.0-alpha.4, #515 merges, and an SDK image ships
  • Bump DEFAULT_SDK_VERSION in apps/cli/src/config.ts to that image
  • Confirm dave v3.0.0-alpha.4 is built against rollups-contracts v3.0.0-alpha.10, and that the generated 31337 addresses match deployments/31337/ in its anvil tarball
  • bun run --cwd apps/cli codegen && bun run --cwd apps/cli compile clean
  • bun test apps/cli/ green — the expected addresses in tests/unit/validations.test.ts and tests/unit/compose/node.test.ts need updating for alpha.10
  • bun lint clean
  • Smoke test against the new SDK image: cartesi run, cartesi address-book (devnet and --fork on a public chain, checking the three new entries resolve), cartesi run --prt, cartesi deposit erc20 against TestFungibleToken

Follow-up (separate PR)

Once this and #515 are both in, nothing consumes packages/devnet any more. It can be deleted outright, along with .github/workflows/devnet.yaml, its workspace entry, and its row in CLAUDE.md. That is the endpoint this branch is named for.

Notes for reviewers

  • Codegen now needs network access. The plugin downloads and hash-verifies three tarballs (artifacts, deployment addresses, anvil) on every run and keeps nothing between runs, by design. Offline builds of apps/cli will fail; CI is unaffected.

@changeset-bot

changeset-bot Bot commented Aug 19, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e21f35b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@cartesi/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@brunomenezes brunomenezes moved this to 🧑‍💻 In Progress in Rollups Tooling Aug 19, 2026
@brunomenezes brunomenezes self-assigned this Aug 19, 2026
@socket-security

socket-security Bot commented Aug 19, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​cartesi/​wagmi-plugin@​1.0.0-alpha.6731009896100
Addedmodern-tar@​0.7.710010010095100

View full report

@tuler
tuler force-pushed the refactor/cli-replace-devnet branch from 1f8e52f to e21f35b Compare September 2, 2026 20:40
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Coverage Report

Status Category Percentage Covered / Total
🟢 Lines 99.45% (🎯 0%) 12302 / 12370
🔵 Statements 99.45% 12302 / 12370
🔵 Functions 94.89% 130 / 137
🔵 Branches 0% 0 / 0
📁 File Coverage (19 files)
File Lines Statements Functions Branches Uncovered Lines
apps/cli/src/builder/directory.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
apps/cli/src/builder/docker.ts 🟢 86.72% 🟢 86.72% 🟡 66.67% 🔴 0% 75-77, 79, 109-111, 169-178
apps/cli/src/builder/empty.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
apps/cli/src/builder/none.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
apps/cli/src/builder/tar.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
apps/cli/src/compose/builder.ts 🟢 99.79% 🟢 99.79% 🟢 100% 🔴 0% 228
apps/cli/src/compose/common.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
apps/cli/src/compose/node.ts 🟢 99.24% 🟢 99.24% 🟢 100% 🔴 0% 106
apps/cli/src/config.ts 🟢 94.32% 🟢 94.32% 🟢 95.24% 🔴 0% 75-76, 251, 260, 269, 363, ...
apps/cli/src/contracts.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
...rc/errors/ForkChainValidationError.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
...c/errors/UnsupportedForkChainError.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
...c/exec/cartesi-machine-stored-hash.ts 🟢 92.86% 🟢 92.86% 🟢 100% 🔴 0% 36-37
apps/cli/src/exec/cartesi-machine.ts 🟡 75% 🟡 75% 🟡 66.67% 🔴 0% 10-12, 28-30
apps/cli/src/exec/genext2fs.ts 🟢 96.92% 🟢 96.92% 🟢 100% 🔴 0% 87-88
apps/cli/src/exec/index.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
apps/cli/src/exec/mksquashfs.ts 🟢 91.53% 🟢 91.53% 🟢 100% 🔴 0% 70-74
apps/cli/src/exec/util.ts 🟢 85.11% 🟢 85.11% 🟡 66.67% 🔴 0% 24-28, 68-69
apps/cli/src/validations.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -

@tuler
tuler marked this pull request as ready for review September 2, 2026 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Todo
Status: 🧑‍💻 In Progress

Development

Successfully merging this pull request may close these issues.

1 participant