aboutsummaryrefslogtreecommitdiffstats
path: root/packages/0x.js/src/0x.ts
diff options
context:
space:
mode:
authorBrandon Millman <brandon.millman@gmail.com>2018-07-21 07:15:04 +0800
committerBrandon Millman <brandon.millman@gmail.com>2018-07-21 07:15:04 +0800
commit6ffa907f0ef3c94d3ea7d79d99a24939f62e0eb8 (patch)
tree7b6a6eb86d6a0463221a502fb886bae6ff5a243c /packages/0x.js/src/0x.ts
parent938aabde3db0044c658e86765e1bbdbdce4e4a17 (diff)
parente54501522dcf93521c8ff7dfe5b216cffeaa1b29 (diff)
downloaddexon-sol-tools-6ffa907f0ef3c94d3ea7d79d99a24939f62e0eb8.tar
dexon-sol-tools-6ffa907f0ef3c94d3ea7d79d99a24939f62e0eb8.tar.gz
dexon-sol-tools-6ffa907f0ef3c94d3ea7d79d99a24939f62e0eb8.tar.bz2
dexon-sol-tools-6ffa907f0ef3c94d3ea7d79d99a24939f62e0eb8.tar.lz
dexon-sol-tools-6ffa907f0ef3c94d3ea7d79d99a24939f62e0eb8.tar.xz
dexon-sol-tools-6ffa907f0ef3c94d3ea7d79d99a24939f62e0eb8.tar.zst
dexon-sol-tools-6ffa907f0ef3c94d3ea7d79d99a24939f62e0eb8.zip
Merge branch 'v2-prototype' into feature/website/jobs-page-part2
* v2-prototype: (103 commits) Add changelog entry for @0xproject/utils Add AbortController polyfill to fetchAsync in utils Increase node heap size for webpack command Add missing timestamp to CHANGELOG entries Upgrade some @0xproject packages to 1.0.0 in website Hard code fillOrder selector into abiEncodeFillOrder Returns byte array instead of memory range for encoding fillOrder calldata Created LibAbiEncoder with `fillOrderNoThrow` Add missing dep in migrations Fix the abi-gen entry point Fix linter error Remove the postinstall hook Update website package.json with original imports @0xproject/sra-report@1.0.0 Change all package to depend on the new @0xproject/connect@1.0.0 @0xproject/connect@1.0.0 Use old assert version in @0xproject/connect FIx a typo Remove rc versions from unmigrated packages 0x.js@1.0.0-rc.2 ...
Diffstat (limited to 'packages/0x.js/src/0x.ts')
-rw-r--r--packages/0x.js/src/0x.ts55
1 files changed, 51 insertions, 4 deletions
diff --git a/packages/0x.js/src/0x.ts b/packages/0x.js/src/0x.ts
index 7c06a53af..2a2b82f63 100644
--- a/packages/0x.js/src/0x.ts
+++ b/packages/0x.js/src/0x.ts
@@ -39,10 +39,6 @@ export class ZeroEx {
*/
public static NULL_ADDRESS = constants.NULL_ADDRESS;
/**
- * A set of methods to easily decode/encode assetData fields found in 0x orders.
- */
- public static assetData = assetDataUtils;
- /**
* An instance of the ExchangeWrapper class containing methods for interacting with the 0x Exchange smart contract.
*/
public exchange: ExchangeWrapper;
@@ -126,6 +122,57 @@ export class ZeroEx {
return baseUnitAmount;
}
/**
+ * Encodes an ERC20 token address into a hex encoded assetData string, usable in the makerAssetData or
+ * takerAssetData fields in a 0x order.
+ * @param tokenAddress The ERC20 token address to encode
+ * @return The hex encoded assetData string
+ */
+ public static encodeERC20AssetData(tokenAddress: string): string {
+ return assetDataUtils.encodeERC20AssetData(tokenAddress);
+ }
+ /**
+ * Decodes an ERC20 assetData hex string into it's corresponding ERC20 tokenAddress & assetProxyId
+ * @param assetData Hex encoded assetData string to decode
+ * @return An object containing the decoded tokenAddress & assetProxyId
+ */
+ public static decodeERC20AssetData(assetData: string): ERC20AssetData {
+ return assetDataUtils.decodeERC20AssetData(assetData);
+ }
+ /**
+ * Encodes an ERC721 token address into a hex encoded assetData string, usable in the makerAssetData or
+ * takerAssetData fields in a 0x order.
+ * @param tokenAddress The ERC721 token address to encode
+ * @param tokenId The ERC721 tokenId to encode
+ * @return The hex encoded assetData string
+ */
+ public static encodeERC721AssetData(tokenAddress: string, tokenId: BigNumber): string {
+ return assetDataUtils.encodeERC721AssetData(tokenAddress, tokenId);
+ }
+ /**
+ * Decodes an ERC721 assetData hex string into it's corresponding ERC721 tokenAddress, tokenId & assetProxyId
+ * @param assetData Hex encoded assetData string to decode
+ * @return An object containing the decoded tokenAddress, tokenId & assetProxyId
+ */
+ public static decodeERC721AssetData(assetData: string): ERC721AssetData {
+ return assetDataUtils.decodeERC721AssetData(assetData);
+ }
+ /**
+ * Decode and return the assetProxyId from the assetData
+ * @param assetData Hex encoded assetData string to decode
+ * @return The assetProxyId
+ */
+ public static decodeAssetProxyId(assetData: string): AssetProxyId {
+ return assetDataUtils.decodeAssetProxyId(assetData);
+ }
+ /**
+ * Decode any assetData into it's corresponding assetData object
+ * @param assetData Hex encoded assetData string to decode
+ * @return Either a ERC20 or ERC721 assetData object
+ */
+ public static decodeAssetDataOrThrow(assetData: string): ERC20AssetData | ERC721AssetData {
+ return assetDataUtils.decodeAssetDataOrThrow(assetData);
+ }
+ /**
* Instantiates a new ZeroEx instance that provides the public interface to the 0x.js library.
* @param provider The Provider instance you would like the 0x.js library to use for interacting with
* the Ethereum network.