diff options
author | Fabio Berger <me@fabioberger.com> | 2018-08-24 01:12:39 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-24 01:12:39 +0800 |
commit | 6e27324a341801e1a2d8d6989d749dfe021ae39b (patch) | |
tree | 32b2e1d93958905f7e4d0529e4fbead4206275ab /packages/subproviders/src | |
parent | b013cf2e145825a9e250c61bc77825384b2af69e (diff) | |
parent | 8eb4b6f91791313dc02865a9dd3324cce646d537 (diff) | |
download | dexon-sol-tools-6e27324a341801e1a2d8d6989d749dfe021ae39b.tar dexon-sol-tools-6e27324a341801e1a2d8d6989d749dfe021ae39b.tar.gz dexon-sol-tools-6e27324a341801e1a2d8d6989d749dfe021ae39b.tar.bz2 dexon-sol-tools-6e27324a341801e1a2d8d6989d749dfe021ae39b.tar.lz dexon-sol-tools-6e27324a341801e1a2d8d6989d749dfe021ae39b.tar.xz dexon-sol-tools-6e27324a341801e1a2d8d6989d749dfe021ae39b.tar.zst dexon-sol-tools-6e27324a341801e1a2d8d6989d749dfe021ae39b.zip |
Merge pull request #924 from 0xProject/wrap-typedoc
Improved Docs & Removed monorepo-scripts from packages
Diffstat (limited to 'packages/subproviders/src')
8 files changed, 44 insertions, 29 deletions
diff --git a/packages/subproviders/src/index.ts b/packages/subproviders/src/index.ts index 9d4480e59..b5f9b3f90 100644 --- a/packages/subproviders/src/index.ts +++ b/packages/subproviders/src/index.ts @@ -1,11 +1,21 @@ import Eth from '@ledgerhq/hw-app-eth'; import TransportU2F from '@ledgerhq/hw-transport-u2f'; export import Web3ProviderEngine = require('web3-provider-engine'); -export { ECSignature } from '@0xproject/types'; import { LedgerEthereumClient } from './types'; +/** + * A factory method for creating a LedgerEthereumClient usable in a browser context. + * @return LedgerEthereumClient A browser client for the LedgerSubprovider + */ +export async function ledgerEthereumBrowserClientFactoryAsync(): Promise<LedgerEthereumClient> { + const ledgerConnection = await TransportU2F.create(); + const ledgerEthClient = new Eth(ledgerConnection); + return ledgerEthClient; +} + export { prependSubprovider } from './utils/subprovider_utils'; + export { EmptyWalletSubprovider } from './subproviders/empty_wallet_subprovider'; export { FakeGasEstimateSubprovider } from './subproviders/fake_gas_estimate_subprovider'; export { SignerSubprovider } from './subproviders/signer'; @@ -18,6 +28,7 @@ export { NonceTrackerSubprovider } from './subproviders/nonce_tracker'; export { PrivateKeyWalletSubprovider } from './subproviders/private_key_wallet'; export { MnemonicWalletSubprovider } from './subproviders/mnemonic_wallet'; export { EthLightwalletSubprovider } from './subproviders/eth_lightwallet_subprovider'; + export { Callback, ErrorCallback, @@ -26,14 +37,16 @@ export { LedgerEthereumClient, NonceSubproviderErrors, LedgerSubproviderConfigs, + PartialTxParams, + JSONRPCRequestPayloadWithMethod, + ECSignatureString, + AccountFetchingConfigs, + LedgerEthereumClientFactoryAsync, + OnNextCompleted, + MnemonicWalletSubproviderConfigs, + LedgerGetAddressResult, } from './types'; -/** - * A factory method for creating a LedgerEthereumClient usable in a browser context. - * @return LedgerEthereumClient A browser client for the LedgerSubprovider - */ -export async function ledgerEthereumBrowserClientFactoryAsync(): Promise<LedgerEthereumClient> { - const ledgerConnection = await TransportU2F.create(); - const ledgerEthClient = new Eth(ledgerConnection); - return ledgerEthClient; -} +export { ECSignature } from '@0xproject/types'; + +export { JSONRPCRequestPayload, Provider, JSONRPCResponsePayload, JSONRPCErrorCallback } from 'ethereum-types'; diff --git a/packages/subproviders/src/monorepo_scripts/postpublish.ts b/packages/subproviders/src/monorepo_scripts/postpublish.ts deleted file mode 100644 index dcb99d0f7..000000000 --- a/packages/subproviders/src/monorepo_scripts/postpublish.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { postpublishUtils } from '@0xproject/monorepo-scripts'; - -import * as packageJSON from '../package.json'; -import * as tsConfigJSON from '../tsconfig.json'; - -const cwd = `${__dirname}/..`; -// tslint:disable-next-line:no-floating-promises -postpublishUtils.runAsync(packageJSON, tsConfigJSON, cwd); diff --git a/packages/subproviders/src/monorepo_scripts/stage_docs.ts b/packages/subproviders/src/monorepo_scripts/stage_docs.ts deleted file mode 100644 index e732ac8eb..000000000 --- a/packages/subproviders/src/monorepo_scripts/stage_docs.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { postpublishUtils } from '@0xproject/monorepo-scripts'; - -import * as packageJSON from '../package.json'; -import * as tsConfigJSON from '../tsconfig.json'; - -const cwd = `${__dirname}/..`; -// tslint:disable-next-line:no-floating-promises -postpublishUtils.publishDocsToStagingAsync(packageJSON, tsConfigJSON, cwd); diff --git a/packages/subproviders/src/subproviders/eth_lightwallet_subprovider.ts b/packages/subproviders/src/subproviders/eth_lightwallet_subprovider.ts index 454dae58e..6afd71422 100644 --- a/packages/subproviders/src/subproviders/eth_lightwallet_subprovider.ts +++ b/packages/subproviders/src/subproviders/eth_lightwallet_subprovider.ts @@ -14,6 +14,12 @@ import { PrivateKeyWalletSubprovider } from './private_key_wallet'; export class EthLightwalletSubprovider extends BaseWalletSubprovider { private readonly _keystore: lightwallet.keystore; private readonly _pwDerivedKey: Uint8Array; + /** + * Instantiate an EthLightwalletSubprovider + * @param keystore The EthLightWallet keystore you wish to use + * @param pwDerivedKey The password derived key to use + * @return EthLightwalletSubprovider instance + */ constructor(keystore: lightwallet.keystore, pwDerivedKey: Uint8Array) { super(); this._keystore = keystore; diff --git a/packages/subproviders/src/subproviders/ganache.ts b/packages/subproviders/src/subproviders/ganache.ts index 986094dba..2b8544f8b 100644 --- a/packages/subproviders/src/subproviders/ganache.ts +++ b/packages/subproviders/src/subproviders/ganache.ts @@ -24,7 +24,7 @@ export class GanacheSubprovider extends Subprovider { * It is called internally by the ProviderEngine when it is this subproviders * turn to handle a JSON RPC request. * @param payload JSON RPC payload - * @param next Callback to call if this subprovider decides not to handle the request + * @param _next Callback to call if this subprovider decides not to handle the request * @param end Callback to call if subprovider handled the request and wants to pass back the request. */ // tslint:disable-next-line:prefer-function-over-method async-suffix diff --git a/packages/subproviders/src/subproviders/redundant_subprovider.ts b/packages/subproviders/src/subproviders/redundant_subprovider.ts index 7aa6226d5..59a2986f8 100644 --- a/packages/subproviders/src/subproviders/redundant_subprovider.ts +++ b/packages/subproviders/src/subproviders/redundant_subprovider.ts @@ -34,7 +34,7 @@ export class RedundantSubprovider extends Subprovider { } /** * Instantiates a new RedundantSubprovider - * @param endpoints JSON RPC endpoints to attempt. Attempts are made in the order of the endpoints. + * @param subproviders Subproviders to attempt the request with */ constructor(subproviders: Subprovider[]) { super(); diff --git a/packages/subproviders/src/subproviders/rpc_subprovider.ts b/packages/subproviders/src/subproviders/rpc_subprovider.ts index d874c6f05..18d6da307 100644 --- a/packages/subproviders/src/subproviders/rpc_subprovider.ts +++ b/packages/subproviders/src/subproviders/rpc_subprovider.ts @@ -15,6 +15,10 @@ import { Subprovider } from './subprovider'; export class RPCSubprovider extends Subprovider { private readonly _rpcUrl: string; private readonly _requestTimeoutMs: number; + /** + * @param rpcUrl URL to the backing Ethereum node to which JSON RPC requests should be sent + * @param requestTimeoutMs Amount of miliseconds to wait before timing out the JSON RPC request + */ constructor(rpcUrl: string, requestTimeoutMs: number = 20000) { super(); assert.isString('rpcUrl', rpcUrl); @@ -27,7 +31,7 @@ export class RPCSubprovider extends Subprovider { * It is called internally by the ProviderEngine when it is this subproviders * turn to handle a JSON RPC request. * @param payload JSON RPC payload - * @param next Callback to call if this subprovider decides not to handle the request + * @param _next Callback to call if this subprovider decides not to handle the request * @param end Callback to call if subprovider handled the request and wants to pass back the request. */ // tslint:disable-next-line:prefer-function-over-method async-suffix diff --git a/packages/subproviders/src/subproviders/subprovider.ts b/packages/subproviders/src/subproviders/subprovider.ts index 5dc273569..dcf880c79 100644 --- a/packages/subproviders/src/subproviders/subprovider.ts +++ b/packages/subproviders/src/subproviders/subprovider.ts @@ -32,6 +32,11 @@ export abstract class Subprovider { // 16 digits return datePart + extraPart; } + /** + * @param payload JSON RPC request payload + * @param next A callback to pass the request to the next subprovider in the stack + * @param end A callback called once the subprovider is done handling the request + */ // tslint:disable-next-line:async-suffix public abstract async handleRequest( payload: JSONRPCRequestPayload, @@ -48,6 +53,8 @@ export abstract class Subprovider { */ public async emitPayloadAsync(payload: Partial<JSONRPCRequestPayloadWithMethod>): Promise<JSONRPCResponsePayload> { const finalPayload = Subprovider._createFinalPayload(payload); + // Promisify does the binding internally and `this` is supplied as a second argument + // tslint:disable-next-line:no-unbound-method const response = await promisify<JSONRPCResponsePayload>(this.engine.sendAsync, this.engine)(finalPayload); return response; } @@ -55,6 +62,7 @@ export abstract class Subprovider { * Set's the subprovider's engine to the ProviderEngine it is added to. * This is only called within the ProviderEngine source code, do not call * directly. + * @param engine The ProviderEngine this subprovider is added to */ public setEngine(engine: Provider): void { this.engine = engine; |