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

chore(monorepo): remove dependency on connect in components and produ… #17153

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

mroz22
Copy link
Contributor

@mroz22 mroz22 commented Feb 21, 2025

…ct-components

I'd say that components and probably also product-components should not depend on connect.

Copy link

coderabbitai bot commented Feb 21, 2025

Warning

Rate limit exceeded

@mroz22 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 6 minutes and 17 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between f6b52f1 and 224f1da.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (41)
  • packages/components/package.json (1 hunks)
  • packages/components/src/components/animations/DeviceAnimation.tsx (1 hunks)
  • packages/components/src/components/animations/LottieAnimation.tsx (1 hunks)
  • packages/components/tsconfig.json (1 hunks)
  • packages/connect/package.json (1 hunks)
  • packages/connect/src/api/firmware/getBinaryForFirmwareUpgrade.ts (1 hunks)
  • packages/connect/src/api/firmware/parseFirmwareHeaders.ts (1 hunks)
  • packages/connect/src/data/firmwareInfo.ts (1 hunks)
  • packages/connect/src/data/models.ts (1 hunks)
  • packages/connect/src/device/__tests__/checkFirmwareRevision.test.ts (1 hunks)
  • packages/connect/src/device/calculateRevisionForDevice.ts (1 hunks)
  • packages/connect/src/events/device.ts (1 hunks)
  • packages/connect/src/types/api/firmwareUpdate.ts (1 hunks)
  • packages/connect/src/types/device.ts (2 hunks)
  • packages/connect/src/types/firmware.ts (1 hunks)
  • packages/connect/src/types/index.ts (1 hunks)
  • packages/connect/tsconfig.json (1 hunks)
  • packages/connect/tsconfig.lib.json (1 hunks)
  • packages/device-utils/package.json (1 hunks)
  • packages/device-utils/src/customTypes.ts (1 hunks)
  • packages/device-utils/src/firmwareUtils.ts (2 hunks)
  • packages/device-utils/src/index.ts (1 hunks)
  • packages/device-utils/src/modelUtils.ts (1 hunks)
  • packages/device-utils/src/types.ts (1 hunks)
  • packages/device-utils/tests/__fixtures__/modelUtils.ts (1 hunks)
  • packages/device-utils/tsconfig.json (1 hunks)
  • packages/device-utils/tsconfig.lib.json (1 hunks)
  • packages/product-components/package.json (1 hunks)
  • packages/product-components/src/components/ConfirmOnDevice/ConfirmOnDevice.stories.tsx (1 hunks)
  • packages/product-components/src/components/ConfirmOnDevice/ConfirmOnDevice.tsx (1 hunks)
  • packages/product-components/src/components/ConfirmOnDevice/ConfirmOnDeviceContent.tsx (1 hunks)
  • packages/product-components/src/components/PassphraseTypeCard/EnterOnTrezorButton.tsx (1 hunks)
  • packages/product-components/src/components/PassphraseTypeCard/PassphraseTypeCard.tsx (2 hunks)
  • packages/product-components/src/components/RotateDeviceImage/RotateDeviceImage.stories.tsx (1 hunks)
  • packages/product-components/src/components/RotateDeviceImage/RotateDeviceImage.tsx (1 hunks)
  • packages/product-components/src/components/TokenIconSet/TokenIconSet.tsx (1 hunks)
  • packages/product-components/src/utils/mapTrezorModelToIcon.ts (1 hunks)
  • packages/product-components/tsconfig.json (1 hunks)
  • packages/protobuf/scripts/protobuf-types.ts (1 hunks)
  • packages/protobuf/src/index.ts (0 hunks)
  • packages/suite-desktop-core/tsconfig.lib.json (1 hunks)

Walkthrough

This pull request systematically replaces references to the @trezor/connect package with references to @trezor/device-utils and other external modules across multiple packages. Changes include removing @trezor/connect as a dependency and adding @trezor/device-utils or @trezor/blockchain-link-types where appropriate. Import statements in various TypeScript and TSX files have been updated to reflect these new sources, ensuring that types such as DeviceModelInternal, FirmwareType, and VersionArray are imported from the updated modules. Additionally, local type declarations and enums related to firmware and device models have been removed in favor of the imported definitions. Several configuration files, such as various tsconfig.json and library-specific configuration files, have been updated to adjust module path references and project dependencies accordingly. These changes align the codebase’s dependencies and type sources across its multiple components and packages.


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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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

