AccountMetamaskFactory not compatible with Superhero Wallet
I am having a problem connecting with MM snap.
When the Superhero wallet is present,
new AccountMetamaskFactory()does not return the MetaMask provider. Therefore, the.installSnap()method does nothing, and the app hangs.I previously reported to the SH wallet team about SH conflicting with MM. They made some changes to resolve the issue, but now Snap is not working. I think they are overriding MM provider.. Is it possible to make sure
AccountMetamaskFactoryreturns MM provider?![]()
Originally posted by @yusufseyrek in #2037
related bug on Superhero Wallet side: https://github.com/superhero-com/superhero-wallet/issues/3509
another necessary fix: https://github.com/aeternity/aepp-sdk-js/pull/2050
After resolving the above, I expect this will work out of the box. Meanwhile, you need to manually detect MetaMask provider and give it to AccountMetamaskFactory.
setTimeout(() => window.dispatchEvent(new Event('eip6963:requestProvider')));
const provider = await new Promise((resolve) => {
const handler = (event) => {
if (event.detail.info.rdns !== 'io.metamask') return;
window.removeEventListener('eip6963:announceProvider', handler);
resolve(event.detail.provider);
};
window.addEventListener('eip6963:announceProvider', handler);
setTimeout(() => {
window.removeEventListener('eip6963:announceProvider', handler);
resolve(undefined);
}, 500);
});
if (provider == null) throw new Error('MetaMask not found');
const factory = new AccountMetamaskFactory(provider);
based on guide: https://docs.metamask.io/snaps/how-to/connect-to-a-snap/
related issue: https://github.com/superhero-com/superhero-wallet/issues/3451