Skip to content

Commit

Permalink
remove unused methods logging cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mholtzman committed Oct 7, 2021
1 parent 99a6bee commit 1be4205
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 29 deletions.
35 changes: 11 additions & 24 deletions main/signers/trezor/Trezor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ export default class Trezor extends Signer {
device: TrezorDevice;
derivation: Derivation | undefined;

setPhrase: ((phrase: string) => void) | undefined;
setPin: ((pin: string) => void) | undefined;

constructor (device: TrezorDevice) {
super()

Expand Down Expand Up @@ -155,9 +152,7 @@ export default class Trezor extends Signer {
if (err === 'Device call in progress' && attempt < 5) {
setTimeout(() => this.verifyAddress(index, currentAddress, display, cb, ++attempt), 1000 * (attempt + 1))
} else {
log.info('Verify Address Error: ')
// TODO: Error Notification
log.error(err)
log.error('Verify address error: ', err)

this.close()

Expand Down Expand Up @@ -195,36 +190,28 @@ export default class Trezor extends Signer {
flex.rpc('trezor.getPublicKey', this.device.path, this.basePath(), rpcCallback)
}

needPhrase () {
this.status = 'Enter Passphrase'
this.update()

setPhrase (phrase: string) {
const rpcCallback: FlexCallback = err => {
if (err) log.error(err)
setTimeout(() => this.deviceStatus(), 1000)
}

this.setPhrase = (phrase) => {
this.status = 'loading'
this.update()
flex.rpc('trezor.inputPhrase', this.device.path, phrase, rpcCallback)
}
}

needPin () {
this.status = 'Need Pin'
this.status = 'loading'
this.update()

flex.rpc('trezor.inputPhrase', this.device.path, phrase, rpcCallback)
}

setPin (pin: string) {
const rpcCallback: FlexCallback = err => {
if (err) log.error(err)
setTimeout(() => this.deviceStatus(), 250)
}

this.setPin = (pin) => {
this.status = 'loading'
this.update()
flex.rpc('trezor.inputPin', this.device.path, pin, rpcCallback)
}
this.status = 'loading'
this.update()

flex.rpc('trezor.inputPin', this.device.path, pin, rpcCallback)
}

// Standard Methods
Expand Down
18 changes: 13 additions & 5 deletions main/signers/trezor/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,26 @@ export default class TrezorSignerAdapter extends SignerAdapter {
}

const updateListener = (device: any) => {
log.info(':: Trezor Scan - Updated Device')
log.debug(':: Trezor Scan - Updated Device')
this.withSigner(device, signer => this.emit('update', signer))
}

const needPinListener = (device: any) => {
log.info(':: Trezor Scan - Device Needs Pin')
this.withSigner(device, signer => signer.needPin())
log.debug(':: Trezor Scan - Device Needs Pin')

this.withSigner(device, signer => {
signer.status = 'Need Pin',
signer.update()
})
}

const needPhraseListener = (device: any) => {
log.info(':: Trezor Scan - Device Needs Phrase')
this.withSigner(device, signer => signer.needPhrase())
log.debug(':: Trezor Scan - Device Needs Phrase')

this.withSigner(device, signer => {
signer.status = 'Enter Passphrase'
signer.update()
})
}

const scanListener = (err: any) => {
Expand Down

0 comments on commit 1be4205

Please sign in to comment.