Refactor @0x/contracts-utils from @0x/contracts-core

This commit is contained in:
Leonid Logvinov 2018-12-04 14:41:18 +01:00
parent 79f5e36edb
commit e8d0aff333
No known key found for this signature in database
GPG Key ID: 0DD294BFDE8C95D4
49 changed files with 334 additions and 55 deletions

2
.gitignore vendored
View File

@ -81,6 +81,7 @@ packages/testnet-faucets/server/
# generated contract artifacts/
contracts/core/generated-artifacts/
contracts/multisig/generated-artifacts/
contracts/utils/generated-artifacts/
packages/sol-cov/test/fixtures/artifacts/
packages/metacoin/artifacts/
@ -88,6 +89,7 @@ packages/metacoin/artifacts/
packages/abi-gen-wrappers/wrappers
contracts/core/generated-wrappers/
contracts/multisig/generated-wrappers/
contracts/utils/generated-wrappers/
packages/metacoin/src/contract_wrappers
# solc-bin in sol-compiler

View File

@ -4,6 +4,8 @@ lib
/contracts/core/generated-artifacts
/contracts/multisig/generated-wrappers
/contracts/multisig/generated-artifacts
/contracts/utils/generated-wrappers
/contracts/utils/generated-artifacts
/packages/abi-gen-wrappers/src/generated-wrappers
/packages/contract-artifacts/artifacts
/python-packages/order_utils/src/zero_ex/contract_artifacts/artifacts

View File

@ -44,8 +44,6 @@
"ReentrantERC20Token",
"TestAssetProxyOwner",
"TestAssetProxyDispatcher",
"TestConstants",
"TestLibBytes",
"TestLibs",
"TestExchangeInternals",
"TestSignatureValidator",

View File

@ -19,7 +19,7 @@
pragma solidity 0.4.24;
import "../../protocol/Exchange/interfaces/IWallet.sol";
import "../../utils/LibBytes/LibBytes.sol";
import "@0x/contracts-utils/contracts/utils/LibBytes/LibBytes.sol";
contract Wallet is

View File

@ -21,7 +21,7 @@ pragma experimental ABIEncoderV2;
import "../../protocol/Exchange/interfaces/IExchange.sol";
import "../../protocol/Exchange/libs/LibOrder.sol";
import "../../utils/Ownable/Ownable.sol";
import "@0x/contracts-utils/contracts/utils/Ownable/Ownable.sol";
contract Whitelist is

View File

@ -22,8 +22,8 @@ pragma experimental ABIEncoderV2;
import "../../protocol/Exchange/interfaces/IExchange.sol";
import "../../protocol/Exchange/libs/LibOrder.sol";
import "../../tokens/ERC20Token/IERC20Token.sol";
import "../../utils/LibBytes/LibBytes.sol";
import "../../utils/SafeMath/SafeMath.sol";
import "@0x/contracts-utils/contracts/utils/LibBytes/LibBytes.sol";
import "@0x/contracts-utils/contracts/utils/SafeMath/SafeMath.sol";
contract DutchAuction is

View File

@ -18,8 +18,8 @@
pragma solidity 0.4.24;
import "../../utils/LibBytes/LibBytes.sol";
import "../../utils/Ownable/Ownable.sol";
import "@0x/contracts-utils/contracts/utils/LibBytes/LibBytes.sol";
import "@0x/contracts-utils/contracts/utils/Ownable/Ownable.sol";
import "../../tokens/ERC20Token/IERC20Token.sol";
import "../../tokens/ERC721Token/IERC721Token.sol";
import "./libs/LibConstants.sol";

View File

@ -24,7 +24,7 @@ import "./mixins/MWeth.sol";
import "./mixins/MAssets.sol";
import "./mixins/MExchangeWrapper.sol";
import "./interfaces/IForwarderCore.sol";
import "../../utils/LibBytes/LibBytes.sol";
import "@0x/contracts-utils/contracts/utils/LibBytes/LibBytes.sol";
import "../../protocol/Exchange/libs/LibOrder.sol";
import "../../protocol/Exchange/libs/LibFillResults.sol";
import "../../protocol/Exchange/libs/LibMath.sol";

