aboutsummaryrefslogtreecommitdiffstats
path: root/packages/order-watcher/src/order_watcher/order_watcher.ts
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-07-18 21:37:34 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2018-07-18 21:38:10 +0800
commitc71781d9abf7f2654a51dbef95bd18200ea2bde1 (patch)
treebcaf7b858ba1d22d6f8c1afe0ff21aec28467598 /packages/order-watcher/src/order_watcher/order_watcher.ts
parentdad557164ea4ccc012243d43df013078a7c37eb6 (diff)
downloaddexon-sol-tools-c71781d9abf7f2654a51dbef95bd18200ea2bde1.tar
dexon-sol-tools-c71781d9abf7f2654a51dbef95bd18200ea2bde1.tar.gz
dexon-sol-tools-c71781d9abf7f2654a51dbef95bd18200ea2bde1.tar.bz2
dexon-sol-tools-c71781d9abf7f2654a51dbef95bd18200ea2bde1.tar.lz
dexon-sol-tools-c71781d9abf7f2654a51dbef95bd18200ea2bde1.tar.xz
dexon-sol-tools-c71781d9abf7f2654a51dbef95bd18200ea2bde1.tar.zst
dexon-sol-tools-c71781d9abf7f2654a51dbef95bd18200ea2bde1.zip
Merge
Diffstat (limited to 'packages/order-watcher/src/order_watcher/order_watcher.ts')
-rw-r--r--packages/order-watcher/src/order_watcher/order_watcher.ts16
1 files changed, 13 insertions, 3 deletions
diff --git a/packages/order-watcher/src/order_watcher/order_watcher.ts b/packages/order-watcher/src/order_watcher/order_watcher.ts
index 0ad3267d8..afc854445 100644
--- a/packages/order-watcher/src/order_watcher/order_watcher.ts
+++ b/packages/order-watcher/src/order_watcher/order_watcher.ts
@@ -28,7 +28,7 @@ import {
orderHashUtils,
OrderStateUtils,
} from '@0xproject/order-utils';
-import { ExchangeContractErrs, OrderState, SignedOrder } from '@0xproject/types';
+import { AssetProxyId, ExchangeContractErrs, OrderState, SignedOrder } from '@0xproject/types';
import { errorUtils, intervalUtils } from '@0xproject/utils';
import { BlockParamLiteral, LogEntryEvent, LogWithDecodedArgs, Provider } from 'ethereum-types';
import * as _ from 'lodash';
@@ -134,16 +134,26 @@ export class OrderWatcher {
* signature is verified.
* @param signedOrder The order you wish to start watching.
*/
- public addOrder(signedOrder: SignedOrder): void {
+ public async addOrderAsync(signedOrder: SignedOrder): Promise<void> {
assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema);
const orderHash = orderHashUtils.getOrderHashHex(signedOrder);
- assert.isValidSignatureAsync(this._provider, orderHash, signedOrder.signature, signedOrder.makerAddress);
+ await assert.isValidSignatureAsync(this._provider, orderHash, signedOrder.signature, signedOrder.makerAddress);
const expirationUnixTimestampMs = signedOrder.expirationTimeSeconds.times(MILLISECONDS_IN_A_SECOND);
this._expirationWatcher.addOrder(orderHash, expirationUnixTimestampMs);
this._orderByOrderHash[orderHash] = signedOrder;
this._dependentOrderHashesTracker.addToDependentOrderHashes(signedOrder);
+
+ const orderAssetDatas = [signedOrder.makerAssetData, signedOrder.takerAssetData];
+ _.each(orderAssetDatas, assetData => {
+ const decodedAssetData = assetProxyUtils.decodeAssetDataOrThrow(assetData);
+ if (decodedAssetData.assetProxyId === AssetProxyId.ERC20) {
+ this._collisionResistantAbiDecoder.addERC20Token(decodedAssetData.tokenAddress);
+ } else if (decodedAssetData.assetProxyId === AssetProxyId.ERC721) {
+ this._collisionResistantAbiDecoder.addERC721Token(decodedAssetData.tokenAddress);
+ }
+ });
}
/**
* Removes an order from the orderWatcher