@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: 0

🧹 Nitpick comments (5)
packages/product-components/src/components/TokenIconSet/TokenIconSet.tsx (2)

23-23: Simplify the grid layout configuration.

The ternary operator in minmax(${$length > 1 ? '1px' : '6px'}, 6px) is redundant since this CSS block only executes when $length > 1.

-            grid-template-columns: repeat(auto-fit, minmax(${$length > 1 ? '1px' : '6px'}, 6px));
+            grid-template-columns: repeat(auto-fit, minmax(1px, 6px));

55-63: Add error handling and type narrowing.

Consider adding error handling for invalid inputs and type narrowing for optional fields:

             {visibleTokens.map(token => (
+                // Ensure contract address exists
+                token.contract ? (
                 <AssetLogo
                     key={token.contract}
                     size={20}
                     coingeckoId={coingeckoId ?? ''}
                     contractAddress={getContractAddressForNetworkSymbol(symbol, token.contract)}
-                    placeholder={token.symbol?.toUpperCase() ?? ''}
+                    placeholder={token.symbol ? token.symbol.toUpperCase() : ''}
                     placeholderWithTooltip={false}
                 />
+                ) : null
             ))}
packages/device-utils/src/types.ts (2)

3-11: Consider adding JSDoc comments for device models.

While the enum values are self-explanatory for those familiar with Trezor devices, adding documentation would help new developers understand what each model represents.

 export enum DeviceModelInternal {
+    /** Trezor One with Bitcoin-only firmware */
     T1B1 = 'T1B1',
+    /** Trezor T with regular firmware */
     T2T1 = 'T2T1',
+    /** Trezor T with Bitcoin-only firmware */
     T2B1 = 'T2B1',
+    /** Trezor Safe 3 with Bitcoin-only firmware */
     T3B1 = 'T3B1',
+    /** Trezor Safe 3 with regular firmware */
     T3T1 = 'T3T1',
+    /** Trezor Safe 3 wireless variant */
     T3W1 = 'T3W1',
+    /** Unknown device model */
     UNKNOWN = 'UNKNOWN',
 }

20-41: Consider grouping related version fields.

The features object has multiple version-related fields that could be grouped for better organization.

 export type PartialDevice = {
     features?: {
         bootloader_hash?: string;

-        major_version?: number;
-        minor_version?: number;
-        patch_version?: number;
-
-        fw_major?: number;
-        fw_minor?: number;
-        fw_patch?: number;
+        version?: {
+            major?: number;
+            minor?: number;
+            patch?: number;
+        };
+        firmware?: {
+            major?: number;
+            minor?: number;
+            patch?: number;
+        };

         firmwareType?: FirmwareType;

         revision?: string;

         bootloader_mode?: boolean;
         initialize?: boolean;
         no_backup?: boolean;
         unit_btconly?: boolean;
     };
 };
packages/product-components/src/components/PassphraseTypeCard/PassphraseTypeCard.tsx (1)

67-67: Consider using a more specific type for deviceBackup.

The type change from Features['backup_type'] | null to string | null makes the type less specific. Since this prop is used to check for specific values (e.g., deviceBackup === 'Bip39'), consider using a union type to ensure type safety:

