-
Notifications
You must be signed in to change notification settings - Fork 795
Add ENS avatar and TXT records resolution #889
Conversation
As well as arbitrary fields.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have an idea on how to split up the ERC-721/1155 code nicely?
few nits and suggestions, can improve once addressed.
Would it be preferable to use an Option in the return type of resolve_avatar?
how would this manifest itself in the response? statuscode? failed decoded?
Is there a configuration system in place right now to be able to modify the IPFS HTTP gateway?
think this is fixed to ipfs.io?
ethers-providers/src/lib.rs
Outdated
async fn resolve_avatar(&self, ens_name: &str) -> Result<Url, Self::Error> { | ||
self.inner().resolve_avatar(ens_name).await.map_err(FromErr::from) | ||
} | ||
|
||
async fn resolve_field(&self, ens_name: &str, field: &str) -> Result<String, Self::Error> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please document these trait functions, or link to the matching functions, that are document.
ethers-providers/src/provider.rs
Outdated
} | ||
[0xc8, 0x7b, 0x56, 0xdd] | ||
} | ||
"erc1155" => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if possible, we should make them 2 separate functions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
307bdcc adds a ERCToken
type and another method to resolve a token. Not sure about how future this is though 🤔
I was thinking of scenarios like: unsupported scheme, or invalid ownership. They're not necessarily errors -- but I don't think it matters too much considering I'm mostly using the opaque
Anyone can deploy a gateway, another big one is Cloudflare's. So someone could want to use a different one (e.g. private one, or if ipfs.io is down). But I really don't think it's that important for now. |
Oh and also, I'm curious why |
we use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
thanks!
needs nightly fmt
ethers-providers/src/provider.rs
Outdated
/// if not configured) | ||
/// | ||
/// # Example | ||
/// ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's do no_run here
/// ``` | |
/// ```no_run |
ethers-providers/src/provider.rs
Outdated
/// Returns the URL (not necesserily HTTP) of the image behind a token. | ||
/// | ||
/// # Example | ||
/// ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// ``` | |
/// ```no_run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice work!
Tests seem to be failing here, any clue why? Maybe the IPFS path changed?
|
Indeed, hopefully the new one won't change for a while |
This PR adds support for resolution of text records and also adds a helper to resolve avatars and validate them (as well as provide a HTTP link to make it easier for the user). This is mostly a translation of
ethers.js
implementation.I am not terribly happy with the current interface and place in the code, so I'm hoping you have an opinion on the matter.
Motivation
We simply need to resolve records and specifically avatars of ENS domains.
Solution
TXT records can be resolved using
resolve_field
(I have encountered both the terms "record" and "field", which isn't great), and theavatar
record can also be resolved usingresolve_avatar
to automatically find the target image and validate ownership in the case of NFTs.PR Checklist
Questions
Option
in the return type ofresolve_avatar
?