diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-07-18 20:54:47 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-18 20:54:47 +0800 |
commit | f3241ff86a0d99f4291c5a5f4eaaa5ebe1736da0 (patch) | |
tree | 4aacfa2652ba2c5f976e36ac25449decb561d3f0 /packages/subproviders | |
parent | 904968cf4a899642d3f4e78abc53352125e17447 (diff) | |
parent | bf8ac3b9e6ee59f267f7850418febfe84dedceb8 (diff) | |
download | dexon-sol-tools-f3241ff86a0d99f4291c5a5f4eaaa5ebe1736da0.tar dexon-sol-tools-f3241ff86a0d99f4291c5a5f4eaaa5ebe1736da0.tar.gz dexon-sol-tools-f3241ff86a0d99f4291c5a5f4eaaa5ebe1736da0.tar.bz2 dexon-sol-tools-f3241ff86a0d99f4291c5a5f4eaaa5ebe1736da0.tar.lz dexon-sol-tools-f3241ff86a0d99f4291c5a5f4eaaa5ebe1736da0.tar.xz dexon-sol-tools-f3241ff86a0d99f4291c5a5f4eaaa5ebe1736da0.tar.zst dexon-sol-tools-f3241ff86a0d99f4291c5a5f4eaaa5ebe1736da0.zip |
Merge pull request #883 from 0xProject/feature/tslint-improvements
New tslint rules
Diffstat (limited to 'packages/subproviders')
15 files changed, 36 insertions, 36 deletions
diff --git a/packages/subproviders/package.json b/packages/subproviders/package.json index 796d87cf4..02e51a614 100644 --- a/packages/subproviders/package.json +++ b/packages/subproviders/package.json @@ -82,7 +82,7 @@ "nyc": "^11.0.1", "shx": "^0.2.2", "sinon": "^4.0.0", - "tslint": "5.8.0", + "tslint": "5.11.0", "typedoc": "0xProject/typedoc", "typescript": "2.7.1", "webpack": "^3.1.0" diff --git a/packages/subproviders/src/subproviders/eth_lightwallet_subprovider.ts b/packages/subproviders/src/subproviders/eth_lightwallet_subprovider.ts index a9ebbb790..454dae58e 100644 --- a/packages/subproviders/src/subproviders/eth_lightwallet_subprovider.ts +++ b/packages/subproviders/src/subproviders/eth_lightwallet_subprovider.ts @@ -12,8 +12,8 @@ import { PrivateKeyWalletSubprovider } from './private_key_wallet'; * Source: https://github.com/MetaMask/provider-engine/blob/master/subproviders/subprovider.js */ export class EthLightwalletSubprovider extends BaseWalletSubprovider { - private _keystore: lightwallet.keystore; - private _pwDerivedKey: Uint8Array; + private readonly _keystore: lightwallet.keystore; + private readonly _pwDerivedKey: Uint8Array; constructor(keystore: lightwallet.keystore, pwDerivedKey: Uint8Array) { super(); this._keystore = keystore; diff --git a/packages/subproviders/src/subproviders/fake_gas_estimate_subprovider.ts b/packages/subproviders/src/subproviders/fake_gas_estimate_subprovider.ts index d750505e7..bc1b34aba 100644 --- a/packages/subproviders/src/subproviders/fake_gas_estimate_subprovider.ts +++ b/packages/subproviders/src/subproviders/fake_gas_estimate_subprovider.ts @@ -14,7 +14,7 @@ import { Subprovider } from './subprovider'; * It intercepts the `eth_estimateGas` JSON RPC call and always returns a constant gas amount when queried. */ export class FakeGasEstimateSubprovider extends Subprovider { - private _constantGasAmount: number; + private readonly _constantGasAmount: number; /** * Instantiates an instance of the FakeGasEstimateSubprovider * @param constantGasAmount The constant gas amount you want returned diff --git a/packages/subproviders/src/subproviders/ganache.ts b/packages/subproviders/src/subproviders/ganache.ts index 79c43bc68..986094dba 100644 --- a/packages/subproviders/src/subproviders/ganache.ts +++ b/packages/subproviders/src/subproviders/ganache.ts @@ -10,7 +10,7 @@ import { Subprovider } from './subprovider'; * It intercepts all JSON RPC requests and relays them to an in-process ganache instance. */ export class GanacheSubprovider extends Subprovider { - private _ganacheProvider: Provider; + private readonly _ganacheProvider: Provider; /** * Instantiates a GanacheSubprovider * @param opts The desired opts with which to instantiate the Ganache provider diff --git a/packages/subproviders/src/subproviders/ledger.ts b/packages/subproviders/src/subproviders/ledger.ts index 8345be33c..6ad5de2e2 100644 --- a/packages/subproviders/src/subproviders/ledger.ts +++ b/packages/subproviders/src/subproviders/ledger.ts @@ -32,14 +32,14 @@ const DEFAULT_ADDRESS_SEARCH_LIMIT = 1000; */ export class LedgerSubprovider extends BaseWalletSubprovider { // tslint:disable-next-line:no-unused-variable - private _nonceLock = new Lock(); - private _connectionLock = new Lock(); - private _networkId: number; + private readonly _nonceLock = new Lock(); + private readonly _connectionLock = new Lock(); + private readonly _networkId: number; private _baseDerivationPath: string; - private _ledgerEthereumClientFactoryAsync: LedgerEthereumClientFactoryAsync; + private readonly _ledgerEthereumClientFactoryAsync: LedgerEthereumClientFactoryAsync; private _ledgerClientIfExists?: LedgerEthereumClient; - private _shouldAlwaysAskForConfirmation: boolean; - private _addressSearchLimit: number; + private readonly _shouldAlwaysAskForConfirmation: boolean; + private readonly _addressSearchLimit: number; /** * Instantiates a LedgerSubprovider. Defaults to derivationPath set to `44'/60'/0'`. * TestRPC/Ganache defaults to `m/44'/60'/0'/0`, so set this in the configs if desired. diff --git a/packages/subproviders/src/subproviders/mnemonic_wallet.ts b/packages/subproviders/src/subproviders/mnemonic_wallet.ts index 596300425..1495112b6 100644 --- a/packages/subproviders/src/subproviders/mnemonic_wallet.ts +++ b/packages/subproviders/src/subproviders/mnemonic_wallet.ts @@ -20,10 +20,10 @@ const DEFAULT_ADDRESS_SEARCH_LIMIT = 1000; * all requests with accounts derived from the supplied mnemonic. */ export class MnemonicWalletSubprovider extends BaseWalletSubprovider { - private _addressSearchLimit: number; + private readonly _addressSearchLimit: number; private _baseDerivationPath: string; private _derivedKeyInfo: DerivedHDKeyInfo; - private _mnemonic: string; + private readonly _mnemonic: string; /** * Instantiates a MnemonicWalletSubprovider. Defaults to baseDerivationPath set to `44'/60'/0'/0`. diff --git a/packages/subproviders/src/subproviders/nonce_tracker.ts b/packages/subproviders/src/subproviders/nonce_tracker.ts index dcc421574..eea722aee 100644 --- a/packages/subproviders/src/subproviders/nonce_tracker.ts +++ b/packages/subproviders/src/subproviders/nonce_tracker.ts @@ -17,7 +17,7 @@ const NONCE_TOO_LOW_ERROR_MESSAGE = 'Transaction nonce is too low'; * We added the additional feature of clearing the cached nonce value when a `nonce value too low` error occurs. */ export class NonceTrackerSubprovider extends Subprovider { - private _nonceCache: { [address: string]: string } = {}; + private readonly _nonceCache: { [address: string]: string } = {}; private static _reconstructTransaction(payload: JSONRPCRequestPayload): EthereumTx { const raw = payload.params[0]; if (_.isUndefined(raw)) { diff --git a/packages/subproviders/src/subproviders/private_key_wallet.ts b/packages/subproviders/src/subproviders/private_key_wallet.ts index b3f48fd90..9d6fc487e 100644 --- a/packages/subproviders/src/subproviders/private_key_wallet.ts +++ b/packages/subproviders/src/subproviders/private_key_wallet.ts @@ -13,8 +13,8 @@ import { BaseWalletSubprovider } from './base_wallet_subprovider'; * all requests with the supplied Ethereum private key. */ export class PrivateKeyWalletSubprovider extends BaseWalletSubprovider { - private _address: string; - private _privateKeyBuffer: Buffer; + private readonly _address: string; + private readonly _privateKeyBuffer: Buffer; /** * Instantiates a PrivateKeyWalletSubprovider. * @param privateKey The corresponding private key to an Ethereum address diff --git a/packages/subproviders/src/subproviders/redundant_subprovider.ts b/packages/subproviders/src/subproviders/redundant_subprovider.ts index a60d6706e..7aa6226d5 100644 --- a/packages/subproviders/src/subproviders/redundant_subprovider.ts +++ b/packages/subproviders/src/subproviders/redundant_subprovider.ts @@ -12,7 +12,7 @@ import { Subprovider } from './subprovider'; * set of JSON RPC endpoints. */ export class RedundantSubprovider extends Subprovider { - private _subproviders: Subprovider[]; + private readonly _subproviders: Subprovider[]; private static async _firstSuccessAsync( subproviders: Subprovider[], payload: JSONRPCRequestPayload, diff --git a/packages/subproviders/src/subproviders/rpc_subprovider.ts b/packages/subproviders/src/subproviders/rpc_subprovider.ts index 3ad0e5325..d874c6f05 100644 --- a/packages/subproviders/src/subproviders/rpc_subprovider.ts +++ b/packages/subproviders/src/subproviders/rpc_subprovider.ts @@ -13,8 +13,8 @@ import { Subprovider } from './subprovider'; * It forwards on JSON RPC requests to the supplied `rpcUrl` endpoint */ export class RPCSubprovider extends Subprovider { - private _rpcUrl: string; - private _requestTimeoutMs: number; + private readonly _rpcUrl: string; + private readonly _requestTimeoutMs: number; constructor(rpcUrl: string, requestTimeoutMs: number = 20000) { super(); assert.isString('rpcUrl', rpcUrl); diff --git a/packages/subproviders/src/subproviders/signer.ts b/packages/subproviders/src/subproviders/signer.ts index f7329e00c..d5fd86897 100644 --- a/packages/subproviders/src/subproviders/signer.ts +++ b/packages/subproviders/src/subproviders/signer.ts @@ -12,7 +12,7 @@ import { Subprovider } from './subprovider'; * are passed onwards for subsequent subproviders to handle. */ export class SignerSubprovider extends Subprovider { - private _web3Wrapper: Web3Wrapper; + private readonly _web3Wrapper: Web3Wrapper; /** * Instantiates a new SignerSubprovider * @param provider Web3 provider that should handle all user account related requests diff --git a/packages/subproviders/src/utils/wallet_utils.ts b/packages/subproviders/src/utils/wallet_utils.ts index 3748077ef..4c233645b 100644 --- a/packages/subproviders/src/utils/wallet_utils.ts +++ b/packages/subproviders/src/utils/wallet_utils.ts @@ -6,8 +6,8 @@ import { DerivedHDKeyInfo } from '../types'; const DEFAULT_ADDRESS_SEARCH_LIMIT = 1000; class DerivedHDKeyInfoIterator implements IterableIterator<DerivedHDKeyInfo> { - private _parentDerivedKeyInfo: DerivedHDKeyInfo; - private _searchLimit: number; + private readonly _parentDerivedKeyInfo: DerivedHDKeyInfo; + private readonly _searchLimit: number; private _index: number; constructor(initialDerivedKey: DerivedHDKeyInfo, searchLimit: number = DEFAULT_ADDRESS_SEARCH_LIMIT) { diff --git a/packages/subproviders/test/integration/ledger_subprovider_test.ts b/packages/subproviders/test/integration/ledger_subprovider_test.ts index 103e8f952..527ee5b22 100644 --- a/packages/subproviders/test/integration/ledger_subprovider_test.ts +++ b/packages/subproviders/test/integration/ledger_subprovider_test.ts @@ -176,7 +176,7 @@ describe('LedgerSubprovider', () => { params: [tx], id: 1, }; - await promisify(defaultProvider.sendAsync, defaultProvider)(payload); + await promisify(defaultProvider.sendAsync.bind(defaultProvider))(payload); // Send transaction from Ledger tx = { diff --git a/packages/subproviders/test/unit/ledger_subprovider_test.ts b/packages/subproviders/test/unit/ledger_subprovider_test.ts index edff5144e..a1d146dbc 100644 --- a/packages/subproviders/test/unit/ledger_subprovider_test.ts +++ b/packages/subproviders/test/unit/ledger_subprovider_test.ts @@ -55,7 +55,7 @@ describe('LedgerSubprovider', () => { return ecSignature; }, transport: { - close: _.noop, + close: _.noop.bind(_), } as LedgerCommunicationClient, }; // tslint:enable:no-object-literal-type-assertion diff --git a/packages/subproviders/test/unit/nonce_tracker_subprovider_test.ts b/packages/subproviders/test/unit/nonce_tracker_subprovider_test.ts index c437d0815..05f213cf5 100644 --- a/packages/subproviders/test/unit/nonce_tracker_subprovider_test.ts +++ b/packages/subproviders/test/unit/nonce_tracker_subprovider_test.ts @@ -60,9 +60,9 @@ describe('NonceTrackerSubprovider', () => { const payload = { ...getTransactionCountPayload, params: ['0x0', 'pending'] }; - const response = await promisify<any>(provider.sendAsync, provider)(payload); + const response = await promisify<any>(provider.sendAsync.bind(provider))(payload); expect(response.result).to.be.eq('0x00'); - const secondResponse = await promisify<any>(provider.sendAsync, provider)(payload); + const secondResponse = await promisify<any>(provider.sendAsync.bind(provider))(payload); expect(secondResponse.result).to.be.eq('0x00'); }); it('does not cache the result for latest transaction count', async () => { @@ -74,9 +74,9 @@ describe('NonceTrackerSubprovider', () => { const payload = { ...getTransactionCountPayload, params: ['0x0', 'latest'] }; - const response = await promisify<any>(provider.sendAsync, provider)(payload); + const response = await promisify<any>(provider.sendAsync.bind(provider))(payload); expect(response.result).to.be.eq('0x00'); - const secondResponse = await promisify<any>(provider.sendAsync, provider)(payload); + const secondResponse = await promisify<any>(provider.sendAsync.bind(provider))(payload); expect(secondResponse.result).to.be.eq('0x99'); }); it('clears the cache on a Nonce Too Low Error', async () => { @@ -103,14 +103,14 @@ describe('NonceTrackerSubprovider', () => { params: [transaction.serialize()], }; - const response = await promisify<any>(provider.sendAsync, provider)(noncePayload); + const response = await promisify<any>(provider.sendAsync.bind(provider))(noncePayload); expect(response.result).to.be.eq('0x00'); - const secondResponse = await promisify<any>(provider.sendAsync, provider)(noncePayload); + const secondResponse = await promisify<any>(provider.sendAsync.bind(provider))(noncePayload); expect(secondResponse.result).to.be.eq('0x00'); try { - await promisify(provider.sendAsync, provider)(txPayload); + await promisify(provider.sendAsync.bind(provider))(txPayload); } catch (err) { - const thirdResponse = await promisify<any>(provider.sendAsync, provider)(noncePayload); + const thirdResponse = await promisify<any>(provider.sendAsync.bind(provider))(noncePayload); expect(thirdResponse.result).to.be.eq('0x99'); } }); @@ -138,12 +138,12 @@ describe('NonceTrackerSubprovider', () => { params: [transaction.serialize()], }; - const response = await promisify<any>(provider.sendAsync, provider)(noncePayload); + const response = await promisify<any>(provider.sendAsync.bind(provider))(noncePayload); expect(response.result).to.be.eq('0x00'); - const secondResponse = await promisify<any>(provider.sendAsync, provider)(noncePayload); + const secondResponse = await promisify<any>(provider.sendAsync.bind(provider))(noncePayload); expect(secondResponse.result).to.be.eq('0x00'); - await promisify(provider.sendAsync, provider)(txPayload); - const thirdResponse = await promisify<any>(provider.sendAsync, provider)(noncePayload); + await promisify(provider.sendAsync.bind(provider))(txPayload); + const thirdResponse = await promisify<any>(provider.sendAsync.bind(provider))(noncePayload); expect(thirdResponse.result).to.be.eq('0x01'); }); }); |