refactor(cli): migrate account, dkg, election, epochs to viem [5/8]#770
refactor(cli): migrate account, dkg, election, epochs to viem [5/8]#770pahor167 wants to merge 1 commit intopahor/viem-D1-cli-basefrom
Conversation
Replace web3-based transaction patterns with viem equivalents across account/, dkg/, election/, and epochs/ 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: 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)) |
There was a problem hiding this comment.
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 πΒ / π.
| send: (tx: any) => | ||
| kit.connection | ||
| .sendTransaction({ ...tx, to: dkg.address, data: startData }) | ||
| .then((r) => r), |
There was a problem hiding this comment.
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 πΒ / π.
Stack
Changes
Replace web3-based transaction patterns with viem equivalents across
account/,dkg/,election/, andepochs/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
web3withkit.connection.viemClientfor transaction handling and account management, enhancing consistency and potentially improving performance.Detailed summary
web3calls withkit.connection.viemClient.requestin various account commands.displaySendTxtodisplayViemTx.getAddressinstead oftoChecksumAddress.dkgcommands to useencodeFunctionDataandwaitForTransactionReceipt.testLocallyWithWeb3NodetotestLocallyWithNode.newKitFromProviderfor initializingkitin tests.