diff options
Diffstat (limited to 'contracts')
42 files changed, 408 insertions, 339 deletions
diff --git a/contracts/TESTING.md b/contracts/TESTING.md index 750b3c62c..3e6888c04 100644 --- a/contracts/TESTING.md +++ b/contracts/TESTING.md @@ -20,7 +20,7 @@ TEST_PROVIDER=geth yarn test ## Code coverage -In order to see the Solidity code coverage output generated by `@0x/sol-cov`, run: +In order to see the Solidity code coverage output generated by `@0x/sol-coverage`, run: ``` yarn test:coverage diff --git a/contracts/examples/CHANGELOG.json b/contracts/examples/CHANGELOG.json index 19ac770af..50872eb07 100644 --- a/contracts/examples/CHANGELOG.json +++ b/contracts/examples/CHANGELOG.json @@ -1,5 +1,14 @@ [ { + "timestamp": 1547040760, + "version": "1.0.3", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "timestamp": 1544741676, "version": "1.0.2", "changes": [ diff --git a/contracts/examples/CHANGELOG.md b/contracts/examples/CHANGELOG.md index 716353d05..4732f1746 100644 --- a/contracts/examples/CHANGELOG.md +++ b/contracts/examples/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.3 - _January 9, 2019_ + + * Dependencies updated + ## v1.0.2 - _December 13, 2018_ * Dependencies updated diff --git a/contracts/examples/package.json b/contracts/examples/package.json index 37b73f98c..d04b5fc44 100644 --- a/contracts/examples/package.json +++ b/contracts/examples/package.json @@ -1,6 +1,6 @@ { "name": "@0x/contracts-examples", - "version": "1.0.2", + "version": "1.0.3", "engines": { "node": ">=6.12" }, @@ -33,12 +33,11 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/contracts/examples/README.md", "devDependencies": { - "@0x/abi-gen": "^1.0.19", - "@0x/contracts-test-utils": "^1.0.2", - "@0x/dev-utils": "^1.0.21", - "@0x/sol-compiler": "^1.1.16", - "@0x/sol-cov": "^2.1.16", - "@0x/subproviders": "^2.1.8", + "@0x/abi-gen": "^1.0.20", + "@0x/contracts-test-utils": "^1.0.3", + "@0x/dev-utils": "^1.0.22", + "@0x/sol-compiler": "^2.0.0", + "@0x/subproviders": "^2.1.9", "@0x/tslint-config": "^2.0.0", "@types/bn.js": "^4.11.0", "@types/lodash": "4.14.104", @@ -53,24 +52,23 @@ "mocha": "^4.1.0", "npm-run-all": "^4.1.2", "shx": "^0.2.2", - "solc": "^0.4.24", "solhint": "^1.4.1", "tslint": "5.11.0", "typescript": "3.0.1", "yargs": "^10.0.3" }, "dependencies": { - "@0x/base-contract": "^3.0.10", - "@0x/contracts-interfaces": "^1.0.2", - "@0x/contracts-libs": "^1.0.2", - "@0x/contracts-multisig": "^1.0.2", - "@0x/contracts-tokens": "^1.0.2", - "@0x/contracts-utils": "^1.0.2", - "@0x/order-utils": "^3.0.7", - "@0x/types": "^1.4.1", + "@0x/base-contract": "^3.0.11", + "@0x/contracts-interfaces": "^1.0.3", + "@0x/contracts-libs": "^1.0.3", + "@0x/contracts-multisig": "^1.0.3", + "@0x/contracts-tokens": "^1.0.3", + "@0x/contracts-utils": "^1.0.3", + "@0x/order-utils": "^3.1.0", + "@0x/types": "^1.5.0", "@0x/typescript-typings": "^3.0.6", - "@0x/utils": "^2.0.8", - "@0x/web3-wrapper": "^3.2.1", + "@0x/utils": "^2.1.1", + "@0x/web3-wrapper": "^3.2.2", "@types/js-combinatorics": "^0.5.29", "bn.js": "^4.11.8", "ethereum-types": "^1.1.4", diff --git a/contracts/extensions/CHANGELOG.json b/contracts/extensions/CHANGELOG.json index 083ad33fb..de1ada0a8 100644 --- a/contracts/extensions/CHANGELOG.json +++ b/contracts/extensions/CHANGELOG.json @@ -1,5 +1,15 @@ [ { + "version": "1.2.0", + "changes": [ + { + "note": "Added Dutch Auction Wrapper", + "pr": 1465 + } + ], + "timestamp": 1547040760 + }, + { "version": "1.1.0", "changes": [ { diff --git a/contracts/extensions/CHANGELOG.md b/contracts/extensions/CHANGELOG.md index 716353d05..452cc8e82 100644 --- a/contracts/extensions/CHANGELOG.md +++ b/contracts/extensions/CHANGELOG.md @@ -5,6 +5,16 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.2.0 - _January 9, 2019_ + + * Added Dutch Auction Wrapper (#1465) + +## v1.1.0 - _Invalid date_ + + * Added Balance Threshold Filter (#1383) + * Add OrderMatcher (#1117) + * Add OrderValidator (#1464) + ## v1.0.2 - _December 13, 2018_ * Dependencies updated diff --git a/contracts/extensions/package.json b/contracts/extensions/package.json index 069b5d2d5..99b5b35a8 100644 --- a/contracts/extensions/package.json +++ b/contracts/extensions/package.json @@ -1,6 +1,6 @@ { "name": "@0x/contracts-extensions", - "version": "1.0.2", + "version": "1.2.0", "engines": { "node": ">=6.12" }, @@ -44,12 +44,12 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/contracts/extensions/README.md", "devDependencies": { - "@0x/abi-gen": "^1.0.19", - "@0x/contracts-test-utils": "^1.0.2", - "@0x/dev-utils": "^1.0.21", - "@0x/sol-compiler": "^1.1.16", - "@0x/sol-cov": "^2.1.16", - "@0x/subproviders": "^2.1.8", + "@0x/abi-gen": "^1.0.20", + "@0x/contract-wrappers": "^4.2.0", + "@0x/contracts-test-utils": "^1.0.3", + "@0x/dev-utils": "^1.0.22", + "@0x/sol-compiler": "^2.0.0", + "@0x/subproviders": "^2.1.9", "@0x/tslint-config": "^2.0.0", "@types/bn.js": "^4.11.0", "@types/lodash": "4.14.104", @@ -64,24 +64,23 @@ "mocha": "^4.1.0", "npm-run-all": "^4.1.2", "shx": "^0.2.2", - "solc": "^0.4.24", "solhint": "^1.4.1", "tslint": "5.11.0", "typescript": "3.0.1", "yargs": "^10.0.3" }, "dependencies": { - "@0x/base-contract": "^3.0.10", - "@0x/contracts-interfaces": "^1.0.2", - "@0x/contracts-libs": "^1.0.2", - "@0x/contracts-protocol": "^2.1.59", - "@0x/contracts-tokens": "^1.0.2", - "@0x/contracts-utils": "^1.0.2", - "@0x/order-utils": "^3.0.7", - "@0x/types": "^1.4.1", + "@0x/base-contract": "^3.0.11", + "@0x/contracts-interfaces": "^1.0.3", + "@0x/contracts-libs": "^1.0.3", + "@0x/contracts-protocol": "^2.2.0", + "@0x/contracts-tokens": "^1.0.3", + "@0x/contracts-utils": "^1.0.3", + "@0x/order-utils": "^3.1.0", + "@0x/types": "^1.5.0", "@0x/typescript-typings": "^3.0.6", - "@0x/utils": "^2.0.8", - "@0x/web3-wrapper": "^3.2.1", + "@0x/utils": "^2.1.1", + "@0x/web3-wrapper": "^3.2.2", "@types/js-combinatorics": "^0.5.29", "bn.js": "^4.11.8", "ethereum-types": "^1.1.4", diff --git a/contracts/extensions/test/extensions/dutch_auction.ts b/contracts/extensions/test/extensions/dutch_auction.ts index 6c3b2f0f3..22b3caa16 100644 --- a/contracts/extensions/test/extensions/dutch_auction.ts +++ b/contracts/extensions/test/extensions/dutch_auction.ts @@ -1,3 +1,4 @@ +import { DutchAuctionWrapper } from '@0x/contract-wrappers'; import { artifacts as protocolArtifacts, ERC20Wrapper, @@ -29,12 +30,11 @@ import { RevertReason, SignedOrder } from '@0x/types'; import { BigNumber } from '@0x/utils'; import { Web3Wrapper } from '@0x/web3-wrapper'; import * as chai from 'chai'; -import ethAbi = require('ethereumjs-abi'); -import * as ethUtil from 'ethereumjs-util'; import * as _ from 'lodash'; import { DutchAuctionContract } from '../../generated-wrappers/dutch_auction'; import { artifacts } from '../../src/artifacts'; +import { DutchAuctionTestWrapper } from '../utils/dutch_auction_test_wrapper'; chaiSetup.configure(); const expect = chai.expect; @@ -68,19 +68,8 @@ describe(ContractName.DutchAuction, () => { let erc721MakerAssetIds: BigNumber[]; const tenMinutesInSeconds = 10 * 60; - function extendMakerAssetData(makerAssetData: string, beginTimeSeconds: BigNumber, beginAmount: BigNumber): string { - return ethUtil.bufferToHex( - Buffer.concat([ - ethUtil.toBuffer(makerAssetData), - ethUtil.toBuffer( - (ethAbi as any).rawEncode( - ['uint256', 'uint256'], - [beginTimeSeconds.toString(), beginAmount.toString()], - ), - ), - ]), - ); - } + let dutchAuctionTestWrapper: DutchAuctionTestWrapper; + let defaultERC20MakerAssetData: string; before(async () => { await blockchainLifecycle.startAsync(); @@ -136,6 +125,7 @@ describe(ContractName.DutchAuction, () => { dutchAuctionInstance.address, provider, ); + dutchAuctionTestWrapper = new DutchAuctionTestWrapper(dutchAuctionInstance, provider); defaultMakerAssetAddress = erc20TokenA.address; const defaultTakerAssetAddress = wethContract.address; @@ -174,7 +164,7 @@ describe(ContractName.DutchAuction, () => { feeRecipientAddress, // taker address or sender address should be set to the ducth auction contract takerAddress: dutchAuctionContract.address, - makerAssetData: extendMakerAssetData( + makerAssetData: DutchAuctionWrapper.encodeDutchAuctionAssetData( assetDataUtils.encodeERC20AssetData(defaultMakerAssetAddress), auctionBeginTimeSeconds, auctionBeginAmount, @@ -199,6 +189,7 @@ describe(ContractName.DutchAuction, () => { const takerPrivateKey = constants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(takerAddress)]; sellerOrderFactory = new OrderFactory(makerPrivateKey, sellerDefaultOrderParams); buyerOrderFactory = new OrderFactory(takerPrivateKey, buyerDefaultOrderParams); + defaultERC20MakerAssetData = assetDataUtils.encodeERC20AssetData(defaultMakerAssetAddress); }); after(async () => { await blockchainLifecycle.revertAsync(); @@ -215,49 +206,41 @@ describe(ContractName.DutchAuction, () => { describe('matchOrders', () => { it('should be worth the begin price at the begining of the auction', async () => { auctionBeginTimeSeconds = new BigNumber(currentBlockTimestamp + 2); - sellOrder = await sellerOrderFactory.newSignedOrderAsync({ - makerAssetData: extendMakerAssetData( - assetDataUtils.encodeERC20AssetData(defaultMakerAssetAddress), - auctionBeginTimeSeconds, - auctionBeginAmount, - ), - }); - const auctionDetails = await dutchAuctionContract.getAuctionDetails.callAsync(sellOrder); + const makerAssetData = DutchAuctionWrapper.encodeDutchAuctionAssetData( + defaultERC20MakerAssetData, + auctionBeginTimeSeconds, + auctionBeginAmount, + ); + sellOrder = await sellerOrderFactory.newSignedOrderAsync({ makerAssetData }); + const auctionDetails = await dutchAuctionTestWrapper.getAuctionDetailsAsync(sellOrder); + expect(auctionDetails.currentTimeSeconds).to.be.bignumber.lte(auctionBeginTimeSeconds); expect(auctionDetails.currentAmount).to.be.bignumber.equal(auctionBeginAmount); expect(auctionDetails.beginAmount).to.be.bignumber.equal(auctionBeginAmount); }); it('should be be worth the end price at the end of the auction', async () => { auctionBeginTimeSeconds = new BigNumber(currentBlockTimestamp - tenMinutesInSeconds * 2); auctionEndTimeSeconds = new BigNumber(currentBlockTimestamp - tenMinutesInSeconds); + const makerAssetData = DutchAuctionWrapper.encodeDutchAuctionAssetData( + defaultERC20MakerAssetData, + auctionBeginTimeSeconds, + auctionBeginAmount, + ); sellOrder = await sellerOrderFactory.newSignedOrderAsync({ - makerAssetData: extendMakerAssetData( - assetDataUtils.encodeERC20AssetData(defaultMakerAssetAddress), - auctionBeginTimeSeconds, - auctionBeginAmount, - ), + makerAssetData, expirationTimeSeconds: auctionEndTimeSeconds, }); - const auctionDetails = await dutchAuctionContract.getAuctionDetails.callAsync(sellOrder); + const auctionDetails = await dutchAuctionTestWrapper.getAuctionDetailsAsync(sellOrder); + expect(auctionDetails.currentTimeSeconds).to.be.bignumber.gte(auctionEndTimeSeconds); expect(auctionDetails.currentAmount).to.be.bignumber.equal(auctionEndAmount); expect(auctionDetails.beginAmount).to.be.bignumber.equal(auctionBeginAmount); }); it('should match orders at current amount and send excess to buyer', async () => { - const beforeAuctionDetails = await dutchAuctionContract.getAuctionDetails.callAsync(sellOrder); + const beforeAuctionDetails = await dutchAuctionTestWrapper.getAuctionDetailsAsync(sellOrder); buyOrder = await buyerOrderFactory.newSignedOrderAsync({ makerAssetAmount: beforeAuctionDetails.currentAmount.times(2), }); - await web3Wrapper.awaitTransactionSuccessAsync( - await dutchAuctionContract.matchOrders.sendTransactionAsync( - buyOrder, - sellOrder, - buyOrder.signature, - sellOrder.signature, - { - from: takerAddress, - }, - ), - ); - const afterAuctionDetails = await dutchAuctionContract.getAuctionDetails.callAsync(sellOrder); + await dutchAuctionTestWrapper.matchOrdersAsync(buyOrder, sellOrder, takerAddress); + const afterAuctionDetails = await dutchAuctionTestWrapper.getAuctionDetailsAsync(sellOrder); const newBalances = await erc20Wrapper.getBalancesAsync(); expect(newBalances[dutchAuctionContract.address][wethContract.address]).to.be.bignumber.equal( constants.ZERO_AMOUNT, @@ -276,17 +259,8 @@ describe(ContractName.DutchAuction, () => { sellOrder = await sellerOrderFactory.newSignedOrderAsync({ makerFee: new BigNumber(1), }); - const txHash = await dutchAuctionContract.matchOrders.sendTransactionAsync( - buyOrder, - sellOrder, - buyOrder.signature, - sellOrder.signature, - { - from: takerAddress, - }, - ); - await web3Wrapper.awaitTransactionSuccessAsync(txHash); - const afterAuctionDetails = await dutchAuctionContract.getAuctionDetails.callAsync(sellOrder); + await dutchAuctionTestWrapper.matchOrdersAsync(buyOrder, sellOrder, takerAddress); + const afterAuctionDetails = await dutchAuctionTestWrapper.getAuctionDetailsAsync(sellOrder); const newBalances = await erc20Wrapper.getBalancesAsync(); expect(newBalances[makerAddress][wethContract.address]).to.be.bignumber.gte( erc20Balances[makerAddress][wethContract.address].plus(afterAuctionDetails.currentAmount), @@ -299,18 +273,9 @@ describe(ContractName.DutchAuction, () => { buyOrder = await buyerOrderFactory.newSignedOrderAsync({ makerFee: new BigNumber(1), }); - const txHash = await dutchAuctionContract.matchOrders.sendTransactionAsync( - buyOrder, - sellOrder, - buyOrder.signature, - sellOrder.signature, - { - from: takerAddress, - }, - ); - await web3Wrapper.awaitTransactionSuccessAsync(txHash); + await dutchAuctionTestWrapper.matchOrdersAsync(buyOrder, sellOrder, takerAddress); const newBalances = await erc20Wrapper.getBalancesAsync(); - const afterAuctionDetails = await dutchAuctionContract.getAuctionDetails.callAsync(sellOrder); + const afterAuctionDetails = await dutchAuctionTestWrapper.getAuctionDetailsAsync(sellOrder); expect(newBalances[makerAddress][wethContract.address]).to.be.bignumber.gte( erc20Balances[makerAddress][wethContract.address].plus(afterAuctionDetails.currentAmount), ); @@ -321,24 +286,17 @@ describe(ContractName.DutchAuction, () => { it('should revert when auction expires', async () => { auctionBeginTimeSeconds = new BigNumber(currentBlockTimestamp - tenMinutesInSeconds * 2); auctionEndTimeSeconds = new BigNumber(currentBlockTimestamp - tenMinutesInSeconds); + const makerAssetData = DutchAuctionWrapper.encodeDutchAuctionAssetData( + defaultERC20MakerAssetData, + auctionBeginTimeSeconds, + auctionBeginAmount, + ); sellOrder = await sellerOrderFactory.newSignedOrderAsync({ expirationTimeSeconds: auctionEndTimeSeconds, - makerAssetData: extendMakerAssetData( - assetDataUtils.encodeERC20AssetData(defaultMakerAssetAddress), - auctionBeginTimeSeconds, - auctionBeginAmount, - ), + makerAssetData, }); return expectTransactionFailedAsync( - dutchAuctionContract.matchOrders.sendTransactionAsync( - buyOrder, - sellOrder, - buyOrder.signature, - sellOrder.signature, - { - from: takerAddress, - }, - ), + dutchAuctionTestWrapper.matchOrdersAsync(buyOrder, sellOrder, takerAddress), RevertReason.AuctionExpired, ); }); @@ -347,15 +305,7 @@ describe(ContractName.DutchAuction, () => { makerAssetAmount: sellOrder.takerAssetAmount, }); return expectTransactionFailedAsync( - dutchAuctionContract.matchOrders.sendTransactionAsync( - buyOrder, - sellOrder, - buyOrder.signature, - sellOrder.signature, - { - from: takerAddress, - }, - ), + dutchAuctionTestWrapper.matchOrdersAsync(buyOrder, sellOrder, takerAddress), RevertReason.AuctionInvalidAmount, ); }); @@ -364,38 +314,23 @@ describe(ContractName.DutchAuction, () => { takerAssetAmount: auctionBeginAmount.plus(1), }); return expectTransactionFailedAsync( - dutchAuctionContract.matchOrders.sendTransactionAsync( - buyOrder, - sellOrder, - buyOrder.signature, - sellOrder.signature, - { - from: takerAddress, - }, - ), + dutchAuctionTestWrapper.matchOrdersAsync(buyOrder, sellOrder, takerAddress), RevertReason.AuctionInvalidAmount, ); }); it('begin time is less than end time', async () => { auctionBeginTimeSeconds = new BigNumber(auctionEndTimeSeconds).plus(tenMinutesInSeconds); + const makerAssetData = DutchAuctionWrapper.encodeDutchAuctionAssetData( + defaultERC20MakerAssetData, + auctionBeginTimeSeconds, + auctionBeginAmount, + ); sellOrder = await sellerOrderFactory.newSignedOrderAsync({ expirationTimeSeconds: auctionEndTimeSeconds, - makerAssetData: extendMakerAssetData( - assetDataUtils.encodeERC20AssetData(defaultMakerAssetAddress), - auctionBeginTimeSeconds, - auctionBeginAmount, - ), + makerAssetData, }); return expectTransactionFailedAsync( - dutchAuctionContract.matchOrders.sendTransactionAsync( - buyOrder, - sellOrder, - buyOrder.signature, - sellOrder.signature, - { - from: takerAddress, - }, - ), + dutchAuctionTestWrapper.matchOrdersAsync(buyOrder, sellOrder, takerAddress), RevertReason.AuctionInvalidBeginTime, ); }); @@ -404,45 +339,30 @@ describe(ContractName.DutchAuction, () => { makerAssetData: assetDataUtils.encodeERC20AssetData(defaultMakerAssetAddress), }); return expectTransactionFailedAsync( - dutchAuctionContract.matchOrders.sendTransactionAsync( - buyOrder, - sellOrder, - buyOrder.signature, - sellOrder.signature, - { - from: takerAddress, - }, - ), + dutchAuctionTestWrapper.matchOrdersAsync(buyOrder, sellOrder, takerAddress), RevertReason.InvalidAssetData, ); }); + describe('ERC721', () => { it('should match orders when ERC721', async () => { const makerAssetId = erc721MakerAssetIds[0]; + const erc721MakerAssetData = assetDataUtils.encodeERC721AssetData(erc721Token.address, makerAssetId); + const makerAssetData = DutchAuctionWrapper.encodeDutchAuctionAssetData( + erc721MakerAssetData, + auctionBeginTimeSeconds, + auctionBeginAmount, + ); sellOrder = await sellerOrderFactory.newSignedOrderAsync({ makerAssetAmount: new BigNumber(1), - makerAssetData: extendMakerAssetData( - assetDataUtils.encodeERC721AssetData(erc721Token.address, makerAssetId), - auctionBeginTimeSeconds, - auctionBeginAmount, - ), + makerAssetData, }); buyOrder = await buyerOrderFactory.newSignedOrderAsync({ takerAssetAmount: new BigNumber(1), takerAssetData: sellOrder.makerAssetData, }); - await web3Wrapper.awaitTransactionSuccessAsync( - await dutchAuctionContract.matchOrders.sendTransactionAsync( - buyOrder, - sellOrder, - buyOrder.signature, - sellOrder.signature, - { - from: takerAddress, - }, - ), - ); - const afterAuctionDetails = await dutchAuctionContract.getAuctionDetails.callAsync(sellOrder); + await dutchAuctionTestWrapper.matchOrdersAsync(buyOrder, sellOrder, takerAddress); + const afterAuctionDetails = await dutchAuctionTestWrapper.getAuctionDetailsAsync(sellOrder); const newBalances = await erc20Wrapper.getBalancesAsync(); // HACK gte used here due to a bug in ganache where the timestamp can change // between multiple calls to the same block. Which can move the amount in our case diff --git a/contracts/extensions/test/utils/dutch_auction_test_wrapper.ts b/contracts/extensions/test/utils/dutch_auction_test_wrapper.ts new file mode 100644 index 000000000..c1e2f2070 --- /dev/null +++ b/contracts/extensions/test/utils/dutch_auction_test_wrapper.ts @@ -0,0 +1,62 @@ +import { artifacts as protocolArtifacts } from '@0x/contracts-protocol'; +import { LogDecoder } from '@0x/contracts-test-utils'; +import { artifacts as tokensArtifacts } from '@0x/contracts-tokens'; +import { DutchAuctionDetails, SignedOrder } from '@0x/types'; +import { Web3Wrapper } from '@0x/web3-wrapper'; +import { Provider, TransactionReceiptWithDecodedLogs } from 'ethereum-types'; +import * as _ from 'lodash'; + +import { DutchAuctionContract } from '../../generated-wrappers/dutch_auction'; +import { artifacts } from '../../src/artifacts'; + +export class DutchAuctionTestWrapper { + private readonly _dutchAuctionContract: DutchAuctionContract; + private readonly _web3Wrapper: Web3Wrapper; + private readonly _logDecoder: LogDecoder; + + constructor(contractInstance: DutchAuctionContract, provider: Provider) { + this._dutchAuctionContract = contractInstance; + this._web3Wrapper = new Web3Wrapper(provider); + this._logDecoder = new LogDecoder(this._web3Wrapper, { + ...artifacts, + ...tokensArtifacts, + ...protocolArtifacts, + }); + } + /** + * Matches the buy and sell orders at an amount given the following: the current block time, the auction + * start time and the auction begin amount. The sell order is a an order at the lowest amount + * at the end of the auction. Excess from the match is transferred to the seller. + * Over time the price moves from beginAmount to endAmount given the current block.timestamp. + * @param buyOrder The Buyer's order. This order is for the current expected price of the auction. + * @param sellOrder The Seller's order. This order is for the lowest amount (at the end of the auction). + * @param from Address the transaction is being sent from. + * @return Transaction receipt with decoded logs. + */ + public async matchOrdersAsync( + buyOrder: SignedOrder, + sellOrder: SignedOrder, + from: string, + ): Promise<TransactionReceiptWithDecodedLogs> { + const txHash = await this._dutchAuctionContract.matchOrders.sendTransactionAsync( + buyOrder, + sellOrder, + buyOrder.signature, + sellOrder.signature, + { + from, + }, + ); + const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash); + return tx; + } + /** + * Calculates the Auction Details for the given order + * @param sellOrder The Seller's order. This order is for the lowest amount (at the end of the auction). + * @return The dutch auction details. + */ + public async getAuctionDetailsAsync(sellOrder: SignedOrder): Promise<DutchAuctionDetails> { + const auctionDetails = await this._dutchAuctionContract.getAuctionDetails.callAsync(sellOrder); + return auctionDetails; + } +} diff --git a/contracts/interfaces/CHANGELOG.json b/contracts/interfaces/CHANGELOG.json index 19ac770af..50872eb07 100644 --- a/contracts/interfaces/CHANGELOG.json +++ b/contracts/interfaces/CHANGELOG.json @@ -1,5 +1,14 @@ [ { + "timestamp": 1547040760, + "version": "1.0.3", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "timestamp": 1544741676, "version": "1.0.2", "changes": [ diff --git a/contracts/interfaces/CHANGELOG.md b/contracts/interfaces/CHANGELOG.md index 716353d05..4732f1746 100644 --- a/contracts/interfaces/CHANGELOG.md +++ b/contracts/interfaces/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.3 - _January 9, 2019_ + + * Dependencies updated + ## v1.0.2 - _December 13, 2018_ * Dependencies updated diff --git a/contracts/interfaces/README.md b/contracts/interfaces/README.md index b7d519abb..81dd4c3ac 100644 --- a/contracts/interfaces/README.md +++ b/contracts/interfaces/README.md @@ -6,8 +6,8 @@ Smart contract interfaces of the 0x protocol. Contracts that make up and interact with version 2.0.0 of the protocol can be found in the [contracts](./contracts) directory. The contents of this directory are broken down into the following subdirectories: -* [protocol](./contracts/protocol) - * This directory contains the contract interfaces that make up version 2.0.0. A full specification can be found [here](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md). +- [protocol](./contracts/protocol) + - This directory contains the contract interfaces that make up version 2.0.0. A full specification can be found [here](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md). ## Bug bounty diff --git a/contracts/interfaces/package.json b/contracts/interfaces/package.json index 15385a154..9017f0a73 100644 --- a/contracts/interfaces/package.json +++ b/contracts/interfaces/package.json @@ -1,6 +1,6 @@ { "name": "@0x/contracts-interfaces", - "version": "1.0.2", + "version": "1.0.3", "engines": { "node": ">=6.12" }, @@ -30,8 +30,8 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/contracts/interfaces/README.md", "devDependencies": { - "@0x/abi-gen": "^1.0.19", - "@0x/sol-compiler": "^1.1.16", + "@0x/abi-gen": "^1.0.20", + "@0x/sol-compiler": "^2.0.0", "@0x/tslint-config": "^2.0.0", "npm-run-all": "^4.1.2", "shx": "^0.2.2", @@ -41,13 +41,13 @@ "yargs": "^10.0.3" }, "dependencies": { - "@0x/base-contract": "^3.0.10", - "@0x/contracts-libs": "^1.0.2", - "@0x/contracts-utils": "^1.0.2", - "@0x/types": "^1.4.1", + "@0x/base-contract": "^3.0.11", + "@0x/contracts-libs": "^1.0.3", + "@0x/contracts-utils": "^1.0.3", + "@0x/types": "^1.5.0", "@0x/typescript-typings": "^3.0.6", - "@0x/utils": "^2.0.8", - "@0x/web3-wrapper": "^3.2.1", + "@0x/utils": "^2.1.1", + "@0x/web3-wrapper": "^3.2.2", "ethereum-types": "^1.1.4", "lodash": "^4.17.5" }, diff --git a/contracts/libs/CHANGELOG.json b/contracts/libs/CHANGELOG.json index 19ac770af..50872eb07 100644 --- a/contracts/libs/CHANGELOG.json +++ b/contracts/libs/CHANGELOG.json @@ -1,5 +1,14 @@ [ { + "timestamp": 1547040760, + "version": "1.0.3", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "timestamp": 1544741676, "version": "1.0.2", "changes": [ diff --git a/contracts/libs/CHANGELOG.md b/contracts/libs/CHANGELOG.md index 716353d05..4732f1746 100644 --- a/contracts/libs/CHANGELOG.md +++ b/contracts/libs/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.3 - _January 9, 2019_ + + * Dependencies updated + ## v1.0.2 - _December 13, 2018_ * Dependencies updated diff --git a/contracts/libs/README.md b/contracts/libs/README.md index 66eedf6be..cfa631679 100644 --- a/contracts/libs/README.md +++ b/contracts/libs/README.md @@ -6,10 +6,10 @@ Smart contracts libs used in the 0x protocol. Contracts can be found in the [contracts](./contracts) directory. The contents of this directory are broken down into the following subdirectories: -* [libs](./contracts/protocol) - * This directory contains the libs. -* [test](./contracts/test) - * This directory contains mocks and other contracts that are used solely for testing contracts within the other directories. +- [libs](./contracts/protocol) + - This directory contains the libs. +- [test](./contracts/test) + - This directory contains mocks and other contracts that are used solely for testing contracts within the other directories. ## Contributing diff --git a/contracts/libs/package.json b/contracts/libs/package.json index ce7b97502..9d28cc038 100644 --- a/contracts/libs/package.json +++ b/contracts/libs/package.json @@ -1,6 +1,6 @@ { "name": "@0x/contracts-libs", - "version": "1.0.2", + "version": "1.0.3", "engines": { "node": ">=6.12" }, @@ -44,12 +44,11 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/contracts/libs/README.md", "devDependencies": { - "@0x/abi-gen": "^1.0.19", - "@0x/contracts-test-utils": "^1.0.2", - "@0x/dev-utils": "^1.0.21", - "@0x/sol-compiler": "^1.1.16", - "@0x/sol-cov": "^2.1.16", - "@0x/subproviders": "^2.1.8", + "@0x/abi-gen": "^1.0.20", + "@0x/contracts-test-utils": "^1.0.3", + "@0x/dev-utils": "^1.0.22", + "@0x/sol-compiler": "^2.0.0", + "@0x/subproviders": "^2.1.9", "@0x/tslint-config": "^2.0.0", "@types/bn.js": "^4.11.0", "@types/lodash": "4.14.104", @@ -64,21 +63,20 @@ "mocha": "^4.1.0", "npm-run-all": "^4.1.2", "shx": "^0.2.2", - "solc": "^0.4.24", "solhint": "^1.4.1", "tslint": "5.11.0", "typescript": "3.0.1", "yargs": "^10.0.3" }, "dependencies": { - "@0x/base-contract": "^3.0.10", - "@0x/contracts-multisig": "^1.0.2", - "@0x/contracts-utils": "^1.0.2", - "@0x/order-utils": "^3.0.7", - "@0x/types": "^1.4.1", + "@0x/base-contract": "^3.0.11", + "@0x/contracts-multisig": "^1.0.3", + "@0x/contracts-utils": "^1.0.3", + "@0x/order-utils": "^3.1.0", + "@0x/types": "^1.5.0", "@0x/typescript-typings": "^3.0.6", - "@0x/utils": "^2.0.8", - "@0x/web3-wrapper": "^3.2.1", + "@0x/utils": "^2.1.1", + "@0x/web3-wrapper": "^3.2.2", "@types/js-combinatorics": "^0.5.29", "bn.js": "^4.11.8", "ethereum-types": "^1.1.4", diff --git a/contracts/multisig/CHANGELOG.json b/contracts/multisig/CHANGELOG.json index 19ac770af..50872eb07 100644 --- a/contracts/multisig/CHANGELOG.json +++ b/contracts/multisig/CHANGELOG.json @@ -1,5 +1,14 @@ [ { + "timestamp": 1547040760, + "version": "1.0.3", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "timestamp": 1544741676, "version": "1.0.2", "changes": [ diff --git a/contracts/multisig/CHANGELOG.md b/contracts/multisig/CHANGELOG.md index 716353d05..4732f1746 100644 --- a/contracts/multisig/CHANGELOG.md +++ b/contracts/multisig/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.3 - _January 9, 2019_ + + * Dependencies updated + ## v1.0.2 - _December 13, 2018_ * Dependencies updated diff --git a/contracts/multisig/README.md b/contracts/multisig/README.md index 93db63b5b..e29f46251 100644 --- a/contracts/multisig/README.md +++ b/contracts/multisig/README.md @@ -6,10 +6,10 @@ MultiSig smart contracts Contracts can be found in the [contracts](./contracts) directory. The contents of this directory are broken down into the following subdirectories: -* [multisig](./contracts/multisig) - * This directory contains the [Gnosis MultiSigWallet](https://github.com/gnosis/MultiSigWallet) and a custom extension that adds a timelock to transactions within the MultiSigWallet. -* [test](./contracts/test) - * This directory contains mocks and other contracts that are used solely for testing contracts within the other directories. +- [multisig](./contracts/multisig) + - This directory contains the [Gnosis MultiSigWallet](https://github.com/gnosis/MultiSigWallet) and a custom extension that adds a timelock to transactions within the MultiSigWallet. +- [test](./contracts/test) + - This directory contains mocks and other contracts that are used solely for testing contracts within the other directories. ## Contributing diff --git a/contracts/multisig/package.json b/contracts/multisig/package.json index 2d7b4aa05..e0bbc001d 100644 --- a/contracts/multisig/package.json +++ b/contracts/multisig/package.json @@ -1,6 +1,6 @@ { "name": "@0x/contracts-multisig", - "version": "1.0.2", + "version": "1.0.3", "engines": { "node": ">=6.12" }, @@ -44,12 +44,11 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/contracts/multisig/README.md", "devDependencies": { - "@0x/abi-gen": "^1.0.19", - "@0x/contracts-test-utils": "^1.0.2", - "@0x/dev-utils": "^1.0.21", - "@0x/sol-compiler": "^1.1.16", - "@0x/sol-cov": "^2.1.16", - "@0x/subproviders": "^2.1.8", + "@0x/abi-gen": "^1.0.20", + "@0x/contracts-test-utils": "^1.0.3", + "@0x/dev-utils": "^1.0.22", + "@0x/sol-compiler": "^2.0.0", + "@0x/subproviders": "^2.1.9", "@0x/tslint-config": "^2.0.0", "@types/bn.js": "^4.11.0", "@types/ethereumjs-abi": "^0.6.0", @@ -64,19 +63,18 @@ "mocha": "^4.1.0", "npm-run-all": "^4.1.2", "shx": "^0.2.2", - "solc": "^0.4.24", "solhint": "^1.4.1", "tslint": "5.11.0", "typescript": "3.0.1", "yargs": "^10.0.3" }, "dependencies": { - "@0x/base-contract": "^3.0.10", - "@0x/order-utils": "^3.0.7", - "@0x/types": "^1.4.1", + "@0x/base-contract": "^3.0.11", + "@0x/order-utils": "^3.1.0", + "@0x/types": "^1.5.0", "@0x/typescript-typings": "^3.0.6", - "@0x/utils": "^2.0.8", - "@0x/web3-wrapper": "^3.2.1", + "@0x/utils": "^2.1.1", + "@0x/web3-wrapper": "^3.2.2", "ethereum-types": "^1.1.4", "lodash": "^4.17.5" }, diff --git a/contracts/protocol/CHANGELOG.json b/contracts/protocol/CHANGELOG.json index e283d7917..6672ce9c3 100644 --- a/contracts/protocol/CHANGELOG.json +++ b/contracts/protocol/CHANGELOG.json @@ -14,7 +14,8 @@ "note": "Move OrderValidator to extensions", "pr": 1464 } - ] + ], + "timestamp": 1547040760 }, { "timestamp": 1544741676, diff --git a/contracts/protocol/CHANGELOG.md b/contracts/protocol/CHANGELOG.md index d90b1b2cc..a8ad921a2 100644 --- a/contracts/protocol/CHANGELOG.md +++ b/contracts/protocol/CHANGELOG.md @@ -5,6 +5,12 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v2.2.0 - _January 9, 2019_ + + * Added LibAddressArray (#1383) + * Add validation and comments to MultiAssetProxy (#1455) + * Move OrderValidator to extensions (#1464) + ## v2.1.59 - _December 13, 2018_ * Dependencies updated diff --git a/contracts/protocol/README.md b/contracts/protocol/README.md index 5fc9c0a89..dc1f32c98 100644 --- a/contracts/protocol/README.md +++ b/contracts/protocol/README.md @@ -6,10 +6,10 @@ Smart contracts that implement the 0x protocol. Addresses of the deployed contra Contracts that make up and interact with version 2.0.0 of the protocol can be found in the [contracts](./contracts) directory. The contents of this directory are broken down into the following subdirectories: -* [protocol](./contracts/protocol) - * This directory contains the contracts that make up version 2.0.0. A full specification can be found [here](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md). -* [test](./contracts/test) - * This directory contains mocks and other contracts that are used solely for testing contracts within the other directories. +- [protocol](./contracts/protocol) + - This directory contains the contracts that make up version 2.0.0. A full specification can be found [here](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md). +- [test](./contracts/test) + - This directory contains mocks and other contracts that are used solely for testing contracts within the other directories. ## Bug bounty diff --git a/contracts/protocol/package.json b/contracts/protocol/package.json index 891838e54..7d49dfbe8 100644 --- a/contracts/protocol/package.json +++ b/contracts/protocol/package.json @@ -1,6 +1,6 @@ { "name": "@0x/contracts-protocol", - "version": "2.1.59", + "version": "2.2.0", "engines": { "node": ">=6.12" }, @@ -44,11 +44,10 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/contracts/protocol/README.md", "devDependencies": { - "@0x/abi-gen": "^1.0.19", - "@0x/dev-utils": "^1.0.21", - "@0x/sol-compiler": "^1.1.16", - "@0x/sol-cov": "^2.1.16", - "@0x/subproviders": "^2.1.8", + "@0x/abi-gen": "^1.0.20", + "@0x/dev-utils": "^1.0.22", + "@0x/sol-compiler": "^2.0.0", + "@0x/subproviders": "^2.1.9", "@0x/tslint-config": "^2.0.0", "@types/bn.js": "^4.11.0", "@types/lodash": "4.14.104", @@ -63,26 +62,25 @@ "mocha": "^4.1.0", "npm-run-all": "^4.1.2", "shx": "^0.2.2", - "solc": "^0.4.24", "solhint": "^1.4.1", "tslint": "5.11.0", "typescript": "3.0.1", "yargs": "^10.0.3" }, "dependencies": { - "@0x/base-contract": "^3.0.10", - "@0x/contracts-examples": "^1.0.2", - "@0x/contracts-interfaces": "^1.0.2", - "@0x/contracts-libs": "^1.0.2", - "@0x/contracts-multisig": "^1.0.2", - "@0x/contracts-test-utils": "^1.0.2", - "@0x/contracts-tokens": "^1.0.2", - "@0x/contracts-utils": "^1.0.2", - "@0x/order-utils": "^3.0.7", - "@0x/types": "^1.4.1", + "@0x/base-contract": "^3.0.11", + "@0x/contracts-examples": "^1.0.3", + "@0x/contracts-interfaces": "^1.0.3", + "@0x/contracts-libs": "^1.0.3", + "@0x/contracts-multisig": "^1.0.3", + "@0x/contracts-test-utils": "^1.0.3", + "@0x/contracts-tokens": "^1.0.3", + "@0x/contracts-utils": "^1.0.3", + "@0x/order-utils": "^3.1.0", + "@0x/types": "^1.5.0", "@0x/typescript-typings": "^3.0.6", - "@0x/utils": "^2.0.8", - "@0x/web3-wrapper": "^3.2.1", + "@0x/utils": "^2.1.1", + "@0x/web3-wrapper": "^3.2.2", "@types/js-combinatorics": "^0.5.29", "bn.js": "^4.11.8", "ethereum-types": "^1.1.4", diff --git a/contracts/protocol/test/asset_proxy/proxies.ts b/contracts/protocol/test/asset_proxy/proxies.ts index 89c8b390c..bbb44f402 100644 --- a/contracts/protocol/test/asset_proxy/proxies.ts +++ b/contracts/protocol/test/asset_proxy/proxies.ts @@ -715,7 +715,7 @@ describe('Asset Transfer Proxies', () => { const erc20AssetData = assetDataUtils.encodeERC20AssetData(erc20TokenA.address); const amounts = [erc20Amount]; const nestedAssetData = [erc20AssetData]; - const assetData = assetDataInterface.MultiAsset.getABIEncodedTransactionData(amounts, nestedAssetData); + const assetData = assetDataUtils.encodeMultiAssetData(amounts, nestedAssetData); const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( assetData, fromAddress, @@ -778,7 +778,7 @@ describe('Asset Transfer Proxies', () => { const erc20AssetData2 = assetDataUtils.encodeERC20AssetData(erc20TokenA.address); const amounts = [erc20Amount1, erc20Amount2]; const nestedAssetData = [erc20AssetData1, erc20AssetData2]; - const assetData = assetDataInterface.MultiAsset.getABIEncodedTransactionData(amounts, nestedAssetData); + const assetData = assetDataUtils.encodeMultiAssetData(amounts, nestedAssetData); const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( assetData, fromAddress, @@ -811,7 +811,7 @@ describe('Asset Transfer Proxies', () => { const erc20AssetData2 = assetDataUtils.encodeERC20AssetData(erc20TokenB.address); const amounts = [erc20Amount1, erc20Amount2]; const nestedAssetData = [erc20AssetData1, erc20AssetData2]; - const assetData = assetDataInterface.MultiAsset.getABIEncodedTransactionData(amounts, nestedAssetData); + const assetData = assetDataUtils.encodeMultiAssetData(amounts, nestedAssetData); const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( assetData, fromAddress, @@ -849,7 +849,7 @@ describe('Asset Transfer Proxies', () => { const erc721AssetData = assetDataUtils.encodeERC721AssetData(erc721TokenA.address, erc721AFromTokenId); const amounts = [erc721Amount]; const nestedAssetData = [erc721AssetData]; - const assetData = assetDataInterface.MultiAsset.getABIEncodedTransactionData(amounts, nestedAssetData); + const assetData = assetDataUtils.encodeMultiAssetData(amounts, nestedAssetData); const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( assetData, fromAddress, @@ -881,7 +881,7 @@ describe('Asset Transfer Proxies', () => { const erc721Amount = new BigNumber(1); const amounts = [erc721Amount, erc721Amount]; const nestedAssetData = [erc721AssetData1, erc721AssetData2]; - const assetData = assetDataInterface.MultiAsset.getABIEncodedTransactionData(amounts, nestedAssetData); + const assetData = assetDataUtils.encodeMultiAssetData(amounts, nestedAssetData); const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( assetData, fromAddress, @@ -913,7 +913,7 @@ describe('Asset Transfer Proxies', () => { const erc721Amount = new BigNumber(1); const amounts = [erc721Amount, erc721Amount]; const nestedAssetData = [erc721AssetData1, erc721AssetData2]; - const assetData = assetDataInterface.MultiAsset.getABIEncodedTransactionData(amounts, nestedAssetData); + const assetData = assetDataUtils.encodeMultiAssetData(amounts, nestedAssetData); const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( assetData, fromAddress, @@ -946,7 +946,7 @@ describe('Asset Transfer Proxies', () => { const erc721AssetData = assetDataUtils.encodeERC721AssetData(erc721TokenA.address, erc721AFromTokenId); const amounts = [erc20Amount, erc721Amount]; const nestedAssetData = [erc20AssetData, erc721AssetData]; - const assetData = assetDataInterface.MultiAsset.getABIEncodedTransactionData(amounts, nestedAssetData); + const assetData = assetDataUtils.encodeMultiAssetData(amounts, nestedAssetData); const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( assetData, fromAddress, @@ -984,10 +984,7 @@ describe('Asset Transfer Proxies', () => { const amounts = [erc20Amount, erc721Amount]; const nestedAssetData = [erc20AssetData, erc721AssetData]; const extraData = '0102030405060708'; - const assetData = `${assetDataInterface.MultiAsset.getABIEncodedTransactionData( - amounts, - nestedAssetData, - )}${extraData}`; + const assetData = `${assetDataUtils.encodeMultiAssetData(amounts, nestedAssetData)}${extraData}`; const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( assetData, fromAddress, @@ -1024,7 +1021,7 @@ describe('Asset Transfer Proxies', () => { const erc20AssetData2 = assetDataUtils.encodeERC20AssetData(erc20TokenB.address); const amounts = [erc20Amount1, erc20Amount2]; const nestedAssetData = [erc20AssetData1, erc20AssetData2]; - const assetData = assetDataInterface.MultiAsset.getABIEncodedTransactionData(amounts, nestedAssetData); + const assetData = assetDataUtils.encodeMultiAssetData(amounts, nestedAssetData); const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( assetData, fromAddress, @@ -1085,7 +1082,7 @@ describe('Asset Transfer Proxies', () => { erc721AssetData3, erc721AssetData4, ]; - const assetData = assetDataInterface.MultiAsset.getABIEncodedTransactionData(amounts, nestedAssetData); + const assetData = assetDataUtils.encodeMultiAssetData(amounts, nestedAssetData); const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( assetData, fromAddress, @@ -1143,7 +1140,7 @@ describe('Asset Transfer Proxies', () => { const erc721AssetData = assetDataUtils.encodeERC721AssetData(erc721TokenA.address, erc721AFromTokenId); const amounts = [erc20Amount, erc721Amount]; const nestedAssetData = [erc20AssetData, erc721AssetData]; - const assetData = assetDataInterface.MultiAsset.getABIEncodedTransactionData(amounts, nestedAssetData); + const assetData = assetDataUtils.encodeMultiAssetData(amounts, nestedAssetData); const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( assetData, fromAddress, @@ -1169,6 +1166,7 @@ describe('Asset Transfer Proxies', () => { const invalidErc721AssetData = `${invalidProxyId}${erc721AssetData.slice(10)}`; const amounts = [erc20Amount, erc721Amount]; const nestedAssetData = [erc20AssetData, invalidErc721AssetData]; + // HACK: This is used to get around validation built into assetDataUtils const assetData = assetDataInterface.MultiAsset.getABIEncodedTransactionData(amounts, nestedAssetData); const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( assetData, @@ -1192,6 +1190,7 @@ describe('Asset Transfer Proxies', () => { const erc721AssetData = assetDataUtils.encodeERC721AssetData(erc721TokenA.address, erc721AFromTokenId); const amounts = [erc20Amount]; const nestedAssetData = [erc20AssetData, erc721AssetData]; + // HACK: This is used to get around validation built into assetDataUtils const assetData = assetDataInterface.MultiAsset.getABIEncodedTransactionData(amounts, nestedAssetData); const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( assetData, @@ -1214,7 +1213,7 @@ describe('Asset Transfer Proxies', () => { const erc20AssetData = assetDataUtils.encodeERC20AssetData(erc20TokenA.address); const amounts = [erc20Amount]; const nestedAssetData = [erc20AssetData]; - const assetData = assetDataInterface.MultiAsset.getABIEncodedTransactionData(amounts, nestedAssetData); + const assetData = assetDataUtils.encodeMultiAssetData(amounts, nestedAssetData); const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( assetData, fromAddress, @@ -1238,6 +1237,7 @@ describe('Asset Transfer Proxies', () => { const erc721AssetData = '0x123456'; const amounts = [erc20Amount, erc721Amount]; const nestedAssetData = [erc20AssetData, erc721AssetData]; + // HACK: This is used to get around validation built into assetDataUtils const assetData = assetDataInterface.MultiAsset.getABIEncodedTransactionData(amounts, nestedAssetData); const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( assetData, @@ -1262,7 +1262,7 @@ describe('Asset Transfer Proxies', () => { const erc721AssetData = assetDataUtils.encodeERC721AssetData(erc721TokenA.address, erc721AFromTokenId); const amounts = [erc20Amount, erc721Amount]; const nestedAssetData = [erc20AssetData, erc721AssetData]; - const assetData = assetDataInterface.MultiAsset.getABIEncodedTransactionData(amounts, nestedAssetData); + const assetData = assetDataUtils.encodeMultiAssetData(amounts, nestedAssetData); const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData( assetData, fromAddress, diff --git a/contracts/protocol/test/exchange/core.ts b/contracts/protocol/test/exchange/core.ts index 9b948f991..42db8623d 100644 --- a/contracts/protocol/test/exchange/core.ts +++ b/contracts/protocol/test/exchange/core.ts @@ -1,4 +1,3 @@ -import { artifacts as interfacesArtifacts, IAssetDataContract } from '@0x/contracts-interfaces'; import { chaiSetup, constants, @@ -43,11 +42,6 @@ import { ExchangeWrapper } from '../utils/exchange_wrapper'; chaiSetup.configure(); const expect = chai.expect; const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper); -const assetDataInterface = new IAssetDataContract( - interfacesArtifacts.IAssetData.compilerOutput.abi, - constants.NULL_ADDRESS, - provider, -); // tslint:disable:no-unnecessary-type-assertion describe('Exchange core', () => { let makerAddress: string; @@ -777,10 +771,7 @@ describe('Exchange core', () => { assetDataUtils.encodeERC20AssetData(erc20TokenA.address), assetDataUtils.encodeERC20AssetData(erc20TokenB.address), ]; - const makerAssetData = assetDataInterface.MultiAsset.getABIEncodedTransactionData( - makerAmounts, - makerNestedAssetData, - ); + const makerAssetData = assetDataUtils.encodeMultiAssetData(makerAmounts, makerNestedAssetData); const makerAssetAmount = new BigNumber(1); const takerAssetData = assetDataUtils.encodeERC20AssetData(zrxToken.address); const takerAssetAmount = new BigNumber(10); @@ -830,10 +821,7 @@ describe('Exchange core', () => { assetDataUtils.encodeERC20AssetData(erc20TokenA.address), assetDataUtils.encodeERC20AssetData(erc20TokenB.address), ]; - const makerAssetData = assetDataInterface.MultiAsset.getABIEncodedTransactionData( - makerAmounts, - makerNestedAssetData, - ); + const makerAssetData = assetDataUtils.encodeMultiAssetData(makerAmounts, makerNestedAssetData); const makerAssetAmount = new BigNumber(1); const takerAmounts = [new BigNumber(10), new BigNumber(1)]; const takerAssetId = erc721TakerAssetIds[0]; @@ -841,10 +829,7 @@ describe('Exchange core', () => { assetDataUtils.encodeERC20AssetData(zrxToken.address), assetDataUtils.encodeERC721AssetData(erc721Token.address, takerAssetId), ]; - const takerAssetData = assetDataInterface.MultiAsset.getABIEncodedTransactionData( - takerAmounts, - takerNestedAssetData, - ); + const takerAssetData = assetDataUtils.encodeMultiAssetData(takerAmounts, takerNestedAssetData); const takerAssetAmount = new BigNumber(1); signedOrder = await orderFactory.newSignedOrderAsync({ makerAssetData, @@ -900,10 +885,7 @@ describe('Exchange core', () => { assetDataUtils.encodeERC20AssetData(erc20TokenA.address), assetDataUtils.encodeERC20AssetData(erc20TokenB.address), ]; - const makerAssetData = assetDataInterface.MultiAsset.getABIEncodedTransactionData( - makerAmounts, - makerNestedAssetData, - ); + const makerAssetData = assetDataUtils.encodeMultiAssetData(makerAmounts, makerNestedAssetData); const makerAssetAmount = new BigNumber(30); const takerAssetData = assetDataUtils.encodeERC20AssetData(zrxToken.address); const takerAssetAmount = new BigNumber(10); @@ -980,10 +962,7 @@ describe('Exchange core', () => { assetDataUtils.encodeERC20AssetData(erc20TokenA.address), assetDataUtils.encodeERC20AssetData(erc20TokenB.address), ]; - const takerAssetData = assetDataInterface.MultiAsset.getABIEncodedTransactionData( - takerAmounts, - takerNestedAssetData, - ); + const takerAssetData = assetDataUtils.encodeMultiAssetData(takerAmounts, takerNestedAssetData); const takerAssetAmount = new BigNumber(30); const makerAssetData = assetDataUtils.encodeERC20AssetData(zrxToken.address); const makerAssetAmount = new BigNumber(10); diff --git a/contracts/test-utils/CHANGELOG.json b/contracts/test-utils/CHANGELOG.json index 6e4682b7e..8ba8d179a 100644 --- a/contracts/test-utils/CHANGELOG.json +++ b/contracts/test-utils/CHANGELOG.json @@ -1,5 +1,14 @@ [ { + "timestamp": 1547040760, + "version": "1.0.3", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "version": "1.0.2", "changes": [ { diff --git a/contracts/test-utils/CHANGELOG.md b/contracts/test-utils/CHANGELOG.md index 716353d05..4732f1746 100644 --- a/contracts/test-utils/CHANGELOG.md +++ b/contracts/test-utils/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.3 - _January 9, 2019_ + + * Dependencies updated + ## v1.0.2 - _December 13, 2018_ * Dependencies updated diff --git a/contracts/test-utils/package.json b/contracts/test-utils/package.json index 18ec8f6a8..2653fc0e4 100644 --- a/contracts/test-utils/package.json +++ b/contracts/test-utils/package.json @@ -1,6 +1,6 @@ { "name": "@0x/contracts-test-utils", - "version": "1.0.2", + "version": "1.0.3", "engines": { "node": ">=6.12" }, @@ -40,17 +40,19 @@ "typescript": "3.0.1" }, "dependencies": { - "@0x/abi-gen": "^1.0.19", - "@0x/dev-utils": "^1.0.21", - "@0x/order-utils": "^3.0.7", - "@0x/sol-compiler": "^1.1.16", - "@0x/sol-cov": "^2.1.16", - "@0x/subproviders": "^2.1.8", + "@0x/sol-coverage": "^1.0.0", + "@0x/sol-profiler": "^1.0.0", + "@0x/sol-trace": "^1.0.0", + "@0x/abi-gen": "^1.0.20", + "@0x/dev-utils": "^1.0.22", + "@0x/order-utils": "^3.1.0", + "@0x/sol-compiler": "^2.0.0", + "@0x/subproviders": "^2.1.9", "@0x/tslint-config": "^2.0.0", - "@0x/types": "^1.4.1", + "@0x/types": "^1.5.0", "@0x/typescript-typings": "^3.0.6", - "@0x/utils": "^2.0.8", - "@0x/web3-wrapper": "^3.2.1", + "@0x/utils": "^2.1.1", + "@0x/web3-wrapper": "^3.2.2", "@types/bn.js": "^4.11.0", "@types/ethereumjs-abi": "^0.6.0", "@types/js-combinatorics": "^0.5.29", diff --git a/contracts/test-utils/src/coverage.ts b/contracts/test-utils/src/coverage.ts index 5becfa1b6..f82288eec 100644 --- a/contracts/test-utils/src/coverage.ts +++ b/contracts/test-utils/src/coverage.ts @@ -1,5 +1,5 @@ import { devConstants } from '@0x/dev-utils'; -import { CoverageSubprovider, SolCompilerArtifactAdapter } from '@0x/sol-cov'; +import { CoverageSubprovider, SolCompilerArtifactAdapter } from '@0x/sol-coverage'; import * as _ from 'lodash'; let coverageSubprovider: CoverageSubprovider; diff --git a/contracts/test-utils/src/profiler.ts b/contracts/test-utils/src/profiler.ts index 2c7c1d66c..7f51c384f 100644 --- a/contracts/test-utils/src/profiler.ts +++ b/contracts/test-utils/src/profiler.ts @@ -1,5 +1,5 @@ import { devConstants } from '@0x/dev-utils'; -import { ProfilerSubprovider, SolCompilerArtifactAdapter } from '@0x/sol-cov'; +import { ProfilerSubprovider, SolCompilerArtifactAdapter } from '@0x/sol-profiler'; import * as _ from 'lodash'; let profilerSubprovider: ProfilerSubprovider; diff --git a/contracts/test-utils/src/revert_trace.ts b/contracts/test-utils/src/revert_trace.ts index 3f74fd28b..3a5778859 100644 --- a/contracts/test-utils/src/revert_trace.ts +++ b/contracts/test-utils/src/revert_trace.ts @@ -1,5 +1,5 @@ import { devConstants } from '@0x/dev-utils'; -import { RevertTraceSubprovider, SolCompilerArtifactAdapter } from '@0x/sol-cov'; +import { RevertTraceSubprovider, SolCompilerArtifactAdapter } from '@0x/sol-trace'; import * as _ from 'lodash'; let revertTraceSubprovider: RevertTraceSubprovider; diff --git a/contracts/tokens/CHANGELOG.json b/contracts/tokens/CHANGELOG.json index 19ac770af..50872eb07 100644 --- a/contracts/tokens/CHANGELOG.json +++ b/contracts/tokens/CHANGELOG.json @@ -1,5 +1,14 @@ [ { + "timestamp": 1547040760, + "version": "1.0.3", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "timestamp": 1544741676, "version": "1.0.2", "changes": [ diff --git a/contracts/tokens/CHANGELOG.md b/contracts/tokens/CHANGELOG.md index 716353d05..4732f1746 100644 --- a/contracts/tokens/CHANGELOG.md +++ b/contracts/tokens/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.3 - _January 9, 2019_ + + * Dependencies updated + ## v1.0.2 - _December 13, 2018_ * Dependencies updated diff --git a/contracts/tokens/README.md b/contracts/tokens/README.md index 9c4106d41..2d1db92f0 100644 --- a/contracts/tokens/README.md +++ b/contracts/tokens/README.md @@ -6,10 +6,10 @@ Token smart contracts that are used in the 0x protocol. Addresses of the deploye Token contracts that make up and interact with version 2.0.0 of the protocol can be found in the [contracts](./contracts) directory. The contents of this directory are broken down into the following subdirectories: -* [tokens](./contracts/tokens) - * This directory contains implementations of different tokens and token standards, including [wETH](https://weth.io/), ZRX, [ERC20](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md), and [ERC721](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md). -* [test](./contracts/test) - * This directory contains mocks and other contracts that are used solely for testing contracts within the other directories. +- [tokens](./contracts/tokens) + - This directory contains implementations of different tokens and token standards, including [wETH](https://weth.io/), ZRX, [ERC20](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md), and [ERC721](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md). +- [test](./contracts/test) + - This directory contains mocks and other contracts that are used solely for testing contracts within the other directories. ## Bug bounty diff --git a/contracts/tokens/package.json b/contracts/tokens/package.json index 79afc4820..31bf8f7cc 100644 --- a/contracts/tokens/package.json +++ b/contracts/tokens/package.json @@ -1,6 +1,6 @@ { "name": "@0x/contracts-tokens", - "version": "1.0.2", + "version": "1.0.3", "engines": { "node": ">=6.12" }, @@ -44,12 +44,11 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/contracts/tokens/README.md", "devDependencies": { - "@0x/abi-gen": "^1.0.19", - "@0x/contracts-test-utils": "^1.0.2", - "@0x/dev-utils": "^1.0.21", - "@0x/sol-compiler": "^1.1.16", - "@0x/sol-cov": "^2.1.16", - "@0x/subproviders": "^2.1.8", + "@0x/abi-gen": "^1.0.20", + "@0x/contracts-test-utils": "^1.0.3", + "@0x/dev-utils": "^1.0.22", + "@0x/sol-compiler": "^2.0.0", + "@0x/subproviders": "^2.1.9", "@0x/tslint-config": "^2.0.0", "@types/bn.js": "^4.11.0", "@types/lodash": "4.14.104", @@ -64,23 +63,22 @@ "mocha": "^4.1.0", "npm-run-all": "^4.1.2", "shx": "^0.2.2", - "solc": "^0.4.24", "solhint": "^1.4.1", "tslint": "5.11.0", "typescript": "3.0.1", "yargs": "^10.0.3" }, "dependencies": { - "@0x/base-contract": "^3.0.10", - "@0x/contracts-interfaces": "^1.0.2", - "@0x/contracts-libs": "^1.0.2", - "@0x/contracts-multisig": "^1.0.2", - "@0x/contracts-utils": "^1.0.2", - "@0x/order-utils": "^3.0.7", - "@0x/types": "^1.4.1", + "@0x/base-contract": "^3.0.11", + "@0x/contracts-interfaces": "^1.0.3", + "@0x/contracts-libs": "^1.0.3", + "@0x/contracts-multisig": "^1.0.3", + "@0x/contracts-utils": "^1.0.3", + "@0x/order-utils": "^3.1.0", + "@0x/types": "^1.5.0", "@0x/typescript-typings": "^3.0.6", - "@0x/utils": "^2.0.8", - "@0x/web3-wrapper": "^3.2.1", + "@0x/utils": "^2.1.1", + "@0x/web3-wrapper": "^3.2.2", "@types/js-combinatorics": "^0.5.29", "bn.js": "^4.11.8", "ethereum-types": "^1.1.4", diff --git a/contracts/tokens/src/artifacts/index.ts b/contracts/tokens/src/artifacts/index.ts index 63b808748..977d01c3e 100644 --- a/contracts/tokens/src/artifacts/index.ts +++ b/contracts/tokens/src/artifacts/index.ts @@ -22,6 +22,7 @@ import * as UnlimitedAllowanceToken_v1 from '../../generated-artifacts/Unlimited import * as WETH9 from '../../generated-artifacts/WETH9.json'; import * as ZRXToken from '../../generated-artifacts/ZRXToken.json'; +// tslint:disable:no-unnecessary-type-assertion export const artifacts = { DummyERC20Token: DummyERC20Token as ContractArtifact, DummyMultipleReturnERC20Token: DummyMultipleReturnERC20Token as ContractArtifact, diff --git a/contracts/utils/CHANGELOG.json b/contracts/utils/CHANGELOG.json index 19ac770af..50872eb07 100644 --- a/contracts/utils/CHANGELOG.json +++ b/contracts/utils/CHANGELOG.json @@ -1,5 +1,14 @@ [ { + "timestamp": 1547040760, + "version": "1.0.3", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "timestamp": 1544741676, "version": "1.0.2", "changes": [ diff --git a/contracts/utils/CHANGELOG.md b/contracts/utils/CHANGELOG.md index 716353d05..4732f1746 100644 --- a/contracts/utils/CHANGELOG.md +++ b/contracts/utils/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.3 - _January 9, 2019_ + + * Dependencies updated + ## v1.0.2 - _December 13, 2018_ * Dependencies updated diff --git a/contracts/utils/README.md b/contracts/utils/README.md index e7c7b49ff..2f872ddb5 100644 --- a/contracts/utils/README.md +++ b/contracts/utils/README.md @@ -6,10 +6,10 @@ Smart contracts utils used in the 0x protocol. Contracts can be found in the [contracts](./contracts) directory. The contents of this directory are broken down into the following subdirectories: -* [utils](./contracts/utils) - * This directory contains libraries and utils. -* [test](./contracts/test) - * This directory contains mocks and other contracts that are used solely for testing contracts within the other directories. +- [utils](./contracts/utils) + - This directory contains libraries and utils. +- [test](./contracts/test) + - This directory contains mocks and other contracts that are used solely for testing contracts within the other directories. ## Contributing diff --git a/contracts/utils/package.json b/contracts/utils/package.json index cf94af0f6..732556f34 100644 --- a/contracts/utils/package.json +++ b/contracts/utils/package.json @@ -1,6 +1,6 @@ { "name": "@0x/contracts-utils", - "version": "1.0.2", + "version": "1.0.3", "engines": { "node": ">=6.12" }, @@ -44,12 +44,11 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/contracts/utils/README.md", "devDependencies": { - "@0x/abi-gen": "^1.0.19", - "@0x/contracts-test-utils": "^1.0.2", - "@0x/dev-utils": "^1.0.21", - "@0x/sol-compiler": "^1.1.16", - "@0x/sol-cov": "^2.1.16", - "@0x/subproviders": "^2.1.8", + "@0x/abi-gen": "^1.0.20", + "@0x/contracts-test-utils": "^1.0.3", + "@0x/dev-utils": "^1.0.22", + "@0x/sol-compiler": "^2.0.0", + "@0x/subproviders": "^2.1.9", "@0x/tslint-config": "^2.0.0", "@types/bn.js": "^4.11.0", "@types/lodash": "4.14.104", @@ -65,20 +64,19 @@ "mocha": "^4.1.0", "npm-run-all": "^4.1.2", "shx": "^0.2.2", - "solc": "^0.4.24", "solhint": "^1.4.1", "tslint": "5.11.0", "typescript": "3.0.1", "yargs": "^10.0.3" }, "dependencies": { - "@0x/base-contract": "^3.0.10", - "@0x/contracts-multisig": "^1.0.2", - "@0x/order-utils": "^3.0.7", - "@0x/types": "^1.4.1", + "@0x/base-contract": "^3.0.11", + "@0x/contracts-multisig": "^1.0.3", + "@0x/order-utils": "^3.1.0", + "@0x/types": "^1.5.0", "@0x/typescript-typings": "^3.0.6", - "@0x/utils": "^2.0.8", - "@0x/web3-wrapper": "^3.2.1", + "@0x/utils": "^2.1.1", + "@0x/web3-wrapper": "^3.2.2", "ethereum-types": "^1.1.4", "ethereumjs-util": "^5.1.1", "lodash": "^4.17.5" |