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

ENS: throws error when no resolver contract set #2656

Closed
darrenlangley opened this issue Apr 6, 2019 · 1 comment
Closed

ENS: throws error when no resolver contract set #2656

darrenlangley opened this issue Apr 6, 2019 · 1 comment

Comments

@darrenlangley
Copy link

Description

When querying an ENS name, it is possible that a resolver contract is not set (0x0). Web3 throws an unspecific error message when no resolver is set.

Expected behavior

const address = await web3.eth.ens.getAddress(ensNameWithoutResolver);
expect(address).toEqual('0x0');

There are two options for expected behaviour:

  • returns 0x0 address when no resolver set
  • throws specific error message "No resolver set"

There are pros/cons of both. Personally, I feel it should return 0x0 because the address doesn't exist and it makes the call more intuitive to use.

Actual behavior

const address = await web3.eth.ens.getAddress(ensNameWithoutResolver); // throws error

Steps to reproduce the behavior

(async () => {
  const Web3 = require('web3');
  const web3 = new Web3('https://mainnet.infura.io/v3/b0444015b0c64183a7dbea5d183661b5');
  const address = await web3.eth.ens.getAddress('ipledger.eth');
})();

Error Logs

(node:31248) UnhandledPromiseRejectionWarning: Error: Invalid bytes string given: 0x
    at AbiCoder.decodeParameters (/home/langers/Source/kauri-io/enslookup/node_modules/web3-eth-abi/dist/web3-eth-abi.cjs.js:64:15)
    at AbiCoder.decodeParameter (/home/langers/Source/kauri-io/enslookup/node_modules/web3-eth-abi/dist/web3-eth-abi.cjs.js:55:19)

Versions

  • web3.js: 1.0.0-beta.50
  • nodejs: v10.15.3

Happy to raise a PR - just let me know what is the preferred expected behaviour.

@nivida
Copy link
Contributor

nivida commented Apr 6, 2019

This got fixed with beta.52 :)

@nivida nivida closed this as completed Apr 6, 2019
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

2 participants