aboutsummaryrefslogtreecommitdiffstats
path: root/packages/subproviders/src
diff options
context:
space:
mode:
authorBrandon Millman <brandon.millman@gmail.com>2018-03-30 01:02:46 +0800
committerBrandon Millman <brandon.millman@gmail.com>2018-03-30 01:02:46 +0800
commit665011174bab7cfc6ec53e0044d60e1463222aee (patch)
tree44bc55bd390044d6cbfe8e0f7dddb621a8be7249 /packages/subproviders/src
parentd106079d9b69191d9cdc6d9323dbae3e4b45daf2 (diff)
parentc4dd9658e791a9f821ea3b6eb4326bcba53b081a (diff)
downloaddexon-sol-tools-665011174bab7cfc6ec53e0044d60e1463222aee.tar
dexon-sol-tools-665011174bab7cfc6ec53e0044d60e1463222aee.tar.gz
dexon-sol-tools-665011174bab7cfc6ec53e0044d60e1463222aee.tar.bz2
dexon-sol-tools-665011174bab7cfc6ec53e0044d60e1463222aee.tar.lz
dexon-sol-tools-665011174bab7cfc6ec53e0044d60e1463222aee.tar.xz
dexon-sol-tools-665011174bab7cfc6ec53e0044d60e1463222aee.tar.zst
dexon-sol-tools-665011174bab7cfc6ec53e0044d60e1463222aee.zip
Merge branch 'development' into feature/website/wallet-wrap
* development: (35 commits) Fix CHANGELOG Update Yarn.lock Standardize changelog dates and format Fix stubbing of a non-existent property Remove redundant cast Move common types out of web3 types Add monorepo_scripts to npmignore Add typeRoots Add clean-state tests Remove nested .gitignore files since `yarn publish` gets confused by them and ignores their contents on the top-level scope Remove WETH hack now that updated WETH address is in TokenRegistry Revert TokenRegistry address on Kovan Improve rounding error message Portal fill with mixed decimals Add error popover if TokenRegistry on network user is browsing on don't include the requisite default tokens for 0x Portal to function Set timeout for compiler tests Remove redundant types Add missing param comments Fix a comment Add a comment ...
Diffstat (limited to 'packages/subproviders/src')
-rw-r--r--packages/subproviders/src/globals.d.ts8
-rw-r--r--packages/subproviders/src/index.ts2
-rw-r--r--packages/subproviders/src/subproviders/empty_wallet_subprovider.ts4
-rw-r--r--packages/subproviders/src/subproviders/fake_gas_estimate_subprovider.ts4
-rw-r--r--packages/subproviders/src/subproviders/ganache.ts3
-rw-r--r--packages/subproviders/src/subproviders/injected_web3.ts3
-rw-r--r--packages/subproviders/src/subproviders/ledger.ts4
-rw-r--r--packages/subproviders/src/subproviders/nonce_tracker.ts17
-rw-r--r--packages/subproviders/src/subproviders/redundant_rpc.ts6
-rw-r--r--packages/subproviders/src/subproviders/subprovider.ts5
-rw-r--r--packages/subproviders/src/types.ts7
11 files changed, 28 insertions, 35 deletions
diff --git a/packages/subproviders/src/globals.d.ts b/packages/subproviders/src/globals.d.ts
index 2c86346f5..ebc4efe86 100644
--- a/packages/subproviders/src/globals.d.ts
+++ b/packages/subproviders/src/globals.d.ts
@@ -73,11 +73,11 @@ declare module 'web3-provider-engine/subproviders/subprovider' {
export = Subprovider;
}
declare module 'web3-provider-engine/subproviders/rpc' {
- import * as Web3 from 'web3';
+ import { JSONRPCRequestPayload } from '@0xproject/types';
class RpcSubprovider {
constructor(options: { rpcUrl: string });
public handleRequest(
- payload: Web3.JSONRPCRequestPayload,
+ payload: JSONRPCRequestPayload,
next: () => void,
end: (err: Error | null, data?: any) => void,
): void;
@@ -102,11 +102,11 @@ declare module 'web3-provider-engine/util/rpc-cache-utils' {
export = ProviderEngineRpcUtils;
}
declare module 'web3-provider-engine/subproviders/fixture' {
- import * as Web3 from 'web3';
+ import { JSONRPCRequestPayload } from '@0xproject/types';
class FixtureSubprovider {
constructor(staticResponses: any);
public handleRequest(
- payload: Web3.JSONRPCRequestPayload,
+ payload: JSONRPCRequestPayload,
next: () => void,
end: (err: Error | null, data?: any) => void,
): void;
diff --git a/packages/subproviders/src/index.ts b/packages/subproviders/src/index.ts
index d88792fd0..9786347e6 100644
--- a/packages/subproviders/src/index.ts
+++ b/packages/subproviders/src/index.ts
@@ -1,5 +1,6 @@
import Eth from '@ledgerhq/hw-app-eth';
import TransportU2F from '@ledgerhq/hw-transport-u2f';
+export { ECSignature } from '@0xproject/types';
import { LedgerEthereumClient } from './types';
@@ -15,7 +16,6 @@ export {
Callback,
ErrorCallback,
NextCallback,
- ECSignature,
LedgerWalletSubprovider,
LedgerCommunicationClient,
NonceSubproviderErrors,
diff --git a/packages/subproviders/src/subproviders/empty_wallet_subprovider.ts b/packages/subproviders/src/subproviders/empty_wallet_subprovider.ts
index dc570b152..595ec654d 100644
--- a/packages/subproviders/src/subproviders/empty_wallet_subprovider.ts
+++ b/packages/subproviders/src/subproviders/empty_wallet_subprovider.ts
@@ -1,4 +1,4 @@
-import * as Web3 from 'web3';
+import { JSONRPCRequestPayload } from '@0xproject/types';
import { Callback, ErrorCallback } from '../types';
@@ -18,7 +18,7 @@ export class EmptyWalletSubprovider 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
- public handleRequest(payload: Web3.JSONRPCRequestPayload, next: Callback, end: ErrorCallback) {
+ public handleRequest(payload: 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 a6f978db1..966c37d8a 100644
--- a/packages/subproviders/src/subproviders/fake_gas_estimate_subprovider.ts
+++ b/packages/subproviders/src/subproviders/fake_gas_estimate_subprovider.ts
@@ -1,4 +1,4 @@
-import * as Web3 from 'web3';
+import { JSONRPCRequestPayload } from '@0xproject/types';
import { Callback, ErrorCallback } from '../types';
@@ -32,7 +32,7 @@ export class FakeGasEstimateSubprovider 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
- public handleRequest(payload: Web3.JSONRPCRequestPayload, next: Callback, end: ErrorCallback) {
+ public handleRequest(payload: 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 fc0b9c3d2..785de792d 100644
--- a/packages/subproviders/src/subproviders/ganache.ts
+++ b/packages/subproviders/src/subproviders/ganache.ts
@@ -1,3 +1,4 @@
+import { JSONRPCRequestPayload } from '@0xproject/types';
import * as Ganache from 'ganache-core';
import * as Web3 from 'web3';
@@ -28,7 +29,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
- public handleRequest(payload: Web3.JSONRPCRequestPayload, next: Callback, end: ErrorCallback) {
+ public handleRequest(payload: 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 cd9b0b603..edecd8bf6 100644
--- a/packages/subproviders/src/subproviders/injected_web3.ts
+++ b/packages/subproviders/src/subproviders/injected_web3.ts
@@ -1,3 +1,4 @@
+import { JSONRPCRequestPayload } from '@0xproject/types';
import * as _ from 'lodash';
import * as Web3 from 'web3';
@@ -30,7 +31,7 @@ export class InjectedWeb3Subprovider 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
- public handleRequest(payload: Web3.JSONRPCRequestPayload, next: Callback, end: ErrorCallback) {
+ public handleRequest(payload: 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 8bc70d8b6..95784a391 100644
--- a/packages/subproviders/src/subproviders/ledger.ts
+++ b/packages/subproviders/src/subproviders/ledger.ts
@@ -1,11 +1,11 @@
import { assert } from '@0xproject/assert';
+import { JSONRPCRequestPayload } from '@0xproject/types';
import { addressUtils } from '@0xproject/utils';
import EthereumTx = require('ethereumjs-tx');
import ethUtil = require('ethereumjs-util');
import HDNode = require('hdkey');
import * as _ from 'lodash';
import { Lock } from 'semaphore-async-await';
-import * as Web3 from 'web3';
import {
Callback,
@@ -208,7 +208,7 @@ export class LedgerSubprovider extends Subprovider {
*/
// tslint:disable-next-line:async-suffix
public async handleRequest(
- payload: Web3.JSONRPCRequestPayload,
+ payload: 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 249f16199..907330111 100644
--- a/packages/subproviders/src/subproviders/nonce_tracker.ts
+++ b/packages/subproviders/src/subproviders/nonce_tracker.ts
@@ -1,9 +1,8 @@
import * as _ from 'lodash';
-import { BlockParamLiteral } from '@0xproject/types';
+import { BlockParamLiteral, JSONRPCRequestPayload } from '@0xproject/types';
import EthereumTx = require('ethereumjs-tx');
import ethUtil = require('ethereumjs-util');
-import * as Web3 from 'web3';
import providerEngineUtils = require('web3-provider-engine/util/rpc-cache-utils');
import { Callback, ErrorCallback, NextCallback, NonceSubproviderErrors } from '../types';
@@ -19,7 +18,7 @@ const NONCE_TOO_LOW_ERROR_MESSAGE = 'Transaction nonce is too low';
*/
export class NonceTrackerSubprovider extends Subprovider {
private _nonceCache: { [address: string]: string } = {};
- private static _reconstructTransaction(payload: Web3.JSONRPCRequestPayload): EthereumTx {
+ private static _reconstructTransaction(payload: JSONRPCRequestPayload): EthereumTx {
const raw = payload.params[0];
if (_.isUndefined(raw)) {
throw new Error(NonceSubproviderErrors.EmptyParametersFound);
@@ -28,7 +27,7 @@ export class NonceTrackerSubprovider extends Subprovider {
const transaction = new EthereumTx(rawData);
return transaction;
}
- private static _determineAddress(payload: Web3.JSONRPCRequestPayload): string {
+ private static _determineAddress(payload: JSONRPCRequestPayload): string {
let address: string;
switch (payload.method) {
case 'eth_getTransactionCount':
@@ -55,11 +54,7 @@ export class NonceTrackerSubprovider extends Subprovider {
* @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,
- ): Promise<void> {
+ public async handleRequest(payload: JSONRPCRequestPayload, next: NextCallback, end: ErrorCallback): Promise<void> {
switch (payload.method) {
case 'eth_getTransactionCount':
const requestDefaultBlock = providerEngineUtils.blockTagForPayload(payload);
@@ -92,7 +87,7 @@ export class NonceTrackerSubprovider extends Subprovider {
return next();
}
}
- private _handleSuccessfulTransaction(payload: Web3.JSONRPCRequestPayload): void {
+ private _handleSuccessfulTransaction(payload: JSONRPCRequestPayload): void {
const address = NonceTrackerSubprovider._determineAddress(payload);
const transaction = NonceTrackerSubprovider._reconstructTransaction(payload);
// Increment the nonce from the previous successfully submitted transaction
@@ -105,7 +100,7 @@ export class NonceTrackerSubprovider extends Subprovider {
const nextPrefixedHexNonce = `0x${nextHexNonce}`;
this._nonceCache[address] = nextPrefixedHexNonce;
}
- private _handleSendTransactionError(payload: Web3.JSONRPCRequestPayload, err: Error): void {
+ private _handleSendTransactionError(payload: JSONRPCRequestPayload, err: Error): void {
const address = NonceTrackerSubprovider._determineAddress(payload);
if (this._nonceCache[address] && _.includes(err.message, NONCE_TOO_LOW_ERROR_MESSAGE)) {
delete this._nonceCache[address];
diff --git a/packages/subproviders/src/subproviders/redundant_rpc.ts b/packages/subproviders/src/subproviders/redundant_rpc.ts
index ace2ed3c8..f8ff0915d 100644
--- a/packages/subproviders/src/subproviders/redundant_rpc.ts
+++ b/packages/subproviders/src/subproviders/redundant_rpc.ts
@@ -1,6 +1,6 @@
+import { JSONRPCRequestPayload } from '@0xproject/types';
import { promisify } from '@0xproject/utils';
import * as _ from 'lodash';
-import * as Web3 from 'web3';
import RpcSubprovider = require('web3-provider-engine/subproviders/rpc');
import { Callback } from '../types';
@@ -16,7 +16,7 @@ export class RedundantRPCSubprovider extends Subprovider {
private _rpcs: RpcSubprovider[];
private static async _firstSuccessAsync(
rpcs: RpcSubprovider[],
- payload: Web3.JSONRPCRequestPayload,
+ payload: JSONRPCRequestPayload,
next: Callback,
): Promise<any> {
let lastErr: Error | undefined;
@@ -55,7 +55,7 @@ export class RedundantRPCSubprovider extends Subprovider {
*/
// tslint:disable-next-line:async-suffix
public async handleRequest(
- payload: Web3.JSONRPCRequestPayload,
+ payload: JSONRPCRequestPayload,
next: Callback,
end: (err: Error | null, data?: any) => void,
): Promise<void> {
diff --git a/packages/subproviders/src/subproviders/subprovider.ts b/packages/subproviders/src/subproviders/subprovider.ts
index 4fa351e11..26ce19305 100644
--- a/packages/subproviders/src/subproviders/subprovider.ts
+++ b/packages/subproviders/src/subproviders/subprovider.ts
@@ -1,3 +1,4 @@
+import { JSONRPCRequestPayload, JSONRPCResponsePayload } from '@0xproject/types';
import promisify = require('es6-promisify');
import * as Web3 from 'web3';
@@ -37,9 +38,7 @@ export class Subprovider {
* @param payload JSON RPC payload
* @returns JSON RPC response payload
*/
- public async emitPayloadAsync(
- payload: Partial<JSONRPCRequestPayloadWithMethod>,
- ): Promise<Web3.JSONRPCResponsePayload> {
+ public async emitPayloadAsync(payload: Partial<JSONRPCRequestPayloadWithMethod>): Promise<JSONRPCResponsePayload> {
const finalPayload = Subprovider._createFinalPayload(payload);
const response = await promisify(this._engine.sendAsync, this._engine)(finalPayload);
return response;
diff --git a/packages/subproviders/src/types.ts b/packages/subproviders/src/types.ts
index 9bb9ff696..a1fec1882 100644
--- a/packages/subproviders/src/types.ts
+++ b/packages/subproviders/src/types.ts
@@ -1,8 +1,5 @@
-import { ECSignature } from '@0xproject/types';
+import { ECSignature, JSONRPCRequestPayload } from '@0xproject/types';
import * as _ from 'lodash';
-import * as Web3 from 'web3';
-
-export { ECSignature } from '@0xproject/types';
export interface LedgerCommunicationClient {
close: () => Promise<void>;
@@ -116,6 +113,6 @@ export type Callback = () => void;
export type OnNextCompleted = (err: Error | null, result: any, cb: Callback) => void;
export type NextCallback = (callback?: OnNextCompleted) => void;
-export interface JSONRPCRequestPayloadWithMethod extends Web3.JSONRPCRequestPayload {
+export interface JSONRPCRequestPayloadWithMethod extends JSONRPCRequestPayload {
method: string;
}