-
Notifications
You must be signed in to change notification settings - Fork 90
Open
Description
Overview
Currently, we detect ethereum providers with @metamask/detect-provider package.
However, there are two issues with this:
- The published npm package isn't up-to-date with the latest source, see npm package is not up to date MetaMask/detect-provider#49. This forces us to use a hacky cast to type things correctly:
hdwallet/packages/hdwallet-metamask/src/adapter.ts
Lines 24 to 25 in fe03120
// TODO: remove casting, @metamask/detect-provider npm package hasn't been published with latest typings // https://github.com/MetaMask/detect-provider/blame/5ce916fc24779c4b36741531a41d9c8b3cbb0a17/src/index.ts#L37 - The logic of the detection is basically "is metamask / is any other provider" with the
mustBeMetamaskoption. While this works perfectly in the context of detecting exactly metamask, this doesn't narrow down other providers, not gives us guarantees that the provider we get is really the provider we want. Which again, makes us use some copypasta detection utils to detect and narrow down the specific provider
We should patch detectEthereumProvider so that it correctly detects MM/XDEFI/Tally, and narrows down the returned provider type.
References and additional details
| private async detectTallyProvider(): Promise<TallyHoEthereumProvider | null> { |
| const provider: any = await detectEthereumProvider({ mustBeMetaMask: true, silent: false, timeout: 3000 }); |
| const provider: any = (globalThis as any).xfi?.ethereum; |
Acceptance Criteria
detectEthereumProvideris patched with the latest source changesdetectEthereumProviderdetects, returns and narrows down the types of MetaMask, XDEFI and Tally providersdetectTallyProviderand its calls are removed and the patcheddetectEthereumProvideris used instead(globalThis as any).xfi?.ethereum;is replaced by a call to the patcheddetectEthereumProvider
Need By Date
No response
Screenshots/Mockups
No response
Estimated effort
3 hours
Metadata
Metadata
Assignees
Labels
No labels