Skip to content

Commit bb1c4da

Browse files
committed
tmp resetDevice as LoadDevice
1 parent 9dea6b2 commit bb1c4da

File tree

1 file changed

+31
-5
lines changed

1 file changed

+31
-5
lines changed

packages/connect/src/api/resetDevice.ts

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { AbstractMethod } from '../core/AbstractMethod';
44
import { UI } from '../events';
55
import { getFirmwareRange } from './common/paramsValidator';
66
import { PROTO } from '../constants';
7-
import { Assert } from '@trezor/schema-utils';
7+
// import { Assert } from '@trezor/schema-utils';
88

99
export default class ResetDevice extends AbstractMethod<'resetDevice', PROTO.ResetDevice> {
1010
init() {
@@ -15,7 +15,7 @@ export default class ResetDevice extends AbstractMethod<'resetDevice', PROTO.Res
1515

1616
const { payload } = this;
1717
// validate bundle type
18-
Assert(PROTO.ResetDevice, payload);
18+
// Assert(PROTO.ResetDevice, payload);
1919

2020
this.params = {
2121
display_random: payload.display_random,
@@ -43,9 +43,35 @@ export default class ResetDevice extends AbstractMethod<'resetDevice', PROTO.Res
4343
}
4444

4545
async run() {
46-
const cmd = this.device.getCommands();
47-
const response = await cmd.typedCall('ResetDevice', 'Success', this.params);
46+
// const cmd = this.device.getCommands();
47+
// const response = await cmd.typedCall('ResetDevice', 'Success', this.params);
48+
console.warn('----> running reset function!');
49+
const response = await this.device.transport.call({
50+
session: this.device.transportSession!,
51+
name: 'LoadDevice',
52+
data: {
53+
pin: '',
54+
label: 'THP device',
55+
passphrase_protection: true,
56+
mnemonics: ['all all all all all all all all all all all all'],
57+
skip_checksum: true,
58+
},
59+
protocol: this.device.protocol,
60+
protocolState: this.device.protocolState,
61+
});
4862

49-
return response.message;
63+
if (response.success && response.payload.type === 'ButtonRequest') {
64+
return this.device.transport.call({
65+
session: this.device.transportSession!,
66+
name: 'ButtonAck',
67+
data: {},
68+
protocol: this.device.protocol,
69+
protocolState: this.device.protocolState,
70+
});
71+
}
72+
73+
console.warn('----> end reset function!', response);
74+
75+
return response as any;
5076
}
5177
}

0 commit comments

Comments
 (0)