aboutsummaryrefslogtreecommitdiffstats
path: root/packages/order-utils/src
diff options
context:
space:
mode:
authorAmir Bandeali <abandeali1@gmail.com>2018-12-03 05:16:07 +0800
committerAmir Bandeali <abandeali1@gmail.com>2019-01-08 02:31:11 +0800
commit8549252a2c0d12ec736eea72b702924353a9daaf (patch)
tree163a36fe5a13c06372a19f831ebe8bf73fdc2c62 /packages/order-utils/src
parentaae32037da737e77b3ffaf0115494a1d7966a972 (diff)
downloaddexon-0x-contracts-8549252a2c0d12ec736eea72b702924353a9daaf.tar.gz
dexon-0x-contracts-8549252a2c0d12ec736eea72b702924353a9daaf.tar.zst
dexon-0x-contracts-8549252a2c0d12ec736eea72b702924353a9daaf.zip
Fix decoding and add tests
Diffstat (limited to 'packages/order-utils/src')
-rw-r--r--packages/order-utils/src/asset_data_utils.ts17
1 files changed, 11 insertions, 6 deletions
diff --git a/packages/order-utils/src/asset_data_utils.ts b/packages/order-utils/src/asset_data_utils.ts
index 0b32cf216..1b416abd1 100644
--- a/packages/order-utils/src/asset_data_utils.ts
+++ b/packages/order-utils/src/asset_data_utils.ts
@@ -30,10 +30,11 @@ export const assetDataUtils = {
assetDataUtils.validateERC20AssetDataThrow(assetData);
const assetProxyId = assetDataUtils.decodeAssetProxyId(assetData);
const abiEncoder = new AbiEncoder.Method(constants.ERC20_METHOD_ABI as MethodAbi);
- const [tokenAddress] = abiEncoder.decode(assetData, decodingRules);
+ const decodedAssetData = abiEncoder.decode(assetData, decodingRules);
return {
assetProxyId,
- tokenAddress,
+ // TODO(abandeali1): fix decode return types
+ tokenAddress: (decodedAssetData as any).tokenContract,
};
},
/**
@@ -58,11 +59,12 @@ export const assetDataUtils = {
assetDataUtils.validateERC721AssetDataOrThrow(assetData);
const assetProxyId = assetDataUtils.decodeAssetProxyId(assetData);
const abiEncoder = new AbiEncoder.Method(constants.ERC721_METHOD_ABI as MethodAbi);
- const [tokenAddress, tokenId] = abiEncoder.decode(assetData, decodingRules);
+ const decodedAssetData = abiEncoder.decode(assetData, decodingRules);
return {
assetProxyId,
- tokenAddress,
- tokenId,
+ // TODO(abandeali1): fix decode return types
+ tokenAddress: (decodedAssetData as any).tokenContract,
+ tokenId: (decodedAssetData as any).tokenId,
};
},
/**
@@ -95,7 +97,10 @@ export const assetDataUtils = {
assetDataUtils.validateMultiAssetDataOrThrow(assetData);
const assetProxyId = assetDataUtils.decodeAssetProxyId(assetData);
const abiEncoder = new AbiEncoder.Method(constants.MULTI_ASSET_METHOD_ABI as MethodAbi);
- const [amounts, nestedAssetData] = abiEncoder.decode(assetData, decodingRules);
+ const decodedAssetData = abiEncoder.decode(assetData, decodingRules);
+ // TODO(abandeali1): fix decode return types
+ const amounts = (decodedAssetData as any).amounts;
+ const nestedAssetData = (decodedAssetData as any).nestedAssetData;
if (amounts.length !== nestedAssetData.length) {
throw new Error(
`Invalid MultiAsset assetData. Expected length of 'amounts' (${