diff --git a/.changeset/poor-beans-dream.md b/.changeset/poor-beans-dream.md new file mode 100644 index 000000000..b78be7966 --- /dev/null +++ b/.changeset/poor-beans-dream.md @@ -0,0 +1,5 @@ +--- +'@ant-design/web3-wagmi': patch +--- + +fix: add custom configured chains in chainAssets diff --git a/packages/wagmi/src/wagmi-provider/__tests__/custom-config.test.tsx b/packages/wagmi/src/wagmi-provider/__tests__/custom-config.test.tsx index 774d033e7..61fd266cb 100644 --- a/packages/wagmi/src/wagmi-provider/__tests__/custom-config.test.tsx +++ b/packages/wagmi/src/wagmi-provider/__tests__/custom-config.test.tsx @@ -145,7 +145,7 @@ describe('WagmiWeb3ConfigProvider config', () => { ); const { baseElement } = render(); - expect(baseElement.querySelector('.chains-name')?.textContent).toBe('Ethereum'); + expect(baseElement.querySelector('.chains-name')?.textContent).toBe('Polygon,Goerli,Ethereum'); }); it('avaliable chains with assets', () => { @@ -186,7 +186,9 @@ describe('WagmiWeb3ConfigProvider config', () => { ); const { baseElement } = render(); - expect(baseElement.querySelector('.chains-name')?.textContent).toBe('Polygon,Ethereum,Base'); + expect(baseElement.querySelector('.chains-name')?.textContent).toBe( + 'Polygon,Ethereum,Base,Goerli', + ); }); it('empty connectors', () => { diff --git a/packages/wagmi/src/wagmi-provider/index.tsx b/packages/wagmi/src/wagmi-provider/index.tsx index 155acd676..d04cd0383 100644 --- a/packages/wagmi/src/wagmi-provider/index.tsx +++ b/packages/wagmi/src/wagmi-provider/index.tsx @@ -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];