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

[wip] chore(protobuf): update protobuf definitions (display type enum added) #15588

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions packages/connect/setupJest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

import { AbstractApiTransport, UsbApi } from '@trezor/transport';

import { DeviceModelInternal, type Features, type FirmwareRelease } from './src/types';
import {
DeviceModelInternal,
type Features,
type FirmwareRelease,
DisplayRotation,
} from './src/types';

class TestTransport extends AbstractApiTransport {
name = 'TestTransport' as any;
Expand Down Expand Up @@ -81,7 +86,7 @@ export const getDeviceFeatures = (feat?: Partial<Features>): Features => ({
passphrase_always_on_device: false,
safety_checks: 'Strict',
auto_lock_delay_ms: 60000,
display_rotation: 0,
display_rotation: DisplayRotation.North,
experimental_features: false,
...feat,
});
Expand Down
1 change: 1 addition & 0 deletions packages/connect/src/types/device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ export type Device = KnownDevice | UnknownDevice | UnreadableDevice;
export type Features = PROTO.Features;

export { DeviceModelInternal } from '@trezor/protobuf';
export { DisplayRotation } from '@trezor/protobuf';

type FeaturesNarrowing =
| {
Expand Down
28 changes: 24 additions & 4 deletions packages/protobuf/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -2943,8 +2943,20 @@
"id": 2
},
"wait_layout": {
"type": "bool",
"id": 3
"type": "DebugWaitType",
"id": 3,
"options": {
"default": "IMMEDIATE"
}
}
},
"nested": {
"DebugWaitType": {
"values": {
"IMMEDIATE": 0,
"NEXT_LAYOUT": 1,
"CURRENT_LAYOUT": 2
}
}
}
},
Expand Down Expand Up @@ -4243,6 +4255,14 @@
"PromptTemporarily": 2
}
},
"DisplayRotation": {
"values": {
"North": 0,
"East": 90,
"South": 180,
"West": 270
}
},
"HomescreenFormat": {
"values": {
"Toif": 1,
Expand Down Expand Up @@ -4423,7 +4443,7 @@
"id": 38
},
"display_rotation": {
"type": "uint32",
"type": "DisplayRotation",
"id": 39
},
"experimental_features": {
Expand Down Expand Up @@ -4573,7 +4593,7 @@
"id": 6
},
"display_rotation": {
"type": "uint32",
"type": "DisplayRotation",
"id": 7
},
"passphrase_always_on_device": {
Expand Down
1 change: 1 addition & 0 deletions packages/protobuf/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ export { parseConfigure, createMessageFromName, createMessageFromType } from './
export * as MessagesSchema from './messages-schema';
// It's problem to reexport enums when they are under MessagesSchema namespace, check packages/connect/src/types/device.ts
export { DeviceModelInternal } from './messages-schema';
export { DisplayRotation } from './messages-schema';
21 changes: 20 additions & 1 deletion packages/protobuf/src/messages-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1582,6 +1582,15 @@ export enum DebugPhysicalButton {
export type EnumDebugPhysicalButton = Static<typeof EnumDebugPhysicalButton>;
export const EnumDebugPhysicalButton = Type.Enum(DebugPhysicalButton);

export enum DebugWaitType {
IMMEDIATE = 0,
NEXT_LAYOUT = 1,
CURRENT_LAYOUT = 2,
}

export type EnumDebugWaitType = Static<typeof EnumDebugWaitType>;
export const EnumDebugWaitType = Type.Enum(DebugWaitType);

export type DebugLinkResetDebugEvents = Static<typeof DebugLinkResetDebugEvents>;
export const DebugLinkResetDebugEvents = Type.Object({}, { $id: 'DebugLinkResetDebugEvents' });

Expand Down Expand Up @@ -2181,6 +2190,16 @@ export const EnumEnum_SafetyCheckLevel = Type.Enum(Enum_SafetyCheckLevel);
export type SafetyCheckLevel = Static<typeof SafetyCheckLevel>;
export const SafetyCheckLevel = Type.KeyOfEnum(Enum_SafetyCheckLevel, { $id: 'SafetyCheckLevel' });

export enum DisplayRotation {
North = 0,
East = 90,
South = 180,
West = 270,
}

export type EnumDisplayRotation = Static<typeof EnumDisplayRotation>;
export const EnumDisplayRotation = Type.Enum(DisplayRotation);

export enum Enum_HomescreenFormat {
Toif = 1,
Jpeg = 2,
Expand Down Expand Up @@ -2380,7 +2399,7 @@ export const ApplySettings = Type.Object(
homescreen: Type.Optional(Type.String()),
_passphrase_source: Type.Optional(Type.Number()),
auto_lock_delay_ms: Type.Optional(Type.Number()),
display_rotation: Type.Optional(Type.Number()),
display_rotation: Type.Optional(EnumDisplayRotation),
passphrase_always_on_device: Type.Optional(Type.Boolean()),
safety_checks: Type.Optional(SafetyCheckLevel),
experimental_features: Type.Optional(Type.Boolean()),
Expand Down
15 changes: 14 additions & 1 deletion packages/protobuf/src/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1044,6 +1044,12 @@ export enum DebugPhysicalButton {
RIGHT_BTN = 2,
}

export enum DebugWaitType {
IMMEDIATE = 0,
NEXT_LAYOUT = 1,
CURRENT_LAYOUT = 2,
}

export type DebugLinkResetDebugEvents = {};

export type DebugLinkOptigaSetSecMax = {};
Expand Down Expand Up @@ -1418,6 +1424,13 @@ export enum Enum_SafetyCheckLevel {

export type SafetyCheckLevel = keyof typeof Enum_SafetyCheckLevel;

export enum DisplayRotation {
North = 0,
East = 90,
South = 180,
West = 270,
}

export enum Enum_HomescreenFormat {
Toif = 1,
Jpeg = 2,
Expand Down Expand Up @@ -1571,7 +1584,7 @@ export type ApplySettings = {
homescreen?: string;
_passphrase_source?: number;
auto_lock_delay_ms?: number;
display_rotation?: number;
display_rotation?: DisplayRotation;
passphrase_always_on_device?: boolean;
safety_checks?: SafetyCheckLevel;
experimental_features?: boolean;
Expand Down
3 changes: 2 additions & 1 deletion suite-common/test-utils/src/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
DeviceModelInternal,
FirmwareType,
DeviceUniquePath,
DisplayRotation,
} from '@trezor/connect';
import {
TrezorDevice,
Expand Down Expand Up @@ -132,7 +133,7 @@ const getDeviceFeatures = (feat?: Partial<Features>): Features => ({
passphrase_always_on_device: false,
safety_checks: 'Strict',
auto_lock_delay_ms: 60000,
display_rotation: 0,
display_rotation: DisplayRotation.North,
experimental_features: false,
...feat,
});
Expand Down
Loading