diff options
Diffstat (limited to 'packages/subproviders')
8 files changed, 33 insertions, 24 deletions
diff --git a/packages/subproviders/CHANGELOG.json b/packages/subproviders/CHANGELOG.json index d3bf79ac4..d7fe5e330 100644 --- a/packages/subproviders/CHANGELOG.json +++ b/packages/subproviders/CHANGELOG.json @@ -1,5 +1,14 @@ [ { + "version": "0.10.3", + "changes": [ + { + "note": "Define engine type as Provider in setEngine", + "pr": 675 + } + ] + }, + { "timestamp": 1527009133, "version": "0.10.2", "changes": [ diff --git a/packages/subproviders/src/subproviders/ganache.ts b/packages/subproviders/src/subproviders/ganache.ts index 73d0513cc..61b6bb5e9 100644 --- a/packages/subproviders/src/subproviders/ganache.ts +++ b/packages/subproviders/src/subproviders/ganache.ts @@ -28,7 +28,7 @@ export class GanacheSubprovider extends Subprovider { * @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 - public async handleRequest(payload: JSONRPCRequestPayload, next: Callback, end: ErrorCallback): Promise<void> { + public async handleRequest(payload: JSONRPCRequestPayload, _next: Callback, end: ErrorCallback): Promise<void> { this._ganacheProvider.sendAsync(payload, (err: Error | null, result: any) => { end(err, result && result.result); }); diff --git a/packages/subproviders/src/subproviders/nonce_tracker.ts b/packages/subproviders/src/subproviders/nonce_tracker.ts index 98773e79c..dcc421574 100644 --- a/packages/subproviders/src/subproviders/nonce_tracker.ts +++ b/packages/subproviders/src/subproviders/nonce_tracker.ts @@ -75,7 +75,7 @@ export class NonceTrackerSubprovider extends Subprovider { return next(); } case 'eth_sendRawTransaction': - return next((sendTransactionError: Error | null, txResult: any, cb: Callback) => { + return next((sendTransactionError: Error | null, _txResult: any, cb: Callback) => { if (_.isNull(sendTransactionError)) { this._handleSuccessfulTransaction(payload); } else { diff --git a/packages/subproviders/src/subproviders/subprovider.ts b/packages/subproviders/src/subproviders/subprovider.ts index 329bf7d9c..ff8378c4e 100644 --- a/packages/subproviders/src/subproviders/subprovider.ts +++ b/packages/subproviders/src/subproviders/subprovider.ts @@ -1,5 +1,5 @@ import { promisify } from '@0xproject/utils'; -import { JSONRPCRequestPayload, JSONRPCResponsePayload } from 'ethereum-types'; +import { JSONRPCRequestPayload, JSONRPCResponsePayload, Provider } from 'ethereum-types'; import { Callback, ErrorCallback, JSONRPCRequestPayloadWithMethod } from '../types'; /** @@ -8,7 +8,7 @@ import { Callback, ErrorCallback, JSONRPCRequestPayloadWithMethod } from '../typ */ export abstract class Subprovider { // tslint:disable-next-line:underscore-private-and-protected - private engine: any; + private engine!: Provider; // Ported from: https://github.com/MetaMask/provider-engine/blob/master/util/random-id.js private static _getRandomId(): number { const extraDigits = 3; @@ -56,7 +56,7 @@ export abstract class Subprovider { * This is only called within the ProviderEngine source code, do not call * directly. */ - public setEngine(engine: any): void { + public setEngine(engine: Provider): void { this.engine = engine; } } diff --git a/packages/subproviders/test/unit/ledger_subprovider_test.ts b/packages/subproviders/test/unit/ledger_subprovider_test.ts index d3efb6abc..bd1dad1f9 100644 --- a/packages/subproviders/test/unit/ledger_subprovider_test.ts +++ b/packages/subproviders/test/unit/ledger_subprovider_test.ts @@ -48,7 +48,7 @@ describe('LedgerSubprovider', () => { }; return ecSignature; }, - signTransaction: async (derivationPath: string, txHex: string) => { + signTransaction: async (_derivationPath: string, _txHex: string) => { const ecSignature = { v: '77', r: '88a95ef1378487bc82be558e82c8478baf840c545d5b887536bb1da63673a98b', @@ -193,7 +193,7 @@ describe('LedgerSubprovider', () => { params: [FAKE_ADDRESS, nonHexMessage], id: 1, }; - const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => { + const callback = reportCallbackErrors(done)((err: Error, _response: JSONRPCResponsePayload) => { expect(err).to.not.be.a('null'); expect(err.message).to.be.equal('Expected data to be of type HexString, encountered: hello world'); done(); @@ -208,7 +208,7 @@ describe('LedgerSubprovider', () => { params: [nonHexMessage, FAKE_ADDRESS], id: 1, }; - const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => { + const callback = reportCallbackErrors(done)((err: Error, _response: JSONRPCResponsePayload) => { expect(err).to.not.be.a('null'); expect(err.message).to.be.equal('Expected data to be of type HexString, encountered: hello world'); done(); @@ -226,7 +226,7 @@ describe('LedgerSubprovider', () => { params: [tx], id: 1, }; - const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => { + const callback = reportCallbackErrors(done)((err: Error, _response: JSONRPCResponsePayload) => { expect(err).to.not.be.a('null'); expect(err.message).to.be.equal(WalletSubproviderErrors.SenderInvalidOrNotSupplied); done(); @@ -245,7 +245,7 @@ describe('LedgerSubprovider', () => { params: [tx], id: 1, }; - const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => { + const callback = reportCallbackErrors(done)((err: Error, _response: JSONRPCResponsePayload) => { expect(err).to.not.be.a('null'); expect(err.message).to.be.equal(WalletSubproviderErrors.SenderInvalidOrNotSupplied); done(); diff --git a/packages/subproviders/test/unit/mnemonic_wallet_subprovider_test.ts b/packages/subproviders/test/unit/mnemonic_wallet_subprovider_test.ts index 794c40d1d..331e52ea1 100644 --- a/packages/subproviders/test/unit/mnemonic_wallet_subprovider_test.ts +++ b/packages/subproviders/test/unit/mnemonic_wallet_subprovider_test.ts @@ -130,7 +130,7 @@ describe('MnemonicWalletSubprovider', () => { params: [fixtureData.TEST_RPC_ACCOUNT_0, nonHexMessage], id: 1, }; - const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => { + const callback = reportCallbackErrors(done)((err: Error, _response: JSONRPCResponsePayload) => { expect(err).to.not.be.a('null'); expect(err.message).to.be.equal('Expected data to be of type HexString, encountered: hello world'); done(); @@ -145,7 +145,7 @@ describe('MnemonicWalletSubprovider', () => { params: [nonHexMessage, fixtureData.TEST_RPC_ACCOUNT_0], id: 1, }; - const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => { + const callback = reportCallbackErrors(done)((err: Error, _response: JSONRPCResponsePayload) => { expect(err).to.not.be.a('null'); expect(err.message).to.be.equal('Expected data to be of type HexString, encountered: hello world'); done(); @@ -160,7 +160,7 @@ describe('MnemonicWalletSubprovider', () => { params: [messageHex, fixtureData.NULL_ADDRESS], id: 1, }; - const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => { + const callback = reportCallbackErrors(done)((err: Error, _response: JSONRPCResponsePayload) => { expect(err).to.not.be.a('null'); expect(err.message).to.be.equal( `${WalletSubproviderErrors.AddressNotFound}: ${fixtureData.NULL_ADDRESS}`, @@ -180,7 +180,7 @@ describe('MnemonicWalletSubprovider', () => { params: [tx], id: 1, }; - const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => { + const callback = reportCallbackErrors(done)((err: Error, _response: JSONRPCResponsePayload) => { expect(err).to.not.be.a('null'); expect(err.message).to.be.equal(WalletSubproviderErrors.SenderInvalidOrNotSupplied); done(); @@ -199,7 +199,7 @@ describe('MnemonicWalletSubprovider', () => { params: [tx], id: 1, }; - const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => { + const callback = reportCallbackErrors(done)((err: Error, _response: JSONRPCResponsePayload) => { expect(err).to.not.be.a('null'); expect(err.message).to.be.equal(WalletSubproviderErrors.SenderInvalidOrNotSupplied); done(); diff --git a/packages/subproviders/test/unit/nonce_tracker_subprovider_test.ts b/packages/subproviders/test/unit/nonce_tracker_subprovider_test.ts index 2475dde7a..d799bce9e 100644 --- a/packages/subproviders/test/unit/nonce_tracker_subprovider_test.ts +++ b/packages/subproviders/test/unit/nonce_tracker_subprovider_test.ts @@ -41,7 +41,7 @@ describe('NonceTrackerSubprovider', () => { let isFirstGetTransactionCount = true; const fixedBlockNumberAndTransactionCountProvider = new FixtureSubprovider({ eth_getBlockByNumber: '0x01', - eth_getTransactionCount: (data: any, next: any, end: any) => { + eth_getTransactionCount: (_data: any, _next: any, end: any) => { // For testing caching we return different results on the second call if (isFirstGetTransactionCount) { isFirstGetTransactionCount = false; @@ -88,7 +88,7 @@ describe('NonceTrackerSubprovider', () => { provider.addProvider(createFixtureSubprovider()); provider.addProvider( new FixtureSubprovider({ - eth_sendRawTransaction: (data: any, next: any, end: any) => { + eth_sendRawTransaction: (_data: any, _next: any, end: any) => { end(new Error('Transaction nonce is too low')); }, }), @@ -123,7 +123,7 @@ describe('NonceTrackerSubprovider', () => { provider.addProvider(createFixtureSubprovider()); provider.addProvider( new FixtureSubprovider({ - eth_sendRawTransaction: (data: any, next: any, end: any) => { + eth_sendRawTransaction: (_data: any, _next: any, end: any) => { end(null); }, }), diff --git a/packages/subproviders/test/unit/private_key_wallet_subprovider_test.ts b/packages/subproviders/test/unit/private_key_wallet_subprovider_test.ts index ef7919801..34295c25e 100644 --- a/packages/subproviders/test/unit/private_key_wallet_subprovider_test.ts +++ b/packages/subproviders/test/unit/private_key_wallet_subprovider_test.ts @@ -101,7 +101,7 @@ describe('PrivateKeyWalletSubprovider', () => { params: [fixtureData.TEST_RPC_ACCOUNT_0, nonHexMessage], id: 1, }; - const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => { + const callback = reportCallbackErrors(done)((err: Error, _response: JSONRPCResponsePayload) => { expect(err).to.not.be.a('null'); expect(err.message).to.be.equal('Expected data to be of type HexString, encountered: hello world'); done(); @@ -116,7 +116,7 @@ describe('PrivateKeyWalletSubprovider', () => { params: [nonHexMessage, fixtureData.TEST_RPC_ACCOUNT_0], id: 1, }; - const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => { + const callback = reportCallbackErrors(done)((err: Error, _response: JSONRPCResponsePayload) => { expect(err).to.not.be.a('null'); expect(err.message).to.be.equal('Expected data to be of type HexString, encountered: hello world'); done(); @@ -131,7 +131,7 @@ describe('PrivateKeyWalletSubprovider', () => { params: [messageHex, fixtureData.TEST_RPC_ACCOUNT_1], id: 1, }; - const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => { + const callback = reportCallbackErrors(done)((err: Error, _response: JSONRPCResponsePayload) => { expect(err).to.not.be.a('null'); expect(err.message).to.be.equal( `Requested to sign message with address: ${ @@ -153,7 +153,7 @@ describe('PrivateKeyWalletSubprovider', () => { params: [tx], id: 1, }; - const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => { + const callback = reportCallbackErrors(done)((err: Error, _response: JSONRPCResponsePayload) => { expect(err).to.not.be.a('null'); expect(err.message).to.be.equal(WalletSubproviderErrors.SenderInvalidOrNotSupplied); done(); @@ -172,7 +172,7 @@ describe('PrivateKeyWalletSubprovider', () => { params: [tx], id: 1, }; - const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => { + const callback = reportCallbackErrors(done)((err: Error, _response: JSONRPCResponsePayload) => { expect(err).to.not.be.a('null'); expect(err.message).to.be.equal(WalletSubproviderErrors.SenderInvalidOrNotSupplied); done(); @@ -187,7 +187,7 @@ describe('PrivateKeyWalletSubprovider', () => { params: [messageHex, '0x0'], id: 1, }; - const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => { + const callback = reportCallbackErrors(done)((err: Error, _response: JSONRPCResponsePayload) => { expect(err).to.not.be.a('null'); expect(err.message).to.be.equal(`Expected address to be of type ETHAddressHex, encountered: 0x0`); done(); |