getConnections() possibly get two connections, but just link metamask browser extension
JJLau626 opened this issue · comments
Describe the bug
if i use the injected and target function to open target metamask extension, it maybe get two connections , so i can't disconnect in once. but OKEX wallet will not reproduce this problem.
when i reload the page and use getConnections() , it turns in normal .
Link to Minimal Reproducible Example
No response
Steps To Reproduce
use this following code and will possibly get two connections . so i have to use twice disconnect() to disconnect it
am this code right?
async function handleLinkMetamask() {
console.log('click handleLinkMetamask');
const targetConnector = 'MetaMask'
const connectors = await getConnectors(config)
console.log({ connectors });
await connect(config, {
connector: injected({
target() {
return {
id: 'io.metamask',
name: 'MetaMask',
provider: async () => {
console.log('handleLinkMetamask target provider');
const connectors = getConnectors(config)
console.log('handleLinkMetamask', connectors);
const provider = await connectors.find(item => item.name === targetConnector)?.getProvider()
console.log('handleLinkMetamask provider', provider);
return provider
}
}
}
})
})
}
function handleGetConnections() {
const connections = getConnections(config)
// possibly there are two connections
console.log('connections', connections);
}
Wagmi Version
2.7.0
Viem Version
2.9.28
TypeScript Version
5.4.0
Check existing issues
- I checked there isn't already an issue for the bug I encountered.
Anything else?
No response
Hello @JJLau626. Please provide a minimal reproduction using new.wagmi.sh for runtime issues or TypeScript Playground for type issues. Issues marked with "needs reproduction" will be closed if they have no activity within 3 days.
This issue has been locked since it has been closed for more than 14 days.
If you found a concrete bug or regression related to it, please open a new bug report with a reproduction against the latest wagmi version. If you have any other comments you can create a new discussion.