Skip to content

Commit ac3d176

Browse files
mroz22peter-sanderson
authored andcommitted
feat: introduce internal_model UNKNOWN, add support for it in the Suite
wip(suite): implement UNKNOWN internal model
1 parent c5b661d commit ac3d176

File tree

32 files changed

+95
-20
lines changed

32 files changed

+95
-20
lines changed

packages/components/src/components/Image/images.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export const SVG_IMAGES = {
1111
DEVICE_CONFIRM_TREZOR_T3B1: 'device-confirm-trezor-t3b1.svg',
1212
DEVICE_CONFIRM_TREZOR_T3T1: 'device-confirm-trezor-t3t1.svg',
1313
DEVICE_CONFIRM_TREZOR_T3W1: 'device-confirm-trezor-t3w1.svg',
14+
DEVICE_CONFIRM_TREZOR_UNKNOWN: 'device-confirm-trezor-unknown.svg',
1415
SPINNER: 'spinner.svg',
1516
SPINNER_GREY: 'spinner-grey.svg',
1617
SPINNER_LIGHT_GREY: 'spinner-light-grey.svg',
@@ -81,6 +82,8 @@ export const PNG_IMAGES = {
8182
UNDERSTAND_2x: '[email protected]',
8283
WALLET: 'wallet.png',
8384
WALLET_2x: '[email protected]',
85+
DONT_DISCONNECT_TREZOR_UNKNOWN: 'dont-disconnect-trezor-unknown.png',
86+
DONT_DISCONNECT_TREZOR_UNKNOWN_2x: '[email protected]',
8487
DONT_DISCONNECT_TREZOR_T2T1: 'dont-disconnect-trezor-t2t1.png',
8588
DONT_DISCONNECT_TREZOR_T2T1_2x: '[email protected]',
8689
DONT_DISCONNECT_TREZOR_T1B1: 'dont-disconnect-trezor-t1b1.png',
@@ -93,6 +96,8 @@ export const PNG_IMAGES = {
9396
DONT_DISCONNECT_TREZOR_T3T1_2x: '[email protected]',
9497
DONT_DISCONNECT_TREZOR_T3W1: 'dont-disconnect-trezor-t3w1.png',
9598
DONT_DISCONNECT_TREZOR_T3W1_2x: '[email protected]',
99+
TREZOR_UNKNOWN: 'trezor-unknown.png',
100+
TREZOR_UNKNOWN_2x: '[email protected]',
96101
TREZOR_T1B1: 'trezor-t1b1.png',
97102
TREZOR_T1B1_2x: '[email protected]',
98103
TREZOR_T2T1: 'trezor-t2t1.png',
@@ -105,6 +110,8 @@ export const PNG_IMAGES = {
105110
TREZOR_T3T1_2x: '[email protected]',
106111
TREZOR_T3W1: 'trezor-t3w1.png',
107112
TREZOR_T3W1_2x: '[email protected]',
113+
TREZOR_UNKNOWN_LARGE: 'trezor-unknown-large.png',
114+
TREZOR_UNKNOWN_LARGE_2x: '[email protected]',
108115
TREZOR_T1B1_LARGE: 'trezor-t1b1-large.png',
109116
TREZOR_T1B1_LARGE_2x: '[email protected]',
110117
TREZOR_T2T1_LARGE: 'trezor-t2t1-large.png',
@@ -117,6 +124,8 @@ export const PNG_IMAGES = {
117124
TREZOR_T3T1_LARGE_2x: '[email protected]',
118125
TREZOR_T3W1_LARGE: 'trezor-t3w1-large.png',
119126
TREZOR_T3W1_LARGE_2x: '[email protected]',
127+
TREZOR_UNKNOWN_GHOST: 'trezor-unknown-ghost.png',
128+
TREZOR_UNKNOWN_GHOST_2x: '[email protected]',
120129
TREZOR_T1B1_GHOST: 'trezor-t1b1-ghost.png',
121130
TREZOR_T1B1_GHOST_2x: '[email protected]',
122131
TREZOR_T2T1_GHOST: 'trezor-t2t1-ghost.png',

packages/connect/src/api/common/__fixtures__/paramsValidator.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,8 @@ export const validateParams = [
170170
},
171171
];
172172

173-
const DEFAULT_RANGE = {
173+
const DEFAULT_RANGE: FirmwareRange = {
174+
UNKNOWN: { min: '0', max: '0' },
174175
T1B1: { min: '1.0.0', max: '0' },
175176
T2T1: { min: '2.0.0', max: '0' },
176177
T2B1: { min: '2.0.0', max: '0' },
@@ -179,8 +180,13 @@ const DEFAULT_RANGE = {
179180
T3W1: { min: '2.0.0', max: '0' },
180181
};
181182

182-
const DEFAULT_COIN_INFO = {
183+
const DEFAULT_COIN_INFO: {
184+
support: Record<DeviceModelInternal, string>;
185+
shortcut: string;
186+
type: string;
187+
} = {
183188
support: {
189+
UNKNOWN: '0.0.0',
184190
T1B1: '1.6.2',
185191
T2T1: '2.1.0',
186192
T2B1: '2.0.0',

packages/connect/src/api/ethereum/ethereumDefinitions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ export const ethereumNetworkInfoFromDefinition = (
156156
T3B1: '2.0.0',
157157
T3T1: '2.0.0',
158158
T3W1: '2.0.0',
159+
UNKNOWN: '0.0.0',
159160
},
160161
blockchainLink: undefined,
161162
});

packages/connect/src/core/AbstractMethod.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export interface MethodInfo {
3535
}
3636

3737
export const DEFAULT_FIRMWARE_RANGE: FirmwareRange = {
38+
UNKNOWN: { min: '1.0.0', max: '0' },
3839
T1B1: { min: '1.0.0', max: '0' },
3940
T2T1: { min: '2.0.0', max: '0' },
4041
T2B1: { min: '2.6.1', max: '0' },

packages/connect/src/data/deviceAuthenticityConfigTypes.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ type ModelPubKeys = Static<typeof ModelPubKeys>;
1212

1313
const ModelsWithKeys = Type.Exclude(
1414
Type.KeyOfEnum(PROTO.DeviceModelInternal),
15-
Type.Union([Type.Literal('T1B1'), Type.Literal('T2T1')]),
15+
Type.Union([Type.Literal('T1B1'), Type.Literal('T2T1'), Type.Literal('UNKNOWN')]),
1616
);
1717

1818
const ModelsWithoutKeys = Type.Extract(
1919
Type.KeyOfEnum(PROTO.DeviceModelInternal),
20-
Type.Union([Type.Literal('T1B1'), Type.Literal('T2T1')]),
20+
Type.Union([Type.Literal('T1B1'), Type.Literal('T2T1'), Type.Literal('UNKNOWN')]),
2121
);
2222

2323
const ModelPubKeys = Type.Intersect([

packages/connect/src/data/models.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,8 @@ export const models: Record<DeviceModelInternal, ModelConfig> = {
4646
'4': 'Majestic Bitcoin', // TODO T3W1
4747
},
4848
},
49+
UNKNOWN: {
50+
name: 'Unknown',
51+
colors: safe3Model.colors, // just in case
52+
},
4953
};

packages/connect/src/device/Device.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import {
4848
FirmwareHashCheckResult,
4949
FirmwareHashCheckError,
5050
DeviceUniquePath,
51+
DeviceModelInternal,
5152
} from '../types';
5253
import { models } from '../data/models';
5354
import { getLanguage } from '../data/getLanguage';
@@ -960,13 +961,18 @@ export class Device extends TypedEmitter<DeviceEvents> {
960961
const revision = parseRevision(feat);
961962
feat.revision = revision;
962963

964+
feat.model = 'maow';
965+
// @ts-expect-error // Todo: dont forget to remove it
966+
feat.internal_model = 'brambora';
967+
963968
// Fix missing model and internal_model in older fw, model has to be fixed first
964969
// 1. - old T1B1 is missing features.model
965970
if (!feat.model && feat.major_version === 1) {
966971
feat.model = '1';
967972
}
968973
// 2. - old fw does not include internal_model. T1B1 does not report it yet, T2T1 starts in 2.6.0
969-
if (!feat.internal_model) {
974+
// - or reported internal_model is not known to connect
975+
if (!feat.internal_model || !DeviceModelInternal[feat.internal_model]) {
970976
feat.internal_model = ensureInternalModelFeature(feat.model);
971977
}
972978

packages/connect/src/utils/assetUtils.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ export const firmwareAssets: Record<DeviceModelInternal, NodeRequire> = {
1212
[DeviceModelInternal.T3B1]: require('@trezor/connect-common/files/firmware/t3b1/releases.json'),
1313
[DeviceModelInternal.T3T1]: require('@trezor/connect-common/files/firmware/t3t1/releases.json'),
1414
[DeviceModelInternal.T3W1]: require('@trezor/connect-common/files/firmware/t3w1/releases.json'),
15+
// @ts-expect-error
16+
[DeviceModelInternal.UNKNOWN]: [],
1517
};
1618

1719
export const tryLocalAssetRequire = (url: string) => {

packages/connect/src/utils/deviceFeaturesUtils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,8 @@ export const ensureInternalModelFeature = (model: Features['model']): DeviceMode
180180
case 'T':
181181
return DeviceModelInternal.T2T1;
182182
case '1':
183-
default:
184183
return DeviceModelInternal.T1B1;
184+
default:
185+
return DeviceModelInternal.UNKNOWN;
185186
}
186187
};

packages/product-components/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export {
77
export { SearchAsset } from './components/SelectAssetModal/SearchAsset';
88
export { PassphraseTypeCard } from './components/PassphraseTypeCard/PassphraseTypeCard';
99
export { ConfirmOnDevice } from './components/ConfirmOnDevice/ConfirmOnDevice';
10-
export { mapTrezorModelToIcon } from './utils/mapTrezorModelToIcon';
10+
export { mapTrezorModelToIcon, mapTrezorModelToIconFilled } from './utils/mapTrezorModelToIcon';
1111
export { RotateDeviceImage } from './components/RotateDeviceImage/RotateDeviceImage';
1212
export { TrezorLogo } from './components/TrezorLogo/TrezorLogo';
1313
export { PasswordStrengthIndicator } from './components/PasswordStrengthIndicator/PasswordStrengthIndicator';

0 commit comments

Comments
 (0)