aboutsummaryrefslogtreecommitdiffstats
path: root/packages/order-utils
diff options
context:
space:
mode:
authorGreg Hysen <greg.hysen@gmail.com>2018-06-07 08:14:13 +0800
committerGreg Hysen <greg.hysen@gmail.com>2018-06-08 06:39:40 +0800
commitdb086de84ae7a238b91b5ce79fcc1a8e4c830ac5 (patch)
treee4e94a44b0dc0e7f99ab44fc968ff4d7457de68d /packages/order-utils
parent37684c6af0d2962f7c7822dd14531787bd7b4212 (diff)
downloaddexon-sol-tools-db086de84ae7a238b91b5ce79fcc1a8e4c830ac5.tar
dexon-sol-tools-db086de84ae7a238b91b5ce79fcc1a8e4c830ac5.tar.gz
dexon-sol-tools-db086de84ae7a238b91b5ce79fcc1a8e4c830ac5.tar.bz2
dexon-sol-tools-db086de84ae7a238b91b5ce79fcc1a8e4c830ac5.tar.lz
dexon-sol-tools-db086de84ae7a238b91b5ce79fcc1a8e4c830ac5.tar.xz
dexon-sol-tools-db086de84ae7a238b91b5ce79fcc1a8e4c830ac5.tar.zst
dexon-sol-tools-db086de84ae7a238b91b5ce79fcc1a8e4c830ac5.zip
Union types for generalized decodeAssetData
Diffstat (limited to 'packages/order-utils')
-rw-r--r--packages/order-utils/src/asset_proxy_utils.ts17
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}`);
}