Skip to content

Add the rollupsPrtContracts wagmi plugin - #162

Draft
tuler wants to merge 1 commit into
prerelease/v2-alphafrom
claude/rollups-prt-contracts-import-202p0s
Draft

Add the rollupsPrtContracts wagmi plugin#162
tuler wants to merge 1 commit into
prerelease/v2-alphafrom
claude/rollups-prt-contracts-import-202p0s

Conversation

@tuler

@tuler tuler commented Aug 14, 2026

Copy link
Copy Markdown
Member

Follows #151, now merged — this branch is rebased onto prerelease/v2-alpha.

Adds rollupsPrtContracts, a second @wagmi/cli plugin that generates the PRT (Permissionless Refereed Tournaments) contracts from a dave release, defaulting to the v3.0.0-alpha.3 tarballs (hash-verified).

What the dave release layout needs

The tarball reading shared with rollupsContracts moves to src/release.ts and grows three things, each driven by how the dave release differs from a rollups-contracts one:

  • One foundry build per contracts project. The artifacts tarball holds cartesi-rollups/contracts/out and prt/contracts/out, and both nest .sol directories below their out (out/src/…, out/libs/…). Artifacts are now found by searching for .sol directories at any depth, which also covers the single-out rollups-contracts layout.
  • The same contract built by more than one project. 19 names appear in more than one build (ITournament, Machine, Time, …). They are generated once, and the copies must declare the same ABI — in alpha.3 they all do.
  • Deployment addresses for contracts built elsewhere. The deployment tarballs list 12 rollups-contracts contracts a PRT deployment runs against (InputBox, the portals, ApplicationFactory, the devnet test tokens, …). dave does not build them, so they have no ABI in the release. Those are now skipped instead of raising Deployed contract X has no build artifact.

dave publishes an anvil tarball of its own (deployments/31337/), so the devnet addresses are read the same way rollupsContracts reads them since #151 — through an anvil option defaulting to the release and disabled with false.

The intersection with rollups-contracts

dave builds its own copy of five cartesi-rollups interfaces — IApplication, IApplicationFactory, IInputBox, IOutputsMerkleRootValidator and IWithdrawalOutputBuilder — pinned to whichever rollups-contracts version it was released against, so the ABIs are not the same. The wagmi CLI rejects two contracts with the same name (Contract name "IApplication" must be unique.), so rollupsPrtContracts excludes them by default, exported as SHARED_CONTRACTS, and leaves them to rollupsContracts.

That makes the two plugins usable in the same config out of the box:

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

excludeSharedContracts: false generates the dave copies instead, which then rules rollupsContracts out.

The intersection is the same five names against both rollups-contracts 3.0.0-alpha.8 and 3.0.0-alpha.9, so #151's version bump did not change it.

One caveat, documented on the new docs page: while dave pins an older rollups-contracts, the two releases are deployed at different addresses (dave's InputBox on mainnet is 0x346B…3939, rollups-contracts 3.0.0-alpha.9's is 0xCC04…6fF2). The generated addresses for the rollups contracts are the rollups-contracts ones.

Preparing for dave 3.0.0-alpha.4

alpha.3 still ships one JSON file per deployed contract, as rollups-contracts did before 3.0.0-alpha.8. Deployment addresses are now read according to a deploymentFormat option ("json" | "txt"), defaulting to PRT_DEFAULT_DEPLOYMENT_FORMAT. When alpha.4 lands, moving to it is a bump of PRT_DEFAULT_VERSION, PRT_DEFAULT_ANVIL_VERSION and the three hashes, plus flipping that one constant to "txt"; rollupsContracts stays plaintext-only, as #151 made it.

Verification

Re-run in full after the rebase onto prerelease/v2-alpha:

  • rollupsContracts() alone: codec, client and react codegen unchanged; every package builds; docs site builds with no dead links and renders the new /wagmi-plugin/prt page.
  • Test suites: client 12, codec 70, react 122, all passing. pnpm lint is green across all 7 packages.
  • rollupsPrtContracts() alone: generates the PRT contracts with addresses across the 8 livenets plus the devnet.
  • Both together: 76 contracts, each shared name emitted exactly once and from rollups-contracts (iInputBoxAbi has alpha.9's 12 entries, inputBoxAddress is the alpha.9 address). Devnet addresses merge for every PRT contract — Tournament resolves to dave's 0xae22…57cA on chain 31337 and the livenets alike.
  • anvil: false: no chain 31337 in the output.
  • excludeSharedContracts: false alongside rollupsContracts(): fails with the wagmi CLI's duplicate-name error, as documented.
  • deploymentFormat: "txt" against alpha.3: fails with … has no .txt deployment file, so the tarball is not in the expected format.
  • No extraction directories left behind under the temp dir, on the success and the failure paths alike.
  • Changesets v3 accepts the new changeset: changeset version archives it into .changeset/pre/ and lands the entry under @cartesi/wagmi-plugin@1.0.0-alpha.5 as a minor.

One caveat about the sandbox this was verified in, not about the diff: turbo run build hits fetch failed when several packages download release tarballs concurrently. It reproduces on the base branch with this diff stashed, and building the packages one at a time succeeds.

🤖 Generated with Claude Code

https://claude.ai/code/session_017dyPxGkLKcxgyECXkVKqae

@changeset-bot

changeset-bot Bot commented Aug 14, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b524656

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

This PR includes changesets to release 1 package
Name Type
@cartesi/wagmi-plugin Minor

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

@tuler
tuler force-pushed the claude/wagmi-plugin-version-bump-e8wqpt branch from 5fbf1fc to 0c9a591 Compare August 17, 2026 12:44
@brunomenezes brunomenezes moved this to 🧑‍💻 In Progress in Rollups Tooling Aug 19, 2026
Base automatically changed from claude/wagmi-plugin-version-bump-e8wqpt to prerelease/v2-alpha August 19, 2026 19:24
@tuler
tuler force-pushed the claude/rollups-prt-contracts-import-202p0s branch 2 times, most recently from f22a61b to b7fa215 Compare August 20, 2026 14:05
Generate the PRT (Permissionless Refereed Tournaments) contracts from a
dave release, defaulting to the v3.0.0-alpha.3 GitHub release tarballs.

The tarball reading shared with rollupsContracts moves to release.ts, and
grows the three things the dave release layout needs:

- artifacts are searched for `.sol` directories at any depth, so a tarball
  holding one foundry build per contracts project works as well as one
  holding a single `out` directory;
- a contract built by more than one project is generated once, and its
  copies must declare the same ABI;
- a deployment address without a build artifact is skipped rather than an
  error, since the dave release also lists the rollups-contracts contracts
  a PRT deployment runs against, which dave does not build.

Both plugins can be used in the same config: the contracts both releases
build, exported as SHARED_CONTRACTS, are excluded from rollupsPrtContracts
by default, so the wagmi CLI does not fail on duplicate contract names.

dave publishes an anvil tarball of its own, so the devnet addresses are
read the same way, through an `anvil` option defaulting to the release and
disabled with `false`.

dave still ships one JSON file per deployed contract, as rollups-contracts
did before 3.0.0-alpha.8, so deployment addresses are read according to a
deploymentFormat option. It defaults to PRT_DEFAULT_DEPLOYMENT_FORMAT,
which becomes "txt" when the default moves to dave 3.0.0-alpha.4.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017dyPxGkLKcxgyECXkVKqae
@tuler
tuler force-pushed the claude/rollups-prt-contracts-import-202p0s branch from b7fa215 to b524656 Compare August 24, 2026 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🧑‍💻 In Progress

Development

Successfully merging this pull request may close these issues.

3 participants