Skip to content

Conversation

@jeasonstudio
Copy link
Collaborator

[中文版模板 / Chinese template]

💡 Background and solution

🔗 Related issue link

@jeasonstudio jeasonstudio requested a review from Copilot October 14, 2025 08:48
@changeset-bot
Copy link

changeset-bot bot commented Oct 14, 2025

🦋 Changeset detected

Latest commit: b034777

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@ant-design/web3-ledger Minor

Not sure what this means? Click here to learn what changesets are.

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

@vercel
Copy link

vercel bot commented Oct 14, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
ant-design-web3 Ready Ready Preview Comment Nov 24, 2025 6:21am

@github-actions
Copy link

github-actions bot commented Oct 14, 2025

Prepare preview

@coderabbitai
Copy link

coderabbitai bot commented Oct 14, 2025

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat-new-provider-ledger

Tip

📝 Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


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

Comment @coderabbitai help to get the list of available commands and usage tips.

@socket-security
Copy link

socket-security bot commented Oct 14, 2025

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​ledgerhq/​device-transport-kit-web-hid@​1.2.08410092100100
Added@​ledgerhq/​device-management-kit@​0.9.186100100100100
Added@​ledgerhq/​device-signer-kit-ethereum@​1.8.0100100100100100

View full report

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a new Ledger hardware wallet provider for Ant Design Web3, enabling integration with Ledger devices through WebHID API. The implementation provides secure hardware wallet connectivity with device management, message signing capabilities, and React hooks for device interaction.

Key changes:

  • Adds complete Ledger wallet adapter package with React provider and hooks
  • Implements device discovery, connection management, and Ethereum signing functionality
  • Provides comprehensive documentation and examples for Ledger integration

Reviewed Changes

Copilot reviewed 28 out of 30 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
packages/ledger/package.json Package configuration with Ledger SDK dependencies
packages/ledger/src/ledger/*.ts Core Ledger device management hooks and utilities
packages/ledger/src/wallets/ledger.tsx Main Ledger wallet factory implementation
packages/ledger/src/provider/*.tsx React providers for Ledger integration
packages/ledger/src/types.ts TypeScript interfaces for Ledger wallet types
packages/ledger/docs/* Documentation and usage examples
.changeset/vast-tools-poke.md Changeset for the new feature
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

},

signMessage: async (message: string) => {
console.log('Signing message:', message);
Copy link

Copilot AI Oct 14, 2025

Choose a reason for hiding this comment

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

Console.log statements should be removed or replaced with proper logging mechanism. These debug logs will appear in production code.

Copilot uses AI. Check for mistakes.
return {
name: 'Ledger',
adapter,
icon: undefined, // TODO: Add Ledger icon
Copy link

Copilot AI Oct 14, 2025

Choose a reason for hiding this comment

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

TODO comment indicates incomplete implementation. The icon should be implemented or the TODO should be tracked in an issue.

Copilot uses AI. Check for mistakes.
setDeviceStatus(state.deviceStatus);

// Extract current app name if available
const appName = (state as any)?.currentApp?.name;
Copy link

Copilot AI Oct 14, 2025

Choose a reason for hiding this comment

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

Using 'any' type defeats TypeScript's type safety. Define proper types for the state object or use more specific type assertion.

Suggested change
const appName = (state as any)?.currentApp?.name;
const appName = (typeof state === 'object' && state !== null && 'currentApp' in state && typeof (state as { currentApp?: { name?: string } }).currentApp?.name === 'string')
? (state as { currentApp: { name: string } }).currentApp.name
: undefined;

Copilot uses AI. Check for mistakes.
selectWallet(wallet);
}
}
}, [wallets]);
Copy link

Copilot AI Oct 14, 2025

Choose a reason for hiding this comment

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

The useEffect dependency array includes 'wallets' but the effect also depends on 'autoConnect', 'latestWalletNameRef.current', and 'adapterName'. Missing dependencies could cause stale closures.

Suggested change
}, [wallets]);
}, [wallets, autoConnect, adapterName, latestWalletNameRef]);

Copilot uses AI. Check for mistakes.
@yutingzhao1991
Copy link
Collaborator

有冲突了,需要 rebase 一下

@@ -0,0 +1,14 @@
import { ConnectButton, Connector } from '@ant-design/web3';
import { Ledger, LedgerWeb3ConfigProvider } from '@ant-design/web3-ledger';
Copy link
Collaborator

Choose a reason for hiding this comment

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

@ant-design/web3-ledger 只支持 Ladger 还是未来也可能支持其它硬件钱包?如果是可能支持其他硬件钱包,那命名是不是应该改一下。那如果只支持 Legder,那是不是 Ledger 也没必要配置了,默认就行。

try {
devicesRef = [await discoverFn()];
} catch (error) {
message.error('Failed to discover device');
Copy link
Collaborator

Choose a reason for hiding this comment

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

这里应该不需要显示错误,而是应该抛出异常,adapter 应该不要做任何和 UI 相关的事情

export interface LedgerWeb3ConfigProviderProps {
wallet?: WalletFactory;
locale?: Locale;
// balance?: boolean;
Copy link
Collaborator

Choose a reason for hiding this comment

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

没用的代码可以直接删除

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.

4 participants