-    deviceBackup?: string | null;
+    deviceBackup?: 'Bip39' | null;
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e0dde30 and 692bf4b.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (27)
  • packages/components/package.json (1 hunks)
  • packages/components/src/components/animations/DeviceAnimation.tsx (1 hunks)
  • packages/components/src/components/animations/LottieAnimation.tsx (1 hunks)
  • packages/components/tsconfig.json (1 hunks)
  • packages/connect/package.json (1 hunks)
  • packages/connect/src/types/device.ts (1 hunks)
  • packages/connect/src/types/firmware.ts (1 hunks)
  • packages/connect/tsconfig.json (1 hunks)
  • packages/connect/tsconfig.lib.json (1 hunks)
  • packages/device-utils/package.json (0 hunks)
  • packages/device-utils/src/firmwareUtils.ts (1 hunks)
  • packages/device-utils/src/index.ts (1 hunks)
  • packages/device-utils/src/types.ts (1 hunks)
  • packages/device-utils/tsconfig.json (1 hunks)
  • packages/product-components/package.json (1 hunks)
  • packages/product-components/src/components/ConfirmOnDevice/ConfirmOnDevice.stories.tsx (1 hunks)
  • packages/product-components/src/components/ConfirmOnDevice/ConfirmOnDevice.tsx (1 hunks)
  • packages/product-components/src/components/ConfirmOnDevice/ConfirmOnDeviceContent.tsx (1 hunks)
  • packages/product-components/src/components/PassphraseTypeCard/EnterOnTrezorButton.tsx (1 hunks)
  • packages/product-components/src/components/PassphraseTypeCard/PassphraseTypeCard.tsx (2 hunks)
  • packages/product-components/src/components/RotateDeviceImage/RotateDeviceImage.stories.tsx (1 hunks)
  • packages/product-components/src/components/RotateDeviceImage/RotateDeviceImage.tsx (1 hunks)
  • packages/product-components/src/components/TokenIconSet/TokenIconSet.tsx (1 hunks)
  • packages/product-components/src/utils/mapTrezorModelToIcon.ts (1 hunks)
  • packages/product-components/tsconfig.json (1 hunks)
  • packages/protobuf/src/messages-schema.ts (1 hunks)
  • packages/suite-desktop-core/tsconfig.lib.json (1 hunks)
💤 Files with no reviewable changes (1)
  • packages/device-utils/package.json
✅ Files skipped from review due to trivial changes (10)
  • packages/product-components/src/components/PassphraseTypeCard/EnterOnTrezorButton.tsx
  • packages/components/src/components/animations/LottieAnimation.tsx
  • packages/product-components/src/components/RotateDeviceImage/RotateDeviceImage.stories.tsx
  • packages/product-components/src/components/ConfirmOnDevice/ConfirmOnDeviceContent.tsx
  • packages/components/src/components/animations/DeviceAnimation.tsx
  • packages/product-components/src/components/RotateDeviceImage/RotateDeviceImage.tsx
  • packages/product-components/src/utils/mapTrezorModelToIcon.ts
  • packages/device-utils/src/firmwareUtils.ts
  • packages/product-components/src/components/ConfirmOnDevice/ConfirmOnDevice.stories.tsx
  • packages/product-components/src/components/ConfirmOnDevice/ConfirmOnDevice.tsx
⏰ Context from checks skipped due to timeout of 90000ms (16)
  • GitHub Check: build-deploy
  • GitHub Check: build-deploy
  • GitHub Check: run-desktop-tests (@group=wallet, trezor-user-env-unix bitcoin-regtest)
  • GitHub Check: run-desktop-tests (@group=other, trezor-user-env-unix)
  • GitHub Check: EAS Update
  • GitHub Check: run-desktop-tests (@group=passphrase, trezor-user-env-unix)
  • GitHub Check: build
  • GitHub Check: transport-e2e-test
  • GitHub Check: run-desktop-tests (@group=settings, trezor-user-env-unix bitcoin-regtest)
  • GitHub Check: Setup and Cache Dependencies
  • GitHub Check: run-desktop-tests (@group=device-management, trezor-user-env-unix)
  • GitHub Check: test
  • GitHub Check: Analyze with CodeQL (javascript)
  • GitHub Check: prepare_android_test_app
  • GitHub Check: run-desktop-tests (@group=suite, trezor-user-env-unix)
  • GitHub Check: Socket Security: Pull Request Alerts
🔇 Additional comments (17)
packages/product-components/src/components/TokenIconSet/TokenIconSet.tsx (1)

5-5: LGTM! Import change aligns with PR objectives.

The change successfully removes the dependency on @trezor/connect by importing the TokenInfo type from @trezor/blockchain-link-types. The explicit type import is a good TypeScript practice.

packages/device-utils/src/index.ts (1)

5-5: LGTM! Export statement aligns with PR objectives.

The addition of export * from './types'; supports the centralization of device-related types in the device-utils package, which is a key part of removing the connect dependency.

