-
Notifications
You must be signed in to change notification settings - Fork 67
migrate setResolver
#248
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
base: feature/fet-1885-ensjs-refactor
Are you sure you want to change the base?
migrate setResolver
#248
Conversation
commit: |
name: string; | ||
/** Contract to set resolver on - can be 'registry', 'nameWrapper', or an address of a namechain registry */ | ||
contract: "registry" | "nameWrapper" | Address; | ||
/** Resolver address to set */ |
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.
I'd recommend turning contract into optional "registry" | "name wrapper" and adding a new parameter called registryAddress to make this more descriptive and precise. You can use discriminated unions to keep it type safe.
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.
i think we should think about it more. i'll leave it as is for now
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 reformat the file. It seems like the configuration wasn't applied, and it switched from spaces to tabs
|
} | ||
|
||
// Handle namechain contracts | ||
if (registryAddress && !isAddress(registryAddress)) { |
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.
Don't need to check if registryAddress exists. isAddres will return false if registryAddress does not exist. Also this condition will fail if registryAddress is empty.
TLDR. Just check if registryAddres is address.
const baseParams = { | ||
address, | ||
functionName, | ||
address: registryAddress!, |
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.
We want to avoid forcing the value or registryAddress. Should add a guard function before this is isAddress does not satisfy it.
e.g. function checkAddress(x: unknown): x is Address
migrate
setResolver
to support namechain contracts while maintaining backwards compatibility.the function now accepts registry addresses in addition to 'registry' and 'namewrapper' string literals.
for namechain contracts, it uses
labelhash
instead ofnamehash
and callssetResolver(tokenid, resolver)
with the appropriate abi.should we extract the namechain abi snippet to a separate file like ../../contracts/namechain.js similar to how
nameWrapper
has? currently it's defined inline because its very simple.