Skip to content

Commit

Permalink
chore(monorepo): remove dependency on connect in components and produ…
Browse files Browse the repository at this point in the history
…ct-components
  • Loading branch information
mroz22 committed Feb 21, 2025
1 parent 7ca599d commit 692bf4b
Show file tree
Hide file tree
Showing 29 changed files with 131 additions and 50 deletions.
2 changes: 1 addition & 1 deletion packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"@suite-common/validators": "workspace:*",
"@testing-library/jest-dom": "^6.6.3",
"@trezor/asset-utils": "workspace:*",
"@trezor/connect": "workspace:*",
"@trezor/device-utils": "workspace:*",
"@trezor/dom-utils": "workspace:*",
"@trezor/env-utils": "workspace:*",
"@trezor/react-utils": "workspace:*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import styled, { useTheme } from 'styled-components';

import { DEFAULT_FLAGSHIP_MODEL } from '@suite-common/suite-constants';
import { getNarrowedDeviceModelInternal } from '@suite-common/suite-utils';
import { DeviceModelInternal } from '@trezor/connect';
import { DeviceModelInternal } from '@trezor/device-utils';

import { AnimationWrapper, Shape } from './AnimationPrimitives';
import { resolveStaticPath } from '../../utils/resolveStaticPath';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import styled from 'styled-components';

import { DEFAULT_FLAGSHIP_MODEL } from '@suite-common/suite-constants';
import { getNarrowedDeviceModelInternal } from '@suite-common/suite-utils';
import { DeviceModelInternal } from '@trezor/connect';
import { DeviceModelInternal } from '@trezor/device-utils';

import { AnimationWrapper, Shape } from './AnimationPrimitives';
import { resolveStaticPath } from '../../utils/resolveStaticPath';
Expand Down
2 changes: 1 addition & 1 deletion packages/components/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"path": "../../suite-common/validators"
},
{ "path": "../asset-utils" },
{ "path": "../connect" },
{ "path": "../device-utils" },
{ "path": "../dom-utils" },
{ "path": "../env-utils" },
{ "path": "../react-utils" },
Expand Down
1 change: 1 addition & 0 deletions packages/connect/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
"@trezor/connect-analytics": "workspace:*",
"@trezor/connect-common": "workspace:*",
"@trezor/crypto-utils": "workspace:*",
"@trezor/device-utils": "workspace:*",
"@trezor/protobuf": "workspace:*",
"@trezor/protocol": "workspace:*",
"@trezor/schema-utils": "workspace:*",
Expand Down
Empty file.
6 changes: 1 addition & 5 deletions packages/connect/src/types/device.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { FirmwareType } from '@trezor/device-utils';
import { Descriptor } from '@trezor/transport';

import type { PROTO } from '../constants';
Expand Down Expand Up @@ -26,11 +27,6 @@ export type UnavailableCapability =
| 'update-required'
| 'trezor-connect-outdated';

export enum FirmwareType {
BitcoinOnly = 'bitcoin-only',
Regular = 'regular',
}

export type StaticSessionId = `${string}@${string}:${number}`;

export type DeviceState = {
Expand Down
3 changes: 1 addition & 2 deletions packages/connect/src/types/firmware.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { VersionArray } from '@trezor/device-utils';
import { DeviceModelInternal } from '@trezor/protobuf';
import { Type } from '@trezor/schema-utils';

Expand All @@ -9,8 +10,6 @@ export type FirmwareRange = Record<
}
>;

export type VersionArray = [number, number, number];

export type FirmwareRelease = {
required: boolean;
url: string;
Expand Down
1 change: 1 addition & 0 deletions packages/connect/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
{ "path": "../connect-analytics" },
{ "path": "../connect-common" },
{ "path": "../crypto-utils" },
{ "path": "../device-utils" },
{ "path": "../protobuf" },
{ "path": "../protocol" },
{ "path": "../schema-utils" },
Expand Down
3 changes: 3 additions & 0 deletions packages/connect/tsconfig.lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
{
"path": "../crypto-utils"
},
{
"path": "../device-utils"
},
{
"path": "../protobuf"
},
Expand Down
3 changes: 0 additions & 3 deletions packages/device-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,5 @@
"depcheck": "yarn g:depcheck",
"type-check": "yarn g:tsc --build",
"test:unit": "yarn g:jest -c ../../jest.config.base.js"
},
"dependencies": {
"@trezor/connect": "workspace:*"
}
}
4 changes: 1 addition & 3 deletions packages/device-utils/src/firmwareUtils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { FirmwareType, VersionArray } from '@trezor/connect';

