-
Notifications
You must be signed in to change notification settings - Fork 574
[SDK] Add Hashkey chain configuration #7910
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
base: main
Are you sure you want to change the base?
Conversation
|
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
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. |
WalkthroughAdds 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
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 unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
@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. |
There was a problem hiding this 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 labelsCurrent 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 consistencyMost
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 nameAlign 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.
📒 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 localtypes.ts
barrels
Prefer type aliases over interface except for nominal shapes
Avoidany
andunknown
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 mainnetStatic 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 foundA search across
packages/thirdweb/src/chains/chain-definitions/
shows only one occurrence ofid: 177
inhashkey.ts
(line 14). No other chains define this ID, so there’s no risk of runtime ambiguity.
1-1
: Import style consistency verifiedAll
chain-definitions/*.ts
files—includinghashkey.ts
—importdefineChain
from"../utils.js"
, matching the existing pattern. No changes required.
7-13
: Confirm blockExplorers shape matches project-wide type
- The
blockExplorers
entries inChainOptions
are defined as:(portal.thirdweb.com){ apiUrl?: string; name: string; url: string; }- In
packages/thirdweb/src/chains/chain-definitions/hashkey.ts
, you’re using onlyname
andurl
, which satisfies the type (theapiUrl
field is optional).- We did not find any
family
property used in any of the chain definitions; it isn’t part ofChainOptions
.- If you plan to consume HashKey’s BlockScout API, you can optionally include:
Otherwise, no changes are needed here.blockExplorers: [ { name: "Hashkey Explorer", url: "https://hashkey.blockscout.com/", + apiUrl:"https://hashkey.blockscout.com/api", }, ],
packages/thirdweb/src/chains/chain-definitions/hashkey-testnet.ts (3)
13-22
: LGTM: testnet flag and currency mirror mainnet appropriatelytestnet: true is present; currency shape aligns with mainnet; RPC looks isolated for testing.
14-14
: Chain ID 133 is unique across all definitionsI ran a search for
id: 133
across every file inpackages/thirdweb/src/chains/chain-definitions
and only found it defined inhashkey-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 endpointsThe optional availability check shows that all configured RPC and explorer URLs are reachable:
- RPC “https://testnet.hsk.xyz” returns HTTP 415 (server reachable, unsupported media type for HEAD)
- Explorer “https://testnet-explorer.hsk.xyz” returns HTTP 200
- RPC “https://mainnet.hsk.xyz” returns HTTP 405 (server reachable, method not allowed for HEAD)
- Explorer “https://hashkey.blockscout.com” returns HTTP 200
Since all endpoints respond successfully over HTTPS, no immediate action is required.
/** | ||
* @chain | ||
*/ | ||
export const HashkeyTestnet = /*@__PURE__*/ defineChain({ |
There was a problem hiding this comment.
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.
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({ |
There was a problem hiding this comment.
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.
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.
PR-Codex overview
This PR introduces two new chain definitions for
Hashkey
andHashkey Testnet
, including their respective RPC URLs, native currencies, and block explorer details.Detailed summary
Added
Hashkey
chain definition with:https://mainnet.hsk.xyz
HashKey Platform Token
(symbol:HSK
, decimals: 18)Hashkey Explorer
(URL:https://hashkey.blockscout.com/
)Added
HashkeyTestnet
chain definition with:https://testnet.hsk.xyz
HashKey Platform Token
(symbol:HSK
, decimals: 18)Hashkey Explorer
(URL:https://testnet-explorer.hsk.xyz
)Summary by CodeRabbit