aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Hysen <greg.hysen@gmail.com>2018-12-12 06:47:52 +0800
committerGreg Hysen <greg.hysen@gmail.com>2018-12-19 05:36:05 +0800
commit4417c76b130655da3b14209148191d43037e8f8a (patch)
tree1cb3cf7ea3104d2dd68d9f5f48c1183e037ad244
parent8799f9bb90c6bcfffc74550d74ed87422467f9e1 (diff)
downloaddexon-sol-tools-4417c76b130655da3b14209148191d43037e8f8a.tar
dexon-sol-tools-4417c76b130655da3b14209148191d43037e8f8a.tar.gz
dexon-sol-tools-4417c76b130655da3b14209148191d43037e8f8a.tar.bz2
dexon-sol-tools-4417c76b130655da3b14209148191d43037e8f8a.tar.lz
dexon-sol-tools-4417c76b130655da3b14209148191d43037e8f8a.tar.xz
dexon-sol-tools-4417c76b130655da3b14209148191d43037e8f8a.tar.zst
dexon-sol-tools-4417c76b130655da3b14209148191d43037e8f8a.zip
Ported Balance Threshold Filter to new contract directory structure
-rw-r--r--contracts/extensions/compiler.json2
-rw-r--r--contracts/extensions/contracts/BalanceThresholdFilter/BalanceThresholdFilter.sol (renamed from packages/contracts/contracts/extensions/BalanceThresholdFilter/BalanceThresholdFilter.sol)4
-rw-r--r--contracts/extensions/contracts/BalanceThresholdFilter/MixinBalanceThresholdFilterCore.sol (renamed from packages/contracts/contracts/extensions/BalanceThresholdFilter/MixinBalanceThresholdFilterCore.sol)0
-rw-r--r--contracts/extensions/contracts/BalanceThresholdFilter/interfaces/IThresholdAsset.sol (renamed from packages/contracts/contracts/extensions/BalanceThresholdFilter/interfaces/IThresholdAsset.sol)0
-rw-r--r--contracts/extensions/contracts/BalanceThresholdFilter/mixins/MBalanceThresholdFilterCore.sol (renamed from packages/contracts/contracts/extensions/BalanceThresholdFilter/mixins/MBalanceThresholdFilterCore.sol)2
-rw-r--r--contracts/extensions/package.json2
-rw-r--r--contracts/extensions/src/artifacts/index.ts2
-rw-r--r--contracts/extensions/src/wrappers/index.ts1
-rw-r--r--contracts/extensions/test/extensions/balance_threshold_filter.ts (renamed from packages/contracts/test/extensions/balance_threshold_filter.ts)65
-rw-r--r--contracts/extensions/test/utils/balance_threshold_wrapper.ts (renamed from packages/contracts/test/utils/balance_threshold_wrapper.ts)13
-rw-r--r--contracts/extensions/tsconfig.json2
11 files changed, 52 insertions, 41 deletions
diff --git a/contracts/extensions/compiler.json b/contracts/extensions/compiler.json
index 69d607b3e..e6ed0c215 100644
--- a/contracts/extensions/compiler.json
+++ b/contracts/extensions/compiler.json
@@ -18,5 +18,5 @@
}
}
},
- "contracts": ["DutchAuction", "Forwarder"]
+ "contracts": ["BalanceThresholdFilter", "DutchAuction", "Forwarder"]
}
diff --git a/packages/contracts/contracts/extensions/BalanceThresholdFilter/BalanceThresholdFilter.sol b/contracts/extensions/contracts/BalanceThresholdFilter/BalanceThresholdFilter.sol
index bf4a94509..a68f6805d 100644
--- a/packages/contracts/contracts/extensions/BalanceThresholdFilter/BalanceThresholdFilter.sol
+++ b/contracts/extensions/contracts/BalanceThresholdFilter/BalanceThresholdFilter.sol
@@ -19,7 +19,7 @@
pragma solidity 0.4.24;
pragma experimental ABIEncoderV2;
-import "../../protocol/Exchange/interfaces/IExchange.sol";
+import "@0x/contracts-interfaces/contracts/protocol/Exchange/IExchange.sol";
import "./interfaces/IThresholdAsset.sol";
import "./MixinBalanceThresholdFilterCore.sol";
@@ -41,4 +41,4 @@ contract BalanceThresholdFilter is MixinBalanceThresholdFilterCore {
THRESHOLD_ASSET = IThresholdAsset(thresholdAsset);
THRESHOLD_BALANCE = thresholdBalance;
}
-} \ No newline at end of file
+}
diff --git a/packages/contracts/contracts/extensions/BalanceThresholdFilter/MixinBalanceThresholdFilterCore.sol b/contracts/extensions/contracts/BalanceThresholdFilter/MixinBalanceThresholdFilterCore.sol
index 0ad8ccddf..0ad8ccddf 100644
--- a/packages/contracts/contracts/extensions/BalanceThresholdFilter/MixinBalanceThresholdFilterCore.sol
+++ b/contracts/extensions/contracts/BalanceThresholdFilter/MixinBalanceThresholdFilterCore.sol
diff --git a/packages/contracts/contracts/extensions/BalanceThresholdFilter/interfaces/IThresholdAsset.sol b/contracts/extensions/contracts/BalanceThresholdFilter/interfaces/IThresholdAsset.sol
index 61acaba0a..61acaba0a 100644
--- a/packages/contracts/contracts/extensions/BalanceThresholdFilter/interfaces/IThresholdAsset.sol
+++ b/contracts/extensions/contracts/BalanceThresholdFilter/interfaces/IThresholdAsset.sol
diff --git a/packages/contracts/contracts/extensions/BalanceThresholdFilter/mixins/MBalanceThresholdFilterCore.sol b/contracts/extensions/contracts/BalanceThresholdFilter/mixins/MBalanceThresholdFilterCore.sol
index 612fd481c..ff0042f58 100644
--- a/packages/contracts/contracts/extensions/BalanceThresholdFilter/mixins/MBalanceThresholdFilterCore.sol
+++ b/contracts/extensions/contracts/BalanceThresholdFilter/mixins/MBalanceThresholdFilterCore.sol
@@ -19,7 +19,7 @@
pragma solidity 0.4.24;
pragma experimental ABIEncoderV2;
-import "../../../protocol/Exchange/interfaces/IExchange.sol";
+import "@0x/contracts-interfaces/contracts/protocol/Exchange/IExchange.sol";
import "../interfaces/IThresholdAsset.sol";
diff --git a/contracts/extensions/package.json b/contracts/extensions/package.json
index 938e1138c..2d9ed4dcd 100644
--- a/contracts/extensions/package.json
+++ b/contracts/extensions/package.json
@@ -31,7 +31,7 @@
"lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol"
},
"config": {
- "abis": "generated-artifacts/@(DutchAuction|Forwarder).json"
+ "abis": "generated-artifacts/@(BalanceThresholdFilter|DutchAuction|Forwarder).json"
},
"repository": {
"type": "git",
diff --git a/contracts/extensions/src/artifacts/index.ts b/contracts/extensions/src/artifacts/index.ts
index 7588178f0..ebf0b8050 100644
--- a/contracts/extensions/src/artifacts/index.ts
+++ b/contracts/extensions/src/artifacts/index.ts
@@ -1,9 +1,11 @@
import { ContractArtifact } from 'ethereum-types';
+import * as BalanceThresholdFilter from '../../generated-artifacts/BalanceThresholdFilter.json';
import * as DutchAuction from '../../generated-artifacts/DutchAuction.json';
import * as Forwarder from '../../generated-artifacts/Forwarder.json';
export const artifacts = {
+ BalanceThresholdFilter: BalanceThresholdFilter as ContractArtifact,
DutchAuction: DutchAuction as ContractArtifact,
Forwarder: Forwarder as ContractArtifact,
};
diff --git a/contracts/extensions/src/wrappers/index.ts b/contracts/extensions/src/wrappers/index.ts
index 90880e37f..8a8122caa 100644
--- a/contracts/extensions/src/wrappers/index.ts
+++ b/contracts/extensions/src/wrappers/index.ts
@@ -1,2 +1,3 @@
+export * from '../../generated-wrappers/balance_threshold_filter';
export * from '../../generated-wrappers/dutch_auction';
export * from '../../generated-wrappers/forwarder';
diff --git a/packages/contracts/test/extensions/balance_threshold_filter.ts b/contracts/extensions/test/extensions/balance_threshold_filter.ts
index c4723e7aa..34339564c 100644
--- a/packages/contracts/test/extensions/balance_threshold_filter.ts
+++ b/contracts/extensions/test/extensions/balance_threshold_filter.ts
@@ -8,33 +8,42 @@ import * as ethUtil from 'ethereumjs-util';
import * as _ from 'lodash';
import { TransactionReceiptWithDecodedLogs } from 'ethereum-types';
-import { DummyERC20TokenContract } from '../../generated-wrappers/dummy_erc20_token';
-import { ExchangeContract } from '../../generated-wrappers/exchange';
-import { BalanceThresholdFilterContract } from '../../generated-wrappers/balance_threshold_filter';
-
-import { artifacts } from '../../src/artifacts';
import {
+ artifacts as protocolArtifacts,
+ ERC20Wrapper,
+ ERC721Wrapper,
+ ExchangeContract,
+ ExchangeWrapper,
+ TestExchangeInternalsContract,
+} from '@0x/contracts-protocol';
+import {
+ chaiSetup,
+ constants,
+ ContractName,
+ ERC20BalancesByOwner,
expectTransactionFailedAsync,
expectTransactionFailedWithoutReasonAsync,
-} from '../utils/assertions';
-import { chaiSetup } from '../utils/chai_setup';
-import { constants } from '../utils/constants';
-import { ERC20Wrapper } from '../utils/erc20_wrapper';
-import { ExchangeWrapper } from '../utils/exchange_wrapper';
-import { MatchOrderTester } from '../utils/match_order_tester';
-import { OrderFactory } from '../utils/order_factory';
-import { orderUtils } from '../utils/order_utils';
-import { TransactionFactory } from '../utils/transaction_factory';
-import { BalanceThresholdWrapper } from '../utils/balance_threshold_wrapper';
-import { ContractName, ERC20BalancesByOwner, SignedTransaction, OrderStatus } from '../utils/types';
-import { provider, txDefaults, web3Wrapper } from '../utils/web3_wrapper';
-import { TestExchangeInternalsContract } from '../../generated-wrappers/test_exchange_internals';
+ getLatestBlockTimestampAsync,
+ LogDecoder,
+ OrderFactory,
+ OrderStatus,
+ orderUtils,
+ provider,
+ SignedTransaction,
+ txDefaults,
+ TransactionFactory,
+ web3Wrapper,
+} from '@0x/contracts-test-utils';
+import {
+ artifacts as tokensArtifacts,
+ DummyERC20TokenContract,
+ DummyERC721TokenContract,
+ WETH9Contract,
+} from '@0x/contracts-tokens';
-import { MethodAbi, AbiDefinition } from 'ethereum-types';
-import { AbiEncoder } from '@0x/utils';
-import { Method } from '@0x/utils/lib/src/abi_encoder';
-import { LogDecoder } from '../utils/log_decoder';
-import { ERC721Wrapper } from '../utils/erc721_wrapper';
+import { artifacts } from '../../src/artifacts';
+import { BalanceThresholdFilterContract } from '../../generated-wrappers/balance_threshold_filter';
+import { BalanceThresholdWrapper } from '../utils/balance_threshold_wrapper';
chaiSetup.configure();
const expect = chai.expect;
@@ -137,7 +146,7 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
await erc20Wrapper.setBalancesAndAllowancesAsync();
// Deploy Exchange congtract
exchangeInstance = await ExchangeContract.deployFrom0xArtifactAsync(
- artifacts.Exchange,
+ protocolArtifacts.Exchange,
provider,
txDefaults,
zrxAssetData,
@@ -224,7 +233,7 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
compliantSignedOrderWithoutExchangeAddressData,
);
- logDecoder = new LogDecoder(web3Wrapper);
+ logDecoder = new LogDecoder(web3Wrapper, {... artifacts, ... protocolArtifacts, ... tokensArtifacts});
erc20TakerBalanceThresholdWrapper = new BalanceThresholdWrapper(erc20CompliantForwarderInstance, exchangeInstance, new TransactionFactory(takerPrivateKey, exchangeInstance.address), provider);
erc721TakerBalanceThresholdWrapper = new BalanceThresholdWrapper(erc721CompliantForwarderInstance, exchangeInstance, new TransactionFactory(takerPrivateKey, exchangeInstance.address), provider);
erc721MakerBalanceThresholdWrapper = new BalanceThresholdWrapper(erc721CompliantForwarderInstance, exchangeInstance, new TransactionFactory(makerPrivateKey, exchangeInstance.address), provider);
@@ -232,7 +241,7 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
// Instantiate internal exchange contract
exchangeInternals = await TestExchangeInternalsContract.deployFrom0xArtifactAsync(
- artifacts.TestExchangeInternals,
+ protocolArtifacts.TestExchangeInternals,
provider,
txDefaults,
);
@@ -244,13 +253,13 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
await blockchainLifecycle.revertAsync();
});
- describe.only('General Sanity Checks', () => {
+ describe('General Sanity Checks', () => {
beforeEach(async () => {
erc20Balances = await erc20Wrapper.getBalancesAsync();
compliantSignedOrder = await orderFactory.newSignedOrderAsync();
compliantSignedOrder2 = await orderFactory2.newSignedOrderAsync();
});
- it.only('should transfer the correct amounts and validate both maker/taker when both maker and taker exceed the balance threshold of an ERC20 token', async () => {
+ it('should transfer the correct amounts and validate both maker/taker when both maker and taker exceed the balance threshold of an ERC20 token', async () => {
const compliantSignedOrderERC20Sender = await orderFactory.newSignedOrderAsync({
...
defaultOrderParams,
diff --git a/packages/contracts/test/utils/balance_threshold_wrapper.ts b/contracts/extensions/test/utils/balance_threshold_wrapper.ts
index cff40aa52..63128686c 100644
--- a/packages/contracts/test/utils/balance_threshold_wrapper.ts
+++ b/contracts/extensions/test/utils/balance_threshold_wrapper.ts
@@ -4,14 +4,13 @@ import { Web3Wrapper } from '@0x/web3-wrapper';
import { Provider, TransactionReceiptWithDecodedLogs } from 'ethereum-types';
import * as _ from 'lodash';
-import { ExchangeContract } from '../../generated-wrappers/exchange';
+import { ExchangeContract } from '@0x/contracts-protocol';
import { BalanceThresholdFilterContract } from '../../generated-wrappers/balance_threshold_filter';
-import { formatters } from './formatters';
-import { LogDecoder } from './log_decoder';
-import { orderUtils } from './order_utils';
-import { TransactionFactory } from '../utils/transaction_factory';
-import { OrderInfo } from './types';
+import { formatters, LogDecoder, orderUtils, OrderInfo, TransactionFactory } from '@0x/contracts-test-utils';
+import { artifacts } from '../../src/artifacts';
+import {artifacts as protocolArtifacts} from '@0x/contracts-protocol';
+import { artifacts as tokensArtifacts } from '@0x/contracts-tokens';
export class BalanceThresholdWrapper {
private readonly _balanceThresholdFilter: BalanceThresholdFilterContract;
@@ -24,7 +23,7 @@ export class BalanceThresholdWrapper {
this._exchange = exchangeContract;
this._signerTransactionFactory = signerTransactionFactory;
this._web3Wrapper = new Web3Wrapper(provider);
- this._logDecoder = new LogDecoder(this._web3Wrapper);
+ this._logDecoder = new LogDecoder(this._web3Wrapper, {... artifacts, ... tokensArtifacts, ... protocolArtifacts} );
}
public async fillOrderAsync(
signedOrder: SignedOrder,
diff --git a/contracts/extensions/tsconfig.json b/contracts/extensions/tsconfig.json
index a4ce1e002..5d3ebfe74 100644
--- a/contracts/extensions/tsconfig.json
+++ b/contracts/extensions/tsconfig.json
@@ -6,6 +6,6 @@
"resolveJsonModule": true
},
"include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*"],
- "files": ["./generated-artifacts/DutchAuction.json", "./generated-artifacts/Forwarder.json"],
+ "files": ["./generated-artifacts/BalanceThresholdFilter.json", "./generated-artifacts/DutchAuction.json", "./generated-artifacts/Forwarder.json"],
"exclude": ["./deploy/solc/solc_bin"]
}