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

feat: add space id web3 name sdk to tools #508

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

minghuipei
Copy link

@minghuipei minghuipei commented Nov 26, 2024

Summary by CodeRabbit

  • New Features

    • Introduced the SPACE ID Web3 Name SDK for resolving web3 domain names and reverse resolving conventional addresses.
    • Added a new entry for "space-id" in the metadata, detailing the SDK's capabilities.
  • Documentation

    • Launched comprehensive documentation for the SPACE ID Web3 Name SDK, including setup instructions and code snippets for developers.

Copy link

vercel bot commented Nov 26, 2024

@minghuipei is attempting to deploy a commit to the Zeta Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

coderabbitai bot commented Nov 26, 2024

📝 Walkthrough

Walkthrough

The changes include the addition of a new entry for "space-id" in the JSON metadata file and the introduction of a new documentation file for the SPACE ID Web3 Name SDK. The JSON entry specifies the title and description of the SDK, while the documentation outlines its functionalities, setup instructions, and usage examples, focusing on domain name resolution and reverse resolution of conventional addresses.

Changes

File Path Change Summary
src/pages/developers/services/_meta.json Added new entry "space-id" with title "Web3 Name SDK" and description "SPACE ID Web3 Name SDK".
src/pages/developers/services/space-id.mdx New file added containing comprehensive documentation for the SPACE ID Web3 Name SDK, including setup and usage.

Sequence Diagram(s)

sequenceDiagram
    participant Developer
    participant SDK
    participant Blockchain

    Developer->>SDK: Install SDK
    SDK->>Developer: Provide setup instructions
    Developer->>SDK: Resolve web3 domain name
    SDK->>Blockchain: Query domain information
    Blockchain-->>SDK: Return domain details
    SDK-->>Developer: Provide domain information
    Developer->>SDK: Reverse resolve conventional address
    SDK->>Blockchain: Query reverse resolution
    Blockchain-->>SDK: Return primary domain name
    SDK-->>Developer: Provide primary domain name
Loading

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Outside diff range and nitpick comments (4)
src/pages/reference/_meta.json (1)

17-17: Consider enhancing the description for better clarity.

The current description "SPACE ID Web3 Name SDK" could be more informative about the SDK's purpose and capabilities.

-    "description": "SPACE ID Web3 Name SDK"
+    "description": "Tools and utilities for Web3 domain name resolution using SPACE ID SDK"
src/pages/reference/space-id/setup.mdx (3)

34-34: Consider relaxing the viem version constraint

The current installation command specifies a strict version requirement for viem (^1.20). Consider using a more flexible version range to allow for compatible updates.

-npm install @web3-name-sdk/core viem@^1.20
+npm install @web3-name-sdk/core viem@^1

36-42: Enhance Next.js configuration documentation

The Next.js configuration section would benefit from explaining why transpilation is necessary and potential implications.

Add context about the transpilation requirement:

If you are using next.js, please add the following configuration in your next.config.js in order to transpile commonjs dependencies:

+// This configuration is required because @web3-name-sdk/core is distributed as CommonJS,
+// and Next.js needs to transpile it to ensure compatibility with its module system.

const nextConfig = {
  transpilePackages: ["@web3-name-sdk/core"],
};

104-104: Consider adding additional documentation sections

The documentation would benefit from the following additional sections:

  • Error handling and troubleshooting guide
  • TypeScript type definitions and interfaces
  • Advanced usage scenarios and best practices
  • Rate limiting and performance considerations

Would you like me to help draft content for these sections?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 07bc9c5 and 1bf6f94.

