blockful-io / external-resolver-dapp

https://external-resolver-dapp.vercel.app
2 stars 2 forks source link

feat: create new subdomain (DB resolver) #150

Closed alextnetto closed 2 months ago

alextnetto commented 3 months ago

Feature Request

Describe the Feature Request

Create the modal user-flow for registering a subdomain (with records).

Figma designs and prototype is available here.

Image

Must:

This modal user-flow should only be reachable when a domain uses our new ENSIP for Off-Chain resolvers, meaning that subdomains should not be created through SubGraph.

Definition of Done:

This issue will be considered as done when:

pikonha commented 3 months ago
  const name = normalize('edu.blockful.eth')
  const node = namehash(name)
  const signer = privateKeyToAccount(privateKey as Hex)

  if (!resolver) {
    resolver = getChainContractAddress({
      chain: client.chain,
      contract: 'ensUniversalResolver',
    })
  }

  const [resolverAddr] = (await client.readContract({
    address: resolver as Hex,
    functionName: 'findResolver',
    abi: uAbi,
    args: [toHex(packetToBytes(name))],
  })) as Hash[]

  // REGISTER NEW DOMAIN
  try {
    await client.simulateContract({
      functionName: 'register',
      abi: dbAbi,
      args: [toHex(name), 300, signer.address],
      account: signer.address,
      address: resolverAddr,
    })
  } catch (err) {
    const data = getRevertErrorData(err)
    if (data?.errorName === 'StorageHandledByOffChainDatabase') {
      const [domain, url, message] = data.args as [
        DomainData,
        string,
        MessageData,
      ]
      await handleDBStorage({ domain, url, message, signer })
    } else {
      console.error('writing failed: ', { err })
    }
  }
FrancoAguzzi commented 3 months ago

@alextnetto

  1. Can you please review this issue's specs and let us know if anything?
  2. Should it be possible to register subdomains for a domain that does not use Database Resolver?
alextnetto commented 3 months ago
  1. subdomains should not be created through SubGraph

SubGraph is a tool indexing data from the blockchain, in context of ENS is used for getting domain data. So there is no write operation possible, for creating a subdomain. That's done directly in ENS contracts.

Blockchain transaction statuses are correctly reflecting in user's Ui;

In this case is not a blockchain transaction, it's a signature.

Besides that all looks good!

  1. Great question! At this moment, we'll only register a domain through the database resolver. In a future moment where we implement an L2 infrastructure, then we'll do a blockchain transaction in the L2 (instead of the signature), following the exact same structure.