diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-07-17 19:28:27 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-07-17 19:28:27 +0800 |
commit | 01e617bb831c90f27ca454679f9836cf86235f72 (patch) | |
tree | 9c1ba9d5292c473cfe8d193395fa4b0deecbe435 | |
parent | 28a9a8c3809a63510d2cddf7f9eeaf74635b08ad (diff) | |
download | dexon-sol-tools-01e617bb831c90f27ca454679f9836cf86235f72.tar dexon-sol-tools-01e617bb831c90f27ca454679f9836cf86235f72.tar.gz dexon-sol-tools-01e617bb831c90f27ca454679f9836cf86235f72.tar.bz2 dexon-sol-tools-01e617bb831c90f27ca454679f9836cf86235f72.tar.lz dexon-sol-tools-01e617bb831c90f27ca454679f9836cf86235f72.tar.xz dexon-sol-tools-01e617bb831c90f27ca454679f9836cf86235f72.tar.zst dexon-sol-tools-01e617bb831c90f27ca454679f9836cf86235f72.zip |
DRY up the code in order-watcher collision-resistant abi decoder
-rw-r--r-- | packages/order-watcher/src/order_watcher/order_watcher.ts | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/packages/order-watcher/src/order_watcher/order_watcher.ts b/packages/order-watcher/src/order_watcher/order_watcher.ts index de0ff6b87..68ef9fab7 100644 --- a/packages/order-watcher/src/order_watcher/order_watcher.ts +++ b/packages/order-watcher/src/order_watcher/order_watcher.ts @@ -153,19 +153,15 @@ export class OrderWatcher { this._orderByOrderHash[orderHash] = signedOrder; this._dependentOrderHashesTracker.addToDependentOrderHashes(signedOrder); - const decodedMakerAssetData = assetProxyUtils.decodeAssetDataOrThrow(signedOrder.makerAssetData); - if (decodedMakerAssetData.assetProxyId === AssetProxyId.ERC20) { - this._collisionResistantAbiDecoder.addERC20Token(decodedMakerAssetData.tokenAddress); - } else if (decodedMakerAssetData.assetProxyId === AssetProxyId.ERC721) { - this._collisionResistantAbiDecoder.addERC721Token(decodedMakerAssetData.tokenAddress); - } - - const decodedTakerAssetData = assetProxyUtils.decodeAssetDataOrThrow(signedOrder.takerAssetData); - if (decodedTakerAssetData.assetProxyId === AssetProxyId.ERC20) { - this._collisionResistantAbiDecoder.addERC20Token(decodedTakerAssetData.tokenAddress); - } else if (decodedTakerAssetData.assetProxyId === AssetProxyId.ERC721) { - this._collisionResistantAbiDecoder.addERC721Token(decodedTakerAssetData.tokenAddress); - } + const orderAssetDatas = [signedOrder.makerAssetData, signedOrder.takerAssetData]; + _.each(orderAssetDatas, assetData => { + const decodedAssetData = assetProxyUtils.decodeAssetData(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 |