📒 Files selected for processing (3)
  • src/pages/reference/_meta.json (1 hunks)
  • src/pages/reference/space-id/_meta.json (1 hunks)
  • src/pages/reference/space-id/setup.mdx (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/pages/reference/space-id/_meta.json
🧰 Additional context used
🪛 LanguageTool
src/pages/reference/space-id/setup.mdx

[style] ~17-~17: As a shorter alternative for ‘able to’, consider using “can”.
Context: ...gy: TLD Primary Name: - Every address is able to set TLD Primary Name to configure a rev...

(BE_ABLE_TO)


[uncategorized] ~54-~54: You might be missing the article “an” here.
Context: ... 2. Resolve a domain name​ You can get address from domain name with a single request:...

(AI_EN_LECTOR_MISSING_DETERMINER_AN)


[uncategorized] ~54-~54: You might be missing the article “a” here.
Context: ... domain name​ You can get address from domain name with a single request: ```typescr...

(AI_EN_LECTOR_MISSING_DETERMINER_A)

🔇 Additional comments (1)
src/pages/reference/_meta.json (1)

15-17: LGTM! The structure and integration are well-implemented.

The new "space-id" section follows the established pattern and maintains consistency with existing entries.

Comment on lines 1 to 4
---
title: SPACE ID Web3 Name SDK
description:
---
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Add missing description in frontmatter metadata

The description field in the frontmatter metadata is empty. This could affect documentation generation and SEO.

Add a concise description, for example:

---
title: SPACE ID Web3 Name SDK
description:
+description: "A comprehensive SDK for resolving Web3 domain names and performing reverse address resolution across different blockchains and TLDs"
---
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
---
title: SPACE ID Web3 Name SDK
description:
---
---
title: SPACE ID Web3 Name SDK
description: "A comprehensive SDK for resolving Web3 domain names and performing reverse address resolution across different blockchains and TLDs"
---

Comment on lines 91 to 95
const record = await sid.getDomainRecord({
name: "zeta.zeta",
key: "avatar",
});
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix inconsistent variable naming in examples

The variable sid is used here, but web3name was used in previous examples. This inconsistency could confuse users.

-const record = await sid.getDomainRecord({
+const record = await web3name.getDomainRecord({
  name: "zeta.zeta",
  key: "avatar",
});
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const record = await sid.getDomainRecord({
name: "zeta.zeta",
key: "avatar",
});
```
const record = await web3name.getDomainRecord({
name: "zeta.zeta",
key: "avatar",
});

Comment on lines 102 to 104
// requesting
const metadata = await web3Name.getMetadata({ name: "public.zeta" });
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Enhance metadata example with error handling and response structure

The metadata example would benefit from error handling and showing the expected response structure.

-// requesting
-const metadata = await web3Name.getMetadata({ name: "public.zeta" });
+try {
+  const metadata = await web3name.getMetadata({ name: "public.zeta" });
+  // Example response structure:
+  // {
+  //   name: string;
+  //   tokenId: string;
+  //   chainId: number;
+  //   owner: string;
+  //   resolver: string;
+  //   // ... other metadata fields
+  // }
+} catch (error) {
+  console.error('Failed to fetch metadata:', error);
+}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// requesting
const metadata = await web3Name.getMetadata({ name: "public.zeta" });
```
try {
const metadata = await web3name.getMetadata({ name: "public.zeta" });
// Example response structure:
// {
// name: string;
// tokenId: string;
// chainId: number;
// owner: string;
// resolver: string;
// // ... other metadata fields
// }
} catch (error) {
console.error('Failed to fetch metadata:', error);
}

@fadeev
Copy link
Member

fadeev commented Nov 26, 2024

@minghuipei the doc looks good, but can you, please, move it to https://github.com/zeta-chain/docs/tree/main/src/pages/developers/services ? This is where all our third-party tutorials are. Thanks!

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (6)
src/pages/developers/services/_meta.json (1)

30-32: Consider maintaining alphabetical ordering of entries.

For better maintainability and easier navigation, consider moving the "space-id" entry before "subquery" to maintain alphabetical ordering.

   "pyth": {
     "title": "Pyth",
     "description": "Price and VRF Oracle"
   },
+  "space-id": {
+    "title": "Web3 Name SDK",
+    "description": "SPACE ID Web3 Name SDK"
+  },
   "subquery": {
     "title": "SubQuery",
     "description": "Open-source, flexible, multi-chain data indexer"
   },
   "goldrush": {
     "title": "GoldRush",
     "description": "Historical blockchain data API"
-  },
-  "space-id": {
-    "title": "Web3 Name SDK",
-    "description": "SPACE ID Web3 Name SDK"
   }
src/pages/developers/services/space-id.mdx (5)

1-4: Consider enhancing frontmatter with additional metadata.

Consider adding helpful metadata fields such as:

  • sidebar_label: For navigation menu display
  • tags: For documentation categorization
  • keywords: For search optimization
 ---
 title: SPACE ID Web3 Name SDK
 description: Resolve web3 domain name or reverse resolve conventional address
+sidebar_label: SPACE ID
+tags: ['web3', 'domain', 'sdk']
+keywords: ['space id', 'web3 name', 'domain resolution']
 ---

17-17: Improve readability with concise wording.

Consider rephrasing for clarity and conciseness.

-Every address is able to set TLD Primary Name to configure
+Every address can set TLD Primary Name to configure
🧰 Tools
🪛 LanguageTool

[style] ~17-~17: As a shorter alternative for ‘able to’, consider using “can”.
Context: ...gy: TLD Primary Name: - Every address is able to set TLD Primary Name to configure a rev...

(BE_ABLE_TO)


8-11: Enhance list formatting for better readability.

Consider using consistent formatting for the capability descriptions.

 The primary capabilities of the SDK include:

-Domain Name Resolution: It resolves domain names to obtain essential information about the domain, including its associated conventional address, various records (such as avatars, IPFS links, social data), and metadata, etc.
+1. Domain Name Resolution
+   - Resolves domain names to obtain essential information
+   - Retrieves associated conventional addresses
+   - Fetches various records (avatars, IPFS links, social data)
+   - Provides domain metadata

34-34: Consider specifying version ranges for dependencies.

The installation command should specify compatible version ranges for better dependency management.

-npm install @web3-name-sdk/core viem@^1.20
+npm install @web3-name-sdk/core@^1.0.0 viem@^1.20.0

69-74: Add TypeScript type annotations for better code documentation.

Consider adding type information to improve code clarity and IDE support.

 // Resolve an address from Zeta Chain
-const name = await web3name.getDomainName({
+interface ResolutionParams {
+  address: string;
+  queryChainIdList?: number[];
+}
+
+const name: string = await web3name.getDomainName({
   address: "0x253a4ee0acb7c89bab7c20097200ea240119049a",
   queryChainIdList: [7000],
 }); // expect: karlyshka.zeta
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 1bf6f94 and 535ad3f.

📒 Files selected for processing (2)
  • src/pages/developers/services/_meta.json (1 hunks)
  • src/pages/developers/services/space-id.mdx (1 hunks)
🧰 Additional context used
🪛 LanguageTool
src/pages/developers/services/space-id.mdx

[style] ~17-~17: As a shorter alternative for ‘able to’, consider using “can”.
Context: ...gy: TLD Primary Name: - Every address is able to set TLD Primary Name to configure a rev...

(BE_ABLE_TO)

🔇 Additional comments (2)
src/pages/developers/services/_meta.json (1)

29-32: LGTM! Entry structure is consistent with existing patterns.

The new "space-id" entry maintains proper JSON formatting and follows the established pattern of title and description fields.

src/pages/developers/services/space-id.mdx (1)

1-104: Documentation placement looks good.

The file is correctly placed in the /developers/services directory as requested by the reviewer fadeev.

🧰 Tools
🪛 LanguageTool

[style] ~17-~17: As a shorter alternative for ‘able to’, consider using “can”.
Context: ...gy: TLD Primary Name: - Every address is able to set TLD Primary Name to configure a rev...

(BE_ABLE_TO)

Comment on lines +57 to +61
const address = await web3name.getAddress("zeta.zeta");
const address = await web3name.getAddress("bts_official.lens");
const address = await web3name.getAddress("beresnev.crypto");
const address = await web3name.getAddress("registry.zeta");
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add error handling to resolution examples.

Consider demonstrating proper error handling for failed resolutions.

 const address = await web3name.getAddress("zeta.zeta");
+
+// Example with error handling
+try {
+  const address = await web3name.getAddress("nonexistent.zeta");
+} catch (error) {
+  if (error.code === 'DOMAIN_NOT_FOUND') {
+    console.error('Domain does not exist');
+  } else {
+    console.error('Resolution failed:', error.message);
+  }
+}

Committable suggestion skipped: line range outside the PR's diff.

@minghuipei
Copy link
Author

@fadeev I have updated, please review it one more. Thanks~

Copy link
Member

@fadeev fadeev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍

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

Successfully merging this pull request may close these issues.

2 participants