View File

@ -18,7 +18,7 @@
pragma solidity 0.4.24;
import "../../../utils/LibBytes/LibBytes.sol";
import "@0x/contracts-utils/contracts/utils/LibBytes/LibBytes.sol";
import "../../../protocol/Exchange/interfaces/IExchange.sol";
import "../../../tokens/EtherToken/IEtherToken.sol";
import "../../../tokens/ERC20Token/IERC20Token.sol";

View File

@ -23,7 +23,7 @@ import "../../protocol/Exchange/interfaces/IExchange.sol";
import "../../protocol/Exchange/libs/LibOrder.sol";
import "../../tokens/ERC20Token/IERC20Token.sol";
import "../../tokens/ERC721Token/IERC721Token.sol";
import "../../utils/LibBytes/LibBytes.sol";
import "@0x/contracts-utils/contracts/utils/LibBytes/LibBytes.sol";
contract OrderValidator {

View File

@ -18,7 +18,7 @@
pragma solidity 0.4.24;
import "../../utils/Ownable/Ownable.sol";
import "@0x/contracts-utils/contracts/utils/Ownable/Ownable.sol";
import "./mixins/MAuthorizable.sol";

View File

@ -18,7 +18,7 @@
pragma solidity 0.4.24;
import "../../../utils/Ownable/IOwnable.sol";
import "@0x/contracts-utils/contracts/utils/Ownable/IOwnable.sol";
contract IAuthorizable is

View File

@ -19,7 +19,7 @@
pragma solidity 0.4.24;
import "@0x/contracts-multisig/contracts/multisig/MultiSigWalletWithTimeLock.sol";
import "../../utils/LibBytes/LibBytes.sol";
import "@0x/contracts-utils/contracts/utils/LibBytes/LibBytes.sol";
contract AssetProxyOwner is

View File

@ -18,7 +18,7 @@
pragma solidity 0.4.24;
import "../../utils/Ownable/Ownable.sol";
import "@0x/contracts-utils/contracts/utils/Ownable/Ownable.sol";
import "./mixins/MAssetProxyDispatcher.sol";
import "../AssetProxy/interfaces/IAssetProxy.sol";

View File

@ -19,7 +19,7 @@
pragma solidity 0.4.24;
pragma experimental ABIEncoderV2;
import "../../utils/ReentrancyGuard/ReentrancyGuard.sol";
import "@0x/contracts-utils/contracts/utils/ReentrancyGuard/ReentrancyGuard.sol";
import "./libs/LibConstants.sol";
import "./libs/LibFillResults.sol";
import "./libs/LibOrder.sol";

View File

@ -14,7 +14,7 @@
pragma solidity 0.4.24;
pragma experimental ABIEncoderV2;
import "../../utils/ReentrancyGuard/ReentrancyGuard.sol";
import "@0x/contracts-utils/contracts/utils/ReentrancyGuard/ReentrancyGuard.sol";
import "./libs/LibConstants.sol";
import "./libs/LibMath.sol";
import "./libs/LibOrder.sol";

View File

@ -18,8 +18,8 @@
pragma solidity 0.4.24;
import "../../utils/LibBytes/LibBytes.sol";
import "../../utils/ReentrancyGuard/ReentrancyGuard.sol";
import "@0x/contracts-utils/contracts/utils/LibBytes/LibBytes.sol";
import "@0x/contracts-utils/contracts/utils/ReentrancyGuard/ReentrancyGuard.sol";
import "./mixins/MSignatureValidator.sol";
import "./mixins/MTransactions.sol";
import "./interfaces/IWallet.sol";

View File

@ -19,7 +19,7 @@
pragma solidity 0.4.24;
pragma experimental ABIEncoderV2;
import "../../utils/ReentrancyGuard/ReentrancyGuard.sol";
import "@0x/contracts-utils/contracts/utils/ReentrancyGuard/ReentrancyGuard.sol";
import "./libs/LibMath.sol";
import "./libs/LibOrder.sol";
import "./libs/LibFillResults.sol";

View File

@ -18,7 +18,7 @@
pragma solidity 0.4.24;
import "../../../utils/SafeMath/SafeMath.sol";
import "@0x/contracts-utils/contracts/utils/SafeMath/SafeMath.sol";
contract LibFillResults is

View File

@ -18,7 +18,7 @@
pragma solidity 0.4.24;
import "../../../utils/SafeMath/SafeMath.sol";
import "@0x/contracts-utils/contracts/utils/SafeMath/SafeMath.sol";
contract LibMath is

View File

@ -18,7 +18,7 @@
pragma solidity 0.4.24;
import "../../utils/Ownable/Ownable.sol";
import "@0x/contracts-utils/contracts/utils/Ownable/Ownable.sol";
import "../../tokens/ERC20Token/MintableERC20Token.sol";

View File

@ -19,7 +19,7 @@
pragma solidity 0.4.24;
import "../../tokens/ERC721Token/MintableERC721Token.sol";
import "../../utils/Ownable/Ownable.sol";
import "@0x/contracts-utils/contracts/utils/Ownable/Ownable.sol";
// solhint-disable no-empty-blocks

View File

@ -19,7 +19,7 @@
pragma solidity 0.4.24;
pragma experimental ABIEncoderV2;
import "../../utils/LibBytes/LibBytes.sol";
import "@0x/contracts-utils/contracts/utils/LibBytes/LibBytes.sol";
import "../../tokens/ERC20Token/ERC20Token.sol";
import "../../protocol/Exchange/interfaces/IExchange.sol";
import "../../protocol/Exchange/libs/LibOrder.sol";

View File

@ -18,7 +18,7 @@
pragma solidity 0.4.24;
import "../../utils/SafeMath/SafeMath.sol";
import "@0x/contracts-utils/contracts/utils/SafeMath/SafeMath.sol";
import "./UnlimitedAllowanceERC20Token.sol";

View File

@ -20,7 +20,7 @@ pragma solidity 0.4.24;
import "./IERC721Token.sol";
import "./IERC721Receiver.sol";
import "../../utils/SafeMath/SafeMath.sol";
import "@0x/contracts-utils/contracts/utils/SafeMath/SafeMath.sol";
contract ERC721Token is

View File

@ -75,6 +75,7 @@
"@0x/base-contract": "^3.0.8",
"@0x/order-utils": "^3.0.4",
"@0x/contracts-multisig": "^1.0.0",
"@0x/contracts-utils": "^1.0.0",
"@0x/types": "^1.3.0",
"@0x/typescript-typings": "^3.0.4",
"@0x/utils": "^2.0.6",

View File

@ -25,9 +25,7 @@ import * as OrderValidator from '../../generated-artifacts/OrderValidator.json';
import * as ReentrantERC20Token from '../../generated-artifacts/ReentrantERC20Token.json';
import * as TestAssetProxyDispatcher from '../../generated-artifacts/TestAssetProxyDispatcher.json';
import * as TestAssetProxyOwner from '../../generated-artifacts/TestAssetProxyOwner.json';
import * as TestConstants from '../../generated-artifacts/TestConstants.json';
import * as TestExchangeInternals from '../../generated-artifacts/TestExchangeInternals.json';
import * as TestLibBytes from '../../generated-artifacts/TestLibBytes.json';
import * as TestLibs from '../../generated-artifacts/TestLibs.json';
import * as TestSignatureValidator from '../../generated-artifacts/TestSignatureValidator.json';
import * as TestStaticCallReceiver from '../../generated-artifacts/TestStaticCallReceiver.json';
@ -63,9 +61,7 @@ export const artifacts = {
ReentrantERC20Token: ReentrantERC20Token as ContractArtifact,
TestAssetProxyDispatcher: TestAssetProxyDispatcher as ContractArtifact,
TestAssetProxyOwner: TestAssetProxyOwner as ContractArtifact,
TestConstants: TestConstants as ContractArtifact,
TestExchangeInternals: TestExchangeInternals as ContractArtifact,
TestLibBytes: TestLibBytes as ContractArtifact,
TestLibs: TestLibs as ContractArtifact,
TestSignatureValidator: TestSignatureValidator as ContractArtifact,
TestStaticCallReceiver: TestStaticCallReceiver as ContractArtifact,

View File

@ -20,9 +20,7 @@ export * from '../../generated-wrappers/order_validator';
export * from '../../generated-wrappers/reentrant_erc20_token';
export * from '../../generated-wrappers/test_asset_proxy_dispatcher';
export * from '../../generated-wrappers/test_asset_proxy_owner';
export * from '../../generated-wrappers/test_constants';
export * from '../../generated-wrappers/test_exchange_internals';
export * from '../../generated-wrappers/test_lib_bytes';
export * from '../../generated-wrappers/test_libs';
export * from '../../generated-wrappers/test_signature_validator';
export * from '../../generated-wrappers/test_static_call_receiver';

View File

@ -13,7 +13,6 @@ import { SignedOrder } from '@0x/types';
import { BigNumber } from '@0x/utils';
import * as chai from 'chai';
import { TestConstantsContract } from '../../generated-wrappers/test_constants';
import { TestLibsContract } from '../../generated-wrappers/test_libs';
import { artifacts } from '../../src/artifacts';
@ -26,7 +25,6 @@ describe('Exchange libs', () => {
let signedOrder: SignedOrder;
let orderFactory: OrderFactory;
let libs: TestLibsContract;
let testConstants: TestConstantsContract;
before(async () => {
await blockchainLifecycle.startAsync();
@ -38,11 +36,6 @@ describe('Exchange libs', () => {
const accounts = await web3Wrapper.getAvailableAddressesAsync();
const makerAddress = accounts[0];
libs = await TestLibsContract.deployFrom0xArtifactAsync(artifacts.TestLibs, provider, txDefaults);
testConstants = await TestConstantsContract.deployFrom0xArtifactAsync(
artifacts.TestConstants,
provider,
txDefaults,
);
const defaultOrderParams = {
...constants.STATIC_ORDER_PARAMS,
@ -62,15 +55,6 @@ describe('Exchange libs', () => {
afterEach(async () => {
await blockchainLifecycle.revertAsync();
});
describe('LibConstants', () => {
describe('ZRX_ASSET_DATA', () => {
it('should have the correct ZRX_ASSET_DATA', async () => {
const isValid = await testConstants.assertValidZrxAssetData.callAsync();
expect(isValid).to.be.equal(true);
});
});
});
// Note(albrow): These tests are designed to be supplemental to the
// combinatorial tests in test/exchange/internal. They test specific edge
// cases that are not covered by the combinatorial tests.

View File

@ -32,9 +32,7 @@
"./generated-artifacts/ReentrantERC20Token.json",
"./generated-artifacts/TestAssetProxyDispatcher.json",
"./generated-artifacts/TestAssetProxyOwner.json",
"./generated-artifacts/TestConstants.json",
"./generated-artifacts/TestExchangeInternals.json",
"./generated-artifacts/TestLibBytes.json",
"./generated-artifacts/TestLibs.json",
"./generated-artifacts/TestSignatureValidator.json",
"./generated-artifacts/TestStaticCallReceiver.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"
}
}

70
contracts/utils/README.md Normal file
View File

@ -0,0 +1,70 @@
## Contracts utils
Smart contracts utils used in the 0x protocol.
## Usage
Contracts can be found in the [contracts](./contracts) directory. The contents of this directory are broken down into the following subdirectories:
* [utils](./contracts/utils)
* This directory contains libraries and utils.
* [test](./contracts/test)
* This directory contains mocks and other contracts that are used solely for testing contracts within the other directories.
## 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-utils yarn build
```
Or continuously rebuild on change:
```bash
PKG=@0x/contracts-utils 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": ["TestConstants", "TestLibBytes", "LibBytes", "Ownable", "IOwnable", "ReentrancyGuard", "SafeMath"]
}

View File

@ -18,7 +18,7 @@
pragma solidity 0.4.24;
import "../../utils/LibBytes/LibBytes.sol";
import "@0x/contracts-utils/contracts/utils/LibBytes/LibBytes.sol";
// solhint-disable max-line-length

View File

@ -18,7 +18,7 @@
pragma solidity 0.4.24;
import "../../utils/LibBytes/LibBytes.sol";
import "@0x/contracts-utils/contracts/utils/LibBytes/LibBytes.sol";
contract TestLibBytes {

View File

@ -0,0 +1,89 @@
{
"private": true,
"name": "@0x/contracts-utils",
"version": "1.0.0",
"engines": {
"node": ">=6.12"
},
"description": "Smart contract utils 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/@(IOwnable|Ownable|LibBytes|ReentrancyGuard|SafeMath|TestConstants|TestLibBytes).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-multisig": "^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",
"ethereum-types": "^1.1.2",
"ethereumjs-util": "^5.1.1",
"lodash": "^4.17.5"
},
"publishConfig": {
"access": "public"
}
}

View File

@ -0,0 +1,19 @@
import { ContractArtifact } from 'ethereum-types';
import * as IOwnable from '../../generated-artifacts/IOwnable.json';
import * as LibBytes from '../../generated-artifacts/LibBytes.json';
import * as Ownable from '../../generated-artifacts/Ownable.json';
import * as ReentrancyGuard from '../../generated-artifacts/ReentrancyGuard.json';
import * as SafeMath from '../../generated-artifacts/SafeMath.json';
import * as TestConstants from '../../generated-artifacts/TestConstants.json';
import * as TestLibBytes from '../../generated-artifacts/TestLibBytes.json';
export const artifacts = {
TestConstants: TestConstants as ContractArtifact,
TestLibBytes: TestLibBytes as ContractArtifact,
IOwnable: IOwnable as ContractArtifact,
LibBytes: LibBytes as ContractArtifact,
Ownable: Ownable as ContractArtifact,
SafeMath: SafeMath as ContractArtifact,
ReentrancyGuard: ReentrancyGuard as ContractArtifact,
};

View File

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

View File

@ -0,0 +1,2 @@
export * from '../../generated-wrappers/test_constants';
export * from '../../generated-wrappers/test_lib_bytes';

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

@ -16,8 +16,8 @@ import * as chai from 'chai';
import ethUtil = require('ethereumjs-util');
import * as _ from 'lodash';
import { TestLibBytesContract } from '../../generated-wrappers/test_lib_bytes';
import { artifacts } from '../../src/artifacts';
import { TestLibBytesContract } from '../generated-wrappers/test_lib_bytes';
import { artifacts } from '../src';
chaiSetup.configure();
const expect = chai.expect;

View File

@ -0,0 +1,34 @@
import { chaiSetup, provider, txDefaults, web3Wrapper } from '@0x/contracts-test-utils';
import { BlockchainLifecycle } from '@0x/dev-utils';
import * as chai from 'chai';
import { TestConstantsContract } from '../generated-wrappers/test_constants';
import { artifacts } from '../src';
chaiSetup.configure();
const expect = chai.expect;
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
describe('Libs', () => {
beforeEach(async () => {
await blockchainLifecycle.startAsync();
});
afterEach(async () => {
await blockchainLifecycle.revertAsync();
});
describe('LibConstants', () => {
describe('ZRX_ASSET_DATA', () => {
it('should have the correct ZRX_ASSET_DATA', async () => {
const testConstants = await TestConstantsContract.deployFrom0xArtifactAsync(
artifacts.TestConstants,
provider,
txDefaults,
);
const isValid = await testConstants.assertValidZrxAssetData.callAsync();
expect(isValid).to.be.equal(true);
});
});
});
});

View File

@ -0,0 +1,19 @@
{
"extends": "../../tsconfig",
"compilerOptions": {
"outDir": "lib",
"rootDir": ".",
"resolveJsonModule": true
},
"include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*"],
"files": [
"./generated-artifacts/TestConstants.json",
"./generated-artifacts/TestLibBytes.json",
"./generated-artifacts/IOwnable.json",
"./generated-artifacts/Ownable.json",
"./generated-artifacts/LibBytes.json",
"./generated-artifacts/SafeMath.json",
"./generated-artifacts/ReentrancyGuard.json"
],
"exclude": ["./deploy/solc/solc_bin"]
}

View File

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