packages/device-utils/src/types.ts (2)

1-1: LGTM! Well-defined version string type.

The template literal type ensures version strings follow the correct format of three dot-separated numbers.


13-16: LGTM! Clear firmware type enum.

The enum values accurately represent the two firmware variants.

packages/connect/src/types/firmware.ts (1)

1-1: LGTM! Import aligns with type centralization.

Importing VersionArray from device-utils instead of defining it locally reduces duplication and centralizes type definitions.

packages/connect/src/types/device.ts (1)

1-1: LGTM! Import aligns with type centralization.

Importing FirmwareType from device-utils instead of defining it locally reduces duplication and centralizes type definitions.

packages/product-components/src/components/PassphraseTypeCard/PassphraseTypeCard.tsx (1)

8-8: LGTM!

The import of DeviceModelInternal from @trezor/device-utils aligns with the PR objective of removing dependency on @trezor/connect.

packages/protobuf/src/messages-schema.ts (1)

1-1: LGTM!

The import of DeviceModelInternal from @trezor/device-utils and removal of the local enum aligns with the PR objective of centralizing device-related types.

packages/device-utils/tsconfig.json (1)

4-4: LGTM!

Removing the reference to @trezor/connect is correct as it prevents circular dependencies and aligns with the architectural goal of making device-utils independent.

packages/connect/tsconfig.json (1)

11-11: LGTM!

Adding a reference to @trezor/device-utils correctly establishes the new dependency relationship and maintains proper dependency direction.

packages/product-components/tsconfig.json (1)

15-34: Updated References Array Aligns with PR Objectives

The references array has been updated to include the new dependency reference "../blockchain-link-types" (line 25) and no longer includes the "../connect" reference. This change correctly aligns the tsconfig with the intended removal of the obsolete connect dependency in product-components.

packages/components/tsconfig.json (1)

29-30: TSConfig Path Reference Updated

The reference for "device-utils" (line 30) has been added as a replacement for the removed "connect" dependency. This update improves the modularity of the components package and is in line with the PR objectives.

packages/connect/tsconfig.lib.json (1)

27-29: Added Device-Utils Reference in Connect

A new reference to "../device-utils" (lines 27–29) has been introduced. This ensures that the connect package now leverages device-related utilities from the updated module. Please confirm that all device-related types and functionality now originate from @trezor/device-utils.

packages/suite-desktop-core/tsconfig.lib.json (1)

8-74: Extensive References Array Update – Verify Connect Dependency

The references array has been significantly extended to include many new modules (e.g. message-system, sentry, suite-types, etc.), which should enhance cross-package type-checking and integration. One point to note: the reference to "../connect" (present around lines 29–32) remains in the configuration. Given that the PR’s main focus was on removing the connect dependency in components and product-components, please verify that its retention in suite-desktop-core is intentional and that no unintended dependencies persist.

packages/product-components/package.json (1)

22-22: Dependencies Updated Correctly

The dependency on @trezor/blockchain-link-types has been added (line 22) and the obsolete @trezor/connect dependency has been removed. This update is consistent with the broader effort to eliminate the connect dependency and streamline the module imports. Ensure all affected import statements in the codebase have been updated accordingly.

packages/components/package.json (1)

29-29: New Device Utils Dependency Added
The new dependency on @trezor/device-utils has been correctly added to replace the removed @trezor/connect dependency. This update aligns with the PR objectives by reducing unnecessary coupling and increasing modularity.

packages/connect/package.json (1)

89-89: Added Device Utils Dependency in Connect Package
The addition of @trezor/device-utils in the dependencies ensures that device-related functionalities and type definitions are centralized. This change supports the broader effort to shift from @trezor/connect and enhance consistency across the codebase.

Copy link

github-actions bot commented Feb 21, 2025

🚀 Expo preview is ready!

  • Project → trezor-suite-preview
  • Platforms → android, ios
  • Scheme → trezorsuitelite
  • Runtime Version → 26
  • More info

Learn more about 𝝠 Expo Github Action

import { CloneType, Static, Type } from '@trezor/schema-utils';

