Update trezor-connect.js to v4 (#856)

* Update trezor connect.

* Re-ignore trezor connect, fix typings.
This commit is contained in:
William O'Beirne 2018-01-18 00:16:47 -05:00 committed by Daniel Ternyak
parent 9c9d6c2f61
commit 1713e3fa29
3 changed files with 923 additions and 968 deletions

View File

@ -1,5 +1,5 @@
import DPATHS from 'config/dpaths';
import { TrezorWallet } from 'libs/wallet';
import { TrezorWallet, TREZOR_MINIMUM_FIRMWARE } from 'libs/wallet';
import React, { Component } from 'react';
import translate, { translateRaw } from 'translations';
import TrezorConnect from 'vendor/trezor-connect';
@ -97,7 +97,7 @@ export class TrezorDecrypt extends Component<Props, State> {
error: null
});
TrezorConnect.getXPubKey(
(TrezorConnect as any).getXPubKey(
dPath,
res => {
if (res.success) {
@ -114,7 +114,7 @@ export class TrezorDecrypt extends Component<Props, State> {
});
}
},
'1.5.2'
TREZOR_MINIMUM_FIRMWARE
);
};

View File

@ -10,6 +10,8 @@ import mapValues from 'lodash/mapValues';
import { IFullWallet } from '../IWallet';
import { translateRaw } from 'translations';
export const TREZOR_MINIMUM_FIRMWARE = '1.5.2';
export class TrezorWallet extends DeterministicWallet implements IFullWallet {
public signRawTransaction(tx: EthTx): Promise<Buffer> {
return new Promise((resolve, reject) => {
@ -17,7 +19,7 @@ export class TrezorWallet extends DeterministicWallet implements IFullWallet {
// stripHexPrefixAndLower identical to ethFuncs.getNakedAddress
const cleanedTx = mapValues(mapValues(strTx, stripHexPrefixAndLower), padLeftEven);
TrezorConnect.ethereumSignTx(
(TrezorConnect as any).ethereumSignTx(
// Args
this.getPath(),
cleanedTx.nonce,
@ -51,7 +53,6 @@ export class TrezorWallet extends DeterministicWallet implements IFullWallet {
public signMessage = () => Promise.reject(new Error('Signing via Trezor not yet supported.'));
// trezor-connect.js doesn't provide the promise return type
public displayAddress = (dPath?: string, index?: number): Promise<any> => {
if (!dPath) {
dPath = this.dPath;
@ -59,7 +60,20 @@ export class TrezorWallet extends DeterministicWallet implements IFullWallet {
if (!index) {
index = this.index;
}
return TrezorConnect.ethereumGetAddress(dPath + '/' + index);
return new Promise((resolve, reject) => {
(TrezorConnect as any).ethereumGetAddress(
dPath + '/' + index,
res => {
if (res.error) {
reject(res.error);
} else {
resolve(res);
}
},
TREZOR_MINIMUM_FIRMWARE
);
});
};
public getWalletType(): string {

File diff suppressed because it is too large Load Diff