Skip to content

Commit

Permalink
Update for Metmask new EIP6963 support
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastienGllmt committed Jan 12, 2024
1 parent 8d06db9 commit ca8b58e
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions packages/paima-sdk/paima-providers/src/evm/injected.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,17 +126,6 @@ export class EvmInjectedConnector implements IConnector<EvmApi> {
allWallets.push(...eip5749Options);
}

// Metamask doesn't support EIP6963 yet, but it plans to. In the meantime, we add it manually
if (windowObj.ethereum != null && windowObj.ethereum.isMetaMask) {
const ethereum = windowObj.ethereum;
allWallets.push({
metadata: {
name: 'metamask',
displayName: 'MetaMask',
},
api: () => Promise.resolve(ethereum),
});
}
// some wallets aggressively put themselves in the list of wallets the user has installed
// even if the user has never actually used these
// we put these wallets at the bottom of the priority
Expand Down Expand Up @@ -209,8 +198,11 @@ export class EvmInjectedConnector implements IConnector<EvmApi> {
return this.provider;
}

// the eip6963 name for Metamask is io.metamask
// but we want to keep simply "metamask" working for backwards compatibility with older versions of Paima
const adjustedName = name === 'metamask' ? 'io.metamask' : name;
const provider = EvmInjectedConnector.getPossiblyDuplicateWalletOptions().find(
entry => entry.metadata.name === name
entry => entry.metadata.name === adjustedName
);
if (provider == null) {
throw new WalletNotFound(`EVM wallet ${name} not found`);
Expand Down

0 comments on commit ca8b58e

Please sign in to comment.