diff options
author | Fabio Berger <me@fabioberger.com> | 2018-03-22 23:54:13 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-03-22 23:54:13 +0800 |
commit | de8450d5c93c5b46d227325ca225eadce9610af0 (patch) | |
tree | 830a70884a13de56acae365a996ef6e089a92a5e /packages/subproviders/src | |
parent | bcb9ee4cc2531660847046c575b9a4e57f82ced7 (diff) | |
download | dexon-sol-tools-de8450d5c93c5b46d227325ca225eadce9610af0.tar dexon-sol-tools-de8450d5c93c5b46d227325ca225eadce9610af0.tar.gz dexon-sol-tools-de8450d5c93c5b46d227325ca225eadce9610af0.tar.bz2 dexon-sol-tools-de8450d5c93c5b46d227325ca225eadce9610af0.tar.lz dexon-sol-tools-de8450d5c93c5b46d227325ca225eadce9610af0.tar.xz dexon-sol-tools-de8450d5c93c5b46d227325ca225eadce9610af0.tar.zst dexon-sol-tools-de8450d5c93c5b46d227325ca225eadce9610af0.zip |
Make handleRequest public and add comment for it
Diffstat (limited to 'packages/subproviders/src')
7 files changed, 70 insertions, 21 deletions
diff --git a/packages/subproviders/src/subproviders/empty_wallet_subprovider.ts b/packages/subproviders/src/subproviders/empty_wallet_subprovider.ts index 4cf3ece69..dc570b152 100644 --- a/packages/subproviders/src/subproviders/empty_wallet_subprovider.ts +++ b/packages/subproviders/src/subproviders/empty_wallet_subprovider.ts @@ -9,9 +9,16 @@ import { Subprovider } from './subprovider'; * It intercepts the `eth_accounts` JSON RPC requests and never returns any addresses when queried. */ export class EmptyWalletSubprovider extends Subprovider { - // This method must conform to the web3-provider-engine interface - // tslint:disable-next-line:prefer-function-over-method underscore-private-and-protected - private handleRequest(payload: Web3.JSONRPCRequestPayload, next: Callback, end: ErrorCallback) { + /** + * This method conforms to the web3-provider-engine interface. + * 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 end Callback to call if subprovider handled the request and wants to pass back the request. + */ + // tslint:disable-next-line:prefer-function-over-method + public handleRequest(payload: Web3.JSONRPCRequestPayload, next: Callback, end: ErrorCallback) { switch (payload.method) { case 'eth_accounts': end(null, []); diff --git a/packages/subproviders/src/subproviders/fake_gas_estimate_subprovider.ts b/packages/subproviders/src/subproviders/fake_gas_estimate_subprovider.ts index eff4439b4..a6f978db1 100644 --- a/packages/subproviders/src/subproviders/fake_gas_estimate_subprovider.ts +++ b/packages/subproviders/src/subproviders/fake_gas_estimate_subprovider.ts @@ -23,9 +23,16 @@ export class FakeGasEstimateSubprovider extends Subprovider { super(); this._constantGasAmount = constantGasAmount; } - // This method must conform to the web3-provider-engine interface - // tslint:disable-next-line:prefer-function-over-method underscore-private-and-protected - private handleRequest(payload: Web3.JSONRPCRequestPayload, next: Callback, end: ErrorCallback) { + /** + * This method conforms to the web3-provider-engine interface. + * 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 end Callback to call if subprovider handled the request and wants to pass back the request. + */ + // tslint:disable-next-line:prefer-function-over-method + public handleRequest(payload: Web3.JSONRPCRequestPayload, next: Callback, end: ErrorCallback) { switch (payload.method) { case 'eth_estimateGas': end(null, this._constantGasAmount); diff --git a/packages/subproviders/src/subproviders/ganache.ts b/packages/subproviders/src/subproviders/ganache.ts index feb17f8c5..fc0b9c3d2 100644 --- a/packages/subproviders/src/subproviders/ganache.ts +++ b/packages/subproviders/src/subproviders/ganache.ts @@ -19,9 +19,16 @@ export class GanacheSubprovider extends Subprovider { super(); this._ganacheProvider = Ganache.provider(opts); } - // This method must conform to the web3-provider-engine interface - // tslint:disable-next-line:prefer-function-over-method underscore-private-and-protected - private handleRequest(payload: Web3.JSONRPCRequestPayload, next: Callback, end: ErrorCallback) { + /** + * This method conforms to the web3-provider-engine interface. + * 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 end Callback to call if subprovider handled the request and wants to pass back the request. + */ + // tslint:disable-next-line:prefer-function-over-method + public handleRequest(payload: Web3.JSONRPCRequestPayload, next: Callback, end: ErrorCallback) { this._ganacheProvider.sendAsync(payload, (err: Error | null, result: any) => { end(err, result && result.result); }); diff --git a/packages/subproviders/src/subproviders/injected_web3.ts b/packages/subproviders/src/subproviders/injected_web3.ts index 73c7e59db..cd9b0b603 100644 --- a/packages/subproviders/src/subproviders/injected_web3.ts +++ b/packages/subproviders/src/subproviders/injected_web3.ts @@ -21,9 +21,16 @@ export class InjectedWeb3Subprovider extends Subprovider { super(); this._injectedWeb3 = new Web3(provider); } - // This method must conform to the web3-provider-engine interface - // tslint:disable-next-line:prefer-function-over-method underscore-private-and-protected - private handleRequest(payload: Web3.JSONRPCRequestPayload, next: Callback, end: ErrorCallback) { + /** + * This method conforms to the web3-provider-engine interface. + * 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 end Callback to call if subprovider handled the request and wants to pass back the request. + */ + // tslint:disable-next-line:prefer-function-over-method + public handleRequest(payload: Web3.JSONRPCRequestPayload, next: Callback, end: ErrorCallback) { switch (payload.method) { case 'web3_clientVersion': this._injectedWeb3.version.getNode(end); diff --git a/packages/subproviders/src/subproviders/ledger.ts b/packages/subproviders/src/subproviders/ledger.ts index 3a63ff80f..8bc70d8b6 100644 --- a/packages/subproviders/src/subproviders/ledger.ts +++ b/packages/subproviders/src/subproviders/ledger.ts @@ -198,9 +198,16 @@ export class LedgerSubprovider extends Subprovider { throw err; } } - // Required to implement this public interface which doesn't conform to our linting rule. - // tslint:disable-next-line:async-suffix underscore-private-and-protected - private async handleRequest( + /** + * This method conforms to the web3-provider-engine interface. + * 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 end Callback to call if subprovider handled the request and wants to pass back the request. + */ + // tslint:disable-next-line:async-suffix + public async handleRequest( payload: Web3.JSONRPCRequestPayload, next: Callback, end: (err: Error | null, result?: any) => void, diff --git a/packages/subproviders/src/subproviders/nonce_tracker.ts b/packages/subproviders/src/subproviders/nonce_tracker.ts index 919aa861f..249f16199 100644 --- a/packages/subproviders/src/subproviders/nonce_tracker.ts +++ b/packages/subproviders/src/subproviders/nonce_tracker.ts @@ -46,9 +46,16 @@ export class NonceTrackerSubprovider extends Subprovider { throw new Error(NonceSubproviderErrors.CannotDetermineAddressFromPayload); } } - // This method must conform to the web3-provider-engine interface - // tslint:disable-next-line:prefer-function-over-method underscore-private-and-protected - private async handleRequest( + /** + * This method conforms to the web3-provider-engine interface. + * 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 end Callback to call if subprovider handled the request and wants to pass back the request. + */ + // tslint:disable-next-line:async-suffix + public async handleRequest( payload: Web3.JSONRPCRequestPayload, next: NextCallback, end: ErrorCallback, diff --git a/packages/subproviders/src/subproviders/redundant_rpc.ts b/packages/subproviders/src/subproviders/redundant_rpc.ts index 55b4128f4..ace2ed3c8 100644 --- a/packages/subproviders/src/subproviders/redundant_rpc.ts +++ b/packages/subproviders/src/subproviders/redundant_rpc.ts @@ -45,9 +45,16 @@ export class RedundantRPCSubprovider extends Subprovider { }); }); } - // This method must conform to the web3-provider-engine interface - // tslint:disable-next-line:prefer-function-over-method underscore-private-and-protected - private async handleRequest( + /** + * This method conforms to the web3-provider-engine interface. + * 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 end Callback to call if subprovider handled the request and wants to pass back the request. + */ + // tslint:disable-next-line:async-suffix + public async handleRequest( payload: Web3.JSONRPCRequestPayload, next: Callback, end: (err: Error | null, data?: any) => void, |