xf00f / web3x

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

eth.personal.sign() + Metamask error #51

Closed ondratra closed 5 years ago

ondratra commented 5 years ago

Hello, I have possibly discovered error in web3x. I am using Metamask 6.6.1 and web3x 3.0.11. When I tried to sign a message via

const userAddress = Address.fromString('0x123...')
const eth = Eth.fromCurrentProvider()
const personal = new Personal(eth.provider)

const signature = await personal.sign('a2000ab', userAddress, '')

I got error MetaMask - RPC Error: TypeError: e.toLowerCase is not a function, that happened inside of metamask. After some debugging I found that it works when i convert address to lowercased string like this:

const signature = await personal.sign('a2000ab', <any> userAddress.toString().toLowerCase(), '')

I assume function sign() is missing this conversion to lowercase string. I could create pull request for this but I am not sure that wouldn't break other combination of Metamask + web3x versions. @xf00f can you have look at this, please?

xf00f commented 5 years ago

This should be fixed in release v4.0.0.

ondratra commented 5 years ago

I can confirm it is fixed. Thx.