Skip to content
This repository has been archived by the owner on Sep 28, 2022. It is now read-only.

Don't have a hard dependency on selectedAddress. #262

Open
MicahZoltu opened this issue Feb 11, 2021 · 0 comments
Open

Don't have a hard dependency on selectedAddress. #262

MicahZoltu opened this issue Feb 11, 2021 · 0 comments

Comments

@MicahZoltu
Copy link

function getSelectedAddress() {
return typeof window.ethereum !== 'undefined'
? window.ethereum.selectedAddress
: window.web3.eth.defaultAccount;
}

I don't believe selectedAddress isn't a standardized property on window.ethereum. While it may exist in MetaMask, there is no guarantee that it exists on any other wallet. Recommend having a fallback to the result of wallet_requestAccounts or eth_coinbase or eth_accounts. Currently, if the connect wallet doesn't have a selectedAddress property on window.ethereum the console gets spammed with Uncaught (in promise) TypeError: Cannot read property 'toLowerCase' of undefined because this function always returns undefined.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant