Refactor our extensions package

This commit is contained in:
Leonid Logvinov 2018-12-10 10:53:25 -08:00
parent b88ff0a19f
commit 924c2705b2
No known key found for this signature in database
GPG Key ID: 0DD294BFDE8C95D4
42 changed files with 304 additions and 304 deletions

View File

@ -44,6 +44,7 @@ jobs:
- run: yarn wsrun test:circleci @0x/contracts-utils
- run: yarn wsrun test:circleci @0x/contracts-libs
- run: yarn wsrun test:circleci @0x/contracts-tokens
- run: yarn wsrun test:circleci @0x/contracts-extensions
- run: yarn wsrun test:circleci @0x/contracts-core
test-contracts-geth:
docker:
@ -60,6 +61,7 @@ jobs:
- run: TEST_PROVIDER=geth yarn wsrun test @0x/contracts-utils
- run: TEST_PROVIDER=geth yarn wsrun test @0x/contracts-libs
- run: TEST_PROVIDER=geth yarn wsrun test @0x/contracts-tokens
- run: TEST_PROVIDER=geth yarn wsrun test @0x/contracts-extensions
- run: TEST_PROVIDER=geth yarn wsrun test @0x/contracts-core
test-publish:
resource_class: medium+

2
.gitignore vendored
View File

@ -86,6 +86,7 @@ contracts/libs/generated-artifacts/
contracts/interfaces/generated-artifacts/
contracts/tokens/generated-artifacts/
contracts/examples/generated-artifacts/
contracts/extensions/generated-artifacts/
packages/sol-cov/test/fixtures/artifacts/
packages/metacoin/artifacts/
@ -98,6 +99,7 @@ contracts/libs/generated-wrappers/
contracts/interfaces/generated-wrappers/
contracts/tokens/generated-wrappers/
contracts/examples/generated-wrappers/
contracts/extensions/generated-wrappers/
packages/metacoin/src/contract_wrappers
# solc-bin in sol-compiler

View File

@ -8,8 +8,6 @@ Contracts that make up and interact with version 2.0.0 of the protocol can be fo
* [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).
* [extensions](./contracts/extensions)
* This directory contains contracts that interact with the 2.0.0 contracts and will be used in production, such as the [Forwarder](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/forwarder-specification.md) contract.
* [test](./contracts/test)
* This directory contains mocks and other contracts that are used solely for testing contracts within the other directories.

View File

@ -20,14 +20,11 @@
},
"contracts": [
"AssetProxyOwner",
"DutchAuction",
"ERC20Proxy",
"ERC721Proxy",
"Exchange",
"Forwarder",
"MixinAuthorizable",
"MultiAssetProxy",
"OrderValidator",
"TestAssetProxyOwner",
"TestAssetProxyDispatcher",
"TestExchangeInternals",

View File

@ -33,7 +33,7 @@
"lint-contracts": "solhint contracts/**/**/**/**/*.sol"
},
"config": {
"abis": "generated-artifacts/@(AssetProxyOwner|DutchAuction|ERC20Proxy|ERC721Proxy|Forwarder|Exchange|MixinAuthorizable|MultiAssetProxy|OrderValidator|TestAssetProxyOwner|TestAssetProxyDispatcher|TestExchangeInternals|TestStaticCallReceiver).json"
"abis": "generated-artifacts/@(AssetProxyOwner|ERC20Proxy|ERC721Proxy|Exchange|MixinAuthorizable|MultiAssetProxy|TestSignatureValidator|TestAssetProxyOwner|TestAssetProxyDispatcher|TestExchangeInternals|TestStaticCallReceiver).json"
},
"repository": {
"type": "git",

View File

@ -1,14 +1,11 @@
import { ContractArtifact } from 'ethereum-types';
import * as AssetProxyOwner from '../../generated-artifacts/AssetProxyOwner.json';
import * as DutchAuction from '../../generated-artifacts/DutchAuction.json';
import * as ERC20Proxy from '../../generated-artifacts/ERC20Proxy.json';
import * as ERC721Proxy from '../../generated-artifacts/ERC721Proxy.json';
import * as Exchange from '../../generated-artifacts/Exchange.json';
import * as Forwarder from '../../generated-artifacts/Forwarder.json';
import * as MixinAuthorizable from '../../generated-artifacts/MixinAuthorizable.json';
import * as MultiAssetProxy from '../../generated-artifacts/MultiAssetProxy.json';
import * as OrderValidator from '../../generated-artifacts/OrderValidator.json';
import * as TestAssetProxyDispatcher from '../../generated-artifacts/TestAssetProxyDispatcher.json';
import * as TestAssetProxyOwner from '../../generated-artifacts/TestAssetProxyOwner.json';
import * as TestExchangeInternals from '../../generated-artifacts/TestExchangeInternals.json';
@ -17,14 +14,11 @@ import * as TestStaticCallReceiver from '../../generated-artifacts/TestStaticCal
export const artifacts = {
AssetProxyOwner: AssetProxyOwner as ContractArtifact,
DutchAuction: DutchAuction as ContractArtifact,
ERC20Proxy: ERC20Proxy as ContractArtifact,
ERC721Proxy: ERC721Proxy as ContractArtifact,
Exchange: Exchange as ContractArtifact,
Forwarder: Forwarder as ContractArtifact,
MixinAuthorizable: MixinAuthorizable as ContractArtifact,
MultiAssetProxy: MultiAssetProxy as ContractArtifact,
OrderValidator: OrderValidator as ContractArtifact,
TestAssetProxyDispatcher: TestAssetProxyDispatcher as ContractArtifact,
TestAssetProxyOwner: TestAssetProxyOwner as ContractArtifact,
TestExchangeInternals: TestExchangeInternals as ContractArtifact,

View File

@ -1,2 +1,3 @@
export * from './artifacts';
export * from './wrappers';
export * from '../test/utils';

View File

@ -1,11 +1,8 @@
export * from '../../generated-wrappers/asset_proxy_owner';
export * from '../../generated-wrappers/dutch_auction';
export * from '../../generated-wrappers/erc20_proxy';
export * from '../../generated-wrappers/erc721_proxy';
export * from '../../generated-wrappers/exchange';
export * from '../../generated-wrappers/forwarder';
export * from '../../generated-wrappers/mixin_authorizable';
export * from '../../generated-wrappers/order_validator';
export * from '../../generated-wrappers/test_asset_proxy_dispatcher';
export * from '../../generated-wrappers/test_asset_proxy_owner';
export * from '../../generated-wrappers/test_exchange_internals';

View File

@ -1,3 +1,5 @@
import { ValidatorContract, WalletContract } from '@0x/contracts-examples';
import { artifacts as examplesArtifacts } from '@0x/contracts-examples';
import {
addressUtils,
chaiSetup,
@ -22,8 +24,6 @@ import {
TestSignatureValidatorContract,
TestSignatureValidatorSignatureValidatorApprovalEventArgs,
TestStaticCallReceiverContract,
ValidatorContract,
WalletContract,
} from '../../src';
chaiSetup.configure();
@ -62,13 +62,13 @@ describe('MixinSignatureValidator', () => {
txDefaults,
);
testWallet = await WalletContract.deployFrom0xArtifactAsync(
artifacts.Wallet,
examplesArtifacts.Wallet,
provider,
txDefaults,
signerAddress,
);
testValidator = await ValidatorContract.deployFrom0xArtifactAsync(
artifacts.Validator,
examplesArtifacts.Validator,
provider,
txDefaults,
signerAddress,

View File

@ -1,3 +1,4 @@
import { artifacts as examplesArtifacts, ExchangeWrapperContract, WhitelistContract } from '@0x/contracts-examples';
import {
chaiSetup,
constants,
@ -21,8 +22,6 @@ import * as _ from 'lodash';
import { ERC20ProxyContract } from '../../generated-wrappers/erc20_proxy';
import { ExchangeContract } from '../../generated-wrappers/exchange';
import { ExchangeWrapperContract } from '../../generated-wrappers/exchange_wrapper';
import { WhitelistContract } from '../../generated-wrappers/whitelist';
import { artifacts } from '../../src/artifacts';
import { ERC20Wrapper } from '../utils/erc20_wrapper';
import { ExchangeWrapper } from '../utils/exchange_wrapper';
@ -222,7 +221,7 @@ describe('Exchange transactions', () => {
before(async () => {
exchangeWrapperContract = await ExchangeWrapperContract.deployFrom0xArtifactAsync(
artifacts.ExchangeWrapper,
examplesArtifacts.ExchangeWrapper,
provider,
txDefaults,
exchange.address,
@ -336,7 +335,7 @@ describe('Exchange transactions', () => {
before(async () => {
whitelist = await WhitelistContract.deployFrom0xArtifactAsync(
artifacts.Whitelist,
examplesArtifacts.Whitelist,
provider,
txDefaults,
exchange.address,

View File

@ -1,260 +0,0 @@
// import { ECSignature, SignedOrder, ZeroEx } from '0x.js';
// import { BlockchainLifecycle, devConstants, web3Factory } from '@0x/dev-utils';
// import { ExchangeContractErrs } from 'ethereum-types';
// import { BigNumber } from '@0x/utils';
// import { Web3Wrapper } from '@0x/web3-wrapper';
// import * as chai from 'chai';
// import ethUtil = require('ethereumjs-util');
// import * as Web3 from 'web3';
// import { AccountLevelsContract } from '../../src/generated_contract_wrappers/account_levels';
// import { ArbitrageContract } from '../../src/generated_contract_wrappers/arbitrage';
// import { DummyTokenContract } from '../../src/generated_contract_wrappers/dummy_token';
// import { EtherDeltaContract } from '../../src/generated_contract_wrappers/ether_delta';
// import { ExchangeContract } from '../../src/generated_contract_wrappers/exchange';
// import { TokenTransferProxyContract } from '../../src/generated_contract_wrappers/token_transfer_proxy';
// import { artifacts } from '../../util/artifacts';
// import { Balances } from '../../util/balances';
// import { constants } from '../../util/constants';
// import { crypto } from '../../util/crypto';
// import { ExchangeWrapper } from '../../util/exchange_wrapper';
// import { OrderFactory } from '../../util/order_factory';
// import { BalancesByOwner, ContractName } from '../../util/types';
// import { chaiSetup } from '../utils/chai_setup';
// import { provider, txDefaults, web3Wrapper } from '../utils/web3_wrapper';
// chaiSetup.configure();
// const expect = chai.expect;
// const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
// describe('Arbitrage', () => {
// let coinbase: string;
// let maker: string;
// let edMaker: string;
// let edFrontRunner: string;
// let amountGet: BigNumber;
// let amountGive: BigNumber;
// let makerTokenAmount: BigNumber;
// let takerTokenAmount: BigNumber;
// const feeRecipient = constants.NULL_ADDRESS;
// const INITIAL_BALANCE = ZeroEx.toBaseUnitAmount(new BigNumber(10000), 18);
// const INITIAL_ALLOWANCE = ZeroEx.toBaseUnitAmount(new BigNumber(10000), 18);
// let weth: DummyTokenContract;
// let zrx: DummyTokenContract;
// let arbitrage: ArbitrageContract;
// let etherDelta: EtherDeltaContract;
// let signedOrder: SignedOrder;
// let exWrapper: ExchangeWrapper;
// let orderFactory: OrderFactory;
// let zeroEx: ZeroEx;
// // From a bird's eye view - we create two orders.
// // 0x order of 1 ZRX (maker) for 1 WETH (taker)
// // ED order of 2 WETH (tokenGive) for 1 ZRX (tokenGet)
// // And then we do an atomic arbitrage between them which gives us 1 WETH.
// before(async () => {
// const accounts = await web3Wrapper.getAvailableAddressesAsync();
// [coinbase, maker, edMaker, edFrontRunner] = accounts;
// weth = await DummyTokenContract.deployFrom0xArtifactAsync(
// artifacts.DummyToken,
// provider,
// txDefaults,
// constants.DUMMY_TOKEN_NAME,
// constants.DUMMY_TOKEN_SYMBOL,
// constants.DUMMY_TOKEN_DECIMALS,
// constants.DUMMY_TOKEN_TOTAL_SUPPLY,
// );
// zrx = await DummyTokenContract.deployFrom0xArtifactAsync(
// artifacts.DummyToken,
// provider,
// txDefaults,
// constants.DUMMY_TOKEN_NAME,
// constants.DUMMY_TOKEN_SYMBOL,
// constants.DUMMY_TOKEN_DECIMALS,
// constants.DUMMY_TOKEN_TOTAL_SUPPLY,
// );
// const accountLevels = await AccountLevelsContract.deployFrom0xArtifactAsync(
// artifacts.AccountLevels,
// provider,
// txDefaults,
// );
// const edAdminAddress = accounts[0];
// const edMakerFee = new BigNumber(0);
// const edTakerFee = new BigNumber(0);
// const edFeeRebate = new BigNumber(0);
// etherDelta = await EtherDeltaContract.deployFrom0xArtifactAsync(
// artifacts.EtherDelta,
// provider,
// txDefaults,
// edAdminAddress,
// feeRecipient,
// accountLevels.address,
// edMakerFee,
// edTakerFee,
// edFeeRebate,
// );
// const tokenTransferProxy = await TokenTransferProxyContract.deployFrom0xArtifactAsync(
// artifacts.TokenTransferProxy,
// provider,
// txDefaults,
// );
// const exchange = await ExchangeContract.deployFrom0xArtifactAsync(
// artifacts.Exchange,
// provider,
// txDefaults,
// zrx.address,
// tokenTransferProxy.address,
// );
// await tokenTransferProxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, { from: accounts[0] });
// zeroEx = new ZeroEx(provider, {
// exchangeContractAddress: exchange.address,
// networkId: constants.TESTRPC_NETWORK_ID,
// });
// exWrapper = new ExchangeWrapper(exchange, provider);
// makerTokenAmount = ZeroEx.toBaseUnitAmount(new BigNumber(1), 18);
// takerTokenAmount = makerTokenAmount;
// const defaultOrderParams = {
// exchangeContractAddress: exchange.address,
// maker,
// feeRecipient,
// makerTokenAddress: zrx.address,
// takerTokenAddress: weth.address,
// makerTokenAmount,
// takerTokenAmount,
// makerFee: new BigNumber(0),
// takerFee: new BigNumber(0),
// };
// orderFactory = new OrderFactory(zeroEx, defaultOrderParams);
// arbitrage = await ArbitrageContract.deployFrom0xArtifactAsync(
// artifacts.Arbitrage,
// provider,
// txDefaults,
// exchange.address,
// etherDelta.address,
// tokenTransferProxy.address,
// );
// // Enable arbitrage and withdrawals of tokens
// await arbitrage.setAllowances.sendTransactionAsync(weth.address, { from: coinbase });
// await arbitrage.setAllowances.sendTransactionAsync(zrx.address, { from: coinbase });
// // Give some tokens to arbitrage contract
// await weth.setBalance.sendTransactionAsync(arbitrage.address, takerTokenAmount, { from: coinbase });
// // Fund the maker on exchange side
// await zrx.setBalance.sendTransactionAsync(maker, makerTokenAmount, { from: coinbase });
// // Set the allowance for the maker on Exchange side
// await zrx.approve.sendTransactionAsync(tokenTransferProxy.address, INITIAL_ALLOWANCE, { from: maker });
// amountGive = ZeroEx.toBaseUnitAmount(new BigNumber(2), 18);
// // Fund the maker on EtherDelta side
// await weth.setBalance.sendTransactionAsync(edMaker, amountGive, { from: coinbase });
// // Set the allowance for the maker on EtherDelta side
// await weth.approve.sendTransactionAsync(etherDelta.address, INITIAL_ALLOWANCE, { from: edMaker });
// // Deposit maker funds into EtherDelta
// await etherDelta.depositToken.sendTransactionAsync(weth.address, amountGive, { from: edMaker });
// amountGet = makerTokenAmount;
// // Fund the front runner on EtherDelta side
// await zrx.setBalance.sendTransactionAsync(edFrontRunner, amountGet, { from: coinbase });
// // Set the allowance for the front-runner on EtherDelta side
// await zrx.approve.sendTransactionAsync(etherDelta.address, INITIAL_ALLOWANCE, { from: edFrontRunner });
// // Deposit front runner funds into EtherDelta
// await etherDelta.depositToken.sendTransactionAsync(zrx.address, amountGet, { from: edFrontRunner });
// });
// beforeEach(async () => {
// await blockchainLifecycle.startAsync();
// });
// afterEach(async () => {
// await blockchainLifecycle.revertAsync();
// });
// describe('makeAtomicTrade', () => {
// let addresses: string[];
// let values: BigNumber[];
// let v: number[];
// let r: string[];
// let s: string[];
// let tokenGet: string;
// let tokenGive: string;
// let expires: BigNumber;
// let nonce: BigNumber;
// let edSignature: ECSignature;
// before(async () => {
// signedOrder = await orderFactory.newSignedOrderAsync();
// tokenGet = zrx.address;
// tokenGive = weth.address;
// const blockNumber = await web3Wrapper.getBlockNumberAsync();
// const ED_ORDER_EXPIRATION_IN_BLOCKS = 10;
// expires = new BigNumber(blockNumber + ED_ORDER_EXPIRATION_IN_BLOCKS);
// nonce = new BigNumber(42);
// const edOrderHash = `0x${crypto
// .solSHA256([etherDelta.address, tokenGet, amountGet, tokenGive, amountGive, expires, nonce])
// .toString('hex')}`;
// const shouldAddPersonalMessagePrefix = false;
// edSignature = await zeroEx.signOrderHashAsync(edOrderHash, edMaker, shouldAddPersonalMessagePrefix);
// addresses = [
// signedOrder.maker,
// signedOrder.taker,
// signedOrder.makerTokenAddress,
// signedOrder.takerTokenAddress,
// signedOrder.feeRecipient,
// edMaker,
// ];
// const fillTakerTokenAmount = takerTokenAmount;
// const edFillAmount = makerTokenAmount;
// values = [
// signedOrder.makerTokenAmount,
// signedOrder.takerTokenAmount,
// signedOrder.makerFee,
// signedOrder.takerFee,
// signedOrder.expirationUnixTimestampSec,
// signedOrder.salt,
// fillTakerTokenAmount,
// amountGet,
// amountGive,
// expires,
// nonce,
// edFillAmount,
// ];
// v = [signedOrder.ecSignature.v, edSignature.v];
// r = [signedOrder.ecSignature.r, edSignature.r];
// s = [signedOrder.ecSignature.s, edSignature.s];
// });
// it('should successfully execute the arbitrage if not front-runned', async () => {
// const txHash = await arbitrage.makeAtomicTrade.sendTransactionAsync(addresses, values, v, r, s, {
// from: coinbase,
// });
// const res = await zeroEx.awaitTransactionMinedAsync(txHash);
// const postBalance = await weth.balanceOf.callAsync(arbitrage.address);
// expect(postBalance).to.be.bignumber.equal(amountGive);
// });
// it('should fail and revert if front-runned', async () => {
// const preBalance = await weth.balanceOf.callAsync(arbitrage.address);
// // Front-running transaction
// await etherDelta.trade.sendTransactionAsync(
// tokenGet,
// amountGet,
// tokenGive,
// amountGive,
// expires,
// nonce,
// edMaker,
// edSignature.v,
// edSignature.r,
// edSignature.s,
// amountGet,
// { from: edFrontRunner },
// );
// // tslint:disable-next-line:await-promise
// await expect(
// arbitrage.makeAtomicTrade.sendTransactionAsync(addresses, values, v, r, s, { from: coinbase }),
// ).to.be.rejectedWith(constants.REVERT);
// const postBalance = await weth.balanceOf.callAsync(arbitrage.address);
// expect(preBalance).to.be.bignumber.equal(postBalance);
// });
// });
// });

View File

@ -0,0 +1,3 @@
export * from './exchange_wrapper';
export * from './erc20_wrapper';
export * from './erc721_wrapper';

View File

@ -8,14 +8,11 @@
"include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*"],
"files": [
"./generated-artifacts/AssetProxyOwner.json",
"./generated-artifacts/DutchAuction.json",
"./generated-artifacts/ERC20Proxy.json",
"./generated-artifacts/ERC721Proxy.json",
"./generated-artifacts/Exchange.json",
"./generated-artifacts/Forwarder.json",
"./generated-artifacts/MixinAuthorizable.json",
"./generated-artifacts/MultiAssetProxy.json",
"./generated-artifacts/OrderValidator.json",
"./generated-artifacts/TestAssetProxyDispatcher.json",
"./generated-artifacts/TestAssetProxyOwner.json",
"./generated-artifacts/TestExchangeInternals.json",

View File

@ -0,0 +1,20 @@
{
"extends": "default",
"rules": {
"avoid-low-level-calls": false,
"avoid-tx-origin": "warn",
"bracket-align": false,
"code-complexity": false,
"const-name-snakecase": "error",
"expression-indent": "error",
"function-max-lines": false,
"func-order": "error",
"indent": ["error", 4],
"max-line-length": ["warn", 160],
"no-inline-assembly": false,
"quotes": ["error", "double"],
"separate-by-one-line-in-contract": "error",
"space-after-comma": "error",
"statement-indent": "error"
}
}

View File

@ -0,0 +1,69 @@
## Contract extensions
Smart contracts that implement extensions for the 0x protocol.
## Usage
Contract extensions of the protocol can be found in the [contracts](./contracts) directory. This directory contains contracts that interact with the 2.0.0 contracts and will be used in production, such as the [Forwarder](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/forwarder-specification.md) contract.
## Bug bounty
A bug bounty for the 2.0.0 contracts is ongoing! Instructions can be found [here](https://0xproject.com/wiki#Bug-Bounty).
## Contributing
We strongly recommend that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository.
For proposals regarding the 0x protocol's smart contract architecture, message format, or additional functionality, go to the [0x Improvement Proposals (ZEIPs)](https://github.com/0xProject/ZEIPs) repository and follow the contribution guidelines provided therein.
Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started.
### Install Dependencies
If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them:
```bash
yarn config set workspaces-experimental true
```
Then install dependencies
```bash
yarn install
```
### Build
To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory:
```bash
PKG=@0x/contracts-extensions yarn build
```
Or continuously rebuild on change:
```bash
PKG=@0x/contracts-extensions yarn watch
```
### Clean
```bash
yarn clean
```
### Lint
```bash
yarn lint
```
### Run Tests
```bash
yarn test
```
#### Testing options
Contracts testing options like coverage, profiling, revert traces or backing node choosing - are described [here](../TESTING.md).

View File

@ -0,0 +1,22 @@
{
"artifactsDir": "./generated-artifacts",
"contractsDir": "./contracts",
"compilerSettings": {
"optimizer": {
"enabled": true,
"runs": 1000000
},
"outputSelection": {
"*": {
"*": [
"abi",
"evm.bytecode.object",
"evm.bytecode.sourceMap",
"evm.deployedBytecode.object",
"evm.deployedBytecode.sourceMap"
]
}
}
},
"contracts": ["DutchAuction", "Forwarder", "OrderValidator"]
}

View File

@ -0,0 +1,95 @@
{
"private": true,
"name": "@0x/contracts-extensions",
"version": "1.0.0",
"engines": {
"node": ">=6.12"
},
"description": "Smart contract extensions of 0x protocol",
"main": "lib/src/index.js",
"directories": {
"test": "test"
},
"scripts": {
"build": "yarn pre_build && tsc -b",
"build:ci": "yarn build",
"pre_build": "run-s compile generate_contract_wrappers",
"test": "yarn run_mocha",
"rebuild_and_test": "run-s build test",
"test:coverage": "SOLIDITY_COVERAGE=true run-s build run_mocha coverage:report:text coverage:report:lcov",
"test:profiler": "SOLIDITY_PROFILER=true run-s build run_mocha profiler:report:html",
"test:trace": "SOLIDITY_REVERT_TRACE=true run-s build run_mocha",
"run_mocha":
"mocha --require source-map-support/register --require make-promises-safe 'lib/test/**/*.js' --timeout 100000 --bail --exit",
"compile": "sol-compiler --contracts-dir contracts",
"clean": "shx rm -rf lib generated-artifacts generated-wrappers",
"generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --template ../../node_modules/@0x/abi-gen-templates/contract.handlebars --partials '../../node_modules/@0x/abi-gen-templates/partials/**/*.handlebars' --output generated-wrappers --backend ethers",
"lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
"coverage:report:text": "istanbul report text",
"coverage:report:html": "istanbul report html && open coverage/index.html",
"profiler:report:html": "istanbul report html && open coverage/index.html",
"coverage:report:lcov": "istanbul report lcov",
"test:circleci": "yarn test",
"lint-contracts": "solhint contracts/**/**/**/**/*.sol"
},
"config": {
"abis": "generated-artifacts/@(DutchAuction|Forwarder|OrderValidator).json"
},
"repository": {
"type": "git",
"url": "https://github.com/0xProject/0x-monorepo.git"
},
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/0xProject/0x-monorepo/issues"
},
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/core/README.md",
"devDependencies": {
"@0x/contracts-test-utils": "^1.0.0",
"@0x/abi-gen": "^1.0.17",
"@0x/dev-utils": "^1.0.19",
"@0x/sol-compiler": "^1.1.14",
"@0x/sol-cov": "^2.1.14",
"@0x/subproviders": "^2.1.6",
"@0x/tslint-config": "^1.0.10",
"@types/bn.js": "^4.11.0",
"@types/lodash": "4.14.104",
"@types/node": "*",
"@types/yargs": "^10.0.0",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
"chai-bignumber": "^2.0.1",
"dirty-chai": "^2.0.1",
"make-promises-safe": "^1.1.0",
"ethereumjs-abi": "0.6.5",
"mocha": "^4.1.0",
"npm-run-all": "^4.1.2",
"shx": "^0.2.2",
"solc": "^0.4.24",
"solhint": "^1.2.1",
"tslint": "5.11.0",
"typescript": "3.0.1",
"yargs": "^10.0.3"
},
"dependencies": {
"@0x/base-contract": "^3.0.8",
"@0x/order-utils": "^3.0.4",
"@0x/contracts-utils": "^1.0.0",
"@0x/contracts-core": "^2.1.56",
"@0x/contracts-tokens": "^1.0.0",
"@0x/contracts-libs": "^1.0.0",
"@0x/contracts-interfaces": "^1.0.0",
"@0x/types": "^1.3.0",
"@0x/typescript-typings": "^3.0.4",
"@0x/utils": "^2.0.6",
"@0x/web3-wrapper": "^3.1.6",
"@types/js-combinatorics": "^0.5.29",
"bn.js": "^4.11.8",
"ethereum-types": "^1.1.2",
"ethereumjs-util": "^5.1.1",
"lodash": "^4.17.5"
},
"publishConfig": {
"access": "public"
}
}

View File

@ -0,0 +1,11 @@
import { ContractArtifact } from 'ethereum-types';
import * as DutchAuction from '../../generated-artifacts/DutchAuction.json';
import * as Forwarder from '../../generated-artifacts/Forwarder.json';
import * as OrderValidator from '../../generated-artifacts/OrderValidator.json';
export const artifacts = {
DutchAuction: DutchAuction as ContractArtifact,
Forwarder: Forwarder as ContractArtifact,
OrderValidator: OrderValidator as ContractArtifact,
};

View File

@ -0,0 +1,2 @@
export * from './artifacts';
export * from './wrappers';

View File

@ -0,0 +1,3 @@
export * from '../../generated-wrappers/dutch_auction';
export * from '../../generated-wrappers/forwarder';
export * from '../../generated-wrappers/order_validator';

View File

@ -1,3 +1,10 @@
import {
artifacts as coreArtifacts,
ERC20Wrapper,
ERC721Wrapper,
ExchangeContract,
ExchangeWrapper,
} from '@0x/contracts-core';
import {
chaiSetup,
constants,
@ -27,11 +34,7 @@ import * as ethUtil from 'ethereumjs-util';
import * as _ from 'lodash';
import { DutchAuctionContract } from '../../generated-wrappers/dutch_auction';
import { ExchangeContract } from '../../generated-wrappers/exchange';
import { artifacts } from '../../src/artifacts';
import { ERC20Wrapper } from '../utils/erc20_wrapper';
import { ERC721Wrapper } from '../utils/erc721_wrapper';
import { ExchangeWrapper } from '../utils/exchange_wrapper';
chaiSetup.configure();
const expect = chai.expect;
@ -106,7 +109,7 @@ describe(ContractName.DutchAuction, () => {
const zrxAssetData = assetDataUtils.encodeERC20AssetData(zrxToken.address);
const exchangeInstance = await ExchangeContract.deployFrom0xArtifactAsync(
artifacts.Exchange,
coreArtifacts.Exchange,
provider,
txDefaults,
zrxAssetData,

View File

@ -1,3 +1,10 @@
import {
artifacts as coreArtifacts,
ERC20Wrapper,
ERC721Wrapper,
ExchangeContract,
ExchangeWrapper,
} from '@0x/contracts-core';
import {
chaiSetup,
constants,
@ -25,12 +32,9 @@ import { Web3Wrapper } from '@0x/web3-wrapper';
import * as chai from 'chai';
import { TransactionReceiptWithDecodedLogs } from 'ethereum-types';
import { ExchangeContract } from '../../generated-wrappers/exchange';
import { ForwarderContract } from '../../generated-wrappers/forwarder';
import { artifacts } from '../../src/artifacts';
import { ERC20Wrapper } from '../utils/erc20_wrapper';
import { ERC721Wrapper } from '../utils/erc721_wrapper';
import { ExchangeWrapper } from '../utils/exchange_wrapper';
import { ForwarderWrapper } from '../utils/forwarder_wrapper';
chaiSetup.configure();
@ -104,7 +108,7 @@ describe(ContractName.Forwarder, () => {
wethAssetData = assetDataUtils.encodeERC20AssetData(wethContract.address);
zrxAssetData = assetDataUtils.encodeERC20AssetData(zrxToken.address);
const exchangeInstance = await ExchangeContract.deployFrom0xArtifactAsync(
artifacts.Exchange,
coreArtifacts.Exchange,
provider,
txDefaults,
zrxAssetData,
@ -175,7 +179,7 @@ describe(ContractName.Forwarder, () => {
describe('constructor', () => {
it('should revert if assetProxy is unregistered', async () => {
const exchangeInstance = await ExchangeContract.deployFrom0xArtifactAsync(
artifacts.Exchange,
coreArtifacts.Exchange,
provider,
txDefaults,
zrxAssetData,

View File

@ -1,3 +1,12 @@
import {
artifacts as coreArtifacts,
ERC20ProxyContract,
ERC20Wrapper,
ERC721ProxyContract,
ERC721Wrapper,
ExchangeContract,
ExchangeWrapper,
} from '@0x/contracts-core';
import {
chaiSetup,
constants,
@ -15,14 +24,8 @@ import { BigNumber } from '@0x/utils';
import * as chai from 'chai';
import * as _ from 'lodash';
import { ERC20ProxyContract } from '../../generated-wrappers/erc20_proxy';
import { ERC721ProxyContract } from '../../generated-wrappers/erc721_proxy';
import { ExchangeContract } from '../../generated-wrappers/exchange';
import { OrderValidatorContract } from '../../generated-wrappers/order_validator';
import { artifacts } from '../../src/artifacts';
import { ERC20Wrapper } from '../utils/erc20_wrapper';
import { ERC721Wrapper } from '../utils/erc721_wrapper';
import { ExchangeWrapper } from '../utils/exchange_wrapper';
chaiSetup.configure();
const expect = chai.expect;
@ -78,7 +81,7 @@ describe('OrderValidator', () => {
const zrxAssetData = assetDataUtils.encodeERC20AssetData(zrxToken.address);
exchange = await ExchangeContract.deployFrom0xArtifactAsync(
artifacts.Exchange,
coreArtifacts.Exchange,
provider,
txDefaults,
zrxAssetData,

View File

@ -0,0 +1,17 @@
import { env, EnvVars } from '@0x/dev-utils';
import { coverage, profiler, provider } from '@0x/contracts-test-utils';
before('start web3 provider', () => {
provider.start();
});
after('generate coverage report', async () => {
if (env.parseBoolean(EnvVars.SolidityCoverage)) {
const coverageSubprovider = coverage.getCoverageSubproviderSingleton();
await coverageSubprovider.writeCoverageAsync();
}
if (env.parseBoolean(EnvVars.SolidityProfiler)) {
const profilerSubprovider = profiler.getProfilerSubproviderSingleton();
await profilerSubprovider.writeProfilerOutputAsync();
}
provider.stop();
});

View File

@ -0,0 +1,15 @@
{
"extends": "../../tsconfig",
"compilerOptions": {
"outDir": "lib",
"rootDir": ".",
"resolveJsonModule": true
},
"include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*"],
"files": [
"./generated-artifacts/DutchAuction.json",
"./generated-artifacts/Forwarder.json",
"./generated-artifacts/OrderValidator.json"
],
"exclude": ["./deploy/solc/solc_bin"]
}

View File

@ -0,0 +1,6 @@
{
"extends": ["@0x/tslint-config"],
"rules": {
"custom-no-magic-numbers": false
}
}