aboutsummaryrefslogtreecommitdiffstats
path: root/packages/subproviders/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/subproviders/src')
-rw-r--r--packages/subproviders/src/globals.d.ts17
-rw-r--r--packages/subproviders/src/index.ts13
-rw-r--r--packages/subproviders/src/types.ts32
3 files changed, 21 insertions, 41 deletions
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<void>
+ close(): Promise<void>;
}
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<ECSignatureString>;
- public getAppConfiguration(): Promise<{ arbitraryDataEnabled: number; version: string; }>;
+ public getAppConfiguration(): Promise<{ arbitraryDataEnabled: number; version: string }>;
public signPersonalMessage(path: string, messageHex: string): Promise<ECSignature>;
transport: LedgerTransport;
}
+ export default Eth;
}
declare module '@ledgerhq/hw-transport-u2f' {
- export class TransportU2F implements LedgerTransport {
- public static create(): Promise<TransportU2F>;
+ export default class TransportU2F {
+ public static create(): Promise<LedgerTransport>;
public close(): Promise<void>;
}
}
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<LedgerEthereumClient> {
- 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<LedgerTransport>;
- // tslint:disable-next-line:async-suffix
- public static close(): Promise<void>;
-}
-
export interface LedgerCommunicationClient {
close: () => Promise<void>;
}
+/*
+ * 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<LedgerGetAddressResult>;
signTransaction: (derivationPath: string, rawTxHex: string) => Promise<ECSignatureString>;
signPersonalMessage: (derivationPath: string, messageHex: string) => Promise<ECSignature>;
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<LedgerGetAddressResult>;
-// signPersonalMessage_async: (derivationPath: string, messageHex: string) => Promise<ECSignature>;
-// signTransaction_async: (derivationPath: string, txHex: string) => Promise<ECSignatureString>;
-// comm: LedgerCommunicationClient;
-// }
-
export interface ECSignatureString {
v: string;
r: string;