Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Export utility methods and data from instant #1787

Merged
merged 1 commit into from
Apr 23, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions packages/instant/src/index.umd.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { AssetBuyer, BigNumber } from '@0x/asset-buyer';
import { assetDataUtils } from '@0x/order-utils';
import { AssetProxyId } from '@0x/types';
import { providerUtils } from '@0x/utils';
import { SupportedProvider, ZeroExProvider } from 'ethereum-types';
import * as _ from 'lodash';
Expand Down Expand Up @@ -151,11 +152,20 @@ export const render = (config: ZeroExInstantConfig, selector: string = DEFAULT_Z
window.onpopstate = onPopStateHandler;
};

export const ERC721_PROXY_ID = AssetProxyId.ERC721;

export const ERC20_PROXY_ID = AssetProxyId.ERC20;

export const assetDataForERC20TokenAddress = (tokenAddress: string): string => {
assert.isETHAddressHex('tokenAddress', tokenAddress);
return assetDataUtils.encodeERC20AssetData(tokenAddress);
};

export const assetDataForERC721TokenAddress = (tokenAddress: string, tokenId: string | number): string => {
assert.isETHAddressHex('tokenAddress', tokenAddress);
return assetDataUtils.encodeERC721AssetData(tokenAddress, new BigNumber(tokenId));
};

export const hasMetaDataForAssetData = (assetData: string): boolean => {
assert.isHexString('assetData', assetData);
return assetMetaDataMap[assetData] !== undefined;
Expand Down