From 7bfc499ec8e50778dd33183646dd19ef66496052 Mon Sep 17 00:00:00 2001 From: Jacob Evans Date: Mon, 5 Mar 2018 22:14:00 -0500 Subject: Nuke tests for now --- packages/subproviders/src/globals.d.ts | 17 +++++++++++------ packages/subproviders/src/index.ts | 13 ++++--------- packages/subproviders/src/types.ts | 32 ++++++-------------------------- 3 files changed, 21 insertions(+), 41 deletions(-) (limited to 'packages/subproviders/src') diff --git a/packages/subproviders/src/globals.d.ts b/packages/subproviders/src/globals.d.ts index 1a9b2ad61..238d9be78 100644 --- a/packages/subproviders/src/globals.d.ts +++ b/packages/subproviders/src/globals.d.ts @@ -34,22 +34,27 @@ interface ECSignature { } interface LedgerTransport { - close(): Promise + close(): Promise; } declare module '@ledgerhq/hw-app-eth' { - export class Eth { + class Eth { constructor(transport: LedgerTransport); - public getAddress(path: string, boolDisplay?: boolean, boolChaincode?: boolean): Promise<{ publicKey: string; address: string; chainCode: string }>; + public getAddress( + path: string, + boolDisplay?: boolean, + boolChaincode?: boolean, + ): Promise<{ publicKey: string; address: string; chainCode: string }>; public signTransaction(path: string, rawTxHex: string): Promise; - public getAppConfiguration(): Promise<{ arbitraryDataEnabled: number; version: string; }>; + public getAppConfiguration(): Promise<{ arbitraryDataEnabled: number; version: string }>; public signPersonalMessage(path: string, messageHex: string): Promise; transport: LedgerTransport; } + export default Eth; } declare module '@ledgerhq/hw-transport-u2f' { - export class TransportU2F implements LedgerTransport { - public static create(): Promise; + export default class TransportU2F { + public static create(): Promise; public close(): Promise; } } diff --git a/packages/subproviders/src/index.ts b/packages/subproviders/src/index.ts index d296c7be6..e22b6f5f3 100644 --- a/packages/subproviders/src/index.ts +++ b/packages/subproviders/src/index.ts @@ -1,10 +1,5 @@ -import { - Eth as LedgerEthereumClientFn, -} from '@ledgerhq/hw-app-eth'; - -import { - TransportU2F as LedgerBrowserCommunication, -} from '@ledgerhq/hw-transport-u2f'; +import Eth from '@ledgerhq/hw-app-eth'; +import TransportU2F from '@ledgerhq/hw-transport-u2f'; import { LedgerEthereumClient } from './types'; @@ -21,7 +16,7 @@ export { ECSignature, LedgerWalletSubprovider, LedgerCommunicationClient, NonceS * @return LedgerEthereumClient A browser client */ export async function ledgerEthereumBrowserClientFactoryAsync(): Promise { - const ledgerConnection = await LedgerBrowserCommunication.create(); - const ledgerEthClient = new LedgerEthereumClientFn(ledgerConnection); + const ledgerConnection = await TransportU2F.create(); + const ledgerEthClient = new Eth(ledgerConnection); return ledgerEthClient; } diff --git a/packages/subproviders/src/types.ts b/packages/subproviders/src/types.ts index 785547a22..11a178f69 100644 --- a/packages/subproviders/src/types.ts +++ b/packages/subproviders/src/types.ts @@ -1,45 +1,25 @@ import * as _ from 'lodash'; -declare class LedgerTransport { - // tslint:disable-next-line:async-suffix - public static create(): Promise; - // tslint:disable-next-line:async-suffix - public static close(): Promise; -} - export interface LedgerCommunicationClient { close: () => Promise; } +/* + * The LedgerEthereumClient sends Ethereum-specific requests to the Ledger Nano S + * It uses an internal LedgerCommunicationClient to relay these requests. Currently + * NodeJs and Browser communication are supported. + */ export interface LedgerEthereumClient { getAddress: ( derivationPath: string, askForDeviceConfirmation?: boolean, shouldGetChainCode?: boolean, - ) => Promise<{ publicKey: string; address: string; chainCode: string }>; + ) => Promise; signTransaction: (derivationPath: string, rawTxHex: string) => Promise; signPersonalMessage: (derivationPath: string, messageHex: string) => Promise; transport: LedgerCommunicationClient; } -/* - * The LedgerEthereumClient sends Ethereum-specific requests to the Ledger Nano S - * It uses an internal LedgerCommunicationClient to relay these requests. Currently - * NodeJs and Browser communication are supported. - */ -// export interface LedgerEthereumClient { -// // shouldGetChainCode is defined as `true` instead of `boolean` because other types rely on the assumption -// // that we get back the chain code and we don't have dependent types to express it properly -// getAddress_async: ( -// derivationPath: string, -// askForDeviceConfirmation: boolean, -// shouldGetChainCode: true, -// ) => Promise; -// signPersonalMessage_async: (derivationPath: string, messageHex: string) => Promise; -// signTransaction_async: (derivationPath: string, txHex: string) => Promise; -// comm: LedgerCommunicationClient; -// } - export interface ECSignatureString { v: string; r: string; -- cgit v1.2.3