diff options
Diffstat (limited to 'packages/pipeline/src/parsers/sra_orders')
-rw-r--r-- | packages/pipeline/src/parsers/sra_orders/index.ts | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/packages/pipeline/src/parsers/sra_orders/index.ts b/packages/pipeline/src/parsers/sra_orders/index.ts index 4e4bf12ff..3d7f73fca 100644 --- a/packages/pipeline/src/parsers/sra_orders/index.ts +++ b/packages/pipeline/src/parsers/sra_orders/index.ts @@ -6,10 +6,19 @@ import * as R from 'ramda'; import { SraOrder } from '../../entities'; import { bigNumbertoStringOrNull } from '../../utils'; +/** + * Parses a raw order response from an SRA endpoint and returns an array of + * SraOrder entities. + * @param rawOrdersResponse A raw order response from an SRA endpoint. + */ export function parseSraOrders(rawOrdersResponse: OrdersResponse): SraOrder[] { return R.map(_convertToEntity, rawOrdersResponse.records); } +/** + * Converts a single APIOrder into an SraOrder entity. + * @param apiOrder A single order from the response from an SRA endpoint. + */ export function _convertToEntity(apiOrder: APIOrder): SraOrder { // TODO(albrow): refactor out common asset data decoding code. const makerAssetData = assetDataUtils.decodeAssetDataOrThrow(apiOrder.order.makerAssetData); @@ -41,11 +50,14 @@ export function _convertToEntity(apiOrder: APIOrder): SraOrder { sraOrder.makerAssetType = makerAssetType; sraOrder.makerAssetProxyId = makerAssetData.assetProxyId; sraOrder.makerTokenAddress = makerAssetData.tokenAddress; + // tslint has a false positive here. Type assertion is required. + // tslint:disable-next-line:no-unnecessary-type-assertion sraOrder.makerTokenId = bigNumbertoStringOrNull((makerAssetData as ERC721AssetData).tokenId); sraOrder.rawTakerAssetData = apiOrder.order.takerAssetData; sraOrder.takerAssetType = takerAssetType; sraOrder.takerAssetProxyId = takerAssetData.assetProxyId; sraOrder.takerTokenAddress = takerAssetData.tokenAddress; + // tslint:disable-next-line:no-unnecessary-type-assertion sraOrder.takerTokenId = bigNumbertoStringOrNull((takerAssetData as ERC721AssetData).tokenId); sraOrder.metadataJson = JSON.stringify(apiOrder.metaData); |