Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: incorrect chains error log #1278

Merged
merged 5 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading