@@ -4,7 +4,7 @@ import { AbstractMethod } from '../core/AbstractMethod';
4
4
import { UI } from '../events' ;
5
5
import { getFirmwareRange } from './common/paramsValidator' ;
6
6
import { PROTO } from '../constants' ;
7
- import { Assert } from '@trezor/schema-utils' ;
7
+ // import { Assert } from '@trezor/schema-utils';
8
8
9
9
export default class ResetDevice extends AbstractMethod < 'resetDevice' , PROTO . ResetDevice > {
10
10
init ( ) {
@@ -15,7 +15,7 @@ export default class ResetDevice extends AbstractMethod<'resetDevice', PROTO.Res
15
15
16
16
const { payload } = this ;
17
17
// validate bundle type
18
- Assert ( PROTO . ResetDevice , payload ) ;
18
+ // Assert(PROTO.ResetDevice, payload);
19
19
20
20
this . params = {
21
21
display_random : payload . display_random ,
@@ -43,9 +43,35 @@ export default class ResetDevice extends AbstractMethod<'resetDevice', PROTO.Res
43
43
}
44
44
45
45
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
+ } ) ;
48
62
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 ;
50
76
}
51
77
}
0 commit comments