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

fix(protobuf): clean up type of backup_type in schema #11907

Merged
merged 1 commit into from
Apr 8, 2024
Merged
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
5 changes: 2 additions & 3 deletions packages/connect/src/api/resetDevice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
import { AbstractMethod } from '../core/AbstractMethod';
import { UI, createUiMessage } from '../events';
import { getFirmwareRange } from './common/paramsValidator';
import type { PROTO } from '../constants';
import { PROTO } from '../constants';
import { Assert } from '@trezor/schema-utils';
import { ResetDevice as ResetDeviceSchema } from '../types/api/resetDevice';

export default class ResetDevice extends AbstractMethod<'resetDevice', PROTO.ResetDevice> {
confirmed?: boolean;
Expand All @@ -18,7 +17,7 @@ export default class ResetDevice extends AbstractMethod<'resetDevice', PROTO.Res

const { payload } = this;
// validate bundle type
Assert(ResetDeviceSchema, payload);
Assert(PROTO.ResetDevice, payload);
peter-sanderson marked this conversation as resolved.
Show resolved Hide resolved

this.params = {
display_random: payload.display_random,
Expand Down
11 changes: 1 addition & 10 deletions packages/connect/src/types/api/resetDevice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,7 @@
* Performs device setup and generates a new seed.
*/

import { Static, Type } from '@trezor/schema-utils';
import { PROTO } from '../../constants';
import type { Params, Response } from '../params';

export type ResetDevice = Static<typeof ResetDevice>;
export const ResetDevice = Type.Composite([
PROTO.ResetDevice,
Type.Object({
backup_type: Type.Optional(Type.Union([Type.Literal(0), Type.Literal(1)])),
}),
]);

export declare function resetDevice(params: Params<ResetDevice>): Response<PROTO.Success>;
export declare function resetDevice(params: Params<PROTO.ResetDevice>): Response<PROTO.Success>;
2 changes: 1 addition & 1 deletion packages/protobuf/scripts/protobuf-patches/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ const TYPE_PATCH = {
'EosActionUnlinkAuth.type': 'string',
'EosActionNewAccount.creator': 'string',
'EosActionNewAccount.name': 'string',
'ResetDevice.backup_type': 'string | number', // BackupType is a enum. in Features displayed as string, in resetDevice method param accepted as number
'ResetDevice.backup_type': 'Enum_BackupType',
'StellarAsset.type': '0 | 1 | 2 | "NATIVE" | "ALPHANUM4" | "ALPHANUM12"', // StellarAssetType is a enum, accepted as both number and string
'StellarSignTx.sequence_number': UINT_TYPE,
'StellarSignTx.memo_id': UINT_TYPE,
Expand Down
2 changes: 1 addition & 1 deletion packages/protobuf/src/messages-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2428,7 +2428,7 @@ export const ResetDevice = Type.Object(
u2f_counter: Type.Optional(Type.Number()),
skip_backup: Type.Optional(Type.Boolean()),
no_backup: Type.Optional(Type.Boolean()),
backup_type: Type.Optional(Type.Union([Type.String(), Type.Number()])),
backup_type: Type.Optional(EnumEnum_BackupType),
},
{ $id: 'ResetDevice' },
);
Expand Down
2 changes: 1 addition & 1 deletion packages/protobuf/src/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1729,7 +1729,7 @@ export type ResetDevice = {
u2f_counter?: number;
skip_backup?: boolean;
no_backup?: boolean;
backup_type?: string | number;
backup_type?: Enum_BackupType;
};

// BackupDevice
Expand Down
Loading