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

Add methods to support fetching the ENS contenthash and other record types #1003

Closed
moodysalem opened this issue Aug 14, 2020 · 9 comments
Closed
Labels
enhancement New feature or improvement. fixed/complete This Bug is fixed or Enhancement is complete and published.

Comments

@moodysalem
Copy link

Currently there are no methods on the provider to support fetching and decoding contenthash, or other record types.

Specifically I need contenthash, but other methods are welcome

@ricmoo ricmoo added the enhancement New feature or improvement. label Aug 20, 2020
@ricmoo
Copy link
Member

ricmoo commented Aug 20, 2020

I completely agree, this is missing and should be added.

Simple methods, which do not require additional libraries will be added. So, the most common and simple content hashes (IPFS PB-node and Swarm) will be handled. Unsupported content hashes will throw an error.

For those following along at home, this is defined in EIP-1577. :)

@ricmoo ricmoo added the on-deck This Enhancement or Bug is currently being worked on. label Aug 29, 2020
@ricmoo
Copy link
Member

ricmoo commented Aug 29, 2020

I have local changes that support contenthash, text and multi-coin address support. Still needs more testing, but feels good so far. :)

@moodysalem
Copy link
Author

Do these local changes also decode IPNS/IPFS content hashes?

@ricmoo
Copy link
Member

ricmoo commented Aug 29, 2020

It handles IPFS content hashes that use dag-pb formats. Are IPNS encoded CID different? If you have an example ENS name with an IPNS that would be super helpful. :)

I have made it super pessimistic though, so if it hits unsupported data, it will throw. It won't ever return wrong data. :)

@moodysalem
Copy link
Author

moodysalem commented Aug 29, 2020

The three formats we care about in Uniswap interface are:

  • IPFS, e.g. ipfs://Qm..
  • IPNS: ipns://Qm...
  • IPNS + DNSLink: ipns://app.uniswap.org

Our decoding code in the interface is here:
https://github.com/Uniswap/uniswap-interface/blob/master/src/utils/contenthashToUri.ts#L21

And some example ENS names here:
https://github.com/Uniswap/uniswap-interface/blob/master/src/constants/lists.ts#L4

Our tokens.uniswap.eth ENS name points at ipns://tokens.uniswap.org

@ricmoo
Copy link
Member

ricmoo commented Aug 29, 2020

Right, but what about the binary encoding. Currently I only support CID version 1 (0x01) with the DAG-PB (0x70) type. It's more about the interpretation of the bytes.

I certainly do not support currently support IPNS + DNSLink... I've not seen that before... Do you have a link to docs?

I just tried all the ones in that test list and they all appear to by ipfs:// DAG-PB. I think you would need to have one with a type of 0xe5 to specify the identity tag, which would use IPNS. I don't support that right now, because I haven't found any usage of it yet to test against.

As people find unsupported combinations (the CID is quite complex) I'll expand support. However, like the multi-coin support, I only plan to support types that are either wildly popular or require very little additional code. To support all Multicodec formats (the vast majority of which probably do not have a single instance of existence on Earth) would more than double the size of the entire ethers.js library, which I aim to keep lean. :)

I might add the ability to extend the object though. So, for example, if you want ZCash support, you can register your own blake2b implementation. But that's a future idea. :)

I'll try getting it out today. :)

@ricmoo
Copy link
Member

ricmoo commented Sep 5, 2020

This should be available in 5.0.10.

You should be able to use:

const resolver = await provider.getResolver("ricmoo.eth");

// Content hash (supports IPFS and swarm; feel free to provide other examples to support)
const contentHash = await resolver.getContentHash();

// Multicoin support (more will be added as requested; assuming they are standard-is and popular)
const btcAddress = await resolver.getAddress(0);
const dogeAddress = await resolver.getAddress(3);

// Text records
const email = await resolver.getText("email");

Try it out and let me know how it goes. :)

@ricmoo ricmoo added fixed/complete This Bug is fixed or Enhancement is complete and published. and removed on-deck This Enhancement or Bug is currently being worked on. labels Sep 5, 2020
@ricmoo
Copy link
Member

ricmoo commented Sep 12, 2020

Closing this now, but let me know if you have any issues.

Thanks! :)

@ricmoo ricmoo closed this as completed Sep 12, 2020
@wuyuyue
Copy link

wuyuyue commented Oct 11, 2020

use the latest version 5.0.14 in my project which also need support ipns and cointype such as EOS, unfortunately, it is not working or needs some extra handle.
for details : blockchain-tools/ens-web-ext#1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improvement. fixed/complete This Bug is fixed or Enhancement is complete and published.
Projects
None yet
Development

No branches or pull requests

3 participants