diff options
author | Amir Bandeali <abandeali1@gmail.com> | 2019-01-03 08:52:15 +0800 |
---|---|---|
committer | Amir Bandeali <abandeali1@gmail.com> | 2019-01-08 02:31:11 +0800 |
commit | 1dda10b4f34eb19b731e58c26f13ecc08e367bbe (patch) | |
tree | a33ff795d65bcbb67379414e29138cb364c02fe0 /packages/pipeline/src/parsers/events | |
parent | 0fba0b1a1bbe1192802ebcf4b88437b94d6a1c18 (diff) | |
download | dexon-sol-tools-1dda10b4f34eb19b731e58c26f13ecc08e367bbe.tar.gz dexon-sol-tools-1dda10b4f34eb19b731e58c26f13ecc08e367bbe.tar.zst dexon-sol-tools-1dda10b4f34eb19b731e58c26f13ecc08e367bbe.zip |
Add recursive MultiAsset decoding, store first address in pipeline
Diffstat (limited to 'packages/pipeline/src/parsers/events')
-rw-r--r-- | packages/pipeline/src/parsers/events/exchange_events.ts | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/packages/pipeline/src/parsers/events/exchange_events.ts b/packages/pipeline/src/parsers/events/exchange_events.ts index 16b05260b..50fad7e00 100644 --- a/packages/pipeline/src/parsers/events/exchange_events.ts +++ b/packages/pipeline/src/parsers/events/exchange_events.ts @@ -1,6 +1,6 @@ import { ExchangeCancelEventArgs, ExchangeCancelUpToEventArgs, ExchangeFillEventArgs } from '@0x/contract-wrappers'; import { assetDataUtils } from '@0x/order-utils'; -import { AssetProxyId, ERC20AssetData, ERC721AssetData } from '@0x/types'; +import { AssetProxyId, ERC721AssetData, SingleAssetData } from '@0x/types'; import { LogWithDecodedArgs } from 'ethereum-types'; import * as R from 'ramda'; @@ -62,8 +62,9 @@ export function _convertToExchangeFillEvent(eventLog: LogWithDecodedArgs<Exchang // HACK(abandeali1): this event schema currently does not support multiple maker/taker assets, so we store a null byte array when decoding assetData from the MultiAssetProxy exchangeFillEvent.makerTokenAddress = makerAssetData.assetProxyId === AssetProxyId.MultiAsset - ? '0x' - : (makerAssetData as ERC20AssetData | ERC721AssetData).tokenAddress; + ? assetDataUtils.decodeMultiAssetDataRecursively(eventLog.args.makerAssetData).nestedAssetData[0] + .tokenAddress + : (makerAssetData as SingleAssetData).tokenAddress; // tslint has a false positive here. Type assertion is required. // tslint:disable-next-line:no-unnecessary-type-assertion exchangeFillEvent.makerTokenId = bigNumbertoStringOrNull((makerAssetData as ERC721AssetData).tokenId); @@ -72,9 +73,10 @@ export function _convertToExchangeFillEvent(eventLog: LogWithDecodedArgs<Exchang exchangeFillEvent.takerAssetProxyId = takerAssetData.assetProxyId; // HACK(abandeali1): this event schema currently does not support multiple maker/taker assets, so we store a null byte array when decoding assetData from the MultiAssetProxy exchangeFillEvent.takerTokenAddress = - makerAssetData.assetProxyId === AssetProxyId.MultiAsset - ? '0x' - : (takerAssetData as ERC20AssetData | ERC721AssetData).tokenAddress; + takerAssetData.assetProxyId === AssetProxyId.MultiAsset + ? assetDataUtils.decodeMultiAssetDataRecursively(eventLog.args.takerAssetData).nestedAssetData[0] + .tokenAddress + : (takerAssetData as SingleAssetData).tokenAddress; // tslint:disable-next-line:no-unnecessary-type-assertion exchangeFillEvent.takerTokenId = bigNumbertoStringOrNull((takerAssetData as ERC721AssetData).tokenId); return exchangeFillEvent; @@ -107,8 +109,9 @@ export function _convertToExchangeCancelEvent( // HACK(abandeali1): this event schema currently does not support multiple maker/taker assets, so we store a null byte array when decoding assetData from the MultiAssetProxy exchangeCancelEvent.makerTokenAddress = makerAssetData.assetProxyId === AssetProxyId.MultiAsset - ? '0x' - : (makerAssetData as ERC20AssetData | ERC721AssetData).tokenAddress; + ? assetDataUtils.decodeMultiAssetDataRecursively(eventLog.args.makerAssetData).nestedAssetData[0] + .tokenAddress + : (makerAssetData as SingleAssetData).tokenAddress; // tslint:disable-next-line:no-unnecessary-type-assertion exchangeCancelEvent.makerTokenId = bigNumbertoStringOrNull((makerAssetData as ERC721AssetData).tokenId); exchangeCancelEvent.rawTakerAssetData = eventLog.args.takerAssetData; @@ -116,9 +119,10 @@ export function _convertToExchangeCancelEvent( exchangeCancelEvent.takerAssetProxyId = takerAssetData.assetProxyId; // HACK(abandeali1): this event schema currently does not support multiple maker/taker assets, so we store a null byte array when decoding assetData from the MultiAssetProxy exchangeCancelEvent.takerTokenAddress = - makerAssetData.assetProxyId === AssetProxyId.MultiAsset - ? '0x' - : (takerAssetData as ERC20AssetData | ERC721AssetData).tokenAddress; + takerAssetData.assetProxyId === AssetProxyId.MultiAsset + ? assetDataUtils.decodeMultiAssetDataRecursively(eventLog.args.takerAssetData).nestedAssetData[0] + .tokenAddress + : (takerAssetData as SingleAssetData).tokenAddress; // tslint:disable-next-line:no-unnecessary-type-assertion exchangeCancelEvent.takerTokenId = bigNumbertoStringOrNull((takerAssetData as ERC721AssetData).tokenId); return exchangeCancelEvent; |