Skip to content

Commit

Permalink
fix: incorrect chains error log (#1278)
Browse files Browse the repository at this point in the history
* fix: incorrect chains error log

* docs: incorrect chains error log

* fix: add custom configured chains in chainAssets

* fix: delete redundant changelog

* test(wagmi-provider): update chain names in test assertions
  • Loading branch information
Wecle authored Dec 11, 2024
1 parent 020b483 commit 250e74e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/poor-beans-dream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@ant-design/web3-wagmi': patch
---

fix: add custom configured chains in chainAssets
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ describe('WagmiWeb3ConfigProvider config', () => {
</WagmiWeb3ConfigProvider>
);
const { baseElement } = render(<App />);
expect(baseElement.querySelector('.chains-name')?.textContent).toBe('Ethereum');
expect(baseElement.querySelector('.chains-name')?.textContent).toBe('Polygon,Goerli,Ethereum');
});

it('avaliable chains with assets', () => {
Expand Down Expand Up @@ -186,7 +186,9 @@ describe('WagmiWeb3ConfigProvider config', () => {
</WagmiWeb3ConfigProvider>
);
const { baseElement } = render(<App />);
expect(baseElement.querySelector('.chains-name')?.textContent).toBe('Polygon,Ethereum,Base');
expect(baseElement.querySelector('.chains-name')?.textContent).toBe(
'Polygon,Ethereum,Base,Goerli',
);
});

it('empty connectors', () => {
Expand Down
10 changes: 9 additions & 1 deletion packages/wagmi/src/wagmi-provider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,15 @@ export function WagmiWeb3ConfigProvider({
// When user custom config, add Mainnet by default
// When user not provide config, auto generate config, chains use user provided chains
const chainAssets: ChainAssetWithWagmiChain[] = config
? [Mainnet, ...chains]
? [
Mainnet,
...chains,
...config.chains.map((chain) => ({
id: chain.id,
name: chain.name,
wagmiChain: chain,
})),
]
: chains?.length
? chains
: [Mainnet];
Expand Down

0 comments on commit 250e74e

Please sign in to comment.