Skip to content

refactor(cli): migrate base, utils, test-utils to viem [4/8]#769

Open
pahor167 wants to merge 1 commit intopahor/viem-C-sdk-peripheralsfrom
pahor/viem-D1-cli-base
Open

refactor(cli): migrate base, utils, test-utils to viem [4/8]#769
pahor167 wants to merge 1 commit intopahor/viem-C-sdk-peripheralsfrom
pahor/viem-D1-cli-base

Conversation

@pahor167
Copy link
Copy Markdown
Contributor

@pahor167 pahor167 commented Apr 1, 2026

Stack

A β†’ B β†’ C β†’ D1 β†’ D2 β†’ D3 β†’ D4 β†’ D5 (CI)

Changes

  • base.ts: remove web3 from base command class
  • utils/cli.ts: replace displaySendTx with displayViemTx
  • utils/command.ts: migrate transaction helpers to viem
  • utils/checks.ts, governance.ts, release-gold-base.ts: remove web3 types
  • test-utils/: chain-setup, cliUtils, mockRpc updated for viem
  • Delete exchange.ts and exchange.test.ts (dead code)

Part of the web3 β†’ viem migration. No CI requirement on this PR.


PR-Codex overview

This PR primarily focuses on refactoring the codebase to replace instances of Web3 with a new Provider interface, enhancing consistency and functionality across the code. It also removes outdated methods and optimizes the transaction handling process.

Detailed summary

  • Deleted exchange.ts and exchange.test.ts files.
  • Updated tsconfig.json to exclude all test files.
  • Removed requireCall function from require.ts.
  • Replaced Web3 with Provider in several files.
  • Modified transaction handling to use viem actions for receipts.
  • Adjusted utility functions and tests to accommodate Provider.
  • Enhanced gas estimation and transaction sending methods.
  • Updated mock functions to use the new Provider interface.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

- base.ts: remove web3 from base command class
- utils/cli.ts: replace displaySendTx with displayViemTx
- utils/command.ts: migrate transaction helpers to viem
- utils/checks.ts, governance.ts, release-gold-base.ts: remove web3 types
- test-utils/: chain-setup, cliUtils, mockRpc updated for viem
- Remove exchange.ts and exchange.test.ts (dead code)
@pahor167 pahor167 requested a review from a team as a code owner April 1, 2026 09:08
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 1, 2026

⚠️ No Changeset found

Latest commit: 6929a33

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ’‘ Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6929a3371c

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with πŸ‘.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".


// TODO: How can we deploy contracts with the Celo provider w/o a CeloTransactionObject?
export async function displayWeb3Tx(name: string, txObj: any, tx?: Omit<CeloTx, 'data'>) {
export async function displayTx(name: string, txObj: any, tx?: Omit<CeloTx, 'data'>) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep displaySendTx exported for existing commands

Renaming displaySendTx to displayTx here breaks the current command surface because many command modules still import and call displaySendTx (for example packages/cli/src/commands/account/register.ts, packages/cli/src/commands/governance/approve.ts, and numerous others in this commit state). Without a compatibility export, TypeScript build/runtime module loading for those commands fails until every caller is migrated in the same change.

Useful? React with πŸ‘Β / πŸ‘Ž.

Comment on lines +167 to 173
async newProvider(): Promise<Provider> {
if (!this._provider) {
const nodeUrl = await this.getNodeUrl()
this._provider = getProviderForKit(nodeUrl, undefined)
}
return this._provider
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve BaseCommand.getWeb3 until callers are migrated

This refactor removes the getWeb3() API from BaseCommand, but multiple command files in this commit still invoke this.getWeb3() (e.g. commands/account/lock.ts, commands/account/unlock.ts, and governance commands). That leaves those commands broken as soon as they execute, so this change needs a temporary shim or an atomic migration of all call sites.

Useful? React with πŸ‘Β / πŸ‘Ž.

Comment on lines +8 to 12
export const createSafe = async (
provider: Provider,
signer: StrongAddress,
safeAddress: StrongAddress
) => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Re-export old Safe helpers while governance commands still use them

Replacing createSafeFromWeb3 / safeTransactionMetadataFromCeloTransactionObject with new names here is a breaking API change for existing governance commands that still import the old symbols (commands/governance/approve.ts, propose.ts, withdraw.ts in this commit). Those imports will fail unless these legacy exports remain available until callers are updated.

Useful? React with πŸ‘Β / πŸ‘Ž.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant