From 15a5bc02efb9c500563aa19297d61a1ecea06d5f Mon Sep 17 00:00:00 2001 From: fabioberger Date: Mon, 11 Nov 2019 00:13:44 +0000 Subject: [PATCH] Fix remaining build issues --- contracts/coordinator/package.json | 2 +- contracts/coordinator/test/artifacts.ts | 37 +++++++++++++++++ contracts/coordinator/test/mixins.ts | 21 +++++----- contracts/coordinator/test/wrappers.ts | 19 +++++++++ contracts/coordinator/tsconfig.json | 16 +++++++- contracts/exchange-forwarder/package.json | 2 +- .../exchange-forwarder/test/artifacts.ts | 29 ++++++++++++++ contracts/exchange-forwarder/test/wrappers.ts | 15 +++++++ contracts/exchange-forwarder/tsconfig.json | 12 +++++- contracts/exchange/src/index.ts | 3 +- .../assertion_wrappers/fill_order_wrapper.ts | 3 +- contracts/exchange/test/core.ts | 15 ++++--- contracts/exchange/test/dispatcher.ts | 4 +- contracts/exchange/test/internal.ts | 4 +- .../test/lib_exchange_rich_error_decoder.ts | 3 +- contracts/exchange/test/match_orders.ts | 7 +++- contracts/exchange/test/protocol_fees.ts | 3 +- .../exchange/test/protocol_fees_manager.ts | 4 +- contracts/exchange/test/reentrancy_tests.ts | 3 +- .../exchange/test/signature_validator.ts | 4 +- contracts/exchange/test/transactions.ts | 18 ++++----- .../exchange/test/transactions_unit_tests.ts | 6 ++- contracts/exchange/test/utils/constants.ts | 24 +---------- .../test/utils/exchange_data_encoder.ts | 12 +++--- .../exchange/test/utils/exchange_wrapper.ts | 2 +- .../utils/fill_order_combinatorial_utils.ts | 4 +- .../test/utils/isolated_exchange_wrapper.ts | 5 ++- contracts/exchange/test/utils/types.ts | 10 +++++ contracts/exchange/test/wrapper_unit_tests.ts | 4 +- contracts/extensions/package.json | 1 - .../test/balance_threshold_filter.ts | 11 +++-- contracts/extensions/test/dutch_auction.ts | 17 ++++++-- contracts/extensions/test/order_matcher.ts | 40 +++++++++++++------ contracts/integrations/package.json | 4 +- contracts/integrations/test/actors/utils.ts | 4 +- contracts/integrations/test/artifacts.ts | 9 +++++ .../test/coordinator/coordinator_test.ts | 7 ++-- .../deployment_manager_test.ts | 2 +- .../deployment_test.ts | 5 +-- .../fillorder_test.ts | 8 ++-- .../test/utils/deployment_manager.ts | 10 ++--- .../test/utils}/wrapper_interfaces.ts | 0 contracts/integrations/test/wrappers.ts | 6 +++ contracts/integrations/tsconfig.json | 2 +- contracts/test-utils/src/constants.ts | 24 +++++++++++ contracts/test-utils/src/index.ts | 1 + contracts/test-utils/src/types.ts | 30 ++++++++++++++ contracts/tests/package.json | 2 +- .../test/dev-utils/lib_transaction_decoder.ts | 4 +- .../test/dev-utils/order_validation_utils.ts | 24 ++++++++--- 50 files changed, 369 insertions(+), 133 deletions(-) create mode 100644 contracts/coordinator/test/artifacts.ts create mode 100644 contracts/coordinator/test/wrappers.ts create mode 100644 contracts/exchange-forwarder/test/artifacts.ts create mode 100644 contracts/exchange-forwarder/test/wrappers.ts create mode 100644 contracts/integrations/test/artifacts.ts rename contracts/{exchange/src => integrations/test/utils}/wrapper_interfaces.ts (100%) create mode 100644 contracts/integrations/test/wrappers.ts diff --git a/contracts/coordinator/package.json b/contracts/coordinator/package.json index d052d9a650..a92969a0a2 100644 --- a/contracts/coordinator/package.json +++ b/contracts/coordinator/package.json @@ -36,7 +36,7 @@ "compile:truffle": "truffle compile" }, "config": { - "abis": "./generated-artifacts/@(Coordinator|CoordinatorRegistry|ICoordinatorApprovalVerifier|ICoordinatorCore|ICoordinatorRegistryCore|ICoordinatorSignatureValidator|LibConstants|LibCoordinatorApproval|LibCoordinatorRichErrors|LibEIP712CoordinatorDomain|MixinCoordinatorApprovalVerifier|MixinCoordinatorCore|MixinCoordinatorRegistryCore|MixinSignatureValidator).json", + "abis": "./test/generated-artifacts/@(Coordinator|CoordinatorRegistry|ICoordinatorApprovalVerifier|ICoordinatorCore|ICoordinatorRegistryCore|ICoordinatorSignatureValidator|LibConstants|LibCoordinatorApproval|LibCoordinatorRichErrors|LibEIP712CoordinatorDomain|MixinCoordinatorApprovalVerifier|MixinCoordinatorCore|MixinCoordinatorRegistryCore|MixinSignatureValidator).json", "abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually." }, "repository": { diff --git a/contracts/coordinator/test/artifacts.ts b/contracts/coordinator/test/artifacts.ts new file mode 100644 index 0000000000..d432f86b29 --- /dev/null +++ b/contracts/coordinator/test/artifacts.ts @@ -0,0 +1,37 @@ +/* + * ----------------------------------------------------------------------------- + * Warning: This file is auto-generated by contracts-gen. Don't edit manually. + * ----------------------------------------------------------------------------- + */ +import { ContractArtifact } from 'ethereum-types'; + +import * as Coordinator from '../test/generated-artifacts/Coordinator.json'; +import * as CoordinatorRegistry from '../test/generated-artifacts/CoordinatorRegistry.json'; +import * as ICoordinatorApprovalVerifier from '../test/generated-artifacts/ICoordinatorApprovalVerifier.json'; +import * as ICoordinatorCore from '../test/generated-artifacts/ICoordinatorCore.json'; +import * as ICoordinatorRegistryCore from '../test/generated-artifacts/ICoordinatorRegistryCore.json'; +import * as ICoordinatorSignatureValidator from '../test/generated-artifacts/ICoordinatorSignatureValidator.json'; +import * as LibConstants from '../test/generated-artifacts/LibConstants.json'; +import * as LibCoordinatorApproval from '../test/generated-artifacts/LibCoordinatorApproval.json'; +import * as LibCoordinatorRichErrors from '../test/generated-artifacts/LibCoordinatorRichErrors.json'; +import * as LibEIP712CoordinatorDomain from '../test/generated-artifacts/LibEIP712CoordinatorDomain.json'; +import * as MixinCoordinatorApprovalVerifier from '../test/generated-artifacts/MixinCoordinatorApprovalVerifier.json'; +import * as MixinCoordinatorCore from '../test/generated-artifacts/MixinCoordinatorCore.json'; +import * as MixinCoordinatorRegistryCore from '../test/generated-artifacts/MixinCoordinatorRegistryCore.json'; +import * as MixinSignatureValidator from '../test/generated-artifacts/MixinSignatureValidator.json'; +export const artifacts = { + Coordinator: Coordinator as ContractArtifact, + MixinCoordinatorApprovalVerifier: MixinCoordinatorApprovalVerifier as ContractArtifact, + MixinCoordinatorCore: MixinCoordinatorCore as ContractArtifact, + MixinSignatureValidator: MixinSignatureValidator as ContractArtifact, + ICoordinatorApprovalVerifier: ICoordinatorApprovalVerifier as ContractArtifact, + ICoordinatorCore: ICoordinatorCore as ContractArtifact, + ICoordinatorSignatureValidator: ICoordinatorSignatureValidator as ContractArtifact, + LibConstants: LibConstants as ContractArtifact, + LibCoordinatorApproval: LibCoordinatorApproval as ContractArtifact, + LibCoordinatorRichErrors: LibCoordinatorRichErrors as ContractArtifact, + LibEIP712CoordinatorDomain: LibEIP712CoordinatorDomain as ContractArtifact, + CoordinatorRegistry: CoordinatorRegistry as ContractArtifact, + MixinCoordinatorRegistryCore: MixinCoordinatorRegistryCore as ContractArtifact, + ICoordinatorRegistryCore: ICoordinatorRegistryCore as ContractArtifact, +}; diff --git a/contracts/coordinator/test/mixins.ts b/contracts/coordinator/test/mixins.ts index 4ee471b797..44238f7adc 100644 --- a/contracts/coordinator/test/mixins.ts +++ b/contracts/coordinator/test/mixins.ts @@ -1,7 +1,8 @@ -import { constants as exchangeConstants, exchangeDataEncoder, ExchangeFunctionName } from '@0x/contracts-exchange'; +import { exchangeDataEncoder } from '@0x/contracts-exchange'; import { blockchainTests, constants, + ExchangeFunctionName, expect, hexConcat, hexSlice, @@ -144,7 +145,7 @@ blockchainTests.resets('Mixins tests', env => { }); describe('decodeOrdersFromFillData', () => { - for (const fnName of exchangeConstants.SINGLE_FILL_FN_NAMES) { + for (const fnName of constants.SINGLE_FILL_FN_NAMES) { it(`should correctly decode the orders for ${fnName} data`, async () => { const orders = [defaultOrder]; const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); @@ -158,7 +159,7 @@ blockchainTests.resets('Mixins tests', env => { expect(orders).to.deep.eq(decodedSignedOrders); }); } - for (const fnName of exchangeConstants.BATCH_FILL_FN_NAMES) { + for (const fnName of constants.BATCH_FILL_FN_NAMES) { it(`should correctly decode the orders for ${fnName} data`, async () => { const orders = [defaultOrder, defaultOrder]; const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); @@ -172,7 +173,7 @@ blockchainTests.resets('Mixins tests', env => { expect(orders).to.deep.eq(decodedSignedOrders); }); } - for (const fnName of exchangeConstants.MARKET_FILL_FN_NAMES) { + for (const fnName of constants.MARKET_FILL_FN_NAMES) { it(`should correctly decode the orders for ${fnName} data`, async () => { const orders = [defaultOrder, defaultOrder]; const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); @@ -186,7 +187,7 @@ blockchainTests.resets('Mixins tests', env => { expect(orders).to.deep.eq(decodedSignedOrders); }); } - for (const fnName of exchangeConstants.MATCH_ORDER_FN_NAMES) { + for (const fnName of constants.MATCH_ORDER_FN_NAMES) { it(`should correctly decode the orders for ${fnName} data`, async () => { const orders = [defaultOrder, defaultOrder]; const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); @@ -200,7 +201,7 @@ blockchainTests.resets('Mixins tests', env => { expect(orders).to.deep.eq(decodedSignedOrders); }); } - for (const fnName of exchangeConstants.CANCEL_ORDER_FN_NAMES) { + for (const fnName of constants.CANCEL_ORDER_FN_NAMES) { it(`should correctly decode the orders for ${fnName} data`, async () => { const orders = [defaultOrder, defaultOrder]; const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); @@ -227,7 +228,7 @@ blockchainTests.resets('Mixins tests', env => { }); describe('Single order approvals', () => { - for (const fnName of exchangeConstants.SINGLE_FILL_FN_NAMES) { + for (const fnName of constants.SINGLE_FILL_FN_NAMES) { it(`Should be successful: function=${fnName}, caller=tx_signer, senderAddress=[verifier], approval_sig=[approver1]`, async () => { const orders = [defaultOrder]; const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); @@ -341,9 +342,9 @@ blockchainTests.resets('Mixins tests', env => { }); describe('Batch order approvals', () => { for (const fnName of [ - ...exchangeConstants.BATCH_FILL_FN_NAMES, - ...exchangeConstants.MARKET_FILL_FN_NAMES, - ...exchangeConstants.MATCH_ORDER_FN_NAMES, + ...constants.BATCH_FILL_FN_NAMES, + ...constants.MARKET_FILL_FN_NAMES, + ...constants.MATCH_ORDER_FN_NAMES, ]) { it(`Should be successful: function=${fnName} caller=tx_signer, senderAddress=[verifier,verifier], feeRecipient=[approver1,approver1], approval_sig=[approver1]`, async () => { const orders = [defaultOrder, defaultOrder]; diff --git a/contracts/coordinator/test/wrappers.ts b/contracts/coordinator/test/wrappers.ts new file mode 100644 index 0000000000..cfc1187fb8 --- /dev/null +++ b/contracts/coordinator/test/wrappers.ts @@ -0,0 +1,19 @@ +/* + * ----------------------------------------------------------------------------- + * Warning: This file is auto-generated by contracts-gen. Don't edit manually. + * ----------------------------------------------------------------------------- + */ +export * from '../test/generated-wrappers/coordinator'; +export * from '../test/generated-wrappers/coordinator_registry'; +export * from '../test/generated-wrappers/i_coordinator_approval_verifier'; +export * from '../test/generated-wrappers/i_coordinator_core'; +export * from '../test/generated-wrappers/i_coordinator_registry_core'; +export * from '../test/generated-wrappers/i_coordinator_signature_validator'; +export * from '../test/generated-wrappers/lib_constants'; +export * from '../test/generated-wrappers/lib_coordinator_approval'; +export * from '../test/generated-wrappers/lib_coordinator_rich_errors'; +export * from '../test/generated-wrappers/lib_e_i_p712_coordinator_domain'; +export * from '../test/generated-wrappers/mixin_coordinator_approval_verifier'; +export * from '../test/generated-wrappers/mixin_coordinator_core'; +export * from '../test/generated-wrappers/mixin_coordinator_registry_core'; +export * from '../test/generated-wrappers/mixin_signature_validator'; diff --git a/contracts/coordinator/tsconfig.json b/contracts/coordinator/tsconfig.json index 8db06e4dd6..665faf907a 100644 --- a/contracts/coordinator/tsconfig.json +++ b/contracts/coordinator/tsconfig.json @@ -16,7 +16,21 @@ "generated-artifacts/MixinCoordinatorApprovalVerifier.json", "generated-artifacts/MixinCoordinatorCore.json", "generated-artifacts/MixinCoordinatorRegistryCore.json", - "generated-artifacts/MixinSignatureValidator.json" + "generated-artifacts/MixinSignatureValidator.json", + "test/generated-artifacts/Coordinator.json", + "test/generated-artifacts/CoordinatorRegistry.json", + "test/generated-artifacts/ICoordinatorApprovalVerifier.json", + "test/generated-artifacts/ICoordinatorCore.json", + "test/generated-artifacts/ICoordinatorRegistryCore.json", + "test/generated-artifacts/ICoordinatorSignatureValidator.json", + "test/generated-artifacts/LibConstants.json", + "test/generated-artifacts/LibCoordinatorApproval.json", + "test/generated-artifacts/LibCoordinatorRichErrors.json", + "test/generated-artifacts/LibEIP712CoordinatorDomain.json", + "test/generated-artifacts/MixinCoordinatorApprovalVerifier.json", + "test/generated-artifacts/MixinCoordinatorCore.json", + "test/generated-artifacts/MixinCoordinatorRegistryCore.json", + "test/generated-artifacts/MixinSignatureValidator.json" ], "exclude": ["./deploy/solc/solc_bin"] } diff --git a/contracts/exchange-forwarder/package.json b/contracts/exchange-forwarder/package.json index 6bb6248672..5b922fe02d 100644 --- a/contracts/exchange-forwarder/package.json +++ b/contracts/exchange-forwarder/package.json @@ -35,7 +35,7 @@ "compile:truffle": "truffle compile" }, "config": { - "abis": "./generated-artifacts/@(Forwarder|IAssets|IForwarder|IForwarderCore|LibConstants|LibForwarderRichErrors|MixinAssets|MixinExchangeWrapper|MixinForwarderCore|MixinWeth).json", + "abis": "./test/generated-artifacts/@(Forwarder|IAssets|IForwarder|IForwarderCore|LibConstants|LibForwarderRichErrors|MixinAssets|MixinExchangeWrapper|MixinForwarderCore|MixinWeth).json", "abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually." }, "repository": { diff --git a/contracts/exchange-forwarder/test/artifacts.ts b/contracts/exchange-forwarder/test/artifacts.ts new file mode 100644 index 0000000000..2e786fdfa4 --- /dev/null +++ b/contracts/exchange-forwarder/test/artifacts.ts @@ -0,0 +1,29 @@ +/* + * ----------------------------------------------------------------------------- + * Warning: This file is auto-generated by contracts-gen. Don't edit manually. + * ----------------------------------------------------------------------------- + */ +import { ContractArtifact } from 'ethereum-types'; + +import * as Forwarder from '../test/generated-artifacts/Forwarder.json'; +import * as IAssets from '../test/generated-artifacts/IAssets.json'; +import * as IForwarder from '../test/generated-artifacts/IForwarder.json'; +import * as IForwarderCore from '../test/generated-artifacts/IForwarderCore.json'; +import * as LibConstants from '../test/generated-artifacts/LibConstants.json'; +import * as LibForwarderRichErrors from '../test/generated-artifacts/LibForwarderRichErrors.json'; +import * as MixinAssets from '../test/generated-artifacts/MixinAssets.json'; +import * as MixinExchangeWrapper from '../test/generated-artifacts/MixinExchangeWrapper.json'; +import * as MixinForwarderCore from '../test/generated-artifacts/MixinForwarderCore.json'; +import * as MixinWeth from '../test/generated-artifacts/MixinWeth.json'; +export const artifacts = { + Forwarder: Forwarder as ContractArtifact, + MixinAssets: MixinAssets as ContractArtifact, + MixinExchangeWrapper: MixinExchangeWrapper as ContractArtifact, + MixinForwarderCore: MixinForwarderCore as ContractArtifact, + MixinWeth: MixinWeth as ContractArtifact, + IAssets: IAssets as ContractArtifact, + IForwarder: IForwarder as ContractArtifact, + IForwarderCore: IForwarderCore as ContractArtifact, + LibConstants: LibConstants as ContractArtifact, + LibForwarderRichErrors: LibForwarderRichErrors as ContractArtifact, +}; diff --git a/contracts/exchange-forwarder/test/wrappers.ts b/contracts/exchange-forwarder/test/wrappers.ts new file mode 100644 index 0000000000..fd8cbc5af8 --- /dev/null +++ b/contracts/exchange-forwarder/test/wrappers.ts @@ -0,0 +1,15 @@ +/* + * ----------------------------------------------------------------------------- + * Warning: This file is auto-generated by contracts-gen. Don't edit manually. + * ----------------------------------------------------------------------------- + */ +export * from '../test/generated-wrappers/forwarder'; +export * from '../test/generated-wrappers/i_assets'; +export * from '../test/generated-wrappers/i_forwarder'; +export * from '../test/generated-wrappers/i_forwarder_core'; +export * from '../test/generated-wrappers/lib_constants'; +export * from '../test/generated-wrappers/lib_forwarder_rich_errors'; +export * from '../test/generated-wrappers/mixin_assets'; +export * from '../test/generated-wrappers/mixin_exchange_wrapper'; +export * from '../test/generated-wrappers/mixin_forwarder_core'; +export * from '../test/generated-wrappers/mixin_weth'; diff --git a/contracts/exchange-forwarder/tsconfig.json b/contracts/exchange-forwarder/tsconfig.json index e5d468a5ce..8f93b0be6d 100644 --- a/contracts/exchange-forwarder/tsconfig.json +++ b/contracts/exchange-forwarder/tsconfig.json @@ -12,7 +12,17 @@ "generated-artifacts/MixinAssets.json", "generated-artifacts/MixinExchangeWrapper.json", "generated-artifacts/MixinForwarderCore.json", - "generated-artifacts/MixinWeth.json" + "generated-artifacts/MixinWeth.json", + "test/generated-artifacts/Forwarder.json", + "test/generated-artifacts/IAssets.json", + "test/generated-artifacts/IForwarder.json", + "test/generated-artifacts/IForwarderCore.json", + "test/generated-artifacts/LibConstants.json", + "test/generated-artifacts/LibForwarderRichErrors.json", + "test/generated-artifacts/MixinAssets.json", + "test/generated-artifacts/MixinExchangeWrapper.json", + "test/generated-artifacts/MixinForwarderCore.json", + "test/generated-artifacts/MixinWeth.json" ], "exclude": ["./deploy/solc/solc_bin"] } diff --git a/contracts/exchange/src/index.ts b/contracts/exchange/src/index.ts index 4b64e3df2b..ddfaf590b9 100644 --- a/contracts/exchange/src/index.ts +++ b/contracts/exchange/src/index.ts @@ -1,5 +1,4 @@ export * from './artifacts'; export * from './wrappers'; export * from '../test/balance_stores'; -export * from '../test/utils'; -export * from './wrapper_interfaces'; +export * from '../test/utils/exchange_data_encoder'; diff --git a/contracts/exchange/test/assertion_wrappers/fill_order_wrapper.ts b/contracts/exchange/test/assertion_wrappers/fill_order_wrapper.ts index 0c6e552f3b..1eba3e296f 100644 --- a/contracts/exchange/test/assertion_wrappers/fill_order_wrapper.ts +++ b/contracts/exchange/test/assertion_wrappers/fill_order_wrapper.ts @@ -17,13 +17,14 @@ import * as _ from 'lodash'; import { BalanceStore, BlockchainBalanceStore, - ExchangeContract, LocalBalanceStore, TokenContractsByName, TokenIds, TokenOwnersByName, } from '../../src'; +import { ExchangeContract } from '../wrappers'; + export class FillOrderWrapper { private readonly _blockchainBalanceStore: BlockchainBalanceStore; diff --git a/contracts/exchange/test/core.ts b/contracts/exchange/test/core.ts index 55da2bd13b..13f26f5eb9 100644 --- a/contracts/exchange/test/core.ts +++ b/contracts/exchange/test/core.ts @@ -41,16 +41,21 @@ import { LogWithDecodedArgs } from 'ethereum-types'; import * as _ from 'lodash'; import { Erc1155Wrapper } from '../../erc1155/lib/src'; + +import { + ExchangeWrapper, + ValidatorWalletAction, +} from './utils'; + import { artifacts, +} from './artifacts'; +import { FillOrderWrapper } from './assertion_wrappers/fill_order_wrapper'; +import { ExchangeCancelEventArgs, ExchangeContract, - ExchangeWrapper, TestValidatorWalletContract, - ValidatorWalletAction, -} from '../src'; - -import { FillOrderWrapper } from './assertion_wrappers/fill_order_wrapper'; +} from './wrappers'; // tslint:disable:no-unnecessary-type-assertion blockchainTests.resets('Exchange core', () => { diff --git a/contracts/exchange/test/dispatcher.ts b/contracts/exchange/test/dispatcher.ts index 067f3e2fac..98fce27860 100644 --- a/contracts/exchange/test/dispatcher.ts +++ b/contracts/exchange/test/dispatcher.ts @@ -24,11 +24,11 @@ import * as chai from 'chai'; import { LogWithDecodedArgs } from 'ethereum-types'; import * as _ from 'lodash'; +import { artifacts } from './artifacts'; import { - artifacts, TestAssetProxyDispatcherAssetProxyRegisteredEventArgs, TestAssetProxyDispatcherContract, -} from '../src'; +} from './wrappers'; import { dependencyArtifacts } from './utils/dependency_artifacts'; diff --git a/contracts/exchange/test/internal.ts b/contracts/exchange/test/internal.ts index 9713714774..897662a2ad 100644 --- a/contracts/exchange/test/internal.ts +++ b/contracts/exchange/test/internal.ts @@ -7,12 +7,12 @@ import { Web3Wrapper } from '@0x/web3-wrapper'; import { LogWithDecodedArgs } from 'ethereum-types'; import * as _ from 'lodash'; +import { artifacts } from './artifacts'; import { - artifacts, TestExchangeInternalsContract, TestExchangeInternalsDispatchTransferFromCalledEventArgs, TestExchangeInternalsFillEventArgs, -} from '../src'; +} from './wrappers'; blockchainTests('Exchange core internal functions', env => { const CHAIN_ID = 1337; diff --git a/contracts/exchange/test/lib_exchange_rich_error_decoder.ts b/contracts/exchange/test/lib_exchange_rich_error_decoder.ts index f0c85b5394..400fb4890b 100644 --- a/contracts/exchange/test/lib_exchange_rich_error_decoder.ts +++ b/contracts/exchange/test/lib_exchange_rich_error_decoder.ts @@ -11,7 +11,8 @@ import { ExchangeRevertErrors, generatePseudoRandomSalt } from '@0x/order-utils' import { BigNumber, RevertError } from '@0x/utils'; import * as _ from 'lodash'; -import { artifacts, TestLibExchangeRichErrorDecoderContract } from '../src'; +import { artifacts } from './artifacts'; +import { TestLibExchangeRichErrorDecoderContract } from './wrappers'; blockchainTests.resets('LibExchangeRichErrorDecoder', ({ provider, txDefaults }) => { const ASSET_PROXY_ID_LENGTH = 4; diff --git a/contracts/exchange/test/match_orders.ts b/contracts/exchange/test/match_orders.ts index e05aad4316..7d602af50e 100644 --- a/contracts/exchange/test/match_orders.ts +++ b/contracts/exchange/test/match_orders.ts @@ -30,7 +30,12 @@ import { Web3Wrapper } from '@0x/web3-wrapper'; import * as chai from 'chai'; import * as _ from 'lodash'; -import { artifacts, ExchangeContract, ExchangeWrapper } from '../src'; +import { ExchangeWrapper } from './utils/exchange_wrapper'; + +import { artifacts } from './artifacts'; +import { + ExchangeContract, +} from './wrappers'; import { MatchOrderTester, TokenBalances } from './utils/match_order_tester'; diff --git a/contracts/exchange/test/protocol_fees.ts b/contracts/exchange/test/protocol_fees.ts index 5cba8686ff..abb6fc4f8a 100644 --- a/contracts/exchange/test/protocol_fees.ts +++ b/contracts/exchange/test/protocol_fees.ts @@ -1,7 +1,8 @@ import { blockchainTests } from '@0x/contracts-test-utils'; import { BigNumber } from '@0x/utils'; -import { artifacts, TestProtocolFeesContract, TestProtocolFeesReceiverContract } from '../src'; +import { artifacts } from './artifacts'; +import { TestProtocolFeesContract, TestProtocolFeesReceiverContract} from './wrappers'; // The contents of this test suite does not inform the reader about the assertions made in these // tests. For more information and a more accurate view of the tests, check out diff --git a/contracts/exchange/test/protocol_fees_manager.ts b/contracts/exchange/test/protocol_fees_manager.ts index 010fe122c6..480b1d9de0 100644 --- a/contracts/exchange/test/protocol_fees_manager.ts +++ b/contracts/exchange/test/protocol_fees_manager.ts @@ -2,12 +2,12 @@ import { blockchainTests, constants, expect } from '@0x/contracts-test-utils'; import { BigNumber, OwnableRevertErrors } from '@0x/utils'; import { LogWithDecodedArgs } from 'ethereum-types'; +import { artifacts } from './artifacts'; import { - artifacts, ExchangeContract, ExchangeProtocolFeeCollectorAddressEventArgs, ExchangeProtocolFeeMultiplierEventArgs, -} from '../src'; +} from './wrappers'; blockchainTests.resets('MixinProtocolFees', env => { let accounts: string[]; diff --git a/contracts/exchange/test/reentrancy_tests.ts b/contracts/exchange/test/reentrancy_tests.ts index 593c8285f2..5f76f3d91a 100644 --- a/contracts/exchange/test/reentrancy_tests.ts +++ b/contracts/exchange/test/reentrancy_tests.ts @@ -3,7 +3,8 @@ import { BigNumber } from '@0x/utils'; import { DataItem, MethodAbi, TupleDataItem } from 'ethereum-types'; import * as _ from 'lodash'; -import { artifacts, ReentrancyTesterContract } from '../src'; +import { artifacts } from './artifacts'; +import { ReentrancyTesterContract} from './wrappers'; import { constants as TestConstants } from './utils/constants'; diff --git a/contracts/exchange/test/signature_validator.ts b/contracts/exchange/test/signature_validator.ts index 33aec898fb..c15b7645b7 100644 --- a/contracts/exchange/test/signature_validator.ts +++ b/contracts/exchange/test/signature_validator.ts @@ -17,13 +17,13 @@ import { BigNumber, StringRevertError } from '@0x/utils'; import { LogWithDecodedArgs } from 'ethereum-types'; import ethUtil = require('ethereumjs-util'); +import { artifacts } from './artifacts'; import { - artifacts, IEIP1271DataContract, TestSignatureValidatorContract, TestSignatureValidatorSignatureValidatorApprovalEventArgs, TestValidatorWalletContract, -} from '../src'; +} from './wrappers'; import { ValidatorWalletAction } from './utils'; diff --git a/contracts/exchange/test/transactions.ts b/contracts/exchange/test/transactions.ts index 00e932dbe6..5101e2e229 100644 --- a/contracts/exchange/test/transactions.ts +++ b/contracts/exchange/test/transactions.ts @@ -6,6 +6,7 @@ import { blockchainTests, constants, describe, + ExchangeFunctionName, expect, getLatestBlockTimestampAsync, OrderFactory, @@ -18,19 +19,16 @@ import { LogWithDecodedArgs, MethodAbi } from 'ethereum-types'; import * as ethUtil from 'ethereumjs-util'; import * as _ from 'lodash'; +import { artifacts as localArtifacts } from './artifacts'; +import { exchangeDataEncoder, ExchangeWrapper } from './utils'; import { - artifacts as localArtifacts, - constants as exchangeConstants, ExchangeCancelEventArgs, ExchangeCancelUpToEventArgs, ExchangeContract, - exchangeDataEncoder, ExchangeFillEventArgs, - ExchangeFunctionName, ExchangeSignatureValidatorApprovalEventArgs, ExchangeTransactionExecutionEventArgs, - ExchangeWrapper, -} from '../src/'; +} from './wrappers'; const artifacts = { ...erc20Artifacts, ...localArtifacts }; @@ -210,9 +208,9 @@ blockchainTests.resets('Exchange transactions', env => { }); describe('fill methods', () => { for (const fnName of [ - ...exchangeConstants.SINGLE_FILL_FN_NAMES, - ...exchangeConstants.BATCH_FILL_FN_NAMES, - ...exchangeConstants.MARKET_FILL_FN_NAMES, + ...constants.SINGLE_FILL_FN_NAMES, + ...constants.BATCH_FILL_FN_NAMES, + ...constants.MARKET_FILL_FN_NAMES, ]) { it(`${fnName} should revert if signature is invalid and not called by signer`, async () => { const orders = [await orderFactory.newSignedOrderAsync()]; @@ -301,7 +299,7 @@ blockchainTests.resets('Exchange transactions', env => { const decodedReturnData = abiEncoder.decodeReturnValues(returnData); const fillResults = - exchangeConstants.BATCH_FILL_FN_NAMES.indexOf(fnName) !== -1 + constants.BATCH_FILL_FN_NAMES.indexOf(fnName) !== -1 ? decodedReturnData.fillResults[0] : decodedReturnData.fillResults; diff --git a/contracts/exchange/test/transactions_unit_tests.ts b/contracts/exchange/test/transactions_unit_tests.ts index 257bbf798d..2f36606c4f 100644 --- a/contracts/exchange/test/transactions_unit_tests.ts +++ b/contracts/exchange/test/transactions_unit_tests.ts @@ -5,7 +5,11 @@ import { BigNumber, StringRevertError } from '@0x/utils'; import { LogWithDecodedArgs } from 'ethereum-types'; import * as _ from 'lodash'; -import { artifacts, TestTransactionsContract, TestTransactionsTransactionExecutionEventArgs } from '../src'; +import { artifacts } from './artifacts'; +import { + TestTransactionsContract, + TestTransactionsTransactionExecutionEventArgs, +} from './wrappers'; blockchainTests.resets('Transaction Unit Tests', ({ provider, web3Wrapper, txDefaults }) => { let transactionsContract: TestTransactionsContract; diff --git a/contracts/exchange/test/utils/constants.ts b/contracts/exchange/test/utils/constants.ts index d34001dc22..cee5450e2a 100644 --- a/contracts/exchange/test/utils/constants.ts +++ b/contracts/exchange/test/utils/constants.ts @@ -1,4 +1,4 @@ -import { ExchangeFunctionName } from './types'; +import { ExchangeFunctionName } from '@0x/contracts-test-utils'; export const constants = { // These are functions not secured by the `nonReentrant`, directly or @@ -13,28 +13,6 @@ export const constants = { ExchangeFunctionName.SetProtocolFeeCollectorAddress, ExchangeFunctionName.DetachProtocolFeeCollector, ], - SINGLE_FILL_FN_NAMES: [ExchangeFunctionName.FillOrder, ExchangeFunctionName.FillOrKillOrder], - BATCH_FILL_FN_NAMES: [ - ExchangeFunctionName.BatchFillOrders, - ExchangeFunctionName.BatchFillOrKillOrders, - ExchangeFunctionName.BatchFillOrdersNoThrow, - ], - MARKET_FILL_FN_NAMES: [ - ExchangeFunctionName.MarketBuyOrdersFillOrKill, - ExchangeFunctionName.MarketSellOrdersFillOrKill, - ExchangeFunctionName.MarketBuyOrdersNoThrow, - ExchangeFunctionName.MarketSellOrdersNoThrow, - ], - MATCH_ORDER_FN_NAMES: [ExchangeFunctionName.MatchOrders, ExchangeFunctionName.MatchOrdersWithMaximalFill], - BATCH_MATCH_ORDER_FN_NAMES: [ - ExchangeFunctionName.BatchMatchOrders, - ExchangeFunctionName.BatchMatchOrdersWithMaximalFill, - ], - CANCEL_ORDER_FN_NAMES: [ - ExchangeFunctionName.CancelOrder, - ExchangeFunctionName.BatchCancelOrders, - ExchangeFunctionName.CancelOrdersUpTo, - ], }; export enum ValidatorWalletAction { diff --git a/contracts/exchange/test/utils/exchange_data_encoder.ts b/contracts/exchange/test/utils/exchange_data_encoder.ts index 5b7e383d08..8d8f60f52c 100644 --- a/contracts/exchange/test/utils/exchange_data_encoder.ts +++ b/contracts/exchange/test/utils/exchange_data_encoder.ts @@ -1,33 +1,33 @@ -import { constants, provider } from '@0x/contracts-test-utils'; +import { constants, ExchangeFunctionName, provider } from '@0x/contracts-test-utils'; import { orderHashUtils } from '@0x/order-utils'; import { SignedOrder } from '@0x/types'; -import { constants as exchangeConstants, ExchangeFunctionName, IExchangeContract } from '../../src'; +import { IExchangeContract } from '../wrappers'; export const exchangeDataEncoder = { encodeOrdersToExchangeData(fnName: ExchangeFunctionName, orders: SignedOrder[] = []): string { const exchangeInstance = new IExchangeContract(constants.NULL_ADDRESS, provider); let data; - if (exchangeConstants.SINGLE_FILL_FN_NAMES.indexOf(fnName) !== -1) { + if (constants.SINGLE_FILL_FN_NAMES.indexOf(fnName) !== -1) { data = (exchangeInstance as any)[fnName].getABIEncodedTransactionData( orders[0], orders[0].takerAssetAmount, orders[0].signature, ); - } else if (exchangeConstants.BATCH_FILL_FN_NAMES.indexOf(fnName) !== -1) { + } else if (constants.BATCH_FILL_FN_NAMES.indexOf(fnName) !== -1) { data = (exchangeInstance as any)[fnName].getABIEncodedTransactionData( orders, orders.map(order => order.takerAssetAmount), orders.map(order => order.signature), ); - } else if (exchangeConstants.MARKET_FILL_FN_NAMES.indexOf(fnName) !== -1) { + } else if (constants.MARKET_FILL_FN_NAMES.indexOf(fnName) !== -1) { const fillAsset = /Buy/.test(fnName) ? 'makerAssetAmount' : 'takerAssetAmount'; data = (exchangeInstance as any)[fnName].getABIEncodedTransactionData( orders, orders.map(order => order[fillAsset]).reduce((prev, curr) => prev.plus(curr)), orders.map(order => order.signature), ); - } else if (exchangeConstants.MATCH_ORDER_FN_NAMES.indexOf(fnName) !== -1) { + } else if (constants.MATCH_ORDER_FN_NAMES.indexOf(fnName) !== -1) { data = exchangeInstance.matchOrders.getABIEncodedTransactionData( orders[0], orders[1], diff --git a/contracts/exchange/test/utils/exchange_wrapper.ts b/contracts/exchange/test/utils/exchange_wrapper.ts index dead507440..615467c431 100644 --- a/contracts/exchange/test/utils/exchange_wrapper.ts +++ b/contracts/exchange/test/utils/exchange_wrapper.ts @@ -11,7 +11,7 @@ import { AbiEncoder, BigNumber } from '@0x/utils'; import { MethodAbi, TransactionReceiptWithDecodedLogs } from 'ethereum-types'; import * as _ from 'lodash'; -import { ExchangeContract } from '../../src'; +import { ExchangeContract } from '../wrappers'; import { AbiDecodedFillOrderData } from './types'; diff --git a/contracts/exchange/test/utils/fill_order_combinatorial_utils.ts b/contracts/exchange/test/utils/fill_order_combinatorial_utils.ts index 006088efea..3c6f80697e 100644 --- a/contracts/exchange/test/utils/fill_order_combinatorial_utils.ts +++ b/contracts/exchange/test/utils/fill_order_combinatorial_utils.ts @@ -15,7 +15,9 @@ import { LogWithDecodedArgs, TxData } from 'ethereum-types'; import * as _ from 'lodash'; import 'make-promises-safe'; -import { artifacts, ExchangeContract, ExchangeFillEventArgs } from '../../src'; +import { artifacts } from '../artifacts'; + +import { ExchangeContract, ExchangeFillEventArgs } from '../wrappers'; import { AssetWrapper } from './asset_wrapper'; import { ExchangeWrapper } from './exchange_wrapper'; diff --git a/contracts/exchange/test/utils/isolated_exchange_wrapper.ts b/contracts/exchange/test/utils/isolated_exchange_wrapper.ts index 0d6f948068..c50dd1da80 100644 --- a/contracts/exchange/test/utils/isolated_exchange_wrapper.ts +++ b/contracts/exchange/test/utils/isolated_exchange_wrapper.ts @@ -12,12 +12,13 @@ import { TxData, Web3Wrapper } from '@0x/web3-wrapper'; import * as crypto from 'crypto'; import { LogEntry } from 'ethereum-types'; +import { artifacts } from '../artifacts'; + import { - artifacts, IsolatedExchangeContract, IsolatedExchangeDispatchTransferFromCalledEventArgs as DispatchTransferFromCallArgs, IsolatedExchangeFillEventArgs as FillEventArgs, -} from '../../src'; + } from '../wrappers'; export interface AssetBalances { [assetData: string]: { [address: string]: BigNumber }; diff --git a/contracts/exchange/test/utils/types.ts b/contracts/exchange/test/utils/types.ts index 943232a210..8cd6df9377 100644 --- a/contracts/exchange/test/utils/types.ts +++ b/contracts/exchange/test/utils/types.ts @@ -36,3 +36,13 @@ export enum ExchangeFunctionName { SetProtocolFeeCollectorAddress = 'setProtocolFeeCollectorAddress', DetachProtocolFeeCollector = 'detachProtocolFeeCollector', } + +export enum TradeSide { + Maker = 'maker', + Taker = 'taker', +} + +export enum TransferType { + Trade = 'trade', + Fee = 'fee', +} diff --git a/contracts/exchange/test/wrapper_unit_tests.ts b/contracts/exchange/test/wrapper_unit_tests.ts index 13ae715025..3d903edca5 100644 --- a/contracts/exchange/test/wrapper_unit_tests.ts +++ b/contracts/exchange/test/wrapper_unit_tests.ts @@ -16,12 +16,12 @@ import { LogEntry, LogWithDecodedArgs } from 'ethereum-types'; import * as ethjs from 'ethereumjs-util'; import * as _ from 'lodash'; +import { artifacts } from './artifacts'; import { - artifacts, TestWrapperFunctionsCancelOrderCalledEventArgs as CancelOrderCalledEventArgs, TestWrapperFunctionsContract, TestWrapperFunctionsFillOrderCalledEventArgs as FillOrderCalledEventArgs, -} from '../src'; +} from './wrappers'; blockchainTests('Exchange wrapper functions unit tests.', env => { const CHAIN_ID = 0x74657374; diff --git a/contracts/extensions/package.json b/contracts/extensions/package.json index c76ba61685..9610803c9a 100644 --- a/contracts/extensions/package.json +++ b/contracts/extensions/package.json @@ -77,7 +77,6 @@ "@0x/contracts-dev-utils": "^0.1.0-beta.1", "@0x/contracts-erc20": "^2.3.0-beta.1", "@0x/contracts-erc721": "^2.2.0-beta.1", - "@0x/contracts-exchange": "^2.2.0-beta.1", "@0x/contracts-exchange-libs": "^3.1.0-beta.1", "@0x/contracts-utils": "^3.3.0-beta.1", "@0x/order-utils": "^8.5.0-beta.1", diff --git a/contracts/extensions/test/balance_threshold_filter.ts b/contracts/extensions/test/balance_threshold_filter.ts index 7fe4ee5566..2ca02c6e3e 100644 --- a/contracts/extensions/test/balance_threshold_filter.ts +++ b/contracts/extensions/test/balance_threshold_filter.ts @@ -1,5 +1,5 @@ import { DevUtilsContract } from '@0x/contracts-dev-utils'; -import { ExchangeContract, ExchangeWrapper } from '@0x/contracts-exchange'; +import { ExchangeContract } from '@0x/contracts-exchange'; import { BlockchainLifecycle } from '@0x/dev-utils'; import { ExchangeRevertErrors } from '@0x/order-utils'; import { Order, RevertReason, SignedOrder } from '@0x/types'; @@ -52,7 +52,6 @@ describe(ContractName.BalanceThresholdFilter, () => { let zrxAssetData: string; let zrxToken: DummyERC20TokenContract; let exchangeInstance: ExchangeContract; - let exchangeWrapper: ExchangeWrapper; let devUtils: DevUtilsContract; let orderFactory: OrderFactory; @@ -139,9 +138,13 @@ describe(ContractName.BalanceThresholdFilter, () => { zrxAssetData, new BigNumber(chainId), ); - exchangeWrapper = new ExchangeWrapper(exchangeInstance); // Register proxies - await exchangeWrapper.registerAssetProxyAsync(erc20Proxy.address, owner); + await exchangeInstance.registerAssetProxy.awaitTransactionSuccessAsync( + erc20Proxy.address, + { + from: owner, + }, + ); await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(exchangeInstance.address, { from: owner, }); diff --git a/contracts/extensions/test/dutch_auction.ts b/contracts/extensions/test/dutch_auction.ts index c7cfab18ab..25b563642a 100644 --- a/contracts/extensions/test/dutch_auction.ts +++ b/contracts/extensions/test/dutch_auction.ts @@ -2,7 +2,7 @@ import { ERC20Wrapper, ERC721Wrapper } from '@0x/contracts-asset-proxy'; import { DevUtilsContract } from '@0x/contracts-dev-utils'; import { DummyERC20TokenContract } from '@0x/contracts-erc20'; import { DummyERC721TokenContract } from '@0x/contracts-erc721'; -import { ExchangeContract, ExchangeWrapper } from '@0x/contracts-exchange'; +import { ExchangeContract } from '@0x/contracts-exchange'; import { chaiSetup, constants, @@ -98,9 +98,18 @@ describe(ContractName.DutchAuction, () => { zrxAssetData, new BigNumber(chainId), ); - const exchangeWrapper = new ExchangeWrapper(exchangeInstance); - await exchangeWrapper.registerAssetProxyAsync(erc20Proxy.address, owner); - await exchangeWrapper.registerAssetProxyAsync(erc721Proxy.address, owner); + await exchangeInstance.registerAssetProxy.awaitTransactionSuccessAsync( + erc20Proxy.address, + { + from: owner, + }, + ); + await exchangeInstance.registerAssetProxy.awaitTransactionSuccessAsync( + erc721Proxy.address, + { + from: owner, + }, + ); await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(exchangeInstance.address, { from: owner, diff --git a/contracts/extensions/test/order_matcher.ts b/contracts/extensions/test/order_matcher.ts index bd85592601..8ddf7519fd 100644 --- a/contracts/extensions/test/order_matcher.ts +++ b/contracts/extensions/test/order_matcher.ts @@ -7,7 +7,7 @@ import { import { DevUtilsContract } from '@0x/contracts-dev-utils'; import { DummyERC20TokenContract } from '@0x/contracts-erc20'; import { artifacts as erc721Artifacts, DummyERC721TokenContract } from '@0x/contracts-erc721'; -import { ExchangeContract, ExchangeWrapper } from '@0x/contracts-exchange'; +import { ExchangeContract } from '@0x/contracts-exchange'; import { chaiSetup, constants, @@ -15,6 +15,7 @@ import { expectContractCreationFailedAsync, LogDecoder, OrderFactory, + orderUtils, provider, sendTransactionResult, txDefaults, @@ -53,7 +54,6 @@ describe('OrderMatcher', () => { let orderMatcher: OrderMatcherContract; let erc20BalancesByOwner: ERC20BalancesByOwner; - let exchangeWrapper: ExchangeWrapper; let erc20Wrapper: ERC20Wrapper; let orderFactoryLeft: OrderFactory; let orderFactoryRight: OrderFactory; @@ -117,10 +117,18 @@ describe('OrderMatcher', () => { await devUtils.encodeERC20AssetData.callAsync(zrxToken.address), new BigNumber(chainId), ); - exchangeWrapper = new ExchangeWrapper(exchange); - await exchangeWrapper.registerAssetProxyAsync(erc20Proxy.address, owner); - await exchangeWrapper.registerAssetProxyAsync(erc721Proxy.address, owner); - // Authorize ERC20 trades by exchange + await exchange.registerAssetProxy.awaitTransactionSuccessAsync( + erc20Proxy.address, + { + from: owner, + }, + ); + await exchange.registerAssetProxy.awaitTransactionSuccessAsync( + erc721Proxy.address, + { + from: owner, + }, + ); // Authorize ERC20 trades by exchange await web3Wrapper.awaitTransactionSuccessAsync( await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, { from: owner, @@ -486,12 +494,20 @@ describe('OrderMatcher', () => { makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18), takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(2), 18), }); - await exchangeWrapper.fillOrderAsync(signedOrderLeft, takerAddress, { - takerAssetFillAmount: signedOrderLeft.takerAssetAmount.dividedToIntegerBy(5), - }); - await exchangeWrapper.fillOrderAsync(signedOrderRight, takerAddress, { - takerAssetFillAmount: signedOrderRight.takerAssetAmount.dividedToIntegerBy(5), - }); + let params = orderUtils.createFill(signedOrderLeft, signedOrderLeft.takerAssetAmount.dividedToIntegerBy(5)); + await exchange.fillOrder.awaitTransactionSuccessAsync( + params.order, + params.takerAssetFillAmount, + params.signature, + { from: takerAddress }, + ); + params = orderUtils.createFill(signedOrderRight, signedOrderRight.takerAssetAmount.dividedToIntegerBy(5)); + await exchange.fillOrder.awaitTransactionSuccessAsync( + params.order, + params.takerAssetFillAmount, + params.signature, + { from: takerAddress }, + ); const data = exchange.matchOrders.getABIEncodedTransactionData( signedOrderLeft, signedOrderRight, diff --git a/contracts/integrations/package.json b/contracts/integrations/package.json index 9aa7f28a1b..09e02c289a 100644 --- a/contracts/integrations/package.json +++ b/contracts/integrations/package.json @@ -22,7 +22,7 @@ "compile": "sol-compiler", "watch": "sol-compiler -w", "clean": "shx rm -rf lib test/generated-artifacts test/generated-wrappers generated-artifacts generated-wrappers", - "generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --output generated-wrappers --backend ethers", + "generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --output test/generated-wrappers --backend ethers", "lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./test/generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude ./test/generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", "fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./test/generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude ./test/generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", "coverage:report:text": "istanbul report text", @@ -36,7 +36,7 @@ "compile:truffle": "truffle compile" }, "config": { - "abis": "./generated-artifacts/@(TestFramework).json", + "abis": "./test/generated-artifacts/@(TestFramework).json", "abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually." }, "repository": { diff --git a/contracts/integrations/test/actors/utils.ts b/contracts/integrations/test/actors/utils.ts index 9311e170b6..2164cbeec6 100644 --- a/contracts/integrations/test/actors/utils.ts +++ b/contracts/integrations/test/actors/utils.ts @@ -1,4 +1,4 @@ -import { TokenOwnersByName } from '@0x/contracts-exchange'; +import { ObjectMap } from '@0x/types'; import * as _ from 'lodash'; import { Actor } from './base'; @@ -7,6 +7,6 @@ import { Actor } from './base'; * Utility function to convert Actors into an object mapping readable names to addresses. * Useful for BalanceStore. */ -export function actorAddressesByName(actors: Actor[]): TokenOwnersByName { +export function actorAddressesByName(actors: Actor[]): ObjectMap { return _.zipObject(actors.map(actor => actor.name), actors.map(actor => actor.address)); } diff --git a/contracts/integrations/test/artifacts.ts b/contracts/integrations/test/artifacts.ts new file mode 100644 index 0000000000..8ea0d872cf --- /dev/null +++ b/contracts/integrations/test/artifacts.ts @@ -0,0 +1,9 @@ +/* + * ----------------------------------------------------------------------------- + * Warning: This file is auto-generated by contracts-gen. Don't edit manually. + * ----------------------------------------------------------------------------- + */ +import { ContractArtifact } from 'ethereum-types'; + +import * as TestFramework from '../test/generated-artifacts/TestFramework.json'; +export const artifacts = { TestFramework: TestFramework as ContractArtifact }; diff --git a/contracts/integrations/test/coordinator/coordinator_test.ts b/contracts/integrations/test/coordinator/coordinator_test.ts index d953739a3f..54141a680e 100644 --- a/contracts/integrations/test/coordinator/coordinator_test.ts +++ b/contracts/integrations/test/coordinator/coordinator_test.ts @@ -2,18 +2,17 @@ import { CoordinatorContract, SignedCoordinatorApproval } from '@0x/contracts-co import { DevUtilsContract } from '@0x/contracts-dev-utils'; import { BlockchainBalanceStore, - constants as exchangeConstants, ExchangeCancelEventArgs, ExchangeCancelUpToEventArgs, exchangeDataEncoder, ExchangeEvents, ExchangeFillEventArgs, - ExchangeFunctionName, LocalBalanceStore, } from '@0x/contracts-exchange'; import { blockchainTests, constants, + ExchangeFunctionName, expect, hexConcat, hexSlice, @@ -174,7 +173,7 @@ blockchainTests.resets('Coordinator integration tests', env => { let transaction: SignedZeroExTransaction; let approval: SignedCoordinatorApproval; - for (const fnName of exchangeConstants.SINGLE_FILL_FN_NAMES) { + for (const fnName of constants.SINGLE_FILL_FN_NAMES) { before(async () => { order = await maker.signOrderAsync(); data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, [order]); @@ -321,7 +320,7 @@ blockchainTests.resets('Coordinator integration tests', env => { let transaction: SignedZeroExTransaction; let approval: SignedCoordinatorApproval; - for (const fnName of [...exchangeConstants.MARKET_FILL_FN_NAMES, ...exchangeConstants.BATCH_FILL_FN_NAMES]) { + for (const fnName of [...constants.MARKET_FILL_FN_NAMES, ...constants.BATCH_FILL_FN_NAMES]) { before(async () => { orders = [await maker.signOrderAsync(), await maker.signOrderAsync()]; data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders); diff --git a/contracts/integrations/test/framework-unit-tests/deployment_manager_test.ts b/contracts/integrations/test/framework-unit-tests/deployment_manager_test.ts index 7cc4a15424..c94a6ab557 100644 --- a/contracts/integrations/test/framework-unit-tests/deployment_manager_test.ts +++ b/contracts/integrations/test/framework-unit-tests/deployment_manager_test.ts @@ -1,8 +1,8 @@ -import { Authorizable, Ownable } from '@0x/contracts-exchange'; import { constants as stakingConstants } from '@0x/contracts-staking'; import { blockchainTests, expect } from '@0x/contracts-test-utils'; import { DeploymentManager } from '../utils/deployment_manager'; +import { Authorizable, Ownable } from '../utils/wrapper_interfaces'; blockchainTests('Deployment Manager', env => { let owner: string; diff --git a/contracts/integrations/test/internal-integration-tests/deployment_test.ts b/contracts/integrations/test/internal-integration-tests/deployment_test.ts index d6e49e0e09..2cf46eb373 100644 --- a/contracts/integrations/test/internal-integration-tests/deployment_test.ts +++ b/contracts/integrations/test/internal-integration-tests/deployment_test.ts @@ -8,14 +8,11 @@ import { } from '@0x/contracts-asset-proxy'; import { artifacts as exchangeArtifacts, - AssetProxyDispatcher, - Authorizable, ExchangeAssetProxyRegisteredEventArgs, ExchangeContract, ExchangeEvents, ExchangeProtocolFeeCollectorAddressEventArgs, ExchangeProtocolFeeMultiplierEventArgs, - Ownable, } from '@0x/contracts-exchange'; import { artifacts as multisigArtifacts, ZeroExGovernorContract } from '@0x/contracts-multisig'; import { @@ -36,6 +33,8 @@ import { AssetProxyId } from '@0x/types'; import { BigNumber } from '@0x/utils'; import { TxData } from 'ethereum-types'; +import { AssetProxyDispatcher, Authorizable, Ownable } from '../utils/wrapper_interfaces'; + // tslint:disable:no-unnecessary-type-assertion blockchainTests('Deployment and Configuration End to End Tests', env => { // Available Addresses diff --git a/contracts/integrations/test/internal-integration-tests/fillorder_test.ts b/contracts/integrations/test/internal-integration-tests/fillorder_test.ts index 16f532f609..db1e40cf75 100644 --- a/contracts/integrations/test/internal-integration-tests/fillorder_test.ts +++ b/contracts/integrations/test/internal-integration-tests/fillorder_test.ts @@ -2,8 +2,8 @@ import { DevUtilsContract } from '@0x/contracts-dev-utils'; import { IERC20TokenEvents, IERC20TokenTransferEventArgs } from '@0x/contracts-erc20'; import { BlockchainBalanceStore, - IExchangeEvents, - IExchangeFillEventArgs, + ExchangeEvents, + ExchangeFillEventArgs, LocalBalanceStore, } from '@0x/contracts-exchange'; import { @@ -142,7 +142,7 @@ blockchainTests.resets('fillOrder integration tests', env => { function verifyFillEvents(order: SignedOrder, receipt: TransactionReceiptWithDecodedLogs): void { // Ensure that the fill event was correct. - verifyEvents( + verifyEvents( receipt, [ { @@ -162,7 +162,7 @@ blockchainTests.resets('fillOrder integration tests', env => { protocolFeePaid: DeploymentManager.protocolFee, }, ], - IExchangeEvents.Fill, + ExchangeEvents.Fill, ); // Ensure that the transfer events were correctly emitted. diff --git a/contracts/integrations/test/utils/deployment_manager.ts b/contracts/integrations/test/utils/deployment_manager.ts index b67008cbf1..7695f0c8af 100644 --- a/contracts/integrations/test/utils/deployment_manager.ts +++ b/contracts/integrations/test/utils/deployment_manager.ts @@ -9,13 +9,7 @@ import { import { artifacts as ERC1155Artifacts, ERC1155MintableContract } from '@0x/contracts-erc1155'; import { artifacts as ERC20Artifacts, DummyERC20TokenContract, WETH9Contract } from '@0x/contracts-erc20'; import { artifacts as ERC721Artifacts, DummyERC721TokenContract } from '@0x/contracts-erc721'; -import { - artifacts as exchangeArtifacts, - AssetProxyDispatcher, - Authorizable, - ExchangeContract, - Ownable, -} from '@0x/contracts-exchange'; +import { artifacts as exchangeArtifacts, ExchangeContract } from '@0x/contracts-exchange'; import { artifacts as multisigArtifacts, ZeroExGovernorContract } from '@0x/contracts-multisig'; import { artifacts as stakingArtifacts, @@ -28,6 +22,8 @@ import { BigNumber } from '@0x/utils'; import { TxData } from 'ethereum-types'; import * as _ from 'lodash'; +import { AssetProxyDispatcher, Authorizable, Ownable } from './wrapper_interfaces'; + /** * Adds a batch of authorities to a list of authorizable contracts. * @param owner The owner of the authorizable contracts. diff --git a/contracts/exchange/src/wrapper_interfaces.ts b/contracts/integrations/test/utils/wrapper_interfaces.ts similarity index 100% rename from contracts/exchange/src/wrapper_interfaces.ts rename to contracts/integrations/test/utils/wrapper_interfaces.ts diff --git a/contracts/integrations/test/wrappers.ts b/contracts/integrations/test/wrappers.ts new file mode 100644 index 0000000000..74a642fc95 --- /dev/null +++ b/contracts/integrations/test/wrappers.ts @@ -0,0 +1,6 @@ +/* + * ----------------------------------------------------------------------------- + * Warning: This file is auto-generated by contracts-gen. Don't edit manually. + * ----------------------------------------------------------------------------- + */ +export * from '../test/generated-wrappers/test_framework'; diff --git a/contracts/integrations/tsconfig.json b/contracts/integrations/tsconfig.json index 7f0aa6948a..18b5c60dac 100644 --- a/contracts/integrations/tsconfig.json +++ b/contracts/integrations/tsconfig.json @@ -2,5 +2,5 @@ "extends": "../../tsconfig", "compilerOptions": { "outDir": "lib", "rootDir": ".", "resolveJsonModule": true }, "include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*"], - "files": ["generated-artifacts/TestFramework.json"] + "files": ["generated-artifacts/TestFramework.json", "test/generated-artifacts/TestFramework.json"] } diff --git a/contracts/test-utils/src/constants.ts b/contracts/test-utils/src/constants.ts index eb93afbcf7..b71b8a4ca5 100644 --- a/contracts/test-utils/src/constants.ts +++ b/contracts/test-utils/src/constants.ts @@ -3,6 +3,8 @@ import { Web3Wrapper } from '@0x/web3-wrapper'; import * as ethUtil from 'ethereumjs-util'; import * as _ from 'lodash'; +import { ExchangeFunctionName } from './types'; + const TESTRPC_PRIVATE_KEYS_STRINGS = [ '0xf2f48ee19680706196e2e339e5da3491186e0c4c5030670656b0e0164837257d', '0x5d862464fe9303452126c8bc94274b8c5f9874cbd219789b3eb2128075a76f72', @@ -84,4 +86,26 @@ export const constants = { PPM_DENOMINATOR: 1e6, PPM_100_PERCENT: 1e6, MAX_CODE_SIZE: 24576, + SINGLE_FILL_FN_NAMES: [ExchangeFunctionName.FillOrder, ExchangeFunctionName.FillOrKillOrder], + BATCH_FILL_FN_NAMES: [ + ExchangeFunctionName.BatchFillOrders, + ExchangeFunctionName.BatchFillOrKillOrders, + ExchangeFunctionName.BatchFillOrdersNoThrow, + ], + MARKET_FILL_FN_NAMES: [ + ExchangeFunctionName.MarketBuyOrdersFillOrKill, + ExchangeFunctionName.MarketSellOrdersFillOrKill, + ExchangeFunctionName.MarketBuyOrdersNoThrow, + ExchangeFunctionName.MarketSellOrdersNoThrow, + ], + MATCH_ORDER_FN_NAMES: [ExchangeFunctionName.MatchOrders, ExchangeFunctionName.MatchOrdersWithMaximalFill], + BATCH_MATCH_ORDER_FN_NAMES: [ + ExchangeFunctionName.BatchMatchOrders, + ExchangeFunctionName.BatchMatchOrdersWithMaximalFill, + ], + CANCEL_ORDER_FN_NAMES: [ + ExchangeFunctionName.CancelOrder, + ExchangeFunctionName.BatchCancelOrders, + ExchangeFunctionName.CancelOrdersUpTo, + ], }; diff --git a/contracts/test-utils/src/index.ts b/contracts/test-utils/src/index.ts index 063859363d..a2ba137c0a 100644 --- a/contracts/test-utils/src/index.ts +++ b/contracts/test-utils/src/index.ts @@ -57,6 +57,7 @@ export { Token, TokenBalances, TransactionDataParams, + ExchangeFunctionName, } from './types'; export { blockchainTests, BlockchainTestsEnvironment, describe } from './mocha_blockchain'; export { chaiSetup, expect } from './chai_setup'; diff --git a/contracts/test-utils/src/types.ts b/contracts/test-utils/src/types.ts index 01b445f184..2db80a1437 100644 --- a/contracts/test-utils/src/types.ts +++ b/contracts/test-utils/src/types.ts @@ -171,3 +171,33 @@ export interface FillEventArgs { } export type Numberish = BigNumber | string | number; + +export enum ExchangeFunctionName { + BatchCancelOrders = 'batchCancelOrders', + BatchExecuteTransactions = 'batchExecuteTransactions', + BatchFillOrKillOrders = 'batchFillOrKillOrders', + BatchFillOrders = 'batchFillOrders', + BatchFillOrdersNoThrow = 'batchFillOrdersNoThrow', + BatchMatchOrders = 'batchMatchOrders', + BatchMatchOrdersWithMaximalFill = 'batchMatchOrdersWithMaximalFill', + CancelOrder = 'cancelOrder', + CancelOrdersUpTo = 'cancelOrdersUpTo', + ExecuteTransaction = 'executeTransaction', + FillOrKillOrder = 'fillOrKillOrder', + FillOrder = 'fillOrder', + FillOrderNoThrow = 'fillOrderNoThrow', + MarketBuyOrdersNoThrow = 'marketBuyOrdersNoThrow', + MarketSellOrdersNoThrow = 'marketSellOrdersNoThrow', + MarketBuyOrdersFillOrKill = 'marketBuyOrdersFillOrKill', + MarketSellOrdersFillOrKill = 'marketSellOrdersFillOrKill', + MatchOrders = 'matchOrders', + MatchOrdersWithMaximalFill = 'matchOrdersWithMaximalFill', + PreSign = 'preSign', + RegisterAssetProxy = 'registerAssetProxy', + SetSignatureValidatorApproval = 'setSignatureValidatorApproval', + SimulateDispatchTransferFromCalls = 'simulateDispatchTransferFromCalls', + TransferOwnership = 'transferOwnership', + SetProtocolFeeMultiplier = 'setProtocolFeeMultiplier', + SetProtocolFeeCollectorAddress = 'setProtocolFeeCollectorAddress', + DetachProtocolFeeCollector = 'detachProtocolFeeCollector', +} diff --git a/contracts/tests/package.json b/contracts/tests/package.json index 9ae908f542..d91335b46b 100644 --- a/contracts/tests/package.json +++ b/contracts/tests/package.json @@ -23,7 +23,7 @@ "compile": "sol-compiler", "watch": "sol-compiler -w", "clean": "shx rm -rf lib test/generated-artifacts test/generated-wrappers generated-artifacts generated-wrappers", - "generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --output generated-wrappers --backend ethers", + "generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --output test/generated-wrappers --backend ethers", "lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./test/generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude ./test/generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", "fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./test/generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude ./test/generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts", "coverage:report:text": "istanbul report text", diff --git a/contracts/tests/test/dev-utils/lib_transaction_decoder.ts b/contracts/tests/test/dev-utils/lib_transaction_decoder.ts index 9fe5ee13d6..37ad8fac86 100644 --- a/contracts/tests/test/dev-utils/lib_transaction_decoder.ts +++ b/contracts/tests/test/dev-utils/lib_transaction_decoder.ts @@ -1,4 +1,4 @@ -import { IExchangeContract } from '@0x/contracts-exchange'; +import { ExchangeContract } from '@0x/contracts-exchange'; import { chaiSetup, constants, provider, txDefaults, web3Wrapper } from '@0x/contracts-test-utils'; import { BlockchainLifecycle } from '@0x/dev-utils'; import { BigNumber } from '@0x/utils'; @@ -32,7 +32,7 @@ const signature = describe('LibTransactionDecoder', () => { let libTxDecoder: LibTransactionDecoderContract; - const exchangeInterface = new IExchangeContract(constants.NULL_ADDRESS, provider, txDefaults); + const exchangeInterface = new ExchangeContract(constants.NULL_ADDRESS, provider, txDefaults); before(async () => { await blockchainLifecycle.startAsync(); libTxDecoder = await LibTransactionDecoderContract.deployFrom0xArtifactAsync( diff --git a/contracts/tests/test/dev-utils/order_validation_utils.ts b/contracts/tests/test/dev-utils/order_validation_utils.ts index 05f5ea8da5..ad579e7150 100644 --- a/contracts/tests/test/dev-utils/order_validation_utils.ts +++ b/contracts/tests/test/dev-utils/order_validation_utils.ts @@ -8,7 +8,7 @@ import { } 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 { artifacts as exchangeArtifacts, ExchangeContract } from '@0x/contracts-exchange'; import { chaiSetup, constants, @@ -93,10 +93,24 @@ describe('OrderValidationUtils/OrderTransferSimulatorUtils', () => { txDefaults, artifacts, ); - const exchangeWrapper = new ExchangeWrapper(exchange); - await exchangeWrapper.registerAssetProxyAsync(erc20Proxy.address, owner); - await exchangeWrapper.registerAssetProxyAsync(erc721Proxy.address, owner); - await exchangeWrapper.registerAssetProxyAsync(multiAssetProxy.address, owner); + await exchange.registerAssetProxy.awaitTransactionSuccessAsync( + erc20Proxy.address, + { + from: owner, + }, + ); + await exchange.registerAssetProxy.awaitTransactionSuccessAsync( + erc721Proxy.address, + { + from: owner, + }, + ); + await exchange.registerAssetProxy.awaitTransactionSuccessAsync( + multiAssetProxy.address, + { + from: owner, + }, + ); await erc20Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(exchange.address, { from: owner }); await erc721Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(exchange.address, { from: owner });