Add support for EIP-1193 (and drop legacy Web3 support?)
See original GitHub issueFrom EIP-1193:
ethereum.send(method: String, params?: Array<any>): Promise<any>;
The problem here is that ethers is seeing .send
on the provider and then treating it as having the following signature:
send?: (request: any, callback: (error: any, response: any) => void) => void
when in reality it has this signature (per EIP-1193):
ethereum.send(method: String, params?: Array<any>): Promise<any>;
This of course leads to failure for two reasons:
ethereum.send
expects two parameters,method
andparams
, rather than a single JSON-RPC request object.ethereum.send
returns the result in a promise, and ethers is waiting for the second parameter (callback) to be called (which will never happen).
This is biting me when I try to use my browser-extension provider with a dapp that uses ethers
because ethers calls into my window.ethereum.send
incorrectly and thus the app fails to work with my extension.
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (7 by maintainers)
Top Results From Across the Web
EIP-1193: Ethereum Provider JavaScript API
Summary. A JavaScript Ethereum Provider API for consistency across clients and applications. Abstract. A common convention in the Ethereum ...
Read more >@ethvault/iframe-provider | Yarn - Package Manager
Contact Support at https://www.npmjs.com/support for more info. ... This is an EIP-1193 compliant Ethereum provider that communicates with a parent iframe ...
Read more >Documentation - Ethers.js
For legacy transactions and networks which do not support EIP-1559, the gasPrice ... Web3 Providers (or otherwise compatible) or an EIP-1193 provider.
Read more >Provider Migration Guide - MetaMask Docs
This package is a drop-in replacement for our window.web3 that you can add to your website even before remove window.web3 on all platforms....
Read more >MetaMask Mobile Beta — a feature guide and walkthrough!
Support for this token standard now allows anyone in the world to own Non-Fungible ... EIP-1193: concurrent standard and legacy support ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sorry, forgot to tag the commit https://github.com/ethers-io/ethers.js/commit/56af4413b1dd1787db68985e0b612b63d86fdf7c with this issue.
Now that the EIP-1193 specification is backwards compatible, it is much safer to add EIP-1193 support without breaking anyone in the meantime.
The Web3Provider should now work with all versions of Web3 as well as an EIP-1193 compatible provider. It will favour EIP-1193 using Promises, followed by
sendAsync
andsend
, using the Web3 callback signature.Closing this now, but if anyone has any issues, please re-open or create a new issue.
Thanks! 😃