diff options
Diffstat (limited to 'packages')
-rw-r--r-- | packages/0x.js/src/order_watcher/order_state_watcher.ts | 33 |
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 |