aboutsummaryrefslogtreecommitdiffstats
path: root/packages/0x.js/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/0x.js/src')
-rw-r--r--packages/0x.js/src/contract_wrappers/contract_wrapper.ts11
-rw-r--r--packages/0x.js/src/contract_wrappers/ether_token_wrapper.ts13
-rw-r--r--packages/0x.js/src/order_watcher/order_state_watcher.ts6
3 files changed, 24 insertions, 6 deletions
diff --git a/packages/0x.js/src/contract_wrappers/contract_wrapper.ts b/packages/0x.js/src/contract_wrappers/contract_wrapper.ts
index 873489dc9..2fbf8c32d 100644
--- a/packages/0x.js/src/contract_wrappers/contract_wrapper.ts
+++ b/packages/0x.js/src/contract_wrappers/contract_wrapper.ts
@@ -32,10 +32,10 @@ const CONTRACT_NAME_TO_NOT_FOUND_ERROR: {
export class ContractWrapper {
protected _web3Wrapper: Web3Wrapper;
- private _networkId: number;
+ protected _networkId: number;
private _abiDecoder?: AbiDecoder;
- private _blockAndLogStreamerIfExists: BlockAndLogStreamer | undefined;
- private _blockAndLogStreamInterval: NodeJS.Timer;
+ private _blockAndLogStreamerIfExists?: BlockAndLogStreamer;
+ private _blockAndLogStreamIntervalIfExists?: NodeJS.Timer;
private _filters: { [filterToken: string]: Web3.FilterObject };
private _filterCallbacks: {
[filterToken: string]: EventCallback<ContractEventArgs>;
@@ -162,7 +162,7 @@ export class ContractWrapper {
);
const catchAllLogFilter = {};
this._blockAndLogStreamerIfExists.addLogFilter(catchAllLogFilter);
- this._blockAndLogStreamInterval = intervalUtils.setAsyncExcludingInterval(
+ this._blockAndLogStreamIntervalIfExists = intervalUtils.setAsyncExcludingInterval(
this._reconcileBlockAsync.bind(this),
constants.DEFAULT_BLOCK_POLLING_INTERVAL,
this._onReconcileBlockError.bind(this),
@@ -191,11 +191,12 @@ export class ContractWrapper {
}
this._blockAndLogStreamerIfExists.unsubscribeFromOnLogAdded(this._onLogAddedSubscriptionToken as string);
this._blockAndLogStreamerIfExists.unsubscribeFromOnLogRemoved(this._onLogRemovedSubscriptionToken as string);
- intervalUtils.clearAsyncExcludingInterval(this._blockAndLogStreamInterval);
+ intervalUtils.clearAsyncExcludingInterval(this._blockAndLogStreamIntervalIfExists as NodeJS.Timer);
delete this._blockAndLogStreamerIfExists;
}
private async _reconcileBlockAsync(): Promise<void> {
const latestBlock = await this._web3Wrapper.getBlockAsync(BlockParamLiteral.Latest);
+ console.log('latestBlock', latestBlock.number);
// We need to coerce to Block type cause Web3.Block includes types for mempool blocks
if (!_.isUndefined(this._blockAndLogStreamerIfExists)) {
// If we clear the interval while fetching the block - this._blockAndLogStreamer will be undefined
diff --git a/packages/0x.js/src/contract_wrappers/ether_token_wrapper.ts b/packages/0x.js/src/contract_wrappers/ether_token_wrapper.ts
index cbafcfe94..32c9ae6a9 100644
--- a/packages/0x.js/src/contract_wrappers/ether_token_wrapper.ts
+++ b/packages/0x.js/src/contract_wrappers/ether_token_wrapper.ts
@@ -162,6 +162,19 @@ export class EtherTokenWrapper extends ContractWrapper {
public _unsubscribeAll(): void {
super._unsubscribeAll();
}
+ /**
+ * Retrieves the Ethereum address of the EtherToken contract deployed on the network
+ * that the user-passed web3 provider is connected to. If it's not Kovan, Ropsten, Rinkeby, Mainnet or TestRPC
+ * (networkId: 50), it will return undefined (e.g a private network).
+ * @returns The Ethereum address of the EtherToken contract or undefined.
+ */
+ public getContractAddressIfExists(): string | undefined {
+ const networkSpecificArtifact = artifacts.EtherTokenArtifact.networks[this._networkId];
+ const contractAddressIfExists = _.isUndefined(networkSpecificArtifact)
+ ? undefined
+ : networkSpecificArtifact.address;
+ return contractAddressIfExists;
+ }
private _invalidateContractInstance(): void {
this._unsubscribeAll();
this._etherTokenContractsByAddress = {};
diff --git a/packages/0x.js/src/order_watcher/order_state_watcher.ts b/packages/0x.js/src/order_watcher/order_state_watcher.ts
index 576be00c8..1ad1a90b1 100644
--- a/packages/0x.js/src/order_watcher/order_state_watcher.ts
+++ b/packages/0x.js/src/order_watcher/order_state_watcher.ts
@@ -133,8 +133,12 @@ export class OrderStateWatcher {
delete this._orderStateByOrderHashCache[orderHash];
const exchange = (this._orderFilledCancelledLazyStore as any)._exchange as ExchangeWrapper;
const zrxTokenAddress = exchange.getZRXTokenAddress();
+
this._removeFromDependentOrderHashes(signedOrder.maker, zrxTokenAddress, orderHash);
- this._removeFromDependentOrderHashes(signedOrder.maker, signedOrder.makerTokenAddress, orderHash);
+ if (zrxTokenAddress !== signedOrder.makerTokenAddress) {
+ this._removeFromDependentOrderHashes(signedOrder.maker, signedOrder.makerTokenAddress, orderHash);
+ }
+
this._expirationWatcher.removeOrder(orderHash);
}
/**