aboutsummaryrefslogtreecommitdiffstats
path: root/packages/pipeline/src/parsers/sra_orders
diff options
context:
space:
mode:
authorAlex Browne <stephenalexbrowne@gmail.com>2018-11-13 09:36:33 +0800
committerFred Carlsen <fred@sjelfull.no>2018-12-13 01:15:50 +0800
commit52f2ee6e797435d887d4ad06955a3ffbf61081ca (patch)
treefbefdb09c23fe1e0a6b8ad335c618610104d4113 /packages/pipeline/src/parsers/sra_orders
parent4fa4f13813a0b41013bc7acc60101ccae175edff (diff)
downloaddexon-0x-contracts-52f2ee6e797435d887d4ad06955a3ffbf61081ca.tar.gz
dexon-0x-contracts-52f2ee6e797435d887d4ad06955a3ffbf61081ca.tar.zst
dexon-0x-contracts-52f2ee6e797435d887d4ad06955a3ffbf61081ca.zip
Configure linter with --format stylish and fix linter errors
Diffstat (limited to 'packages/pipeline/src/parsers/sra_orders')
-rw-r--r--packages/pipeline/src/parsers/sra_orders/index.ts12
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);