Closed pablofullana closed 6 years ago
These are the options we thought, ordered by ease of implementation:
Inject both a web3
variable and a niftyWalletWeb3
(or a better name) variable, both pointing to the same object but with different names. Dapps that prefer to use Nifty Wallet can use niftyWalletWeb3
as a provider. Other dapps will use web3
as usual; here we don't know which extension will "win", but if they are compatible it shouldn't matter. Injecting both variables will also allow Nifty Wallet to work with any dapp, even if MetaMask is not installed.
Make dapps check in runtime that Nifty Wallet is active and that MetaMask is not, to make sure that the injected web3
comes from Nifty Wallet. The downside of this is that you can't have both extensions enabled at the same time.
Investigate if there is a mechanism to guarantee that Nifty Wallet code is executed after MetaMask's, so that the last injected web3
is from Nifty Wallet. We are not sure if this is possible and, even if it is, it may be browser-dependent.
The first option is what I had in mind. Everyone who wants to build DApp and use NiftyWallet
just needs to choose injected another web3
object name to pass all transactions through niftyWallet
.
The side-effect of it, that DApp developer should change the way, how web3 object is chosen.
We could show an example in README of how to modify choosing of web3
object in DApp to support all cases:
Given that MetaMask doesn't inject web3
if web3
is already defined.
https://github.com/poanetwork/metamask-extension/blob/db4469794e3e843f3cb08222d0a9b568c7816a85/app/scripts/inpage.js#L29-L35
An option is to remove that behavior on Nifty Wallet. So:
- If MetaMask loads first, injects web3 but later Nifty wallet overrides it.
- If Nifty loads first, injects web3, then MetaMaks will detect it and do nothing.
The good thing about this solution is that it doesn't require any change on DApps, they will just use web3
. The downside is that we are forcing to use Nifty Wallet over MetaMask on every DApp if both are installed.
This is the cleanest solution imo and it’s arguable that force use of Nifty over MM is downside.
Ideally users would use Nifty as default plugin.
Some users will switch to nifty. Users that prefer to use MM can log out of Nifty.
How can i vote twice for this? :)
On Tue, 17 Jul 2018 at 18:21, Gerardo Nardelli notifications@github.com wrote:
Given that MetaMask doesn't inject web3 if web3 is already defined.
https://github.com/poanetwork/metamask-extension/blob/db4469794e3e843f3cb08222d0a9b568c7816a85/app/scripts/inpage.js#L29-L35 An option is to remove that behavior on Nifty Wallet. So:
- If MetaMask loads first, injects web3 but later Nifty wallet overrides it.
- If Nifty loads first, injects web3, then MetaMaks will detect it and do nothing.
The good thing about this solution is that it doesn't require any change on DApps, they will just use web3. The downside is that we are forcing to use Nifty Wallet over MetaMask on every DApp if both are installed.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/poanetwork/metamask-extension/issues/1#issuecomment-405660060, or mute the thread https://github.com/notifications/unsubscribe-auth/Ah-f6PS9Zt0m9z5oqxrxdKqT8b8qjjfLks5uHh0BgaJpZM4VSuOR .
@patitonar good find! Let's use your approach
Option 1 above seems to make most sense: Inject both a web3 variable and a niftyWalletWeb3 (or a better name) variable, both pointing to the same object but with different names. Injecting both variables will also allow Nifty Wallet to work with any dapp, even if MetaMask is not installed.
This also allows DApps to enable special options for Nifty Wallet Users.
@vbaranov please comment here