Skip to content

Conversation

leo-shi-dacheng
Copy link
Contributor

@leo-shi-dacheng leo-shi-dacheng commented Aug 26, 2025

PR-Codex overview

This PR introduces two new chain definitions for Hashkey and Hashkey Testnet, including their respective RPC URLs, native currencies, and block explorer details.

Detailed summary

  • Added Hashkey chain definition with:

    • RPC URL: https://mainnet.hsk.xyz
    • ID: 177
    • Native currency: HashKey Platform Token (symbol: HSK, decimals: 18)
    • Block explorer: Hashkey Explorer (URL: https://hashkey.blockscout.com/)
  • Added HashkeyTestnet chain definition with:

    • RPC URL: https://testnet.hsk.xyz
    • ID: 133
    • Native currency: HashKey Platform Token (symbol: HSK, decimals: 18)
    • Block explorer: Hashkey Explorer (URL: https://testnet-explorer.hsk.xyz)
    • Marked as a testnet.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Summary by CodeRabbit

  • New Features
    • Added native support for Hashkey (mainnet) and Hashkey Testnet networks.
    • Preconfigured RPC endpoints for quick, reliable connections.
    • Integrated block explorer links for easier transaction and contract lookups.
    • Recognizes HSK as the native currency with correct decimals and symbol.
    • Enables connecting wallets, deploying, and interacting with contracts on these networks.
    • Includes proper network identifiers for smooth network selection and tooling integration.

@leo-shi-dacheng leo-shi-dacheng requested review from a team as code owners August 26, 2025 02:28
Copy link

changeset-bot bot commented Aug 26, 2025

⚠️ No Changeset found

Latest commit: f047bb7

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

graphite-app bot commented Aug 26, 2025

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge-queue - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

Copy link
Contributor

coderabbitai bot commented Aug 26, 2025

Walkthrough

Adds two new chain definition files for Hashkey networks. Each exports a constant created via defineChain: Hashkey (mainnet, id 177) and HashkeyTestnet (testnet, id 133), specifying RPC URLs, block explorers, native currency (HSK), and testnet flag for the testnet.

Changes

Cohort / File(s) Summary of changes
Chain definitions: Hashkey networks
packages/thirdweb/src/chains/chain-definitions/hashkey.ts, packages/thirdweb/src/chains/chain-definitions/hashkey-testnet.ts
Added new exported chain configs using defineChain: Hashkey (id 177, rpc https://mainnet.hsk.xyz, explorer https://hashkey.blockscout.com/) and HashkeyTestnet (id 133, rpc https://testnet.hsk.xyz, explorer https://testnet-explorer.hsk.xyz), both with HSK native currency; testnet flagged true only for testnet.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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

vercel bot commented Aug 26, 2025

@leo-shi-dacheng is attempting to deploy a commit to the thirdweb Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions bot added packages SDK Involves changes to the thirdweb SDK labels Aug 26, 2025
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: 2

🧹 Nitpick comments (5)
packages/thirdweb/src/chains/chain-definitions/hashkey.ts (2)

9-10: Use brand-consistent casing: “HashKey” (capital K) across labels

Current strings mix “Hashkey” and “HashKey”. Prefer “HashKey” for brand correctness in name and explorer label.

Apply:

-      name: "Hashkey Explorer",
+      name: "HashKey Explorer",
@@
-  name: "Hashkey",
+  name: "HashKey",

Also applies to: 15-15


10-10: Normalize trailing slash on Hashkey Explorer URL for consistency

Most blockExplorers.url entries (55 out of 73) omit the trailing slash, while only 18 include one. To align with the repo’s majority convention and avoid duplicate-slash logic, please remove the trailing slash in this file.

• File: packages/thirdweb/src/chains/chain-definitions/hashkey.ts

 blockExplorers: [
   {
     name: "Hashkey Explorer",
-      url: "https://hashkey.blockscout.com/",
+      url: "https://hashkey.blockscout.com",
   },
 ],
packages/thirdweb/src/chains/chain-definitions/hashkey-testnet.ts (3)

6-6: Add the lint exception for direct defineChain usage (repo rule)

As with mainnet, add the eslint-disable for direct defineChain usage to avoid lint failures.

Apply:

- export const HashkeyTestnet = /*@__PURE__*/ defineChain({
+// eslint-disable-next-line no-restricted-syntax
+export const HashkeyTestnet = /*@__PURE__*/ defineChain({

9-10: Use brand-consistent casing: “HashKey” (capital K) in labels and name

Align with the mainnet change for consistent branding.

Apply:

-      name: "Hashkey Explorer",
+      name: "HashKey Explorer",
@@
-  name: "Hashkey Testnet",
+  name: "HashKey Testnet",

Also applies to: 15-15


10-10: Explorer URL normalization (slash consistency)

Mirror the mainnet decision for trailing slash convention.

Option (add trailing slash if majority includes it, or remove otherwise):

-      url: "https://testnet-explorer.hsk.xyz",
+      url: "https://testnet-explorer.hsk.xyz/",

Confirm the project-wide convention with the same script provided on the mainnet comment.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 8828df0 and f047bb7.

📒 Files selected for processing (2)
  • packages/thirdweb/src/chains/chain-definitions/hashkey-testnet.ts (1 hunks)
  • packages/thirdweb/src/chains/chain-definitions/hashkey.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Write idiomatic TypeScript with explicit function declarations and return types
Limit each file to one stateless, single-responsibility function for clarity
Re-use shared types from @/types or local types.ts barrels
Prefer type aliases over interface except for nominal shapes
Avoid any and unknown unless unavoidable; narrow generics when possible
Choose composition over inheritance; leverage utility types (Partial, Pick, etc.)
Comment only ambiguous logic; avoid restating TypeScript in prose

Files:

  • packages/thirdweb/src/chains/chain-definitions/hashkey-testnet.ts
  • packages/thirdweb/src/chains/chain-definitions/hashkey.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Load heavy dependencies inside async paths to keep initial bundle lean (lazy loading)

Files:

  • packages/thirdweb/src/chains/chain-definitions/hashkey-testnet.ts
  • packages/thirdweb/src/chains/chain-definitions/hashkey.ts
🧠 Learnings (2)
📚 Learning: 2025-07-18T19:19:55.613Z
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-18T19:19:55.613Z
Learning: Applies to **/*.test.{ts,tsx} : Use `FORKED_ETHEREUM_CHAIN` for mainnet interactions and `ANVIL_CHAIN` for isolated tests

Applied to files:

  • packages/thirdweb/src/chains/chain-definitions/hashkey-testnet.ts
📚 Learning: 2025-06-06T23:46:08.795Z
Learnt from: MananTank
PR: thirdweb-dev/js#7298
File: apps/dashboard/src/app/nebula-app/move-funds/move-funds.tsx:424-424
Timestamp: 2025-06-06T23:46:08.795Z
Learning: The thirdweb project has an ESLint rule that restricts direct usage of `defineChain`. When it's necessary to use `defineChain` directly, it's acceptable to disable the rule with `// eslint-disable-next-line no-restricted-syntax`.

Applied to files:

  • packages/thirdweb/src/chains/chain-definitions/hashkey-testnet.ts
🔇 Additional comments (7)
packages/thirdweb/src/chains/chain-definitions/hashkey.ts (4)

7-13: LGTM overall: schema fields and values look correct for mainnet

Static config is minimal and follows the expected shape: id, rpc, explorers, nativeCurrency. Pure annotation helps tree-shaking.

Also applies to: 16-21


14-14: Chain ID 177 is unique – no collisions found

A search across packages/thirdweb/src/chains/chain-definitions/ shows only one occurrence of id: 177 in hashkey.ts (line 14). No other chains define this ID, so there’s no risk of runtime ambiguity.


1-1: Import style consistency verified

All chain-definitions/*.ts files—including hashkey.ts—import defineChain from "../utils.js", matching the existing pattern. No changes required.


7-13: Confirm blockExplorers shape matches project-wide type

  • The blockExplorers entries in ChainOptions are defined as:
    {
      apiUrl?: string;
      name:    string;
      url:     string;
    }
    (portal.thirdweb.com)
  • In packages/thirdweb/src/chains/chain-definitions/hashkey.ts, you’re using only name and url, which satisfies the type (the apiUrl field is optional).
  • We did not find any family property used in any of the chain definitions; it isn’t part of ChainOptions.
  • If you plan to consume HashKey’s BlockScout API, you can optionally include:
     blockExplorers: [
       {
         name: "Hashkey Explorer",
         url:  "https://hashkey.blockscout.com/",
    +    apiUrl:"https://hashkey.blockscout.com/api",
       },
     ],
    Otherwise, no changes are needed here.
packages/thirdweb/src/chains/chain-definitions/hashkey-testnet.ts (3)

13-22: LGTM: testnet flag and currency mirror mainnet appropriately

testnet: true is present; currency shape aligns with mainnet; RPC looks isolated for testing.


14-14: Chain ID 133 is unique across all definitions

I ran a search for id: 133 across every file in packages/thirdweb/src/chains/chain-definitions and only found it defined in hashkey-testnet.ts. There are no collisions with any other testnet or mainnet entries.

• packages/thirdweb/src/chains/chain-definitions/hashkey-testnet.ts – id: 133 (only occurrence)


13-13: Availability check passed for all HashKey endpoints

The optional availability check shows that all configured RPC and explorer URLs are reachable:

Since all endpoints respond successfully over HTTPS, no immediate action is required.

/**
* @chain
*/
export const HashkeyTestnet = /*@__PURE__*/ defineChain({
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Confirm export naming style matches the directory’s convention

Ensure “HashkeyTestnet” casing matches other testnet exports (e.g., FooTestnet vs fooTestnet). Rename if needed before public release to avoid churn.

List export names in this folder:

If most are PascalCaseTestnet, keep as-is; otherwise consider aligning.


🏁 Script executed:

#!/bin/bash
rg -nP -g 'packages/thirdweb/src/chains/chain-definitions/**' '^export const\s+\w+' \
  | sed -E 's/.*export const\s+([A-Za-z0-9_]+).*/\1/' | sort -u

Length of output: 1047


Rename HashkeyTestnet export to lower-camel-case

Most testnet exports in this directory use lower-camel-case (e.g., bscTestnet, fantomTestnet, celoAlfajoresTestnet), but HashkeyTestnet is the only one starting with an uppercase letter. To maintain consistency, rename the export in hashkey-testnet.ts and update all its imports:

• File: packages/thirdweb/src/chains/chain-definitions/hashkey-testnet.ts
Line 6:

-export const HashkeyTestnet = /*@__PURE__*/ defineChain({
+export const hashkeyTestnet = /*@__PURE__*/ defineChain({

After this change, search for any HashkeyTestnet references elsewhere and update them to hashkeyTestnet to avoid breaking imports.

📝 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
export const HashkeyTestnet = /*@__PURE__*/ defineChain({
export const hashkeyTestnet = /*@__PURE__*/ defineChain({
🤖 Prompt for AI Agents
In packages/thirdweb/src/chains/chain-definitions/hashkey-testnet.ts around line
6, the named export is currently "HashkeyTestnet" (PascalCase) but should follow
the directory's lower-camel-case convention; rename the export to
"hashkeyTestnet" (export const hashkeyTestnet = /*@__PURE__*/
defineChain({...})), save the file, then search the repo for any imports or
references to "HashkeyTestnet" and update them to "hashkeyTestnet" to keep
imports consistent and avoid breakage.

/**
* @chain
*/
export const Hashkey = /*@__PURE__*/ defineChain({
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Add the lint exception for direct defineChain usage (repo rule)

Per project learnings, direct usage of defineChain may be restricted by ESLint. Add the inline exception to avoid lint failures.

Apply:

- export const Hashkey = /*@__PURE__*/ defineChain({
+// eslint-disable-next-line no-restricted-syntax
+export const Hashkey = /*@__PURE__*/ defineChain({

And verify lint behavior:


🏁 Script executed:

#!/bin/bash
# Inspect if other chain-definitions disable this rule too
rg -nC1 -g 'packages/thirdweb/src/chains/chain-definitions/**' \
  -P 'eslint-disable-next-line\s+no-restricted-syntax'

Length of output: 117


🏁 Script executed:

#!/bin/bash
# List all occurrences of defineChain in chain-definitions to check for existing lint exceptions
rg -nC1 -g 'packages/thirdweb/src/chains/chain-definitions/**' -P 'defineChain'

Length of output: 34776


🏁 Script executed:

#!/bin/bash
set -eux

echo "Searching ESLint config for no-restricted-syntax rule..."
rg -nR "no-restricted-syntax" -g "*.eslintrc*" || true

echo "Searching ESLint config for defineChain restriction..."
rg -nR "defineChain" -g "*.eslintrc*" || true

Length of output: 1161


🏁 Script executed:

#!/bin/bash
set -e

echo "=== Checking .eslintrc* files for no-restricted-syntax rule ==="
rg -n "no-restricted-syntax" -g ".eslintrc*" || echo "<none in .eslintrc*>"

echo "=== Checking package.json for no-restricted-syntax ==="
rg -n "no-restricted-syntax" -g "package.json" || echo "<none in package.json>"

echo "=== Checking ESLint configs for defineChain mention ==="
rg -n "defineChain" -g ".eslintrc*" || echo "<none in .eslintrc*>"
rg -n "defineChain" -g "package.json" || echo "<none in package.json>"

Length of output: 1096


Add ESLint disable for no-restricted-syntax on defineChain

The repository’s ESLint config (packages/thirdweb/.eslintrc.cjs) includes a no-restricted-syntax rule blocking direct calls to defineChain, so any chain-definition file will fail lint unless it’s explicitly disabled.

• File to update:

  • packages/thirdweb/src/chains/chain-definitions/hashkey.ts

• Change required:

- export const Hashkey = /*@__PURE__*/ defineChain({
+ // eslint-disable-next-line no-restricted-syntax
+ export const Hashkey = /*@__PURE__*/ defineChain({
📝 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
export const Hashkey = /*@__PURE__*/ defineChain({
// eslint-disable-next-line no-restricted-syntax
export const Hashkey = /*@__PURE__*/ defineChain({
🤖 Prompt for AI Agents
In packages/thirdweb/src/chains/chain-definitions/hashkey.ts around line 6, the
call to defineChain is blocked by the repo ESLint rule no-restricted-syntax; add
an ESLint disable for that rule immediately before the export (use an inline
directive such as eslint-disable-next-line no-restricted-syntax) so the
defineChain invocation is exempted; keep the disable scoped to that line to
avoid silencing the rule globally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
packages SDK Involves changes to the thirdweb SDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant