Separate forwarder into own package

This commit is contained in:
Amir Bandeali 2019-01-21 21:32:59 -08:00
parent f9c29c3e74
commit efbfd08aa0
56 changed files with 371 additions and 8 deletions

View File

@ -49,6 +49,7 @@ jobs:
- run: yarn wsrun test:circleci @0x/contracts-extensions
- run: yarn wsrun test:circleci @0x/contracts-asset-proxy
- run: yarn wsrun test:circleci @0x/contracts-exchange
- run: yarn wsrun test:circleci @0x/contracts-exchange-forwarder
test-contracts-geth:
docker:
- image: circleci/node:9-browsers
@ -68,6 +69,7 @@ jobs:
- run: yarn wsrun test:circleci @0x/contracts-extensions
- run: yarn wsrun test:circleci @0x/contracts-asset-proxy
- run: yarn wsrun test:circleci @0x/contracts-exchange
- run: yarn wsrun test:circleci @0x/contracts-exchange-forwarder
test-publish:
resource_class: medium+
docker:

2
.gitignore vendored
View File

@ -91,6 +91,7 @@ contracts/exchange-libs/generated-artifacts/
contracts/erc20/generated-artifacts/
contracts/erc721/generated-artifacts/
contracts/extensions/generated-artifacts/
contracts/exchange-forwarder/generated-artifacts/
packages/sol-tracing-utils/test/fixtures/artifacts/
packages/metacoin/artifacts/
@ -104,6 +105,7 @@ contracts/exchange-libs/generated-wrappers/
contracts/erc20/generated-wrappers/
contracts/erc721/generated-wrappers/
contracts/extensions/generated-wrappers/
contracts/exchange-forwarder/generated-wrappers/
packages/metacoin/src/contract_wrappers
# solc-bin in sol-compiler

View File

@ -16,6 +16,8 @@ lib
/contracts/erc721/generated-artifacts
/contracts/extensions/generated-wrappers
/contracts/extensions/generated-artifacts
/contracts/exchange-forwarder/generated-wrappers
/contracts/exchange-forwarder/generated-artifacts
/packages/abi-gen-wrappers/src/generated-wrappers
/packages/contract-artifacts/artifacts
/python-packages/contract_artifacts/src/zero_ex/contract_artifacts/artifacts

View File

@ -0,0 +1,74 @@
[
{
"version": "2.0.0",
"changes": [
{
"note": "Upgrade the bignumber.js to v8.0.2",
"pr": 1517
}
]
},
{
"timestamp": 1547747677,
"version": "1.2.3",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1547561734,
"version": "1.2.2",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1547225310,
"version": "1.2.1",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "1.2.0",
"changes": [
{
"note": "Added Dutch Auction Wrapper",
"pr": 1465
}
],
"timestamp": 1547040760
},
{
"version": "1.1.0",
"changes": [
{
"note": "Added Balance Threshold Filter",
"pr": 1383
},
{
"note": "Add OrderMatcher",
"pr": 1117
},
{
"note": "Add OrderValidator",
"pr": 1464
}
]
},
{
"timestamp": 1544741676,
"version": "1.0.2",
"changes": [
{
"note": "Dependencies updated"
}
]
}
]

View File

