refactor(cli): generate contracts with @cartesi/wagmi-plugin - #520
Draft
brunomenezes wants to merge 3 commits into
Draft
refactor(cli): generate contracts with @cartesi/wagmi-plugin#520brunomenezes wants to merge 3 commits into
brunomenezes wants to merge 3 commits into
Conversation
🦋 Changeset detectedLatest commit: 1f8e52f The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
…uilderFactory to the address book
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Code changes that replace the use of
@sunodo/wagmi-plugin-hardhat-deploy+@cartesi/devnetpackage in favour of@cartesi/wagmi-pluginfromrollups-tsrepository.apps/clino longer depends on@cartesi/devnetat all.Important
This PR does not build yet and is opened for review of the direction.
bun run --cwd apps/cli compilefails with 4tscerrors insrc/plus one intests/, all from the missing PRT contracts. See the checklist.Changes
apps/cli/wagmi.config.tshardhatDeploy({ directory: … })→rollupsContracts();rollupsPrtContracts()left commented outapps/cli/package.json@cartesi/devnetand@sunodo/wagmi-plugin-hardhat-deploy, add@cartesi/wagmi-plugin@1.0.0-alpha.4apps/cli/src/base.tscartesi address-book@cartesi/wagmi-pluginis pinned exactly, as@cartesi/devnetwas — the plugin version determines codegen output.1.0.0-alpha.4is the newest published version. (Its README says to install@alpha, but that dist-tag currently points at1.0.0-alpha.0, hence the explicit pin.)What the generated file looks like now
rollupsContracts()with no options defaults to rollups-contracts v3.0.0-alpha.9, and — since plugin1.0.0-alpha.4— reads the release's anvil tarball too, so chain 31337 is covered out of the box.@cartesi/devnet).src/contracts.tsis 5,694 lines, up from 3,446. The artifacts tarball also carries the dependency tree the contracts are compiled against; anincludelist onrollupsContracts()would trim it if the bundle growth matters.@cartesi/devnetdid not provide:refundOutputBuilder*,testUsdc*, plus ABIs for the interfaces and dependencies.Warning
Every contract address changes.
@cartesi/devnetbuilds from rollups-contracts v3.0.0-alpha.6; the plugin now defaults to v3.0.0-alpha.9. For exampleinputBoxAddressgoes0x346B3df038FE9f8380071eC6514D5a83aD143939→0x45daF6f9aA5fc563aB59481FDa36A281e5dB3812. This is the point of blocker 2 below: the generated addresses and the Anvil state the SDK image loads have to be bumped together.Address book additions
Three contracts the release now provides are added to
cartesi address-book:TestUsdcTestToken/TestNFT/TestMultiTokenRefundOutputBuilder@cartesi/devnetnever had itUsdWithdrawalOutputBuilderFactoryTestUsdWithdrawalOutputBuilderentryOnly five contracts in alpha.9 are genuinely devnet-only —
TestFungibleToken,TestMultiToken,TestNonFungibleToken,TestUsdcandTestUsdWithdrawalOutputBuilder. The other two above are deployed at the same address on all nine chains, which is why they go incommonContracts.This changes
cartesi address-bookoutput: 14 devnet rows become 17, and the fork output gains 2.Merge blockers
1. The PRT contracts are not generated yet
rollupsPrtContractsis added by cartesi/rollups-ts#162, still an open draft (now rebased ontoprerelease/v2-alpha; its dependency #151 is merged and shipped in plugin1.0.0-alpha.4). Until #162 lands,daveAppFactoryAbianddaveAppFactoryAddressdo not exist.Breaks
src/base.ts:18,src/validations.ts:11-12,src/compose/node.ts:4andtests/unit/validations.test.ts:4— the only remaining build failures.Uncommenting the
rollupsPrtContracts()line fixes all of them.daveAppFactoryAddresshas 6 distinct values across the 8 public chains, so the plugin will keep it as a chain-id record and thedaveAppFactoryAddress[chainId]lookups keep compiling.2. 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.9 addresses. Until the image catches up,
cartesi runon devnet would talk to addresses that hold no code.#515 is the other half: it moves the SDK image off
@cartesi/devnettoo, pullinganvil_state.jsonstraight from the dave release (CARTESI_PRT_VERSION = 3.0.0-alpha.4,FOUNDRY_VERSION = 1.5.1), and it stops shipping/usr/share/cartesi/deploymentsand printing the address list from thedevnetscript — "usecartesi address-book". It depends on dave v3.0.0-alpha.4, which is not released yet (alpha.3 is the newest).So this PR and #515 must land together, with
DEFAULT_SDK_VERSIONinsrc/config.ts:93bumped to the resulting image, and the generated 31337 addresses re-checked againstdeployments/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.
Resolved by
@cartesi/wagmi-plugin@1.0.0-alpha.4Two blockers listed in earlier revisions of this description are gone, both closed by the plugin release rather than by changes here:
*-deployment-addresses.tar.gzcovers only the live chains; 31337 ships in a separate*-anvil-*.tar.gzasset. The plugin now reads it through a newanviloption that defaults to the same release's tarball (DEFAULT_ANVIL,DEFAULT_ANVIL_VERSION), sotestFungibleTokenAddress,testMultiTokenAddress,testNonFungibleTokenAddressandtestUsdWithdrawalOutputBuilderAddressall generate. Passanvil: falsefor livenet-only output.TestUsdWithdrawalOutputBuilderhad no build artifact. The release publishes no artifact for the concrete contract the factory instantiates; the plugin now aliases its ABI toIUsdWithdrawalOutputBuilder.Checklist before merge
rollupsPrtContracts@cartesi/wagmi-pluginpin and uncommentrollupsPrtContracts()DEFAULT_SDK_VERSIONinapps/cli/src/config.tsto that imagedeployments/31337/in its anvil tarballbun run --cwd apps/cli codegen && bun run --cwd apps/cli compilecleanbun test apps/cli/green — the expected addresses intests/unit/validations.test.tsandtests/unit/compose/node.test.tsneed updating for alpha.9bun lintcleancartesi run,cartesi address-book(devnet and--forkon a public chain, checking the three new entries resolve),cartesi run --prt,cartesi deposit erc20againstTestFungibleTokenFollow-up (separate PR)
Once this and #515 are both in, nothing consumes
packages/devnetany more. It can be deleted outright, along with.github/workflows/devnet.yaml, its workspace entry, and its row inCLAUDE.md. That is the endpoint this branch is named for.Notes for reviewers
apps/cliwill fail; CI is unaffected.