Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot read property 'toHexString' of undefined when validating smart contract wallet signature #61

Closed
djnicholson opened this issue Mar 26, 2022 · 5 comments

Comments

@djnicholson
Copy link

djnicholson commented Mar 26, 2022

This code:

  const provider = new ethers.providers.JsonRpcProvider(web3HostUrl);
  const message = new SiweMessage({
        domain,
        address,
        statement,
        uri,
        version: "1",
        chainId,
        expirationTime,
        issuedAt,
        nonce,
      });
  await message.validate(signature, provider);

Throws this exception:

TypeError: Cannot read property 'toHexString' of undefined
    at isHexable (/sample/node_modules/@ethersproject/bytes/src.ts/index.ts:55:21)
    at arrayify (/sample/node_modules/@ethersproject/bytes/src.ts/index.ts:112:9)
    at BytesCoder.DynamicBytesCoder.encode (/sample/node_modules/@ethersproject/abi/src.ts/coders/bytes.ts:17:25)
    at /sample/node_modules/@ethersproject/abi/src.ts/coders/array.ts:62:19
    at Array.forEach (<anonymous>)
    at pack (/sample/node_modules/@ethersproject/abi/src.ts/coders/array.ts:54:12)
    at TupleCoder.encode (/sample/node_modules/@ethersproject/abi/src.ts/coders/tuple.ts:54:20)
    at AbiCoder.encode (/sample/node_modules/@ethersproject/abi/src.ts/abi-coder.ts:112:15)
    at Interface._encodeParams (/sample/node_modules/@ethersproject/abi/src.ts/interface.ts:325:31)
    at Interface.encodeFunctionData (/sample/node_modules/@ethersproject/abi/src.ts/interface.ts:380:18)

Whenever signature was produced by an address other than address (i.e. a smart contract wallet)

Package versions:

"siwe": "^1.1.2",
"ethers": "^5.6.1",
@awoie
Copy link

awoie commented Mar 29, 2022

Just to make sure we are addressing the correct issue here, can you please provide an example of your SIWE message. Our implementation will assume that address is the contract account that validates the signature. Does that work for you?

@djnicholson
Copy link
Author

That should work fine for me, can you let me know when there is an npm release with the fix?

Here is an example SIWE message:

localhost wants you to sign in with your Ethereum account:
0xC36946c342ff98C3196e74C7bEf060b645B7fDB6

Connect? By connecting you agree to our Terms & Conditions and Privacy Policy.

URI: https://localhost
Version: 1
Chain ID: 1
Nonce: 4KMFuhU32gASNmV1d
Issued At: 2022-03-29T18:50:38.407Z
Expiration Time: 2022-03-30T01:50:38.407Z

@w4ll3
Copy link
Member

w4ll3 commented Apr 1, 2022

Hello, #63 addressed this error and is already on main, a release will be made soon.

@djnicholson
Copy link
Author

I tested with version 1.1.6 and the issue is resolved. Thank you.

@w4ll3
Copy link
Member

w4ll3 commented Apr 2, 2022

Great!

@w4ll3 w4ll3 closed this as completed Apr 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants