question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add support for EIP-1193 (and drop legacy Web3 support?)

See original GitHub issue

https://github.com/ethers-io/ethers.js/blob/76a8e503dd47b8da1961fb85a6ca28d007f49585/src.ts/providers/web3-provider.ts#L36-L47

From 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:

  1. ethereum.send expects two parameters, method and params, rather than a single JSON-RPC request object.
  2. 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:closed
  • Created 4 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
ricmoocommented, Apr 28, 2020

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 and send, using the Web3 callback signature.

0reactions
ricmoocommented, Apr 28, 2020

Closing this now, but if anyone has any issues, please re-open or create a new issue.

Thanks! 😃

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found