aboutsummaryrefslogtreecommitdiffstats
path: root/contracts/extensions
diff options
context:
space:
mode:
Diffstat (limited to 'contracts/extensions')
-rw-r--r--contracts/extensions/compiler.json19
-rw-r--r--contracts/extensions/package.json5
-rw-r--r--contracts/extensions/src/artifacts.ts27
-rw-r--r--contracts/extensions/src/artifacts/index.ts13
-rw-r--r--contracts/extensions/src/wrappers.ts12
-rw-r--r--contracts/extensions/src/wrappers/index.ts4
-rw-r--r--contracts/extensions/test/balance_threshold_filter.ts6
-rw-r--r--contracts/extensions/test/dutch_auction.ts18
-rw-r--r--contracts/extensions/test/order_matcher.ts47
-rw-r--r--contracts/extensions/test/order_validator.ts18
-rw-r--r--contracts/extensions/test/utils/balance_threshold_wrapper.ts15
-rw-r--r--contracts/extensions/test/utils/dutch_auction_test_wrapper.ts10
-rw-r--r--contracts/extensions/tsconfig.json21
13 files changed, 120 insertions, 95 deletions
diff --git a/contracts/extensions/compiler.json b/contracts/extensions/compiler.json
index 91e0bd429..41fd582ad 100644
--- a/contracts/extensions/compiler.json
+++ b/contracts/extensions/compiler.json
@@ -3,10 +3,7 @@
"contractsDir": "./contracts",
"useDockerisedSolc": true,
"compilerSettings": {
- "optimizer": {
- "enabled": true,
- "runs": 1000000
- },
+ "optimizer": { "enabled": true, "runs": 1000000 },
"outputSelection": {
"*": {
"*": [
@@ -19,5 +16,17 @@
}
}
},
- "contracts": ["BalanceThresholdFilter", "DutchAuction", "OrderMatcher", "OrderValidator"]
+ "contracts": [
+ "@0x/contracts-asset-proxy/contracts/src/ERC20Proxy.sol",
+ "@0x/contracts-asset-proxy/contracts/src/ERC721Proxy.sol",
+ "@0x/contracts-erc20/contracts/src/WETH9.sol",
+ "@0x/contracts-erc20/contracts/test/DummyERC20Token.sol",
+ "@0x/contracts-erc721/contracts/test/DummyERC721Token.sol",
+ "@0x/contracts-exchange/contracts/examples/ExchangeWrapper.sol",
+ "@0x/contracts-exchange/contracts/src/Exchange.sol",
+ "src/BalanceThresholdFilter/BalanceThresholdFilter.sol",
+ "src/DutchAuction/DutchAuction.sol",
+ "src/OrderMatcher/OrderMatcher.sol",
+ "src/OrderValidator/OrderValidator.sol"
+ ]
}
diff --git a/contracts/extensions/package.json b/contracts/extensions/package.json
index ad829033f..698c42ccf 100644
--- a/contracts/extensions/package.json
+++ b/contracts/extensions/package.json
@@ -29,10 +29,12 @@
"profiler:report:html": "istanbul report html && open coverage/index.html",
"coverage:report:lcov": "istanbul report lcov",
"test:circleci": "yarn test",
+ "contracts:gen": "contracts-gen",
"lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol"
},
"config": {
- "abis": "generated-artifacts/@(BalanceThresholdFilter|DutchAuction|OrderMatcher|OrderValidator).json"
+ "abis": "./generated-artifacts/@(BalanceThresholdFilter|DummyERC20Token|DummyERC721Token|DutchAuction|ERC20Proxy|ERC721Proxy|Exchange|ExchangeWrapper|OrderMatcher|OrderValidator|WETH9).json",
+ "abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually."
},
"repository": {
"type": "git",
@@ -50,6 +52,7 @@
"@0x/dev-utils": "^1.0.24",
"@0x/sol-compiler": "^2.0.2",
"@0x/tslint-config": "^2.0.2",
+ "@0x/contracts-gen": "^1.0.0",
"@types/lodash": "4.14.104",
"@types/node": "*",
"chai": "^4.0.1",
diff --git a/contracts/extensions/src/artifacts.ts b/contracts/extensions/src/artifacts.ts
new file mode 100644
index 000000000..6db3daecc
--- /dev/null
+++ b/contracts/extensions/src/artifacts.ts
@@ -0,0 +1,27 @@
+// This file is auto-generated by contracts-gen. Don't edit manually.
+import { ContractArtifact } from 'ethereum-types';
+
+import * as BalanceThresholdFilter from '../generated-artifacts/BalanceThresholdFilter.json';
+import * as DummyERC20Token from '../generated-artifacts/DummyERC20Token.json';
+import * as DummyERC721Token from '../generated-artifacts/DummyERC721Token.json';
+import * as DutchAuction from '../generated-artifacts/DutchAuction.json';
+import * as ERC20Proxy from '../generated-artifacts/ERC20Proxy.json';
+import * as ERC721Proxy from '../generated-artifacts/ERC721Proxy.json';
+import * as Exchange from '../generated-artifacts/Exchange.json';
+import * as ExchangeWrapper from '../generated-artifacts/ExchangeWrapper.json';
+import * as OrderMatcher from '../generated-artifacts/OrderMatcher.json';
+import * as OrderValidator from '../generated-artifacts/OrderValidator.json';
+import * as WETH9 from '../generated-artifacts/WETH9.json';
+export const artifacts = {
+ ERC20Proxy: ERC20Proxy as ContractArtifact,
+ ERC721Proxy: ERC721Proxy as ContractArtifact,
+ WETH9: WETH9 as ContractArtifact,
+ DummyERC20Token: DummyERC20Token as ContractArtifact,
+ DummyERC721Token: DummyERC721Token as ContractArtifact,
+ ExchangeWrapper: ExchangeWrapper as ContractArtifact,
+ Exchange: Exchange as ContractArtifact,
+ BalanceThresholdFilter: BalanceThresholdFilter as ContractArtifact,
+ DutchAuction: DutchAuction as ContractArtifact,
+ OrderMatcher: OrderMatcher as ContractArtifact,
+ OrderValidator: OrderValidator as ContractArtifact,
+};
diff --git a/contracts/extensions/src/artifacts/index.ts b/contracts/extensions/src/artifacts/index.ts
deleted file mode 100644
index f2aee4908..000000000
--- a/contracts/extensions/src/artifacts/index.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import { ContractArtifact } from 'ethereum-types';
-
-import * as BalanceThresholdFilter from '../../generated-artifacts/BalanceThresholdFilter.json';
-import * as DutchAuction from '../../generated-artifacts/DutchAuction.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,
- OrderMatcher: OrderMatcher as ContractArtifact,
- OrderValidator: OrderValidator as ContractArtifact,
-};
diff --git a/contracts/extensions/src/wrappers.ts b/contracts/extensions/src/wrappers.ts
new file mode 100644
index 000000000..d34cca292
--- /dev/null
+++ b/contracts/extensions/src/wrappers.ts
@@ -0,0 +1,12 @@
+// This file is auto-generated by contracts-gen. Don't edit manually.
+export * from '../generated-wrappers/balance_threshold_filter';
+export * from '../generated-wrappers/dummy_erc20_token';
+export * from '../generated-wrappers/dummy_erc721_token';
+export * from '../generated-wrappers/dutch_auction';
+export * from '../generated-wrappers/erc20_proxy';
+export * from '../generated-wrappers/erc721_proxy';
+export * from '../generated-wrappers/exchange';
+export * from '../generated-wrappers/exchange_wrapper';
+export * from '../generated-wrappers/order_matcher';
+export * from '../generated-wrappers/order_validator';
+export * from '../generated-wrappers/weth9';
diff --git a/contracts/extensions/src/wrappers/index.ts b/contracts/extensions/src/wrappers/index.ts
deleted file mode 100644
index eed198524..000000000
--- a/contracts/extensions/src/wrappers/index.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-export * from '../../generated-wrappers/balance_threshold_filter';
-export * from '../../generated-wrappers/dutch_auction';
-export * from '../../generated-wrappers/order_matcher';
-export * from '../../generated-wrappers/order_validator';
diff --git a/contracts/extensions/test/balance_threshold_filter.ts b/contracts/extensions/test/balance_threshold_filter.ts
index c79a72f5a..34eb319de 100644
--- a/contracts/extensions/test/balance_threshold_filter.ts
+++ b/contracts/extensions/test/balance_threshold_filter.ts
@@ -1,3 +1,4 @@
+import { ExchangeWrapper } from '@0x/contracts-exchange';
import { BlockchainLifecycle } from '@0x/dev-utils';
import { assetDataUtils } from '@0x/order-utils';
import { Order, RevertReason, SignedOrder } from '@0x/types';
@@ -9,7 +10,6 @@ import * as _ from 'lodash';
import { ERC20Wrapper, ERC721Wrapper } from '@0x/contracts-asset-proxy';
import { DummyERC20TokenContract } from '@0x/contracts-erc20';
-import { artifacts as exchangeArtifacts, ExchangeContract, ExchangeWrapper } from '@0x/contracts-exchange';
import {
chaiSetup,
constants,
@@ -24,7 +24,7 @@ import {
web3Wrapper,
} from '@0x/contracts-test-utils';
-import { artifacts, BalanceThresholdFilterContract, BalanceThresholdWrapper } from '../src';
+import { artifacts, BalanceThresholdFilterContract, BalanceThresholdWrapper, ExchangeContract } from '../src';
chaiSetup.configure();
const expect = chai.expect;
@@ -127,7 +127,7 @@ describe(ContractName.BalanceThresholdFilter, () => {
await erc20Wrapper.setBalancesAndAllowancesAsync();
// Deploy Exchange contract
exchangeInstance = await ExchangeContract.deployFrom0xArtifactAsync(
- exchangeArtifacts.Exchange,
+ artifacts.Exchange,
provider,
txDefaults,
zrxAssetData,
diff --git a/contracts/extensions/test/dutch_auction.ts b/contracts/extensions/test/dutch_auction.ts
index 34ff25c3d..efe813ffc 100644
--- a/contracts/extensions/test/dutch_auction.ts
+++ b/contracts/extensions/test/dutch_auction.ts
@@ -1,8 +1,6 @@
import { DutchAuctionWrapper } from '@0x/contract-wrappers';
import { ERC20Wrapper, ERC721Wrapper } from '@0x/contracts-asset-proxy';
-import { artifacts as erc20Artifacts, DummyERC20TokenContract, WETH9Contract } from '@0x/contracts-erc20';
-import { DummyERC721TokenContract } from '@0x/contracts-erc721';
-import { artifacts as exchangeArtifacts, ExchangeContract, ExchangeWrapper } from '@0x/contracts-exchange';
+import { ExchangeWrapper } from '@0x/contracts-exchange';
import {
chaiSetup,
constants,
@@ -23,7 +21,15 @@ import { Web3Wrapper } from '@0x/web3-wrapper';
import * as chai from 'chai';
import * as _ from 'lodash';
-import { artifacts, DutchAuctionContract, DutchAuctionTestWrapper } from '../src';
+import {
+ artifacts,
+ DummyERC20TokenContract,
+ DummyERC721TokenContract,
+ DutchAuctionContract,
+ DutchAuctionTestWrapper,
+ ExchangeContract,
+ WETH9Contract,
+} from '../src';
chaiSetup.configure();
const expect = chai.expect;
@@ -82,12 +88,12 @@ describe(ContractName.DutchAuction, () => {
const erc721Balances = await erc721Wrapper.getBalancesAsync();
erc721MakerAssetIds = erc721Balances[makerAddress][erc721Token.address];
- wethContract = await WETH9Contract.deployFrom0xArtifactAsync(erc20Artifacts.WETH9, provider, txDefaults);
+ wethContract = await WETH9Contract.deployFrom0xArtifactAsync(artifacts.WETH9, provider, txDefaults);
erc20Wrapper.addDummyTokenContract(wethContract as any);
const zrxAssetData = assetDataUtils.encodeERC20AssetData(zrxToken.address);
const exchangeInstance = await ExchangeContract.deployFrom0xArtifactAsync(
- exchangeArtifacts.Exchange,
+ artifacts.Exchange,
provider,
txDefaults,
zrxAssetData,
diff --git a/contracts/extensions/test/order_matcher.ts b/contracts/extensions/test/order_matcher.ts
index 0b2f9ddbb..d726de8e0 100644
--- a/contracts/extensions/test/order_matcher.ts
+++ b/contracts/extensions/test/order_matcher.ts
@@ -1,17 +1,5 @@
-import {
- artifacts as proxyArtifacts,
- ERC20ProxyContract,
- ERC20Wrapper,
- ERC721ProxyContract,
-} from '@0x/contracts-asset-proxy';
-import { artifacts as erc20Artifacts, DummyERC20TokenContract } from '@0x/contracts-erc20';
-import { artifacts as erc721Artifacts, DummyERC721TokenContract } from '@0x/contracts-erc721';
-import {
- artifacts as exchangeArtifacts,
- ExchangeContract,
- ExchangeFillEventArgs,
- ExchangeWrapper,
-} from '@0x/contracts-exchange';
+import { ERC20Wrapper } from '@0x/contracts-asset-proxy';
+import { ExchangeWrapper } from '@0x/contracts-exchange';
import {
chaiSetup,
constants,
@@ -34,7 +22,16 @@ import * as chai from 'chai';
import { LogWithDecodedArgs } from 'ethereum-types';
import * as _ from 'lodash';
-import { artifacts, OrderMatcherContract } from '../src';
+import {
+ artifacts,
+ DummyERC20TokenContract,
+ DummyERC721TokenContract,
+ ERC20ProxyContract,
+ ERC721ProxyContract,
+ ExchangeContract,
+ ExchangeFillEventArgs,
+ OrderMatcherContract,
+} from '../src';
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
chaiSetup.configure();
@@ -104,14 +101,10 @@ describe('OrderMatcher', () => {
erc20Proxy = await erc20Wrapper.deployProxyAsync();
await erc20Wrapper.setBalancesAndAllowancesAsync();
// Deploy ERC721 proxy
- erc721Proxy = await ERC721ProxyContract.deployFrom0xArtifactAsync(
- proxyArtifacts.ERC721Proxy,
- provider,
- txDefaults,
- );
+ erc721Proxy = await ERC721ProxyContract.deployFrom0xArtifactAsync(artifacts.ERC721Proxy, provider, txDefaults);
// Depoy exchange
exchange = await ExchangeContract.deployFrom0xArtifactAsync(
- exchangeArtifacts.Exchange,
+ artifacts.Exchange,
provider,
txDefaults,
assetDataUtils.encodeERC20AssetData(zrxToken.address),
@@ -200,7 +193,7 @@ describe('OrderMatcher', () => {
describe('constructor', () => {
it('should revert if assetProxy is unregistered', async () => {
const exchangeInstance = await ExchangeContract.deployFrom0xArtifactAsync(
- exchangeArtifacts.Exchange,
+ artifacts.Exchange,
provider,
txDefaults,
constants.NULL_BYTES,
@@ -454,7 +447,7 @@ describe('OrderMatcher', () => {
signedOrderLeft.signature,
signedOrderRight.signature,
);
- const logDecoder = new LogDecoder(web3Wrapper, { ...artifacts, ...erc20Artifacts, ...exchangeArtifacts });
+ const logDecoder = new LogDecoder(web3Wrapper, artifacts);
const txReceipt = await logDecoder.getTxWithDecodedLogsAsync(
await web3Wrapper.sendTransactionAsync({
data,
@@ -492,7 +485,7 @@ describe('OrderMatcher', () => {
signedOrderLeft.signature,
signedOrderRight.signature,
);
- const logDecoder = new LogDecoder(web3Wrapper, { ...artifacts, ...erc20Artifacts, ...exchangeArtifacts });
+ const logDecoder = new LogDecoder(web3Wrapper, artifacts);
const txReceipt = await logDecoder.getTxWithDecodedLogsAsync(
await web3Wrapper.sendTransactionAsync({
data,
@@ -729,7 +722,7 @@ describe('OrderMatcher', () => {
});
it('should allow owner to withdraw ERC721 tokens', async () => {
const erc721Token = await DummyERC721TokenContract.deployFrom0xArtifactAsync(
- erc721Artifacts.DummyERC721Token,
+ artifacts.DummyERC721Token,
provider,
txDefaults,
constants.DUMMY_TOKEN_NAME,
@@ -774,7 +767,7 @@ describe('OrderMatcher', () => {
});
it('should be able to approve an ERC721 token by passing in allowance = 1', async () => {
const erc721Token = await DummyERC721TokenContract.deployFrom0xArtifactAsync(
- erc721Artifacts.DummyERC721Token,
+ artifacts.DummyERC721Token,
provider,
txDefaults,
constants.DUMMY_TOKEN_NAME,
@@ -791,7 +784,7 @@ describe('OrderMatcher', () => {
});
it('should be able to approve an ERC721 token by passing in allowance > 1', async () => {
const erc721Token = await DummyERC721TokenContract.deployFrom0xArtifactAsync(
- erc721Artifacts.DummyERC721Token,
+ artifacts.DummyERC721Token,
provider,
txDefaults,
constants.DUMMY_TOKEN_NAME,
diff --git a/contracts/extensions/test/order_validator.ts b/contracts/extensions/test/order_validator.ts
index 88dae14fb..ec31cafbc 100644
--- a/contracts/extensions/test/order_validator.ts
+++ b/contracts/extensions/test/order_validator.ts
@@ -1,7 +1,5 @@
-import { ERC20ProxyContract, ERC20Wrapper, ERC721ProxyContract, ERC721Wrapper } from '@0x/contracts-asset-proxy';
-import { DummyERC20TokenContract } from '@0x/contracts-erc20';
-import { DummyERC721TokenContract } from '@0x/contracts-erc721';
-import { artifacts as exchangeArtifacts, ExchangeContract, ExchangeWrapper } from '@0x/contracts-exchange';
+import { ERC20Wrapper, ERC721Wrapper } from '@0x/contracts-asset-proxy';
+import { ExchangeWrapper } from '@0x/contracts-exchange';
import {
chaiSetup,
constants,
@@ -18,7 +16,15 @@ import { BigNumber } from '@0x/utils';
import * as chai from 'chai';
import * as _ from 'lodash';
-import { artifacts, OrderValidatorContract } from '../src';
+import {
+ artifacts,
+ DummyERC20TokenContract,
+ DummyERC721TokenContract,
+ ERC20ProxyContract,
+ ERC721ProxyContract,
+ ExchangeContract,
+ OrderValidatorContract,
+} from '../src';
chaiSetup.configure();
const expect = chai.expect;
@@ -74,7 +80,7 @@ describe('OrderValidator', () => {
const zrxAssetData = assetDataUtils.encodeERC20AssetData(zrxToken.address);
exchange = await ExchangeContract.deployFrom0xArtifactAsync(
- exchangeArtifacts.Exchange,
+ artifacts.Exchange,
provider,
txDefaults,
zrxAssetData,
diff --git a/contracts/extensions/test/utils/balance_threshold_wrapper.ts b/contracts/extensions/test/utils/balance_threshold_wrapper.ts
index 3178d992e..ab59c5688 100644
--- a/contracts/extensions/test/utils/balance_threshold_wrapper.ts
+++ b/contracts/extensions/test/utils/balance_threshold_wrapper.ts
@@ -1,6 +1,3 @@
-import { artifacts as erc20Artifacts } from '@0x/contracts-erc20';
-import { artifacts as erc721Artifacts } from '@0x/contracts-erc721';
-import { artifacts as exchangeArtifacts, ExchangeContract } from '@0x/contracts-exchange';
import {
FillResults,
formatters,
@@ -15,8 +12,7 @@ import { Web3Wrapper } from '@0x/web3-wrapper';
import { Provider, TransactionReceiptWithDecodedLogs } from 'ethereum-types';
import * as _ from 'lodash';
-import { BalanceThresholdFilterContract } from '../../generated-wrappers/balance_threshold_filter';
-import { artifacts } from '../../src/artifacts';
+import { artifacts, BalanceThresholdFilterContract, ExchangeContract } from '../../src';
export class BalanceThresholdWrapper {
private readonly _balanceThresholdFilter: BalanceThresholdFilterContract;
@@ -34,12 +30,7 @@ export class BalanceThresholdWrapper {
this._exchange = exchangeContract;
this._signerTransactionFactory = signerTransactionFactory;
this._web3Wrapper = new Web3Wrapper(provider);
- this._logDecoder = new LogDecoder(this._web3Wrapper, {
- ...artifacts,
- ...erc20Artifacts,
- ...erc721Artifacts,
- ...exchangeArtifacts,
- });
+ this._logDecoder = new LogDecoder(this._web3Wrapper, artifacts);
}
public async fillOrderAsync(
signedOrder: SignedOrder,
@@ -227,7 +218,7 @@ export class BalanceThresholdWrapper {
from: string,
): Promise<TransactionReceiptWithDecodedLogs> {
const params = orderUtils.createMatchOrders(signedOrderLeft, signedOrderRight);
- const data = await this._exchange.matchOrders.getABIEncodedTransactionData(
+ const data = this._exchange.matchOrders.getABIEncodedTransactionData(
params.left,
params.right,
params.leftSignature,
diff --git a/contracts/extensions/test/utils/dutch_auction_test_wrapper.ts b/contracts/extensions/test/utils/dutch_auction_test_wrapper.ts
index 5899ffcac..06cdc21d5 100644
--- a/contracts/extensions/test/utils/dutch_auction_test_wrapper.ts
+++ b/contracts/extensions/test/utils/dutch_auction_test_wrapper.ts
@@ -1,6 +1,3 @@
-import { artifacts as erc20Artifacts } from '@0x/contracts-erc20';
-import { artifacts as erc721Artifacts } from '@0x/contracts-erc721';
-import { artifacts as exchangeArtifacts } from '@0x/contracts-exchange';
import { LogDecoder } from '@0x/contracts-test-utils';
import { DutchAuctionDetails, SignedOrder } from '@0x/types';
import { Web3Wrapper } from '@0x/web3-wrapper';
@@ -18,12 +15,7 @@ export class DutchAuctionTestWrapper {
constructor(contractInstance: DutchAuctionContract, provider: Provider) {
this._dutchAuctionContract = contractInstance;
this._web3Wrapper = new Web3Wrapper(provider);
- this._logDecoder = new LogDecoder(this._web3Wrapper, {
- ...artifacts,
- ...erc20Artifacts,
- ...erc721Artifacts,
- ...exchangeArtifacts,
- });
+ this._logDecoder = new LogDecoder(this._web3Wrapper, artifacts);
}
/**
* Matches the buy and sell orders at an amount given the following: the current block time, the auction
diff --git a/contracts/extensions/tsconfig.json b/contracts/extensions/tsconfig.json
index 0c06c6902..b424bfa04 100644
--- a/contracts/extensions/tsconfig.json
+++ b/contracts/extensions/tsconfig.json
@@ -1,16 +1,19 @@
{
"extends": "../../tsconfig",
- "compilerOptions": {
- "outDir": "lib",
- "rootDir": ".",
- "resolveJsonModule": true
- },
+ "compilerOptions": { "outDir": "lib", "rootDir": ".", "resolveJsonModule": true },
"include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*"],
"files": [
- "./generated-artifacts/BalanceThresholdFilter.json",
- "./generated-artifacts/DutchAuction.json",
- "./generated-artifacts/OrderMatcher.json",
- "./generated-artifacts/OrderValidator.json"
+ "generated-artifacts/BalanceThresholdFilter.json",
+ "generated-artifacts/DummyERC20Token.json",
+ "generated-artifacts/DummyERC721Token.json",
+ "generated-artifacts/DutchAuction.json",
+ "generated-artifacts/ERC20Proxy.json",
+ "generated-artifacts/ERC721Proxy.json",
+ "generated-artifacts/Exchange.json",
+ "generated-artifacts/ExchangeWrapper.json",
+ "generated-artifacts/OrderMatcher.json",
+ "generated-artifacts/OrderValidator.json",
+ "generated-artifacts/WETH9.json"
],
"exclude": ["./deploy/solc/solc_bin"]
}