Skip to content

Fix: correction for how providers and accounts get created when the chain changes#18

Merged
krishan711 merged 5 commits into
mainfrom
fixchainacc
Jan 20, 2026
Merged

Fix: correction for how providers and accounts get created when the chain changes#18
krishan711 merged 5 commits into
mainfrom
fixchainacc

Conversation

@krishan711
Copy link
Copy Markdown
Contributor

Description

Screenshots:

Checklist:

  • I have updated the CHANGELOG with a summary of my changes
  • I have updated the documentation accordingly

Copilot AI review requested due to automatic review settings January 20, 2026 21:49
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes an issue with provider and account recreation when the blockchain network changes in a Web3 React application. The fix addresses an ethers.js v6 limitation where providers throw errors if used after the network has changed.

Changes:

  • Updated the web3 provider creation logic to depend on web3ChainId, ensuring the provider is recreated when the chain changes
  • Removed redundant loadWeb3Accounts() call from onChainChanged callback to rely on the useEffect trigger instead
  • Added extensive console.log debugging statements throughout the codebase
  • Updated dependencies including ethers, @base-org/account, React types, and build tools

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 4 comments.

File Description
src/Web3AccountContext.tsx Core fix: Added web3ChainId dependency to web3 provider useMemo and removed redundant loadWeb3Accounts call; added debug logging
src/useWeb3Transaction.ts Added console.log statements for transaction debugging
package.json Updated dependencies: ethers (6.15.0→6.16.0), @base-org/account (2.3.1→2.5.1), React types, and build tools
Comments suppressed due to low confidence (2)

src/Web3AccountContext.tsx:298

  • Console.log statements should be removed before merging to production. These debugging statements will add unnecessary noise to the browser console in production environments.
      throw new Error('No web3 provider available to switch chain');

src/Web3AccountContext.tsx:327

  • Console.log statements should be removed before merging to production. These debugging statements will add unnecessary noise to the browser console in production environments.
    }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Web3AccountContext.tsx Outdated
Comment thread src/Web3AccountContext.tsx Outdated
Comment thread src/Web3AccountContext.tsx Outdated
Comment thread src/Web3AccountContext.tsx Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 3 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@krishan711 krishan711 merged commit 5dd3b96 into main Jan 20, 2026
3 checks passed
@krishan711 krishan711 deleted the fixchainacc branch January 20, 2026 22:01
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.

2 participants