aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2017-11-10 05:59:41 +0800
committerFabio Berger <me@fabioberger.com>2017-11-10 05:59:41 +0800
commit126a165f558326625d892c4a379c0ebd66088c9a (patch)
treeac7b872b3cd84e0fcb650845eae08bf40c841f50 /src
parent6f5a55b5fe4c6f0f56303b6ac5dcbd99129ee7bd (diff)
downloaddexon-sol-tools-126a165f558326625d892c4a379c0ebd66088c9a.tar
dexon-sol-tools-126a165f558326625d892c4a379c0ebd66088c9a.tar.gz
dexon-sol-tools-126a165f558326625d892c4a379c0ebd66088c9a.tar.bz2
dexon-sol-tools-126a165f558326625d892c4a379c0ebd66088c9a.tar.lz
dexon-sol-tools-126a165f558326625d892c4a379c0ebd66088c9a.tar.xz
dexon-sol-tools-126a165f558326625d892c4a379c0ebd66088c9a.tar.zst
dexon-sol-tools-126a165f558326625d892c4a379c0ebd66088c9a.zip
Add nested config for orderWatcher
Diffstat (limited to 'src')
-rw-r--r--src/0x.ts5
-rw-r--r--src/order_watcher/order_state_watcher.ts4
-rw-r--r--src/schemas/zero_ex_config_schema.ts11
-rw-r--r--src/types.ts11
4 files changed, 23 insertions, 8 deletions
diff --git a/src/0x.ts b/src/0x.ts
index 75a154930..dfe64f2df 100644
--- a/src/0x.ts
+++ b/src/0x.ts
@@ -26,6 +26,7 @@ import {
SignedOrder,
Web3Provider,
ZeroExConfig,
+ OrderStateWatcherConfig,
TransactionReceiptWithDecodedLogs,
} from './types';
import {zeroExConfigSchema} from './schemas/zero_ex_config_schema';
@@ -213,10 +214,10 @@ export class ZeroEx {
this.tokenRegistry = new TokenRegistryWrapper(this._web3Wrapper, 'tokenRegistryContractAddressIfExists');
const etherTokenContractAddressIfExists = _.get(config, 'etherTokenContractAddress');
this.etherToken = new EtherTokenWrapper(this._web3Wrapper, this.token, 'etherTokenContractAddressIfExists');
- const mempoolPollingIntervalMs: number|undefined = _.get(config, 'mempoolPollingIntervalMs');
+ const orderWatcherConfig: OrderStateWatcherConfig|undefined = _.get(config, 'orderWatcherConfig');
const orderStateUtils = new OrderStateUtils(this.token, this.exchange);
this.orderStateWatcher = new OrderStateWatcher(
- this._web3Wrapper, this._abiDecoder, orderStateUtils, mempoolPollingIntervalMs,
+ this._web3Wrapper, this._abiDecoder, orderStateUtils, orderWatcherConfig,
);
}
/**
diff --git a/src/order_watcher/order_state_watcher.ts b/src/order_watcher/order_state_watcher.ts
index e31fc962d..14b5b6cf9 100644
--- a/src/order_watcher/order_state_watcher.ts
+++ b/src/order_watcher/order_state_watcher.ts
@@ -15,6 +15,7 @@ import {
BlockParamLiteral,
LogWithDecodedArgs,
OnOrderStateChangeCallback,
+ OrderStateWatcherConfig,
ExchangeEvents,
TokenEvents,
ZeroExError,
@@ -41,10 +42,11 @@ export class OrderStateWatcher {
private _orderStateUtils: OrderStateUtils;
constructor(
web3Wrapper: Web3Wrapper, abiDecoder: AbiDecoder, orderStateUtils: OrderStateUtils,
- eventPollingIntervalMs?: number) {
+ config?: OrderStateWatcherConfig) {
this._web3Wrapper = web3Wrapper;
this._orders = {};
this._dependentOrderHashes = {};
+ const eventPollingIntervalMs = _.isUndefined(config) ? undefined : config.pollingIntervalMs;
this._eventWatcher = new EventWatcher(
this._web3Wrapper, eventPollingIntervalMs,
);
diff --git a/src/schemas/zero_ex_config_schema.ts b/src/schemas/zero_ex_config_schema.ts
index 5be651a9a..5a2afeaa2 100644
--- a/src/schemas/zero_ex_config_schema.ts
+++ b/src/schemas/zero_ex_config_schema.ts
@@ -5,9 +5,14 @@ export const zeroExConfigSchema = {
exchangeContractAddress: {$ref: '/Address'},
tokenRegistryContractAddress: {$ref: '/Address'},
etherTokenContractAddress: {$ref: '/Address'},
- mempoolPollingIntervalMs: {
- type: 'number',
- min: 0,
+ orderWatcherConfig: {
+ type: 'object',
+ properties: {
+ pollingIntervalMs: {
+ type: 'number',
+ minimum: 0,
+ },
+ },
},
},
type: 'object',
diff --git a/src/types.ts b/src/types.ts
index 4a0a74826..704c0b866 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -396,18 +396,25 @@ export interface JSONRPCPayload {
}
/*
+ * pollingIntervalMs: How often to check for new mempool events
+ */
+export interface OrderStateWatcherConfig {
+ pollingIntervalMs?: number;
+}
+
+/*
* gasPrice: Gas price to use with every transaction
* exchangeContractAddress: The address of an exchange contract to use
* tokenRegistryContractAddress: The address of a token registry contract to use
* etherTokenContractAddress: The address of an ether token contract to use
- * mempoolPollingIntervalMs: How often to check for new mempool events
+ * orderWatcherConfig: All the configs related to the orderWatcher
*/
export interface ZeroExConfig {
gasPrice?: BigNumber; // Gas price to use with every transaction
exchangeContractAddress?: string;
tokenRegistryContractAddress?: string;
etherTokenContractAddress?: string;
- mempoolPollingIntervalMs?: number;
+ orderWatcherConfig?: OrderStateWatcherConfig;
}
export type TransactionReceipt = Web3.TransactionReceipt;