import { isDeviceInBootloaderMode } from './modeUtils';
import { FirmwareVersionString, PartialDevice } from './types';
import { FirmwareType, FirmwareVersionString, PartialDevice, VersionArray } from './types';

export const getFirmwareRevision = (device?: PartialDevice) => device?.features?.revision || '';

Expand Down
1 change: 1 addition & 0 deletions packages/device-utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export * from './firmwareUtils';
export * from './bootloaderUtils';
export * from './modelUtils';
export * from './modeUtils';
export * from './types';
43 changes: 38 additions & 5 deletions packages/device-utils/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,41 @@
import { Device } from '@trezor/connect';
export type FirmwareVersionString = `${number}.${number}.${number}`;

export enum DeviceModelInternal {
T1B1 = 'T1B1',
T2T1 = 'T2T1',
T2B1 = 'T2B1',
T3B1 = 'T3B1',
T3T1 = 'T3T1',
T3W1 = 'T3W1',
UNKNOWN = 'UNKNOWN',
}

export enum FirmwareType {
BitcoinOnly = 'bitcoin-only',
Regular = 'regular',
}

export type VersionArray = [number, number, number];

export type PartialDevice = {
features?: Device['features'];
firmwareType?: Device['firmwareType'];
};
features?: {
bootloader_hash?: string;

export type FirmwareVersionString = `${number}.${number}.${number}`;
major_version?: number;
minor_version?: number;
patch_version?: number;

fw_major?: number;
fw_minor?: number;
fw_patch?: number;

firmwareType?: FirmwareType;

revision?: string;

bootloader_mode?: boolean;
initialize?: boolean;
no_backup?: boolean;
unit_btconly?: boolean;
};
};
2 changes: 1 addition & 1 deletion packages/device-utils/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": { "outDir": "libDev" },
"references": [{ "path": "../connect" }]
"references": []
}
2 changes: 1 addition & 1 deletion packages/product-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"@suite-common/validators": "workspace:*",
"@suite-common/wallet-config": "workspace:*",
"@suite-common/wallet-utils": "workspace:*",
"@trezor/blockchain-link-types": "workspace:*",
"@trezor/components": "workspace:*",
"@trezor/connect": "workspace:*",
"@trezor/dom-utils": "workspace:*",
"@trezor/env-utils": "workspace:*",
"@trezor/react-utils": "workspace:*",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Meta, StoryFn } from '@storybook/react';

import { StoryColumn } from '@trezor/components';
import { DeviceModelInternal } from '@trezor/connect';
import { DeviceModelInternal } from '@trezor/device-utils';

import { ConfirmOnDevice as ConfirmOnDeviceComponent } from './ConfirmOnDevice';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ReactNode } from 'react';
import styled, { css, keyframes } from 'styled-components';

import { ElevationUp } from '@trezor/components';
import { DeviceModelInternal } from '@trezor/connect';
import { DeviceModelInternal } from '@trezor/device-utils';
import { borders, spacingsPx } from '@trezor/theme';

import { ConfirmOnDeviceContent } from './ConfirmOnDeviceContent';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ReactNode } from 'react';
import styled, { css } from 'styled-components';

import { Column, IconButton, Row, Text } from '@trezor/components';
import { DeviceModelInternal } from '@trezor/connect';
import { DeviceModelInternal } from '@trezor/device-utils';
import { borders, spacings, spacingsPx } from '@trezor/theme';

import { RotateDeviceImage } from '../RotateDeviceImage/RotateDeviceImage';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { FormattedMessage } from 'react-intl';
import styled, { useTheme } from 'styled-components';

import { Icon, Image, Row, Text } from '@trezor/components';
import { DeviceModelInternal } from '@trezor/connect';
import { DeviceModelInternal } from '@trezor/device-utils';
import { spacings } from '@trezor/theme';

import { CardButton } from '../CardButton/CardButton';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import styled, { css } from 'styled-components';

