paritytech / parity-extension

Parity Chrome Extension
GNU General Public License v3.0
37 stars 14 forks source link

Possibility to detect if injected provider is Parity #119

Open schmidsi opened 6 years ago

schmidsi commented 6 years ago

As I understand and reverse engineered, this extension injects two objects into the window scope: web3 and ethereumProvider.

Both provide some functionality to use them later with:

import Api from '@parity/api';
const api = new Api(ethereumProvider);

But since we need some parity specific features, I would like to know if these injected objects are actually from parity and not from MetaMask.

Inside parity dapps (http://127.0.0.1:8180/) the injected objects are: web3 and ethereum (note this time without the "Provider"-suffix), whereas the ethereum object has a isParity method.

Furthermore it would be nice if both injecting mechanisms inject the same stuff.