refactor(connect,utils): replace web3 with viem [1/8]#766
refactor(connect,utils): replace web3 with viem [1/8]#766
Conversation
- Delete rpc-caller.ts, celo-transaction-object.ts, tx-result.ts, promi-event - Add contract-types.ts (CeloContract<TAbi>), viem-abi-coder.ts, wallet-adapter.ts - Replace web3 ABI types with viem-native equivalents in abi-types.ts - Rewrite connection.ts internals to use viem client - Remove BigNumber/bn.js from utils β use native bigint in solidity.ts, signatureUtils.ts, ecies.ts - Remove @ethereumjs/* dependencies - Patch buffer-equal-constant-time for Node 25 compatibility - Drop web3 from yarn.lock
π¦ Changeset detectedLatest commit: 05fceb7 The changes in this PR will be included in the next version bump. This PR includes changesets to release 15 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
π‘ Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 05fceb7606
βΉοΈ 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".
|
|
||
| debugPayload('%O', payload) | ||
| request: EIP1193RequestFn = async ({ method, params }) => { | ||
| const safeParams: any[] = Array.isArray(params) ? params : params != null ? [params] : [] |
There was a problem hiding this comment.
Preserve object-form params when forwarding requests
The new request implementation always coerces non-array params into an array ({...} becomes [{...}]), but EIP-1193 allows object-form params and some RPC methods require that exact shape. In those cases (for example wallet-management methods), forwarding through CeloProvider will send malformed params and the upstream provider will reject the call, breaking consumers that call connection.currentProvider.request(...) with object params.
Useful? React with πΒ / π.
| const isOverrides = | ||
| lastArg != null && typeof lastArg === 'object' && !Array.isArray(lastArg) |
There was a problem hiding this comment.
Distinguish tuple args from tx overrides in write proxy
The proxy assumes any last argument that is an object is a transaction overrides object, but viem tuple/struct arguments are also plain objects. For contract write methods whose final ABI argument is a tuple, this path can incorrectly treat that tuple as overrides, injecting/removing fields like account/chain on user data and skipping proper overrides placement, which can cause write calls to fail or send with unintended account handling.
Useful? React with πΒ / π.
Stack
Changes
rpc-caller.ts,celo-transaction-object.ts,tx-result.tscontract-types.ts(CeloContract<TAbi>),viem-abi-coder.ts,wallet-adapter.tsconnection.tsinternals to use viem clientutils/β native bigint insolidity.ts,signatureUtils.ts,ecies.ts@ethereumjs/*dependenciesbuffer-equal-constant-timefor Node 25 compatibilityyarn.lockPart of the web3 β viem migration. No CI requirement on this PR.
PR-Codex overview
This PR focuses on refactoring the codebase to improve type safety, remove deprecated features, and transition from
web3toviemfor contract interactions. It also enhances logging and adjusts transaction handling for better performance and clarity.Detailed summary
web3.viemfor contract interaction, replacingweb3methods.anytypes.viemconventions.console.infowithdebug.declarationMapto TypeScript configurations for better debugging.viemimplementation and removeweb3dependencies.