aboutsummaryrefslogblamecommitdiffstats
path: root/packages/subproviders/src/index.ts
blob: 4b3be4efdca8c8369cd43df1f4fe89821cac307a (plain) (tree)
1
2
3
4
5
6
7
8





                                           
                                               
 


                                                                       
                                                                       
                                                                                          
 



                                                                                    





                                                                                                



                                                                             




                                                                                               
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 { NonceTrackerSubprovider } from './subproviders/nonce_tracker';
export { ECSignature, LedgerWalletSubprovider, 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<LedgerEthereumClient> {
    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<LedgerEthereumClient> {
    const ledgerConnection = await LedgerNodeCommunication.create_async();
    const ledgerEthClient = new LedgerEthereumClientFn(ledgerConnection);
    return ledgerEthClient;
}