Move methods in ZeroEx.assetData
to ZeroEx
itself
This commit is contained in:
parent
eb9f7c2c9d
commit
ed19067096
@ -1,4 +1,12 @@
|
|||||||
[
|
[
|
||||||
|
{
|
||||||
|
"version": "1.0.0-rc.2",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Remove `zeroEx.assetData` and instead re-export it's static functions directly off `ZeroEx`"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"version": "1.0.0-rc.1",
|
"version": "1.0.0-rc.1",
|
||||||
"changes": [
|
"changes": [
|
||||||
|
@ -38,10 +38,6 @@ export class ZeroEx {
|
|||||||
* this constant for your convenience.
|
* this constant for your convenience.
|
||||||
*/
|
*/
|
||||||
public static NULL_ADDRESS = constants.NULL_ADDRESS;
|
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.
|
* An instance of the ExchangeWrapper class containing methods for interacting with the 0x Exchange smart contract.
|
||||||
*/
|
*/
|
||||||
@ -125,6 +121,57 @@ export class ZeroEx {
|
|||||||
const baseUnitAmount = Web3Wrapper.toBaseUnitAmount(amount, decimals);
|
const baseUnitAmount = Web3Wrapper.toBaseUnitAmount(amount, decimals);
|
||||||
return baseUnitAmount;
|
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.
|
* 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
|
* @param provider The Provider instance you would like the 0x.js library to use for interacting with
|
||||||
|
Loading…
x
Reference in New Issue
Block a user