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

Commit

Permalink
Merge pull request #1787 from 0xProject/feature/instant/utility-methods
Browse files Browse the repository at this point in the history
Export utility methods and data from instant
  • Loading branch information
fragosti authored Apr 23, 2019
2 parents 59ed5ae + 9c3fdd2 commit 600b86d
Showing 1 changed file with 10 additions and 0 deletions.
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

0 comments on commit 600b86d

Please sign in to comment.