diff options
author | Amir Bandeali <abandeali1@gmail.com> | 2018-12-03 05:16:07 +0800 |
---|---|---|
committer | Amir Bandeali <abandeali1@gmail.com> | 2019-01-08 02:31:11 +0800 |
commit | 8549252a2c0d12ec736eea72b702924353a9daaf (patch) | |
tree | 163a36fe5a13c06372a19f831ebe8bf73fdc2c62 /packages/order-utils/src | |
parent | aae32037da737e77b3ffaf0115494a1d7966a972 (diff) | |
download | dexon-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.ts | 17 |
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' (${ |