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 | |
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
9 files changed, 80 insertions, 26 deletions
diff --git a/packages/sol-cov/src/coverage_subprovider.ts b/packages/sol-cov/src/coverage_subprovider.ts index fc06720de..37682c45f 100644 --- a/packages/sol-cov/src/coverage_subprovider.ts +++ b/packages/sol-cov/src/coverage_subprovider.ts @@ -49,9 +49,16 @@ export class CoverageSubprovider extends Subprovider { public async writeCoverageAsync(): Promise<void> { await this._coverageManager.writeCoverageAsync(); } - // 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: NextCallback, 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: NextCallback, end: ErrorCallback) { switch (payload.method) { case 'eth_sendTransaction': const txData = payload.params[0]; diff --git a/packages/subproviders/CHANGELOG.md b/packages/subproviders/CHANGELOG.md index 2947bb32e..cdf98cba3 100644 --- a/packages/subproviders/CHANGELOG.md +++ b/packages/subproviders/CHANGELOG.md @@ -4,8 +4,6 @@ * Introduce `JSONRPCRequestPayloadWithMethod` type (#465) * Export `ErrorCallback` type. (#465) - * Make `handleRequest` private in `LedgerSubprovider` since it should only be used - internally by the providerEngine. (#465) ## v0.8.0 - _March 18, 2018_ 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, |