aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/contracts')
-rw-r--r--packages/contracts/README.md18
-rw-r--r--packages/contracts/compiler.json39
-rw-r--r--packages/contracts/package.json47
-rw-r--r--packages/contracts/src/contracts/previous/Exchange/Exchange_v1.sol2
-rw-r--r--packages/contracts/src/utils/artifacts.ts48
-rw-r--r--packages/contracts/src/utils/chai_setup.ts (renamed from packages/contracts/test/utils/chai_setup.ts)2
-rw-r--r--packages/contracts/src/utils/constants.ts10
-rw-r--r--packages/contracts/src/utils/crypto.ts2
-rw-r--r--packages/contracts/src/utils/erc20_wrapper.ts33
-rw-r--r--packages/contracts/src/utils/erc721_wrapper.ts31
-rw-r--r--packages/contracts/src/utils/log_decoder.ts11
-rw-r--r--packages/contracts/src/utils/multi_sig_wrapper.ts4
-rw-r--r--packages/contracts/src/utils/token_registry_wrapper.ts8
-rw-r--r--packages/contracts/src/utils/types.ts16
-rw-r--r--packages/contracts/src/utils/web3_wrapper.ts (renamed from packages/contracts/test/utils/web3_wrapper.ts)6
-rw-r--r--packages/contracts/test/asset_proxy/authorizable.ts14
-rw-r--r--packages/contracts/test/asset_proxy/proxies.ts11
-rw-r--r--packages/contracts/test/ether_token.ts17
-rw-r--r--packages/contracts/test/exchange/core.ts26
-rw-r--r--packages/contracts/test/exchange/dispatcher.ts26
-rw-r--r--packages/contracts/test/exchange/libs.ts11
-rw-r--r--packages/contracts/test/exchange/signature_validator.ts17
-rw-r--r--packages/contracts/test/exchange/transactions.ts17
-rw-r--r--packages/contracts/test/exchange/wrapper.ts20
-rw-r--r--packages/contracts/test/libraries/lib_bytes.ts11
-rw-r--r--packages/contracts/test/multi_sig_with_time_lock.ts32
-rw-r--r--packages/contracts/test/multi_sig_with_time_lock_except_remove_auth_addr.ts43
-rw-r--r--packages/contracts/test/token_registry.ts11
-rw-r--r--packages/contracts/test/tutorials/arbitrage.ts191
-rw-r--r--packages/contracts/test/unlimited_allowance_token.ts20
-rw-r--r--packages/contracts/test/utils/deployer.ts18
-rw-r--r--packages/contracts/test/zrx_token.ts11
-rw-r--r--packages/contracts/tsconfig.json9
33 files changed, 410 insertions, 372 deletions
diff --git a/packages/contracts/README.md b/packages/contracts/README.md
index 16e253549..23551b69d 100644
--- a/packages/contracts/README.md
+++ b/packages/contracts/README.md
@@ -34,28 +34,16 @@ yarn install
### Build
-If this is your **first** time building this package, you must first build **all** packages within the monorepo. This is because packages that depend on other packages located inside this monorepo are symlinked when run from **within** the monorepo. This allows you to make changes across multiple packages without first publishing dependent packages to NPM. To build all packages, run the following from the monorepo root directory:
+To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory:
```bash
-yarn lerna:rebuild
+PKG=contracts yarn build
```
Or continuously rebuild on change:
```bash
-yarn dev
-```
-
-You can also build this specific package by running the following from within its directory:
-
-```bash
-yarn build
-```
-
-or continuously rebuild on change:
-
-```bash
-yarn build:watch
+PKG=contracts yarn watch
```
### Clean
diff --git a/packages/contracts/compiler.json b/packages/contracts/compiler.json
new file mode 100644
index 000000000..9b0a1e161
--- /dev/null
+++ b/packages/contracts/compiler.json
@@ -0,0 +1,39 @@
+{
+ "artifactsDir": "../migrations/artifacts/2.0.0",
+ "contractsDir": "src/contracts",
+ "compilerSettings": {
+ "optimizer": {
+ "enabled": true,
+ "runs": 200
+ },
+ "outputSelection": {
+ "*": {
+ "*": [
+ "abi",
+ "evm.bytecode.object",
+ "evm.bytecode.sourceMap",
+ "evm.deployedBytecode.object",
+ "evm.deployedBytecode.sourceMap"
+ ]
+ }
+ }
+ },
+ "contracts": [
+ "DummyERC20Token",
+ "DummyERC721Token",
+ "ERC20Proxy",
+ "ERC721Proxy",
+ "Exchange",
+ "MixinAuthorizable",
+ "MultiSigWallet",
+ "MultiSigWalletWithTimeLock",
+ "MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress",
+ "TestAssetProxyDispatcher",
+ "TestLibBytes",
+ "TestLibs",
+ "TestSignatureValidator",
+ "TokenRegistry",
+ "WETH9",
+ "ZRXToken"
+ ]
+}
diff --git a/packages/contracts/package.json b/packages/contracts/package.json
index 2c5ee872e..b10ed3c44 100644
--- a/packages/contracts/package.json
+++ b/packages/contracts/package.json
@@ -1,28 +1,27 @@
{
"private": true,
"name": "contracts",
- "version": "2.1.25",
+ "version": "2.1.28",
+ "engines": {
+ "node" : ">=6.12"
+ },
"description": "Smart contract components of 0x protocol",
"main": "index.js",
"directories": {
"test": "test"
},
"scripts": {
- "build:watch": "tsc -w",
- "prebuild": "run-s clean compile copy_artifacts generate_contract_wrappers",
- "copy_artifacts": "copyfiles -u 4 '../migrations/src/artifacts/**/*' ./lib/src/artifacts;",
+ "watch": "tsc -w",
+ "prebuild": "run-s clean copy_artifacts generate_contract_wrappers",
+ "copy_artifacts": "copyfiles -u 4 '../migrations/artifacts/2.0.0/**/*' ./lib/src/artifacts;",
"build": "tsc",
"test": "run-s build run_mocha",
"test:coverage": "SOLIDITY_COVERAGE=true run-s build run_mocha coverage:report:text coverage:report:lcov",
"run_mocha": "mocha 'lib/test/**/*.js' --timeout 100000 --bail --exit",
- "compile:comment":
- "Yarn workspaces do not link binaries correctly so we need to reference them directly https://github.com/yarnpkg/yarn/issues/3846",
- "compile":
- "node ../deployer/lib/src/cli.js compile --contracts ${npm_package_config_contracts} --should-optimize true --contracts-dir src/contracts --artifacts-dir ../migrations/src/artifacts",
- "clean": "shx rm -rf ./lib ./src/contract_wrappers/generated",
- "generate_contract_wrappers":
- "node ../abi-gen/lib/index.js --abis ${npm_package_config_abis} --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/contract_wrappers/generated --backend ethers && prettier --write 'src/contract_wrappers/generated/**.ts'",
- "lint": "tslint --project . 'migrations/**/*.ts' 'test/**/*.ts' 'util/**/*.ts' 'deploy/**/*.ts'",
+ "compile": "sol-compiler",
+ "clean": "shx rm -rf lib src/contract_wrappers/generated",
+ "generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/contract_wrappers/generated --backend ethers && prettier --write 'src/contract_wrappers/generated/**.ts'",
+ "lint": "tslint --project .",
"coverage:report:text": "istanbul report text",
"coverage:report:html": "istanbul report html && open coverage/index.html",
"coverage:report:lcov": "istanbul report lcov",
@@ -30,9 +29,7 @@
},
"config": {
"abis":
- "../migrations/src/artifacts/@(DummyERC20Token|Exchange|TokenRegistry|MultiSigWallet|MultiSigWalletWithTimeLock|MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress|TokenRegistry|ZRXToken|TestAssetProxyDispatcher|TestLibs|TestSignatureValidator|ERC20Proxy|ERC721Proxy|DummyERC721Token|TestLibBytes|MixinAuthorizable).json",
- "contracts":
- "Exchange,DummyERC20Token,ZRXToken,WETH9,MultiSigWallet,MultiSigWalletWithTimeLock,MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress,TokenRegistry,TestAssetProxyDispatcher,TestLibs,TestSignatureValidator,ERC20Proxy,ERC721Proxy,DummyERC721Token,TestLibBytes,MixinAuthorizable"
+ "../migrations/artifacts/2.0.0/@(DummyERC20Token|DummyERC721Token|ERC20Proxy|ERC721Proxy|Exchange|MixinAuthorizable|MultiSigWallet|MultiSigWalletWithTimeLock|MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress|TestAssetProxyDispatcher|TestLibBytes|TestLibs|TestSignatureValidator|TokenRegistry|WETH9|ZRXToken).json"
},
"repository": {
"type": "git",
@@ -45,8 +42,9 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/packages/contracts/README.md",
"devDependencies": {
- "@0xproject/dev-utils": "^0.3.6",
- "@0xproject/tslint-config": "^0.4.16",
+ "@0xproject/abi-gen": "^0.2.13",
+ "@0xproject/dev-utils": "^0.4.1",
+ "@0xproject/tslint-config": "^0.4.17",
"@types/lodash": "4.14.104",
"@types/node": "^8.0.53",
"@types/yargs": "^10.0.0",
@@ -65,16 +63,17 @@
"yargs": "^10.0.3"
},
"dependencies": {
- "0x.js": "^0.36.3",
- "@0xproject/deployer": "^0.4.1",
- "@0xproject/types": "^0.6.1",
- "@0xproject/typescript-typings": "^0.2.0",
- "@0xproject/utils": "^0.5.2",
- "@0xproject/web3-wrapper": "^0.6.1",
+ "0x.js": "^0.37.2",
+ "@0xproject/base-contract": "^0.3.1",
+ "@0xproject/sol-compiler": "^0.4.3",
+ "@0xproject/types": "^0.6.3",
+ "@0xproject/typescript-typings": "^0.3.1",
+ "@0xproject/utils": "^0.6.1",
+ "@0xproject/web3-wrapper": "^0.6.3",
"bn.js": "^4.11.8",
"ethereumjs-abi": "^0.6.4",
"ethereumjs-util": "^5.1.1",
- "ethers-contracts": "^2.2.1",
+ "ethers": "^3.0.15",
"lodash": "^4.17.4",
"web3": "^0.20.0"
}
diff --git a/packages/contracts/src/contracts/previous/Exchange/Exchange_v1.sol b/packages/contracts/src/contracts/previous/Exchange/Exchange_v1.sol
index f85e1a7ea..3f8e7368d 100644
--- a/packages/contracts/src/contracts/previous/Exchange/Exchange_v1.sol
+++ b/packages/contracts/src/contracts/previous/Exchange/Exchange_v1.sol
@@ -85,7 +85,7 @@ contract Exchange_v1 is SafeMath {
bytes32 orderHash;
}
- function Exchange(address _zrxToken, address _tokenTransferProxy) {
+ function Exchange_v1(address _zrxToken, address _tokenTransferProxy) {
ZRX_TOKEN_CONTRACT = _zrxToken;
TOKEN_TRANSFER_PROXY_CONTRACT = _tokenTransferProxy;
}
diff --git a/packages/contracts/src/utils/artifacts.ts b/packages/contracts/src/utils/artifacts.ts
index 78ba1c142..caf5b94fd 100644
--- a/packages/contracts/src/utils/artifacts.ts
+++ b/packages/contracts/src/utils/artifacts.ts
@@ -1,19 +1,37 @@
-import * as DummyERC20TokenArtifact from '../artifacts/DummyERC20Token.json';
-import * as ExchangeArtifact from '../artifacts/Exchange.json';
-import * as MultiSigWalletWithTimeLockArtifact from '../artifacts/MultiSigWalletWithTimeLock.json';
-import * as MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddressArtifact from '../artifacts/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.json';
-import * as TokenRegistryArtifact from '../artifacts/TokenRegistry.json';
-import * as EtherTokenArtifact from '../artifacts/WETH9.json';
-import * as ZRXArtifact from '../artifacts/ZRXToken.json';
+import { ContractArtifact } from '@0xproject/sol-compiler';
-import { Artifact } from './types';
+import * as DummyERC20Token from '../artifacts/DummyERC20Token.json';
+import * as DummyERC721Token from '../artifacts/DummyERC721Token.json';
+import * as ERC20Proxy from '../artifacts/ERC20Proxy.json';
+import * as ERC721Proxy from '../artifacts/ERC721Proxy.json';
+import * as Exchange from '../artifacts/Exchange.json';
+import * as MixinAuthorizable from '../artifacts/MixinAuthorizable.json';
+import * as MultiSigWallet from '../artifacts/MultiSigWallet.json';
+import * as MultiSigWalletWithTimeLock from '../artifacts/MultiSigWalletWithTimeLock.json';
+import * as MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress from '../artifacts/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.json';
+import * as TestAssetProxyDispatcher from '../artifacts/TestAssetProxyDispatcher.json';
+import * as TestLibBytes from '../artifacts/TestLibBytes.json';
+import * as TestLibs from '../artifacts/TestLibs.json';
+import * as TestSignatureValidator from '../artifacts/TestSignatureValidator.json';
+import * as TokenRegistry from '../artifacts/TokenRegistry.json';
+import * as EtherToken from '../artifacts/WETH9.json';
+import * as ZRX from '../artifacts/ZRXToken.json';
export const artifacts = {
- ZRXArtifact: (ZRXArtifact as any) as Artifact,
- DummyERC20TokenArtifact: (DummyERC20TokenArtifact as any) as Artifact,
- ExchangeArtifact: (ExchangeArtifact as any) as Artifact,
- EtherTokenArtifact: (EtherTokenArtifact as any) as Artifact,
- TokenRegistryArtifact: (TokenRegistryArtifact as any) as Artifact,
- MultiSigWalletWithTimeLockArtifact: (MultiSigWalletWithTimeLockArtifact as any) as Artifact,
- MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddressArtifact: (MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddressArtifact as any) as Artifact,
+ DummyERC20Token: (DummyERC20Token as any) as ContractArtifact,
+ DummyERC721Token: (DummyERC721Token as any) as ContractArtifact,
+ ERC20Proxy: (ERC20Proxy as any) as ContractArtifact,
+ ERC721Proxy: (ERC721Proxy as any) as ContractArtifact,
+ Exchange: (Exchange as any) as ContractArtifact,
+ EtherToken: (EtherToken as any) as ContractArtifact,
+ MixinAuthorizable: (MixinAuthorizable as any) as ContractArtifact,
+ MultiSigWallet: (MultiSigWallet as any) as ContractArtifact,
+ MultiSigWalletWithTimeLock: (MultiSigWalletWithTimeLock as any) as ContractArtifact,
+ MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress: (MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress as any) as ContractArtifact,
+ TestAssetProxyDispatcher: (TestAssetProxyDispatcher as any) as ContractArtifact,
+ TestLibBytes: (TestLibBytes as any) as ContractArtifact,
+ TestLibs: (TestLibs as any) as ContractArtifact,
+ TestSignatureValidator: (TestSignatureValidator as any) as ContractArtifact,
+ TokenRegistry: (TokenRegistry as any) as ContractArtifact,
+ ZRX: (ZRX as any) as ContractArtifact,
};
diff --git a/packages/contracts/test/utils/chai_setup.ts b/packages/contracts/src/utils/chai_setup.ts
index 078edd309..1a8733093 100644
--- a/packages/contracts/test/utils/chai_setup.ts
+++ b/packages/contracts/src/utils/chai_setup.ts
@@ -4,7 +4,7 @@ import ChaiBigNumber = require('chai-bignumber');
import * as dirtyChai from 'dirty-chai';
export const chaiSetup = {
- configure() {
+ configure(): void {
chai.config.includeStack = true;
chai.use(ChaiBigNumber());
chai.use(dirtyChai);
diff --git a/packages/contracts/src/utils/constants.ts b/packages/contracts/src/utils/constants.ts
index 2c9d7b272..3fd2a0a3b 100644
--- a/packages/contracts/src/utils/constants.ts
+++ b/packages/contracts/src/utils/constants.ts
@@ -3,10 +3,6 @@ import { BigNumber } from '@0xproject/utils';
import * as ethUtil from 'ethereumjs-util';
import * as _ from 'lodash';
-const DUMMY_TOKEN_NAME = '';
-const DUMMY_TOKEN_SYMBOL = '';
-const DUMMY_TOKEN_DECIMALS = 18;
-const DUMMY_TOKEN_TOTAL_SUPPLY = 0;
const TESTRPC_PRIVATE_KEYS_STRINGS = [
'0xf2f48ee19680706196e2e339e5da3491186e0c4c5030670656b0e0164837257d',
'0x5d862464fe9303452126c8bc94274b8c5f9874cbd219789b3eb2128075a76f72',
@@ -27,8 +23,10 @@ export const constants = {
MAX_ETHERTOKEN_WITHDRAW_GAS: 43000,
MAX_TOKEN_TRANSFERFROM_GAS: 80000,
MAX_TOKEN_APPROVE_GAS: 60000,
- DUMMY_ERC20_TOKEN_ARGS: [DUMMY_TOKEN_NAME, DUMMY_TOKEN_SYMBOL, DUMMY_TOKEN_DECIMALS, DUMMY_TOKEN_TOTAL_SUPPLY],
- DUMMY_ERC721_TOKEN_ARGS: [DUMMY_TOKEN_NAME, DUMMY_TOKEN_SYMBOL],
+ DUMMY_TOKEN_NAME: '',
+ DUMMY_TOKEN_SYMBOL: '',
+ DUMMY_TOKEN_DECIMALS: new BigNumber(18),
+ DUMMY_TOKEN_TOTAL_SUPPLY: new BigNumber(0),
NUM_DUMMY_ERC20_TO_DEPLOY: 3,
NUM_DUMMY_ERC721_TO_DEPLOY: 1,
NUM_ERC721_TOKENS_TO_MINT: 2,
diff --git a/packages/contracts/src/utils/crypto.ts b/packages/contracts/src/utils/crypto.ts
index 222cb7cca..80c5f30a5 100644
--- a/packages/contracts/src/utils/crypto.ts
+++ b/packages/contracts/src/utils/crypto.ts
@@ -18,7 +18,7 @@ export const crypto = {
solSHA256(args: any[]): Buffer {
return crypto._solHash(args, ABI.soliditySHA256);
},
- _solHash(args: any[], hashFunction: (types: string[], values: any[]) => Buffer) {
+ _solHash(args: any[], hashFunction: (types: string[], values: any[]) => Buffer): Buffer {
const argTypes: string[] = [];
_.each(args, (arg, i) => {
const isNumber = _.isFinite(arg);
diff --git a/packages/contracts/src/utils/erc20_wrapper.ts b/packages/contracts/src/utils/erc20_wrapper.ts
index c2effb617..f12571b48 100644
--- a/packages/contracts/src/utils/erc20_wrapper.ts
+++ b/packages/contracts/src/utils/erc20_wrapper.ts
@@ -1,4 +1,3 @@
-import { Deployer } from '@0xproject/deployer';
import { Provider } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
import * as _ from 'lodash';
@@ -6,41 +5,43 @@ import * as _ from 'lodash';
import { DummyERC20TokenContract } from '../contract_wrappers/generated/dummy_e_r_c20_token';
import { ERC20ProxyContract } from '../contract_wrappers/generated/e_r_c20_proxy';
+import { artifacts } from './artifacts';
import { constants } from './constants';
-import { ContractName, ERC20BalancesByOwner } from './types';
+import { ERC20BalancesByOwner } from './types';
+import { txDefaults } from './web3_wrapper';
export class ERC20Wrapper {
private _tokenOwnerAddresses: string[];
private _contractOwnerAddress: string;
- private _deployer: Deployer;
private _provider: Provider;
private _dummyTokenContracts?: DummyERC20TokenContract[];
private _proxyContract?: ERC20ProxyContract;
- constructor(deployer: Deployer, provider: Provider, tokenOwnerAddresses: string[], contractOwnerAddress: string) {
- this._deployer = deployer;
+ constructor(provider: Provider, tokenOwnerAddresses: string[], contractOwnerAddress: string) {
this._provider = provider;
this._tokenOwnerAddresses = tokenOwnerAddresses;
this._contractOwnerAddress = contractOwnerAddress;
}
public async deployDummyTokensAsync(): Promise<DummyERC20TokenContract[]> {
- const tokenContractInstances = await Promise.all(
+ this._dummyTokenContracts = await Promise.all(
_.times(constants.NUM_DUMMY_ERC20_TO_DEPLOY, () =>
- this._deployer.deployAsync(ContractName.DummyERC20Token, constants.DUMMY_ERC20_TOKEN_ARGS),
+ DummyERC20TokenContract.deployFrom0xArtifactAsync(
+ artifacts.DummyERC20Token,
+ this._provider,
+ txDefaults,
+ constants.DUMMY_TOKEN_NAME,
+ constants.DUMMY_TOKEN_SYMBOL,
+ constants.DUMMY_TOKEN_DECIMALS,
+ constants.DUMMY_TOKEN_TOTAL_SUPPLY,
+ ),
),
);
- this._dummyTokenContracts = _.map(
- tokenContractInstances,
- tokenContractInstance =>
- new DummyERC20TokenContract(tokenContractInstance.abi, tokenContractInstance.address, this._provider),
- );
return this._dummyTokenContracts;
}
public async deployProxyAsync(): Promise<ERC20ProxyContract> {
- const proxyContractInstance = await this._deployer.deployAsync(ContractName.ERC20Proxy);
- this._proxyContract = new ERC20ProxyContract(
- proxyContractInstance.abi,
- proxyContractInstance.address,
+ this._proxyContract = await ERC20ProxyContract.deployFrom0xArtifactAsync(
+ artifacts.ERC20Proxy,
this._provider,
+ txDefaults,
);
return this._proxyContract;
}
diff --git a/packages/contracts/src/utils/erc721_wrapper.ts b/packages/contracts/src/utils/erc721_wrapper.ts
index b78b76b51..5b5de262f 100644
--- a/packages/contracts/src/utils/erc721_wrapper.ts
+++ b/packages/contracts/src/utils/erc721_wrapper.ts
@@ -1,5 +1,4 @@
import { ZeroEx } from '0x.js';
-import { Deployer } from '@0xproject/deployer';
import { Provider } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
import * as _ from 'lodash';
@@ -7,42 +6,42 @@ import * as _ from 'lodash';
import { DummyERC721TokenContract } from '../contract_wrappers/generated/dummy_e_r_c721_token';
import { ERC721ProxyContract } from '../contract_wrappers/generated/e_r_c721_proxy';
+import { artifacts } from './artifacts';
import { constants } from './constants';
-import { ContractName, ERC721TokenIdsByOwner } from './types';
+import { ERC721TokenIdsByOwner } from './types';
+import { txDefaults } from './web3_wrapper';
export class ERC721Wrapper {
private _tokenOwnerAddresses: string[];
private _contractOwnerAddress: string;
- private _deployer: Deployer;
private _provider: Provider;
private _dummyTokenContracts?: DummyERC721TokenContract[];
private _proxyContract?: ERC721ProxyContract;
private _initialTokenIdsByOwner: ERC721TokenIdsByOwner = {};
- constructor(deployer: Deployer, provider: Provider, tokenOwnerAddresses: string[], contractOwnerAddress: string) {
- this._deployer = deployer;
+ constructor(provider: Provider, tokenOwnerAddresses: string[], contractOwnerAddress: string) {
this._provider = provider;
this._tokenOwnerAddresses = tokenOwnerAddresses;
this._contractOwnerAddress = contractOwnerAddress;
}
public async deployDummyTokensAsync(): Promise<DummyERC721TokenContract[]> {
- const tokenContractInstances = await Promise.all(
+ this._dummyTokenContracts = await Promise.all(
_.times(constants.NUM_DUMMY_ERC721_TO_DEPLOY, () =>
- this._deployer.deployAsync(ContractName.DummyERC721Token, constants.DUMMY_ERC721_TOKEN_ARGS),
+ DummyERC721TokenContract.deployFrom0xArtifactAsync(
+ artifacts.DummyERC721Token,
+ this._provider,
+ txDefaults,
+ constants.DUMMY_TOKEN_NAME,
+ constants.DUMMY_TOKEN_SYMBOL,
+ ),
),
);
- this._dummyTokenContracts = _.map(
- tokenContractInstances,
- tokenContractInstance =>
- new DummyERC721TokenContract(tokenContractInstance.abi, tokenContractInstance.address, this._provider),
- );
return this._dummyTokenContracts;
}
public async deployProxyAsync(): Promise<ERC721ProxyContract> {
- const proxyContractInstance = await this._deployer.deployAsync(ContractName.ERC721Proxy);
- this._proxyContract = new ERC721ProxyContract(
- proxyContractInstance.abi,
- proxyContractInstance.address,
+ this._proxyContract = await ERC721ProxyContract.deployFrom0xArtifactAsync(
+ artifacts.ERC721Proxy,
this._provider,
+ txDefaults,
);
return this._proxyContract;
}
diff --git a/packages/contracts/src/utils/log_decoder.ts b/packages/contracts/src/utils/log_decoder.ts
index 291b85dd2..747c7644d 100644
--- a/packages/contracts/src/utils/log_decoder.ts
+++ b/packages/contracts/src/utils/log_decoder.ts
@@ -1,9 +1,9 @@
+import { ContractArtifact } from '@0xproject/sol-compiler';
import { AbiDefinition, LogEntry, LogWithDecodedArgs, RawLog } from '@0xproject/types';
import { AbiDecoder, BigNumber } from '@0xproject/utils';
import * as _ from 'lodash';
import { artifacts } from './artifacts';
-import { Artifact } from './types';
export class LogDecoder {
private _abiDecoder: AbiDecoder;
@@ -12,12 +12,9 @@ export class LogDecoder {
throw new Error('networkId not specified');
}
const abiArrays: AbiDefinition[][] = [];
- _.forEach(artifacts, (artifact: Artifact) => {
- const networkIfExists = artifact.networks[networkIdIfExists];
- if (_.isUndefined(networkIfExists)) {
- throw new Error(`Artifact does not exist on network ${networkIdIfExists}`);
- }
- abiArrays.push(networkIfExists.abi);
+ _.forEach(artifacts, (artifact: ContractArtifact) => {
+ const compilerOutput = artifact.compilerOutput;
+ abiArrays.push(compilerOutput.abi);
});
this._abiDecoder = new AbiDecoder(abiArrays);
}
diff --git a/packages/contracts/src/utils/multi_sig_wrapper.ts b/packages/contracts/src/utils/multi_sig_wrapper.ts
index 84fed7944..41a1dd8d9 100644
--- a/packages/contracts/src/utils/multi_sig_wrapper.ts
+++ b/packages/contracts/src/utils/multi_sig_wrapper.ts
@@ -11,7 +11,7 @@ import { TransactionDataParams } from './types';
export class MultiSigWrapper {
private _multiSig: MultiSigWalletContract;
- public static encodeFnArgs(name: string, abi: AbiDefinition[], args: any[]) {
+ public static encodeFnArgs(name: string, abi: AbiDefinition[], args: any[]): string {
const abiEntity = _.find(abi, { name }) as MethodAbi;
if (_.isUndefined(abiEntity)) {
throw new Error(`Did not find abi entry for name: ${name}`);
@@ -33,7 +33,7 @@ export class MultiSigWrapper {
from: string,
dataParams: TransactionDataParams,
value: BigNumber = new BigNumber(0),
- ) {
+ ): Promise<string> {
const { name, abi, args = [] } = dataParams;
const encoded = MultiSigWrapper.encodeFnArgs(name, abi, args);
return this._multiSig.submitTransaction.sendTransactionAsync(destination, value, encoded, {
diff --git a/packages/contracts/src/utils/token_registry_wrapper.ts b/packages/contracts/src/utils/token_registry_wrapper.ts
index 91bd5503d..86daeca62 100644
--- a/packages/contracts/src/utils/token_registry_wrapper.ts
+++ b/packages/contracts/src/utils/token_registry_wrapper.ts
@@ -9,7 +9,7 @@ export class TokenRegWrapper {
constructor(tokenRegContract: TokenRegistryContract) {
this._tokenReg = tokenRegContract;
}
- public async addTokenAsync(token: Token, from: string) {
+ public async addTokenAsync(token: Token, from: string): Promise<string> {
const tx = this._tokenReg.addToken.sendTransactionAsync(
token.address as string,
token.name,
@@ -21,7 +21,7 @@ export class TokenRegWrapper {
);
return tx;
}
- public async getTokenMetaDataAsync(tokenAddress: string) {
+ public async getTokenMetaDataAsync(tokenAddress: string): Promise<Token> {
const data = await this._tokenReg.getTokenMetaData.callAsync(tokenAddress);
const token: Token = {
address: data[0],
@@ -33,7 +33,7 @@ export class TokenRegWrapper {
};
return token;
}
- public async getTokenByNameAsync(tokenName: string) {
+ public async getTokenByNameAsync(tokenName: string): Promise<Token> {
const data = await this._tokenReg.getTokenByName.callAsync(tokenName);
const token: Token = {
address: data[0],
@@ -45,7 +45,7 @@ export class TokenRegWrapper {
};
return token;
}
- public async getTokenBySymbolAsync(tokenSymbol: string) {
+ public async getTokenBySymbolAsync(tokenSymbol: string): Promise<Token> {
const data = await this._tokenReg.getTokenBySymbol.callAsync(tokenSymbol);
const token: Token = {
address: data[0],
diff --git a/packages/contracts/src/utils/types.ts b/packages/contracts/src/utils/types.ts
index 2200e09f3..234b14ef9 100644
--- a/packages/contracts/src/utils/types.ts
+++ b/packages/contracts/src/utils/types.ts
@@ -103,22 +103,6 @@ export enum ContractName {
Authorizable = 'Authorizable',
}
-export interface Artifact {
- contract_name: ContractName;
- networks: {
- [networkId: number]: {
- abi: ContractAbi;
- solc_version: string;
- keccak256: string;
- optimizer_enabled: number;
- unlinked_binary: string;
- updated_at: number;
- address: string;
- constructor_args: string;
- };
- };
-}
-
export interface SignedOrder extends UnsignedOrder {
signature: string;
}
diff --git a/packages/contracts/test/utils/web3_wrapper.ts b/packages/contracts/src/utils/web3_wrapper.ts
index dd6f198c4..ed1c488a2 100644
--- a/packages/contracts/test/utils/web3_wrapper.ts
+++ b/packages/contracts/src/utils/web3_wrapper.ts
@@ -1,7 +1,11 @@
-import { web3Factory } from '@0xproject/dev-utils';
+import { devConstants, web3Factory } from '@0xproject/dev-utils';
import { Provider } from '@0xproject/types';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
+export const txDefaults = {
+ from: devConstants.TESTRPC_FIRST_ADDRESS,
+ gas: devConstants.GAS_ESTIMATE,
+};
const providerConfigs = { shouldUseInProcessGanache: true };
export const web3 = web3Factory.create(providerConfigs);
export const provider = web3.currentProvider;
diff --git a/packages/contracts/test/asset_proxy/authorizable.ts b/packages/contracts/test/asset_proxy/authorizable.ts
index 9cea263e7..39672bea9 100644
--- a/packages/contracts/test/asset_proxy/authorizable.ts
+++ b/packages/contracts/test/asset_proxy/authorizable.ts
@@ -4,11 +4,10 @@ import * as chai from 'chai';
import * as Web3 from 'web3';
import { MixinAuthorizableContract } from '../../src/contract_wrappers/generated/mixin_authorizable';
+import { artifacts } from '../../src/utils/artifacts';
+import { chaiSetup } from '../../src/utils/chai_setup';
import { constants } from '../../src/utils/constants';
-import { ContractName } from '../../src/utils/types';
-import { chaiSetup } from '../utils/chai_setup';
-import { deployer } from '../utils/deployer';
-import { provider, web3Wrapper } from '../utils/web3_wrapper';
+import { provider, txDefaults, web3Wrapper } from '../../src/utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
@@ -23,8 +22,11 @@ describe('Authorizable', () => {
const accounts = await web3Wrapper.getAvailableAddressesAsync();
owner = address = accounts[0];
notOwner = accounts[1];
- const authorizableInstance = await deployer.deployAsync(ContractName.Authorizable);
- authorizable = new MixinAuthorizableContract(authorizableInstance.abi, authorizableInstance.address, provider);
+ authorizable = await MixinAuthorizableContract.deployFrom0xArtifactAsync(
+ artifacts.MixinAuthorizable,
+ provider,
+ txDefaults,
+ );
});
beforeEach(async () => {
await blockchainLifecycle.startAsync();
diff --git a/packages/contracts/test/asset_proxy/proxies.ts b/packages/contracts/test/asset_proxy/proxies.ts
index a304da585..e7ef9a0d3 100644
--- a/packages/contracts/test/asset_proxy/proxies.ts
+++ b/packages/contracts/test/asset_proxy/proxies.ts
@@ -10,13 +10,12 @@ import { DummyERC721TokenContract } from '../../src/contract_wrappers/generated/
import { ERC20ProxyContract } from '../../src/contract_wrappers/generated/e_r_c20_proxy';
import { ERC721ProxyContract } from '../../src/contract_wrappers/generated/e_r_c721_proxy';
import { assetProxyUtils } from '../../src/utils/asset_proxy_utils';
+import { chaiSetup } from '../../src/utils/chai_setup';
import { constants } from '../../src/utils/constants';
import { ERC20Wrapper } from '../../src/utils/erc20_wrapper';
import { ERC721Wrapper } from '../../src/utils/erc721_wrapper';
-import { AssetProxyId, ContractName } from '../../src/utils/types';
-import { chaiSetup } from '../utils/chai_setup';
-import { deployer } from '../utils/deployer';
-import { provider, web3Wrapper } from '../utils/web3_wrapper';
+import { AssetProxyId } from '../../src/utils/types';
+import { provider, web3Wrapper } from '../../src/utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
@@ -44,8 +43,8 @@ describe('Asset Transfer Proxies', () => {
const accounts = await web3Wrapper.getAvailableAddressesAsync();
const usedAddresses = ([owner, notAuthorized, exchangeAddress, makerAddress, takerAddress] = accounts);
- erc20Wrapper = new ERC20Wrapper(deployer, provider, usedAddresses, owner);
- erc721Wrapper = new ERC721Wrapper(deployer, provider, usedAddresses, owner);
+ erc20Wrapper = new ERC20Wrapper(provider, usedAddresses, owner);
+ erc721Wrapper = new ERC721Wrapper(provider, usedAddresses, owner);
[zrxToken] = await erc20Wrapper.deployDummyTokensAsync();
erc20Proxy = await erc20Wrapper.deployProxyAsync();
diff --git a/packages/contracts/test/ether_token.ts b/packages/contracts/test/ether_token.ts
index e9aba07c5..213c7c8a6 100644
--- a/packages/contracts/test/ether_token.ts
+++ b/packages/contracts/test/ether_token.ts
@@ -1,15 +1,14 @@
-import { ZeroEx, ZeroExError } from '0x.js';
+import { ContractWrappersError, ZeroEx } from '0x.js';
import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
import { BigNumber, promisify } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as chai from 'chai';
+import { WETH9Contract } from '../src/contract_wrappers/generated/weth9';
+import { artifacts } from '../src/utils/artifacts';
+import { chaiSetup } from '../src/utils/chai_setup';
import { constants } from '../src/utils/constants';
-import { ContractName } from '../src/utils/types';
-
-import { chaiSetup } from './utils/chai_setup';
-import { deployer } from './utils/deployer';
-import { provider, web3Wrapper } from './utils/web3_wrapper';
+import { provider, txDefaults, web3Wrapper } from '../src/utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
@@ -24,7 +23,7 @@ describe('EtherToken', () => {
const accounts = await web3Wrapper.getAvailableAddressesAsync();
account = accounts[0];
- const etherToken = await deployer.deployAsync(ContractName.EtherToken);
+ const etherToken = await WETH9Contract.deployFrom0xArtifactAsync(artifacts.EtherToken, provider, txDefaults);
etherTokenAddress = etherToken.address;
zeroEx = new ZeroEx(provider, {
gasPrice,
@@ -43,7 +42,7 @@ describe('EtherToken', () => {
const ethToDeposit = initEthBalance.plus(1);
return expect(zeroEx.etherToken.depositAsync(etherTokenAddress, ethToDeposit, account)).to.be.rejectedWith(
- ZeroExError.InsufficientEthBalanceForDeposit,
+ ContractWrappersError.InsufficientEthBalanceForDeposit,
);
});
@@ -72,7 +71,7 @@ describe('EtherToken', () => {
return expect(
zeroEx.etherToken.withdrawAsync(etherTokenAddress, ethTokensToWithdraw, account),
- ).to.be.rejectedWith(ZeroExError.InsufficientWEthBalanceForWithdrawal);
+ ).to.be.rejectedWith(ContractWrappersError.InsufficientWEthBalanceForWithdrawal);
});
it('should convert ether tokens to ether with sufficient balance', async () => {
diff --git a/packages/contracts/test/exchange/core.ts b/packages/contracts/test/exchange/core.ts
index b714fa899..6c190d4da 100644
--- a/packages/contracts/test/exchange/core.ts
+++ b/packages/contracts/test/exchange/core.ts
@@ -15,7 +15,9 @@ import {
ExchangeErrorContractEventArgs,
FillContractEventArgs,
} from '../../src/contract_wrappers/generated/exchange';
+import { artifacts } from '../../src/utils/artifacts';
import { assetProxyUtils } from '../../src/utils/asset_proxy_utils';
+import { chaiSetup } from '../../src/utils/chai_setup';
import { constants } from '../../src/utils/constants';
import { crypto } from '../../src/utils/crypto';
import { ERC20Wrapper } from '../../src/utils/erc20_wrapper';
@@ -23,16 +25,8 @@ import { ERC721Wrapper } from '../../src/utils/erc721_wrapper';
import { ExchangeWrapper } from '../../src/utils/exchange_wrapper';
import { OrderFactory } from '../../src/utils/order_factory';
import { orderUtils } from '../../src/utils/order_utils';
-import {
- AssetProxyId,
- ContractName,
- ERC20BalancesByOwner,
- ExchangeContractErrs,
- SignedOrder,
-} from '../../src/utils/types';
-import { chaiSetup } from '../utils/chai_setup';
-import { deployer } from '../utils/deployer';
-import { provider, web3Wrapper } from '../utils/web3_wrapper';
+import { AssetProxyId, ERC20BalancesByOwner, ExchangeContractErrs, SignedOrder } from '../../src/utils/types';
+import { provider, txDefaults, web3Wrapper } from '../../src/utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
@@ -71,8 +65,8 @@ describe('Exchange core', () => {
const accounts = await web3Wrapper.getAvailableAddressesAsync();
const usedAddresses = ([owner, makerAddress, takerAddress, feeRecipientAddress] = accounts);
- erc20Wrapper = new ERC20Wrapper(deployer, provider, usedAddresses, owner);
- erc721Wrapper = new ERC721Wrapper(deployer, provider, usedAddresses, owner);
+ erc20Wrapper = new ERC20Wrapper(provider, usedAddresses, owner);
+ erc721Wrapper = new ERC721Wrapper(provider, usedAddresses, owner);
[erc20TokenA, erc20TokenB, zrxToken] = await erc20Wrapper.deployDummyTokensAsync();
erc20Proxy = await erc20Wrapper.deployProxyAsync();
@@ -85,10 +79,12 @@ describe('Exchange core', () => {
erc721MakerAssetIds = erc721Balances[makerAddress][erc721Token.address];
erc721TakerAssetIds = erc721Balances[takerAddress][erc721Token.address];
- const exchangeInstance = await deployer.deployAsync(ContractName.Exchange, [
+ exchange = await ExchangeContract.deployFrom0xArtifactAsync(
+ artifacts.Exchange,
+ provider,
+ txDefaults,
assetProxyUtils.encodeERC20ProxyData(zrxToken.address),
- ]);
- exchange = new ExchangeContract(exchangeInstance.abi, exchangeInstance.address, provider);
+ );
zeroEx = new ZeroEx(provider, {
exchangeContractAddress: exchange.address,
networkId: constants.TESTRPC_NETWORK_ID,
diff --git a/packages/contracts/test/exchange/dispatcher.ts b/packages/contracts/test/exchange/dispatcher.ts
index 31f5f5dbb..db2f18ddc 100644
--- a/packages/contracts/test/exchange/dispatcher.ts
+++ b/packages/contracts/test/exchange/dispatcher.ts
@@ -8,14 +8,14 @@ import { DummyERC20TokenContract } from '../../src/contract_wrappers/generated/d
import { ERC20ProxyContract } from '../../src/contract_wrappers/generated/e_r_c20_proxy';
import { ERC721ProxyContract } from '../../src/contract_wrappers/generated/e_r_c721_proxy';
import { TestAssetProxyDispatcherContract } from '../../src/contract_wrappers/generated/test_asset_proxy_dispatcher';
+import { artifacts } from '../../src/utils/artifacts';
import { assetProxyUtils } from '../../src/utils/asset_proxy_utils';
+import { chaiSetup } from '../../src/utils/chai_setup';
import { constants } from '../../src/utils/constants';
import { ERC20Wrapper } from '../../src/utils/erc20_wrapper';
import { ERC721Wrapper } from '../../src/utils/erc721_wrapper';
-import { AssetProxyId, ContractName } from '../../src/utils/types';
-import { chaiSetup } from '../utils/chai_setup';
-import { deployer } from '../utils/deployer';
-import { provider, web3Wrapper } from '../utils/web3_wrapper';
+import { AssetProxyId } from '../../src/utils/types';
+import { provider, txDefaults, web3Wrapper } from '../../src/utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
@@ -42,8 +42,8 @@ describe('AssetProxyDispatcher', () => {
const usedAddresses = ([owner, notOwner, makerAddress, takerAddress] = accounts);
notAuthorized = notOwner;
- erc20Wrapper = new ERC20Wrapper(deployer, provider, usedAddresses, owner);
- erc721Wrapper = new ERC721Wrapper(deployer, provider, usedAddresses, owner);
+ erc20Wrapper = new ERC20Wrapper(provider, usedAddresses, owner);
+ erc721Wrapper = new ERC721Wrapper(provider, usedAddresses, owner);
[zrxToken] = await erc20Wrapper.deployDummyTokensAsync();
erc20Proxy = await erc20Wrapper.deployProxyAsync();
@@ -51,11 +51,10 @@ describe('AssetProxyDispatcher', () => {
erc721Proxy = await erc721Wrapper.deployProxyAsync();
- const assetProxyDispatcherInstance = await deployer.deployAsync(ContractName.TestAssetProxyDispatcher);
- assetProxyDispatcher = new TestAssetProxyDispatcherContract(
- assetProxyDispatcherInstance.abi,
- assetProxyDispatcherInstance.address,
+ assetProxyDispatcher = await TestAssetProxyDispatcherContract.deployFrom0xArtifactAsync(
+ artifacts.TestAssetProxyDispatcher,
provider,
+ txDefaults,
);
await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(assetProxyDispatcher.address, {
from: owner,
@@ -118,11 +117,10 @@ describe('AssetProxyDispatcher', () => {
let proxyAddress = await assetProxyDispatcher.getAssetProxy.callAsync(AssetProxyId.ERC20);
expect(proxyAddress).to.be.equal(erc20Proxy.address);
// Deploy a new version of the ERC20 Transfer Proxy contract
- const newErc20TransferProxyInstance = await deployer.deployAsync(ContractName.ERC20Proxy);
- const newErc20TransferProxy = new ERC20ProxyContract(
- newErc20TransferProxyInstance.abi,
- newErc20TransferProxyInstance.address,
+ const newErc20TransferProxy = await ERC20ProxyContract.deployFrom0xArtifactAsync(
+ artifacts.ERC20Proxy,
provider,
+ txDefaults,
);
// Register new ERC20 Transfer Proxy contract
const newAddress = newErc20TransferProxy.address;
diff --git a/packages/contracts/test/exchange/libs.ts b/packages/contracts/test/exchange/libs.ts
index 0074cdff7..1036cb815 100644
--- a/packages/contracts/test/exchange/libs.ts
+++ b/packages/contracts/test/exchange/libs.ts
@@ -6,14 +6,14 @@ import ethUtil = require('ethereumjs-util');
import { TestLibsContract } from '../../src/contract_wrappers/generated/test_libs';
import { addressUtils } from '../../src/utils/address_utils';
+import { artifacts } from '../../src/utils/artifacts';
import { assetProxyUtils } from '../../src/utils/asset_proxy_utils';
+import { chaiSetup } from '../../src/utils/chai_setup';
import { constants } from '../../src/utils/constants';
import { OrderFactory } from '../../src/utils/order_factory';
import { orderUtils } from '../../src/utils/order_utils';
-import { ContractName, SignedOrder } from '../../src/utils/types';
-import { chaiSetup } from '../utils/chai_setup';
-import { deployer } from '../utils/deployer';
-import { provider, web3Wrapper } from '../utils/web3_wrapper';
+import { SignedOrder } from '../../src/utils/types';
+import { provider, txDefaults, web3Wrapper } from '../../src/utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
@@ -28,8 +28,7 @@ describe('Exchange libs', () => {
before(async () => {
const accounts = await web3Wrapper.getAvailableAddressesAsync();
const makerAddress = accounts[0];
- const libsInstance = await deployer.deployAsync(ContractName.TestLibs);
- libs = new TestLibsContract(libsInstance.abi, libsInstance.address, provider);
+ libs = await TestLibsContract.deployFrom0xArtifactAsync(artifacts.TestLibs, provider, txDefaults);
const zeroEx = new ZeroEx(provider, { networkId: constants.TESTRPC_NETWORK_ID });
const defaultOrderParams = {
diff --git a/packages/contracts/test/exchange/signature_validator.ts b/packages/contracts/test/exchange/signature_validator.ts
index f47999bfa..489ed32c5 100644
--- a/packages/contracts/test/exchange/signature_validator.ts
+++ b/packages/contracts/test/exchange/signature_validator.ts
@@ -6,14 +6,14 @@ import ethUtil = require('ethereumjs-util');
import { TestSignatureValidatorContract } from '../../src/contract_wrappers/generated/test_signature_validator';
import { addressUtils } from '../../src/utils/address_utils';
+import { artifacts } from '../../src/utils/artifacts';
import { assetProxyUtils } from '../../src/utils/asset_proxy_utils';
+import { chaiSetup } from '../../src/utils/chai_setup';
import { constants } from '../../src/utils/constants';
import { OrderFactory } from '../../src/utils/order_factory';
import { orderUtils } from '../../src/utils/order_utils';
-import { ContractName, SignedOrder } from '../../src/utils/types';
-import { chaiSetup } from '../utils/chai_setup';
-import { deployer } from '../utils/deployer';
-import { provider, web3Wrapper } from '../utils/web3_wrapper';
+import { SignedOrder } from '../../src/utils/types';
+import { provider, txDefaults, web3Wrapper } from '../../src/utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
@@ -28,17 +28,16 @@ describe('MixinSignatureValidator', () => {
before(async () => {
const accounts = await web3Wrapper.getAvailableAddressesAsync();
const makerAddress = accounts[0];
- const signatureValidatorInstance = await deployer.deployAsync(ContractName.TestSignatureValidator);
- signatureValidator = new TestSignatureValidatorContract(
- signatureValidatorInstance.abi,
- signatureValidatorInstance.address,
+ signatureValidator = await TestSignatureValidatorContract.deployFrom0xArtifactAsync(
+ artifacts.TestSignatureValidator,
provider,
+ txDefaults,
);
const zeroEx = new ZeroEx(provider, { networkId: constants.TESTRPC_NETWORK_ID });
const defaultOrderParams = {
...constants.STATIC_ORDER_PARAMS,
- exchangeAddress: signatureValidatorInstance.address,
+ exchangeAddress: signatureValidator.address,
makerAddress,
feeRecipientAddress: addressUtils.generatePseudoRandomAddress(),
makerAssetData: assetProxyUtils.encodeERC20ProxyData(addressUtils.generatePseudoRandomAddress()),
diff --git a/packages/contracts/test/exchange/transactions.ts b/packages/contracts/test/exchange/transactions.ts
index 2bc078153..a71b50a61 100644
--- a/packages/contracts/test/exchange/transactions.ts
+++ b/packages/contracts/test/exchange/transactions.ts
@@ -9,7 +9,9 @@ import * as Web3 from 'web3';
import { DummyERC20TokenContract } from '../../src/contract_wrappers/generated/dummy_e_r_c20_token';
import { ERC20ProxyContract } from '../../src/contract_wrappers/generated/e_r_c20_proxy';
import { ExchangeContract } from '../../src/contract_wrappers/generated/exchange';
+import { artifacts } from '../../src/utils/artifacts';
import { assetProxyUtils } from '../../src/utils/asset_proxy_utils';
+import { chaiSetup } from '../../src/utils/chai_setup';
import { constants } from '../../src/utils/constants';
import { ERC20Wrapper } from '../../src/utils/erc20_wrapper';
import { ExchangeWrapper } from '../../src/utils/exchange_wrapper';
@@ -18,7 +20,6 @@ import { orderUtils } from '../../src/utils/order_utils';
import { TransactionFactory } from '../../src/utils/transaction_factory';
import {
AssetProxyId,
- ContractName,
ERC20BalancesByOwner,
ExchangeContractErrs,
OrderStruct,
@@ -26,9 +27,7 @@ import {
SignedOrder,
SignedTransaction,
} from '../../src/utils/types';
-import { chaiSetup } from '../utils/chai_setup';
-import { deployer } from '../utils/deployer';
-import { provider, web3Wrapper } from '../utils/web3_wrapper';
+import { provider, txDefaults, web3Wrapper } from '../../src/utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
@@ -66,16 +65,18 @@ describe('Exchange transactions', () => {
const accounts = await web3Wrapper.getAvailableAddressesAsync();
const usedAddresses = ([owner, senderAddress, makerAddress, takerAddress, feeRecipientAddress] = accounts);
- erc20Wrapper = new ERC20Wrapper(deployer, provider, usedAddresses, owner);
+ erc20Wrapper = new ERC20Wrapper(provider, usedAddresses, owner);
[erc20TokenA, erc20TokenB, zrxToken] = await erc20Wrapper.deployDummyTokensAsync();
erc20Proxy = await erc20Wrapper.deployProxyAsync();
await erc20Wrapper.setBalancesAndAllowancesAsync();
- const exchangeInstance = await deployer.deployAsync(ContractName.Exchange, [
+ exchange = await ExchangeContract.deployFrom0xArtifactAsync(
+ artifacts.Exchange,
+ provider,
+ txDefaults,
assetProxyUtils.encodeERC20ProxyData(zrxToken.address),
- ]);
- exchange = new ExchangeContract(exchangeInstance.abi, exchangeInstance.address, provider);
+ );
zeroEx = new ZeroEx(provider, {
exchangeContractAddress: exchange.address,
networkId: constants.TESTRPC_NETWORK_ID,
diff --git a/packages/contracts/test/exchange/wrapper.ts b/packages/contracts/test/exchange/wrapper.ts
index 88e42fee6..44145b4f0 100644
--- a/packages/contracts/test/exchange/wrapper.ts
+++ b/packages/contracts/test/exchange/wrapper.ts
@@ -12,16 +12,16 @@ import { ERC20ProxyContract } from '../../src/contract_wrappers/generated/e_r_c2
import { ERC721ProxyContract } from '../../src/contract_wrappers/generated/e_r_c721_proxy';
import { ExchangeContract } from '../../src/contract_wrappers/generated/exchange';
import { TokenRegistryContract } from '../../src/contract_wrappers/generated/token_registry';
+import { artifacts } from '../../src/utils/artifacts';
import { assetProxyUtils } from '../../src/utils/asset_proxy_utils';
+import { chaiSetup } from '../../src/utils/chai_setup';
import { constants } from '../../src/utils/constants';
import { ERC20Wrapper } from '../../src/utils/erc20_wrapper';
import { ERC721Wrapper } from '../../src/utils/erc721_wrapper';
import { ExchangeWrapper } from '../../src/utils/exchange_wrapper';
import { OrderFactory } from '../../src/utils/order_factory';
-import { AssetProxyId, ContractName, ERC20BalancesByOwner, SignedOrder } from '../../src/utils/types';
-import { chaiSetup } from '../utils/chai_setup';
-import { deployer } from '../utils/deployer';
-import { provider, web3Wrapper } from '../utils/web3_wrapper';
+import { AssetProxyId, ERC20BalancesByOwner, SignedOrder } from '../../src/utils/types';
+import { provider, txDefaults, web3Wrapper } from '../../src/utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
@@ -59,8 +59,8 @@ describe('Exchange wrappers', () => {
const accounts = await web3Wrapper.getAvailableAddressesAsync();
const usedAddresses = ([owner, makerAddress, takerAddress, feeRecipientAddress] = accounts);
- erc20Wrapper = new ERC20Wrapper(deployer, provider, usedAddresses, owner);
- erc721Wrapper = new ERC721Wrapper(deployer, provider, usedAddresses, owner);
+ erc20Wrapper = new ERC20Wrapper(provider, usedAddresses, owner);
+ erc721Wrapper = new ERC721Wrapper(provider, usedAddresses, owner);
[erc20TokenA, erc20TokenB, zrxToken] = await erc20Wrapper.deployDummyTokensAsync();
erc20Proxy = await erc20Wrapper.deployProxyAsync();
@@ -73,10 +73,12 @@ describe('Exchange wrappers', () => {
erc721MakerAssetId = erc721Balances[makerAddress][erc721Token.address][0];
erc721TakerAssetId = erc721Balances[takerAddress][erc721Token.address][0];
- const exchangeInstance = await deployer.deployAsync(ContractName.Exchange, [
+ exchange = await ExchangeContract.deployFrom0xArtifactAsync(
+ artifacts.Exchange,
+ provider,
+ txDefaults,
assetProxyUtils.encodeERC20ProxyData(zrxToken.address),
- ]);
- exchange = new ExchangeContract(exchangeInstance.abi, exchangeInstance.address, provider);
+ );
zeroEx = new ZeroEx(provider, {
exchangeContractAddress: exchange.address,
networkId: constants.TESTRPC_NETWORK_ID,
diff --git a/packages/contracts/test/libraries/lib_bytes.ts b/packages/contracts/test/libraries/lib_bytes.ts
index 1270a617f..5ed5c356f 100644
--- a/packages/contracts/test/libraries/lib_bytes.ts
+++ b/packages/contracts/test/libraries/lib_bytes.ts
@@ -8,11 +8,11 @@ import ethUtil = require('ethereumjs-util');
import * as Web3 from 'web3';
import { TestLibBytesContract } from '../../src/contract_wrappers/generated/test_lib_bytes';
+import { artifacts } from '../../src/utils/artifacts';
+import { chaiSetup } from '../../src/utils/chai_setup';
import { constants } from '../../src/utils/constants';
-import { AssetProxyId, ContractName } from '../../src/utils/types';
-import { chaiSetup } from '../utils/chai_setup';
-import { deployer } from '../utils/deployer';
-import { provider, web3Wrapper } from '../utils/web3_wrapper';
+import { AssetProxyId } from '../../src/utils/types';
+import { provider, txDefaults, web3Wrapper } from '../../src/utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
@@ -38,8 +38,7 @@ describe('LibBytes', () => {
owner = accounts[0];
testAddress = accounts[1];
// Deploy LibBytes
- const libBytesInstance = await deployer.deployAsync(ContractName.TestLibBytes);
- libBytes = new TestLibBytesContract(libBytesInstance.abi, libBytesInstance.address, provider);
+ libBytes = await TestLibBytesContract.deployFrom0xArtifactAsync(artifacts.TestLibBytes, provider, txDefaults);
// Verify lengths of test data
const byteArrayShorterThan32BytesLength = ethUtil.toBuffer(byteArrayShorterThan32Bytes).byteLength;
expect(byteArrayShorterThan32BytesLength).to.be.lessThan(32);
diff --git a/packages/contracts/test/multi_sig_with_time_lock.ts b/packages/contracts/test/multi_sig_with_time_lock.ts
index 48600ae3d..d39fa6d09 100644
--- a/packages/contracts/test/multi_sig_with_time_lock.ts
+++ b/packages/contracts/test/multi_sig_with_time_lock.ts
@@ -9,15 +9,13 @@ import * as multiSigWalletJSON from '../../build/contracts/MultiSigWalletWithTim
import { MultiSigWalletContract } from '../src/contract_wrappers/generated/multi_sig_wallet';
import { MultiSigWalletWithTimeLockContract } from '../src/contract_wrappers/generated/multi_sig_wallet_with_time_lock';
import { artifacts } from '../src/utils/artifacts';
+import { chaiSetup } from '../src/utils/chai_setup';
import { constants } from '../src/utils/constants';
import { MultiSigWrapper } from '../src/utils/multi_sig_wrapper';
-import { ContractName, SubmissionContractEventArgs } from '../src/utils/types';
+import { SubmissionContractEventArgs } from '../src/utils/types';
+import { provider, txDefaults, web3Wrapper } from '../src/utils/web3_wrapper';
-import { chaiSetup } from './utils/chai_setup';
-import { deployer } from './utils/deployer';
-import { provider, web3Wrapper } from './utils/web3_wrapper';
-
-const MULTI_SIG_ABI = artifacts.MultiSigWalletWithTimeLockArtifact.networks[constants.TESTRPC_NETWORK_ID].abi;
+const MULTI_SIG_ABI = artifacts.MultiSigWalletWithTimeLock.compilerOutput.abi;
chaiSetup.configure();
const expect = chai.expect;
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
@@ -47,15 +45,13 @@ describe('MultiSigWalletWithTimeLock', () => {
describe('changeTimeLock', () => {
describe('initially non-time-locked', async () => {
before('deploy a wallet', async () => {
- const multiSigInstance = await deployer.deployAsync(ContractName.MultiSigWalletWithTimeLock, [
+ multiSig = await MultiSigWalletWithTimeLockContract.deployFrom0xArtifactAsync(
+ artifacts.MultiSigWalletWithTimeLock,
+ provider,
+ txDefaults,
owners,
SIGNATURES_REQUIRED,
- 0,
- ]);
- multiSig = new MultiSigWalletWithTimeLockContract(
- multiSigInstance.abi,
- multiSigInstance.address,
- provider,
+ new BigNumber(0),
);
multiSigWrapper = new MultiSigWrapper((multiSig as any) as MultiSigWalletContract);
@@ -144,15 +140,13 @@ describe('MultiSigWalletWithTimeLock', () => {
});
describe('initially time-locked', async () => {
before('deploy a wallet', async () => {
- const multiSigInstance = await deployer.deployAsync(ContractName.MultiSigWalletWithTimeLock, [
+ multiSig = await MultiSigWalletWithTimeLockContract.deployFrom0xArtifactAsync(
+ artifacts.MultiSigWalletWithTimeLock,
+ provider,
+ txDefaults,
owners,
SIGNATURES_REQUIRED,
SECONDS_TIME_LOCKED,
- ]);
- multiSig = new MultiSigWalletWithTimeLockContract(
- multiSigInstance.abi,
- multiSigInstance.address,
- provider,
);
multiSigWrapper = new MultiSigWrapper((multiSig as any) as MultiSigWalletContract);
diff --git a/packages/contracts/test/multi_sig_with_time_lock_except_remove_auth_addr.ts b/packages/contracts/test/multi_sig_with_time_lock_except_remove_auth_addr.ts
index 74475c3db..65cd5c5a8 100644
--- a/packages/contracts/test/multi_sig_with_time_lock_except_remove_auth_addr.ts
+++ b/packages/contracts/test/multi_sig_with_time_lock_except_remove_auth_addr.ts
@@ -6,7 +6,7 @@
*
import { LogWithDecodedArgs, ZeroEx } from '0x.js';
import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
-import { AbiDecoder } from '@0xproject/utils';
+import { AbiDecoder, BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as chai from 'chai';
import * as Web3 from 'web3';
@@ -21,12 +21,12 @@ import { MultiSigWrapper } from '../src/utils/multi_sig_wrapper';
import { ContractName, SubmissionContractEventArgs, TransactionDataParams } from '../src/utils/types';
import { chaiSetup } from './utils/chai_setup';
-import { deployer } from './utils/deployer';
-import { provider, web3Wrapper } from './utils/web3_wrapper';
-const PROXY_ABI = artifacts.TokenTransferProxyArtifact.networks[constants.TESTRPC_NETWORK_ID].abi;
+
+import { provider, txDefaults, web3Wrapper } from './utils/web3_wrapper';
+
+const PROXY_ABI = artifacts.TokenTransferProxy.compilerOutput.abi;
const MUTISIG_WALLET_WITH_TIME_LOCK_EXCEPT_REMOVE_AUTHORIZED_ADDRESS_ABI =
- artifacts.MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddressArtifact.networks[constants.TESTRPC_NETWORK_ID]
- .abi;
+ artifacts.MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.compilerOutput.abi;
chaiSetup.configure();
const expect = chai.expect;
@@ -36,8 +36,8 @@ const abiDecoder = new AbiDecoder([MUTISIG_WALLET_WITH_TIME_LOCK_EXCEPT_REMOVE_A
describe('MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress', () => {
const zeroEx = new ZeroEx(provider, { networkId: constants.TESTRPC_NETWORK_ID });
let owners: string[];
- const requiredApprovals = 2;
- const SECONDS_TIME_LOCKED = 1000000;
+ const requiredApprovals = new BigNumber(2);
+ const SECONDS_TIME_LOCKED = new BigNumber(1000000);
// initialize fake addresses
let authorizedAddress: string;
@@ -53,23 +53,22 @@ describe('MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress', () => {
owners = [accounts[0], accounts[1]];
[authorizedAddress, unauthorizedAddress] = accounts;
const initialOwner = accounts[0];
- const tokenTransferProxyInstance = await deployer.deployAsync(ContractName.TokenTransferProxy);
- tokenTransferProxy = new TokenTransferProxyContract(
- tokenTransferProxyInstance.abi,
- tokenTransferProxyInstance.address,
+ tokenTransferProxy = await TokenTransferProxyContract.deployFrom0xArtifactAsync(
+ artifacts.TokenTransferProxy,
provider,
+ txDefaults,
);
await tokenTransferProxy.addAuthorizedAddress.sendTransactionAsync(authorizedAddress, {
from: initialOwner,
});
- const multiSigInstance = await deployer.deployAsync(
- ContractName.MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress,
- [owners, requiredApprovals, SECONDS_TIME_LOCKED, tokenTransferProxy.address],
- );
- multiSig = new MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddressContract(
- multiSigInstance.abi,
- multiSigInstance.address,
+ multiSig = await MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddressContract.deployFrom0xArtifactAsync(
+ artifacts.MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress,
provider,
+ txDefaults,
+ owners,
+ requiredApprovals,
+ SECONDS_TIME_LOCKED,
+ tokenTransferProxy.address,
);
await tokenTransferProxy.transferOwnership.sendTransactionAsync(multiSig.address, {
from: initialOwner,
@@ -117,7 +116,11 @@ describe('MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress', () => {
});
it('should throw if tx destination is not the tokenTransferProxy', async () => {
- const invalidTokenTransferProxy = await deployer.deployAsync(ContractName.TokenTransferProxy);
+ const invalidTokenTransferProxy = await TokenTransferProxyContract.deployFrom0xArtifactAsync(
+ artifacts.TokenTransferProxy,
+ provider,
+ txDefaults,
+ );
const invalidDestination = invalidTokenTransferProxy.address;
const dataParams: TransactionDataParams = {
name: 'removeAuthorizedAddress',
diff --git a/packages/contracts/test/token_registry.ts b/packages/contracts/test/token_registry.ts
index c34478b65..1cae3da52 100644
--- a/packages/contracts/test/token_registry.ts
+++ b/packages/contracts/test/token_registry.ts
@@ -8,13 +8,11 @@ import * as _ from 'lodash';
import * as Web3 from 'web3';
import { TokenRegistryContract } from '../src/contract_wrappers/generated/token_registry';
+import { artifacts } from '../src/utils/artifacts';
+import { chaiSetup } from '../src/utils/chai_setup';
import { constants } from '../src/utils/constants';
import { TokenRegWrapper } from '../src/utils/token_registry_wrapper';
-import { ContractName } from '../src/utils/types';
-
-import { chaiSetup } from './utils/chai_setup';
-import { deployer } from './utils/deployer';
-import { provider, web3Wrapper } from './utils/web3_wrapper';
+import { provider, txDefaults, web3Wrapper } from '../src/utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
@@ -29,8 +27,7 @@ describe('TokenRegistry', () => {
const accounts = await web3Wrapper.getAvailableAddressesAsync();
owner = accounts[0];
notOwner = accounts[1];
- const tokenRegInstance = await deployer.deployAsync(ContractName.TokenRegistry);
- tokenReg = new TokenRegistryContract(tokenRegInstance.abi, tokenRegInstance.address, provider);
+ tokenReg = await TokenRegistryContract.deployFrom0xArtifactAsync(artifacts.TokenRegistry, provider, txDefaults);
tokenRegWrapper = new TokenRegWrapper(tokenReg);
});
beforeEach(async () => {
diff --git a/packages/contracts/test/tutorials/arbitrage.ts b/packages/contracts/test/tutorials/arbitrage.ts
index 95bc421e1..c65e050ad 100644
--- a/packages/contracts/test/tutorials/arbitrage.ts
+++ b/packages/contracts/test/tutorials/arbitrage.ts
@@ -1,23 +1,28 @@
// import { ECSignature, SignedOrder, ZeroEx } from '0x.js';
// import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
+// import { ExchangeContractErrs } from '@0xproject/types';
// import { BigNumber } from '@0xproject/utils';
// import { Web3Wrapper } from '@0xproject/web3-wrapper';
// import * as chai from 'chai';
// import ethUtil = require('ethereumjs-util');
// import * as Web3 from 'web3';
+// import { AccountLevelsContract } from '../../src/contract_wrappers/generated/account_levels';
// import { ArbitrageContract } from '../../src/contract_wrappers/generated/arbitrage';
+// import { DummyTokenContract } from '../../src/contract_wrappers/generated/dummy_token';
// import { EtherDeltaContract } from '../../src/contract_wrappers/generated/ether_delta';
// import { ExchangeContract } from '../../src/contract_wrappers/generated/exchange';
-// import { Balances } from '../../src/utils/balances';
-// import { constants } from '../../src/utils/constants';
-// import { crypto } from '../../src/utils/crypto';
-// import { ExchangeWrapper } from '../../src/utils/exchange_wrapper';
-// import { OrderFactory } from '../../src/utils/order_factory';
-// import { BalancesByOwner, ContractName, ExchangeContractErrs } from '../../src/utils/types';
+// import { TokenTransferProxyContract } from '../../src/contract_wrappers/generated/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 { deployer } from '../utils/deployer';
-// import { provider, web3Wrapper } from '../utils/web3_wrapper';
+
+// import { provider, txDefaults, web3Wrapper } from '../utils/web3_wrapper';
// chaiSetup.configure();
// const expect = chai.expect;
@@ -36,8 +41,8 @@
// const INITIAL_BALANCE = ZeroEx.toBaseUnitAmount(new BigNumber(10000), 18);
// const INITIAL_ALLOWANCE = ZeroEx.toBaseUnitAmount(new BigNumber(10000), 18);
-// let weth: Web3.ContractInstance;
-// let zrx: Web3.ContractInstance;
+// let weth: DummyTokenContract;
+// let zrx: DummyTokenContract;
// let arbitrage: ArbitrageContract;
// let etherDelta: EtherDeltaContract;
@@ -47,87 +52,117 @@
// 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 deployer.deployAsync(ContractName.DummyERC20Token, constants.DUMMY_TOKEN_ARGS);
-// zrx = await deployer.deployAsync(ContractName.DummyERC20Token, constants.DUMMY_TOKEN_ARGS);
-// const accountLevels = await deployer.deployAsync(ContractName.AccountLevels);
-// const edAdminAddress = accounts[0];
-// const edMakerFee = 0;
-// const edTakerFee = 0;
-// const edFeeRebate = 0;
-// const etherDeltaInstance = await deployer.deployAsync(ContractName.EtherDelta, [
-// edAdminAddress,
-// feeRecipient,
-// accountLevels.address,
-// edMakerFee,
-// edTakerFee,
-// edFeeRebate,
-// ]);
-// etherDelta = new EtherDeltaContract(etherDeltaInstance.abi, etherDeltaInstance.address, provider);
-// const tokenTransferProxy = await deployer.deployAsync(ContractName.TokenTransferProxy);
-// const exchangeInstance = await deployer.deployAsync(ContractName.Exchange, [
-// zrx.address,
-// tokenTransferProxy.address,
-// ]);
-// await tokenTransferProxy.addAuthorizedAddress(exchangeInstance.address, { from: accounts[0] });
-// zeroEx = new ZeroEx(provider, {
-// exchangeContractAddress: exchangeInstance.address,
-// networkId: constants.TESTRPC_NETWORK_ID,
-// });
-// const exchange = new ExchangeContract(exchangeInstance.abi, exchangeInstance.address, provider);
-// exWrapper = new ExchangeWrapper(exchange, 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, zeroEx);
-// 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);
-// const arbitrageInstance = await deployer.deployAsync(ContractName.Arbitrage, [
-// exchange.address,
-// etherDelta.address,
-// tokenTransferProxy.address,
-// ]);
-// arbitrage = new ArbitrageContract(arbitrageInstance.abi, arbitrageInstance.address, provider);
-// // Enable arbitrage and withdrawals of tokens
-// await arbitrage.setAllowances.sendTransactionAsync(weth.address, { from: coinbase });
-// await arbitrage.setAllowances.sendTransactionAsync(zrx.address, { from: coinbase });
+// 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(arbitrage.address, takerTokenAmount, { from: coinbase });
+// await weth.setBalance.sendTransactionAsync(arbitrage.address, takerTokenAmount, { from: coinbase });
// // Fund the maker on exchange side
-// await zrx.setBalance(maker, makerTokenAmount, { from: coinbase });
+// await zrx.setBalance.sendTransactionAsync(maker, makerTokenAmount, { from: coinbase });
// // Set the allowance for the maker on Exchange side
-// await zrx.approve(tokenTransferProxy.address, INITIAL_ALLOWANCE, { from: maker });
+// 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(edMaker, amountGive, { from: coinbase });
+// await weth.setBalance.sendTransactionAsync(edMaker, amountGive, { from: coinbase });
// // Set the allowance for the maker on EtherDelta side
-// await weth.approve(etherDelta.address, INITIAL_ALLOWANCE, { from: edMaker });
+// 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(edFrontRunner, amountGet, { from: coinbase });
+// await zrx.setBalance.sendTransactionAsync(edFrontRunner, amountGet, { from: coinbase });
// // Set the allowance for the front-runner on EtherDelta side
-// await zrx.approve(etherDelta.address, INITIAL_ALLOWANCE, { from: edFrontRunner });
+// 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 });
// });
@@ -194,11 +229,11 @@
// from: coinbase,
// });
// const res = await zeroEx.awaitTransactionMinedAsync(txHash);
-// const postBalance = await weth.balanceOf(arbitrage.address);
+// 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(arbitrage.address);
+// const preBalance = await weth.balanceOf.callAsync(arbitrage.address);
// // Front-running transaction
// await etherDelta.trade.sendTransactionAsync(
// tokenGet,
@@ -218,7 +253,7 @@
// await expect(
// arbitrage.makeAtomicTrade.sendTransactionAsync(addresses, values, v, r, s, { from: coinbase }),
// ).to.be.rejectedWith(constants.REVERT);
-// const postBalance = await weth.balanceOf(arbitrage.address);
+// const postBalance = await weth.balanceOf.callAsync(arbitrage.address);
// expect(preBalance).to.be.bignumber.equal(postBalance);
// });
// });
diff --git a/packages/contracts/test/unlimited_allowance_token.ts b/packages/contracts/test/unlimited_allowance_token.ts
index f40708dbd..8721930be 100644
--- a/packages/contracts/test/unlimited_allowance_token.ts
+++ b/packages/contracts/test/unlimited_allowance_token.ts
@@ -6,12 +6,10 @@ import * as chai from 'chai';
import * as Web3 from 'web3';
import { DummyERC20TokenContract } from '../src/contract_wrappers/generated/dummy_e_r_c20_token';
+import { artifacts } from '../src/utils/artifacts';
+import { chaiSetup } from '../src/utils/chai_setup';
import { constants } from '../src/utils/constants';
-import { ContractName } from '../src/utils/types';
-
-import { chaiSetup } from './utils/chai_setup';
-import { deployer } from './utils/deployer';
-import { provider, web3Wrapper } from './utils/web3_wrapper';
+import { provider, txDefaults, web3Wrapper } from '../src/utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
@@ -32,11 +30,15 @@ describe('UnlimitedAllowanceToken', () => {
const accounts = await web3Wrapper.getAvailableAddressesAsync();
owner = accounts[0];
spender = accounts[1];
- const tokenInstance = await deployer.deployAsync(
- ContractName.DummyERC20Token,
- constants.DUMMY_ERC20_TOKEN_ARGS,
+ token = await DummyERC20TokenContract.deployFrom0xArtifactAsync(
+ artifacts.DummyERC20Token,
+ provider,
+ txDefaults,
+ constants.DUMMY_TOKEN_NAME,
+ constants.DUMMY_TOKEN_SYMBOL,
+ constants.DUMMY_TOKEN_DECIMALS,
+ constants.DUMMY_TOKEN_TOTAL_SUPPLY,
);
- token = new DummyERC20TokenContract(tokenInstance.abi, tokenInstance.address, provider);
await token.mint.sendTransactionAsync(MAX_MINT_VALUE, { from: owner });
tokenAddress = token.address;
});
diff --git a/packages/contracts/test/utils/deployer.ts b/packages/contracts/test/utils/deployer.ts
deleted file mode 100644
index 967cdd903..000000000
--- a/packages/contracts/test/utils/deployer.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-import { Deployer } from '@0xproject/deployer';
-import { devConstants } from '@0xproject/dev-utils';
-import * as path from 'path';
-
-import { constants } from '../../src/utils/constants';
-
-import { web3 } from './web3_wrapper';
-
-const deployerOpts = {
- provider: web3.currentProvider,
- artifactsDir: path.resolve('lib', 'src', 'artifacts'),
- networkId: constants.TESTRPC_NETWORK_ID,
- defaults: {
- gas: devConstants.GAS_ESTIMATE,
- },
-};
-
-export const deployer = new Deployer(deployerOpts);
diff --git a/packages/contracts/test/zrx_token.ts b/packages/contracts/test/zrx_token.ts
index a5de67f64..5de751780 100644
--- a/packages/contracts/test/zrx_token.ts
+++ b/packages/contracts/test/zrx_token.ts
@@ -6,12 +6,10 @@ import * as chai from 'chai';
import * as Web3 from 'web3';
import { ZRXTokenContract } from '../src/contract_wrappers/generated/zrx_token';
+import { artifacts } from '../src/utils/artifacts';
+import { chaiSetup } from '../src/utils/chai_setup';
import { constants } from '../src/utils/constants';
-import { ContractName } from '../src/utils/types';
-
-import { chaiSetup } from './utils/chai_setup';
-import { deployer } from './utils/deployer';
-import { provider, web3Wrapper } from './utils/web3_wrapper';
+import { provider, txDefaults, web3Wrapper } from '../src/utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
@@ -34,8 +32,7 @@ describe('ZRXToken', () => {
zeroEx = new ZeroEx(provider, {
networkId: constants.TESTRPC_NETWORK_ID,
});
- const zrxInstance = await deployer.deployAsync(ContractName.ZRXToken);
- zrxToken = new ZRXTokenContract(zrxInstance.abi, zrxInstance.address, provider);
+ zrxToken = await ZRXTokenContract.deployFrom0xArtifactAsync(artifacts.ZRX, provider, txDefaults);
zrxAddress = zrxToken.address;
MAX_UINT = zeroEx.token.UNLIMITED_ALLOWANCE_IN_BASE_UNITS;
});
diff --git a/packages/contracts/tsconfig.json b/packages/contracts/tsconfig.json
index 717415073..86b33ede7 100644
--- a/packages/contracts/tsconfig.json
+++ b/packages/contracts/tsconfig.json
@@ -6,6 +6,13 @@
"declaration": false,
"allowJs": true
},
- "include": ["./globals.d.ts", "./src/**/*", "./util/**/*", "./test/**/*", "./migrations/**/*"],
+ "include": [
+ "./globals.d.ts",
+ "./contract_wrappers",
+ "./src/**/*",
+ "./utils/**/*",
+ "./test/**/*",
+ "./migrations/**/*"
+ ],
"exclude": ["./deploy/solc/solc_bin"]
}