Skip to content

Commit b39249e

Browse files
authored
fix: save chainId on chainChanged event without formatting (#297)
* fix: save chainId on chainChanged event without formatting * docs: add changelog
1 parent 4c55e0a commit b39249e

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

.changeset/curvy-phones-agree.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@web3-ui/hooks": patch
3+
---
4+
5+
closes #273
6+
fix: save chainId on chainChanged event without formatting

packages/hooks/src/Provider.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export const Provider: React.FC<ProviderProps> = ({
119119
setConnected(true);
120120

121121
connection.on('chainChanged', async (newChainId: string) => {
122-
const formattedChainId = +newChainId.split('0x')[1];
122+
const formattedChainId = +newChainId;
123123
setChainId(formattedChainId);
124124
setCorrectNetwork(formattedChainId === network);
125125
const provider = new ethers.providers.Web3Provider(connection);

0 commit comments

Comments
 (0)