diff options
Diffstat (limited to 'packages/0x.js')
-rw-r--r-- | packages/0x.js/CHANGELOG.json | 35 | ||||
-rw-r--r-- | packages/0x.js/CHANGELOG.md | 4 | ||||
-rw-r--r-- | packages/0x.js/package.json | 52 | ||||
-rw-r--r-- | packages/0x.js/src/0x.ts | 59 | ||||
-rw-r--r-- | packages/0x.js/src/index.ts | 4 | ||||
-rw-r--r-- | packages/0x.js/test/global_hooks.ts | 2 |
6 files changed, 120 insertions, 36 deletions
diff --git a/packages/0x.js/CHANGELOG.json b/packages/0x.js/CHANGELOG.json index 3ec09cd7e..c3b8728c6 100644 --- a/packages/0x.js/CHANGELOG.json +++ b/packages/0x.js/CHANGELOG.json @@ -1,37 +1,60 @@ [ { - "version": "1.0.0", + "timestamp": 1532043100, + "version": "1.0.0-rc.2", + "changes": [ + { + "note": "Remove `zeroEx.assetData` and instead re-export it's static functions directly off `ZeroEx`" + } + ] + }, + { + "timestamp": 1532043000, + "version": "1.0.0-rc.1", "changes": [ { "note": "Remove tokenRegistry wrapper", "pr": 863 }, { - "note": "Rename zeroEx.token to zeroEx.erc20Token, and add zeroEx.erc721Token", + "note": "Rename `zeroEx.token` to `zeroEx.erc20Token`, and add `zeroEx.erc721Token`", "pr": 863 }, { - "note": "Rename zeroEx.proxy to zeroEx.erc20Proxy and add zeroEx.erc721Proxy", + "note": "Rename `zeroEx.proxy` to `zeroEx.erc20Proxy` and add `zeroEx.erc721Proxy`", "pr": 863 }, { "note": - "Refactored ZeroEx.isValidSignature to zeroEx.isValidSignatureAsync. It is now async so that it can verify contract-dependent signature types", + "Refactored `ZeroEx.isValidSignature` to `zeroEx.isValidSignatureAsync`. It is now async so that it can verify contract-dependent signature types", "pr": 863 }, { "note": - "Refactored signOrderHashAsync to ecSignOrderHashAsync. There are now many non-ECSignature ways to sign orders too.", + "Refactored `signOrderHashAsync` to `ecSignOrderHashAsync`. There are now many non-ECSignature ways to sign orders too.", "pr": 863 }, { "note": - "Removed createOrderWatcherAsync method. Will be added back once OrderWatcher is refactored for V2", + "Removed `createOrderWatcherAsync` method. Will be added back once OrderWatcher is refactored for V2", "pr": 863 }, { "note": "0x.js exports renamed contract events and event arg types", "pr": 863 + }, + { + "note": "Export `ZeroEx.assetData` with methods to decode/encode assetData fields found in 0x orders", + "pr": 884 + } + ] + }, + { + "timestamp": 1531919263, + "version": "0.38.6", + "changes": [ + { + "note": "Dependencies updated" } ] }, diff --git a/packages/0x.js/CHANGELOG.md b/packages/0x.js/CHANGELOG.md index 00048f610..f38529715 100644 --- a/packages/0x.js/CHANGELOG.md +++ b/packages/0x.js/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v0.38.6 - _July 18, 2018_ + + * Dependencies updated + ## v0.38.5 - _July 9, 2018_ * Dependencies updated diff --git a/packages/0x.js/package.json b/packages/0x.js/package.json index 966770cf0..06ffe2daf 100644 --- a/packages/0x.js/package.json +++ b/packages/0x.js/package.json @@ -1,6 +1,6 @@ { "name": "0x.js", - "version": "0.38.5", + "version": "1.0.0-rc.2", "engines": { "node": ">=6.12" }, @@ -41,8 +41,8 @@ "contracts": "ZRXToken", "postpublish": { "assets": [ - "packages/0x.js/_bundles/index.js", - "packages/0x.js/_bundles/index.min.js" + "_bundles/index.js", + "_bundles/index.min.js" ], "docPublishConfigs": { "extraFileIncludes": [ @@ -51,13 +51,11 @@ "../contract-wrappers/src/types.ts", "../contract-wrappers/src/contract_wrappers/ether_token_wrapper.ts", "../contract-wrappers/src/contract_wrappers/exchange_wrapper.ts", - "../contract-wrappers/src/contract_wrappers/token_registry_wrapper.ts", - "../contract-wrappers/src/contract_wrappers/token_transfer_proxy_wrapper.ts", - "../contract-wrappers/src/contract_wrappers/token_wrapper.ts", - "../order-watcher/src/order_watcher/order_watcher.ts", - "./src/generated_contract_wrappers/ether_token.ts", - "./src/generated_contract_wrappers/token.ts", - "./src/generated_contract_wrappers/exchange.ts" + "../contract-wrappers/src/contract_wrappers/erc20_proxy_wrapper.ts", + "../contract-wrappers/src/contract_wrappers/erc721_proxy_wrapper.ts", + "../contract-wrappers/src/contract_wrappers/erc20_token_wrapper.ts", + "../contract-wrappers/src/contract_wrappers/erc721_token_wrapper.ts", + "../order-watcher/src/order_watcher/order_watcher.ts" ], "s3BucketPath": "s3://doc-jsons/0x.js/", "s3StagingBucketPath": "s3://staging-doc-jsons/0x.js/" @@ -70,11 +68,11 @@ }, "license": "Apache-2.0", "devDependencies": { - "@0xproject/abi-gen": "^0.3.3", - "@0xproject/dev-utils": "^0.4.5", - "@0xproject/migrations": "^0.0.9", - "@0xproject/monorepo-scripts": "^0.2.2", - "@0xproject/tslint-config": "^0.4.21", + "@0xproject/abi-gen": "^1.0.0", + "@0xproject/dev-utils": "^1.0.0", + "@0xproject/migrations": "^1.0.0", + "@0xproject/monorepo-scripts": "^1.0.0", + "@0xproject/tslint-config": "^1.0.0", "@types/lodash": "4.14.104", "@types/mocha": "^2.2.42", "@types/node": "^8.0.53", @@ -94,23 +92,23 @@ "shx": "^0.2.2", "sinon": "^4.0.0", "source-map-support": "^0.5.0", - "tslint": "5.8.0", + "tslint": "5.11.0", "typedoc": "0xProject/typedoc", "typescript": "2.7.1", "webpack": "^3.1.0" }, "dependencies": { - "@0xproject/assert": "^0.2.13", - "@0xproject/base-contract": "^0.3.5", - "@0xproject/contract-wrappers": "^0.1.0", - "@0xproject/order-utils": "^1.0.0", - "@0xproject/sol-compiler": "^0.5.3", - "@0xproject/subproviders": "^0.10.5", - "@0xproject/types": "^1.0.0", - "@0xproject/typescript-typings": "^0.4.2", - "@0xproject/utils": "^0.7.2", - "@0xproject/web3-wrapper": "^0.7.2", - "ethereum-types": "^0.0.2", + "@0xproject/assert": "^1.0.0", + "@0xproject/base-contract": "^1.0.0", + "@0xproject/contract-wrappers": "^1.0.0-rc.1", + "@0xproject/order-utils": "^1.0.0-rc.1", + "@0xproject/sol-compiler": "^1.0.0", + "@0xproject/subproviders": "^1.0.0", + "@0xproject/types": "^1.0.0-rc.1", + "@0xproject/typescript-typings": "^1.0.0", + "@0xproject/utils": "^1.0.0", + "@0xproject/web3-wrapper": "^1.0.0", + "ethereum-types": "^1.0.0", "ethers": "3.0.22", "lodash": "^4.17.4" }, diff --git a/packages/0x.js/src/0x.ts b/packages/0x.js/src/0x.ts index 5d9a03719..2a2b82f63 100644 --- a/packages/0x.js/src/0x.ts +++ b/packages/0x.js/src/0x.ts @@ -10,13 +10,17 @@ import { ExchangeWrapper, } from '@0xproject/contract-wrappers'; import { + assetDataUtils, ecSignOrderHashAsync, generatePseudoRandomSalt, isValidSignatureAsync, MessagePrefixOpts, orderHashUtils, } from '@0xproject/order-utils'; -import { ECSignature, Order, SignedOrder } from '@0xproject/types'; +// HACK: Since we export assetDataUtils from ZeroEx and it has AssetProxyId, ERC20AssetData and ERC721AssetData +// in it's public interface, we need to import these types here. +// tslint:disable-next-line:no-unused-variable +import { AssetProxyId, ECSignature, ERC20AssetData, ERC721AssetData, Order, SignedOrder } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; import { Provider, TransactionReceiptWithDecodedLogs } from 'ethereum-types'; @@ -61,7 +65,7 @@ export class ZeroEx { * ERC721 proxy smart contract. */ public erc721Proxy: ERC721ProxyWrapper; - private _contractWrappers: ContractWrappers; + private readonly _contractWrappers: ContractWrappers; /** * Generates a pseudo-random 256-bit salt. * The salt can be included in a 0x order, ensuring that the order generates a unique orderHash @@ -118,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. diff --git a/packages/0x.js/src/index.ts b/packages/0x.js/src/index.ts index 95faa860d..95ca07eea 100644 --- a/packages/0x.js/src/index.ts +++ b/packages/0x.js/src/index.ts @@ -12,6 +12,9 @@ export { OrderStateInvalid, OrderState, Token, + ERC20AssetData, + ERC721AssetData, + AssetProxyId, } from '@0xproject/types'; export { @@ -59,4 +62,5 @@ export { ExchangeCancelEventArgs, ExchangeEventArgs, ContractWrappersConfig, + OrderInfo, } from '@0xproject/contract-wrappers'; diff --git a/packages/0x.js/test/global_hooks.ts b/packages/0x.js/test/global_hooks.ts index 3d74634fe..364828231 100644 --- a/packages/0x.js/test/global_hooks.ts +++ b/packages/0x.js/test/global_hooks.ts @@ -7,7 +7,7 @@ before('migrate contracts', async function(): Promise<void> { // HACK: Since the migrations take longer then our global mocha timeout limit // we manually increase it for this before hook. const mochaTestTimeoutMs = 20000; - this.timeout(mochaTestTimeoutMs); + this.timeout(mochaTestTimeoutMs); // tslint:disable-line:no-invalid-this const txDefaults = { gas: devConstants.GAS_LIMIT, from: devConstants.TESTRPC_FIRST_ADDRESS, |