aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--packages/0x.js/CHANGELOG.json7
-rw-r--r--packages/0x.js/src/contract_wrappers/exchange_wrapper.ts10
-rw-r--r--packages/0x.js/src/fetchers/simple_balance_and_proxy_allowance_fetcher.ts4
-rw-r--r--packages/0x.js/src/fetchers/simple_order_filled_cancelled_fetcher.ts4
-rw-r--r--packages/0x.js/src/order_watcher/expiration_watcher.ts3
-rw-r--r--packages/0x.js/src/stores/balance_proxy_allowance_lazy_store.ts8
-rw-r--r--packages/0x.js/src/stores/order_filled_cancelled_lazy_store.ts7
-rw-r--r--packages/0x.js/src/utils/order_state_utils.ts2
8 files changed, 33 insertions, 12 deletions
diff --git a/packages/0x.js/CHANGELOG.json b/packages/0x.js/CHANGELOG.json
index 65228b183..2dfcc448e 100644
--- a/packages/0x.js/CHANGELOG.json
+++ b/packages/0x.js/CHANGELOG.json
@@ -4,6 +4,10 @@
"changes": [
{
"note": "Internal changes and refactoring"
+ },
+ {
+ "note": "Fix redundant expired order removal bug",
+ "pr": 527
}
]
},
@@ -15,7 +19,8 @@
"pr": 501
},
{
- "note": "Add `zeroEx.exchange.getOrderStateAsync` to allow obtaining current OrderState for a signedOrder",
+ "note":
+ "Add `zeroEx.exchange.getOrderStateAsync` to allow obtaining current OrderState for a signedOrder",
"pr": 510
}
],
diff --git a/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts b/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts
index eacd3ebf0..7cda70f16 100644
--- a/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts
+++ b/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts
@@ -882,13 +882,19 @@ export class ExchangeWrapper extends ContractWrapper {
* @param stateLayer Optional, desired blockchain state layer (defaults to latest).
* @return OrderState of the signedOrder
*/
- public async getOrderStateAsync(signedOrder: SignedOrder, stateLayer: BlockParamLiteral = BlockParamLiteral.Latest): Promise<OrderState> {
+ public async getOrderStateAsync(
+ signedOrder: SignedOrder,
+ stateLayer: BlockParamLiteral = BlockParamLiteral.Latest,
+ ): Promise<OrderState> {
const simpleBalanceAndProxyAllowanceFetcher = new SimpleBalanceAndProxyAllowanceFetcher(
this._tokenWrapper,
stateLayer,
);
const simpleOrderFilledCancelledFetcher = new SimpleOrderFilledCancelledFetcher(this, stateLayer);
- const orderStateUtils = new OrderStateUtils(simpleBalanceAndProxyAllowanceFetcher, simpleOrderFilledCancelledFetcher);
+ const orderStateUtils = new OrderStateUtils(
+ simpleBalanceAndProxyAllowanceFetcher,
+ simpleOrderFilledCancelledFetcher,
+ );
const orderState = orderStateUtils.getOrderStateAsync(signedOrder);
return orderState;
}
diff --git a/packages/0x.js/src/fetchers/simple_balance_and_proxy_allowance_fetcher.ts b/packages/0x.js/src/fetchers/simple_balance_and_proxy_allowance_fetcher.ts
index c00dba5cf..21774d794 100644
--- a/packages/0x.js/src/fetchers/simple_balance_and_proxy_allowance_fetcher.ts
+++ b/packages/0x.js/src/fetchers/simple_balance_and_proxy_allowance_fetcher.ts
@@ -1,8 +1,8 @@
import { BlockParamLiteral } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
-import {BalanceAndProxyAllowanceFetcher} from '../abstract/balance_and_proxy_allowance_fetcher';
-import {TokenWrapper} from '../contract_wrappers/token_wrapper';
+import { BalanceAndProxyAllowanceFetcher } from '../abstract/balance_and_proxy_allowance_fetcher';
+import { TokenWrapper } from '../contract_wrappers/token_wrapper';
export class SimpleBalanceAndProxyAllowanceFetcher implements BalanceAndProxyAllowanceFetcher {
private _tokenWrapper: TokenWrapper;
diff --git a/packages/0x.js/src/fetchers/simple_order_filled_cancelled_fetcher.ts b/packages/0x.js/src/fetchers/simple_order_filled_cancelled_fetcher.ts
index 1c8aec1a1..b7548d54d 100644
--- a/packages/0x.js/src/fetchers/simple_order_filled_cancelled_fetcher.ts
+++ b/packages/0x.js/src/fetchers/simple_order_filled_cancelled_fetcher.ts
@@ -1,8 +1,8 @@
import { BlockParamLiteral } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
-import {OrderFilledCancelledFetcher} from '../abstract/order_filled_cancelled_fetcher';
-import {ExchangeWrapper} from '../contract_wrappers/exchange_wrapper';
+import { OrderFilledCancelledFetcher } from '../abstract/order_filled_cancelled_fetcher';
+import { ExchangeWrapper } from '../contract_wrappers/exchange_wrapper';
export class SimpleOrderFilledCancelledFetcher implements OrderFilledCancelledFetcher {
private _exchangeWrapper: ExchangeWrapper;
diff --git a/packages/0x.js/src/order_watcher/expiration_watcher.ts b/packages/0x.js/src/order_watcher/expiration_watcher.ts
index 00b62162d..8b306bf3b 100644
--- a/packages/0x.js/src/order_watcher/expiration_watcher.ts
+++ b/packages/0x.js/src/order_watcher/expiration_watcher.ts
@@ -48,6 +48,9 @@ export class ExpirationWatcher {
this._orderHashByExpirationRBTree.insert(orderHash);
}
public removeOrder(orderHash: string): void {
+ if (_.isUndefined(this._expiration[orderHash])) {
+ return; // noop since order already removed
+ }
this._orderHashByExpirationRBTree.remove(orderHash);
delete this._expiration[orderHash];
}
diff --git a/packages/0x.js/src/stores/balance_proxy_allowance_lazy_store.ts b/packages/0x.js/src/stores/balance_proxy_allowance_lazy_store.ts
index c8395415e..3ff116db4 100644
--- a/packages/0x.js/src/stores/balance_proxy_allowance_lazy_store.ts
+++ b/packages/0x.js/src/stores/balance_proxy_allowance_lazy_store.ts
@@ -2,8 +2,8 @@ import { BlockParamLiteral } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
import * as _ from 'lodash';
-import { TokenWrapper } from '../contract_wrappers/token_wrapper';
import { BalanceAndProxyAllowanceFetcher } from '../abstract/balance_and_proxy_allowance_fetcher';
+import { TokenWrapper } from '../contract_wrappers/token_wrapper';
/**
* Copy on read store for balances/proxyAllowances of tokens/accounts
@@ -60,7 +60,11 @@ export class BalanceAndProxyAllowanceLazyStore implements BalanceAndProxyAllowan
const methodOpts = {
defaultBlock: this._defaultBlock,
};
- const proxyAllowance = await this._tokenWrapper.getProxyAllowanceAsync(tokenAddress, userAddress, methodOpts);
+ const proxyAllowance = await this._tokenWrapper.getProxyAllowanceAsync(
+ tokenAddress,
+ userAddress,
+ methodOpts,
+ );
this.setProxyAllowance(tokenAddress, userAddress, proxyAllowance);
}
const cachedProxyAllowance = this._proxyAllowance[tokenAddress][userAddress];
diff --git a/packages/0x.js/src/stores/order_filled_cancelled_lazy_store.ts b/packages/0x.js/src/stores/order_filled_cancelled_lazy_store.ts
index 7f3da6e1d..61d2db8c2 100644
--- a/packages/0x.js/src/stores/order_filled_cancelled_lazy_store.ts
+++ b/packages/0x.js/src/stores/order_filled_cancelled_lazy_store.ts
@@ -2,8 +2,8 @@ import { BlockParamLiteral } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
import * as _ from 'lodash';
-import { ExchangeWrapper } from '../contract_wrappers/exchange_wrapper';
import { OrderFilledCancelledFetcher } from '../abstract/order_filled_cancelled_fetcher';
+import { ExchangeWrapper } from '../contract_wrappers/exchange_wrapper';
/**
* Copy on read store for filled/cancelled taker amounts
@@ -45,7 +45,10 @@ export class OrderFilledCancelledLazyStore implements OrderFilledCancelledFetche
const methodOpts = {
defaultBlock: this._defaultBlock,
};
- const cancelledTakerAmount = await this._exchangeWrapper.getCancelledTakerAmountAsync(orderHash, methodOpts);
+ const cancelledTakerAmount = await this._exchangeWrapper.getCancelledTakerAmountAsync(
+ orderHash,
+ methodOpts,
+ );
this.setCancelledTakerAmount(orderHash, cancelledTakerAmount);
}
const cachedCancelled = this._cancelledTakerAmount[orderHash];
diff --git a/packages/0x.js/src/utils/order_state_utils.ts b/packages/0x.js/src/utils/order_state_utils.ts
index e15ff6bc9..b0310d8a8 100644
--- a/packages/0x.js/src/utils/order_state_utils.ts
+++ b/packages/0x.js/src/utils/order_state_utils.ts
@@ -3,9 +3,9 @@ import { BigNumber } from '@0xproject/utils';
import * as _ from 'lodash';
import { ZeroEx } from '../0x';
-import { ExchangeWrapper } from '../contract_wrappers/exchange_wrapper';
import { BalanceAndProxyAllowanceFetcher } from '../abstract/balance_and_proxy_allowance_fetcher';
import { OrderFilledCancelledFetcher } from '../abstract/order_filled_cancelled_fetcher';
+import { ExchangeWrapper } from '../contract_wrappers/exchange_wrapper';
import { RemainingFillableCalculator } from '../order_watcher/remaining_fillable_calculator';
import { ExchangeContractErrs, OrderRelevantState, OrderState, OrderStateInvalid, OrderStateValid } from '../types';