export enum DeviceModelInternal {
Copy link
Member

Choose a reason for hiding this comment

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

This is an auto-generated file, to do this the scripts would need updating

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep, I missed that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

and I can't say I like it very much making this types generation script even more complex :(

@@ -19,8 +19,8 @@
"@suite-common/validators": "workspace:*",
"@suite-common/wallet-config": "workspace:*",
"@suite-common/wallet-utils": "workspace:*",
"@trezor/blockchain-link-types": "workspace:*",
Copy link
Member

Choose a reason for hiding this comment

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

@trezor/device-utils should be here too right?

@mroz22 mroz22 force-pushed the components-should-not-depend-on-connect branch from 692bf4b to f6b52f1 Compare February 23, 2025 12:15
Copy link

@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

🧹 Nitpick comments (2)
packages/device-utils/src/customTypes.ts (1)

1-9: LGTM! Consider adding JSDoc comments.

The DeviceModelInternal enum is well-structured with clear naming. Consider adding JSDoc comments to document:

  • The purpose of this enum
  • What each device model represents (T1B1, T2T1, etc.)
  • When UNKNOWN is used
packages/device-utils/package.json (1)

9-9: New "build:lib" Script Addition

The new "build:lib" script successfully chains the commands to clean the lib directory, build the TypeScript project with tsconfig.lib.json, and update import statements using the custom replace-imports.sh script. Verify that the relative path (../../scripts/replace-imports.sh) is correct within the monorepo structure and that the script has the necessary execution permissions.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 692bf4b and f6b52f1.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (45)
  • packages/components/package.json (1 hunks)
  • packages/components/src/components/animations/DeviceAnimation.tsx (1 hunks)
  • packages/components/src/components/animations/LottieAnimation.tsx (1 hunks)
  • packages/components/tsconfig.json (2 hunks)
  • packages/connect/package.json (1 hunks)
  • packages/connect/src/api/firmware/getBinaryForFirmwareUpgrade.ts (1 hunks)
  • packages/connect/src/api/firmware/parseFirmwareHeaders.ts (1 hunks)
  • packages/connect/src/data/firmwareInfo.ts (1 hunks)
  • packages/connect/src/data/models.ts (1 hunks)
  • packages/connect/src/device/__tests__/checkFirmwareRevision.test.ts (1 hunks)
  • packages/connect/src/device/calculateRevisionForDevice.ts (1 hunks)
  • packages/connect/src/events/device.ts (1 hunks)
  • packages/connect/src/types/api/firmwareUpdate.ts (1 hunks)
  • packages/connect/src/types/device.ts (2 hunks)
  • packages/connect/src/types/firmware.ts (1 hunks)
  • packages/connect/src/types/index.ts (1 hunks)
  • packages/connect/tsconfig.json (1 hunks)
  • packages/connect/tsconfig.lib.json (1 hunks)
  • packages/device-utils/package.json (1 hunks)
  • packages/device-utils/src/customTypes.ts (1 hunks)
  • packages/device-utils/src/firmwareUtils.ts (2 hunks)
  • packages/device-utils/src/index.ts (1 hunks)
  • packages/device-utils/src/modelUtils.ts (1 hunks)
  • packages/device-utils/src/types.ts (1 hunks)
  • packages/device-utils/tests/__fixtures__/modelUtils.ts (1 hunks)
  • packages/device-utils/tsconfig.json (1 hunks)
  • packages/device-utils/tsconfig.lib.json (1 hunks)
  • packages/product-components/package.json (1 hunks)
  • packages/product-components/src/components/ConfirmOnDevice/ConfirmOnDevice.stories.tsx (1 hunks)
  • packages/product-components/src/components/ConfirmOnDevice/ConfirmOnDevice.tsx (1 hunks)
  • packages/product-components/src/components/ConfirmOnDevice/ConfirmOnDeviceContent.tsx (1 hunks)
  • packages/product-components/src/components/PassphraseTypeCard/EnterOnTrezorButton.tsx (1 hunks)
  • packages/product-components/src/components/PassphraseTypeCard/PassphraseTypeCard.tsx (2 hunks)
  • packages/product-components/src/components/RotateDeviceImage/RotateDeviceImage.stories.tsx (1 hunks)
  • packages/product-components/src/components/RotateDeviceImage/RotateDeviceImage.tsx (1 hunks)
  • packages/product-components/src/components/TokenIconSet/TokenIconSet.tsx (1 hunks)
  • packages/product-components/src/utils/mapTrezorModelToIcon.ts (1 hunks)
  • packages/product-components/tsconfig.json (1 hunks)
  • packages/protobuf/messages.json (2 hunks)
  • packages/protobuf/scripts/protobuf-types.ts (1 hunks)
  • packages/protobuf/src/index.ts (0 hunks)
  • packages/protobuf/src/messages-schema.ts (1 hunks)
  • packages/protobuf/src/messages.ts (5 hunks)
  • packages/suite-desktop-core/tsconfig.lib.json (1 hunks)
  • submodules/trezor-common (1 hunks)
💤 Files with no reviewable changes (1)
  • packages/protobuf/src/index.ts
✅ Files skipped from review due to trivial changes (9)
  • packages/connect/src/data/models.ts
  • packages/connect/src/device/tests/checkFirmwareRevision.test.ts
  • packages/device-utils/tests/fixtures/modelUtils.ts
  • packages/connect/src/api/firmware/parseFirmwareHeaders.ts
  • packages/device-utils/tsconfig.lib.json
  • packages/connect/src/events/device.ts
  • packages/device-utils/src/modelUtils.ts
  • submodules/trezor-common
  • packages/connect/src/data/firmwareInfo.ts
🚧 Files skipped from review as they are similar to previous changes (23)
  • packages/device-utils/tsconfig.json
  • packages/connect/tsconfig.lib.json
  • packages/connect/tsconfig.json
  • packages/components/package.json
  • packages/product-components/src/components/PassphraseTypeCard/EnterOnTrezorButton.tsx
  • packages/connect/package.json
  • packages/product-components/src/components/RotateDeviceImage/RotateDeviceImage.stories.tsx
  • packages/product-components/src/components/RotateDeviceImage/RotateDeviceImage.tsx
  • packages/product-components/src/components/ConfirmOnDevice/ConfirmOnDevice.tsx
  • packages/product-components/src/components/ConfirmOnDevice/ConfirmOnDevice.stories.tsx
  • packages/product-components/src/components/ConfirmOnDevice/ConfirmOnDeviceContent.tsx
  • packages/components/src/components/animations/LottieAnimation.tsx
  • packages/device-utils/src/firmwareUtils.ts
  • packages/components/src/components/animations/DeviceAnimation.tsx
  • packages/components/tsconfig.json
  • packages/product-components/src/components/PassphraseTypeCard/PassphraseTypeCard.tsx
  • packages/connect/src/types/firmware.ts
  • packages/product-components/tsconfig.json
  • packages/product-components/package.json
  • packages/product-components/src/components/TokenIconSet/TokenIconSet.tsx
  • packages/product-components/src/utils/mapTrezorModelToIcon.ts
  • packages/protobuf/src/messages-schema.ts
  • packages/suite-desktop-core/tsconfig.lib.json
⏰ Context from checks skipped due to timeout of 90000ms (21)
  • GitHub Check: PR-check / node-authorizeCoinjoin cancelCoinjoinAuthorization passphrase unlockPath setBusy checkFirmwareAuthenticity keepSession cancel.test info.test resetDevice-api
  • GitHub Check: PR-check / node-override init-api-flaky
  • GitHub Check: PR-check / web-override init-api-flaky
  • GitHub Check: PR-check / web-authorizeCoinjoin cancelCoinjoinAuthorization passphrase unlockPath setBusy checkFirmwareAuthenticity keepSession cancel.test info.test resetDevice-api
  • GitHub Check: build-deploy
  • GitHub Check: build-deploy
  • GitHub Check: run-desktop-tests (@group=wallet, trezor-user-env-unix bitcoin-regtest)
  • GitHub Check: run-desktop-tests (@group=other, trezor-user-env-unix)
  • GitHub Check: EAS Update
  • GitHub Check: run-desktop-tests (@group=passphrase, trezor-user-env-unix)
  • GitHub Check: build-web
  • GitHub Check: run-desktop-tests (@group=settings, trezor-user-env-unix bitcoin-regtest)
  • GitHub Check: prepare_android_test_app
  • GitHub Check: Setup and Cache Dependencies
  • GitHub Check: build-web
  • GitHub Check: run-desktop-tests (@group=device-management, trezor-user-env-unix)
  • GitHub Check: transport-e2e-test
  • GitHub Check: Analyze with CodeQL (javascript)
  • GitHub Check: test
  • GitHub Check: run-desktop-tests (@group=suite, trezor-user-env-unix)
  • GitHub Check: Socket Security: Pull Request Alerts
🔇 Additional comments (13)
packages/protobuf/src/messages.ts (1)

1781-1783:

❓ Verification inconclusive

Approve the type change but verify impact.

The change makes the mac property required in UnlockedPathRequest responses, which improves type safety by ensuring the property is always present. However, this is a breaking change that could affect code expecting mac to be optional.

Run the following script to find any code that might be affected by this change:


🏁 Script executed:

#!/bin/bash
# Description: Find code that might be affected by the UnlockedPathRequest.mac change
# Search for UnlockedPathRequest usage
rg -A 5 "UnlockedPathRequest" 

# Search for potential destructuring of the mac property
rg "(?:\{[^}]*mac[\s,}]|\.mac\b)"

Length of output: 4112


Type Change Approval – Please Verify Downstream Usage

The change to make the mac property in UnlockedPathRequest required improves type safety since responses will now always include this field. However, since some parts of the code (e.g., in packages/connect/src/device/DeviceCommands.ts and related usage in packages/protobuf/messages.json and packages/protobuf/src/messages-schema.ts) may have been written with the assumption that mac could be optional, this constitutes a breaking change. Please verify that all consumers of UnlockedPathRequest correctly handle the now-mandatory mac field.

