aboutsummaryrefslogtreecommitdiffstats
path: root/packages/order-watcher/src/order_watcher/order_watcher.ts
diff options
context:
space:
mode:
authorAmir Bandeali <abandeali1@gmail.com>2019-01-05 06:31:25 +0800
committerAmir Bandeali <abandeali1@gmail.com>2019-01-08 02:31:11 +0800
commit24564b986daa703f66e54f85abf4782d99a40f94 (patch)
tree8fbe8caa669b773eafe10c68c5a1a8a08c4954c5 /packages/order-watcher/src/order_watcher/order_watcher.ts
parenta91bc415ed3c9dc94dda2661c0d7ac13bcc58e08 (diff)
downloaddexon-sol-tools-24564b986daa703f66e54f85abf4782d99a40f94.tar
dexon-sol-tools-24564b986daa703f66e54f85abf4782d99a40f94.tar.gz
dexon-sol-tools-24564b986daa703f66e54f85abf4782d99a40f94.tar.bz2
dexon-sol-tools-24564b986daa703f66e54f85abf4782d99a40f94.tar.lz
dexon-sol-tools-24564b986daa703f66e54f85abf4782d99a40f94.tar.xz
dexon-sol-tools-24564b986daa703f66e54f85abf4782d99a40f94.tar.zst
dexon-sol-tools-24564b986daa703f66e54f85abf4782d99a40f94.zip
Minimize unnecessary type assertions
Diffstat (limited to 'packages/order-watcher/src/order_watcher/order_watcher.ts')
-rw-r--r--packages/order-watcher/src/order_watcher/order_watcher.ts33
1 files changed, 9 insertions, 24 deletions
diff --git a/packages/order-watcher/src/order_watcher/order_watcher.ts b/packages/order-watcher/src/order_watcher/order_watcher.ts
index c48606555..656f21a53 100644
--- a/packages/order-watcher/src/order_watcher/order_watcher.ts
+++ b/packages/order-watcher/src/order_watcher/order_watcher.ts
@@ -32,16 +32,7 @@ import {
orderHashUtils,
OrderStateUtils,
} from '@0x/order-utils';
-import {
- AssetProxyId,
- ERC20AssetData,
- ERC721AssetData,
- ExchangeContractErrs,
- MultiAssetData,
- OrderState,
- SignedOrder,
- Stats,
-} from '@0x/types';
+import { AssetProxyId, ExchangeContractErrs, OrderState, SignedOrder, Stats } from '@0x/types';
import { errorUtils, intervalUtils } from '@0x/utils';
import { BlockParamLiteral, LogEntryEvent, LogWithDecodedArgs, Provider } from 'ethereum-types';
import * as _ from 'lodash';
@@ -240,20 +231,14 @@ export class OrderWatcher {
}
private _addAssetDataToAbiDecoder(assetData: string): void {
const decodedAssetData = assetDataUtils.decodeAssetDataOrThrow(assetData);
- switch (decodedAssetData.assetProxyId) {
- case AssetProxyId.ERC20:
- this._collisionResistantAbiDecoder.addERC20Token((decodedAssetData as ERC20AssetData).tokenAddress);
- break;
- case AssetProxyId.ERC721:
- this._collisionResistantAbiDecoder.addERC721Token((decodedAssetData as ERC721AssetData).tokenAddress);
- break;
- case AssetProxyId.MultiAsset:
- _.each((decodedAssetData as MultiAssetData).nestedAssetData, nestedAssetDataElement =>
- this._addAssetDataToAbiDecoder(nestedAssetDataElement),
- );
- break;
- default:
- break;
+ if (assetDataUtils.isERC20AssetData(decodedAssetData)) {
+ this._collisionResistantAbiDecoder.addERC20Token(decodedAssetData.tokenAddress);
+ } else if (assetDataUtils.isERC721AssetData(decodedAssetData)) {
+ this._collisionResistantAbiDecoder.addERC721Token(decodedAssetData.tokenAddress);
+ } else if (assetDataUtils.isMultiAssetData(decodedAssetData)) {
+ _.each(decodedAssetData.nestedAssetData, nestedAssetDataElement =>
+ this._addAssetDataToAbiDecoder(nestedAssetDataElement),
+ );
}
}
private _deleteLazyStoreBalance(assetData: string, userAddress: string): void {