@ -0,0 +1,32 @@
<!--
changelogUtils.file is auto-generated using the monorepo-scripts package. Don't edit directly.
Edit the package's CHANGELOG.json file only.
-->
CHANGELOG
## v1.2.3 - _January 17, 2019_
* Dependencies updated
## v1.2.2 - _January 15, 2019_
* Dependencies updated
## v1.2.1 - _January 11, 2019_
* Dependencies updated
## v1.2.0 - _January 9, 2019_
* Added Dutch Auction Wrapper (#1465)
## v1.1.0 - _Invalid date_
* Added Balance Threshold Filter (#1383)
* Add OrderMatcher (#1117)
* Add OrderValidator (#1464)
## v1.0.2 - _December 13, 2018_
* Dependencies updated

View File

@ -0,0 +1,31 @@
[
{
"name": "Forwarder",
"version": "1.1.0",
"changes": [
{
"note": "Round up when calculating remaining amounts in marketBuy functions",
"pr": 1162,
"networks": {
"1": "0x5468a1dc173652ee28d249c271fa9933144746b1",
"3": "0x2240dab907db71e64d3e0dba4800c83b5c502d4e",
"42": "0x17992e4ffb22730138e4b62aaa6367fa9d3699a6"
}
}
]
},
{
"name": "Forwarder",
"version": "1.0.0",
"changes": [
{
"note": "protocol v2 deploy",
"networks": {
"1": "0x7afc2d5107af94c462a194d2c21b5bdd238709d6",
"3": "0x3983e204b12b3c02fb0638caf2cd406a62e0ead3",
"42": "0xd85e2fa7e7e252b27b01bf0d65c946959d2f45b8"
}
}
]
}
]

View File

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

View File

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

View File

@ -0,0 +1,86 @@
{
"name": "@0x/contracts-exchange-forwarder",
"version": "1.2.3",
"engines": {
"node": ">=6.12"
},
"description": "Smart contract extensions of 0x protocol",
"main": "lib/src/index.js",
"directories": {
"test": "test"
},
"scripts": {
"build": "yarn pre_build && tsc -b",
"build:ci": "yarn build",
"pre_build": "run-s compile generate_contract_wrappers",
"test": "yarn run_mocha",
"rebuild_and_test": "run-s build test",
"test:coverage": "SOLIDITY_COVERAGE=true run-s build run_mocha coverage:report:text coverage:report:lcov",
"test:profiler": "SOLIDITY_PROFILER=true run-s build run_mocha profiler:report:html",
"test:trace": "SOLIDITY_REVERT_TRACE=true run-s build run_mocha",
"run_mocha": "mocha --require source-map-support/register --require make-promises-safe 'lib/test/**/*.js' --timeout 100000 --bail --exit",
"compile": "sol-compiler",
"watch": "sol-compiler -w",
"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 -c ../.solhint.json contracts/**/**/**/**/*.sol"
},
"config": {
"abis": "generated-artifacts/@(Forwarder).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/extensions/README.md",
"devDependencies": {
"@0x/abi-gen": "^1.0.22",
"@0x/contract-wrappers": "^5.0.1",
"@0x/contracts-test-utils": "^2.0.1",
"@0x/dev-utils": "^1.0.24",
"@0x/sol-compiler": "^2.0.2",
"@0x/tslint-config": "^2.0.2",
"@types/lodash": "4.14.104",
"@types/node": "*",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
"chai-bignumber": "^3.0.0",
"dirty-chai": "^2.0.1",
"make-promises-safe": "^1.1.0",
"mocha": "^4.1.0",
"npm-run-all": "^4.1.2",
"shx": "^0.2.2",
"solhint": "^1.4.1",
"tslint": "5.11.0",
"typescript": "3.0.1"
},
"dependencies": {
"@0x/base-contract": "^3.0.13",
"@0x/contracts-asset-proxy": "^2.2.3",
"@0x/contracts-exchange-libs": "^1.0.6",
"@0x/contracts-exchange": "^2.2.3",
"@0x/contracts-erc20": "^1.0.6",
"@0x/contracts-erc721": "^1.0.6",
"@0x/contracts-utils": "^1.0.6",
"@0x/order-utils": "^3.1.2",
"@0x/types": "^1.5.2",
"@0x/typescript-typings": "^3.0.8",
"@0x/utils": "^3.0.1",
"@0x/web3-wrapper": "^3.2.4",
"ethereum-types": "^1.1.6",
"lodash": "^4.17.5"
},
"publishConfig": {
"access": "public"
}
}

View File

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

View File

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

View File

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

View File

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

View File

@ -0,0 +1 @@
export * from './forwarder_wrapper';

View File

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

View File

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

View File

@ -18,5 +18,5 @@
}
}
},
"contracts": ["BalanceThresholdFilter", "DutchAuction", "Forwarder", "OrderMatcher", "OrderValidator"]
"contracts": ["BalanceThresholdFilter", "DutchAuction", "OrderMatcher", "OrderValidator"]
}

View File

@ -32,7 +32,7 @@
"lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol"
},
"config": {
"abis": "generated-artifacts/@(BalanceThresholdFilter|DutchAuction|Forwarder|OrderMatcher|OrderValidator).json"
"abis": "generated-artifacts/@(BalanceThresholdFilter|DutchAuction|OrderMatcher|OrderValidator).json"
},
"repository": {
"type": "git",

View File

@ -2,14 +2,12 @@ import { ContractArtifact } from 'ethereum-types';
import * as BalanceThresholdFilter from '../../generated-artifacts/BalanceThresholdFilter.json';
import * as DutchAuction from '../../generated-artifacts/DutchAuction.json';
import * as Forwarder from '../../generated-artifacts/Forwarder.json';
import * as OrderMatcher from '../../generated-artifacts/OrderMatcher.json';
import * as OrderValidator from '../../generated-artifacts/OrderValidator.json';
export const artifacts = {
BalanceThresholdFilter: BalanceThresholdFilter as ContractArtifact,
DutchAuction: DutchAuction as ContractArtifact,
Forwarder: Forwarder as ContractArtifact,
OrderMatcher: OrderMatcher as ContractArtifact,
OrderValidator: OrderValidator as ContractArtifact,
};

View File

@ -1,5 +1,4 @@
export * from '../../generated-wrappers/balance_threshold_filter';
export * from '../../generated-wrappers/dutch_auction';
export * from '../../generated-wrappers/forwarder';
export * from '../../generated-wrappers/order_matcher';
export * from '../../generated-wrappers/order_validator';

View File

@ -1,3 +1,2 @@
export * from './balance_threshold_wrapper';
export * from './dutch_auction_test_wrapper';
export * from './forwarder_wrapper';

View File

@ -9,7 +9,6 @@
"files": [
"./generated-artifacts/BalanceThresholdFilter.json",
"./generated-artifacts/DutchAuction.json",
"./generated-artifacts/Forwarder.json",
"./generated-artifacts/OrderMatcher.json",
"./generated-artifacts/OrderValidator.json"
],

View File

@ -51,6 +51,7 @@
"@0x/tslint-config": "^2.0.2",
"@types/lodash": "4.14.104",
"@types/node": "*",
"@types/bn.js": "^4.11.0",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
"chai-bignumber": "^3.0.0",
@ -70,6 +71,7 @@
"@0x/typescript-typings": "^3.0.8",
"@0x/utils": "^3.0.1",
"@0x/web3-wrapper": "^3.2.4",
"bn.js": "^4.11.8",
"ethereum-types": "^1.1.6",
"ethereumjs-util": "^5.1.1",
"lodash": "^4.17.5"

View File

@ -42,7 +42,7 @@
"lint": "wsrun lint $PKG --fast-exit --parallel --exclude-missing"
},
"config": {
"contractsPackages": "@0x/contracts-asset-proxy @0x/contracts-erc20 @0x/contracts-erc721 @0x/contracts-exchange @0x/contracts-exchange-libs @0x/contracts-extensions @0x/contracts-multisig @0x/contracts-test-utils @0x/contracts-utils",
"contractsPackages": "@0x/contracts-asset-proxy @0x/contracts-erc20 @0x/contracts-erc721 @0x/contracts-exchange @0x/contracts-exchange-forwarder @0x/contracts-exchange-libs @0x/contracts-extensions @0x/contracts-multisig @0x/contracts-test-utils @0x/contracts-utils",
"mnemonic": "concert load couple harbor equip island argue ramp clarify fence smart topic",
"packagesWithDocPages": "0x.js connect json-schemas subproviders web3-wrapper contract-wrappers order-utils order-watcher sol-compiler sol-coverage sol-profiler sol-trace ethereum-types asset-buyer migrations"
},