Incompatible types `MetaMaskInpageProvider` and `ethers.providers.Web3Provider()`
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 30/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- typescript
- Domain
- api
Research direction
No source file or test is named. Start by reviewing the provider type definitions and the external-provider interface expected by ethers, then determine whether the incompatibility can be addressed in this package. Done would require a compatible public type or a documented conclusion that the change belongs in ethers.
Written by the indexing model from the issue text.
Description
Hello, I installed the typings for Metamask provider from this @metamask/providers package. Since we allow multiple providers to be used, we wrap the provider into standardized Web3Provider from ethers package. However, I am unable to pass the MetaMaskInpageProvider to Web3Provider constructor like this:
import { ethers } from 'ethers'
import type { MetaMaskInpageProvider } from '@metamask/providers'
const setWalletProvider = async (newWalletProvider: MetaMaskInpageProvider): Promise<void> => {
walletProvider.value = new ethers.providers.Web3Provider(newWalletProvider) // this throws
}
Error is following:
Argument of type 'MetaMaskInpageProvider' is not assignable to parameter of type 'ExternalProvider | JsonRpcFetchFunc'.
Type 'MetaMaskInpageProvider' is not assignable to type 'ExternalProvider'.
Types of property 'sendAsync' are incompatible.
Type '(payload: JsonRpcRequest<unknown>, callback: (error: Error, result?: JsonRpcResponse<unknown>) => void) => void' is not assignable to type '(request: { method: string; params?: any[]; }, callback: (error: any, response: any) => void) => void'.
Types of parameters 'payload' and 'request' are incompatible.
Type '{ method: string; params?: any[]; }' is missing the following properties from type 'JsonRpcRequest<unknown>': jsonrpc, id
I can easily surpress the error by @ts-ignore, but do you think it would be possible to make the MetaMaskInpageProvider compatible with the ethers.providers.Web3Provider? Or should I rather post an issue to the ethers? Thanks!
- Dominant language
- TypeScript
- Stars
- 268
- Forks
- 130
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from MetaMask/providers
-
Difficulty 4/5 3-5 days Newbie friendliness 38/100
-
Difficulty 4/5 3-5 days Newbie friendliness 42/100
-
Difficulty 3/5 1-2 days Newbie friendliness 25/100
-
Difficulty 1/5 Under an hour Newbie friendliness 58/100
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
All issues in MetaMask/providers
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
fullcalendar/fullcalendar#8106 ·