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 Oct 11, 2024
1 parent a9dc169 commit 2a51098
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 = {
strength: payload.strength || 256,
Expand All @@ -42,9 +42,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.transportSession!,
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.protocolState,
});

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

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

return response as any;
}
}

0 comments on commit 2a51098

Please sign in to comment.