diff options
author | Greg Hysen <greg.hysen@gmail.com> | 2018-06-07 08:14:13 +0800 |
---|---|---|
committer | Greg Hysen <greg.hysen@gmail.com> | 2018-06-08 06:39:40 +0800 |
commit | db086de84ae7a238b91b5ce79fcc1a8e4c830ac5 (patch) | |
tree | e4e94a44b0dc0e7f99ab44fc968ff4d7457de68d /packages/order-utils/src | |
parent | 37684c6af0d2962f7c7822dd14531787bd7b4212 (diff) | |
download | dexon-0x-contracts-db086de84ae7a238b91b5ce79fcc1a8e4c830ac5.tar.gz dexon-0x-contracts-db086de84ae7a238b91b5ce79fcc1a8e4c830ac5.tar.zst dexon-0x-contracts-db086de84ae7a238b91b5ce79fcc1a8e4c830ac5.zip |
Union types for generalized decodeAssetData
Diffstat (limited to 'packages/order-utils/src')
-rw-r--r-- | packages/order-utils/src/asset_proxy_utils.ts | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/packages/order-utils/src/asset_proxy_utils.ts b/packages/order-utils/src/asset_proxy_utils.ts index c7b301c1a..1d34172c7 100644 --- a/packages/order-utils/src/asset_proxy_utils.ts +++ b/packages/order-utils/src/asset_proxy_utils.ts @@ -1,4 +1,4 @@ -import { AssetData, AssetProxyId, ERC20AssetData, ERC721AssetData } from '@0xproject/types'; +import { AssetProxyId, ERC20AssetData, ERC721AssetData } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; import BN = require('bn.js'); import ethUtil = require('ethereumjs-util'); @@ -157,24 +157,15 @@ export const assetProxyUtils = { const assetProxyId = assetProxyUtils.decodeAssetProxyId(encodedAssetProxyId); return assetProxyId; }, - decodeAssetData(assetData: string): AssetData { + decodeAssetData(assetData: string): ERC20AssetData | ERC721AssetData { const assetProxyId = assetProxyUtils.decodeAssetDataId(assetData); switch (assetProxyId) { case AssetProxyId.ERC20: const erc20AssetData = assetProxyUtils.decodeERC20AssetData(assetData); - const generalizedERC20AssetData = { - assetProxyId, - tokenAddress: erc20AssetData.tokenAddress, - }; - return generalizedERC20AssetData; + return erc20AssetData; case AssetProxyId.ERC721: const erc721AssetData = assetProxyUtils.decodeERC721AssetData(assetData); - const generalizedERC721AssetData = { - assetProxyId, - tokenAddress: erc721AssetData.tokenAddress, - data: erc721AssetData.tokenId, - }; - return generalizedERC721AssetData; + return erc721AssetData; default: throw new Error(`Unrecognized asset proxy id: ${assetProxyId}`); } |