aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-12-19 21:30:37 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-12-20 21:01:59 +0800
commitb829d55752416c60440c6ed91b1f59b753416634 (patch)
treee40a45682629527b2904a8d4f435035c1edcef9b /packages
parente92d6ff84f781005eb01cc5e82eed29a244c9ee8 (diff)
downloaddexon-sol-tools-b829d55752416c60440c6ed91b1f59b753416634.tar
dexon-sol-tools-b829d55752416c60440c6ed91b1f59b753416634.tar.gz
dexon-sol-tools-b829d55752416c60440c6ed91b1f59b753416634.tar.bz2
dexon-sol-tools-b829d55752416c60440c6ed91b1f59b753416634.tar.lz
dexon-sol-tools-b829d55752416c60440c6ed91b1f59b753416634.tar.xz
dexon-sol-tools-b829d55752416c60440c6ed91b1f59b753416634.tar.zst
dexon-sol-tools-b829d55752416c60440c6ed91b1f59b753416634.zip
Make order watcher react to new etherToken events
Diffstat (limited to 'packages')
-rw-r--r--packages/0x.js/src/order_watcher/order_state_watcher.ts33
1 files changed, 33 insertions, 0 deletions
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 c4a9eb1ad..af9814dc8 100644
--- a/packages/0x.js/src/order_watcher/order_state_watcher.ts
+++ b/packages/0x.js/src/order_watcher/order_state_watcher.ts
@@ -12,6 +12,8 @@ import {
ApprovalContractEventArgs,
BlockParamLiteral,
ContractEventArgs,
+ DepositContractEventArgs,
+ EtherTokenEvents,
ExchangeContractErrs,
ExchangeEvents,
LogCancelContractEventArgs,
@@ -24,6 +26,7 @@ import {
SignedOrder,
TokenEvents,
TransferContractEventArgs,
+ WithdrawalContractEventArgs,
ZeroExError,
} from '../types';
import {AbiDecoder} from '../utils/abi_decoder';
@@ -243,6 +246,36 @@ export class OrderStateWatcher {
}
break;
}
+ case EtherTokenEvents.Deposit:
+ {
+ // Invalidate cache
+ const args = decodedLog.args as DepositContractEventArgs;
+ this._balanceAndProxyAllowanceLazyStore.deleteBalance(decodedLog.address, args._owner);
+ // Revalidate orders
+ makerToken = decodedLog.address;
+ makerAddress = args._owner;
+ if (!_.isUndefined(this._dependentOrderHashes[makerAddress]) &&
+ !_.isUndefined(this._dependentOrderHashes[makerAddress][makerToken])) {
+ const orderHashes = Array.from(this._dependentOrderHashes[makerAddress][makerToken]);
+ await this._emitRevalidateOrdersAsync(orderHashes);
+ }
+ break;
+ }
+ case EtherTokenEvents.Withdrawal:
+ {
+ // Invalidate cache
+ const args = decodedLog.args as WithdrawalContractEventArgs;
+ this._balanceAndProxyAllowanceLazyStore.deleteBalance(decodedLog.address, args._owner);
+ // Revalidate orders
+ makerToken = decodedLog.address;
+ makerAddress = args._owner;
+ if (!_.isUndefined(this._dependentOrderHashes[makerAddress]) &&
+ !_.isUndefined(this._dependentOrderHashes[makerAddress][makerToken])) {
+ const orderHashes = Array.from(this._dependentOrderHashes[makerAddress][makerToken]);
+ await this._emitRevalidateOrdersAsync(orderHashes);
+ }
+ break;
+ }
case ExchangeEvents.LogFill:
{
// Invalidate cache