Commit fae30fca authored by tom goriunov's avatar tom goriunov Committed by GitHub

Merge pull request #1138 from jasonzysun/main

fix error in args of wallet_addEthereumChain request
parents e9a45f37 3eca473f
...@@ -27,26 +27,23 @@ export default function useAddOrSwitchChain() { ...@@ -27,26 +27,23 @@ export default function useAddOrSwitchChain() {
// This error code indicates that the chain has not been added to Wallet. // This error code indicates that the chain has not been added to Wallet.
if (code === 4902) { if (code === 4902) {
const params = { const params = [ {
method: 'wallet_addEthereumChain', chainId: hexadecimalChainId,
params: [ { chainName: config.chain.name,
chainId: hexadecimalChainId, nativeCurrency: {
chainName: config.chain.name, name: config.chain.currency.name,
nativeCurrency: { symbol: config.chain.currency.symbol,
name: config.chain.currency.name, decimals: config.chain.currency.decimals,
symbol: config.chain.currency.symbol, },
decimals: config.chain.currency.decimals, rpcUrls: [ config.chain.rpcUrl ],
}, blockExplorerUrls: [ config.app.baseUrl ],
rpcUrls: [ config.chain.rpcUrl ], } ] as never;
blockExplorerUrls: [ config.app.baseUrl ], // in wagmi types for wallet_addEthereumChain method is not provided
} ], // eslint-disable-next-line @typescript-eslint/no-explicit-any
// in wagmi types for wallet_addEthereumChain method is not provided
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any;
return await provider.request({ return await provider.request({
method: 'wallet_addEthereumChain', method: 'wallet_addEthereumChain',
params, params: params,
}); });
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment