Fix remaining Provider to SupportedProvider type
This commit is contained in:
@@ -7,7 +7,7 @@ import {
|
||||
ContractAbi,
|
||||
DataItem,
|
||||
MethodAbi,
|
||||
Provider,
|
||||
SupportedProvider,
|
||||
TxData,
|
||||
TxDataPayable,
|
||||
} from 'ethereum-types';
|
||||
@@ -154,11 +154,11 @@ export class BaseContract {
|
||||
contractName: string,
|
||||
abi: ContractAbi,
|
||||
address: string,
|
||||
provider: Provider,
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults?: Partial<TxData>,
|
||||
) {
|
||||
this.contractName = contractName;
|
||||
this._web3Wrapper = new Web3Wrapper(provider, txDefaults);
|
||||
this._web3Wrapper = new Web3Wrapper(supportedProvider, txDefaults);
|
||||
this.abi = abi;
|
||||
this.address = address;
|
||||
const methodAbis = this.abi.filter(
|
||||
|
@@ -11,7 +11,7 @@ import {
|
||||
} from '@0x/contract-artifacts';
|
||||
import { AbiDecoder, providerUtils } from '@0x/utils';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import { Provider } from 'ethereum-types';
|
||||
import { Provider, SupportedProvider } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { DutchAuctionWrapper } from './contract_wrappers/dutch_auction_wrapper';
|
||||
@@ -76,18 +76,17 @@ export class ContractWrappers {
|
||||
private readonly _web3Wrapper: Web3Wrapper;
|
||||
/**
|
||||
* Instantiates a new ContractWrappers instance.
|
||||
* @param provider The Provider instance you would like the contract-wrappers library to use for interacting with
|
||||
* @param supportedProvider The Provider instance you would like the contract-wrappers library to use for interacting with
|
||||
* the Ethereum network.
|
||||
* @param config The configuration object. Look up the type for the description.
|
||||
* @return An instance of the ContractWrappers class.
|
||||
*/
|
||||
constructor(provider: Provider, config: ContractWrappersConfig) {
|
||||
providerUtils.standardizeOrThrow(provider);
|
||||
constructor(supportedProvider: SupportedProvider, config: ContractWrappersConfig) {
|
||||
assert.doesConformToSchema('config', config, ContractWrappersConfigSchema);
|
||||
const txDefaults = {
|
||||
gasPrice: config.gasPrice,
|
||||
};
|
||||
this._web3Wrapper = new Web3Wrapper(provider, txDefaults);
|
||||
this._web3Wrapper = new Web3Wrapper(supportedProvider, txDefaults);
|
||||
const artifactsArray = [
|
||||
DutchAuction,
|
||||
ERC20Proxy,
|
||||
|
@@ -5,7 +5,7 @@ import { assetDataUtils, signatureUtils } from '@0x/order-utils';
|
||||
import { Order } from '@0x/types'; // tslint:disable-line:no-unused-variable
|
||||
import { BigNumber } from '@0x/utils'; // tslint:disable-line:no-unused-variable
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import { Provider } from 'ethereum-types';
|
||||
import { SupportedProvider } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { constants } from './constants';
|
||||
@@ -13,12 +13,12 @@ import { constants } from './constants';
|
||||
export const assert = {
|
||||
...sharedAssert,
|
||||
async isValidSignatureAsync(
|
||||
provider: Provider,
|
||||
supportedProvider: SupportedProvider,
|
||||
orderHash: string,
|
||||
signature: string,
|
||||
signerAddress: string,
|
||||
): Promise<void> {
|
||||
const isValid = await signatureUtils.isValidSignatureAsync(provider, orderHash, signature, signerAddress);
|
||||
const isValid = await signatureUtils.isValidSignatureAsync(supportedProvider, orderHash, signature, signerAddress);
|
||||
sharedAssert.assert(isValid, `Expected order with hash '${orderHash}' to have a valid signature`);
|
||||
},
|
||||
isValidSubscriptionToken(variableName: string, subscriptionToken: string): void {
|
||||
|
@@ -52,7 +52,6 @@ export interface Web3JsV2Provider {
|
||||
* Interface for providers that conform to EIP 1193
|
||||
* Source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1193.md
|
||||
*/
|
||||
|
||||
export type EIP1193Event = 'accountsChanged' | 'networkChanged' | 'close' | 'connect' | 'notification';
|
||||
|
||||
export interface EIP1193Provider {
|
||||
|
@@ -3,9 +3,9 @@ import * as artifacts from '@0x/contract-artifacts';
|
||||
import { assetDataUtils } from '@0x/order-utils';
|
||||
import { orderFactory } from '@0x/order-utils/lib/src/order_factory';
|
||||
import { OrderWithoutExchangeAddress, SignedOrder } from '@0x/types';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import { BigNumber, providerUtils } from '@0x/utils';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import { Provider } from 'ethereum-types';
|
||||
import { SupportedProvider } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { constants } from './constants';
|
||||
@@ -19,13 +19,14 @@ export class FillScenarios {
|
||||
private readonly _erc20ProxyAddress: string;
|
||||
private readonly _erc721ProxyAddress: string;
|
||||
constructor(
|
||||
provider: Provider,
|
||||
supportedProvider: SupportedProvider,
|
||||
userAddresses: string[],
|
||||
zrxTokenAddress: string,
|
||||
exchangeAddress: string,
|
||||
erc20ProxyAddress: string,
|
||||
erc721ProxyAddress: string,
|
||||
) {
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
this._web3Wrapper = new Web3Wrapper(provider);
|
||||
this._userAddresses = userAddresses;
|
||||
this._coinbase = userAddresses[0];
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import { AssetBuyer, BigNumber } from '@0x/asset-buyer';
|
||||
import { AssetProxyId, ObjectMap, SignedOrder } from '@0x/types';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import { Provider } from 'ethereum-types';
|
||||
import { Provider, SupportedProvider } from 'ethereum-types';
|
||||
|
||||
// Reusable
|
||||
export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
|
||||
@@ -192,7 +192,7 @@ export interface ZeroExInstantRequiredBaseConfig {
|
||||
}
|
||||
|
||||
export interface ZeroExInstantOptionalBaseConfig {
|
||||
provider: Provider;
|
||||
provider: SupportedProvider;
|
||||
walletDisplayName: string;
|
||||
availableAssetDatas: string[];
|
||||
defaultAssetBuyAmount: number;
|
||||
|
@@ -1,17 +1,17 @@
|
||||
import { AssetBuyer, AssetBuyerOpts } from '@0x/asset-buyer';
|
||||
import { Provider } from 'ethereum-types';
|
||||
import { SupportedProvider } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { Network, OrderSource } from '../types';
|
||||
|
||||
export const assetBuyerFactory = {
|
||||
getAssetBuyer: (provider: Provider, orderSource: OrderSource, network: Network): AssetBuyer => {
|
||||
getAssetBuyer: (supportedProvider: SupportedProvider, orderSource: OrderSource, network: Network): AssetBuyer => {
|
||||
const assetBuyerOptions: Partial<AssetBuyerOpts> = {
|
||||
networkId: network,
|
||||
};
|
||||
const assetBuyer = _.isString(orderSource)
|
||||
? AssetBuyer.getAssetBuyerForStandardRelayerAPIUrl(provider, orderSource, assetBuyerOptions)
|
||||
: AssetBuyer.getAssetBuyerForProvidedOrders(provider, orderSource, assetBuyerOptions);
|
||||
? AssetBuyer.getAssetBuyerForStandardRelayerAPIUrl(supportedProvider, orderSource, assetBuyerOptions)
|
||||
: AssetBuyer.getAssetBuyerForProvidedOrders(supportedProvider, orderSource, assetBuyerOptions);
|
||||
return assetBuyer;
|
||||
},
|
||||
};
|
||||
|
@@ -1,5 +1,6 @@
|
||||
import { providerUtils } from '@0x/utils';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import { Provider } from 'ethereum-types';
|
||||
import { Provider, SupportedProvider } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { LOADING_ACCOUNT, NO_ACCOUNT } from '../constants';
|
||||
@@ -13,10 +14,11 @@ export const providerStateFactory = {
|
||||
getInitialProviderState: (
|
||||
orderSource: OrderSource,
|
||||
network: Network,
|
||||
provider?: Provider,
|
||||
supportedProvider?: SupportedProvider,
|
||||
walletDisplayName?: string,
|
||||
): ProviderState => {
|
||||
if (!_.isUndefined(provider)) {
|
||||
if (!_.isUndefined(supportedProvider)) {
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
return providerStateFactory.getInitialProviderStateFromProvider(
|
||||
orderSource,
|
||||
network,
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import { Order, SignedOrder } from '@0x/types';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import { Provider } from 'ethereum-types';
|
||||
import { SupportedProvider } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { constants } from './constants';
|
||||
@@ -52,7 +52,7 @@ export const orderFactory = {
|
||||
return order;
|
||||
},
|
||||
async createSignedOrderAsync(
|
||||
provider: Provider,
|
||||
supportedProvider: SupportedProvider,
|
||||
makerAddress: string,
|
||||
makerAssetAmount: BigNumber,
|
||||
makerAssetData: string,
|
||||
@@ -71,7 +71,7 @@ export const orderFactory = {
|
||||
createOrderOpts,
|
||||
);
|
||||
const orderHash = orderHashUtils.getOrderHashHex(order);
|
||||
const signature = await signatureUtils.ecSignHashAsync(provider, orderHash, makerAddress);
|
||||
const signature = await signatureUtils.ecSignHashAsync(supportedProvider, orderHash, makerAddress);
|
||||
const signedOrder: SignedOrder = _.assign(order, { signature });
|
||||
return signedOrder;
|
||||
},
|
||||
|
@@ -117,8 +117,9 @@ export class OrderValidationUtils {
|
||||
* @param orderFilledCancelledFetcher A module that implements the AbstractOrderFilledCancelledFetcher
|
||||
* @return An instance of OrderValidationUtils
|
||||
*/
|
||||
constructor(orderFilledCancelledFetcher: AbstractOrderFilledCancelledFetcher, provider: Provider) {
|
||||
constructor(orderFilledCancelledFetcher: AbstractOrderFilledCancelledFetcher, supportedProvider: SupportedProvider) {
|
||||
this._orderFilledCancelledFetcher = orderFilledCancelledFetcher;
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
this._provider = provider;
|
||||
}
|
||||
// TODO(fabio): remove this method once the smart contracts have been refactored
|
||||
|
@@ -5,7 +5,7 @@ import { schemas } from '@0x/json-schemas';
|
||||
import { ECSignature, Order, SignatureType, SignedOrder, ValidatorSignature } from '@0x/types';
|
||||
import { providerUtils } from '@0x/utils';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import { Provider } from 'ethereum-types';
|
||||
import { Provider, SupportedProvider } from 'ethereum-types';
|
||||
import * as ethUtil from 'ethereumjs-util';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
@@ -18,6 +18,7 @@ import { utils } from './utils';
|
||||
export const signatureUtils = {
|
||||
/**
|
||||
* Verifies that the provided signature is valid according to the 0x Protocol smart contracts
|
||||
* @param supportedProvider Web3 provider to use for all JSON RPC requests
|
||||
* @param data The hex encoded data signed by the supplied signature.
|
||||
* @param signature A hex encoded 0x Protocol signature made up of: [TypeSpecificData][SignatureType].
|
||||
* E.g [vrs][SignatureType.EIP712]
|
||||
@@ -25,12 +26,12 @@ export const signatureUtils = {
|
||||
* @return Whether the signature is valid for the supplied signerAddress and data.
|
||||
*/
|
||||
async isValidSignatureAsync(
|
||||
provider: Provider,
|
||||
supportedProvider: SupportedProvider,
|
||||
data: string,
|
||||
signature: string,
|
||||
signerAddress: string,
|
||||
): Promise<boolean> {
|
||||
providerUtils.standardizeOrThrow(provider);
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
assert.isHexString('data', data);
|
||||
assert.isHexString('signature', signature);
|
||||
assert.isETHAddressHex('signerAddress', signerAddress);
|
||||
@@ -85,13 +86,13 @@ export const signatureUtils = {
|
||||
},
|
||||
/**
|
||||
* Verifies that the provided presigned signature is valid according to the 0x Protocol smart contracts
|
||||
* @param provider Web3 provider to use for all JSON RPC requests
|
||||
* @param supportedProvider Web3 provider to use for all JSON RPC requests
|
||||
* @param data The hex encoded data signed by the supplied signature
|
||||
* @param signerAddress The hex encoded address that signed the data, producing the supplied signature.
|
||||
* @return Whether the data was preSigned by the supplied signerAddress
|
||||
*/
|
||||
async isValidPresignedSignatureAsync(provider: Provider, data: string, signerAddress: string): Promise<boolean> {
|
||||
providerUtils.standardizeOrThrow(provider);
|
||||
async isValidPresignedSignatureAsync(supportedProvider: SupportedProvider, data: string, signerAddress: string): Promise<boolean> {
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
assert.isHexString('data', data);
|
||||
assert.isETHAddressHex('signerAddress', signerAddress);
|
||||
const web3Wrapper = new Web3Wrapper(provider);
|
||||
@@ -107,19 +108,19 @@ export const signatureUtils = {
|
||||
},
|
||||
/**
|
||||
* Verifies that the provided wallet signature is valid according to the 0x Protocol smart contracts
|
||||
* @param provider Web3 provider to use for all JSON RPC requests
|
||||
* @param supportedProvider Web3 provider to use for all JSON RPC requests
|
||||
* @param data The hex encoded data signed by the supplied signature.
|
||||
* @param signature A hex encoded presigned 0x Protocol signature made up of: [SignatureType.Presigned]
|
||||
* @param signerAddress The hex encoded address that signed the data, producing the supplied signature.
|
||||
* @return Whether the data was preSigned by the supplied signerAddress.
|
||||
*/
|
||||
async isValidWalletSignatureAsync(
|
||||
provider: Provider,
|
||||
supportedProvider: SupportedProvider,
|
||||
data: string,
|
||||
signature: string,
|
||||
signerAddress: string,
|
||||
): Promise<boolean> {
|
||||
providerUtils.standardizeOrThrow(provider);
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
assert.isHexString('data', data);
|
||||
assert.isHexString('signature', signature);
|
||||
assert.isETHAddressHex('signerAddress', signerAddress);
|
||||
@@ -131,19 +132,19 @@ export const signatureUtils = {
|
||||
},
|
||||
/**
|
||||
* Verifies that the provided validator signature is valid according to the 0x Protocol smart contracts
|
||||
* @param provider Web3 provider to use for all JSON RPC requests
|
||||
* @param supportedProvider Web3 provider to use for all JSON RPC requests
|
||||
* @param data The hex encoded data signed by the supplied signature.
|
||||
* @param signature A hex encoded presigned 0x Protocol signature made up of: [SignatureType.Presigned]
|
||||
* @param signerAddress The hex encoded address that signed the data, producing the supplied signature.
|
||||
* @return Whether the data was preSigned by the supplied signerAddress.
|
||||
*/
|
||||
async isValidValidatorSignatureAsync(
|
||||
provider: Provider,
|
||||
supportedProvider: SupportedProvider,
|
||||
data: string,
|
||||
signature: string,
|
||||
signerAddress: string,
|
||||
): Promise<boolean> {
|
||||
providerUtils.standardizeOrThrow(provider);
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
assert.isHexString('data', data);
|
||||
assert.isHexString('signature', signature);
|
||||
assert.isETHAddressHex('signerAddress', signerAddress);
|
||||
@@ -203,15 +204,16 @@ export const signatureUtils = {
|
||||
/**
|
||||
* Signs an order and returns a SignedOrder. First `eth_signTypedData` is requested
|
||||
* then a fallback to `eth_sign` if not available on the supplied provider.
|
||||
* @param supportedProvider Web3 provider to use for all JSON RPC requests
|
||||
* @param order The Order to sign.
|
||||
* @param signerAddress The hex encoded Ethereum address you wish to sign it with. This address
|
||||
* must be available via the supplied Provider.
|
||||
* @return A SignedOrder containing the order and Elliptic curve signature with Signature Type.
|
||||
*/
|
||||
async ecSignOrderAsync(provider: Provider, order: Order, signerAddress: string): Promise<SignedOrder> {
|
||||
async ecSignOrderAsync(supportedProvider: SupportedProvider, order: Order, signerAddress: string): Promise<SignedOrder> {
|
||||
assert.doesConformToSchema('order', order, schemas.orderSchema, [schemas.hexSchema]);
|
||||
try {
|
||||
const signedOrder = await signatureUtils.ecSignTypedDataOrderAsync(provider, order, signerAddress);
|
||||
const signedOrder = await signatureUtils.ecSignTypedDataOrderAsync(supportedProvider, order, signerAddress);
|
||||
return signedOrder;
|
||||
} catch (err) {
|
||||
// HACK: We are unable to handle specific errors thrown since provider is not an object
|
||||
@@ -223,7 +225,7 @@ export const signatureUtils = {
|
||||
throw err;
|
||||
}
|
||||
const orderHash = orderHashUtils.getOrderHashHex(order);
|
||||
const signatureHex = await signatureUtils.ecSignHashAsync(provider, orderHash, signerAddress);
|
||||
const signatureHex = await signatureUtils.ecSignHashAsync(supportedProvider, orderHash, signerAddress);
|
||||
const signedOrder = {
|
||||
...order,
|
||||
signature: signatureHex,
|
||||
@@ -233,13 +235,14 @@ export const signatureUtils = {
|
||||
},
|
||||
/**
|
||||
* Signs an order using `eth_signTypedData` and returns a SignedOrder.
|
||||
* @param supportedProvider Web3 provider to use for all JSON RPC requests
|
||||
* @param order The Order to sign.
|
||||
* @param signerAddress The hex encoded Ethereum address you wish to sign it with. This address
|
||||
* must be available via the supplied Provider.
|
||||
* @return A SignedOrder containing the order and Elliptic curve signature with Signature Type.
|
||||
*/
|
||||
async ecSignTypedDataOrderAsync(provider: Provider, order: Order, signerAddress: string): Promise<SignedOrder> {
|
||||
providerUtils.standardizeOrThrow(provider);
|
||||
async ecSignTypedDataOrderAsync(supportedProvider: SupportedProvider, order: Order, signerAddress: string): Promise<SignedOrder> {
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
assert.isETHAddressHex('signerAddress', signerAddress);
|
||||
assert.doesConformToSchema('order', order, schemas.orderSchema, [schemas.hexSchema]);
|
||||
const web3Wrapper = new Web3Wrapper(provider);
|
||||
@@ -271,13 +274,14 @@ export const signatureUtils = {
|
||||
},
|
||||
/**
|
||||
* Signs a hash using `eth_sign` and returns its elliptic curve signature and signature type.
|
||||
* @param supportedProvider Web3 provider to use for all JSON RPC requests
|
||||
* @param msgHash Hex encoded message to sign.
|
||||
* @param signerAddress The hex encoded Ethereum address you wish to sign it with. This address
|
||||
* must be available via the supplied Provider.
|
||||
* @return A hex encoded string containing the Elliptic curve signature generated by signing the msgHash and the Signature Type.
|
||||
*/
|
||||
async ecSignHashAsync(provider: Provider, msgHash: string, signerAddress: string): Promise<string> {
|
||||
providerUtils.standardizeOrThrow(provider);
|
||||
async ecSignHashAsync(supportedProvider: SupportedProvider, msgHash: string, signerAddress: string): Promise<string> {
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
assert.isHexString('msgHash', msgHash);
|
||||
assert.isETHAddressHex('signerAddress', signerAddress);
|
||||
const web3Wrapper = new Web3Wrapper(provider);
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import { intervalUtils, logUtils } from '@0x/utils';
|
||||
import { marshaller, Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import { BlockParamLiteral, FilterObject, LogEntry, Provider, RawLogEntry } from 'ethereum-types';
|
||||
import { BlockParamLiteral, FilterObject, LogEntry, RawLogEntry, SupportedProvider } from 'ethereum-types';
|
||||
import { Block, BlockAndLogStreamer, Log } from 'ethereumjs-blockstream';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
@@ -27,13 +27,12 @@ export class EventWatcher {
|
||||
private _onLogRemovedSubscriptionToken: string | undefined;
|
||||
private readonly _pollingIntervalMs: number;
|
||||
constructor(
|
||||
provider: Provider,
|
||||
supportedProvider: SupportedProvider,
|
||||
pollingIntervalIfExistsMs: undefined | number,
|
||||
stateLayer: BlockParamLiteral,
|
||||
isVerbose: boolean,
|
||||
) {
|
||||
this._isVerbose = isVerbose;
|
||||
this._web3Wrapper = new Web3Wrapper(provider);
|
||||
this._web3Wrapper = new Web3Wrapper(supportedProvider);
|
||||
this._pollingIntervalMs = _.isUndefined(pollingIntervalIfExistsMs)
|
||||
? DEFAULT_EVENT_POLLING_INTERVAL_MS
|
||||
: pollingIntervalIfExistsMs;
|
||||
|
@@ -34,7 +34,7 @@ import {
|
||||
} from '@0x/order-utils';
|
||||
import { AssetProxyId, ExchangeContractErrs, OrderState, SignedOrder, Stats } from '@0x/types';
|
||||
import { errorUtils, intervalUtils, providerUtils } from '@0x/utils';
|
||||
import { BlockParamLiteral, LogEntryEvent, LogWithDecodedArgs, Provider } from 'ethereum-types';
|
||||
import { BlockParamLiteral, LogEntryEvent, LogWithDecodedArgs, Provider, SupportedProvider } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { orderWatcherPartialConfigSchema } from '../schemas/order_watcher_partial_config_schema';
|
||||
@@ -90,19 +90,19 @@ export class OrderWatcher {
|
||||
private _callbackIfExists?: OnOrderStateChangeCallback;
|
||||
/**
|
||||
* Instantiate a new OrderWatcher
|
||||
* @param provider Web3 provider to use for JSON RPC calls
|
||||
* @param supportedProvider Web3 provider to use for JSON RPC calls
|
||||
* @param networkId NetworkId to watch orders on
|
||||
* @param contractAddresses Optional contract addresses. Defaults to known
|
||||
* addresses based on networkId.
|
||||
* @param partialConfig Optional configurations
|
||||
*/
|
||||
constructor(
|
||||
provider: Provider,
|
||||
supportedProvider: SupportedProvider,
|
||||
networkId: number,
|
||||
contractAddresses?: ContractAddresses,
|
||||
partialConfig: Partial<OrderWatcherConfig> = DEFAULT_ORDER_WATCHER_CONFIG,
|
||||
) {
|
||||
providerUtils.standardizeOrThrow(provider);
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
assert.isNumber('networkId', networkId);
|
||||
assert.doesConformToSchema('partialConfig', partialConfig, orderWatcherPartialConfigSchema);
|
||||
const config = {
|
||||
@@ -122,7 +122,7 @@ export class OrderWatcher {
|
||||
// default values for contractAddresses.
|
||||
contractAddresses,
|
||||
});
|
||||
this._eventWatcher = new EventWatcher(provider, config.eventPollingIntervalMs, STATE_LAYER, config.isVerbose);
|
||||
this._eventWatcher = new EventWatcher(provider, config.eventPollingIntervalMs, config.isVerbose);
|
||||
const balanceAndProxyAllowanceFetcher = new AssetBalanceAndProxyAllowanceFetcher(
|
||||
contractWrappers.erc20Token,
|
||||
contractWrappers.erc721Token,
|
||||
|
@@ -2,7 +2,7 @@ import { ContractAddresses } from '@0x/contract-addresses';
|
||||
import { schemas } from '@0x/json-schemas';
|
||||
import { OrderStateInvalid, OrderStateValid, SignedOrder } from '@0x/types';
|
||||
import { BigNumber, logUtils } from '@0x/utils';
|
||||
import { Provider } from 'ethereum-types';
|
||||
import { SupportedProvider } from 'ethereum-types';
|
||||
import * as http from 'http';
|
||||
import * as WebSocket from 'websocket';
|
||||
|
||||
@@ -43,7 +43,7 @@ export class OrderWatcherWebSocketServer {
|
||||
|
||||
/**
|
||||
* Instantiate a new WebSocket server which provides OrderWatcher functionality
|
||||
* @param provider Web3 provider to use for JSON RPC calls.
|
||||
* @param supportedProvider Web3 provider to use for JSON RPC calls.
|
||||
* @param networkId NetworkId to watch orders on.
|
||||
* @param contractAddresses Optional contract addresses. Defaults to known
|
||||
* addresses based on networkId.
|
||||
@@ -51,7 +51,7 @@ export class OrderWatcherWebSocketServer {
|
||||
* @param isVerbose Whether to enable verbose logging. Defaults to true.
|
||||
*/
|
||||
constructor(
|
||||
provider: Provider,
|
||||
supportedProvider: SupportedProvider,
|
||||
networkId: number,
|
||||
contractAddresses?: ContractAddresses,
|
||||
orderWatcherConfig?: Partial<OrderWatcherConfig>,
|
||||
@@ -60,7 +60,7 @@ export class OrderWatcherWebSocketServer {
|
||||
orderWatcherConfig !== undefined && orderWatcherConfig.isVerbose !== undefined
|
||||
? orderWatcherConfig.isVerbose
|
||||
: true;
|
||||
this._orderWatcher = new OrderWatcher(provider, networkId, contractAddresses, orderWatcherConfig);
|
||||
this._orderWatcher = new OrderWatcher(supportedProvider, networkId, contractAddresses, orderWatcherConfig);
|
||||
this._connectionStore = new Set();
|
||||
this._httpServer = http.createServer();
|
||||
this._wsServer = new WebSocket.server({
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import { marshaller, Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import { JSONRPCRequestPayload, Provider } from 'ethereum-types';
|
||||
import { JSONRPCRequestPayload, SupportedProvider } from 'ethereum-types';
|
||||
|
||||
import { Callback, ErrorCallback } from '../types';
|
||||
|
||||
@@ -17,9 +17,9 @@ export class SignerSubprovider extends Subprovider {
|
||||
* Instantiates a new SignerSubprovider.
|
||||
* @param provider Web3 provider that should handle all user account related requests
|
||||
*/
|
||||
constructor(provider: Provider) {
|
||||
constructor(supportedProvider: SupportedProvider) {
|
||||
super();
|
||||
this._web3Wrapper = new Web3Wrapper(provider);
|
||||
this._web3Wrapper = new Web3Wrapper(supportedProvider);
|
||||
}
|
||||
/**
|
||||
* This method conforms to the web3-provider-engine interface.
|
||||
|
@@ -20,7 +20,7 @@ import {
|
||||
Web3ProviderEngine,
|
||||
} from '@0x/subproviders';
|
||||
import { SignedOrder, Token as ZeroExToken } from '@0x/types';
|
||||
import { BigNumber, intervalUtils, logUtils } from '@0x/utils';
|
||||
import { BigNumber, intervalUtils, logUtils, providerUtils } from '@0x/utils';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import { BlockParam, LogWithDecodedArgs, Provider, TransactionReceiptWithDecodedLogs } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
@@ -597,8 +597,9 @@ export class Blockchain {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
this._injectedProviderIfExists = injectedProviderIfExists;
|
||||
return injectedProviderIfExists;
|
||||
const standardizedInjectedProvider = providerUtils.standardizeOrThrow(injectedProviderIfExists);
|
||||
this._injectedProviderIfExists = standardizedInjectedProvider;
|
||||
return standardizedInjectedProvider;
|
||||
}
|
||||
private async _getInjectedProviderNetworkIdIfExistsAsync(): Promise<number | undefined> {
|
||||
// If the user has an injectedWeb3 instance that is disconnected from a backing
|
||||
|
Reference in New Issue
Block a user