  • File Affected: packages/protobuf/src/messages.ts (line 1782)
  • Impact: The response type now enforces the presence of mac; ensure that downstream code (e.g., in DeviceCommands.ts and unlockPath.ts) does not assume its absence.
  • Action: Double-check how UnlockedPathRequest is used across the codebase to prevent any runtime issues due to the required property.
packages/protobuf/messages.json (2)

2964-2971: New Field Added: "return_empty_state" in DebugLinkGetState

This change introduces a new boolean field "return_empty_state" with ID 4 and a default value of false. It provides additional control for state retrieval. Please verify that the documentation and corresponding TypeScript schema (in messages-schema.ts) have been updated accordingly so that downstream consumers can correctly interpret and use this field.


5127-5135: Updated Field Requirement: "mac" Field in UnlockedPathRequest

The "mac" field in the UnlockedPathRequest message now explicitly includes "rule": "required", enforcing that a MAC value must be provided. Ensure that all clients sending this message have been updated to provide a valid MAC. It’s also recommended to double-check that the change is consistently reflected in the TypeScript schema and that any related tests are updated.

packages/device-utils/src/index.ts (1)

5-6: LGTM! The new exports align with the PR objective.

The addition of these exports from types and customTypes modules supports the goal of moving type definitions from @trezor/connect to @trezor/device-utils.

packages/connect/src/device/calculateRevisionForDevice.ts (1)

1-1: LGTM! Import change aligns with PR objective.

The change to import VersionArray from @trezor/device-utils supports the goal of centralizing type definitions while preserving the existing functionality.

packages/connect/src/types/api/firmwareUpdate.ts (1)

1-1: LGTM! Import change aligns with PR objective.

The change to import VersionArray from @trezor/device-utils supports the goal of centralizing type definitions while maintaining the existing type structure.

packages/connect/src/types/index.ts (1)

46-46: LGTM! Export statement aligns with PR objectives.

The export of FirmwareType and VersionArray from @trezor/device-utils aligns with the PR's goal of reducing dependency on connect by centralizing these types in the device-utils package.

packages/device-utils/src/types.ts (3)

1-8: LGTM! Well-structured type definitions.

The template literal type FirmwareVersionString, enum FirmwareType, and tuple type VersionArray provide strong type safety and clear semantics for version handling.


10-60: LGTM! Comprehensive version and bootloader state handling.

The FeaturesNarrowing type union provides thorough type safety for different device states and version combinations.


62-62:

❓ Verification inconclusive

Address the TODO comment regarding code duplication.

The comment indicates potential code duplication with the protobuf package. Consider either:

