Skip to content

Commit

Permalink
tmp resetDevice as LoadDevice
Browse files Browse the repository at this point in the history
  • Loading branch information
szymonlesisz committed Aug 29, 2024
1 parent de4ae05 commit cb1857f
Showing 1 changed file with 31 additions and 5 deletions.
36 changes: 31 additions & 5 deletions packages/connect/src/api/resetDevice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { AbstractMethod } from '../core/AbstractMethod';
import { UI } from '../events';
import { getFirmwareRange } from './common/paramsValidator';
import { PROTO } from '../constants';
import { Assert } from '@trezor/schema-utils';
// import { Assert } from '@trezor/schema-utils';

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

const { payload } = this;
// validate bundle type
Assert(PROTO.ResetDevice, payload);
// Assert(PROTO.ResetDevice, payload);

this.params = {
display_random: payload.display_random,
Expand Down Expand Up @@ -43,9 +43,35 @@ export default class ResetDevice extends AbstractMethod<'resetDevice', PROTO.Res
}

async run() {
const cmd = this.device.getCommands();
const response = await cmd.typedCall('ResetDevice', 'Success', this.params);
// const cmd = this.device.getCommands();
// const response = await cmd.typedCall('ResetDevice', 'Success', this.params);
console.warn('----> running reset function!');
const response = await this.device.transport.call({
session: this.device.activitySessionID!,
name: 'LoadDevice',
data: {
pin: '',
label: 'THP device',
passphrase_protection: true,
mnemonics: ['all all all all all all all all all all all all'],
skip_checksum: true,
},
protocol: this.device.protocol,
protocolState: this.device.transportState,
}).promise;

return response.message;
if (response.success && response.payload.type === 'ButtonRequest') {
return this.device.transport.call({
session: this.device.activitySessionID!,
name: 'ButtonAck',
data: {},
protocol: this.device.protocol,
protocolState: this.device.transportState,
}).promise;
}

console.warn('----> end reset function!', response);

return response as any;
}
}

0 comments on commit cb1857f

Please sign in to comment.