Skip to content

refactor(cli): migrate governance commands to viem [6/8]#771

Open
pahor167 wants to merge 1 commit intopahor/viem-D2-cli-commands-1from
pahor/viem-D3-cli-governance
Open

refactor(cli): migrate governance commands to viem [6/8]#771
pahor167 wants to merge 1 commit intopahor/viem-D2-cli-commands-1from
pahor/viem-D3-cli-governance

Conversation

@pahor167
Copy link
Copy Markdown
Contributor

@pahor167 pahor167 commented Apr 1, 2026

Stack

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

Changes

Replace web3-based transaction patterns with viem equivalents across all governance/ CLI commands and their tests.

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


PR-Codex overview

This PR focuses on refactoring governance-related commands in the CLI to utilize the viem library for transaction handling instead of the previous web3 implementation. This change improves compatibility and performance.

Detailed summary

  • Replaced toBuffer with hexToBytes in show.ts and preparehotfix.ts.
  • Updated transaction display function from displaySendTx to displayViemTx across multiple files.
  • Added publicClient to various command classes for transaction handling.
  • Adjusted transaction calls to use publicClient for waiting on receipts.
  • Refactored tests to use newKitFromProvider instead of newKitFromWeb3.
  • Modified proposal and hotfix execution methods to accommodate new transaction handling.
  • Ensured all governance-related commands consistently utilize the viem library.

The following files were skipped due to too many changes: packages/cli/src/commands/governance/executehotfix.test.ts, packages/cli/src/commands/governance/withdraw.test.ts, packages/cli/src/commands/governance/propose.test.ts, packages/cli/src/commands/governance/approve.test.ts

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

Replace web3-based transaction patterns with viem equivalents across
all governance/ CLI commands and their tests.
@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: f9b5f5d

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: f9b5f5dd14

ℹ️ 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".

Comment on lines +141 to +144
const proposalIndex = dequeue.findIndex((d) => d.eq(id))
encodedGovernanceData = governance.encodeFunctionData('approve', [
id,
proposalIndex.toString(),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reject missing dequeue index before encoding approve calldata

When --proposalID is used with --useMultiSig/--useSafe, the code now computes proposalIndex via findIndex but never checks for -1. If the proposal is no longer in getDequeue() (e.g., state changed between checks and encoding), this builds calldata with an invalid index instead of failing fast, so the command can submit an unusable multisig/safe transaction. The previous path (governance.approve(id)) guarded this by throwing when the dequeue index was missing.

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