From 5682cd0048072fd5c420a35170045134bc5185b9 Mon Sep 17 00:00:00 2001 From: Jacob Evans Date: Tue, 24 Apr 2018 14:06:56 +1000 Subject: Update Web3 Provider Engine to 14.0.4 --- packages/0x.js/CHANGELOG.json | 6 +++++- packages/0x.js/package.json | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'packages/0x.js') diff --git a/packages/0x.js/CHANGELOG.json b/packages/0x.js/CHANGELOG.json index ef4bb1e07..b2aebf803 100644 --- a/packages/0x.js/CHANGELOG.json +++ b/packages/0x.js/CHANGELOG.json @@ -1,10 +1,14 @@ [ { - "version": "0.36.4", + "version": "0.37.0", "changes": [ { "note": "Fixed expiration watcher comparator to handle orders with equal expiration times", "pr": 526 + }, + { + "note": "Update Web3 Provider Engine to 14.0.4", + "pr": 555 } ] }, diff --git a/packages/0x.js/package.json b/packages/0x.js/package.json index e7cdff09e..24fd44413 100644 --- a/packages/0x.js/package.json +++ b/packages/0x.js/package.json @@ -93,7 +93,7 @@ "tslint": "5.8.0", "typedoc": "0xProject/typedoc", "typescript": "2.7.1", - "web3-provider-engine": "^13.0.1", + "web3-provider-engine": "^14.0.4", "webpack": "^3.1.0" }, "dependencies": { -- cgit v1.2.3 From b36587fac833f4fa35aaed49e4ee05f6ce347a02 Mon Sep 17 00:00:00 2001 From: Jacob Evans Date: Mon, 30 Apr 2018 18:05:45 +1000 Subject: Execute taker side in trade simulation Fill if the taker address is open --- .../0x.js/src/utils/exchange_transfer_simulator.ts | 6 ++++ packages/0x.js/src/utils/order_validation_utils.ts | 25 ++------------- packages/0x.js/test/order_validation_test.ts | 36 +++++++++++++++++++++- 3 files changed, 44 insertions(+), 23 deletions(-) (limited to 'packages/0x.js') diff --git a/packages/0x.js/src/utils/exchange_transfer_simulator.ts b/packages/0x.js/src/utils/exchange_transfer_simulator.ts index 9a920c643..ccefea930 100644 --- a/packages/0x.js/src/utils/exchange_transfer_simulator.ts +++ b/packages/0x.js/src/utils/exchange_transfer_simulator.ts @@ -5,6 +5,7 @@ import * as _ from 'lodash'; import { TokenWrapper } from '../contract_wrappers/token_wrapper'; import { BalanceAndProxyAllowanceLazyStore } from '../stores/balance_proxy_allowance_lazy_store'; import { ExchangeContractErrs, TradeSide, TransferType } from '../types'; +import { constants } from '../utils/constants'; enum FailureReason { Balance = 'balance', @@ -66,6 +67,11 @@ export class ExchangeTransferSimulator { tradeSide: TradeSide, transferType: TransferType, ): Promise { + // If we are simulating an open order then 0x0 will have no balance or allowance + if (from === constants.NULL_ADDRESS && tradeSide === TradeSide.Taker) { + await this._increaseBalanceAsync(tokenAddress, to, amountInBaseUnits); + return; + } const balance = await this._store.getBalanceAsync(tokenAddress, from); const proxyAllowance = await this._store.getProxyAllowanceAsync(tokenAddress, from); if (proxyAllowance.lessThan(amountInBaseUnits)) { diff --git a/packages/0x.js/src/utils/order_validation_utils.ts b/packages/0x.js/src/utils/order_validation_utils.ts index f32bf43d0..b320a3e92 100644 --- a/packages/0x.js/src/utils/order_validation_utils.ts +++ b/packages/0x.js/src/utils/order_validation_utils.ts @@ -124,31 +124,12 @@ export class OrderValidationUtils { if (!_.isUndefined(expectedFillTakerTokenAmount)) { fillTakerTokenAmount = expectedFillTakerTokenAmount; } - const fillMakerTokenAmount = OrderValidationUtils._getPartialAmount( + await OrderValidationUtils.validateFillOrderBalancesAllowancesThrowIfInvalidAsync( + exchangeTradeEmulator, + signedOrder, fillTakerTokenAmount, - signedOrder.takerTokenAmount, - signedOrder.makerTokenAmount, - ); - await exchangeTradeEmulator.transferFromAsync( - signedOrder.makerTokenAddress, - signedOrder.maker, signedOrder.taker, - fillMakerTokenAmount, - TradeSide.Maker, - TransferType.Trade, - ); - const makerFeeAmount = OrderValidationUtils._getPartialAmount( - fillTakerTokenAmount, - signedOrder.takerTokenAmount, - signedOrder.makerFee, - ); - await exchangeTradeEmulator.transferFromAsync( zrxTokenAddress, - signedOrder.maker, - signedOrder.feeRecipient, - makerFeeAmount, - TradeSide.Maker, - TransferType.Fee, ); } public async validateFillOrderThrowIfInvalidAsync( diff --git a/packages/0x.js/test/order_validation_test.ts b/packages/0x.js/test/order_validation_test.ts index c894774b8..9b843b930 100644 --- a/packages/0x.js/test/order_validation_test.ts +++ b/packages/0x.js/test/order_validation_test.ts @@ -68,6 +68,40 @@ describe('OrderValidation', () => { ); await zeroEx.exchange.validateOrderFillableOrThrowAsync(signedOrder); }); + it('should succeed if the maker is buying ZRX and has no ZRX balance', async () => { + const makerFee = new BigNumber(2); + const takerFee = new BigNumber(2); + const signedOrder = await fillScenarios.createFillableSignedOrderWithFeesAsync( + makerTokenAddress, + zrxTokenAddress, + makerFee, + takerFee, + makerAddress, + takerAddress, + fillableAmount, + feeRecipient, + ); + const zrxMakerBalance = await zeroEx.token.getBalanceAsync(zrxTokenAddress, makerAddress); + await zeroEx.token.transferAsync(zrxTokenAddress, makerAddress, takerAddress, zrxMakerBalance); + await zeroEx.exchange.validateOrderFillableOrThrowAsync(signedOrder); + }); + it('should succeed if the maker is buying ZRX and has no ZRX balance and there is no specified taker', async () => { + const makerFee = new BigNumber(2); + const takerFee = new BigNumber(2); + const signedOrder = await fillScenarios.createFillableSignedOrderWithFeesAsync( + makerTokenAddress, + zrxTokenAddress, + makerFee, + takerFee, + makerAddress, + constants.NULL_ADDRESS, + fillableAmount, + feeRecipient, + ); + const zrxMakerBalance = await zeroEx.token.getBalanceAsync(zrxTokenAddress, makerAddress); + await zeroEx.token.transferAsync(zrxTokenAddress, makerAddress, takerAddress, zrxMakerBalance); + await zeroEx.exchange.validateOrderFillableOrThrowAsync(signedOrder); + }); it('should succeed if the order is asymmetric and fillable', async () => { const makerFillableAmount = fillableAmount; const takerFillableAmount = fillableAmount.minus(4); @@ -469,4 +503,4 @@ describe('OrderValidation', () => { expect(partialTakerFee).to.be.bignumber.equal(takerPartialFee); }); }); -}); +}); // tslint:disable-line:max-file-line-count -- cgit v1.2.3 From 8e7937bdb61887ea3df66a602a275f5643e6585c Mon Sep 17 00:00:00 2001 From: Jacob Evans Date: Tue, 1 May 2018 19:06:17 +1000 Subject: Update comment to be more descriptive of null address in exchange simulator --- packages/0x.js/src/utils/exchange_transfer_simulator.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'packages/0x.js') diff --git a/packages/0x.js/src/utils/exchange_transfer_simulator.ts b/packages/0x.js/src/utils/exchange_transfer_simulator.ts index ccefea930..f8301f5c2 100644 --- a/packages/0x.js/src/utils/exchange_transfer_simulator.ts +++ b/packages/0x.js/src/utils/exchange_transfer_simulator.ts @@ -67,7 +67,9 @@ export class ExchangeTransferSimulator { tradeSide: TradeSide, transferType: TransferType, ): Promise { - // If we are simulating an open order then 0x0 will have no balance or allowance + // HACK: When simulating an open order (e.g taker is NULL_ADDRESS), we don't want to adjust balances/ + // allowances for the taker. We do however, want to increase the balance of the maker since the maker + // might be relying on those funds to fill subsequent orders or pay the order's fees. if (from === constants.NULL_ADDRESS && tradeSide === TradeSide.Taker) { await this._increaseBalanceAsync(tokenAddress, to, amountInBaseUnits); return; -- cgit v1.2.3 From 0499541e114e6dd36565428f4f914e0dbdece2b8 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 24 Apr 2018 16:36:35 +0200 Subject: Move order utils to @0xproject/order-utils --- packages/0x.js/CHANGELOG.json | 13 ++ packages/0x.js/package.json | 1 + packages/0x.js/src/0x.ts | 144 +++++++-------------- .../src/contract_wrappers/ether_token_wrapper.ts | 2 +- .../src/contract_wrappers/exchange_wrapper.ts | 8 +- .../contract_wrappers/token_registry_wrapper.ts | 2 +- .../token_transfer_proxy_wrapper.ts | 2 +- .../0x.js/src/contract_wrappers/token_wrapper.ts | 2 +- packages/0x.js/src/order_watcher/event_watcher.ts | 2 +- .../0x.js/src/order_watcher/order_state_watcher.ts | 2 +- packages/0x.js/src/types.ts | 1 - packages/0x.js/src/utils/assert.ts | 35 ----- packages/0x.js/src/utils/constants.ts | 1 - packages/0x.js/src/utils/order_validation_utils.ts | 7 +- packages/0x.js/src/utils/signature_utils.ts | 45 ------- packages/0x.js/src/utils/utils.ts | 50 ------- packages/0x.js/test/0x.js_test.ts | 133 ------------------- packages/0x.js/test/assert_test.ts | 43 ------ packages/0x.js/test/order_validation_test.ts | 3 +- packages/0x.js/test/utils/fill_scenarios.ts | 4 +- packages/0x.js/test/utils/order_factory.ts | 46 ------- packages/0x.js/test/utils/web3_wrapper.ts | 3 - 22 files changed, 82 insertions(+), 467 deletions(-) delete mode 100644 packages/0x.js/src/utils/assert.ts delete mode 100644 packages/0x.js/src/utils/signature_utils.ts delete mode 100644 packages/0x.js/test/utils/order_factory.ts (limited to 'packages/0x.js') diff --git a/packages/0x.js/CHANGELOG.json b/packages/0x.js/CHANGELOG.json index b2aebf803..c2545b7da 100644 --- a/packages/0x.js/CHANGELOG.json +++ b/packages/0x.js/CHANGELOG.json @@ -1,4 +1,17 @@ [ + { + "version": "0.38.0", + "changes": [ + { + "note": "Add `zeroEx.getProvider()`", + "pr": 559 + }, + { + "note": "Move `ZeroExError.InvalidSignature` to `@0xproject/order-utils` `OrderError.InvalidSignature`", + "pr": 559 + } + ] + }, { "version": "0.37.0", "changes": [ diff --git a/packages/0x.js/package.json b/packages/0x.js/package.json index 24fd44413..33c29a788 100644 --- a/packages/0x.js/package.json +++ b/packages/0x.js/package.json @@ -103,6 +103,7 @@ "@0xproject/types": "^0.6.1", "@0xproject/typescript-typings": "^0.2.0", "@0xproject/utils": "^0.5.2", + "@0xproject/order-utils": "^0.0.1", "@0xproject/web3-wrapper": "^0.6.1", "bintrees": "^1.0.2", "bn.js": "^4.11.8", diff --git a/packages/0x.js/src/0x.ts b/packages/0x.js/src/0x.ts index 94d97c23e..780d1b52a 100644 --- a/packages/0x.js/src/0x.ts +++ b/packages/0x.js/src/0x.ts @@ -1,4 +1,12 @@ import { schemas, SchemaValidator } from '@0xproject/json-schemas'; +import { + assert, + generatePseudoRandomSalt, + getOrderHashHex, + isValidOrderHash, + isValidSignature, + signOrderHashAsync, +} from '@0xproject/order-utils'; import { ECSignature, Order, Provider, SignedOrder, TransactionReceiptWithDecodedLogs } from '@0xproject/types'; import { AbiDecoder, BigNumber, intervalUtils } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; @@ -16,10 +24,8 @@ import { zeroExConfigSchema } from './schemas/zero_ex_config_schema'; import { zeroExPrivateNetworkConfigSchema } from './schemas/zero_ex_private_network_config_schema'; import { zeroExPublicNetworkConfigSchema } from './schemas/zero_ex_public_network_config_schema'; import { OrderStateWatcherConfig, ZeroExConfig, ZeroExError } from './types'; -import { assert } from './utils/assert'; import { constants } from './utils/constants'; import { decorators } from './utils/decorators'; -import { signatureUtils } from './utils/signature_utils'; import { utils } from './utils/utils'; /** @@ -33,6 +39,36 @@ export class ZeroEx { * this constant for your convenience. */ public static NULL_ADDRESS = constants.NULL_ADDRESS; + /** + * Generates a pseudo-random 256-bit salt. + * The salt can be included in a 0x order, ensuring that the order generates a unique orderHash + * and will not collide with other outstanding orders that are identical in all other parameters. + * @return A pseudo-random 256-bit number that can be used as a salt. + */ + public static generatePseudoRandomSalt = generatePseudoRandomSalt; + /** + * Verifies that the elliptic curve signature `signature` was generated + * by signing `data` with the private key corresponding to the `signerAddress` address. + * @param data The hex encoded data signed by the supplied signature. + * @param signature An object containing the elliptic curve signature parameters. + * @param signerAddress The hex encoded address that signed the data, producing the supplied signature. + * @return Whether the signature is valid for the supplied signerAddress and data. + */ + public static isValidSignature = isValidSignature; + /** + * Computes the orderHash for a supplied order. + * @param order An object that conforms to the Order or SignedOrder interface definitions. + * @return The resulting orderHash from hashing the supplied order. + */ + public static getOrderHashHex = getOrderHashHex; + /** + * Checks if the supplied hex encoded order hash is valid. + * Note: Valid means it has the expected format, not that an order with the orderHash exists. + * Use this method when processing orderHashes submitted as user input. + * @param orderHash Hex encoded orderHash. + * @return Whether the supplied orderHash has the expected format. + */ + public static isValidOrderHash = isValidOrderHash; /** * An instance of the ExchangeWrapper class containing methods for interacting with the 0x Exchange smart contract. @@ -58,52 +94,6 @@ export class ZeroEx { */ public proxy: TokenTransferProxyWrapper; private _web3Wrapper: Web3Wrapper; - /** - * Verifies that the elliptic curve signature `signature` was generated - * by signing `data` with the private key corresponding to the `signerAddress` address. - * @param data The hex encoded data signed by the supplied signature. - * @param signature An object containing the elliptic curve signature parameters. - * @param signerAddress The hex encoded address that signed the data, producing the supplied signature. - * @return Whether the signature is valid for the supplied signerAddress and data. - */ - public static isValidSignature(data: string, signature: ECSignature, signerAddress: string): boolean { - assert.isHexString('data', data); - assert.doesConformToSchema('signature', signature, schemas.ecSignatureSchema); - assert.isETHAddressHex('signerAddress', signerAddress); - const normalizedSignerAddress = signerAddress.toLowerCase(); - - const isValidSignature = signatureUtils.isValidSignature(data, signature, normalizedSignerAddress); - return isValidSignature; - } - /** - * Generates a pseudo-random 256-bit salt. - * The salt can be included in a 0x order, ensuring that the order generates a unique orderHash - * and will not collide with other outstanding orders that are identical in all other parameters. - * @return A pseudo-random 256-bit number that can be used as a salt. - */ - public static generatePseudoRandomSalt(): BigNumber { - // BigNumber.random returns a pseudo-random number between 0 & 1 with a passed in number of decimal places. - // Source: https://mikemcl.github.io/bignumber.js/#random - const randomNumber = BigNumber.random(constants.MAX_DIGITS_IN_UNSIGNED_256_INT); - const factor = new BigNumber(10).pow(constants.MAX_DIGITS_IN_UNSIGNED_256_INT - 1); - const salt = randomNumber.times(factor).round(); - return salt; - } - /** - * Checks if the supplied hex encoded order hash is valid. - * Note: Valid means it has the expected format, not that an order with the orderHash exists. - * Use this method when processing orderHashes submitted as user input. - * @param orderHash Hex encoded orderHash. - * @return Whether the supplied orderHash has the expected format. - */ - public static isValidOrderHash(orderHash: string): boolean { - // Since this method can be called to check if any arbitrary string conforms to an orderHash's - // format, we only assert that we were indeed passed a string. - assert.isString('orderHash', orderHash); - const schemaValidator = new SchemaValidator(); - const isValidOrderHash = schemaValidator.validate(orderHash, schemas.orderHashSchema).valid; - return isValidOrderHash; - } /** * A unit amount is defined as the amount of a token above the specified decimal places (integer part). * E.g: If a currency has 18 decimal places, 1e18 or one quintillion of the currency is equivalent @@ -132,17 +122,6 @@ export class ZeroEx { const baseUnitAmount = Web3Wrapper.toBaseUnitAmount(amount, decimals); return baseUnitAmount; } - /** - * Computes the orderHash for a supplied order. - * @param order An object that conforms to the Order or SignedOrder interface definitions. - * @return The resulting orderHash from hashing the supplied order. - */ - @decorators.syncZeroExErrorHandler - public static getOrderHashHex(order: Order | SignedOrder): string { - assert.doesConformToSchema('order', order, schemas.orderSchema); - const orderHashHex = utils.getOrderHashHex(order); - return orderHashHex; - } /** * 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 @@ -204,6 +183,12 @@ export class ZeroEx { (this.etherToken as any)._invalidateContractInstance(); (this.etherToken as any)._setNetworkId(networkId); } + /** + * Get the provider instance currently used by 0x.js + */ + public getProvider(): Provider { + return this._web3Wrapper.getProvider(); + } /** * Get user Ethereum addresses available through the supplied web3 provider available for sending transactions. * @return An array of available user Ethereum addresses. @@ -229,41 +214,12 @@ export class ZeroEx { signerAddress: string, shouldAddPersonalMessagePrefix: boolean, ): Promise { - assert.isHexString('orderHash', orderHash); - await assert.isSenderAddressAsync('signerAddress', signerAddress, this._web3Wrapper); - const normalizedSignerAddress = signerAddress.toLowerCase(); - - let msgHashHex = orderHash; - if (shouldAddPersonalMessagePrefix) { - const orderHashBuff = ethUtil.toBuffer(orderHash); - const msgHashBuff = ethUtil.hashPersonalMessage(orderHashBuff); - msgHashHex = ethUtil.bufferToHex(msgHashBuff); - } - - const signature = await this._web3Wrapper.signMessageAsync(normalizedSignerAddress, msgHashHex); - - // HACK: There is no consensus on whether the signatureHex string should be formatted as - // v + r + s OR r + s + v, and different clients (even different versions of the same client) - // return the signature params in different orders. In order to support all client implementations, - // we parse the signature in both ways, and evaluate if either one is a valid signature. - const validVParamValues = [27, 28]; - const ecSignatureVRS = signatureUtils.parseSignatureHexAsVRS(signature); - if (_.includes(validVParamValues, ecSignatureVRS.v)) { - const isValidVRSSignature = ZeroEx.isValidSignature(orderHash, ecSignatureVRS, normalizedSignerAddress); - if (isValidVRSSignature) { - return ecSignatureVRS; - } - } - - const ecSignatureRSV = signatureUtils.parseSignatureHexAsRSV(signature); - if (_.includes(validVParamValues, ecSignatureRSV.v)) { - const isValidRSVSignature = ZeroEx.isValidSignature(orderHash, ecSignatureRSV, normalizedSignerAddress); - if (isValidRSVSignature) { - return ecSignatureRSV; - } - } - - throw new Error(ZeroExError.InvalidSignature); + return signOrderHashAsync( + this._web3Wrapper.getProvider(), + orderHash, + signerAddress, + shouldAddPersonalMessagePrefix, + ); } /** * Waits for a transaction to be mined and returns the transaction receipt. diff --git a/packages/0x.js/src/contract_wrappers/ether_token_wrapper.ts b/packages/0x.js/src/contract_wrappers/ether_token_wrapper.ts index fd39de34b..8a8caa4dc 100644 --- a/packages/0x.js/src/contract_wrappers/ether_token_wrapper.ts +++ b/packages/0x.js/src/contract_wrappers/ether_token_wrapper.ts @@ -1,4 +1,5 @@ import { schemas } from '@0xproject/json-schemas'; +import { assert } from '@0xproject/order-utils'; import { LogWithDecodedArgs } from '@0xproject/types'; import { AbiDecoder, BigNumber } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; @@ -6,7 +7,6 @@ import * as _ from 'lodash'; import { artifacts } from '../artifacts'; import { BlockRange, EventCallback, IndexedFilterValues, TransactionOpts, ZeroExError } from '../types'; -import { assert } from '../utils/assert'; import { ContractWrapper } from './contract_wrapper'; import { EtherTokenContract, EtherTokenContractEventArgs, EtherTokenEvents } from './generated/ether_token'; diff --git a/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts b/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts index 7cda70f16..5dca61ab3 100644 --- a/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts +++ b/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts @@ -1,4 +1,5 @@ import { schemas } from '@0xproject/json-schemas'; +import { assert, getOrderHashHex } from '@0xproject/order-utils'; import { BlockParamLiteral, DecodedLogArgs, @@ -30,7 +31,6 @@ import { OrderValues, ValidateOrderFillableOpts, } from '../types'; -import { assert } from '../utils/assert'; import { decorators } from '../utils/decorators'; import { ExchangeTransferSimulator } from '../utils/exchange_transfer_simulator'; import { OrderStateUtils } from '../utils/order_state_utils'; @@ -570,7 +570,7 @@ export class ExchangeWrapper extends ContractWrapper { ? SHOULD_VALIDATE_BY_DEFAULT : orderTransactionOpts.shouldValidate; if (shouldValidate) { - const orderHash = utils.getOrderHashHex(order); + const orderHash = getOrderHashHex(order); const unavailableTakerTokenAmount = await this.getUnavailableTakerAmountAsync(orderHash); OrderValidationUtils.validateCancelOrderThrowIfInvalid( order, @@ -629,7 +629,7 @@ export class ExchangeWrapper extends ContractWrapper { : orderTransactionOpts.shouldValidate; if (shouldValidate) { for (const orderCancellationRequest of orderCancellationRequests) { - const orderHash = utils.getOrderHashHex(orderCancellationRequest.order); + const orderHash = getOrderHashHex(orderCancellationRequest.order); const unavailableTakerTokenAmount = await this.getUnavailableTakerAmountAsync(orderHash); OrderValidationUtils.validateCancelOrderThrowIfInvalid( orderCancellationRequest.order, @@ -801,7 +801,7 @@ export class ExchangeWrapper extends ContractWrapper { ): Promise { assert.doesConformToSchema('order', order, schemas.orderSchema); assert.isValidBaseUnitAmount('cancelTakerTokenAmount', cancelTakerTokenAmount); - const orderHash = utils.getOrderHashHex(order); + const orderHash = getOrderHashHex(order); const unavailableTakerTokenAmount = await this.getUnavailableTakerAmountAsync(orderHash); OrderValidationUtils.validateCancelOrderThrowIfInvalid( order, diff --git a/packages/0x.js/src/contract_wrappers/token_registry_wrapper.ts b/packages/0x.js/src/contract_wrappers/token_registry_wrapper.ts index c4a193264..a1ec91757 100644 --- a/packages/0x.js/src/contract_wrappers/token_registry_wrapper.ts +++ b/packages/0x.js/src/contract_wrappers/token_registry_wrapper.ts @@ -1,9 +1,9 @@ +import { assert } from '@0xproject/order-utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; import * as _ from 'lodash'; import { artifacts } from '../artifacts'; import { Token, TokenMetadata } from '../types'; -import { assert } from '../utils/assert'; import { constants } from '../utils/constants'; import { ContractWrapper } from './contract_wrapper'; diff --git a/packages/0x.js/src/contract_wrappers/token_transfer_proxy_wrapper.ts b/packages/0x.js/src/contract_wrappers/token_transfer_proxy_wrapper.ts index be558b5be..495923ecc 100644 --- a/packages/0x.js/src/contract_wrappers/token_transfer_proxy_wrapper.ts +++ b/packages/0x.js/src/contract_wrappers/token_transfer_proxy_wrapper.ts @@ -1,8 +1,8 @@ +import { assert } from '@0xproject/order-utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; import * as _ from 'lodash'; import { artifacts } from '../artifacts'; -import { assert } from '../utils/assert'; import { ContractWrapper } from './contract_wrapper'; import { TokenTransferProxyContract } from './generated/token_transfer_proxy'; diff --git a/packages/0x.js/src/contract_wrappers/token_wrapper.ts b/packages/0x.js/src/contract_wrappers/token_wrapper.ts index 194cfb5aa..6751f46b3 100644 --- a/packages/0x.js/src/contract_wrappers/token_wrapper.ts +++ b/packages/0x.js/src/contract_wrappers/token_wrapper.ts @@ -1,4 +1,5 @@ import { schemas } from '@0xproject/json-schemas'; +import { assert } from '@0xproject/order-utils'; import { LogWithDecodedArgs } from '@0xproject/types'; import { AbiDecoder, BigNumber } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; @@ -6,7 +7,6 @@ import * as _ from 'lodash'; import { artifacts } from '../artifacts'; import { BlockRange, EventCallback, IndexedFilterValues, MethodOpts, TransactionOpts, ZeroExError } from '../types'; -import { assert } from '../utils/assert'; import { constants } from '../utils/constants'; import { ContractWrapper } from './contract_wrapper'; diff --git a/packages/0x.js/src/order_watcher/event_watcher.ts b/packages/0x.js/src/order_watcher/event_watcher.ts index de5a99a46..545b352a4 100644 --- a/packages/0x.js/src/order_watcher/event_watcher.ts +++ b/packages/0x.js/src/order_watcher/event_watcher.ts @@ -1,10 +1,10 @@ +import { assert } from '@0xproject/order-utils'; import { BlockParamLiteral, LogEntry } from '@0xproject/types'; import { intervalUtils } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; import * as _ from 'lodash'; import { EventWatcherCallback, ZeroExError } from '../types'; -import { assert } from '../utils/assert'; const DEFAULT_EVENT_POLLING_INTERVAL_MS = 200; diff --git a/packages/0x.js/src/order_watcher/order_state_watcher.ts b/packages/0x.js/src/order_watcher/order_state_watcher.ts index a9df8ac9d..008db6bc4 100644 --- a/packages/0x.js/src/order_watcher/order_state_watcher.ts +++ b/packages/0x.js/src/order_watcher/order_state_watcher.ts @@ -1,4 +1,5 @@ import { schemas } from '@0xproject/json-schemas'; +import { assert } from '@0xproject/order-utils'; import { BlockParamLiteral, LogWithDecodedArgs, SignedOrder } from '@0xproject/types'; import { AbiDecoder, intervalUtils } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; @@ -33,7 +34,6 @@ import { OrderStateWatcherConfig, ZeroExError, } from '../types'; -import { assert } from '../utils/assert'; import { OrderStateUtils } from '../utils/order_state_utils'; import { utils } from '../utils/utils'; diff --git a/packages/0x.js/src/types.ts b/packages/0x.js/src/types.ts index 151204928..ae9f98c5f 100644 --- a/packages/0x.js/src/types.ts +++ b/packages/0x.js/src/types.ts @@ -27,7 +27,6 @@ export enum ZeroExError { TokenContractDoesNotExist = 'TOKEN_CONTRACT_DOES_NOT_EXIST', UnhandledError = 'UNHANDLED_ERROR', UserHasNoAssociatedAddress = 'USER_HAS_NO_ASSOCIATED_ADDRESSES', - InvalidSignature = 'INVALID_SIGNATURE', ContractNotDeployedOnNetwork = 'CONTRACT_NOT_DEPLOYED_ON_NETWORK', InsufficientAllowanceForTransfer = 'INSUFFICIENT_ALLOWANCE_FOR_TRANSFER', InsufficientBalanceForTransfer = 'INSUFFICIENT_BALANCE_FOR_TRANSFER', diff --git a/packages/0x.js/src/utils/assert.ts b/packages/0x.js/src/utils/assert.ts deleted file mode 100644 index 5e8004cd0..000000000 --- a/packages/0x.js/src/utils/assert.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { assert as sharedAssert } from '@0xproject/assert'; -// We need those two unused imports because they're actually used by sharedAssert which gets injected here -// tslint:disable-next-line:no-unused-variable -import { Schema } from '@0xproject/json-schemas'; -// tslint:disable-next-line:no-unused-variable -import { ECSignature } from '@0xproject/types'; -import { BigNumber } from '@0xproject/utils'; -import { Web3Wrapper } from '@0xproject/web3-wrapper'; -import * as _ from 'lodash'; - -import { signatureUtils } from '../utils/signature_utils'; - -export const assert = { - ...sharedAssert, - isValidSignature(orderHash: string, ecSignature: ECSignature, signerAddress: string) { - const isValidSignature = signatureUtils.isValidSignature(orderHash, ecSignature, signerAddress); - this.assert(isValidSignature, `Expected order with hash '${orderHash}' to have a valid signature`); - }, - async isSenderAddressAsync( - variableName: string, - senderAddressHex: string, - web3Wrapper: Web3Wrapper, - ): Promise { - sharedAssert.isETHAddressHex(variableName, senderAddressHex); - const isSenderAddressAvailable = await web3Wrapper.isSenderAddressAvailableAsync(senderAddressHex); - sharedAssert.assert( - isSenderAddressAvailable, - `Specified ${variableName} ${senderAddressHex} isn't available through the supplied web3 provider`, - ); - }, - async isUserAddressAvailableAsync(web3Wrapper: Web3Wrapper): Promise { - const availableAddresses = await web3Wrapper.getAvailableAddressesAsync(); - this.assert(!_.isEmpty(availableAddresses), 'No addresses were available on the provided web3 provider'); - }, -}; diff --git a/packages/0x.js/src/utils/constants.ts b/packages/0x.js/src/utils/constants.ts index 06beec8e2..07da6745d 100644 --- a/packages/0x.js/src/utils/constants.ts +++ b/packages/0x.js/src/utils/constants.ts @@ -3,7 +3,6 @@ import { BigNumber } from '@0xproject/utils'; export const constants = { NULL_ADDRESS: '0x0000000000000000000000000000000000000000', TESTRPC_NETWORK_ID: 50, - MAX_DIGITS_IN_UNSIGNED_256_INT: 78, INVALID_JUMP_PATTERN: 'invalid JUMP at', OUT_OF_GAS_PATTERN: 'out of gas', INVALID_TAKER_FORMAT: 'instance.taker is not of a type(s) string', diff --git a/packages/0x.js/src/utils/order_validation_utils.ts b/packages/0x.js/src/utils/order_validation_utils.ts index b320a3e92..a13c3dc04 100644 --- a/packages/0x.js/src/utils/order_validation_utils.ts +++ b/packages/0x.js/src/utils/order_validation_utils.ts @@ -1,3 +1,4 @@ +import { getOrderHashHex, OrderError } from '@0xproject/order-utils'; import { Order, SignedOrder } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; import * as _ from 'lodash'; @@ -113,7 +114,7 @@ export class OrderValidationUtils { zrxTokenAddress: string, expectedFillTakerTokenAmount?: BigNumber, ): Promise { - const orderHash = utils.getOrderHashHex(signedOrder); + const orderHash = getOrderHashHex(signedOrder); const unavailableTakerTokenAmount = await this._exchangeWrapper.getUnavailableTakerAmountAsync(orderHash); OrderValidationUtils._validateRemainingFillAmountNotZeroOrThrow( signedOrder.takerTokenAmount, @@ -142,9 +143,9 @@ export class OrderValidationUtils { if (fillTakerTokenAmount.eq(0)) { throw new Error(ExchangeContractErrs.OrderFillAmountZero); } - const orderHash = utils.getOrderHashHex(signedOrder); + const orderHash = getOrderHashHex(signedOrder); if (!ZeroEx.isValidSignature(orderHash, signedOrder.ecSignature, signedOrder.maker)) { - throw new Error(ZeroExError.InvalidSignature); + throw new Error(OrderError.InvalidSignature); } const unavailableTakerTokenAmount = await this._exchangeWrapper.getUnavailableTakerAmountAsync(orderHash); OrderValidationUtils._validateRemainingFillAmountNotZeroOrThrow( diff --git a/packages/0x.js/src/utils/signature_utils.ts b/packages/0x.js/src/utils/signature_utils.ts deleted file mode 100644 index 46f167339..000000000 --- a/packages/0x.js/src/utils/signature_utils.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { ECSignature } from '@0xproject/types'; -import * as ethUtil from 'ethereumjs-util'; - -export const signatureUtils = { - isValidSignature(data: string, signature: ECSignature, signerAddress: string): boolean { - const dataBuff = ethUtil.toBuffer(data); - const msgHashBuff = ethUtil.hashPersonalMessage(dataBuff); - try { - const pubKey = ethUtil.ecrecover( - msgHashBuff, - signature.v, - ethUtil.toBuffer(signature.r), - ethUtil.toBuffer(signature.s), - ); - const retrievedAddress = ethUtil.bufferToHex(ethUtil.pubToAddress(pubKey)); - return retrievedAddress === signerAddress; - } catch (err) { - return false; - } - }, - parseSignatureHexAsVRS(signatureHex: string): ECSignature { - const signatureBuffer = ethUtil.toBuffer(signatureHex); - let v = signatureBuffer[0]; - if (v < 27) { - v += 27; - } - const r = signatureBuffer.slice(1, 33); - const s = signatureBuffer.slice(33, 65); - const ecSignature: ECSignature = { - v, - r: ethUtil.bufferToHex(r), - s: ethUtil.bufferToHex(s), - }; - return ecSignature; - }, - parseSignatureHexAsRSV(signatureHex: string): ECSignature { - const { v, r, s } = ethUtil.fromRpcSig(signatureHex); - const ecSignature: ECSignature = { - v, - r: ethUtil.bufferToHex(r), - s: ethUtil.bufferToHex(s), - }; - return ecSignature; - }, -}; diff --git a/packages/0x.js/src/utils/utils.ts b/packages/0x.js/src/utils/utils.ts index c8bcd907e..af1125632 100644 --- a/packages/0x.js/src/utils/utils.ts +++ b/packages/0x.js/src/utils/utils.ts @@ -1,59 +1,9 @@ -import { Order, SignedOrder, SolidityTypes } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; -import BN = require('bn.js'); -import * as ethABI from 'ethereumjs-abi'; -import * as ethUtil from 'ethereumjs-util'; -import * as _ from 'lodash'; export const utils = { - /** - * Converts BigNumber instance to BN - * The only reason we convert to BN is to remain compatible with `ethABI. soliditySHA3` that - * expects values of Solidity type `uint` to be passed as type `BN`. - * We do not use BN anywhere else in the codebase. - */ - bigNumberToBN(value: BigNumber) { - return new BN(value.toString(), 10); - }, spawnSwitchErr(name: string, value: any): Error { return new Error(`Unexpected switch value: ${value} encountered for ${name}`); }, - getOrderHashHex(order: Order | SignedOrder): string { - const orderParts = [ - { value: order.exchangeContractAddress, type: SolidityTypes.Address }, - { value: order.maker, type: SolidityTypes.Address }, - { value: order.taker, type: SolidityTypes.Address }, - { value: order.makerTokenAddress, type: SolidityTypes.Address }, - { value: order.takerTokenAddress, type: SolidityTypes.Address }, - { value: order.feeRecipient, type: SolidityTypes.Address }, - { - value: utils.bigNumberToBN(order.makerTokenAmount), - type: SolidityTypes.Uint256, - }, - { - value: utils.bigNumberToBN(order.takerTokenAmount), - type: SolidityTypes.Uint256, - }, - { - value: utils.bigNumberToBN(order.makerFee), - type: SolidityTypes.Uint256, - }, - { - value: utils.bigNumberToBN(order.takerFee), - type: SolidityTypes.Uint256, - }, - { - value: utils.bigNumberToBN(order.expirationUnixTimestampSec), - type: SolidityTypes.Uint256, - }, - { value: utils.bigNumberToBN(order.salt), type: SolidityTypes.Uint256 }, - ]; - const types = _.map(orderParts, o => o.type); - const values = _.map(orderParts, o => o.value); - const hashBuff = ethABI.soliditySHA3(types, values); - const hashHex = ethUtil.bufferToHex(hashBuff); - return hashHex; - }, getCurrentUnixTimestampSec(): BigNumber { return new BigNumber(Date.now() / 1000).round(); }, diff --git a/packages/0x.js/test/0x.js_test.ts b/packages/0x.js/test/0x.js_test.ts index 838ee7080..6dccdaea7 100644 --- a/packages/0x.js/test/0x.js_test.ts +++ b/packages/0x.js/test/0x.js_test.ts @@ -17,8 +17,6 @@ const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper); chaiSetup.configure(); const expect = chai.expect; -const SHOULD_ADD_PERSONAL_MESSAGE_PREFIX = false; - describe('ZeroEx library', () => { let zeroEx: ZeroEx; before(async () => { @@ -63,14 +61,12 @@ describe('ZeroEx library', () => { }; const address = '0x5409ed021d9299bf6814279a6a1411a7e866a631'; it("should return false if the data doesn't pertain to the signature & address", async () => { - expect(ZeroEx.isValidSignature('0x0', signature, address)).to.be.false(); return expect( (zeroEx.exchange as any)._isValidSignatureUsingContractCallAsync('0x0', signature, address), ).to.become(false); }); it("should return false if the address doesn't pertain to the signature & data", async () => { const validUnrelatedAddress = '0x8b0292b11a196601ed2ce54b665cafeca0347d42'; - expect(ZeroEx.isValidSignature(dataHex, signature, validUnrelatedAddress)).to.be.false(); return expect( (zeroEx.exchange as any)._isValidSignatureUsingContractCallAsync( dataHex, @@ -81,45 +77,16 @@ describe('ZeroEx library', () => { }); it("should return false if the signature doesn't pertain to the dataHex & address", async () => { const wrongSignature = _.assign({}, signature, { v: 28 }); - expect(ZeroEx.isValidSignature(dataHex, wrongSignature, address)).to.be.false(); return expect( (zeroEx.exchange as any)._isValidSignatureUsingContractCallAsync(dataHex, wrongSignature, address), ).to.become(false); }); it('should return true if the signature does pertain to the dataHex & address', async () => { - const isValidSignatureLocal = ZeroEx.isValidSignature(dataHex, signature, address); - expect(isValidSignatureLocal).to.be.true(); return expect( (zeroEx.exchange as any)._isValidSignatureUsingContractCallAsync(dataHex, signature, address), ).to.become(true); }); }); - describe('#generateSalt', () => { - it('generates different salts', () => { - const equal = ZeroEx.generatePseudoRandomSalt().eq(ZeroEx.generatePseudoRandomSalt()); - expect(equal).to.be.false(); - }); - it('generates salt in range [0..2^256)', () => { - const salt = ZeroEx.generatePseudoRandomSalt(); - expect(salt.greaterThanOrEqualTo(0)).to.be.true(); - const twoPow256 = new BigNumber(2).pow(256); - expect(salt.lessThan(twoPow256)).to.be.true(); - }); - }); - describe('#isValidOrderHash', () => { - it('returns false if the value is not a hex string', () => { - const isValid = ZeroEx.isValidOrderHash('not a hex'); - expect(isValid).to.be.false(); - }); - it('returns false if the length is wrong', () => { - const isValid = ZeroEx.isValidOrderHash('0xdeadbeef'); - expect(isValid).to.be.false(); - }); - it('returns true if order hash is correct', () => { - const isValid = ZeroEx.isValidOrderHash('0x' + Array(65).join('0')); - expect(isValid).to.be.true(); - }); - }); describe('#toUnitAmount', () => { it('should throw if invalid baseUnit amount supplied as argument', () => { const invalidBaseUnitAmount = new BigNumber(1000000000.4); @@ -152,106 +119,6 @@ describe('ZeroEx library', () => { ); }); }); - describe('#getOrderHashHex', () => { - const expectedOrderHash = '0x39da987067a3c9e5f1617694f1301326ba8c8b0498ebef5df4863bed394e3c83'; - const fakeExchangeContractAddress = '0xb69e673309512a9d726f87304c6984054f87a93b'; - const order: Order = { - maker: constants.NULL_ADDRESS, - taker: constants.NULL_ADDRESS, - feeRecipient: constants.NULL_ADDRESS, - makerTokenAddress: constants.NULL_ADDRESS, - takerTokenAddress: constants.NULL_ADDRESS, - exchangeContractAddress: fakeExchangeContractAddress, - salt: new BigNumber(0), - makerFee: new BigNumber(0), - takerFee: new BigNumber(0), - makerTokenAmount: new BigNumber(0), - takerTokenAmount: new BigNumber(0), - expirationUnixTimestampSec: new BigNumber(0), - }; - it('calculates the order hash', async () => { - const orderHash = ZeroEx.getOrderHashHex(order); - expect(orderHash).to.be.equal(expectedOrderHash); - }); - it('throws a readable error message if taker format is invalid', async () => { - const orderWithInvalidtakerFormat = { - ...order, - taker: (null as any) as string, - }; - const expectedErrorMessage = - 'Order taker must be of type string. If you want anyone to be able to fill an order - pass ZeroEx.NULL_ADDRESS'; - expect(() => ZeroEx.getOrderHashHex(orderWithInvalidtakerFormat)).to.throw(expectedErrorMessage); - }); - }); - describe('#signOrderHashAsync', () => { - let stubs: Sinon.SinonStub[] = []; - let makerAddress: string; - before(async () => { - const availableAddreses = await zeroEx.getAvailableAddressesAsync(); - makerAddress = availableAddreses[0]; - }); - afterEach(() => { - // clean up any stubs after the test has completed - _.each(stubs, s => s.restore()); - stubs = []; - }); - it('Should return the correct ECSignature', async () => { - const orderHash = '0x6927e990021d23b1eb7b8789f6a6feaf98fe104bb0cf8259421b79f9a34222b0'; - const expectedECSignature = { - v: 27, - r: '0x61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33', - s: '0x40349190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254', - }; - const ecSignature = await zeroEx.signOrderHashAsync( - orderHash, - makerAddress, - SHOULD_ADD_PERSONAL_MESSAGE_PREFIX, - ); - expect(ecSignature).to.deep.equal(expectedECSignature); - }); - it('should return the correct ECSignature for signatureHex concatenated as R + S + V', async () => { - const orderHash = '0x34decbedc118904df65f379a175bb39ca18209d6ce41d5ed549d54e6e0a95004'; - const signature = - '0x22109d11d79cb8bf96ed88625e1cd9558800c4073332a9a02857499883ee5ce3050aa3cc1f2c435e67e114cdce54b9527b4f50548342401bc5d2b77adbdacb021b'; - const expectedECSignature = { - v: 27, - r: '0x22109d11d79cb8bf96ed88625e1cd9558800c4073332a9a02857499883ee5ce3', - s: '0x050aa3cc1f2c435e67e114cdce54b9527b4f50548342401bc5d2b77adbdacb02', - }; - stubs = [ - Sinon.stub((zeroEx as any)._web3Wrapper, 'signMessageAsync').returns(Promise.resolve(signature)), - Sinon.stub(ZeroEx, 'isValidSignature').returns(true), - ]; - - const ecSignature = await zeroEx.signOrderHashAsync( - orderHash, - makerAddress, - SHOULD_ADD_PERSONAL_MESSAGE_PREFIX, - ); - expect(ecSignature).to.deep.equal(expectedECSignature); - }); - it('should return the correct ECSignature for signatureHex concatenated as V + R + S', async () => { - const orderHash = '0xc793e33ffded933b76f2f48d9aa3339fc090399d5e7f5dec8d3660f5480793f7'; - const signature = - '0x1bc80bedc6756722672753413efdd749b5adbd4fd552595f59c13427407ee9aee02dea66f25a608bbae457e020fb6decb763deb8b7192abab624997242da248960'; - const expectedECSignature = { - v: 27, - r: '0xc80bedc6756722672753413efdd749b5adbd4fd552595f59c13427407ee9aee0', - s: '0x2dea66f25a608bbae457e020fb6decb763deb8b7192abab624997242da248960', - }; - stubs = [ - Sinon.stub((zeroEx as any)._web3Wrapper, 'signMessageAsync').returns(Promise.resolve(signature)), - Sinon.stub(ZeroEx, 'isValidSignature').returns(true), - ]; - - const ecSignature = await zeroEx.signOrderHashAsync( - orderHash, - makerAddress, - SHOULD_ADD_PERSONAL_MESSAGE_PREFIX, - ); - expect(ecSignature).to.deep.equal(expectedECSignature); - }); - }); describe('#awaitTransactionMinedAsync', () => { beforeEach(async () => { await blockchainLifecycle.startAsync(); diff --git a/packages/0x.js/test/assert_test.ts b/packages/0x.js/test/assert_test.ts index b08f3e23b..e69de29bb 100644 --- a/packages/0x.js/test/assert_test.ts +++ b/packages/0x.js/test/assert_test.ts @@ -1,43 +0,0 @@ -import { web3Factory } from '@0xproject/dev-utils'; -import * as chai from 'chai'; -import 'mocha'; - -import { ZeroEx } from '../src'; -import { assert } from '../src/utils/assert'; - -import { constants } from './utils/constants'; -import { provider } from './utils/web3_wrapper'; - -const expect = chai.expect; - -describe('Assertion library', () => { - const config = { - networkId: constants.TESTRPC_NETWORK_ID, - }; - const zeroEx = new ZeroEx(provider, config); - describe('#isSenderAddressHexAsync', () => { - it('throws when address is invalid', async () => { - const address = '0xdeadbeef'; - const varName = 'address'; - return expect( - assert.isSenderAddressAsync(varName, address, (zeroEx as any)._web3Wrapper), - ).to.be.rejectedWith(`Expected ${varName} to be of type ETHAddressHex, encountered: ${address}`); - }); - it('throws when address is unavailable', async () => { - const validUnrelatedAddress = '0x8b0292b11a196601eddce54b665cafeca0347d42'; - const varName = 'address'; - return expect( - assert.isSenderAddressAsync(varName, validUnrelatedAddress, (zeroEx as any)._web3Wrapper), - ).to.be.rejectedWith( - `Specified ${varName} ${validUnrelatedAddress} isn't available through the supplied web3 provider`, - ); - }); - it("doesn't throw if address is available", async () => { - const availableAddress = (await zeroEx.getAvailableAddressesAsync())[0]; - const varName = 'address'; - return expect( - assert.isSenderAddressAsync(varName, availableAddress, (zeroEx as any)._web3Wrapper), - ).to.become(undefined); - }); - }); -}); diff --git a/packages/0x.js/test/order_validation_test.ts b/packages/0x.js/test/order_validation_test.ts index 9b843b930..0cb95c1b6 100644 --- a/packages/0x.js/test/order_validation_test.ts +++ b/packages/0x.js/test/order_validation_test.ts @@ -1,4 +1,5 @@ import { BlockchainLifecycle, devConstants } from '@0xproject/dev-utils'; +import { OrderError } from '@0xproject/order-utils'; import { BlockParamLiteral } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; import * as chai from 'chai'; @@ -169,7 +170,7 @@ describe('OrderValidation', () => { signedOrder.ecSignature.v = 28 - signedOrder.ecSignature.v + 27; return expect( zeroEx.exchange.validateFillOrderThrowIfInvalidAsync(signedOrder, fillableAmount, takerAddress), - ).to.be.rejectedWith(ZeroExError.InvalidSignature); + ).to.be.rejectedWith(OrderError.InvalidSignature); }); it('should throw when the order is fully filled or cancelled', async () => { const signedOrder = await fillScenarios.createFillableSignedOrderAsync( diff --git a/packages/0x.js/test/utils/fill_scenarios.ts b/packages/0x.js/test/utils/fill_scenarios.ts index 7d0e8c501..5a82a56d2 100644 --- a/packages/0x.js/test/utils/fill_scenarios.ts +++ b/packages/0x.js/test/utils/fill_scenarios.ts @@ -1,10 +1,10 @@ +import { orderFactory } from '@0xproject/order-utils'; import { BigNumber } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; import { SignedOrder, Token, ZeroEx } from '../../src'; import { artifacts } from '../../src/artifacts'; import { DummyTokenContract } from '../../src/contract_wrappers/generated/dummy_token'; -import { orderFactory } from '../utils/order_factory'; import { constants } from './constants'; @@ -164,7 +164,7 @@ export class FillScenarios { ]); const signedOrder = await orderFactory.createSignedOrderAsync( - this._zeroEx, + this._zeroEx.getProvider(), makerAddress, takerAddress, makerFee, diff --git a/packages/0x.js/test/utils/order_factory.ts b/packages/0x.js/test/utils/order_factory.ts deleted file mode 100644 index 08f2081a4..000000000 --- a/packages/0x.js/test/utils/order_factory.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { BigNumber } from '@0xproject/utils'; -import * as _ from 'lodash'; - -import { SignedOrder, ZeroEx } from '../../src'; - -const SHOULD_ADD_PERSONAL_MESSAGE_PREFIX = false; - -export const orderFactory = { - async createSignedOrderAsync( - zeroEx: ZeroEx, - maker: string, - taker: string, - makerFee: BigNumber, - takerFee: BigNumber, - makerTokenAmount: BigNumber, - makerTokenAddress: string, - takerTokenAmount: BigNumber, - takerTokenAddress: string, - exchangeContractAddress: string, - feeRecipient: string, - expirationUnixTimestampSecIfExists?: BigNumber, - ): Promise { - const defaultExpirationUnixTimestampSec = new BigNumber(2524604400); // Close to infinite - const expirationUnixTimestampSec = _.isUndefined(expirationUnixTimestampSecIfExists) - ? defaultExpirationUnixTimestampSec - : expirationUnixTimestampSecIfExists; - const order = { - maker, - taker, - makerFee, - takerFee, - makerTokenAmount, - takerTokenAmount, - makerTokenAddress, - takerTokenAddress, - salt: ZeroEx.generatePseudoRandomSalt(), - exchangeContractAddress, - feeRecipient, - expirationUnixTimestampSec, - }; - const orderHash = ZeroEx.getOrderHashHex(order); - const ecSignature = await zeroEx.signOrderHashAsync(orderHash, maker, SHOULD_ADD_PERSONAL_MESSAGE_PREFIX); - const signedOrder: SignedOrder = _.assign(order, { ecSignature }); - return signedOrder; - }, -}; diff --git a/packages/0x.js/test/utils/web3_wrapper.ts b/packages/0x.js/test/utils/web3_wrapper.ts index b7b3f0b7f..b0ccfa546 100644 --- a/packages/0x.js/test/utils/web3_wrapper.ts +++ b/packages/0x.js/test/utils/web3_wrapper.ts @@ -1,9 +1,6 @@ import { devConstants, web3Factory } from '@0xproject/dev-utils'; import { Provider } from '@0xproject/types'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; -import * as Web3 from 'web3'; - -import { constants } from './constants'; const web3 = web3Factory.create({ shouldUseInProcessGanache: true }); const provider: Provider = web3.currentProvider; -- cgit v1.2.3 From adaff92c9243e7e13737f92cf4b6ade77ebd6e43 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Wed, 2 May 2018 15:25:30 +0300 Subject: Create wrapper functions so that docs render properly --- packages/0x.js/src/0x.ts | 66 +++++++++++++++++++++++++++--------------------- 1 file changed, 37 insertions(+), 29 deletions(-) (limited to 'packages/0x.js') diff --git a/packages/0x.js/src/0x.ts b/packages/0x.js/src/0x.ts index 780d1b52a..bf776cd95 100644 --- a/packages/0x.js/src/0x.ts +++ b/packages/0x.js/src/0x.ts @@ -39,13 +39,39 @@ export class ZeroEx { * this constant for your convenience. */ public static NULL_ADDRESS = constants.NULL_ADDRESS; + /** + * An instance of the ExchangeWrapper class containing methods for interacting with the 0x Exchange smart contract. + */ + public exchange: ExchangeWrapper; + /** + * An instance of the TokenRegistryWrapper class containing methods for interacting with the 0x + * TokenRegistry smart contract. + */ + public tokenRegistry: TokenRegistryWrapper; + /** + * An instance of the TokenWrapper class containing methods for interacting with any ERC20 token smart contract. + */ + public token: TokenWrapper; + /** + * An instance of the EtherTokenWrapper class containing methods for interacting with the + * wrapped ETH ERC20 token smart contract. + */ + public etherToken: EtherTokenWrapper; + /** + * An instance of the TokenTransferProxyWrapper class containing methods for interacting with the + * tokenTransferProxy smart contract. + */ + public proxy: TokenTransferProxyWrapper; + private _web3Wrapper: Web3Wrapper; /** * Generates a pseudo-random 256-bit salt. * The salt can be included in a 0x order, ensuring that the order generates a unique orderHash * and will not collide with other outstanding orders that are identical in all other parameters. * @return A pseudo-random 256-bit number that can be used as a salt. */ - public static generatePseudoRandomSalt = generatePseudoRandomSalt; + public static generatePseudoRandomSalt(): BigNumber { + return generatePseudoRandomSalt(); + } /** * Verifies that the elliptic curve signature `signature` was generated * by signing `data` with the private key corresponding to the `signerAddress` address. @@ -54,13 +80,17 @@ export class ZeroEx { * @param signerAddress The hex encoded address that signed the data, producing the supplied signature. * @return Whether the signature is valid for the supplied signerAddress and data. */ - public static isValidSignature = isValidSignature; + public static isValidSignature(data: string, signature: ECSignature, signerAddress: string): boolean { + return isValidSignature(data, signature, signerAddress); + } /** * Computes the orderHash for a supplied order. * @param order An object that conforms to the Order or SignedOrder interface definitions. * @return The resulting orderHash from hashing the supplied order. */ - public static getOrderHashHex = getOrderHashHex; + public static getOrderHashHex(order: Order | SignedOrder): string { + return getOrderHashHex(order); + } /** * Checks if the supplied hex encoded order hash is valid. * Note: Valid means it has the expected format, not that an order with the orderHash exists. @@ -68,32 +98,9 @@ export class ZeroEx { * @param orderHash Hex encoded orderHash. * @return Whether the supplied orderHash has the expected format. */ - public static isValidOrderHash = isValidOrderHash; - - /** - * An instance of the ExchangeWrapper class containing methods for interacting with the 0x Exchange smart contract. - */ - public exchange: ExchangeWrapper; - /** - * An instance of the TokenRegistryWrapper class containing methods for interacting with the 0x - * TokenRegistry smart contract. - */ - public tokenRegistry: TokenRegistryWrapper; - /** - * An instance of the TokenWrapper class containing methods for interacting with any ERC20 token smart contract. - */ - public token: TokenWrapper; - /** - * An instance of the EtherTokenWrapper class containing methods for interacting with the - * wrapped ETH ERC20 token smart contract. - */ - public etherToken: EtherTokenWrapper; - /** - * An instance of the TokenTransferProxyWrapper class containing methods for interacting with the - * tokenTransferProxy smart contract. - */ - public proxy: TokenTransferProxyWrapper; - private _web3Wrapper: Web3Wrapper; + public static isValidOrderHash(orderHash: string): boolean { + return isValidOrderHash(orderHash); + } /** * A unit amount is defined as the amount of a token above the specified decimal places (integer part). * E.g: If a currency has 18 decimal places, 1e18 or one quintillion of the currency is equivalent @@ -185,6 +192,7 @@ export class ZeroEx { } /** * Get the provider instance currently used by 0x.js + * @return Web3 provider instance */ public getProvider(): Provider { return this._web3Wrapper.getProvider(); -- cgit v1.2.3 From a6046af0240d9257a9e9dd80dc4dc5f533df8799 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Wed, 2 May 2018 18:38:38 +0300 Subject: Stop exporting assertions from order-utils --- packages/0x.js/src/0x.ts | 2 +- .../src/contract_wrappers/ether_token_wrapper.ts | 2 +- .../src/contract_wrappers/exchange_wrapper.ts | 3 ++- .../contract_wrappers/token_registry_wrapper.ts | 2 +- .../token_transfer_proxy_wrapper.ts | 2 +- .../0x.js/src/contract_wrappers/token_wrapper.ts | 2 +- packages/0x.js/src/order_watcher/event_watcher.ts | 2 +- .../0x.js/src/order_watcher/order_state_watcher.ts | 2 +- packages/0x.js/src/utils/assert.ts | 31 ++++++++++++++++++++++ 9 files changed, 40 insertions(+), 8 deletions(-) create mode 100644 packages/0x.js/src/utils/assert.ts (limited to 'packages/0x.js') diff --git a/packages/0x.js/src/0x.ts b/packages/0x.js/src/0x.ts index bf776cd95..78f9f6beb 100644 --- a/packages/0x.js/src/0x.ts +++ b/packages/0x.js/src/0x.ts @@ -1,6 +1,5 @@ import { schemas, SchemaValidator } from '@0xproject/json-schemas'; import { - assert, generatePseudoRandomSalt, getOrderHashHex, isValidOrderHash, @@ -24,6 +23,7 @@ import { zeroExConfigSchema } from './schemas/zero_ex_config_schema'; import { zeroExPrivateNetworkConfigSchema } from './schemas/zero_ex_private_network_config_schema'; import { zeroExPublicNetworkConfigSchema } from './schemas/zero_ex_public_network_config_schema'; import { OrderStateWatcherConfig, ZeroExConfig, ZeroExError } from './types'; +import { assert } from './utils/assert'; import { constants } from './utils/constants'; import { decorators } from './utils/decorators'; import { utils } from './utils/utils'; diff --git a/packages/0x.js/src/contract_wrappers/ether_token_wrapper.ts b/packages/0x.js/src/contract_wrappers/ether_token_wrapper.ts index 8a8caa4dc..fd39de34b 100644 --- a/packages/0x.js/src/contract_wrappers/ether_token_wrapper.ts +++ b/packages/0x.js/src/contract_wrappers/ether_token_wrapper.ts @@ -1,5 +1,4 @@ import { schemas } from '@0xproject/json-schemas'; -import { assert } from '@0xproject/order-utils'; import { LogWithDecodedArgs } from '@0xproject/types'; import { AbiDecoder, BigNumber } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; @@ -7,6 +6,7 @@ import * as _ from 'lodash'; import { artifacts } from '../artifacts'; import { BlockRange, EventCallback, IndexedFilterValues, TransactionOpts, ZeroExError } from '../types'; +import { assert } from '../utils/assert'; import { ContractWrapper } from './contract_wrapper'; import { EtherTokenContract, EtherTokenContractEventArgs, EtherTokenEvents } from './generated/ether_token'; diff --git a/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts b/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts index 5dca61ab3..6ddaaaf4f 100644 --- a/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts +++ b/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts @@ -1,5 +1,5 @@ import { schemas } from '@0xproject/json-schemas'; -import { assert, getOrderHashHex } from '@0xproject/order-utils'; +import { getOrderHashHex } from '@0xproject/order-utils'; import { BlockParamLiteral, DecodedLogArgs, @@ -31,6 +31,7 @@ import { OrderValues, ValidateOrderFillableOpts, } from '../types'; +import { assert } from '../utils/assert'; import { decorators } from '../utils/decorators'; import { ExchangeTransferSimulator } from '../utils/exchange_transfer_simulator'; import { OrderStateUtils } from '../utils/order_state_utils'; diff --git a/packages/0x.js/src/contract_wrappers/token_registry_wrapper.ts b/packages/0x.js/src/contract_wrappers/token_registry_wrapper.ts index a1ec91757..c4a193264 100644 --- a/packages/0x.js/src/contract_wrappers/token_registry_wrapper.ts +++ b/packages/0x.js/src/contract_wrappers/token_registry_wrapper.ts @@ -1,9 +1,9 @@ -import { assert } from '@0xproject/order-utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; import * as _ from 'lodash'; import { artifacts } from '../artifacts'; import { Token, TokenMetadata } from '../types'; +import { assert } from '../utils/assert'; import { constants } from '../utils/constants'; import { ContractWrapper } from './contract_wrapper'; diff --git a/packages/0x.js/src/contract_wrappers/token_transfer_proxy_wrapper.ts b/packages/0x.js/src/contract_wrappers/token_transfer_proxy_wrapper.ts index 495923ecc..be558b5be 100644 --- a/packages/0x.js/src/contract_wrappers/token_transfer_proxy_wrapper.ts +++ b/packages/0x.js/src/contract_wrappers/token_transfer_proxy_wrapper.ts @@ -1,8 +1,8 @@ -import { assert } from '@0xproject/order-utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; import * as _ from 'lodash'; import { artifacts } from '../artifacts'; +import { assert } from '../utils/assert'; import { ContractWrapper } from './contract_wrapper'; import { TokenTransferProxyContract } from './generated/token_transfer_proxy'; diff --git a/packages/0x.js/src/contract_wrappers/token_wrapper.ts b/packages/0x.js/src/contract_wrappers/token_wrapper.ts index 6751f46b3..194cfb5aa 100644 --- a/packages/0x.js/src/contract_wrappers/token_wrapper.ts +++ b/packages/0x.js/src/contract_wrappers/token_wrapper.ts @@ -1,5 +1,4 @@ import { schemas } from '@0xproject/json-schemas'; -import { assert } from '@0xproject/order-utils'; import { LogWithDecodedArgs } from '@0xproject/types'; import { AbiDecoder, BigNumber } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; @@ -7,6 +6,7 @@ import * as _ from 'lodash'; import { artifacts } from '../artifacts'; import { BlockRange, EventCallback, IndexedFilterValues, MethodOpts, TransactionOpts, ZeroExError } from '../types'; +import { assert } from '../utils/assert'; import { constants } from '../utils/constants'; import { ContractWrapper } from './contract_wrapper'; diff --git a/packages/0x.js/src/order_watcher/event_watcher.ts b/packages/0x.js/src/order_watcher/event_watcher.ts index 545b352a4..de5a99a46 100644 --- a/packages/0x.js/src/order_watcher/event_watcher.ts +++ b/packages/0x.js/src/order_watcher/event_watcher.ts @@ -1,10 +1,10 @@ -import { assert } from '@0xproject/order-utils'; import { BlockParamLiteral, LogEntry } from '@0xproject/types'; import { intervalUtils } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; import * as _ from 'lodash'; import { EventWatcherCallback, ZeroExError } from '../types'; +import { assert } from '../utils/assert'; const DEFAULT_EVENT_POLLING_INTERVAL_MS = 200; diff --git a/packages/0x.js/src/order_watcher/order_state_watcher.ts b/packages/0x.js/src/order_watcher/order_state_watcher.ts index 008db6bc4..a9df8ac9d 100644 --- a/packages/0x.js/src/order_watcher/order_state_watcher.ts +++ b/packages/0x.js/src/order_watcher/order_state_watcher.ts @@ -1,5 +1,4 @@ import { schemas } from '@0xproject/json-schemas'; -import { assert } from '@0xproject/order-utils'; import { BlockParamLiteral, LogWithDecodedArgs, SignedOrder } from '@0xproject/types'; import { AbiDecoder, intervalUtils } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; @@ -34,6 +33,7 @@ import { OrderStateWatcherConfig, ZeroExError, } from '../types'; +import { assert } from '../utils/assert'; import { OrderStateUtils } from '../utils/order_state_utils'; import { utils } from '../utils/utils'; diff --git a/packages/0x.js/src/utils/assert.ts b/packages/0x.js/src/utils/assert.ts new file mode 100644 index 000000000..2588a4d09 --- /dev/null +++ b/packages/0x.js/src/utils/assert.ts @@ -0,0 +1,31 @@ +import { assert as sharedAssert } from '@0xproject/assert'; +// We need those two unused imports because they're actually used by sharedAssert which gets injected here +// tslint:disable-next-line:no-unused-variable +import { Schema } from '@0xproject/json-schemas'; +// tslint:disable-next-line:no-unused-variable +import { ECSignature } from '@0xproject/types'; +import { BigNumber } from '@0xproject/utils'; +import { Web3Wrapper } from '@0xproject/web3-wrapper'; +import * as _ from 'lodash'; + +import { isValidSignature } from '@0xproject/order-utils'; + +export const assert = { + ...sharedAssert, + isValidSignature(orderHash: string, ecSignature: ECSignature, signerAddress: string) { + const isValid = isValidSignature(orderHash, ecSignature, signerAddress); + this.assert(isValid, `Expected order with hash '${orderHash}' to have a valid signature`); + }, + async isSenderAddressAsync( + variableName: string, + senderAddressHex: string, + web3Wrapper: Web3Wrapper, + ): Promise { + sharedAssert.isETHAddressHex(variableName, senderAddressHex); + const isSenderAddressAvailable = await web3Wrapper.isSenderAddressAvailableAsync(senderAddressHex); + sharedAssert.assert( + isSenderAddressAvailable, + `Specified ${variableName} ${senderAddressHex} isn't available through the supplied web3 provider`, + ); + }, +}; -- cgit v1.2.3 From 01dd84dced8d885f6b164cab714ecfde4d0a363e Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Fri, 4 May 2018 11:57:34 +0200 Subject: Add order utils docs to the menu --- packages/0x.js/CHANGELOG.json | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'packages/0x.js') diff --git a/packages/0x.js/CHANGELOG.json b/packages/0x.js/CHANGELOG.json index c2545b7da..181310f0c 100644 --- a/packages/0x.js/CHANGELOG.json +++ b/packages/0x.js/CHANGELOG.json @@ -1,17 +1,4 @@ [ - { - "version": "0.38.0", - "changes": [ - { - "note": "Add `zeroEx.getProvider()`", - "pr": 559 - }, - { - "note": "Move `ZeroExError.InvalidSignature` to `@0xproject/order-utils` `OrderError.InvalidSignature`", - "pr": 559 - } - ] - }, { "version": "0.37.0", "changes": [ @@ -22,6 +9,14 @@ { "note": "Update Web3 Provider Engine to 14.0.4", "pr": 555 + }, + { + "note": "Add `zeroEx.getProvider()`", + "pr": 559 + }, + { + "note": "Move `ZeroExError.InvalidSignature` to `@0xproject/order-utils` `OrderError.InvalidSignature`", + "pr": 559 } ] }, -- cgit v1.2.3 From 3fc99dbad5f7f727f7474473c261a7b512045e63 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Fri, 4 May 2018 12:16:11 +0200 Subject: Updated CHANGELOGS --- packages/0x.js/CHANGELOG.json | 3 ++- packages/0x.js/CHANGELOG.md | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'packages/0x.js') diff --git a/packages/0x.js/CHANGELOG.json b/packages/0x.js/CHANGELOG.json index 181310f0c..60c28ed4b 100644 --- a/packages/0x.js/CHANGELOG.json +++ b/packages/0x.js/CHANGELOG.json @@ -18,7 +18,8 @@ "note": "Move `ZeroExError.InvalidSignature` to `@0xproject/order-utils` `OrderError.InvalidSignature`", "pr": 559 } - ] + ], + "timestamp": 1525428773 }, { "version": "0.36.3", diff --git a/packages/0x.js/CHANGELOG.md b/packages/0x.js/CHANGELOG.md index f800b86db..196f8a72c 100644 --- a/packages/0x.js/CHANGELOG.md +++ b/packages/0x.js/CHANGELOG.md @@ -5,6 +5,13 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v0.37.0 - _May 4, 2018_ + + * Fixed expiration watcher comparator to handle orders with equal expiration times (#526) + * Update Web3 Provider Engine to 14.0.4 (#555) + * Add `zeroEx.getProvider()` (#559) + * Move `ZeroExError.InvalidSignature` to `@0xproject/order-utils` `OrderError.InvalidSignature` (#559) + ## v0.36.3 - _April 18, 2018_ * Move @0xproject/migrations to devDependencies -- cgit v1.2.3 From 8dd91248639d167d198df949d7749a93d6af5bf3 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Fri, 4 May 2018 12:16:17 +0200 Subject: Publish - 0x.js@0.37.0 - @0xproject/abi-gen@0.2.12 - @0xproject/assert@0.2.8 - @0xproject/base-contract@0.3.0 - @0xproject/connect@0.6.11 - contracts@2.1.26 - @0xproject/deployer@0.4.2 - @0xproject/dev-utils@0.4.0 - @0xproject/json-schemas@0.7.22 - @0xproject/metacoin@0.0.5 - @0xproject/migrations@0.0.4 - @0xproject/monorepo-scripts@0.1.19 - @0xproject/order-utils@0.0.2 - @0xproject/react-docs-example@0.0.9 - @0xproject/react-docs@0.0.9 - @0xproject/react-shared@0.1.4 - @0xproject/sol-cov@0.0.9 - @0xproject/sol-resolver@0.0.3 - @0xproject/sra-report@0.0.12 - @0xproject/subproviders@0.10.0 - @0xproject/testnet-faucets@1.0.27 - @0xproject/tslint-config@0.4.17 - @0xproject/types@0.6.2 - @0xproject/typescript-typings@0.3.0 - @0xproject/utils@0.6.0 - @0xproject/web3-wrapper@0.6.2 - @0xproject/website@0.0.29 --- packages/0x.js/package.json | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'packages/0x.js') diff --git a/packages/0x.js/package.json b/packages/0x.js/package.json index 33c29a788..f0d8818ed 100644 --- a/packages/0x.js/package.json +++ b/packages/0x.js/package.json @@ -1,6 +1,6 @@ { "name": "0x.js", - "version": "0.36.3", + "version": "0.37.0", "description": "A javascript library for interacting with the 0x protocol", "keywords": [ "0x.js", @@ -61,12 +61,12 @@ "node": ">=6.0.0" }, "devDependencies": { - "@0xproject/deployer": "^0.4.1", - "@0xproject/dev-utils": "^0.3.6", - "@0xproject/migrations": "^0.0.3", - "@0xproject/monorepo-scripts": "^0.1.18", - "@0xproject/subproviders": "^0.9.0", - "@0xproject/tslint-config": "^0.4.16", + "@0xproject/deployer": "^0.4.2", + "@0xproject/dev-utils": "^0.4.0", + "@0xproject/migrations": "^0.0.4", + "@0xproject/monorepo-scripts": "^0.1.19", + "@0xproject/subproviders": "^0.10.0", + "@0xproject/tslint-config": "^0.4.17", "@types/bintrees": "^1.0.2", "@types/lodash": "4.14.104", "@types/mocha": "^2.2.42", @@ -97,14 +97,14 @@ "webpack": "^3.1.0" }, "dependencies": { - "@0xproject/assert": "^0.2.7", - "@0xproject/base-contract": "^0.2.1", - "@0xproject/json-schemas": "^0.7.21", - "@0xproject/types": "^0.6.1", - "@0xproject/typescript-typings": "^0.2.0", - "@0xproject/utils": "^0.5.2", - "@0xproject/order-utils": "^0.0.1", - "@0xproject/web3-wrapper": "^0.6.1", + "@0xproject/assert": "^0.2.8", + "@0xproject/base-contract": "^0.3.0", + "@0xproject/json-schemas": "^0.7.22", + "@0xproject/order-utils": "^0.0.2", + "@0xproject/types": "^0.6.2", + "@0xproject/typescript-typings": "^0.3.0", + "@0xproject/utils": "^0.6.0", + "@0xproject/web3-wrapper": "^0.6.2", "bintrees": "^1.0.2", "bn.js": "^4.11.8", "ethereumjs-abi": "^0.6.4", -- cgit v1.2.3 From ae68c3abe4a6e76d9f82e8225dab21356d539435 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Fri, 4 May 2018 20:44:12 +0200 Subject: Updated CHANGELOGS --- packages/0x.js/CHANGELOG.json | 9 +++++++++ packages/0x.js/CHANGELOG.md | 4 ++++ 2 files changed, 13 insertions(+) (limited to 'packages/0x.js') diff --git a/packages/0x.js/CHANGELOG.json b/packages/0x.js/CHANGELOG.json index 60c28ed4b..f48abef38 100644 --- a/packages/0x.js/CHANGELOG.json +++ b/packages/0x.js/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1525453812, + "version": "0.37.1", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "version": "0.37.0", "changes": [ diff --git a/packages/0x.js/CHANGELOG.md b/packages/0x.js/CHANGELOG.md index 196f8a72c..7ee7ad9e1 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.37.1 - _May 4, 2018_ + + * Dependencies updated + ## v0.37.0 - _May 4, 2018_ * Fixed expiration watcher comparator to handle orders with equal expiration times (#526) -- cgit v1.2.3 From b4cb21b55ec6dc3089cd6a152fe1b414284a7264 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Fri, 4 May 2018 20:44:18 +0200 Subject: Publish - 0x.js@0.37.1 - contracts@2.1.27 - @0xproject/order-utils@0.0.3 - @0xproject/sra-report@0.0.13 - @0xproject/testnet-faucets@1.0.28 - @0xproject/website@0.0.30 --- packages/0x.js/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'packages/0x.js') diff --git a/packages/0x.js/package.json b/packages/0x.js/package.json index f0d8818ed..15843647b 100644 --- a/packages/0x.js/package.json +++ b/packages/0x.js/package.json @@ -1,6 +1,6 @@ { "name": "0x.js", - "version": "0.37.0", + "version": "0.37.1", "description": "A javascript library for interacting with the 0x protocol", "keywords": [ "0x.js", @@ -100,7 +100,7 @@ "@0xproject/assert": "^0.2.8", "@0xproject/base-contract": "^0.3.0", "@0xproject/json-schemas": "^0.7.22", - "@0xproject/order-utils": "^0.0.2", + "@0xproject/order-utils": "^0.0.3", "@0xproject/types": "^0.6.2", "@0xproject/typescript-typings": "^0.3.0", "@0xproject/utils": "^0.6.0", -- cgit v1.2.3 From bf87b1a6af5bf6041c7051272568ff3d67ba3f9c Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Sat, 5 May 2018 01:55:04 +0200 Subject: Updated CHANGELOGS --- packages/0x.js/CHANGELOG.json | 9 +++++++++ packages/0x.js/CHANGELOG.md | 4 ++++ 2 files changed, 13 insertions(+) (limited to 'packages/0x.js') diff --git a/packages/0x.js/CHANGELOG.json b/packages/0x.js/CHANGELOG.json index f48abef38..bdc575903 100644 --- a/packages/0x.js/CHANGELOG.json +++ b/packages/0x.js/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1525477860, + "version": "0.37.2", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1525453812, "version": "0.37.1", diff --git a/packages/0x.js/CHANGELOG.md b/packages/0x.js/CHANGELOG.md index 7ee7ad9e1..353e0de29 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.37.2 - _May 5, 2018_ + + * Dependencies updated + ## v0.37.1 - _May 4, 2018_ * Dependencies updated -- cgit v1.2.3 From 69a6166b6a1d39afc24b8dd950ec5d8539a03420 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Sat, 5 May 2018 01:55:12 +0200 Subject: Publish - 0x.js@0.37.2 - @0xproject/abi-gen@0.2.13 - @0xproject/assert@0.2.9 - @0xproject/base-contract@0.3.1 - @0xproject/connect@0.6.12 - contracts@2.1.28 - @0xproject/deployer@0.4.3 - @0xproject/dev-utils@0.4.1 - @0xproject/json-schemas@0.7.23 - @0xproject/metacoin@0.0.6 - @0xproject/migrations@0.0.5 - @0xproject/order-utils@0.0.4 - @0xproject/react-docs-example@0.0.11 - @0xproject/react-docs@0.0.11 - @0xproject/react-shared@0.1.6 - @0xproject/sol-cov@0.0.10 - @0xproject/sol-resolver@0.0.4 - @0xproject/sra-report@0.0.14 - @0xproject/subproviders@0.10.1 - @0xproject/testnet-faucets@1.0.29 - @0xproject/types@0.6.3 - @0xproject/typescript-typings@0.3.1 - @0xproject/utils@0.6.1 - @0xproject/web3-wrapper@0.6.3 - @0xproject/website@0.0.32 --- packages/0x.js/package.json | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'packages/0x.js') diff --git a/packages/0x.js/package.json b/packages/0x.js/package.json index 15843647b..d3cf9ad5f 100644 --- a/packages/0x.js/package.json +++ b/packages/0x.js/package.json @@ -1,6 +1,6 @@ { "name": "0x.js", - "version": "0.37.1", + "version": "0.37.2", "description": "A javascript library for interacting with the 0x protocol", "keywords": [ "0x.js", @@ -61,11 +61,11 @@ "node": ">=6.0.0" }, "devDependencies": { - "@0xproject/deployer": "^0.4.2", - "@0xproject/dev-utils": "^0.4.0", - "@0xproject/migrations": "^0.0.4", + "@0xproject/deployer": "^0.4.3", + "@0xproject/dev-utils": "^0.4.1", + "@0xproject/migrations": "^0.0.5", "@0xproject/monorepo-scripts": "^0.1.19", - "@0xproject/subproviders": "^0.10.0", + "@0xproject/subproviders": "^0.10.1", "@0xproject/tslint-config": "^0.4.17", "@types/bintrees": "^1.0.2", "@types/lodash": "4.14.104", @@ -97,14 +97,14 @@ "webpack": "^3.1.0" }, "dependencies": { - "@0xproject/assert": "^0.2.8", - "@0xproject/base-contract": "^0.3.0", - "@0xproject/json-schemas": "^0.7.22", - "@0xproject/order-utils": "^0.0.3", - "@0xproject/types": "^0.6.2", - "@0xproject/typescript-typings": "^0.3.0", - "@0xproject/utils": "^0.6.0", - "@0xproject/web3-wrapper": "^0.6.2", + "@0xproject/assert": "^0.2.9", + "@0xproject/base-contract": "^0.3.1", + "@0xproject/json-schemas": "^0.7.23", + "@0xproject/order-utils": "^0.0.4", + "@0xproject/types": "^0.6.3", + "@0xproject/typescript-typings": "^0.3.1", + "@0xproject/utils": "^0.6.1", + "@0xproject/web3-wrapper": "^0.6.3", "bintrees": "^1.0.2", "bn.js": "^4.11.8", "ethereumjs-abi": "^0.6.4", -- cgit v1.2.3 From 27262c4e5690e79ac19976012c0b82e86644dbdc Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Mon, 7 May 2018 13:31:08 +0200 Subject: Move artifacts from src/artifacts to artifacts/v1 --- packages/0x.js/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'packages/0x.js') diff --git a/packages/0x.js/package.json b/packages/0x.js/package.json index d3cf9ad5f..a23e01938 100644 --- a/packages/0x.js/package.json +++ b/packages/0x.js/package.json @@ -21,7 +21,7 @@ "test": "run-s clean test:commonjs", "test:coverage": "nyc npm run test --all && yarn coverage:report:lcov", "coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info", - "update_artifacts": "for i in ${npm_package_config_contracts}; do copyfiles -u 4 ../migrations/src/artifacts/$i.json test/artifacts; done;", + "update_artifacts": "for i in ${npm_package_config_contracts}; do copyfiles -u 4 ../migrations/artifacts/1.0.0/$i.json test/artifacts; done;", "clean": "shx rm -rf _bundles lib test_temp scripts", "build:umd:prod": "NODE_ENV=production webpack", "build:commonjs": "tsc && yarn update_artifacts && copyfiles -u 2 './src/compact_artifacts/**/*.json' ./lib/src/compact_artifacts && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts", -- cgit v1.2.3