Split protocol package into exchange, asset-proxy, and multisig
This commit is contained in:
parent
e2fe907de0
commit
4a4c26a2e3
22
contracts/asset-proxy/compiler.json
Normal file
22
contracts/asset-proxy/compiler.json
Normal 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": ["ERC20Proxy", "ERC721Proxy", "MixinAuthorizable", "MultiAssetProxy"]
|
||||||
|
}
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
import "@0x/contracts-utils/contracts/utils/Ownable/Ownable.sol";
|
import "@0x/contracts-utils/contracts/utils/Ownable.sol";
|
||||||
import "./mixins/MAssetProxyDispatcher.sol";
|
import "./mixins/MAssetProxyDispatcher.sol";
|
||||||
import "@0x/contracts-interfaces/contracts/protocol/AssetProxy/IAssetProxy.sol";
|
import "@0x/contracts-interfaces/contracts/protocol/AssetProxy/IAssetProxy.sol";
|
||||||
|
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
import "@0x/contracts-utils/contracts/utils/Ownable/Ownable.sol";
|
import "@0x/contracts-utils/contracts/utils/Ownable.sol";
|
||||||
import "./mixins/MAuthorizable.sol";
|
import "./mixins/MAuthorizable.sol";
|
||||||
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
pragma solidity 0.4.24;
|
pragma solidity 0.4.24;
|
||||||
|
|
||||||
import "../Exchange/MixinAssetProxyDispatcher.sol";
|
import "./MixinAssetProxyDispatcher.sol";
|
||||||
import "./MixinAuthorizable.sol";
|
import "./MixinAuthorizable.sol";
|
||||||
|
|
||||||
|
|
252
contracts/asset-proxy/generated-artifacts/ERC20Proxy.json
Normal file
252
contracts/asset-proxy/generated-artifacts/ERC20Proxy.json
Normal file
File diff suppressed because one or more lines are too long
252
contracts/asset-proxy/generated-artifacts/ERC721Proxy.json
Normal file
252
contracts/asset-proxy/generated-artifacts/ERC721Proxy.json
Normal file
File diff suppressed because one or more lines are too long
229
contracts/asset-proxy/generated-artifacts/MixinAuthorizable.json
Normal file
229
contracts/asset-proxy/generated-artifacts/MixinAuthorizable.json
Normal file
File diff suppressed because one or more lines are too long
337
contracts/asset-proxy/generated-artifacts/MultiAssetProxy.json
Normal file
337
contracts/asset-proxy/generated-artifacts/MultiAssetProxy.json
Normal file
File diff suppressed because one or more lines are too long
90
contracts/asset-proxy/package.json
Normal file
90
contracts/asset-proxy/package.json
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
{
|
||||||
|
"name": "@0x/contracts-asset-proxy",
|
||||||
|
"version": "2.2.3",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6.12"
|
||||||
|
},
|
||||||
|
"description": "Smart contract components 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/@(ERC20Proxy|ERC721Proxy|MixinAuthorizable|MultiAssetProxy).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/protocol/README.md",
|
||||||
|
"devDependencies": {
|
||||||
|
"@0x/abi-gen": "^1.0.22",
|
||||||
|
"@0x/dev-utils": "^1.0.24",
|
||||||
|
"@0x/sol-compiler": "^2.0.2",
|
||||||
|
"@0x/subproviders": "^2.1.11",
|
||||||
|
"@0x/tslint-config": "^2.0.2",
|
||||||
|
"@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": "^3.0.0",
|
||||||
|
"dirty-chai": "^2.0.1",
|
||||||
|
"ethereumjs-abi": "0.6.5",
|
||||||
|
"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",
|
||||||
|
"yargs": "^10.0.3"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@0x/base-contract": "^3.0.13",
|
||||||
|
"@0x/contracts-interfaces": "^1.0.6",
|
||||||
|
"@0x/contracts-test-utils": "^2.0.1",
|
||||||
|
"@0x/contracts-tokens": "^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",
|
||||||
|
"@types/js-combinatorics": "^0.5.29",
|
||||||
|
"bn.js": "^4.11.8",
|
||||||
|
"ethereum-types": "^1.1.6",
|
||||||
|
"ethereumjs-util": "^5.1.1",
|
||||||
|
"lodash": "^4.17.5"
|
||||||
|
},
|
||||||
|
"publishConfig": {
|
||||||
|
"access": "public"
|
||||||
|
}
|
||||||
|
}
|
13
contracts/asset-proxy/src/artifacts/index.ts
Normal file
13
contracts/asset-proxy/src/artifacts/index.ts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import { ContractArtifact } from 'ethereum-types';
|
||||||
|
|
||||||
|
import * as ERC20Proxy from '../../generated-artifacts/ERC20Proxy.json';
|
||||||
|
import * as ERC721Proxy from '../../generated-artifacts/ERC721Proxy.json';
|
||||||
|
import * as MixinAuthorizable from '../../generated-artifacts/MixinAuthorizable.json';
|
||||||
|
import * as MultiAssetProxy from '../../generated-artifacts/MultiAssetProxy.json';
|
||||||
|
|
||||||
|
export const artifacts = {
|
||||||
|
ERC20Proxy: ERC20Proxy as ContractArtifact,
|
||||||
|
ERC721Proxy: ERC721Proxy as ContractArtifact,
|
||||||
|
MixinAuthorizable: MixinAuthorizable as ContractArtifact,
|
||||||
|
MultiAssetProxy: MultiAssetProxy as ContractArtifact,
|
||||||
|
};
|
4
contracts/asset-proxy/src/wrappers/index.ts
Normal file
4
contracts/asset-proxy/src/wrappers/index.ts
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
export * from '../../generated-wrappers/erc20_proxy';
|
||||||
|
export * from '../../generated-wrappers/erc721_proxy';
|
||||||
|
export * from '../../generated-wrappers/mixin_authorizable';
|
||||||
|
export * from '../../generated-wrappers/multi_asset_proxy';
|
@ -12,8 +12,8 @@ import { BigNumber } from '@0x/utils';
|
|||||||
import * as chai from 'chai';
|
import * as chai from 'chai';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
import { MixinAuthorizableContract } from '../../generated-wrappers/mixin_authorizable';
|
import { MixinAuthorizableContract } from '../generated-wrappers/mixin_authorizable';
|
||||||
import { artifacts } from '../../src/artifacts';
|
import { artifacts } from '../src/artifacts';
|
||||||
|
|
||||||
chaiSetup.configure();
|
chaiSetup.configure();
|
||||||
const expect = chai.expect;
|
const expect = chai.expect;
|
@ -26,12 +26,13 @@ import * as chai from 'chai';
|
|||||||
import { LogWithDecodedArgs } from 'ethereum-types';
|
import { LogWithDecodedArgs } from 'ethereum-types';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
import { ERC20ProxyContract } from '../../generated-wrappers/erc20_proxy';
|
import { ERC20ProxyContract } from '../generated-wrappers/erc20_proxy';
|
||||||
import { ERC721ProxyContract } from '../../generated-wrappers/erc721_proxy';
|
import { ERC721ProxyContract } from '../generated-wrappers/erc721_proxy';
|
||||||
import { MultiAssetProxyContract } from '../../generated-wrappers/multi_asset_proxy';
|
import { MultiAssetProxyContract } from '../generated-wrappers/multi_asset_proxy';
|
||||||
import { artifacts } from '../../src/artifacts';
|
import { artifacts } from '../src/artifacts';
|
||||||
import { ERC20Wrapper } from '../utils/erc20_wrapper';
|
|
||||||
import { ERC721Wrapper } from '../utils/erc721_wrapper';
|
import { ERC20Wrapper } from './utils/erc20_wrapper';
|
||||||
|
import { ERC721Wrapper } from './utils/erc721_wrapper';
|
||||||
|
|
||||||
chaiSetup.configure();
|
chaiSetup.configure();
|
||||||
const expect = chai.expect;
|
const expect = chai.expect;
|
2
contracts/asset-proxy/test/utils/index.ts
Normal file
2
contracts/asset-proxy/test/utils/index.ts
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
export * from './erc20_wrapper';
|
||||||
|
export * from './erc721_wrapper';
|
16
contracts/asset-proxy/tsconfig.json
Normal file
16
contracts/asset-proxy/tsconfig.json
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"extends": "../../tsconfig",
|
||||||
|
"compilerOptions": {
|
||||||
|
"outDir": "lib",
|
||||||
|
"rootDir": ".",
|
||||||
|
"resolveJsonModule": true
|
||||||
|
},
|
||||||
|
"include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*"],
|
||||||
|
"files": [
|
||||||
|
"./generated-artifacts/ERC20Proxy.json",
|
||||||
|
"./generated-artifacts/ERC721Proxy.json",
|
||||||
|
"./generated-artifacts/MixinAuthorizable.json",
|
||||||
|
"./generated-artifacts/MultiAssetProxy.json"
|
||||||
|
],
|
||||||
|
"exclude": ["./deploy/solc/solc_bin"]
|
||||||
|
}
|
65
contracts/exchange/CHANGELOG.json
Normal file
65
contracts/exchange/CHANGELOG.json
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"version": "3.0.0",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Upgrade the bignumber.js to v8.0.2",
|
||||||
|
"pr": 1517
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"timestamp": 1547747677,
|
||||||
|
"version": "2.2.3",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Dependencies updated"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"timestamp": 1547561734,
|
||||||
|
"version": "2.2.2",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Dependencies updated"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"timestamp": 1547225310,
|
||||||
|
"version": "2.2.1",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Dependencies updated"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "2.2.0",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Added LibAddressArray",
|
||||||
|
"pr": 1383
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"note": "Add validation and comments to MultiAssetProxy",
|
||||||
|
"pr": 1455
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"note": "Move OrderValidator to extensions",
|
||||||
|
"pr": 1464
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"timestamp": 1547040760
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"timestamp": 1544741676,
|
||||||
|
"version": "2.1.59",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Dependencies updated"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
28
contracts/exchange/CHANGELOG.md
Normal file
28
contracts/exchange/CHANGELOG.md
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<!--
|
||||||
|
changelogUtils.file is auto-generated using the monorepo-scripts package. Don't edit directly.
|
||||||
|
Edit the package's CHANGELOG.json file only.
|
||||||
|
-->
|
||||||
|
|
||||||
|
CHANGELOG
|
||||||
|
|
||||||
|
## v2.2.3 - _January 17, 2019_
|
||||||
|
|
||||||
|
* Dependencies updated
|
||||||
|
|
||||||
|
## v2.2.2 - _January 15, 2019_
|
||||||
|
|
||||||
|
* Dependencies updated
|
||||||
|
|
||||||
|
## v2.2.1 - _January 11, 2019_
|
||||||
|
|
||||||
|
* Dependencies updated
|
||||||
|
|
||||||
|
## v2.2.0 - _January 9, 2019_
|
||||||
|
|
||||||
|
* Added LibAddressArray (#1383)
|
||||||
|
* Add validation and comments to MultiAssetProxy (#1455)
|
||||||
|
* Move OrderValidator to extensions (#1464)
|
||||||
|
|
||||||
|
## v2.1.59 - _December 13, 2018_
|
||||||
|
|
||||||
|
* Dependencies updated
|
92
contracts/exchange/DEPLOYS.json
Normal file
92
contracts/exchange/DEPLOYS.json
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "MultiAssetProxy",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Add MultiAssetProxy implementation",
|
||||||
|
"pr": 1224
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "OrderValidator",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "remove `getApproved` check from ERC721 approval query",
|
||||||
|
"pr": 1149
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "OrderValidator",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "protocol v2 deploy",
|
||||||
|
"networks": {
|
||||||
|
"1": "0x9463e518dea6810309563c81d5266c1b1d149138",
|
||||||
|
"3": "0x90431a90516ab49af23a0530e04e8c7836e7122f",
|
||||||
|
"42": "0xb389da3d204b412df2f75c6afb3d0a7ce0bc283d"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Exchange",
|
||||||
|
"version": "2.0.0",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "protocol v2 deploy",
|
||||||
|
"networks": {
|
||||||
|
"1": "0x4f833a24e1f95d70f028921e27040ca56e09ab0b",
|
||||||
|
"3": "0x4530c0483a1633c7a1c97d2c53721caff2caaaaf",
|
||||||
|
"42": "0x35dd2932454449b14cee11a94d3674a936d5d7b2"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ERC20Proxy",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "protocol v2 deploy",
|
||||||
|
"networks": {
|
||||||
|
"1": "0x2240dab907db71e64d3e0dba4800c83b5c502d4e",
|
||||||
|
"3": "0xb1408f4c245a23c31b98d2c626777d4c0d766caa",
|
||||||
|
"42": "0xf1ec01d6236d3cd881a0bf0130ea25fe4234003e"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ERC721Proxy",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "protocol v2 deploy",
|
||||||
|
"networks": {
|
||||||
|
"1": "0x208e41fb445f1bb1b6780d58356e81405f3e6127",
|
||||||
|
"3": "0xe654aac058bfbf9f83fcaee7793311dd82f6ddb4",
|
||||||
|
"42": "0x2a9127c745688a165106c11cd4d647d2220af821"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "AssetProxyOwner",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "protocol v2 deploy",
|
||||||
|
"networks": {
|
||||||
|
"1": "0x17992e4ffb22730138e4b62aaa6367fa9d3699a6",
|
||||||
|
"3": "0xf5fa5b5fed2727a0e44ac67f6772e97977aa358b",
|
||||||
|
"42": "0x2c824d2882baa668e0d5202b1e7f2922278703f8"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
74
contracts/exchange/README.md
Normal file
74
contracts/exchange/README.md
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
## Contracts
|
||||||
|
|
||||||
|
Smart contracts that implement the 0x protocol. Addresses of the deployed contracts can be found in the 0x [wiki](https://0xproject.com/wiki#Deployed-Addresses) or the [CHANGELOG](./CHANGELOG.json) of this package.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
Contracts that make up and interact with version 2.0.0 of the protocol can be found in the [contracts](./contracts) directory. The contents of this directory are broken down into the following subdirectories:
|
||||||
|
|
||||||
|
- [protocol](./contracts/protocol)
|
||||||
|
- This directory contains the contracts that make up version 2.0.0. A full specification can be found [here](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md).
|
||||||
|
- [test](./contracts/test)
|
||||||
|
- This directory contains mocks and other contracts that are used solely for testing contracts within the other directories.
|
||||||
|
|
||||||
|
## 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-protocol yarn build
|
||||||
|
```
|
||||||
|
|
||||||
|
Or continuously rebuild on change:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
PKG=@0x/contracts-protocol 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).
|
@ -19,13 +19,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"contracts": [
|
"contracts": [
|
||||||
"AssetProxyOwner",
|
|
||||||
"ERC20Proxy",
|
|
||||||
"ERC721Proxy",
|
|
||||||
"Exchange",
|
"Exchange",
|
||||||
"MixinAuthorizable",
|
|
||||||
"MultiAssetProxy",
|
|
||||||
"TestAssetProxyOwner",
|
|
||||||
"TestAssetProxyDispatcher",
|
"TestAssetProxyDispatcher",
|
||||||
"TestExchangeInternals",
|
"TestExchangeInternals",
|
||||||
"TestSignatureValidator",
|
"TestSignatureValidator",
|
@ -19,7 +19,7 @@
|
|||||||
pragma solidity 0.4.24;
|
pragma solidity 0.4.24;
|
||||||
pragma experimental ABIEncoderV2;
|
pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
import "@0x/contracts-libs/contracts/libs/LibConstants.sol";
|
import "@0x/contracts-exchange-libs/contracts/exchange-libs/LibConstants.sol";
|
||||||
import "./MixinExchangeCore.sol";
|
import "./MixinExchangeCore.sol";
|
||||||
import "./MixinSignatureValidator.sol";
|
import "./MixinSignatureValidator.sol";
|
||||||
import "./MixinWrapperFunctions.sol";
|
import "./MixinWrapperFunctions.sol";
|
@ -0,0 +1,174 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
|
Copyright 2018 ZeroEx Intl.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "@0x/contracts-utils/contracts/utils/Ownable.sol";
|
||||||
|
import "./mixins/MAssetProxyDispatcher.sol";
|
||||||
|
import "@0x/contracts-interfaces/contracts/protocol/AssetProxy/IAssetProxy.sol";
|
||||||
|
|
||||||
|
|
||||||
|
contract MixinAssetProxyDispatcher is
|
||||||
|
Ownable,
|
||||||
|
MAssetProxyDispatcher
|
||||||
|
{
|
||||||
|
// Mapping from Asset Proxy Id's to their respective Asset Proxy
|
||||||
|
mapping (bytes4 => IAssetProxy) public assetProxies;
|
||||||
|
|
||||||
|
/// @dev Registers an asset proxy to its asset proxy id.
|
||||||
|
/// Once an asset proxy is registered, it cannot be unregistered.
|
||||||
|
/// @param assetProxy Address of new asset proxy to register.
|
||||||
|
function registerAssetProxy(address assetProxy)
|
||||||
|
external
|
||||||
|
onlyOwner
|
||||||
|
{
|
||||||
|
IAssetProxy assetProxyContract = IAssetProxy(assetProxy);
|
||||||
|
|
||||||
|
// Ensure that no asset proxy exists with current id.
|
||||||
|
bytes4 assetProxyId = assetProxyContract.getProxyId();
|
||||||
|
address currentAssetProxy = assetProxies[assetProxyId];
|
||||||
|
require(
|
||||||
|
currentAssetProxy == address(0),
|
||||||
|
"ASSET_PROXY_ALREADY_EXISTS"
|
||||||
|
);
|
||||||
|
|
||||||
|
// Add asset proxy and log registration.
|
||||||
|
assetProxies[assetProxyId] = assetProxyContract;
|
||||||
|
emit AssetProxyRegistered(
|
||||||
|
assetProxyId,
|
||||||
|
assetProxy
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @dev Gets an asset proxy.
|
||||||
|
/// @param assetProxyId Id of the asset proxy.
|
||||||
|
/// @return The asset proxy registered to assetProxyId. Returns 0x0 if no proxy is registered.
|
||||||
|
function getAssetProxy(bytes4 assetProxyId)
|
||||||
|
external
|
||||||
|
view
|
||||||
|
returns (address)
|
||||||
|
{
|
||||||
|
return assetProxies[assetProxyId];
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @dev Forwards arguments to assetProxy and calls `transferFrom`. Either succeeds or throws.
|
||||||
|
/// @param assetData Byte array encoded for the asset.
|
||||||
|
/// @param from Address to transfer token from.
|
||||||
|
/// @param to Address to transfer token to.
|
||||||
|
/// @param amount Amount of token to transfer.
|
||||||
|
function dispatchTransferFrom(
|
||||||
|
bytes memory assetData,
|
||||||
|
address from,
|
||||||
|
address to,
|
||||||
|
uint256 amount
|
||||||
|
)
|
||||||
|
internal
|
||||||
|
{
|
||||||
|
// Do nothing if no amount should be transferred.
|
||||||
|
if (amount > 0 && from != to) {
|
||||||
|
// Ensure assetData length is valid
|
||||||
|
require(
|
||||||
|
assetData.length > 3,
|
||||||
|
"LENGTH_GREATER_THAN_3_REQUIRED"
|
||||||
|
);
|
||||||
|
|
||||||
|
// Lookup assetProxy. We do not use `LibBytes.readBytes4` for gas efficiency reasons.
|
||||||
|
bytes4 assetProxyId;
|
||||||
|
assembly {
|
||||||
|
assetProxyId := and(mload(
|
||||||
|
add(assetData, 32)),
|
||||||
|
0xFFFFFFFF00000000000000000000000000000000000000000000000000000000
|
||||||
|
)
|
||||||
|
}
|
||||||
|
address assetProxy = assetProxies[assetProxyId];
|
||||||
|
|
||||||
|
// Ensure that assetProxy exists
|
||||||
|
require(
|
||||||
|
assetProxy != address(0),
|
||||||
|
"ASSET_PROXY_DOES_NOT_EXIST"
|
||||||
|
);
|
||||||
|
|
||||||
|
// We construct calldata for the `assetProxy.transferFrom` ABI.
|
||||||
|
// The layout of this calldata is in the table below.
|
||||||
|
//
|
||||||
|
// | Area | Offset | Length | Contents |
|
||||||
|
// | -------- |--------|---------|-------------------------------------------- |
|
||||||
|
// | Header | 0 | 4 | function selector |
|
||||||
|
// | Params | | 4 * 32 | function parameters: |
|
||||||
|
// | | 4 | | 1. offset to assetData (*) |
|
||||||
|
// | | 36 | | 2. from |
|
||||||
|
// | | 68 | | 3. to |
|
||||||
|
// | | 100 | | 4. amount |
|
||||||
|
// | Data | | | assetData: |
|
||||||
|
// | | 132 | 32 | assetData Length |
|
||||||
|
// | | 164 | ** | assetData Contents |
|
||||||
|
|
||||||
|
assembly {
|
||||||
|
/////// Setup State ///////
|
||||||
|
// `cdStart` is the start of the calldata for `assetProxy.transferFrom` (equal to free memory ptr).
|
||||||
|
let cdStart := mload(64)
|
||||||
|
// `dataAreaLength` is the total number of words needed to store `assetData`
|
||||||
|
// As-per the ABI spec, this value is padded up to the nearest multiple of 32,
|
||||||
|
// and includes 32-bytes for length.
|
||||||
|
let dataAreaLength := and(add(mload(assetData), 63), 0xFFFFFFFFFFFE0)
|
||||||
|
// `cdEnd` is the end of the calldata for `assetProxy.transferFrom`.
|
||||||
|
let cdEnd := add(cdStart, add(132, dataAreaLength))
|
||||||
|
|
||||||
|
|
||||||
|
/////// Setup Header Area ///////
|
||||||
|
// This area holds the 4-byte `transferFromSelector`.
|
||||||
|
// bytes4(keccak256("transferFrom(bytes,address,address,uint256)")) = 0xa85e59e4
|
||||||
|
mstore(cdStart, 0xa85e59e400000000000000000000000000000000000000000000000000000000)
|
||||||
|
|
||||||
|
/////// Setup Params Area ///////
|
||||||
|
// Each parameter is padded to 32-bytes. The entire Params Area is 128 bytes.
|
||||||
|
// Notes:
|
||||||
|
// 1. The offset to `assetData` is the length of the Params Area (128 bytes).
|
||||||
|
// 2. A 20-byte mask is applied to addresses to zero-out the unused bytes.
|
||||||
|
mstore(add(cdStart, 4), 128)
|
||||||
|
mstore(add(cdStart, 36), and(from, 0xffffffffffffffffffffffffffffffffffffffff))
|
||||||
|
mstore(add(cdStart, 68), and(to, 0xffffffffffffffffffffffffffffffffffffffff))
|
||||||
|
mstore(add(cdStart, 100), amount)
|
||||||
|
|
||||||
|
/////// Setup Data Area ///////
|
||||||
|
// This area holds `assetData`.
|
||||||
|
let dataArea := add(cdStart, 132)
|
||||||
|
// solhint-disable-next-line no-empty-blocks
|
||||||
|
for {} lt(dataArea, cdEnd) {} {
|
||||||
|
mstore(dataArea, mload(assetData))
|
||||||
|
dataArea := add(dataArea, 32)
|
||||||
|
assetData := add(assetData, 32)
|
||||||
|
}
|
||||||
|
|
||||||
|
/////// Call `assetProxy.transferFrom` using the constructed calldata ///////
|
||||||
|
let success := call(
|
||||||
|
gas, // forward all gas
|
||||||
|
assetProxy, // call address of asset proxy
|
||||||
|
0, // don't send any ETH
|
||||||
|
cdStart, // pointer to start of input
|
||||||
|
sub(cdEnd, cdStart), // length of input
|
||||||
|
cdStart, // write output over input
|
||||||
|
512 // reserve 512 bytes for output
|
||||||
|
)
|
||||||
|
if iszero(success) {
|
||||||
|
revert(cdStart, returndatasize())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -19,11 +19,11 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
pragma experimental ABIEncoderV2;
|
pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
import "@0x/contracts-utils/contracts/utils/ReentrancyGuard/ReentrancyGuard.sol";
|
import "@0x/contracts-utils/contracts/utils/ReentrancyGuard.sol";
|
||||||
import "@0x/contracts-libs/contracts/libs/LibConstants.sol";
|
import "@0x/contracts-exchange-libs/contracts/exchange-libs/LibConstants.sol";
|
||||||
import "@0x/contracts-libs/contracts/libs/LibFillResults.sol";
|
import "@0x/contracts-exchange-libs/contracts/exchange-libs/LibFillResults.sol";
|
||||||
import "@0x/contracts-libs/contracts/libs/LibOrder.sol";
|
import "@0x/contracts-exchange-libs/contracts/exchange-libs/LibOrder.sol";
|
||||||
import "@0x/contracts-libs/contracts/libs/LibMath.sol";
|
import "@0x/contracts-exchange-libs/contracts/exchange-libs/LibMath.sol";
|
||||||
import "./mixins/MExchangeCore.sol";
|
import "./mixins/MExchangeCore.sol";
|
||||||
import "./mixins/MSignatureValidator.sol";
|
import "./mixins/MSignatureValidator.sol";
|
||||||
import "./mixins/MTransactions.sol";
|
import "./mixins/MTransactions.sol";
|
@ -14,11 +14,11 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
pragma experimental ABIEncoderV2;
|
pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
import "@0x/contracts-utils/contracts/utils/ReentrancyGuard/ReentrancyGuard.sol";
|
import "@0x/contracts-utils/contracts/utils/ReentrancyGuard.sol";
|
||||||
import "@0x/contracts-libs/contracts/libs/LibConstants.sol";
|
import "@0x/contracts-exchange-libs/contracts/exchange-libs/LibConstants.sol";
|
||||||
import "@0x/contracts-libs/contracts/libs/LibMath.sol";
|
import "@0x/contracts-exchange-libs/contracts/exchange-libs/LibMath.sol";
|
||||||
import "@0x/contracts-libs/contracts/libs/LibOrder.sol";
|
import "@0x/contracts-exchange-libs/contracts/exchange-libs/LibOrder.sol";
|
||||||
import "@0x/contracts-libs/contracts/libs/LibFillResults.sol";
|
import "@0x/contracts-exchange-libs/contracts/exchange-libs/LibFillResults.sol";
|
||||||
import "./mixins/MExchangeCore.sol";
|
import "./mixins/MExchangeCore.sol";
|
||||||
import "./mixins/MMatchOrders.sol";
|
import "./mixins/MMatchOrders.sol";
|
||||||
import "./mixins/MTransactions.sol";
|
import "./mixins/MTransactions.sol";
|
@ -18,8 +18,8 @@
|
|||||||
|
|
||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
import "@0x/contracts-utils/contracts/utils/LibBytes/LibBytes.sol";
|
import "@0x/contracts-utils/contracts/utils/LibBytes.sol";
|
||||||
import "@0x/contracts-utils/contracts/utils/ReentrancyGuard/ReentrancyGuard.sol";
|
import "@0x/contracts-utils/contracts/utils/ReentrancyGuard.sol";
|
||||||
import "./mixins/MSignatureValidator.sol";
|
import "./mixins/MSignatureValidator.sol";
|
||||||
import "./mixins/MTransactions.sol";
|
import "./mixins/MTransactions.sol";
|
||||||
import "@0x/contracts-interfaces/contracts/protocol/Exchange/IWallet.sol";
|
import "@0x/contracts-interfaces/contracts/protocol/Exchange/IWallet.sol";
|
@ -17,10 +17,10 @@
|
|||||||
*/
|
*/
|
||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
import "@0x/contracts-libs/contracts/libs/LibExchangeErrors.sol";
|
import "@0x/contracts-exchange-libs/contracts/exchange-libs/LibExchangeErrors.sol";
|
||||||
import "./mixins/MSignatureValidator.sol";
|
import "./mixins/MSignatureValidator.sol";
|
||||||
import "./mixins/MTransactions.sol";
|
import "./mixins/MTransactions.sol";
|
||||||
import "@0x/contracts-libs/contracts/libs/LibEIP712.sol";
|
import "@0x/contracts-exchange-libs/contracts/exchange-libs/LibEIP712.sol";
|
||||||
|
|
||||||
|
|
||||||
contract MixinTransactions is
|
contract MixinTransactions is
|
@ -19,11 +19,11 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
pragma experimental ABIEncoderV2;
|
pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
import "@0x/contracts-utils/contracts/utils/ReentrancyGuard/ReentrancyGuard.sol";
|
import "@0x/contracts-utils/contracts/utils/ReentrancyGuard.sol";
|
||||||
import "@0x/contracts-libs/contracts/libs/LibMath.sol";
|
import "@0x/contracts-exchange-libs/contracts/exchange-libs/LibMath.sol";
|
||||||
import "@0x/contracts-libs/contracts/libs/LibOrder.sol";
|
import "@0x/contracts-exchange-libs/contracts/exchange-libs/LibOrder.sol";
|
||||||
import "@0x/contracts-libs/contracts/libs/LibFillResults.sol";
|
import "@0x/contracts-exchange-libs/contracts/exchange-libs/LibFillResults.sol";
|
||||||
import "@0x/contracts-libs/contracts/libs/LibAbiEncoder.sol";
|
import "@0x/contracts-exchange-libs/contracts/exchange-libs/LibAbiEncoder.sol";
|
||||||
import "./mixins/MExchangeCore.sol";
|
import "./mixins/MExchangeCore.sol";
|
||||||
import "./mixins/MWrapperFunctions.sol";
|
import "./mixins/MWrapperFunctions.sol";
|
||||||
|
|
@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
|
Copyright 2018 ZeroEx Intl.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "@0x/contracts-interfaces/contracts/protocol/Exchange/IAssetProxyDispatcher.sol";
|
||||||
|
|
||||||
|
|
||||||
|
contract MAssetProxyDispatcher is
|
||||||
|
IAssetProxyDispatcher
|
||||||
|
{
|
||||||
|
// Logs registration of new asset proxy
|
||||||
|
event AssetProxyRegistered(
|
||||||
|
bytes4 id, // Id of new registered AssetProxy.
|
||||||
|
address assetProxy // Address of new registered AssetProxy.
|
||||||
|
);
|
||||||
|
|
||||||
|
/// @dev Forwards arguments to assetProxy and calls `transferFrom`. Either succeeds or throws.
|
||||||
|
/// @param assetData Byte array encoded for the asset.
|
||||||
|
/// @param from Address to transfer token from.
|
||||||
|
/// @param to Address to transfer token to.
|
||||||
|
/// @param amount Amount of token to transfer.
|
||||||
|
function dispatchTransferFrom(
|
||||||
|
bytes memory assetData,
|
||||||
|
address from,
|
||||||
|
address to,
|
||||||
|
uint256 amount
|
||||||
|
)
|
||||||
|
internal;
|
||||||
|
}
|
@ -19,8 +19,8 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
pragma experimental ABIEncoderV2;
|
pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
import "@0x/contracts-libs/contracts/libs/LibOrder.sol";
|
import "@0x/contracts-exchange-libs/contracts/exchange-libs/LibOrder.sol";
|
||||||
import "@0x/contracts-libs/contracts/libs/LibFillResults.sol";
|
import "@0x/contracts-exchange-libs/contracts/exchange-libs/LibFillResults.sol";
|
||||||
import "@0x/contracts-interfaces/contracts/protocol/Exchange/IExchangeCore.sol";
|
import "@0x/contracts-interfaces/contracts/protocol/Exchange/IExchangeCore.sol";
|
||||||
|
|
||||||
|
|
@ -18,8 +18,8 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
pragma experimental ABIEncoderV2;
|
pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
import "@0x/contracts-libs/contracts/libs/LibOrder.sol";
|
import "@0x/contracts-exchange-libs/contracts/exchange-libs/LibOrder.sol";
|
||||||
import "@0x/contracts-libs/contracts/libs/LibFillResults.sol";
|
import "@0x/contracts-exchange-libs/contracts/exchange-libs/LibFillResults.sol";
|
||||||
import "@0x/contracts-interfaces/contracts/protocol/Exchange/IMatchOrders.sol";
|
import "@0x/contracts-interfaces/contracts/protocol/Exchange/IMatchOrders.sol";
|
||||||
|
|
||||||
|
|
@ -19,8 +19,8 @@
|
|||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
pragma experimental ABIEncoderV2;
|
pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
import "@0x/contracts-libs/contracts/libs/LibOrder.sol";
|
import "@0x/contracts-exchange-libs/contracts/exchange-libs/LibOrder.sol";
|
||||||
import "@0x/contracts-libs/contracts/libs/LibFillResults.sol";
|
import "@0x/contracts-exchange-libs/contracts/exchange-libs/LibFillResults.sol";
|
||||||
import "@0x/contracts-interfaces/contracts/protocol/Exchange/IWrapperFunctions.sol";
|
import "@0x/contracts-interfaces/contracts/protocol/Exchange/IWrapperFunctions.sol";
|
||||||
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
pragma solidity 0.4.24;
|
pragma solidity 0.4.24;
|
||||||
|
|
||||||
import "../../protocol/Exchange/MixinAssetProxyDispatcher.sol";
|
import "../exchange/MixinAssetProxyDispatcher.sol";
|
||||||
|
|
||||||
|
|
||||||
contract TestAssetProxyDispatcher is
|
contract TestAssetProxyDispatcher is
|
@ -19,7 +19,7 @@
|
|||||||
pragma solidity 0.4.24;
|
pragma solidity 0.4.24;
|
||||||
pragma experimental ABIEncoderV2;
|
pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
import "../../protocol/Exchange/Exchange.sol";
|
import "../exchange/Exchange.sol";
|
||||||
|
|
||||||
|
|
||||||
// solhint-disable no-empty-blocks
|
// solhint-disable no-empty-blocks
|
@ -18,8 +18,8 @@
|
|||||||
|
|
||||||
pragma solidity 0.4.24;
|
pragma solidity 0.4.24;
|
||||||
|
|
||||||
import "../../protocol/Exchange/MixinSignatureValidator.sol";
|
import "../exchange/MixinSignatureValidator.sol";
|
||||||
import "../../protocol/Exchange/MixinTransactions.sol";
|
import "../exchange/MixinTransactions.sol";
|
||||||
|
|
||||||
|
|
||||||
contract TestSignatureValidator is
|
contract TestSignatureValidator is
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "@0x/contracts-protocol",
|
"name": "@0x/contracts-exchange",
|
||||||
"version": "2.2.3",
|
"version": "2.2.3",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=6.12"
|
"node": ">=6.12"
|
||||||
@ -32,7 +32,7 @@
|
|||||||
"lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol"
|
"lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol"
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"abis": "generated-artifacts/@(AssetProxyOwner|ERC20Proxy|ERC721Proxy|Exchange|MixinAuthorizable|MultiAssetProxy|TestSignatureValidator|TestAssetProxyOwner|TestAssetProxyDispatcher|TestExchangeInternals|TestStaticCallReceiver).json"
|
"abis": "generated-artifacts/@(ERC20Proxy|ERC721Proxy|Exchange|MixinAuthorizable|MultiAssetProxy|TestSignatureValidator|TestAssetProxyDispatcher|TestExchangeInternals|TestStaticCallReceiver).json"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -70,6 +70,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@0x/base-contract": "^3.0.13",
|
"@0x/base-contract": "^3.0.13",
|
||||||
"@0x/contracts-examples": "^1.0.6",
|
"@0x/contracts-examples": "^1.0.6",
|
||||||
|
"@0x/contracts-asset-proxy": "^2.2.3",
|
||||||
"@0x/contracts-interfaces": "^1.0.6",
|
"@0x/contracts-interfaces": "^1.0.6",
|
||||||
"@0x/contracts-libs": "^1.0.6",
|
"@0x/contracts-libs": "^1.0.6",
|
||||||
"@0x/contracts-multisig": "^1.0.6",
|
"@0x/contracts-multisig": "^1.0.6",
|
@ -1,26 +1,14 @@
|
|||||||
import { ContractArtifact } from 'ethereum-types';
|
import { ContractArtifact } from 'ethereum-types';
|
||||||
|
|
||||||
import * as AssetProxyOwner from '../../generated-artifacts/AssetProxyOwner.json';
|
|
||||||
import * as ERC20Proxy from '../../generated-artifacts/ERC20Proxy.json';
|
|
||||||
import * as ERC721Proxy from '../../generated-artifacts/ERC721Proxy.json';
|
|
||||||
import * as Exchange from '../../generated-artifacts/Exchange.json';
|
import * as Exchange from '../../generated-artifacts/Exchange.json';
|
||||||
import * as MixinAuthorizable from '../../generated-artifacts/MixinAuthorizable.json';
|
|
||||||
import * as MultiAssetProxy from '../../generated-artifacts/MultiAssetProxy.json';
|
|
||||||
import * as TestAssetProxyDispatcher from '../../generated-artifacts/TestAssetProxyDispatcher.json';
|
import * as TestAssetProxyDispatcher from '../../generated-artifacts/TestAssetProxyDispatcher.json';
|
||||||
import * as TestAssetProxyOwner from '../../generated-artifacts/TestAssetProxyOwner.json';
|
|
||||||
import * as TestExchangeInternals from '../../generated-artifacts/TestExchangeInternals.json';
|
import * as TestExchangeInternals from '../../generated-artifacts/TestExchangeInternals.json';
|
||||||
import * as TestSignatureValidator from '../../generated-artifacts/TestSignatureValidator.json';
|
import * as TestSignatureValidator from '../../generated-artifacts/TestSignatureValidator.json';
|
||||||
import * as TestStaticCallReceiver from '../../generated-artifacts/TestStaticCallReceiver.json';
|
import * as TestStaticCallReceiver from '../../generated-artifacts/TestStaticCallReceiver.json';
|
||||||
|
|
||||||
export const artifacts = {
|
export const artifacts = {
|
||||||
AssetProxyOwner: AssetProxyOwner as ContractArtifact,
|
|
||||||
ERC20Proxy: ERC20Proxy as ContractArtifact,
|
|
||||||
ERC721Proxy: ERC721Proxy as ContractArtifact,
|
|
||||||
Exchange: Exchange as ContractArtifact,
|
Exchange: Exchange as ContractArtifact,
|
||||||
MixinAuthorizable: MixinAuthorizable as ContractArtifact,
|
|
||||||
MultiAssetProxy: MultiAssetProxy as ContractArtifact,
|
|
||||||
TestAssetProxyDispatcher: TestAssetProxyDispatcher as ContractArtifact,
|
TestAssetProxyDispatcher: TestAssetProxyDispatcher as ContractArtifact,
|
||||||
TestAssetProxyOwner: TestAssetProxyOwner as ContractArtifact,
|
|
||||||
TestExchangeInternals: TestExchangeInternals as ContractArtifact,
|
TestExchangeInternals: TestExchangeInternals as ContractArtifact,
|
||||||
TestSignatureValidator: TestSignatureValidator as ContractArtifact,
|
TestSignatureValidator: TestSignatureValidator as ContractArtifact,
|
||||||
TestStaticCallReceiver: TestStaticCallReceiver as ContractArtifact,
|
TestStaticCallReceiver: TestStaticCallReceiver as ContractArtifact,
|
3
contracts/exchange/src/index.ts
Normal file
3
contracts/exchange/src/index.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export * from './artifacts';
|
||||||
|
export * from './wrappers';
|
||||||
|
export * from '../test/utils';
|
@ -1,10 +1,5 @@
|
|||||||
export * from '../../generated-wrappers/asset_proxy_owner';
|
|
||||||
export * from '../../generated-wrappers/erc20_proxy';
|
|
||||||
export * from '../../generated-wrappers/erc721_proxy';
|
|
||||||
export * from '../../generated-wrappers/exchange';
|
export * from '../../generated-wrappers/exchange';
|
||||||
export * from '../../generated-wrappers/mixin_authorizable';
|
|
||||||
export * from '../../generated-wrappers/test_asset_proxy_dispatcher';
|
export * from '../../generated-wrappers/test_asset_proxy_dispatcher';
|
||||||
export * from '../../generated-wrappers/test_asset_proxy_owner';
|
|
||||||
export * from '../../generated-wrappers/test_exchange_internals';
|
export * from '../../generated-wrappers/test_exchange_internals';
|
||||||
export * from '../../generated-wrappers/test_signature_validator';
|
export * from '../../generated-wrappers/test_signature_validator';
|
||||||
export * from '../../generated-wrappers/test_static_call_receiver';
|
export * from '../../generated-wrappers/test_static_call_receiver';
|
@ -1,3 +1,9 @@
|
|||||||
|
import {
|
||||||
|
artifacts as proxyArtifacts,
|
||||||
|
ERC20ProxyContract,
|
||||||
|
ERC721ProxyContract,
|
||||||
|
MultiAssetProxyContract,
|
||||||
|
} from '@0x/contracts-asset-proxy';
|
||||||
import {
|
import {
|
||||||
chaiSetup,
|
chaiSetup,
|
||||||
constants,
|
constants,
|
||||||
@ -29,15 +35,13 @@ import { LogWithDecodedArgs } from 'ethereum-types';
|
|||||||
import ethUtil = require('ethereumjs-util');
|
import ethUtil = require('ethereumjs-util');
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
import { ERC20ProxyContract } from '../../generated-wrappers/erc20_proxy';
|
import { ExchangeCancelEventArgs, ExchangeContract } from '../generated-wrappers/exchange';
|
||||||
import { ERC721ProxyContract } from '../../generated-wrappers/erc721_proxy';
|
import { TestStaticCallReceiverContract } from '../generated-wrappers/test_static_call_receiver';
|
||||||
import { ExchangeCancelEventArgs, ExchangeContract } from '../../generated-wrappers/exchange';
|
import { artifacts } from '../src/artifacts';
|
||||||
import { MultiAssetProxyContract } from '../../generated-wrappers/multi_asset_proxy';
|
|
||||||
import { TestStaticCallReceiverContract } from '../../generated-wrappers/test_static_call_receiver';
|
import { ERC20Wrapper } from './utils/erc20_wrapper';
|
||||||
import { artifacts } from '../../src/artifacts';
|
import { ERC721Wrapper } from './utils/erc721_wrapper';
|
||||||
import { ERC20Wrapper } from '../utils/erc20_wrapper';
|
import { ExchangeWrapper } from './utils/exchange_wrapper';
|
||||||
import { ERC721Wrapper } from '../utils/erc721_wrapper';
|
|
||||||
import { ExchangeWrapper } from '../utils/exchange_wrapper';
|
|
||||||
|
|
||||||
chaiSetup.configure();
|
chaiSetup.configure();
|
||||||
const expect = chai.expect;
|
const expect = chai.expect;
|
||||||
@ -92,7 +96,7 @@ describe('Exchange core', () => {
|
|||||||
erc20Proxy = await erc20Wrapper.deployProxyAsync();
|
erc20Proxy = await erc20Wrapper.deployProxyAsync();
|
||||||
erc721Proxy = await erc721Wrapper.deployProxyAsync();
|
erc721Proxy = await erc721Wrapper.deployProxyAsync();
|
||||||
multiAssetProxy = await MultiAssetProxyContract.deployFrom0xArtifactAsync(
|
multiAssetProxy = await MultiAssetProxyContract.deployFrom0xArtifactAsync(
|
||||||
artifacts.MultiAssetProxy,
|
proxyArtifacts.MultiAssetProxy,
|
||||||
provider,
|
provider,
|
||||||
txDefaults,
|
txDefaults,
|
||||||
);
|
);
|
@ -1,3 +1,4 @@
|
|||||||
|
import { artifacts as proxyArtifacts, ERC20ProxyContract, ERC721ProxyContract } from '@0x/contracts-asset-proxy';
|
||||||
import {
|
import {
|
||||||
chaiSetup,
|
chaiSetup,
|
||||||
constants,
|
constants,
|
||||||
@ -16,15 +17,14 @@ import * as chai from 'chai';
|
|||||||
import { LogWithDecodedArgs } from 'ethereum-types';
|
import { LogWithDecodedArgs } from 'ethereum-types';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
import { ERC20ProxyContract } from '../../generated-wrappers/erc20_proxy';
|
|
||||||
import { ERC721ProxyContract } from '../../generated-wrappers/erc721_proxy';
|
|
||||||
import {
|
import {
|
||||||
TestAssetProxyDispatcherAssetProxyRegisteredEventArgs,
|
TestAssetProxyDispatcherAssetProxyRegisteredEventArgs,
|
||||||
TestAssetProxyDispatcherContract,
|
TestAssetProxyDispatcherContract,
|
||||||
} from '../../generated-wrappers/test_asset_proxy_dispatcher';
|
} from '../generated-wrappers/test_asset_proxy_dispatcher';
|
||||||
import { artifacts } from '../../src/artifacts';
|
import { artifacts } from '../src/artifacts';
|
||||||
import { ERC20Wrapper } from '../utils/erc20_wrapper';
|
|
||||||
import { ERC721Wrapper } from '../utils/erc721_wrapper';
|
import { ERC20Wrapper } from './utils/erc20_wrapper';
|
||||||
|
import { ERC721Wrapper } from './utils/erc721_wrapper';
|
||||||
|
|
||||||
chaiSetup.configure();
|
chaiSetup.configure();
|
||||||
const expect = chai.expect;
|
const expect = chai.expect;
|
||||||
@ -128,7 +128,7 @@ describe('AssetProxyDispatcher', () => {
|
|||||||
expect(proxyAddress).to.be.equal(erc20Proxy.address);
|
expect(proxyAddress).to.be.equal(erc20Proxy.address);
|
||||||
// Deploy a new version of the ERC20 Transfer Proxy contract
|
// Deploy a new version of the ERC20 Transfer Proxy contract
|
||||||
const newErc20TransferProxy = await ERC20ProxyContract.deployFrom0xArtifactAsync(
|
const newErc20TransferProxy = await ERC20ProxyContract.deployFrom0xArtifactAsync(
|
||||||
artifacts.ERC20Proxy,
|
proxyArtifacts.ERC20Proxy,
|
||||||
provider,
|
provider,
|
||||||
txDefaults,
|
txDefaults,
|
||||||
);
|
);
|
@ -19,7 +19,7 @@ import * as _ from 'lodash';
|
|||||||
import {
|
import {
|
||||||
FillOrderCombinatorialUtils,
|
FillOrderCombinatorialUtils,
|
||||||
fillOrderCombinatorialUtilsFactoryAsync,
|
fillOrderCombinatorialUtilsFactoryAsync,
|
||||||
} from '../utils/fill_order_combinatorial_utils';
|
} from './utils/fill_order_combinatorial_utils';
|
||||||
|
|
||||||
chaiSetup.configure();
|
chaiSetup.configure();
|
||||||
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
17
contracts/exchange/test/global_hooks.ts
Normal file
17
contracts/exchange/test/global_hooks.ts
Normal 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();
|
||||||
|
});
|
@ -16,8 +16,8 @@ import { BigNumber } from '@0x/utils';
|
|||||||
import * as chai from 'chai';
|
import * as chai from 'chai';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
import { TestExchangeInternalsContract } from '../../generated-wrappers/test_exchange_internals';
|
import { TestExchangeInternalsContract } from '../generated-wrappers/test_exchange_internals';
|
||||||
import { artifacts } from '../../src/artifacts';
|
import { artifacts } from '../src/artifacts';
|
||||||
|
|
||||||
chaiSetup.configure();
|
chaiSetup.configure();
|
||||||
const expect = chai.expect;
|
const expect = chai.expect;
|
@ -1,3 +1,4 @@
|
|||||||
|
import { ERC20ProxyContract, ERC721ProxyContract } from '@0x/contracts-asset-proxy';
|
||||||
import {
|
import {
|
||||||
chaiSetup,
|
chaiSetup,
|
||||||
constants,
|
constants,
|
||||||
@ -23,15 +24,14 @@ import { Web3Wrapper } from '@0x/web3-wrapper';
|
|||||||
import * as chai from 'chai';
|
import * as chai from 'chai';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
import { ERC20ProxyContract } from '../../generated-wrappers/erc20_proxy';
|
import { ExchangeContract } from '../generated-wrappers/exchange';
|
||||||
import { ERC721ProxyContract } from '../../generated-wrappers/erc721_proxy';
|
import { TestExchangeInternalsContract } from '../generated-wrappers/test_exchange_internals';
|
||||||
import { ExchangeContract } from '../../generated-wrappers/exchange';
|
import { artifacts } from '../src/artifacts';
|
||||||
import { TestExchangeInternalsContract } from '../../generated-wrappers/test_exchange_internals';
|
|
||||||
import { artifacts } from '../../src/artifacts';
|
import { ERC20Wrapper } from './utils/erc20_wrapper';
|
||||||
import { ERC20Wrapper } from '../utils/erc20_wrapper';
|
import { ERC721Wrapper } from './utils/erc721_wrapper';
|
||||||
import { ERC721Wrapper } from '../utils/erc721_wrapper';
|
import { ExchangeWrapper } from './utils/exchange_wrapper';
|
||||||
import { ExchangeWrapper } from '../utils/exchange_wrapper';
|
import { MatchOrderTester } from './utils/match_order_tester';
|
||||||
import { MatchOrderTester } from '../utils/match_order_tester';
|
|
||||||
|
|
||||||
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
||||||
chaiSetup.configure();
|
chaiSetup.configure();
|
@ -23,7 +23,7 @@ import {
|
|||||||
TestSignatureValidatorContract,
|
TestSignatureValidatorContract,
|
||||||
TestSignatureValidatorSignatureValidatorApprovalEventArgs,
|
TestSignatureValidatorSignatureValidatorApprovalEventArgs,
|
||||||
TestStaticCallReceiverContract,
|
TestStaticCallReceiverContract,
|
||||||
} from '../../src';
|
} from '../src';
|
||||||
|
|
||||||
chaiSetup.configure();
|
chaiSetup.configure();
|
||||||
const expect = chai.expect;
|
const expect = chai.expect;
|
@ -1,3 +1,4 @@
|
|||||||
|
import { ERC20ProxyContract } from '@0x/contracts-asset-proxy';
|
||||||
import { artifacts as examplesArtifacts, ExchangeWrapperContract, WhitelistContract } from '@0x/contracts-examples';
|
import { artifacts as examplesArtifacts, ExchangeWrapperContract, WhitelistContract } from '@0x/contracts-examples';
|
||||||
import {
|
import {
|
||||||
chaiSetup,
|
chaiSetup,
|
||||||
@ -20,11 +21,11 @@ import { BigNumber } from '@0x/utils';
|
|||||||
import * as chai from 'chai';
|
import * as chai from 'chai';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
import { ERC20ProxyContract } from '../../generated-wrappers/erc20_proxy';
|
import { ExchangeContract } from '../generated-wrappers/exchange';
|
||||||
import { ExchangeContract } from '../../generated-wrappers/exchange';
|
import { artifacts } from '../src/artifacts';
|
||||||
import { artifacts } from '../../src/artifacts';
|
|
||||||
import { ERC20Wrapper } from '../utils/erc20_wrapper';
|
import { ERC20Wrapper } from './utils/erc20_wrapper';
|
||||||
import { ExchangeWrapper } from '../utils/exchange_wrapper';
|
import { ExchangeWrapper } from './utils/exchange_wrapper';
|
||||||
|
|
||||||
chaiSetup.configure();
|
chaiSetup.configure();
|
||||||
const expect = chai.expect;
|
const expect = chai.expect;
|
177
contracts/exchange/test/utils/erc20_wrapper.ts
Normal file
177
contracts/exchange/test/utils/erc20_wrapper.ts
Normal file
@ -0,0 +1,177 @@
|
|||||||
|
import { artifacts as proxyArtifacts, ERC20ProxyContract } from '@0x/contracts-asset-proxy';
|
||||||
|
import { constants, ERC20BalancesByOwner, txDefaults } from '@0x/contracts-test-utils';
|
||||||
|
import { artifacts as tokensArtifacts, DummyERC20TokenContract } from '@0x/contracts-tokens';
|
||||||
|
import { assetDataUtils } from '@0x/order-utils';
|
||||||
|
import { BigNumber } from '@0x/utils';
|
||||||
|
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||||
|
import { Provider } from 'ethereum-types';
|
||||||
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
|
export class ERC20Wrapper {
|
||||||
|
private readonly _tokenOwnerAddresses: string[];
|
||||||
|
private readonly _contractOwnerAddress: string;
|
||||||
|
private readonly _web3Wrapper: Web3Wrapper;
|
||||||
|
private readonly _provider: Provider;
|
||||||
|
private readonly _dummyTokenContracts: DummyERC20TokenContract[];
|
||||||
|
private _proxyContract?: ERC20ProxyContract;
|
||||||
|
private _proxyIdIfExists?: string;
|
||||||
|
/**
|
||||||
|
* Instanitates an ERC20Wrapper
|
||||||
|
* @param provider Web3 provider to use for all JSON RPC requests
|
||||||
|
* @param tokenOwnerAddresses Addresses that we want to endow as owners for dummy ERC20 tokens
|
||||||
|
* @param contractOwnerAddress Desired owner of the contract
|
||||||
|
* Instance of ERC20Wrapper
|
||||||
|
*/
|
||||||
|
constructor(provider: Provider, tokenOwnerAddresses: string[], contractOwnerAddress: string) {
|
||||||
|
this._dummyTokenContracts = [];
|
||||||
|
this._web3Wrapper = new Web3Wrapper(provider);
|
||||||
|
this._provider = provider;
|
||||||
|
this._tokenOwnerAddresses = tokenOwnerAddresses;
|
||||||
|
this._contractOwnerAddress = contractOwnerAddress;
|
||||||
|
}
|
||||||
|
public async deployDummyTokensAsync(
|
||||||
|
numberToDeploy: number,
|
||||||
|
decimals: BigNumber,
|
||||||
|
): Promise<DummyERC20TokenContract[]> {
|
||||||
|
for (let i = 0; i < numberToDeploy; i++) {
|
||||||
|
this._dummyTokenContracts.push(
|
||||||
|
await DummyERC20TokenContract.deployFrom0xArtifactAsync(
|
||||||
|
tokensArtifacts.DummyERC20Token,
|
||||||
|
this._provider,
|
||||||
|
txDefaults,
|
||||||
|
constants.DUMMY_TOKEN_NAME,
|
||||||
|
constants.DUMMY_TOKEN_SYMBOL,
|
||||||
|
decimals,
|
||||||
|
constants.DUMMY_TOKEN_TOTAL_SUPPLY,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return this._dummyTokenContracts;
|
||||||
|
}
|
||||||
|
public async deployProxyAsync(): Promise<ERC20ProxyContract> {
|
||||||
|
this._proxyContract = await ERC20ProxyContract.deployFrom0xArtifactAsync(
|
||||||
|
proxyArtifacts.ERC20Proxy,
|
||||||
|
this._provider,
|
||||||
|
txDefaults,
|
||||||
|
);
|
||||||
|
this._proxyIdIfExists = await this._proxyContract.getProxyId.callAsync();
|
||||||
|
return this._proxyContract;
|
||||||
|
}
|
||||||
|
public getProxyId(): string {
|
||||||
|
this._validateProxyContractExistsOrThrow();
|
||||||
|
return this._proxyIdIfExists as string;
|
||||||
|
}
|
||||||
|
public async setBalancesAndAllowancesAsync(): Promise<void> {
|
||||||
|
this._validateDummyTokenContractsExistOrThrow();
|
||||||
|
this._validateProxyContractExistsOrThrow();
|
||||||
|
for (const dummyTokenContract of this._dummyTokenContracts) {
|
||||||
|
for (const tokenOwnerAddress of this._tokenOwnerAddresses) {
|
||||||
|
await this._web3Wrapper.awaitTransactionSuccessAsync(
|
||||||
|
await dummyTokenContract.setBalance.sendTransactionAsync(
|
||||||
|
tokenOwnerAddress,
|
||||||
|
constants.INITIAL_ERC20_BALANCE,
|
||||||
|
{ from: this._contractOwnerAddress },
|
||||||
|
),
|
||||||
|
constants.AWAIT_TRANSACTION_MINED_MS,
|
||||||
|
);
|
||||||
|
await this._web3Wrapper.awaitTransactionSuccessAsync(
|
||||||
|
await dummyTokenContract.approve.sendTransactionAsync(
|
||||||
|
(this._proxyContract as ERC20ProxyContract).address,
|
||||||
|
constants.INITIAL_ERC20_ALLOWANCE,
|
||||||
|
{ from: tokenOwnerAddress },
|
||||||
|
),
|
||||||
|
constants.AWAIT_TRANSACTION_MINED_MS,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public async getBalanceAsync(userAddress: string, assetData: string): Promise<BigNumber> {
|
||||||
|
const tokenContract = this._getTokenContractFromAssetData(assetData);
|
||||||
|
const balance = new BigNumber(await tokenContract.balanceOf.callAsync(userAddress));
|
||||||
|
return balance;
|
||||||
|
}
|
||||||
|
public async setBalanceAsync(userAddress: string, assetData: string, amount: BigNumber): Promise<void> {
|
||||||
|
const tokenContract = this._getTokenContractFromAssetData(assetData);
|
||||||
|
await this._web3Wrapper.awaitTransactionSuccessAsync(
|
||||||
|
await tokenContract.setBalance.sendTransactionAsync(userAddress, amount, {
|
||||||
|
from: this._contractOwnerAddress,
|
||||||
|
}),
|
||||||
|
constants.AWAIT_TRANSACTION_MINED_MS,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
public async getProxyAllowanceAsync(userAddress: string, assetData: string): Promise<BigNumber> {
|
||||||
|
const tokenContract = this._getTokenContractFromAssetData(assetData);
|
||||||
|
const proxyAddress = (this._proxyContract as ERC20ProxyContract).address;
|
||||||
|
const allowance = new BigNumber(await tokenContract.allowance.callAsync(userAddress, proxyAddress));
|
||||||
|
return allowance;
|
||||||
|
}
|
||||||
|
public async setAllowanceAsync(userAddress: string, assetData: string, amount: BigNumber): Promise<void> {
|
||||||
|
const tokenContract = this._getTokenContractFromAssetData(assetData);
|
||||||
|
const proxyAddress = (this._proxyContract as ERC20ProxyContract).address;
|
||||||
|
await this._web3Wrapper.awaitTransactionSuccessAsync(
|
||||||
|
await tokenContract.approve.sendTransactionAsync(proxyAddress, amount, {
|
||||||
|
from: userAddress,
|
||||||
|
}),
|
||||||
|
constants.AWAIT_TRANSACTION_MINED_MS,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
public async getBalancesAsync(): Promise<ERC20BalancesByOwner> {
|
||||||
|
this._validateDummyTokenContractsExistOrThrow();
|
||||||
|
const balancesByOwner: ERC20BalancesByOwner = {};
|
||||||
|
const balances: BigNumber[] = [];
|
||||||
|
const balanceInfo: Array<{ tokenOwnerAddress: string; tokenAddress: string }> = [];
|
||||||
|
for (const dummyTokenContract of this._dummyTokenContracts) {
|
||||||
|
for (const tokenOwnerAddress of this._tokenOwnerAddresses) {
|
||||||
|
balances.push(await dummyTokenContract.balanceOf.callAsync(tokenOwnerAddress));
|
||||||
|
balanceInfo.push({
|
||||||
|
tokenOwnerAddress,
|
||||||
|
tokenAddress: dummyTokenContract.address,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_.forEach(balances, (balance, balanceIndex) => {
|
||||||
|
const tokenAddress = balanceInfo[balanceIndex].tokenAddress;
|
||||||
|
const tokenOwnerAddress = balanceInfo[balanceIndex].tokenOwnerAddress;
|
||||||
|
if (_.isUndefined(balancesByOwner[tokenOwnerAddress])) {
|
||||||
|
balancesByOwner[tokenOwnerAddress] = {};
|
||||||
|
}
|
||||||
|
const wrappedBalance = new BigNumber(balance);
|
||||||
|
balancesByOwner[tokenOwnerAddress][tokenAddress] = wrappedBalance;
|
||||||
|
});
|
||||||
|
return balancesByOwner;
|
||||||
|
}
|
||||||
|
public addDummyTokenContract(dummy: DummyERC20TokenContract): void {
|
||||||
|
if (!_.isUndefined(this._dummyTokenContracts)) {
|
||||||
|
this._dummyTokenContracts.push(dummy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public addTokenOwnerAddress(address: string): void {
|
||||||
|
this._tokenOwnerAddresses.push(address);
|
||||||
|
}
|
||||||
|
public getTokenOwnerAddresses(): string[] {
|
||||||
|
return this._tokenOwnerAddresses;
|
||||||
|
}
|
||||||
|
public getTokenAddresses(): string[] {
|
||||||
|
const tokenAddresses = _.map(this._dummyTokenContracts, dummyTokenContract => dummyTokenContract.address);
|
||||||
|
return tokenAddresses;
|
||||||
|
}
|
||||||
|
private _getTokenContractFromAssetData(assetData: string): DummyERC20TokenContract {
|
||||||
|
const erc20ProxyData = assetDataUtils.decodeERC20AssetData(assetData);
|
||||||
|
const tokenAddress = erc20ProxyData.tokenAddress;
|
||||||
|
const tokenContractIfExists = _.find(this._dummyTokenContracts, c => c.address === tokenAddress);
|
||||||
|
if (_.isUndefined(tokenContractIfExists)) {
|
||||||
|
throw new Error(`Token: ${tokenAddress} was not deployed through ERC20Wrapper`);
|
||||||
|
}
|
||||||
|
return tokenContractIfExists;
|
||||||
|
}
|
||||||
|
private _validateDummyTokenContractsExistOrThrow(): void {
|
||||||
|
if (_.isUndefined(this._dummyTokenContracts)) {
|
||||||
|
throw new Error('Dummy ERC20 tokens not yet deployed, please call "deployDummyTokensAsync"');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private _validateProxyContractExistsOrThrow(): void {
|
||||||
|
if (_.isUndefined(this._proxyContract)) {
|
||||||
|
throw new Error('ERC20 proxy contract not yet deployed, please call "deployProxyAsync"');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
234
contracts/exchange/test/utils/erc721_wrapper.ts
Normal file
234
contracts/exchange/test/utils/erc721_wrapper.ts
Normal file
@ -0,0 +1,234 @@
|
|||||||
|
import { artifacts as proxyArtifacts, ERC721ProxyContract } from '@0x/contracts-asset-proxy';
|
||||||
|
import { constants, ERC721TokenIdsByOwner, txDefaults } from '@0x/contracts-test-utils';
|
||||||
|
import { artifacts as tokensArtifacts, DummyERC721TokenContract } from '@0x/contracts-tokens';
|
||||||
|
import { generatePseudoRandomSalt } from '@0x/order-utils';
|
||||||
|
import { BigNumber } from '@0x/utils';
|
||||||
|
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||||
|
import { Provider } from 'ethereum-types';
|
||||||
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
|
export class ERC721Wrapper {
|
||||||
|
private readonly _tokenOwnerAddresses: string[];
|
||||||
|
private readonly _contractOwnerAddress: string;
|
||||||
|
private readonly _web3Wrapper: Web3Wrapper;
|
||||||
|
private readonly _provider: Provider;
|
||||||
|
private readonly _dummyTokenContracts: DummyERC721TokenContract[];
|
||||||
|
private _proxyContract?: ERC721ProxyContract;
|
||||||
|
private _proxyIdIfExists?: string;
|
||||||
|
private _initialTokenIdsByOwner: ERC721TokenIdsByOwner = {};
|
||||||
|
constructor(provider: Provider, tokenOwnerAddresses: string[], contractOwnerAddress: string) {
|
||||||
|
this._web3Wrapper = new Web3Wrapper(provider);
|
||||||
|
this._provider = provider;
|
||||||
|
this._dummyTokenContracts = [];
|
||||||
|
this._tokenOwnerAddresses = tokenOwnerAddresses;
|
||||||
|
this._contractOwnerAddress = contractOwnerAddress;
|
||||||
|
}
|
||||||
|
public async deployDummyTokensAsync(): Promise<DummyERC721TokenContract[]> {
|
||||||
|
// tslint:disable-next-line:no-unused-variable
|
||||||
|
for (const i of _.times(constants.NUM_DUMMY_ERC721_TO_DEPLOY)) {
|
||||||
|
this._dummyTokenContracts.push(
|
||||||
|
await DummyERC721TokenContract.deployFrom0xArtifactAsync(
|
||||||
|
tokensArtifacts.DummyERC721Token,
|
||||||
|
this._provider,
|
||||||
|
txDefaults,
|
||||||
|
constants.DUMMY_TOKEN_NAME,
|
||||||
|
constants.DUMMY_TOKEN_SYMBOL,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return this._dummyTokenContracts;
|
||||||
|
}
|
||||||
|
public async deployProxyAsync(): Promise<ERC721ProxyContract> {
|
||||||
|
this._proxyContract = await ERC721ProxyContract.deployFrom0xArtifactAsync(
|
||||||
|
proxyArtifacts.ERC721Proxy,
|
||||||
|
this._provider,
|
||||||
|
txDefaults,
|
||||||
|
);
|
||||||
|
this._proxyIdIfExists = await this._proxyContract.getProxyId.callAsync();
|
||||||
|
return this._proxyContract;
|
||||||
|
}
|
||||||
|
public getProxyId(): string {
|
||||||
|
this._validateProxyContractExistsOrThrow();
|
||||||
|
return this._proxyIdIfExists as string;
|
||||||
|
}
|
||||||
|
public async setBalancesAndAllowancesAsync(): Promise<void> {
|
||||||
|
this._validateDummyTokenContractsExistOrThrow();
|
||||||
|
this._validateProxyContractExistsOrThrow();
|
||||||
|
this._initialTokenIdsByOwner = {};
|
||||||
|
for (const dummyTokenContract of this._dummyTokenContracts) {
|
||||||
|
for (const tokenOwnerAddress of this._tokenOwnerAddresses) {
|
||||||
|
// tslint:disable-next-line:no-unused-variable
|
||||||
|
for (const i of _.times(constants.NUM_ERC721_TOKENS_TO_MINT)) {
|
||||||
|
const tokenId = generatePseudoRandomSalt();
|
||||||
|
await this.mintAsync(dummyTokenContract.address, tokenId, tokenOwnerAddress);
|
||||||
|
if (_.isUndefined(this._initialTokenIdsByOwner[tokenOwnerAddress])) {
|
||||||
|
this._initialTokenIdsByOwner[tokenOwnerAddress] = {
|
||||||
|
[dummyTokenContract.address]: [],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (_.isUndefined(this._initialTokenIdsByOwner[tokenOwnerAddress][dummyTokenContract.address])) {
|
||||||
|
this._initialTokenIdsByOwner[tokenOwnerAddress][dummyTokenContract.address] = [];
|
||||||
|
}
|
||||||
|
this._initialTokenIdsByOwner[tokenOwnerAddress][dummyTokenContract.address].push(tokenId);
|
||||||
|
|
||||||
|
await this.approveProxyAsync(dummyTokenContract.address, tokenId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public async doesTokenExistAsync(tokenAddress: string, tokenId: BigNumber): Promise<boolean> {
|
||||||
|
const tokenContract = this._getTokenContractFromAssetData(tokenAddress);
|
||||||
|
const owner = await tokenContract.ownerOf.callAsync(tokenId);
|
||||||
|
const doesExist = owner !== constants.NULL_ADDRESS;
|
||||||
|
return doesExist;
|
||||||
|
}
|
||||||
|
public async approveProxyAsync(tokenAddress: string, tokenId: BigNumber): Promise<void> {
|
||||||
|
const proxyAddress = (this._proxyContract as ERC721ProxyContract).address;
|
||||||
|
await this.approveAsync(proxyAddress, tokenAddress, tokenId);
|
||||||
|
}
|
||||||
|
public async approveProxyForAllAsync(tokenAddress: string, tokenId: BigNumber, isApproved: boolean): Promise<void> {
|
||||||
|
const tokenContract = this._getTokenContractFromAssetData(tokenAddress);
|
||||||
|
const tokenOwner = await this.ownerOfAsync(tokenAddress, tokenId);
|
||||||
|
const proxyAddress = (this._proxyContract as ERC721ProxyContract).address;
|
||||||
|
await this._web3Wrapper.awaitTransactionSuccessAsync(
|
||||||
|
await tokenContract.setApprovalForAll.sendTransactionAsync(proxyAddress, isApproved, {
|
||||||
|
from: tokenOwner,
|
||||||
|
}),
|
||||||
|
constants.AWAIT_TRANSACTION_MINED_MS,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
public async approveAsync(to: string, tokenAddress: string, tokenId: BigNumber): Promise<void> {
|
||||||
|
const tokenContract = this._getTokenContractFromAssetData(tokenAddress);
|
||||||
|
const tokenOwner = await this.ownerOfAsync(tokenAddress, tokenId);
|
||||||
|
await this._web3Wrapper.awaitTransactionSuccessAsync(
|
||||||
|
await tokenContract.approve.sendTransactionAsync(to, tokenId, {
|
||||||
|
from: tokenOwner,
|
||||||
|
}),
|
||||||
|
constants.AWAIT_TRANSACTION_MINED_MS,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
public async transferFromAsync(
|
||||||
|
tokenAddress: string,
|
||||||
|
tokenId: BigNumber,
|
||||||
|
currentOwner: string,
|
||||||
|
userAddress: string,
|
||||||
|
): Promise<void> {
|
||||||
|
const tokenContract = this._getTokenContractFromAssetData(tokenAddress);
|
||||||
|
await this._web3Wrapper.awaitTransactionSuccessAsync(
|
||||||
|
await tokenContract.transferFrom.sendTransactionAsync(currentOwner, userAddress, tokenId, {
|
||||||
|
from: currentOwner,
|
||||||
|
}),
|
||||||
|
constants.AWAIT_TRANSACTION_MINED_MS,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
public async mintAsync(tokenAddress: string, tokenId: BigNumber, userAddress: string): Promise<void> {
|
||||||
|
const tokenContract = this._getTokenContractFromAssetData(tokenAddress);
|
||||||
|
await this._web3Wrapper.awaitTransactionSuccessAsync(
|
||||||
|
await tokenContract.mint.sendTransactionAsync(userAddress, tokenId, {
|
||||||
|
from: this._contractOwnerAddress,
|
||||||
|
}),
|
||||||
|
constants.AWAIT_TRANSACTION_MINED_MS,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
public async burnAsync(tokenAddress: string, tokenId: BigNumber, owner: string): Promise<void> {
|
||||||
|
const tokenContract = this._getTokenContractFromAssetData(tokenAddress);
|
||||||
|
await this._web3Wrapper.awaitTransactionSuccessAsync(
|
||||||
|
await tokenContract.burn.sendTransactionAsync(owner, tokenId, {
|
||||||
|
from: this._contractOwnerAddress,
|
||||||
|
}),
|
||||||
|
constants.AWAIT_TRANSACTION_MINED_MS,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
public async ownerOfAsync(tokenAddress: string, tokenId: BigNumber): Promise<string> {
|
||||||
|
const tokenContract = this._getTokenContractFromAssetData(tokenAddress);
|
||||||
|
const owner = await tokenContract.ownerOf.callAsync(tokenId);
|
||||||
|
return owner;
|
||||||
|
}
|
||||||
|
public async isOwnerAsync(userAddress: string, tokenAddress: string, tokenId: BigNumber): Promise<boolean> {
|
||||||
|
const tokenContract = this._getTokenContractFromAssetData(tokenAddress);
|
||||||
|
const tokenOwner = await tokenContract.ownerOf.callAsync(tokenId);
|
||||||
|
const isOwner = tokenOwner === userAddress;
|
||||||
|
return isOwner;
|
||||||
|
}
|
||||||
|
public async isProxyApprovedForAllAsync(userAddress: string, tokenAddress: string): Promise<boolean> {
|
||||||
|
this._validateProxyContractExistsOrThrow();
|
||||||
|
const tokenContract = this._getTokenContractFromAssetData(tokenAddress);
|
||||||
|
const operator = (this._proxyContract as ERC721ProxyContract).address;
|
||||||
|
const didApproveAll = await tokenContract.isApprovedForAll.callAsync(userAddress, operator);
|
||||||
|
return didApproveAll;
|
||||||
|
}
|
||||||
|
public async isProxyApprovedAsync(tokenAddress: string, tokenId: BigNumber): Promise<boolean> {
|
||||||
|
this._validateProxyContractExistsOrThrow();
|
||||||
|
const tokenContract = this._getTokenContractFromAssetData(tokenAddress);
|
||||||
|
const approvedAddress = await tokenContract.getApproved.callAsync(tokenId);
|
||||||
|
const proxyAddress = (this._proxyContract as ERC721ProxyContract).address;
|
||||||
|
const isProxyAnApprovedOperator = approvedAddress === proxyAddress;
|
||||||
|
return isProxyAnApprovedOperator;
|
||||||
|
}
|
||||||
|
public async getBalancesAsync(): Promise<ERC721TokenIdsByOwner> {
|
||||||
|
this._validateDummyTokenContractsExistOrThrow();
|
||||||
|
this._validateBalancesAndAllowancesSetOrThrow();
|
||||||
|
const tokenIdsByOwner: ERC721TokenIdsByOwner = {};
|
||||||
|
const tokenOwnerAddresses: string[] = [];
|
||||||
|
const tokenInfo: Array<{ tokenId: BigNumber; tokenAddress: string }> = [];
|
||||||
|
for (const dummyTokenContract of this._dummyTokenContracts) {
|
||||||
|
for (const tokenOwnerAddress of this._tokenOwnerAddresses) {
|
||||||
|
const initialTokenOwnerIds = this._initialTokenIdsByOwner[tokenOwnerAddress][
|
||||||
|
dummyTokenContract.address
|
||||||
|
];
|
||||||
|
for (const tokenId of initialTokenOwnerIds) {
|
||||||
|
tokenOwnerAddresses.push(await dummyTokenContract.ownerOf.callAsync(tokenId));
|
||||||
|
tokenInfo.push({
|
||||||
|
tokenId,
|
||||||
|
tokenAddress: dummyTokenContract.address,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_.forEach(tokenOwnerAddresses, (tokenOwnerAddress, ownerIndex) => {
|
||||||
|
const tokenAddress = tokenInfo[ownerIndex].tokenAddress;
|
||||||
|
const tokenId = tokenInfo[ownerIndex].tokenId;
|
||||||
|
if (_.isUndefined(tokenIdsByOwner[tokenOwnerAddress])) {
|
||||||
|
tokenIdsByOwner[tokenOwnerAddress] = {
|
||||||
|
[tokenAddress]: [],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (_.isUndefined(tokenIdsByOwner[tokenOwnerAddress][tokenAddress])) {
|
||||||
|
tokenIdsByOwner[tokenOwnerAddress][tokenAddress] = [];
|
||||||
|
}
|
||||||
|
tokenIdsByOwner[tokenOwnerAddress][tokenAddress].push(tokenId);
|
||||||
|
});
|
||||||
|
return tokenIdsByOwner;
|
||||||
|
}
|
||||||
|
public getTokenOwnerAddresses(): string[] {
|
||||||
|
return this._tokenOwnerAddresses;
|
||||||
|
}
|
||||||
|
public getTokenAddresses(): string[] {
|
||||||
|
const tokenAddresses = _.map(this._dummyTokenContracts, dummyTokenContract => dummyTokenContract.address);
|
||||||
|
return tokenAddresses;
|
||||||
|
}
|
||||||
|
private _getTokenContractFromAssetData(tokenAddress: string): DummyERC721TokenContract {
|
||||||
|
const tokenContractIfExists = _.find(this._dummyTokenContracts, c => c.address === tokenAddress);
|
||||||
|
if (_.isUndefined(tokenContractIfExists)) {
|
||||||
|
throw new Error(`Token: ${tokenAddress} was not deployed through ERC20Wrapper`);
|
||||||
|
}
|
||||||
|
return tokenContractIfExists;
|
||||||
|
}
|
||||||
|
private _validateDummyTokenContractsExistOrThrow(): void {
|
||||||
|
if (_.isUndefined(this._dummyTokenContracts)) {
|
||||||
|
throw new Error('Dummy ERC721 tokens not yet deployed, please call "deployDummyTokensAsync"');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private _validateProxyContractExistsOrThrow(): void {
|
||||||
|
if (_.isUndefined(this._proxyContract)) {
|
||||||
|
throw new Error('ERC721 proxy contract not yet deployed, please call "deployProxyAsync"');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private _validateBalancesAndAllowancesSetOrThrow(): void {
|
||||||
|
if (_.keys(this._initialTokenIdsByOwner).length === 0) {
|
||||||
|
throw new Error(
|
||||||
|
'Dummy ERC721 balances and allowances not yet set, please call "setBalancesAndAllowancesAsync"',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,3 +1,4 @@
|
|||||||
|
import { ERC20ProxyContract, ERC721ProxyContract } from '@0x/contracts-asset-proxy';
|
||||||
import {
|
import {
|
||||||
chaiSetup,
|
chaiSetup,
|
||||||
constants,
|
constants,
|
||||||
@ -25,13 +26,12 @@ import { Web3Wrapper } from '@0x/web3-wrapper';
|
|||||||
import * as chai from 'chai';
|
import * as chai from 'chai';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
import { ERC20ProxyContract } from '../../generated-wrappers/erc20_proxy';
|
import { ExchangeContract } from '../generated-wrappers/exchange';
|
||||||
import { ERC721ProxyContract } from '../../generated-wrappers/erc721_proxy';
|
import { artifacts } from '../src/artifacts';
|
||||||
import { ExchangeContract } from '../../generated-wrappers/exchange';
|
|
||||||
import { artifacts } from '../../src/artifacts';
|
import { ERC20Wrapper } from './utils/erc20_wrapper';
|
||||||
import { ERC20Wrapper } from '../utils/erc20_wrapper';
|
import { ERC721Wrapper } from './utils/erc721_wrapper';
|
||||||
import { ERC721Wrapper } from '../utils/erc721_wrapper';
|
import { ExchangeWrapper } from './utils/exchange_wrapper';
|
||||||
import { ExchangeWrapper } from '../utils/exchange_wrapper';
|
|
||||||
|
|
||||||
chaiSetup.configure();
|
chaiSetup.configure();
|
||||||
const expect = chai.expect;
|
const expect = chai.expect;
|
@ -7,14 +7,8 @@
|
|||||||
},
|
},
|
||||||
"include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*"],
|
"include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*"],
|
||||||
"files": [
|
"files": [
|
||||||
"./generated-artifacts/AssetProxyOwner.json",
|
|
||||||
"./generated-artifacts/ERC20Proxy.json",
|
|
||||||
"./generated-artifacts/ERC721Proxy.json",
|
|
||||||
"./generated-artifacts/Exchange.json",
|
"./generated-artifacts/Exchange.json",
|
||||||
"./generated-artifacts/MixinAuthorizable.json",
|
|
||||||
"./generated-artifacts/MultiAssetProxy.json",
|
|
||||||
"./generated-artifacts/TestAssetProxyDispatcher.json",
|
"./generated-artifacts/TestAssetProxyDispatcher.json",
|
||||||
"./generated-artifacts/TestAssetProxyOwner.json",
|
|
||||||
"./generated-artifacts/TestExchangeInternals.json",
|
"./generated-artifacts/TestExchangeInternals.json",
|
||||||
"./generated-artifacts/TestSignatureValidator.json",
|
"./generated-artifacts/TestSignatureValidator.json",
|
||||||
"./generated-artifacts/TestStaticCallReceiver.json"
|
"./generated-artifacts/TestStaticCallReceiver.json"
|
6
contracts/exchange/tslint.json
Normal file
6
contracts/exchange/tslint.json
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"extends": ["@0x/tslint-config"],
|
||||||
|
"rules": {
|
||||||
|
"custom-no-magic-numbers": false
|
||||||
|
}
|
||||||
|
}
|
@ -18,5 +18,11 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"contracts": ["MultiSigWallet", "MultiSigWalletWithTimeLock", "TestRejectEther"]
|
"contracts": [
|
||||||
|
"AssetProxyOwner",
|
||||||
|
"MultiSigWallet",
|
||||||
|
"MultiSigWalletWithTimeLock",
|
||||||
|
"TestAssetProxyOwner",
|
||||||
|
"TestRejectEther"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
pragma solidity 0.4.24;
|
pragma solidity 0.4.24;
|
||||||
|
|
||||||
import "@0x/contracts-multisig/contracts/multisig/MultiSigWalletWithTimeLock.sol";
|
import "@0x/contracts-multisig/contracts/multisig/MultiSigWalletWithTimeLock.sol";
|
||||||
import "@0x/contracts-utils/contracts/utils/LibBytes/LibBytes.sol";
|
import "@0x/contracts-utils/contracts/utils/LibBytes.sol";
|
||||||
|
|
||||||
|
|
||||||
contract AssetProxyOwner is
|
contract AssetProxyOwner is
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
pragma solidity 0.4.24;
|
pragma solidity 0.4.24;
|
||||||
|
|
||||||
import "../../protocol/AssetProxyOwner/AssetProxyOwner.sol";
|
import "../multisig/AssetProxyOwner.sol";
|
||||||
|
|
||||||
|
|
||||||
// solhint-disable no-empty-blocks
|
// solhint-disable no-empty-blocks
|
@ -32,7 +32,7 @@
|
|||||||
"lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol"
|
"lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol"
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"abis": "generated-artifacts/@(MultiSigWallet|MultiSigWalletWithTimeLock|TestRejectEther).json"
|
"abis": "generated-artifacts/@(AssetProxyOwner|MultiSigWallet|MultiSigWalletWithTimeLock|TestAssetProxyOwner|TestRejectEther).json"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -70,6 +70,8 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@0x/base-contract": "^3.0.13",
|
"@0x/base-contract": "^3.0.13",
|
||||||
|
"@0x/contracts-asset-proxy": "^2.2.3",
|
||||||
|
"@0x/contracts-tokens": "^1.0.6",
|
||||||
"@0x/order-utils": "^3.1.2",
|
"@0x/order-utils": "^3.1.2",
|
||||||
"@0x/types": "^1.5.2",
|
"@0x/types": "^1.5.2",
|
||||||
"@0x/typescript-typings": "^3.0.8",
|
"@0x/typescript-typings": "^3.0.8",
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
import { ContractArtifact } from 'ethereum-types';
|
import { ContractArtifact } from 'ethereum-types';
|
||||||
|
|
||||||
|
import * as AssetProxyOwner from '../../generated-artifacts/AssetProxyOwner.json';
|
||||||
import * as MultiSigWallet from '../../generated-artifacts/MultiSigWallet.json';
|
import * as MultiSigWallet from '../../generated-artifacts/MultiSigWallet.json';
|
||||||
import * as MultiSigWalletWithTimeLock from '../../generated-artifacts/MultiSigWalletWithTimeLock.json';
|
import * as MultiSigWalletWithTimeLock from '../../generated-artifacts/MultiSigWalletWithTimeLock.json';
|
||||||
|
import * as TestAssetProxyOwner from '../../generated-artifacts/TestAssetProxyOwner.json';
|
||||||
import * as TestRejectEther from '../../generated-artifacts/TestRejectEther.json';
|
import * as TestRejectEther from '../../generated-artifacts/TestRejectEther.json';
|
||||||
|
|
||||||
export const artifacts = {
|
export const artifacts = {
|
||||||
TestRejectEther: TestRejectEther as ContractArtifact,
|
AssetProxyOwner: AssetProxyOwner as ContractArtifact,
|
||||||
MultiSigWallet: MultiSigWallet as ContractArtifact,
|
MultiSigWallet: MultiSigWallet as ContractArtifact,
|
||||||
MultiSigWalletWithTimeLock: MultiSigWalletWithTimeLock as ContractArtifact,
|
MultiSigWalletWithTimeLock: MultiSigWalletWithTimeLock as ContractArtifact,
|
||||||
|
TestAssetProxyOwner: TestAssetProxyOwner as ContractArtifact,
|
||||||
|
TestRejectEther: TestRejectEther as ContractArtifact,
|
||||||
};
|
};
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { artifacts as proxyArtifacts, MixinAuthorizableContract } from '@0x/contracts-asset-proxy';
|
||||||
import {
|
import {
|
||||||
chaiSetup,
|
chaiSetup,
|
||||||
constants,
|
constants,
|
||||||
@ -23,11 +24,11 @@ import {
|
|||||||
AssetProxyOwnerExecutionEventArgs,
|
AssetProxyOwnerExecutionEventArgs,
|
||||||
AssetProxyOwnerExecutionFailureEventArgs,
|
AssetProxyOwnerExecutionFailureEventArgs,
|
||||||
AssetProxyOwnerSubmissionEventArgs,
|
AssetProxyOwnerSubmissionEventArgs,
|
||||||
} from '../../generated-wrappers/asset_proxy_owner';
|
} from '../generated-wrappers/asset_proxy_owner';
|
||||||
import { MixinAuthorizableContract } from '../../generated-wrappers/mixin_authorizable';
|
import { TestAssetProxyOwnerContract } from '../generated-wrappers/test_asset_proxy_owner';
|
||||||
import { TestAssetProxyOwnerContract } from '../../generated-wrappers/test_asset_proxy_owner';
|
import { artifacts } from '../src/artifacts';
|
||||||
import { artifacts } from '../../src/artifacts';
|
|
||||||
import { AssetProxyOwnerWrapper } from '../utils/asset_proxy_owner_wrapper';
|
import { AssetProxyOwnerWrapper } from './utils/asset_proxy_owner_wrapper';
|
||||||
|
|
||||||
chaiSetup.configure();
|
chaiSetup.configure();
|
||||||
const expect = chai.expect;
|
const expect = chai.expect;
|
||||||
@ -58,12 +59,12 @@ describe('AssetProxyOwner', () => {
|
|||||||
notOwner = accounts[3];
|
notOwner = accounts[3];
|
||||||
const initialOwner = accounts[0];
|
const initialOwner = accounts[0];
|
||||||
erc20Proxy = await MixinAuthorizableContract.deployFrom0xArtifactAsync(
|
erc20Proxy = await MixinAuthorizableContract.deployFrom0xArtifactAsync(
|
||||||
artifacts.MixinAuthorizable,
|
proxyArtifacts.MixinAuthorizable,
|
||||||
provider,
|
provider,
|
||||||
txDefaults,
|
txDefaults,
|
||||||
);
|
);
|
||||||
erc721Proxy = await MixinAuthorizableContract.deployFrom0xArtifactAsync(
|
erc721Proxy = await MixinAuthorizableContract.deployFrom0xArtifactAsync(
|
||||||
artifacts.MixinAuthorizable,
|
proxyArtifacts.MixinAuthorizable,
|
||||||
provider,
|
provider,
|
||||||
txDefaults,
|
txDefaults,
|
||||||
);
|
);
|
@ -1,3 +1,4 @@
|
|||||||
|
import { artifacts as proxyArtifacts } from '@0x/contracts-asset-proxy';
|
||||||
import { LogDecoder } from '@0x/contracts-test-utils';
|
import { LogDecoder } from '@0x/contracts-test-utils';
|
||||||
import { artifacts as tokensArtifacts } from '@0x/contracts-tokens';
|
import { artifacts as tokensArtifacts } from '@0x/contracts-tokens';
|
||||||
import { BigNumber } from '@0x/utils';
|
import { BigNumber } from '@0x/utils';
|
||||||
@ -15,7 +16,7 @@ export class AssetProxyOwnerWrapper {
|
|||||||
constructor(assetproxyOwnerContract: AssetProxyOwnerContract, provider: Provider) {
|
constructor(assetproxyOwnerContract: AssetProxyOwnerContract, provider: Provider) {
|
||||||
this._assetProxyOwner = assetproxyOwnerContract;
|
this._assetProxyOwner = assetproxyOwnerContract;
|
||||||
this._web3Wrapper = new Web3Wrapper(provider);
|
this._web3Wrapper = new Web3Wrapper(provider);
|
||||||
this._logDecoder = new LogDecoder(this._web3Wrapper, { ...artifacts, ...tokensArtifacts });
|
this._logDecoder = new LogDecoder(this._web3Wrapper, { ...artifacts, ...tokensArtifacts, ...proxyArtifacts });
|
||||||
}
|
}
|
||||||
public async submitTransactionAsync(
|
public async submitTransactionAsync(
|
||||||
destination: string,
|
destination: string,
|
@ -7,8 +7,10 @@
|
|||||||
},
|
},
|
||||||
"include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*"],
|
"include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*"],
|
||||||
"files": [
|
"files": [
|
||||||
|
"./generated-artifacts/AssetProxyOwner.json",
|
||||||
"./generated-artifacts/MultiSigWallet.json",
|
"./generated-artifacts/MultiSigWallet.json",
|
||||||
"./generated-artifacts/MultiSigWalletWithTimeLock.json",
|
"./generated-artifacts/MultiSigWalletWithTimeLock.json",
|
||||||
|
"./generated-artifacts/TestAssetProxyOwner.json",
|
||||||
"./generated-artifacts/TestRejectEther.json"
|
"./generated-artifacts/TestRejectEther.json"
|
||||||
],
|
],
|
||||||
"exclude": ["./deploy/solc/solc_bin"]
|
"exclude": ["./deploy/solc/solc_bin"]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user