feat(rn_cli_wallet): migrate ethers v5 → v6#561
Conversation
Upgrade `ethers` 5.8.0 -> ^6.13.5, decoupled from the previously-reverted secure-enclave work (MMKV plaintext storage kept as-is). - EIP155Lib: HDNodeWallet.fromPhrase / signTypedData / JsonRpcProvider, Wallet | HDNodeWallet typing. Public `_signTypedData` wrapper name kept. - PaymentTransactionUtil: BigNumber -> native bigint; StaticJsonRpcProvider -> JsonRpcProvider + `staticNetwork`; getBlock() null guards. - Named v6 imports across EIP155WalletUtil (Mnemonic.isValidMnemonic), HelperUtil, ERC20BalanceService, EIP155RequestHandlerUtil, PaymentStore. - SettingsStore: wrap wallet setters in valtio ref() (v6's private #signingKey breaks under the proxy and corrupts the shared wallet map). - Drop @ethersproject/pbkdf2 yarn patch + resolutions (v6 has no @ethersproject); keep bip39 patch for non-EVM seed derivation; update quick-crypto web shim comment. - Drive-bys from the original commit: reject eth_sign for security; add handleRedirect to the Canton/Tron sign modals. - Add SettingsStore regression test for the ethers v6 + valtio ref() fix. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Claude finished @ignaciosantise's task in 3m 40s —— View job Code ReviewTasks:
License compliance: ✅ No issues — Data classification: Pre-existing finding noted below (storage unchanged by this PR per stated scope). Found 2 issue(s)Issue 1:
|
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
… ethers version Address PR review: - buildFreshTxRequest: `|| null` coerced a valid `0n` fee to null (bigint is falsy in v6, unlike v5 BigNumber) and dropped EIP-1559 fields on chains returning maxPriorityFeePerGas/maxFeePerGas = 0n. Use `?? null`. - AGENTS.md: ethers 5.8.0 -> 6.13.5. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Thanks for the review — actions taken (commit 9fcfaf2): Issue 1 — Issue 2 — plaintext MMKV key material (CRITICAL, pre-existing): ⏭️ Out of scope (deferred). Doc drift — AGENTS.md listed **Other observations (ref() consistency, eth_sign rejection, getHighestBigInt guard, regression test): ** noted, no action needed — thanks for confirming. |
There was a problem hiding this comment.
Pull request overview
Migrates the wallets/rn_cli_wallet example wallet from ethers@5 to ethers@6, updating EVM signing/provider usage while keeping the existing (non-secure-enclave) storage approach intact. The PR also adds a regression test for the valtio + ethers v6 private fields interaction, rejects eth_sign requests, and triggers redirect handling after signing in Canton/Tron modals.
Changes:
- Upgrade EVM stack to ethers v6 (imports, wallet derivation/signing, providers, fee math).
- Harden request handling (reject
eth_sign) and add post-approve redirect handling in sign modals. - Add regression test ensuring
SettingsStore.setWallet()usesvaltio.ref()to avoid proxying ethers v6 internals.
Reviewed changes
Copilot reviewed 14 out of 16 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| wallets/rn_cli_wallet/package.json | Pins ethers to v6 and removes @ethersproject/pbkdf2 patch mappings. |
| wallets/rn_cli_wallet/yarn.lock | Lockfile updates reflecting ethers v6 and removed v5-era transitive deps. |
| wallets/rn_cli_wallet/src/lib/EIP155Lib.ts | Updates wallet init/typing and typed-data signing to ethers v6 APIs. |
| wallets/rn_cli_wallet/src/utils/PaymentTransactionUtil.ts | Migrates provider/fee types to v6 and switches fee math from BigNumber to bigint. |
| wallets/rn_cli_wallet/src/utils/HelperUtil.ts | Replaces ethers.utils usage with v6 top-level helpers. |
| wallets/rn_cli_wallet/src/utils/EIP155WalletUtil.ts | Updates mnemonic validation to ethers v6 Mnemonic API. |
| wallets/rn_cli_wallet/src/utils/EIP155RequestHandlerUtil.ts | Rejects eth_sign and migrates provider creation to v6 JsonRpcProvider. |
| wallets/rn_cli_wallet/src/store/SettingsStore.ts | Wraps wallet setters in valtio.ref() to avoid proxying ethers v6 instances. |
| wallets/rn_cli_wallet/src/store/PaymentStore.ts | Updates tx request typing to v6 TransactionRequest. |
| wallets/rn_cli_wallet/src/shims/quick-crypto.web.ts | Updates shim comment to reflect bip39 seed-derivation patch behavior. |
| wallets/rn_cli_wallet/src/services/ERC20BalanceService.ts | Migrates formatting/provider usage to ethers v6 APIs. |
| wallets/rn_cli_wallet/src/modals/SessionSignTronModal.tsx | Adds handleRedirect after approval and updates hook deps. |
| wallets/rn_cli_wallet/src/modals/SessionSignCantonModal.tsx | Adds handleRedirect after approval and updates hook deps. |
| wallets/rn_cli_wallet/AGENTS.md | Updates documented ethers version for the sample wallet. |
| wallets/rn_cli_wallet/tests/SettingsStore.test.ts | Adds regression test for ethers v6 + valtio proxy interaction. |
Comments suppressed due to low confidence (1)
wallets/rn_cli_wallet/src/utils/PaymentTransactionUtil.ts:298
- More
biginttruthiness:if (priorityFee)/if (maxFee)will skip valid0nvalues and incorrectly delete fee fields.
Switch these to explicit null checks so 0n is treated as a real value.
if (priorityFee) {
request.maxPriorityFeePerGas = priorityFee;
} else {
delete request.maxPriorityFeePerGas;
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const maxFee = priorityFee | ||
| ? getHighestBigNumber([ | ||
| ? getHighestBigInt([ | ||
| latestBlock.baseFeePerGas | ||
| ? latestBlock.baseFeePerGas.mul(2).add(priorityFee) | ||
| ? latestBlock.baseFeePerGas * 2n + priorityFee | ||
| : null, |
| if ( | ||
| !request.maxPriorityFeePerGas && | ||
| !request.maxFeePerGas && | ||
| feeData.gasPrice | ||
| ) { |
| export function getSignParamsMessage(params: string[]) { | ||
| const message = params.filter(p => !utils.isAddress(p))[0]; | ||
| const message = params.filter(p => !isAddress(p))[0]; | ||
|
|
||
| return convertHexToUtf8(message); | ||
| } |
| const chainData = PresetsUtil.getChainDataById(chainId); | ||
| const provider = new providers.JsonRpcProvider(chainData?.rpcUrl); | ||
| const provider = new JsonRpcProvider(chainData?.rpcUrl); | ||
| const sendTransaction = request.params[0]; | ||
| const connectedWallet = wallet.connect(provider); |
| "joi": "17.13.4", | ||
| "uuid": "11.1.1", | ||
| "@ton/crypto-primitives@2.1.0": "patch:@ton/crypto-primitives@npm%3A2.1.0#./.yarn/patches/@ton-crypto-primitives-npm-2.1.0-3d1ea62176.patch", | ||
| "@ethersproject/pbkdf2@5.8.0": "patch:@ethersproject/pbkdf2@npm%3A5.8.0#./.yarn/patches/@ethersproject-pbkdf2-npm-5.8.0-b720e81bcc.patch", | ||
| "@ethersproject/pbkdf2@^5.8.0": "patch:@ethersproject/pbkdf2@npm%3A5.8.0#./.yarn/patches/@ethersproject-pbkdf2-npm-5.8.0-b720e81bcc.patch", | ||
| "bip39@3.1.0": "patch:bip39@npm%3A3.1.0#./.yarn/patches/bip39-npm-3.1.0-03958ed434.patch", |
| "ed25519-hd-key": "1.3.0", | ||
| "ethers": "5.8.0", | ||
| "ethers": "6.13.5", | ||
| "expo": "56.0.12", |
Context
wallets/rn_cli_walletwas pinned toethers@5.8.0. A prior attempt (0c2a8a9b) upgraded to v6 but bundled it with secure-enclave key storage and was reverted (6945952e). This PR re-does only the ethers v5 → v6 half, keeping the existing MMKV plaintextstorageuntouched.Scope
expo-secure-store/ secure-enclave; storage unchanged.eth_signfor security, andhandleRedirectin the Canton/Tron sign modals.Changes
ethers5.8.0→^6.13.5(resolves 6.17.0); dropped the@ethersproject/pbkdf2yarn patch + resolutions (v6 has no@ethersproject); kept thebip39patch for non-EVM seed derivation.EIP155Lib:HDNodeWallet.fromPhrase,signTypedData,JsonRpcProvider,Wallet | HDNodeWallettyping. Public_signTypedDatawrapper name kept so callers don't change.PaymentTransactionUtil:BigNumber→ nativebigint;StaticJsonRpcProvider→JsonRpcProvider+staticNetwork;getBlock()null-guards.SettingsStore: wrap wallet setters in valtioref()— load-bearing: v6's private#signingKeythrows under valtio's proxy and would corrupt the sharedeip155Walletsinstance.EIP155WalletUtil(Mnemonic.isValidMnemonic),HelperUtil,ERC20BalanceService,EIP155RequestHandlerUtil,PaymentStore; updated thequick-crypto.web.tsshim comment.__tests__/SettingsStore.test.tsregression test for the v6 +ref()interaction.Verification
yarn install— lockfile synced,@ethersproject/pbkdf2fully removed.yarn tsc --noEmit— clean.yarn test— 36/36 pass, incl. the newSettingsStore.test.ts. (App-test.tsxfails onRNBootSplash— pre-existing native-mock issue, unrelated.)Still needs a device (not yet run)
Native/web smoke tests. Clear caches before running (this bit the first revert):
expo start --clear; on Android delete the baked bundle before rebuilding. Then confirm balances load,personal_sign/eth_signTypedData_v4succeed,eth_signis rejected, and a Pay tx goes through.🤖 Generated with Claude Code