diff options
author | Jacob Evans <dekz@dekz.net> | 2018-06-18 19:50:35 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-18 19:50:35 +0800 |
commit | 190eafc30e2e444ed15b76217a6162ec04b33f73 (patch) | |
tree | b20cbad73ff7a069dc0f0ef43ebc0373c714ad02 /packages/subproviders | |
parent | d4ee0e862297c16f8ee62efccd31f1193052c64e (diff) | |
parent | 0c238448fda99c4d7997901d0fe4d72cb06b79cc (diff) | |
download | dexon-sol-tools-190eafc30e2e444ed15b76217a6162ec04b33f73.tar dexon-sol-tools-190eafc30e2e444ed15b76217a6162ec04b33f73.tar.gz dexon-sol-tools-190eafc30e2e444ed15b76217a6162ec04b33f73.tar.bz2 dexon-sol-tools-190eafc30e2e444ed15b76217a6162ec04b33f73.tar.lz dexon-sol-tools-190eafc30e2e444ed15b76217a6162ec04b33f73.tar.xz dexon-sol-tools-190eafc30e2e444ed15b76217a6162ec04b33f73.tar.zst dexon-sol-tools-190eafc30e2e444ed15b76217a6162ec04b33f73.zip |
Merge branch 'v2-prototype' into bug/contracts/eip712-191-prefix
Diffstat (limited to 'packages/subproviders')
17 files changed, 42 insertions, 59 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/package.json b/packages/subproviders/package.json index 3a28e5e8d..b222ace3b 100644 --- a/packages/subproviders/package.json +++ b/packages/subproviders/package.json @@ -8,12 +8,12 @@ "types": "lib/src/index.d.ts", "license": "Apache-2.0", "scripts": { - "watch": "tsc -w", - "clean": "shx rm -rf lib scripts", + "watch_without_deps": "tsc -w", "build": "tsc && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts", + "clean": "shx rm -rf lib scripts", "lint": "tslint --project .", - "run_mocha_unit": "mocha lib/test/unit/**/*_test.js --timeout 10000 --bail --exit", - "run_mocha_integration": "mocha lib/test/integration/**/*_test.js --timeout 10000 --bail --exit", + "run_mocha_unit": "mocha --require source-map-support/register lib/test/unit/**/*_test.js --timeout 10000 --bail --exit", + "run_mocha_integration": "mocha --require source-map-support/register lib/test/integration/**/*_test.js --timeout 10000 --bail --exit", "test": "npm run test:unit", "test:unit:coverage": "nyc npm run test:unit --all && yarn coverage:report:lcov", "coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info", diff --git a/packages/subproviders/src/subproviders/base_wallet_subprovider.ts b/packages/subproviders/src/subproviders/base_wallet_subprovider.ts index c4b344e3b..4342e47e9 100644 --- a/packages/subproviders/src/subproviders/base_wallet_subprovider.ts +++ b/packages/subproviders/src/subproviders/base_wallet_subprovider.ts @@ -3,7 +3,7 @@ import { addressUtils } from '@0xproject/utils'; import { JSONRPCRequestPayload, JSONRPCResponsePayload } from 'ethereum-types'; import * as _ from 'lodash'; -import { Callback, ErrorCallback, PartialTxParams, ResponseWithTxParams, WalletSubproviderErrors } from '../types'; +import { Callback, ErrorCallback, PartialTxParams, WalletSubproviderErrors } from '../types'; import { Subprovider } from './subprovider'; 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/injected_web3.ts b/packages/subproviders/src/subproviders/injected_web3.ts index 165c66d62..2691dec53 100644 --- a/packages/subproviders/src/subproviders/injected_web3.ts +++ b/packages/subproviders/src/subproviders/injected_web3.ts @@ -1,5 +1,4 @@ import { JSONRPCRequestPayload, Provider } from 'ethereum-types'; -import * as _ from 'lodash'; import * as Web3 from 'web3'; import { Callback, ErrorCallback } from '../types'; diff --git a/packages/subproviders/src/subproviders/ledger.ts b/packages/subproviders/src/subproviders/ledger.ts index 467299db0..8345be33c 100644 --- a/packages/subproviders/src/subproviders/ledger.ts +++ b/packages/subproviders/src/subproviders/ledger.ts @@ -7,14 +7,12 @@ import * as _ from 'lodash'; import { Lock } from 'semaphore-async-await'; import { - Callback, DerivedHDKeyInfo, LedgerEthereumClient, LedgerEthereumClientFactoryAsync, LedgerSubproviderConfigs, LedgerSubproviderErrors, PartialTxParams, - ResponseWithTxParams, WalletSubproviderErrors, } from '../types'; import { walletUtils } from '../utils/wallet_utils'; @@ -33,6 +31,7 @@ const DEFAULT_ADDRESS_SEARCH_LIMIT = 1000; * re-routes them to a Ledger device plugged into the users computer. */ export class LedgerSubprovider extends BaseWalletSubprovider { + // tslint:disable-next-line:no-unused-variable private _nonceLock = new Lock(); private _connectionLock = new Lock(); private _networkId: number; diff --git a/packages/subproviders/src/subproviders/mnemonic_wallet.ts b/packages/subproviders/src/subproviders/mnemonic_wallet.ts index f29864a74..596300425 100644 --- a/packages/subproviders/src/subproviders/mnemonic_wallet.ts +++ b/packages/subproviders/src/subproviders/mnemonic_wallet.ts @@ -1,7 +1,6 @@ import { assert } from '@0xproject/assert'; import { addressUtils } from '@0xproject/utils'; import * as bip39 from 'bip39'; -import ethUtil = require('ethereumjs-util'); import HDNode = require('hdkey'); import * as _ from 'lodash'; 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 f9491707e..ff8378c4e 100644 --- a/packages/subproviders/src/subproviders/subprovider.ts +++ b/packages/subproviders/src/subproviders/subprovider.ts @@ -1,6 +1,5 @@ import { promisify } from '@0xproject/utils'; -import { JSONRPCRequestPayload, JSONRPCResponsePayload } from 'ethereum-types'; -import * as Web3 from 'web3'; +import { JSONRPCRequestPayload, JSONRPCResponsePayload, Provider } from 'ethereum-types'; import { Callback, ErrorCallback, JSONRPCRequestPayloadWithMethod } from '../types'; /** @@ -9,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; @@ -57,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/src/types.ts b/packages/subproviders/src/types.ts index 7a8413305..fe58bffa5 100644 --- a/packages/subproviders/src/types.ts +++ b/packages/subproviders/src/types.ts @@ -1,7 +1,6 @@ import { ECSignature } from '@0xproject/types'; import { JSONRPCRequestPayload } from 'ethereum-types'; import HDNode = require('hdkey'); -import * as _ from 'lodash'; export interface LedgerCommunicationClient { close: () => Promise<void>; diff --git a/packages/subproviders/src/utils/wallet_utils.ts b/packages/subproviders/src/utils/wallet_utils.ts index c36fdb9fc..3748077ef 100644 --- a/packages/subproviders/src/utils/wallet_utils.ts +++ b/packages/subproviders/src/utils/wallet_utils.ts @@ -1,8 +1,7 @@ import ethUtil = require('ethereumjs-util'); import HDNode = require('hdkey'); -import * as _ from 'lodash'; -import { DerivedHDKeyInfo, WalletSubproviderErrors } from '../types'; +import { DerivedHDKeyInfo } from '../types'; const DEFAULT_ADDRESS_SEARCH_LIMIT = 1000; diff --git a/packages/subproviders/test/integration/ledger_subprovider_test.ts b/packages/subproviders/test/integration/ledger_subprovider_test.ts index 315dfa894..92d6614d3 100644 --- a/packages/subproviders/test/integration/ledger_subprovider_test.ts +++ b/packages/subproviders/test/integration/ledger_subprovider_test.ts @@ -7,9 +7,7 @@ import TransportNodeHid from '@ledgerhq/hw-transport-node-hid'; import * as chai from 'chai'; import { JSONRPCResponsePayload } from 'ethereum-types'; import * as ethUtils from 'ethereumjs-util'; -import * as _ from 'lodash'; import 'make-promises-safe'; -import Web3 = require('web3'); import Web3ProviderEngine = require('web3-provider-engine'); import RpcSubprovider = require('web3-provider-engine/subproviders/rpc'); diff --git a/packages/subproviders/test/unit/ledger_subprovider_test.ts b/packages/subproviders/test/unit/ledger_subprovider_test.ts index 17e72a694..bd1dad1f9 100644 --- a/packages/subproviders/test/unit/ledger_subprovider_test.ts +++ b/packages/subproviders/test/unit/ledger_subprovider_test.ts @@ -3,7 +3,6 @@ import { JSONRPCResponsePayload } from 'ethereum-types'; import * as ethUtils from 'ethereumjs-util'; import * as _ from 'lodash'; import 'make-promises-safe'; -import Web3 = require('web3'); import Web3ProviderEngine = require('web3-provider-engine'); import { LedgerSubprovider } from '../../src'; @@ -49,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', @@ -194,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(); @@ -209,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(); @@ -227,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(); @@ -246,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 fba221af0..331e52ea1 100644 --- a/packages/subproviders/test/unit/mnemonic_wallet_subprovider_test.ts +++ b/packages/subproviders/test/unit/mnemonic_wallet_subprovider_test.ts @@ -1,17 +1,11 @@ import * as chai from 'chai'; import { JSONRPCResponsePayload } from 'ethereum-types'; import * as ethUtils from 'ethereumjs-util'; -import * as _ from 'lodash'; import 'make-promises-safe'; import Web3ProviderEngine = require('web3-provider-engine'); import { GanacheSubprovider, MnemonicWalletSubprovider } from '../../src/'; -import { - DoneCallback, - LedgerCommunicationClient, - LedgerSubproviderErrors, - WalletSubproviderErrors, -} from '../../src/types'; +import { DoneCallback, WalletSubproviderErrors } from '../../src/types'; import { chaiSetup } from '../chai_setup'; import { fixtureData } from '../utils/fixture_data'; import { reportCallbackErrors } from '../utils/report_callback_errors'; @@ -136,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(); @@ -151,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(); @@ -166,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}`, @@ -186,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(); @@ -205,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 f4aa926d7..d799bce9e 100644 --- a/packages/subproviders/test/unit/nonce_tracker_subprovider_test.ts +++ b/packages/subproviders/test/unit/nonce_tracker_subprovider_test.ts @@ -1,8 +1,5 @@ import * as chai from 'chai'; -import * as fs from 'fs'; -import * as _ from 'lodash'; import 'make-promises-safe'; -import * as path from 'path'; import Web3ProviderEngine = require('web3-provider-engine'); import FixtureSubprovider = require('web3-provider-engine/subproviders/fixture'); @@ -44,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; @@ -91,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')); }, }), @@ -126,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 ac88d8cac..34295c25e 100644 --- a/packages/subproviders/test/unit/private_key_wallet_subprovider_test.ts +++ b/packages/subproviders/test/unit/private_key_wallet_subprovider_test.ts @@ -1,17 +1,11 @@ import * as chai from 'chai'; import { JSONRPCResponsePayload } from 'ethereum-types'; import * as ethUtils from 'ethereumjs-util'; -import * as _ from 'lodash'; import 'make-promises-safe'; import Web3ProviderEngine = require('web3-provider-engine'); import { GanacheSubprovider, PrivateKeyWalletSubprovider } from '../../src/'; -import { - DoneCallback, - LedgerCommunicationClient, - LedgerSubproviderErrors, - WalletSubproviderErrors, -} from '../../src/types'; +import { DoneCallback, WalletSubproviderErrors } from '../../src/types'; import { chaiSetup } from '../chai_setup'; import { fixtureData } from '../utils/fixture_data'; import { reportCallbackErrors } from '../utils/report_callback_errors'; @@ -107,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(); @@ -122,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(); @@ -137,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: ${ @@ -159,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(); @@ -178,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(); @@ -193,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(); diff --git a/packages/subproviders/test/unit/redundant_rpc_subprovider_test.ts b/packages/subproviders/test/unit/redundant_rpc_subprovider_test.ts index fcfec1367..b8b72259d 100644 --- a/packages/subproviders/test/unit/redundant_rpc_subprovider_test.ts +++ b/packages/subproviders/test/unit/redundant_rpc_subprovider_test.ts @@ -1,9 +1,7 @@ import { DoneCallback } from '@0xproject/types'; import * as chai from 'chai'; import { JSONRPCResponsePayload } from 'ethereum-types'; -import * as _ from 'lodash'; import 'make-promises-safe'; -import Web3 = require('web3'); import Web3ProviderEngine = require('web3-provider-engine'); import RpcSubprovider = require('web3-provider-engine/subproviders/rpc'); |