From 038668efdfdd2eac85c30206e17128b0af2b48ce Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Tue, 5 Dec 2017 15:45:35 -0600 Subject: Port subproviders over to mono repo, refactor LedgerSubprovider to no longer rely on hookedWalletSubprovider. Added unit and integration tests. --- packages/subproviders/src/index.ts | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 packages/subproviders/src/index.ts (limited to 'packages/subproviders/src/index.ts') diff --git a/packages/subproviders/src/index.ts b/packages/subproviders/src/index.ts new file mode 100644 index 000000000..9560c3597 --- /dev/null +++ b/packages/subproviders/src/index.ts @@ -0,0 +1,30 @@ +import { + comm_node as LedgerNodeCommunication, + comm_u2f as LedgerBrowserCommunication, + eth as LedgerEthereumClientFn, +} from 'ledgerco'; + +import {LedgerEthereumClient} from './types'; + +export {InjectedWeb3Subprovider} from './subproviders/injected_web3'; +export {RedundantRPCSubprovider} from './subproviders/redundant_rpc'; +export { + LedgerSubprovider, +} from './subproviders/ledger'; +export { + ECSignature, + LedgerWalletSubprovider, + LedgerCommunicationClient, +} from './types'; + +export async function ledgerEthereumBrowserClientFactoryAsync(): Promise { + const ledgerConnection = await LedgerBrowserCommunication.create_async(); + const ledgerEthClient = new LedgerEthereumClientFn(ledgerConnection); + return ledgerEthClient; +} + +export async function ledgerEthereumNodeJsClientFactoryAsync(): Promise { + const ledgerConnection = await LedgerNodeCommunication.create_async(); + const ledgerEthClient = new LedgerEthereumClientFn(ledgerConnection); + return ledgerEthClient; +} -- cgit v1.2.3 From f6321a8e703b8b91f7043b6b55e0db06bbcd0a74 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Tue, 5 Dec 2017 16:33:18 -0600 Subject: Fix lint issues --- packages/subproviders/src/index.ts | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'packages/subproviders/src/index.ts') diff --git a/packages/subproviders/src/index.ts b/packages/subproviders/src/index.ts index 9560c3597..9b7cab3fa 100644 --- a/packages/subproviders/src/index.ts +++ b/packages/subproviders/src/index.ts @@ -17,12 +17,20 @@ export { LedgerCommunicationClient, } from './types'; +/** + * A factory method for creating a LedgerEthereumClient usable in a browser context. + * @return LedgerEthereumClient A browser client + */ export async function ledgerEthereumBrowserClientFactoryAsync(): Promise { const ledgerConnection = await LedgerBrowserCommunication.create_async(); const ledgerEthClient = new LedgerEthereumClientFn(ledgerConnection); return ledgerEthClient; } +/** + * A factory for creating a LedgerEthereumClient usable in a Node.js context. + * @return LedgerEthereumClient A Node.js client + */ export async function ledgerEthereumNodeJsClientFactoryAsync(): Promise { const ledgerConnection = await LedgerNodeCommunication.create_async(); const ledgerEthClient = new LedgerEthereumClientFn(ledgerConnection); -- cgit v1.2.3