Fix bug where remainingTakerAssetAmount is not converted to BigNumber

This commit is contained in:
Jacob Evans
2019-05-13 13:28:59 +02:00
parent 490aafba4e
commit 4d98408aaf
2 changed files with 15 additions and 2 deletions

View File

@@ -1,4 +1,12 @@
[
{
"version": "6.1.2",
"changes": [
{
"note": "Convert `metaData.remainingTakerAssetAmount` to BigNumber if present in APIOrder"
}
]
},
{
"timestamp": 1557507213,
"version": "6.1.1",

View File

@@ -1,5 +1,5 @@
import { HttpClient } from '@0x/connect';
import { orderCalculationUtils } from '@0x/order-utils';
import { orderCalculationUtils, orderParsingUtils } from '@0x/order-utils';
import { APIOrder, AssetPairsResponse, OrderbookResponse } from '@0x/types';
import * as _ from 'lodash';
@@ -25,9 +25,14 @@ export class StandardRelayerAPIOrderProvider implements OrderProvider {
): SignedOrderWithRemainingFillableMakerAssetAmount[] {
const result = _.map(apiOrders, apiOrder => {
const { order, metaData } = apiOrder;
// The contents of metaData is not explicity defined in the spec
// We check for remainingTakerAssetAmount as a string and use this value if populated
const convertedMetaData = orderParsingUtils.convertStringsFieldsToBigNumbers(metaData, [
'remainingTakerAssetAmount',
]);
// calculate remainingFillableMakerAssetAmount from api metadata, else assume order is completely fillable
const remainingFillableTakerAssetAmount = _.get(
metaData,
convertedMetaData,
'remainingTakerAssetAmount',
order.takerAssetAmount,
);