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

Passing a number where a contract expects an address produces a bad error message #364

Closed
ldct opened this issue Dec 5, 2018 · 6 comments
Labels
enhancement New feature or improvement.

Comments

@ldct
Copy link

ldct commented Dec 5, 2018

     TypeError: name.toLowerCase is not a function
      at Object.namehash (/Users/xuanji/gits/cf/monorepo/node_modules/ethers/utils/hash.js:11:17)
      at Web3Provider.BaseProvider.resolveName (/Users/xuanji/gits/cf/monorepo/node_modules/ethers/providers/base-provider.js:1015:31)
      at resolveAddresses (/Users/xuanji/gits/cf/monorepo/node_modules/ethers/contract.js:83:25)
      at /Users/xuanji/gits/cf/monorepo/node_modules/ethers/contract.js:78:29
      at Array.forEach (<anonymous>)
      at resolveAddresses (/Users/xuanji/gits/cf/monorepo/node_modules/ethers/contract.js:70:19)
      at Object.delegateTarget (/Users/xuanji/gits/cf/monorepo/node_modules/ethers/contract.js:142:16)
@ricmoo
Copy link
Member

ricmoo commented Dec 5, 2018

Can you provide some context? What code is causing this.

@ldct
Copy link
Author

ldct commented Dec 5, 2018

function delegateTarget(
  address registryAddr
)
  public
{
  require(registryAddr == address(0));
}

javascript:

await contract.functions.delegateTarget(0);

where contract: ethers.Contract

@ricmoo
Copy link
Member

ricmoo commented Dec 5, 2018

The number 0 is not a valid Ethereum address; addresses must be a valid string (either a hex string or IBAN). You likely want something more like:

await contract.functions.delegateTarget(ethers.constants.AddressZero);

@ricmoo ricmoo added the discussion Questions, feedback and general information. label Dec 5, 2018
@ricmoo
Copy link
Member

ricmoo commented Dec 5, 2018

Oh. You just want a better error message?

@ldct
Copy link
Author

ldct commented Dec 5, 2018 via email

@ricmoo ricmoo added enhancement New feature or improvement. on-deck This Enhancement or Bug is currently being worked on. and removed discussion Questions, feedback and general information. labels Dec 14, 2018
@ricmoo
Copy link
Member

ricmoo commented Dec 14, 2018

The error is now "invalid address" :)

Thanks! :)

@ricmoo ricmoo closed this as completed Dec 14, 2018
@ricmoo ricmoo removed the on-deck This Enhancement or Bug is currently being worked on. label Dec 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improvement.
Projects
None yet
Development

No branches or pull requests

2 participants