  1. Moving these types to the protobuf package
  2. Creating a shared package for common types
  3. Documenting why the duplication is necessary

🏁 Script executed:

#!/bin/bash
# Check if these types exist in the protobuf package
rg -A 5 "type PartialDevice" packages/protobuf/src/messages

Length of output: 132


Attention: Code Duplication in Type Definitions

The TODO comment notes that these types were copy-pasted from packages/protobuf/src/messages, but our search suggests that the expected file path doesn’t exist. Please verify whether duplicate types (such as PartialDevice) actually reside in the protobuf package—or if the reference is outdated. Based on your findings, consider the following actions:

  • If the duplicate types are maintained in an updated location within the protobuf package, refactor by moving these types there.
  • Alternatively, create a shared package for common types.
  • If the duplication is intentional, document the rationale clearly.
packages/connect/src/api/firmware/getBinaryForFirmwareUpgrade.ts (1)

1-1: LGTM! Import statement updated correctly.

The import of VersionArray from @trezor/device-utils aligns with the PR's goal of centralizing types while maintaining the function's robust version comparison and error handling.

packages/connect/src/types/device.ts (1)

1-1: LGTM! Type imports and exports updated correctly.

The imports of FeaturesNarrowing and FirmwareType, and the export of DeviceModelInternal from @trezor/device-utils align with the PR's goal of centralizing device-related types.

Also applies to: 151-151

packages/device-utils/package.json (1)

7-8: Dependency Section Clean-up Validated

The absence of a "dependencies" section indicates that the dependency on @trezor/connect has been removed as per the PR objectives. Please double-check that no module in the package still relies on it.

@@ -184,7 +184,7 @@ const createCustomTypes = () => {
lines.push(`export type ${UINT_TYPE} = string | number;`, '');
lines.push('// custom type sint32/64');
lines.push(`export type ${SINT_TYPE} = string | number;`, '');
lines.push(readPatch('customTypes.ts'), '');
lines.push(readPatch('../../../device-utils/src/customTypes.ts'), '');
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Consider using package imports instead of relative paths.

The relative path ../../../device-utils/src/customTypes.ts traverses outside the package boundary, which can be fragile if the directory structure changes. Consider importing from the package directly using @trezor/device-utils instead.

-    lines.push(readPatch('../../../device-utils/src/customTypes.ts'), '');
+    lines.push(readPatch('@trezor/device-utils/lib/customTypes'), '');

Additionally, verify that this dependency is declared in your package.json:


🏁 Script executed:

#!/bin/bash
# Description: Check if @trezor/device-utils is properly declared as a dependency

# Check package.json for the dependency
jq '.dependencies["@trezor/device-utils"] // .devDependencies["@trezor/device-utils"]' packages/protobuf/package.json

Length of output: 124


Switch to package import and declare dependency

The relative path ../../../device-utils/src/customTypes.ts is fragile and may break if the directory structure changes. Instead, import custom types directly from the @trezor/device-utils package. However, the dependency check indicates that @trezor/device-utils is currently not declared in packages/protobuf/package.json.

  • Action Items:
    • Update the import in packages/protobuf/scripts/protobuf-types.ts to:
      -    lines.push(readPatch('../../../device-utils/src/customTypes.ts'), '');
      +    lines.push(readPatch('@trezor/device-utils/lib/customTypes'), '');
    • Add @trezor/device-utils as a dependency in packages/protobuf/package.json (or confirm it is provided via the monorepo's dependency management).
📝 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
lines.push(readPatch('../../../device-utils/src/customTypes.ts'), '');
lines.push(readPatch('@trezor/device-utils/lib/customTypes'), '');

@mroz22 mroz22 added the no-project This label is used to specify that PR doesn't need to be added to a project label Feb 23, 2025
@mroz22 mroz22 force-pushed the components-should-not-depend-on-connect branch from f6b52f1 to 0159c6f Compare February 23, 2025 19:30
@mroz22 mroz22 force-pushed the components-should-not-depend-on-connect branch from 0159c6f to 224f1da Compare February 23, 2025 19:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-project This label is used to specify that PR doesn't need to be added to a project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants