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 resolveName for ENS #23

Closed
dawsbot opened this issue Feb 10, 2022 · 2 comments
Closed

Add resolveName for ENS #23

dawsbot opened this issue Feb 10, 2022 · 2 comments
Assignees
Labels
Epic Big or tricky

Comments

@dawsbot
Copy link
Owner

dawsbot commented Feb 10, 2022

⚠️ This will be tricky to do in a small package-size ⚠️

daws.eth -> 0xc0DEAF6bD3F0c6574a6a625EF2F22f62A5150EAB

https://docs.ens.domains/dapp-developer-guide/resolving-names

Looks like the easiest namehashing is done like this

await provider.call({
  // ENS public resovler address
  to: "0x4976fb03C32e5B8cfe2b6cCB31c09Ba78EBaBa41",

  // `function addr(namehash("ricmoo.eth")) view returns (address)`
  data: "0x3b3b57debf074faa138b72c65adbdcfb329847e4f2c04bde7f7dd7fcad5a52d2f395a558"
});
// '0x0000000000000000000000005555763613a12d8f3e73be831dff8598089d3dca'

Will require namehashing

import { StaticJsonRpcProvider } from '@ethersproject/providers';

export const resolveENS = async (name: string) => {
  const rpcUrl = processEnv('RPC_MAINNET');
  const provider = new StaticJsonRpcProvider(rpcUrl);
  const resolvedName = await provider.resolveName(name);
  return resolvedName;
};

Ran the ethers name resolution against my local free-eth-node proxy and got these three requests:

import { ethers } from 'ethers';
import { rpcUrls } from './rpc-urls';

const rpcUrl = rpcUrls.mainnet;

describe('provider.resolveName', () => {
  it('should match ethers and essential-eth', async () => {
    const ethersProvider = new ethers.providers.StaticJsonRpcProvider(rpcUrl);
    await ethersProvider.resolveName('ricmoo.eth');
    expect(true).toBe(true);
  });
});
{
  body: {
    method: 'eth_call',
    params: [ [Object], 'latest' ],
    id: 43,
    jsonrpc: '2.0'
  },
  params1: {
    to: '0x00000000000c2e074ec69a0dfb2997ba6c7d2e1e',
    data: '0x0178b8bfbf074faa138b72c65adbdcfb329847e4f2c04bde7f7dd7fcad5a52d2f395a558'
  },
  params2: 'latest'
}
{
  body: {
    method: 'eth_call',
    params: [ [Object], 'latest' ],
    id: 44,
    jsonrpc: '2.0'
  },
  params1: {
    to: '0x4976fb03c32e5b8cfe2b6ccb31c09ba78ebaba41',
    data: '0x01ffc9a79061b92300000000000000000000000000000000000000000000000000000000'
  },
  params2: 'latest'
}
{
  body: {
    method: 'eth_call',
    params: [ [Object], 'latest' ],
    id: 45,
    jsonrpc: '2.0'
  },
  params1: {
    to: '0x4976fb03c32e5b8cfe2b6ccb31c09ba78ebaba41',
    data: '0x3b3b57debf074faa138b72c65adbdcfb329847e4f2c04bde7f7dd7fcad5a52d2f395a558'
  },
  params2: 'latest'
}
@dawsbot dawsbot added the Epic Big or tricky label Mar 29, 2022
@arimgibson arimgibson self-assigned this Jun 1, 2022
@arimgibson
Copy link
Contributor

Going to attempt to get a start on this one... not going to be able to finish it with the time I have left, but hoping it's enough so that someone else can take over

@dawsbot
Copy link
Owner Author

dawsbot commented Jun 5, 2022

Replaced with #143 (for now)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Epic Big or tricky
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants