blob: 10ff3105775ca0c9b67c3ded8bb1826f796b52aa (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
import { ContractWrappers } from '@0xproject/contract-wrappers';
import { assetDataUtils as sharedAssetDataUtils } from '@0xproject/order-utils';
import * as _ from 'lodash';
import { AssetBuyerError } from '../types';
export const assetDataUtils = {
...sharedAssetDataUtils,
getEtherTokenAssetData(contractWrappers: ContractWrappers): string {
const etherTokenAddressIfExists = contractWrappers.etherToken.getContractAddressIfExists();
if (_.isUndefined(etherTokenAddressIfExists)) {
throw new Error(AssetBuyerError.NoEtherTokenContractFound);
}
const etherTokenAssetData = sharedAssetDataUtils.encodeERC20AssetData(etherTokenAddressIfExists);
return etherTokenAssetData;
},
getZrxTokenAssetData(contractWrappers: ContractWrappers): string {
let zrxTokenAssetData: string;
try {
zrxTokenAssetData = contractWrappers.exchange.getZRXAssetData();
} catch (err) {
throw new Error(AssetBuyerError.NoZrxTokenContractFound);
}
return zrxTokenAssetData;
},
};
|