simolus3 / web3dart

Ethereum library, written in Dart.
MIT License
442 stars 270 forks source link

isConnected to dApp browsers like metamask #186

Closed HosseinAsadi closed 2 years ago

HosseinAsadi commented 2 years ago

Hi there

I want to check that my pwa dapp is connect to any dApp browsers like metamask or not

so i have below code

final eth = window.ethereum; if (eth != null) eth!.isConnected();

but this always return true!!

do you have suggestion for me?

simolus3 commented 2 years ago

Good catch, I've fixed this in 3adef15efab8a860126e19f91ed408f449c9c8e2.

HosseinAsadi commented 2 years ago

I am using the latest version but it still returns true! :(

web3dart 2.1.4

simolus3 commented 2 years ago

I've just published version 2.2.0 which contains the fix.

HosseinAsadi commented 2 years ago

thank you so much

HosseinAsadi commented 2 years ago

Hi there

I want to check that my pwa dapp is connect to any dApp browsers like metamask or not

so i have below code

final eth = window.ethereum; if (eth != null) eth!.isConnected();

but this always return true!!

do you have suggestion for me?

It still is!! @simolus3

simolus3 commented 2 years ago

I can't reproduce this. We have this example: https://github.com/simolus3/web3dart/blob/4edbfd797bed74dd70333cb7de60388bc9b45b1e/example/metamask/web/main.dart#L9-L13

When I run dart pub global webdev serve, it prints "MetaMask is not available" in a browser without metamask and opens the pop-up for browsers that have the plugin installed.

HosseinAsadi commented 2 years ago

no no I did not mean that!

if (eth != null) eth!.isConnected();

isConnected()

What is the task of this?

because this function always return true with eth != null !!

In fact, I want to check to see do my dApp is connect to the metamask or not

for example if not connect, I call eth!.requestAccount();

@simolus3