Unknown Account
See original GitHub issueEnvironment Metamask Mobile -> v0.2.19 Ethers -> 5.0.5
Remote debugged with Chrome DevTools This issue do not happen on Firefox and Chrome desktop. It occurs only on Metamask Mobile.
1 - Ethers is loaded dynamically :
Loaded $:/ipfs/library/ethers:
https://cdn.jsdelivr.net/npm/ethers@5.0.5/dist/ethers.umd.min.js
2 - Ethers is instantiated with the metamask provider and the getAccount trick The account is properly retrieved
// https://github.com/ethers-io/ethers.js/issues/433
const account = await this.getAccount(provider)
const web3 = new root.ethers.providers.Web3Provider(provider, 'any')
I use the ‘any’ parameter as advised here: https://github.com/ethers-io/ethers.js/issues/899 I didn’t do this test without this parameter though.
3 - Here is the code who crashes
const abi = ['function setContenthash(bytes32 node, bytes calldata hash)']
const iface = new window.ethers.utils.Interface(abi)
const data = iface.encodeFunctionData('setContenthash', [
domainHash,
encoded
])
const signer = web3.getSigner()
const tx = await signer.sendTransaction({ to: resolver, data: data })
await tx.wait()
Report:
1 - Ethers generates an exception :
Error: unknown account #0 (operation="getAddress", code=UNSUPPORTED_OPERATION, version=providers/5.0.4)
Minor remark -> the signature is still the 5.0.4 and not the 5.0.5
2 - Metamask Mobile generates as well an exception:
VM13:8 MetaMask: 'eth_accounts' unexpectedly updated accounts. Please report this bug.
Workaround :
const signer = web3.getSigner(account)
When I explicitly set the account while retrieving the signer both exceptions are gone.
Thanks
Issue Analytics
- State:
- Created 3 years ago
- Comments:13 (5 by maintainers)
Top GitHub Comments
This does work though
If the wallet.address isnt provided then it tries to use getAddress on account 0 on the provider youre using.
1 - I work around the issue when requesting a signer with an explicit selected account instead of the implicit selected account
provider.getSigner(account)
vsprovider.getSigner()
2 - Metamask Mobile issued several releases in the mean time. I will do some testing to verify if the problem remains
Thanks for your support