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

Register domain receive array of calldata of records to be added at registering time #118

Open
pikonha opened this issue Jun 17, 2024 · 1 comment

Comments

@pikonha
Copy link
Contributor

pikonha commented Jun 17, 2024

export function withRegisterDomain(
  repo: WriteRepository,
  recover: SignatureRecover,
): ccip.HandlerDescription {
  return {
-    type: 'register(bytes32 node, uint32 ttl)',
+    type: 'register(bytes32 node, uint32 ttl, bytes[] memory data)',
    func: async ({ node, ttl, data }, { signature, sender }) => {
      try {
        const signer = await recover.recoverMessageSigner(
          signature as TypedSignature,
        )

        const existingDomain = await repo.getDomain({ node })
        if (existingDomain) {
          if (existingDomain.owner !== signer) {
            return { error: { message: 'Forbidden action', status: 401 } }
          }
          return { error: { message: 'Domain already exists', status: 400 } }
        }

        await repo.register({ node, ttl, owner: signer })

+        if (data.length > 0) {
+          ccipRequest({ data, sender, urls: ["http://127.0.0.1:3000/{sender}/{data}.json"] })
+        }
      } catch (err) {
        return {
          error: { message: 'Unable to register new domain', status: 400 },
        }
      }
    },
  }
}
@FrancoAguzzi
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

2 participants