wevm / mipd

TypeScript Utilities for EIP-6963: Multi Injected Provider Discovery
MIT License
100 stars 13 forks source link

finding providers "conditionally" or by "priority" #12

Closed pseudobun closed 10 months ago

pseudobun commented 10 months ago

I think it would be nice to have the ability in findProvider method:

findProvider({ rdns }) {
  return providerDetails.find(
    (providerDetail) => providerDetail.info.rdns === rdns,
  )
},

that would allow us to search for providers by "priority" or "conditionally".

I would suggest something like this:

const provider = store.findProvider({
  rdns: 'io.metamask' || 'io.metamask.mmi' || 'io.metamask.flask' || 'com.enkrypt'
});

This way the dapps would be able to pick their "preferred" provider which in some cases would be great to have. E.g. we are developing a MetaMask Snap and therefore our preferred wallet is MetaMask since others don't even support Snaps.

Thanks for reply!

jxom commented 10 months ago

You can do this manually right now:

const providers = store.getProviders()
const provider = providers.find(provider => provider.info.rdns === 'io.metamask' || 'io.metamask.mmi' || 'io.metamask.flask' || 'com.enkrypt')