import { formInputsMaxLength } from '@suite-common/validators';
import { TooltipProps } from '@trezor/components';
import { DeviceModelInternal, Features } from '@trezor/connect';
import { DeviceModelInternal } from '@trezor/device-utils';
import { setCaretPosition } from '@trezor/dom-utils';
import { useKeyPress } from '@trezor/react-utils';
import { borders, spacingsPx } from '@trezor/theme';
Expand Down Expand Up @@ -64,7 +64,7 @@ export type PassphraseTypeCardProps = {
offerPassphraseOnDevice?: boolean;
singleColModal?: boolean;
deviceModel?: DeviceModelInternal;
deviceBackup?: Features['backup_type'] | null;
deviceBackup?: string | null;
onSubmit: (value: string, passphraseOnDevice?: boolean) => void;
learnMoreTooltipOnClick?: TooltipProps['addon'];
learnMoreTooltipAppendTo?: TooltipProps['appendTo'];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Meta, StoryObj } from '@storybook/react';

import { DeviceModelInternal } from '@trezor/connect';
import { DeviceModelInternal } from '@trezor/device-utils';

import {
RotateDeviceImage as RotateDeviceImageComponent,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';

import { DeviceAnimation } from '@trezor/components';
import { DeviceModelInternal } from '@trezor/connect';
import { DeviceModelInternal } from '@trezor/device-utils';

export type RotateDeviceImageProps = {
deviceModel?: DeviceModelInternal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import styled, { css } from 'styled-components';

import { NetworkSymbol, getCoingeckoId } from '@suite-common/wallet-config';
import { getContractAddressForNetworkSymbol } from '@suite-common/wallet-utils';
import { type TokenInfo } from '@trezor/blockchain-link-types';
import { AssetLogo, useElevation } from '@trezor/components';
import { TokenInfo } from '@trezor/connect';
import { Elevation, borders, mapElevationToBackground, mapElevationToBorder } from '@trezor/theme';

export type TokenIconSetProps = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IconName } from '@trezor/components';
import { DeviceModelInternal } from '@trezor/connect';
import { DeviceModelInternal } from '@trezor/device-utils';

export const mapTrezorModelToIcon: Record<DeviceModelInternal, IconName> = {
[DeviceModelInternal.UNKNOWN]: 'trezorModelOneFilled', // Just to provide something that wont break UI
Expand Down
2 changes: 1 addition & 1 deletion packages/product-components/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
{
"path": "../../suite-common/wallet-utils"
},
{ "path": "../blockchain-link-types" },
{ "path": "../components" },
{ "path": "../connect" },
{ "path": "../dom-utils" },
{ "path": "../env-utils" },
{ "path": "../react-utils" },
Expand Down
12 changes: 1 addition & 11 deletions packages/protobuf/src/messages-schema.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
import { DeviceModelInternal } from '@trezor/device-utils';
import { CloneType, Static, Type } from '@trezor/schema-utils';

export enum DeviceModelInternal {
T1B1 = 'T1B1',
T2T1 = 'T2T1',
T2B1 = 'T2B1',
T3B1 = 'T3B1',
T3T1 = 'T3T1',
T3W1 = 'T3W1',
UNKNOWN = 'UNKNOWN',
}

export type EnumDeviceModelInternal = Static<typeof EnumDeviceModelInternal>;
export const EnumDeviceModelInternal = Type.Enum(DeviceModelInternal);

Expand Down
63 changes: 63 additions & 0 deletions packages/suite-desktop-core/tsconfig.lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,71 @@
},
"include": ["./scripts"],
"references": [
{
"path": "../../suite-common/message-system"
},
{
"path": "../../suite-common/sentry"
},
{
"path": "../../suite-common/suite-constants"
},
{
"path": "../../suite-common/suite-types"
},
{
"path": "../../suite-common/suite-utils"
},
{
"path": "../../suite-common/wallet-config"
},
{
"path": "../coinjoin"
},
{
"path": "../connect"
},
{
"path": "../connect-common"
},
{
"path": "../env-utils"
},
{
"path": "../eslint"
},
{
"path": "../ipc-proxy"
},
{
"path": "../node-utils"
},
{
"path": "../request-manager"
},
{
"path": "../suite"
},
{
"path": "../suite-desktop-api"
},
{
"path": "../transport"
},
{
"path": "../transport-bridge"
},
{
"path": "../urls"
},
{
"path": "../utils"
},
{
"path": "../trezor-user-env-link"
},
{
"path": "../type-utils"
}
]
}
Loading

0 comments on commit 692bf4b

Please sign in to comment.