-
Notifications
You must be signed in to change notification settings - Fork 85
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
fix: HardWallet connection tip #3326
base: develop
Are you sure you want to change the base?
Conversation
error === ErrorCode.DeviceNotFound || | ||
error === ErrorCode.CkbAppNotFound || | ||
error === ErrorCode.DeviceNotMatchWallet |
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.
We can use [].includes(error)
to avoid chained ||
conditions
@@ -424,14 +428,16 @@ export const useHardWallet = ({ wallet, t }: { wallet: State.WalletIdentity; t: | |||
const ensureDeviceAvailable = useCallback( | |||
async (device: State.DeviceInfo) => { | |||
try { | |||
const connectionRes = await connectDevice(device) | |||
const connectionRes = await connectDevice({ ...device, walletID: wallet.id }) |
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.
Why should walletID
be overriden by wallet.id
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.
The device
does not contain walletID
field.
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.
PR Overview
This PR adds a new error case to address mismatches between the connected hardware wallet and the expected wallet, ensuring that devices are correctly verified before further operations.
- Introduces a new DeviceNotMatchWallet exception in the UI and wallet packages.
- Updates API, controller, and remote services to handle an optional walletID parameter for device connection.
- Modifies various hooks and components to incorporate the new error state and message for device-wallet mismatches.
Reviewed Changes
File | Description |
---|---|
packages/neuron-ui/src/exceptions/hardware.ts | Adds DeviceNotMatchWalletException with a static message for localization. |
packages/neuron-wallet/src/controllers/hardware.ts | Updates connectDevice to destructure and check walletID and validate the matching of public keys. |
packages/neuron-wallet/src/exceptions/hardware.ts | Introduces DeviceNotMatchWallet with an error code for wallet-device mismatches. |
packages/neuron-ui/src/utils/enums.ts | Adds a new error code (408) for DeviceNotMatchWallet. |
packages/neuron-ui/src/components/CellManagement/hooks.ts, Receive/VerifyHardwareAddress.tsx, HardwareSign/hooks.ts | Updates import and error handling to account for the new DeviceNotMatchWallet error condition. |
packages/neuron-wallet/src/controllers/api.ts | Adjusts the API handler to pass the walletID parameter when connecting devices. |
packages/neuron-ui/src/services/remote/hardware.ts | Updates the connectDevice API to support an extended payload with walletID. |
Copilot reviewed 15 out of 15 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (1)
packages/neuron-wallet/src/exceptions/hardware.ts:23
- [nitpick] For consistency with the UI exception naming, consider renaming 'DeviceNotMatchWallet' to 'DeviceNotMatchWalletException' and adding a descriptive error message property similar to the pattern used in other exception classes.
export class DeviceNotMatchWallet extends Error {
issue:
Screen-2025-03-07-212433.mp4