refactor(cli): migrate governance commands to viem [6/8]#771
refactor(cli): migrate governance commands to viem [6/8]#771pahor167 wants to merge 1 commit intopahor/viem-D2-cli-commands-1from
Conversation
Replace web3-based transaction patterns with viem equivalents across all governance/ CLI commands and their tests.
|
There was a problem hiding this comment.
π‘ 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".
| const proposalIndex = dequeue.findIndex((d) => d.eq(id)) | ||
| encodedGovernanceData = governance.encodeFunctionData('approve', [ | ||
| id, | ||
| proposalIndex.toString(), |
There was a problem hiding this comment.
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 πΒ / π.
Stack
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
viemlibrary for transaction handling instead of the previousweb3implementation. This change improves compatibility and performance.Detailed summary
toBufferwithhexToBytesinshow.tsandpreparehotfix.ts.displaySendTxtodisplayViemTxacross multiple files.publicClientto various command classes for transaction handling.publicClientfor waiting on receipts.newKitFromProviderinstead ofnewKitFromWeb3.viemlibrary.