Skip to content

refactor(cli): migrate account, dkg, election, epochs to viem [5/8]#770

Open
pahor167 wants to merge 1 commit intopahor/viem-D1-cli-basefrom
pahor/viem-D2-cli-commands-1
Open

refactor(cli): migrate account, dkg, election, epochs to viem [5/8]#770
pahor167 wants to merge 1 commit intopahor/viem-D1-cli-basefrom
pahor/viem-D2-cli-commands-1

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 account/, dkg/, election/, and epochs/ CLI commands and their tests.

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


PR-Codex overview

This PR refactors the codebase to replace the usage of web3 with kit.connection.viemClient for transaction handling and account management, enhancing consistency and potentially improving performance.

Detailed summary

  • Replaced web3 calls with kit.connection.viemClient.request in various account commands.
  • Updated display functions from displaySendTx to displayViemTx.
  • Modified account address handling using getAddress instead of toChecksumAddress.
  • Refactored transaction handling in dkg commands to use encodeFunctionData and waitForTransactionReceipt.
  • Changed test utilities from testLocallyWithWeb3Node to testLocallyWithNode.
  • Consistently used newKitFromProvider for initializing kit in tests.

The following files were skipped due to too many changes: packages/cli/src/commands/account/claims.test.ts, packages/cli/src/commands/election/show.test.ts, packages/cli/src/commands/account/new.test.ts, packages/cli/src/commands/epochs/process-groups.test.ts, packages/cli/src/commands/account/authorize.test.ts, packages/cli/src/commands/election/activate.test.ts

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

Replace web3-based transaction patterns with viem equivalents across
account/, dkg/, election/, and epochs/ 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: 5b3cffd

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: 5b3cffde48

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

data: resultData!,
}) as readonly [unknown, unknown]
const group = { threshold: data[0], blsKeys: data[1] }
this.log(JSON.stringify(group))
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 Serialize bigint threshold before logging DKG group data

In the viem path, getBlsKeys decodes the uint256 threshold as a bigint, so JSON.stringify(group) throws TypeError: Do not know how to serialize a BigInt when users run dkg:get --method group. The previous web3 call returned stringified numbers, so this is a regression that makes the group method unusable.

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

Comment on lines +30 to +33
send: (tx: any) =>
kit.connection
.sendTransaction({ ...tx, to: dkg.address, data: startData })
.then((r) => r),
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 Wait for DKG start tx receipt before printing success

The custom send implementation returns kit.connection.sendTransaction(...), which resolves to a transaction hash, not a mined receipt; displayTx therefore completes as soon as the hash is returned and the command prints DKG Started! before confirmation. On non-instant mining networks (or if the tx later reverts), this can falsely report success and cause subsequent DKG steps to run too early.

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