diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-12-19 21:30:37 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-12-20 21:01:59 +0800 |
commit | b829d55752416c60440c6ed91b1f59b753416634 (patch) | |
tree | e40a45682629527b2904a8d4f435035c1edcef9b /packages/0x.js | |
parent | e92d6ff84f781005eb01cc5e82eed29a244c9ee8 (diff) | |
download | dexon-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/0x.js')
-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 |