xf00f / web3x

Ethereum TypeScript Client Library - for perfect types and tiny builds.
211 stars 27 forks source link

Unclear how to unlock when required. #50

Closed hickscorp closed 5 years ago

hickscorp commented 5 years ago

When using recent versions of Metamask, it's not clear how Web3x can be used to retrieve the address of the default account.

Using window.ethereum.enable() shows the Metamask authorization popup - how is this taken care of by Web3x?

ondratra commented 5 years ago

Hello, I think web3x is not handling this at all. window.ethereum is possible provider that you can pass to Eth object constructor e.g. const eth = new Eth(window.ethereum). You should request access by calling window.ethereum.enable() manually before you need to use web3 for the first time.

xf00f commented 5 years ago

As discussed above, it is currently the users responsibility to unlock MetaMask.

Can someone enlighten me if window.ethereum.enable() is covered by an EIP? If so I could support it in Eth.fromCurrentProvider(). If it's a MetaMask specific I won't support it and will leave it to the developer to make the call.

I looked into supporting this already, but found oddly that the current latest release of MetaMask (6.6.2) returns an invalid response from window.ethereum.send() and as such web3x continues to support the old window.web3.currentProvider in an adapter. The example @ondratra gave above with 6.6.2 did not work for me as the response is the entire jsonrpc object instead of just the result.

If development versions of MetaMask are working properly, I'll still hold off until a formal release before supporting in web3x.

alcuadrado commented 5 years ago

Can someone enlighten me if window.ethereum.enable() is covered by an EIP? If so I could support it in Eth.fromCurrentProvider(). If it's a MetaMask specific I won't support it and will leave it to the developer to make the call.

I'm pretty sure it's not standard. It's not included in EIP1102 nor EIP1193.

xf00f commented 5 years ago

Thanks. Closing for now.