Refactor contracts-core into contracts-multisig, contracts-core and contracts-test-utils
This commit is contained in:
parent
450c72035f
commit
0faa8b3231
@ -39,8 +39,6 @@
|
||||
"IWallet",
|
||||
"MixinAuthorizable",
|
||||
"MultiAssetProxy",
|
||||
"MultiSigWallet",
|
||||
"MultiSigWalletWithTimeLock",
|
||||
"OrderValidator",
|
||||
"ReentrantERC20Token",
|
||||
"TestAssetProxyOwner",
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
pragma solidity 0.4.24;
|
||||
|
||||
import "../../multisig/MultiSigWalletWithTimeLock.sol";
|
||||
import "@0x/contracts-multisig/contracts/multisig/MultiSigWalletWithTimeLock.sol";
|
||||
import "../../utils/LibBytes/LibBytes.sol";
|
||||
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"name": "contracts",
|
||||
"name": "@0x/contracts-core",
|
||||
"version": "2.1.56",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
@ -47,6 +47,7 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/core/README.md",
|
||||
"devDependencies": {
|
||||
"@0x/contracts-test-utils": "^1.0.0",
|
||||
"@0x/abi-gen": "^1.0.17",
|
||||
"@0x/dev-utils": "^1.0.19",
|
||||
"@0x/sol-compiler": "^1.1.14",
|
||||
@ -73,8 +74,14 @@
|
||||
"yargs": "^10.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
<<<<<<< HEAD
|
||||
"@0x/base-contract": "^3.0.8",
|
||||
"@0x/order-utils": "^3.0.4",
|
||||
=======
|
||||
"@0x/contracts-multisig": "^1.0.0",
|
||||
"@0x/base-contract": "^3.0.7",
|
||||
"@0x/order-utils": "^3.0.3",
|
||||
>>>>>>> Refactor contracts-core into contracts-multisig, contracts-core and contracts-test-utils
|
||||
"@0x/types": "^1.3.0",
|
||||
"@0x/typescript-typings": "^3.0.4",
|
||||
"@0x/utils": "^2.0.6",
|
||||
|
@ -1,3 +1,11 @@
|
||||
import {
|
||||
chaiSetup,
|
||||
constants,
|
||||
expectTransactionFailedAsync,
|
||||
provider,
|
||||
txDefaults,
|
||||
web3Wrapper,
|
||||
} from '@0x/contracts-test-utils';
|
||||
import { BlockchainLifecycle } from '@0x/dev-utils';
|
||||
import { RevertReason } from '@0x/types';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
@ -6,10 +14,6 @@ import * as _ from 'lodash';
|
||||
|
||||
import { MixinAuthorizableContract } from '../../generated-wrappers/mixin_authorizable';
|
||||
import { artifacts } from '../../src/artifacts';
|
||||
import { expectTransactionFailedAsync } from '../utils/assertions';
|
||||
import { chaiSetup } from '../utils/chai_setup';
|
||||
import { constants } from '../utils/constants';
|
||||
import { provider, txDefaults, web3Wrapper } from '../utils/web3_wrapper';
|
||||
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
|
@ -1,3 +1,13 @@
|
||||
import {
|
||||
chaiSetup,
|
||||
constants,
|
||||
expectTransactionFailedAsync,
|
||||
expectTransactionFailedWithoutReasonAsync,
|
||||
LogDecoder,
|
||||
provider,
|
||||
txDefaults,
|
||||
web3Wrapper,
|
||||
} from '@0x/contracts-test-utils';
|
||||
import { BlockchainLifecycle } from '@0x/dev-utils';
|
||||
import { assetDataUtils } from '@0x/order-utils';
|
||||
import { RevertReason } from '@0x/types';
|
||||
@ -16,13 +26,8 @@ import { IAssetDataContract } from '../../generated-wrappers/i_asset_data';
|
||||
import { IAssetProxyContract } from '../../generated-wrappers/i_asset_proxy';
|
||||
import { MultiAssetProxyContract } from '../../generated-wrappers/multi_asset_proxy';
|
||||
import { artifacts } from '../../src/artifacts';
|
||||
import { expectTransactionFailedAsync, expectTransactionFailedWithoutReasonAsync } from '../utils/assertions';
|
||||
import { chaiSetup } from '../utils/chai_setup';
|
||||
import { constants } from '../utils/constants';
|
||||
import { ERC20Wrapper } from '../utils/erc20_wrapper';
|
||||
import { ERC721Wrapper } from '../utils/erc721_wrapper';
|
||||
import { LogDecoder } from '../utils/log_decoder';
|
||||
import { provider, txDefaults, web3Wrapper } from '../utils/web3_wrapper';
|
||||
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
@ -553,7 +558,7 @@ describe('Asset Transfer Proxies', () => {
|
||||
erc721Receiver.address,
|
||||
amount,
|
||||
);
|
||||
const logDecoder = new LogDecoder(web3Wrapper);
|
||||
const logDecoder = new LogDecoder(web3Wrapper, artifacts);
|
||||
const tx = await logDecoder.getTxWithDecodedLogsAsync(
|
||||
await web3Wrapper.sendTransactionAsync({
|
||||
to: erc721Proxy.address,
|
||||
|
@ -1,3 +1,16 @@
|
||||
import {
|
||||
chaiSetup,
|
||||
constants,
|
||||
ERC20BalancesByOwner,
|
||||
expectTransactionFailedAsync,
|
||||
getLatestBlockTimestampAsync,
|
||||
increaseTimeAndMineBlockAsync,
|
||||
OrderFactory,
|
||||
OrderStatus,
|
||||
provider,
|
||||
txDefaults,
|
||||
web3Wrapper,
|
||||
} from '@0x/contracts-test-utils';
|
||||
import { BlockchainLifecycle } from '@0x/dev-utils';
|
||||
import { assetDataUtils, orderHashUtils } from '@0x/order-utils';
|
||||
import { RevertReason, SignatureType, SignedOrder } from '@0x/types';
|
||||
@ -19,16 +32,9 @@ import { MultiAssetProxyContract } from '../../generated-wrappers/multi_asset_pr
|
||||
import { ReentrantERC20TokenContract } from '../../generated-wrappers/reentrant_erc20_token';
|
||||
import { TestStaticCallReceiverContract } from '../../generated-wrappers/test_static_call_receiver';
|
||||
import { artifacts } from '../../src/artifacts';
|
||||
import { expectTransactionFailedAsync } from '../utils/assertions';
|
||||
import { getLatestBlockTimestampAsync, increaseTimeAndMineBlockAsync } from '../utils/block_timestamp';
|
||||
import { chaiSetup } from '../utils/chai_setup';
|
||||
import { constants } from '../utils/constants';
|
||||
import { ERC20Wrapper } from '../utils/erc20_wrapper';
|
||||
import { ERC721Wrapper } from '../utils/erc721_wrapper';
|
||||
import { ExchangeWrapper } from '../utils/exchange_wrapper';
|
||||
import { OrderFactory } from '../utils/order_factory';
|
||||
import { ERC20BalancesByOwner, OrderStatus } from '../utils/types';
|
||||
import { provider, txDefaults, web3Wrapper } from '../utils/web3_wrapper';
|
||||
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
|
@ -1,3 +1,12 @@
|
||||
import {
|
||||
chaiSetup,
|
||||
constants,
|
||||
expectTransactionFailedAsync,
|
||||
LogDecoder,
|
||||
provider,
|
||||
txDefaults,
|
||||
web3Wrapper,
|
||||
} from '@0x/contracts-test-utils';
|
||||
import { BlockchainLifecycle } from '@0x/dev-utils';
|
||||
import { assetDataUtils } from '@0x/order-utils';
|
||||
import { AssetProxyId, RevertReason } from '@0x/types';
|
||||
@ -14,13 +23,8 @@ import {
|
||||
TestAssetProxyDispatcherContract,
|
||||
} from '../../generated-wrappers/test_asset_proxy_dispatcher';
|
||||
import { artifacts } from '../../src/artifacts';
|
||||
import { expectTransactionFailedAsync } from '../utils/assertions';
|
||||
import { chaiSetup } from '../utils/chai_setup';
|
||||
import { constants } from '../utils/constants';
|
||||
import { ERC20Wrapper } from '../utils/erc20_wrapper';
|
||||
import { ERC721Wrapper } from '../utils/erc721_wrapper';
|
||||
import { LogDecoder } from '../utils/log_decoder';
|
||||
import { provider, txDefaults, web3Wrapper } from '../utils/web3_wrapper';
|
||||
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
@ -145,7 +149,7 @@ describe('AssetProxyDispatcher', () => {
|
||||
});
|
||||
|
||||
it('should log an event with correct arguments when an asset proxy is registered', async () => {
|
||||
const logDecoder = new LogDecoder(web3Wrapper);
|
||||
const logDecoder = new LogDecoder(web3Wrapper, artifacts);
|
||||
const txReceipt = await logDecoder.getTxWithDecodedLogsAsync(
|
||||
await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(erc20Proxy.address, { from: owner }),
|
||||
);
|
||||
|
@ -1,23 +1,25 @@
|
||||
import { BlockchainLifecycle } from '@0x/dev-utils';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { chaiSetup } from '../utils/chai_setup';
|
||||
import {
|
||||
FillOrderCombinatorialUtils,
|
||||
fillOrderCombinatorialUtilsFactoryAsync,
|
||||
} from '../utils/fill_order_combinatorial_utils';
|
||||
import {
|
||||
AllowanceAmountScenario,
|
||||
AssetDataScenario,
|
||||
BalanceAmountScenario,
|
||||
chaiSetup,
|
||||
ExpirationTimeSecondsScenario,
|
||||
FeeRecipientAddressScenario,
|
||||
FillScenario,
|
||||
OrderAssetAmountScenario,
|
||||
provider,
|
||||
TakerAssetFillAmountScenario,
|
||||
TakerScenario,
|
||||
} from '../utils/types';
|
||||
import { provider, txDefaults, web3Wrapper } from '../utils/web3_wrapper';
|
||||
txDefaults,
|
||||
web3Wrapper,
|
||||
} from '@0x/contracts-test-utils';
|
||||
import { BlockchainLifecycle } from '@0x/dev-utils';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import {
|
||||
FillOrderCombinatorialUtils,
|
||||
fillOrderCombinatorialUtilsFactoryAsync,
|
||||
} from '../utils/fill_order_combinatorial_utils';
|
||||
|
||||
chaiSetup.configure();
|
||||
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
||||
|
@ -1,3 +1,12 @@
|
||||
import {
|
||||
chaiSetup,
|
||||
constants,
|
||||
FillResults,
|
||||
getRevertReasonOrErrorMessageForSendTransactionAsync,
|
||||
provider,
|
||||
txDefaults,
|
||||
web3Wrapper,
|
||||
} from '@0x/contracts-test-utils';
|
||||
import { BlockchainLifecycle } from '@0x/dev-utils';
|
||||
import { Order, RevertReason, SignedOrder } from '@0x/types';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
@ -6,12 +15,7 @@ import * as _ from 'lodash';
|
||||
|
||||
import { TestExchangeInternalsContract } from '../../generated-wrappers/test_exchange_internals';
|
||||
import { artifacts } from '../../src/artifacts';
|
||||
import { getRevertReasonOrErrorMessageForSendTransactionAsync } from '../utils/assertions';
|
||||
import { chaiSetup } from '../utils/chai_setup';
|
||||
import { bytes32Values, testCombinatoriallyWithReferenceFuncAsync, uint256Values } from '../utils/combinatorial_utils';
|
||||
import { constants } from '../utils/constants';
|
||||
import { FillResults } from '../utils/types';
|
||||
import { provider, txDefaults, web3Wrapper } from '../utils/web3_wrapper';
|
||||
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
|
@ -1,3 +1,12 @@
|
||||
import {
|
||||
addressUtils,
|
||||
chaiSetup,
|
||||
constants,
|
||||
OrderFactory,
|
||||
provider,
|
||||
txDefaults,
|
||||
web3Wrapper,
|
||||
} from '@0x/contracts-test-utils';
|
||||
import { BlockchainLifecycle } from '@0x/dev-utils';
|
||||
import { assetDataUtils, orderHashUtils } from '@0x/order-utils';
|
||||
import { SignedOrder } from '@0x/types';
|
||||
@ -7,11 +16,6 @@ import * as chai from 'chai';
|
||||
import { TestConstantsContract } from '../../generated-wrappers/test_constants';
|
||||
import { TestLibsContract } from '../../generated-wrappers/test_libs';
|
||||
import { artifacts } from '../../src/artifacts';
|
||||
import { addressUtils } from '../utils/address_utils';
|
||||
import { chaiSetup } from '../utils/chai_setup';
|
||||
import { constants } from '../utils/constants';
|
||||
import { OrderFactory } from '../utils/order_factory';
|
||||
import { provider, txDefaults, web3Wrapper } from '../utils/web3_wrapper';
|
||||
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
|
@ -1,3 +1,14 @@
|
||||
import {
|
||||
chaiSetup,
|
||||
constants,
|
||||
ERC20BalancesByOwner,
|
||||
ERC721TokenIdsByOwner,
|
||||
expectTransactionFailedAsync,
|
||||
OrderFactory,
|
||||
provider,
|
||||
txDefaults,
|
||||
web3Wrapper,
|
||||
} from '@0x/contracts-test-utils';
|
||||
import { BlockchainLifecycle } from '@0x/dev-utils';
|
||||
import { assetDataUtils } from '@0x/order-utils';
|
||||
import { RevertReason } from '@0x/types';
|
||||
@ -14,16 +25,10 @@ import { ExchangeContract } from '../../generated-wrappers/exchange';
|
||||
import { ReentrantERC20TokenContract } from '../../generated-wrappers/reentrant_erc20_token';
|
||||
import { TestExchangeInternalsContract } from '../../generated-wrappers/test_exchange_internals';
|
||||
import { artifacts } from '../../src/artifacts';
|
||||
import { expectTransactionFailedAsync } from '../utils/assertions';
|
||||
import { chaiSetup } from '../utils/chai_setup';
|
||||
import { constants } from '../utils/constants';
|
||||
import { ERC20Wrapper } from '../utils/erc20_wrapper';
|
||||
import { ERC721Wrapper } from '../utils/erc721_wrapper';
|
||||
import { ExchangeWrapper } from '../utils/exchange_wrapper';
|
||||
import { MatchOrderTester } from '../utils/match_order_tester';
|
||||
import { OrderFactory } from '../utils/order_factory';
|
||||
import { ERC20BalancesByOwner, ERC721TokenIdsByOwner } from '../utils/types';
|
||||
import { provider, txDefaults, web3Wrapper } from '../utils/web3_wrapper';
|
||||
|
||||
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
||||
chaiSetup.configure();
|
||||
|
@ -1,3 +1,14 @@
|
||||
import {
|
||||
addressUtils,
|
||||
chaiSetup,
|
||||
constants,
|
||||
expectContractCallFailedAsync,
|
||||
LogDecoder,
|
||||
OrderFactory,
|
||||
provider,
|
||||
txDefaults,
|
||||
web3Wrapper,
|
||||
} from '@0x/contracts-test-utils';
|
||||
import { BlockchainLifecycle } from '@0x/dev-utils';
|
||||
import { assetDataUtils, orderHashUtils, signatureUtils } from '@0x/order-utils';
|
||||
import { RevertReason, SignatureType, SignedOrder } from '@0x/types';
|
||||
@ -13,13 +24,6 @@ import { TestStaticCallReceiverContract } from '../../generated-wrappers/test_st
|
||||
import { ValidatorContract } from '../../generated-wrappers/validator';
|
||||
import { WalletContract } from '../../generated-wrappers/wallet';
|
||||
import { artifacts } from '../../src/artifacts';
|
||||
import { addressUtils } from '../utils/address_utils';
|
||||
import { expectContractCallFailedAsync } from '../utils/assertions';
|
||||
import { chaiSetup } from '../utils/chai_setup';
|
||||
import { constants } from '../utils/constants';
|
||||
import { LogDecoder } from '../utils/log_decoder';
|
||||
import { OrderFactory } from '../utils/order_factory';
|
||||
import { provider, txDefaults, web3Wrapper } from '../utils/web3_wrapper';
|
||||
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
@ -73,7 +77,7 @@ describe('MixinSignatureValidator', () => {
|
||||
provider,
|
||||
txDefaults,
|
||||
);
|
||||
signatureValidatorLogDecoder = new LogDecoder(web3Wrapper);
|
||||
signatureValidatorLogDecoder = new LogDecoder(web3Wrapper, artifacts);
|
||||
await web3Wrapper.awaitTransactionSuccessAsync(
|
||||
await signatureValidator.setSignatureValidatorApproval.sendTransactionAsync(testValidator.address, true, {
|
||||
from: signerAddress,
|
||||
|
@ -1,3 +1,16 @@
|
||||
import {
|
||||
chaiSetup,
|
||||
constants,
|
||||
ERC20BalancesByOwner,
|
||||
expectTransactionFailedAsync,
|
||||
OrderFactory,
|
||||
orderUtils,
|
||||
provider,
|
||||
SignedTransaction,
|
||||
TransactionFactory,
|
||||
txDefaults,
|
||||
web3Wrapper,
|
||||
} from '@0x/contracts-test-utils';
|
||||
import { BlockchainLifecycle } from '@0x/dev-utils';
|
||||
import { assetDataUtils, generatePseudoRandomSalt } from '@0x/order-utils';
|
||||
import { OrderWithoutExchangeAddress, RevertReason, SignedOrder } from '@0x/types';
|
||||
@ -11,16 +24,8 @@ import { ExchangeContract } from '../../generated-wrappers/exchange';
|
||||
import { ExchangeWrapperContract } from '../../generated-wrappers/exchange_wrapper';
|
||||
import { WhitelistContract } from '../../generated-wrappers/whitelist';
|
||||
import { artifacts } from '../../src/artifacts';
|
||||
import { expectTransactionFailedAsync } 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 { OrderFactory } from '../utils/order_factory';
|
||||
import { orderUtils } from '../utils/order_utils';
|
||||
import { TransactionFactory } from '../utils/transaction_factory';
|
||||
import { ERC20BalancesByOwner, SignedTransaction } from '../utils/types';
|
||||
import { provider, txDefaults, web3Wrapper } from '../utils/web3_wrapper';
|
||||
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
|
@ -1,3 +1,16 @@
|
||||
import {
|
||||
chaiSetup,
|
||||
constants,
|
||||
ERC20BalancesByOwner,
|
||||
expectTransactionFailedAsync,
|
||||
getLatestBlockTimestampAsync,
|
||||
increaseTimeAndMineBlockAsync,
|
||||
OrderFactory,
|
||||
OrderStatus,
|
||||
provider,
|
||||
txDefaults,
|
||||
web3Wrapper,
|
||||
} from '@0x/contracts-test-utils';
|
||||
import { BlockchainLifecycle } from '@0x/dev-utils';
|
||||
import { assetDataUtils, orderHashUtils } from '@0x/order-utils';
|
||||
import { RevertReason, SignedOrder } from '@0x/types';
|
||||
@ -13,16 +26,9 @@ import { ERC721ProxyContract } from '../../generated-wrappers/erc721_proxy';
|
||||
import { ExchangeContract } from '../../generated-wrappers/exchange';
|
||||
import { ReentrantERC20TokenContract } from '../../generated-wrappers/reentrant_erc20_token';
|
||||
import { artifacts } from '../../src/artifacts';
|
||||
import { expectTransactionFailedAsync } from '../utils/assertions';
|
||||
import { getLatestBlockTimestampAsync, increaseTimeAndMineBlockAsync } from '../utils/block_timestamp';
|
||||
import { chaiSetup } from '../utils/chai_setup';
|
||||
import { constants } from '../utils/constants';
|
||||
import { ERC20Wrapper } from '../utils/erc20_wrapper';
|
||||
import { ERC721Wrapper } from '../utils/erc721_wrapper';
|
||||
import { ExchangeWrapper } from '../utils/exchange_wrapper';
|
||||
import { OrderFactory } from '../utils/order_factory';
|
||||
import { ERC20BalancesByOwner, OrderStatus } from '../utils/types';
|
||||
import { provider, txDefaults, web3Wrapper } from '../utils/web3_wrapper';
|
||||
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
|
@ -1,3 +1,16 @@
|
||||
import {
|
||||
chaiSetup,
|
||||
constants,
|
||||
ContractName,
|
||||
ERC20BalancesByOwner,
|
||||
expectContractCreationFailedAsync,
|
||||
expectTransactionFailedAsync,
|
||||
OrderFactory,
|
||||
provider,
|
||||
sendTransactionResult,
|
||||
txDefaults,
|
||||
web3Wrapper,
|
||||
} from '@0x/contracts-test-utils';
|
||||
import { BlockchainLifecycle } from '@0x/dev-utils';
|
||||
import { assetDataUtils } from '@0x/order-utils';
|
||||
import { RevertReason, SignedOrder } from '@0x/types';
|
||||
@ -12,20 +25,10 @@ import { ExchangeContract } from '../../generated-wrappers/exchange';
|
||||
import { ForwarderContract } from '../../generated-wrappers/forwarder';
|
||||
import { WETH9Contract } from '../../generated-wrappers/weth9';
|
||||
import { artifacts } from '../../src/artifacts';
|
||||
import {
|
||||
expectContractCreationFailedAsync,
|
||||
expectTransactionFailedAsync,
|
||||
sendTransactionResult,
|
||||
} from '../utils/assertions';
|
||||
import { chaiSetup } from '../utils/chai_setup';
|
||||
import { constants } from '../utils/constants';
|
||||
import { ERC20Wrapper } from '../utils/erc20_wrapper';
|
||||
import { ERC721Wrapper } from '../utils/erc721_wrapper';
|
||||
import { ExchangeWrapper } from '../utils/exchange_wrapper';
|
||||
import { ForwarderWrapper } from '../utils/forwarder_wrapper';
|
||||
import { OrderFactory } from '../utils/order_factory';
|
||||
import { ContractName, ERC20BalancesByOwner } from '../utils/types';
|
||||
import { provider, txDefaults, web3Wrapper } from '../utils/web3_wrapper';
|
||||
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
|
@ -1,3 +1,12 @@
|
||||
import {
|
||||
chaiSetup,
|
||||
constants,
|
||||
OrderFactory,
|
||||
OrderStatus,
|
||||
provider,
|
||||
txDefaults,
|
||||
web3Wrapper,
|
||||
} from '@0x/contracts-test-utils';
|
||||
import { BlockchainLifecycle } from '@0x/dev-utils';
|
||||
import { assetDataUtils, orderHashUtils } from '@0x/order-utils';
|
||||
import { SignedOrder } from '@0x/types';
|
||||
@ -12,14 +21,9 @@ import { ERC721ProxyContract } from '../../generated-wrappers/erc721_proxy';
|
||||
import { ExchangeContract } from '../../generated-wrappers/exchange';
|
||||
import { OrderValidatorContract } from '../../generated-wrappers/order_validator';
|
||||
import { artifacts } from '../../src/artifacts';
|
||||
import { chaiSetup } from '../utils/chai_setup';
|
||||
import { constants } from '../utils/constants';
|
||||
import { ERC20Wrapper } from '../utils/erc20_wrapper';
|
||||
import { ERC721Wrapper } from '../utils/erc721_wrapper';
|
||||
import { ExchangeWrapper } from '../utils/exchange_wrapper';
|
||||
import { OrderFactory } from '../utils/order_factory';
|
||||
import { OrderStatus } from '../utils/types';
|
||||
import { provider, txDefaults, web3Wrapper } from '../utils/web3_wrapper';
|
||||
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
|
@ -1,7 +1,6 @@
|
||||
import { env, EnvVars } from '@0x/dev-utils';
|
||||
|
||||
import { coverage } from './utils/coverage';
|
||||
import { profiler } from './utils/profiler';
|
||||
import { coverage, profiler } from '@0x/contracts-test-utils';
|
||||
|
||||
after('generate coverage report', async () => {
|
||||
if (env.parseBoolean(EnvVars.SolidityCoverage)) {
|
||||
|
@ -1,3 +1,12 @@
|
||||
import {
|
||||
chaiSetup,
|
||||
constants,
|
||||
expectContractCallFailedAsync,
|
||||
provider,
|
||||
txDefaults,
|
||||
typeEncodingUtils,
|
||||
web3Wrapper,
|
||||
} from '@0x/contracts-test-utils';
|
||||
import { BlockchainLifecycle } from '@0x/dev-utils';
|
||||
import { generatePseudoRandomSalt } from '@0x/order-utils';
|
||||
import { RevertReason } from '@0x/types';
|
||||
@ -9,11 +18,6 @@ import * as _ from 'lodash';
|
||||
|
||||
import { TestLibBytesContract } from '../../generated-wrappers/test_lib_bytes';
|
||||
import { artifacts } from '../../src/artifacts';
|
||||
import { expectContractCallFailedAsync } from '../utils/assertions';
|
||||
import { chaiSetup } from '../utils/chai_setup';
|
||||
import { constants } from '../utils/constants';
|
||||
import { typeEncodingUtils } from '../utils/type_encoding_utils';
|
||||
import { provider, txDefaults, web3Wrapper } from '../utils/web3_wrapper';
|
||||
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
|
@ -1,3 +1,16 @@
|
||||
import {
|
||||
chaiSetup,
|
||||
constants,
|
||||
expectContractCallFailedAsync,
|
||||
expectContractCreationFailedAsync,
|
||||
expectTransactionFailedAsync,
|
||||
expectTransactionFailedWithoutReasonAsync,
|
||||
increaseTimeAndMineBlockAsync,
|
||||
provider,
|
||||
sendTransactionResult,
|
||||
txDefaults,
|
||||
web3Wrapper,
|
||||
} from '@0x/contracts-test-utils';
|
||||
import { BlockchainLifecycle } from '@0x/dev-utils';
|
||||
import { RevertReason } from '@0x/types';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
@ -14,18 +27,7 @@ import {
|
||||
import { MixinAuthorizableContract } from '../../generated-wrappers/mixin_authorizable';
|
||||
import { TestAssetProxyOwnerContract } from '../../generated-wrappers/test_asset_proxy_owner';
|
||||
import { artifacts } from '../../src/artifacts';
|
||||
import {
|
||||
expectContractCallFailedAsync,
|
||||
expectContractCreationFailedAsync,
|
||||
expectTransactionFailedAsync,
|
||||
expectTransactionFailedWithoutReasonAsync,
|
||||
sendTransactionResult,
|
||||
} from '../utils/assertions';
|
||||
import { increaseTimeAndMineBlockAsync } from '../utils/block_timestamp';
|
||||
import { chaiSetup } from '../utils/chai_setup';
|
||||
import { constants } from '../utils/constants';
|
||||
import { MultiSigWrapper } from '../utils/multi_sig_wrapper';
|
||||
import { provider, txDefaults, web3Wrapper } from '../utils/web3_wrapper';
|
||||
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
@ -495,4 +497,3 @@ describe('AssetProxyOwner', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
// tslint:enable:no-unnecessary-type-assertion
|
||||
|
@ -1,3 +1,13 @@
|
||||
import {
|
||||
chaiSetup,
|
||||
constants,
|
||||
expectTransactionFailedAsync,
|
||||
expectTransactionFailedWithoutReasonAsync,
|
||||
LogDecoder,
|
||||
provider,
|
||||
txDefaults,
|
||||
web3Wrapper,
|
||||
} from '@0x/contracts-test-utils';
|
||||
import { BlockchainLifecycle } from '@0x/dev-utils';
|
||||
import { RevertReason } from '@0x/types';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
@ -14,11 +24,6 @@ import {
|
||||
} from '../../generated-wrappers/dummy_erc721_token';
|
||||
import { InvalidERC721ReceiverContract } from '../../generated-wrappers/invalid_erc721_receiver';
|
||||
import { artifacts } from '../../src/artifacts';
|
||||
import { expectTransactionFailedAsync, expectTransactionFailedWithoutReasonAsync } from '../utils/assertions';
|
||||
import { chaiSetup } from '../utils/chai_setup';
|
||||
import { constants } from '../utils/constants';
|
||||
import { LogDecoder } from '../utils/log_decoder';
|
||||
import { provider, txDefaults, web3Wrapper } from '../utils/web3_wrapper';
|
||||
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
@ -53,7 +58,7 @@ describe('ERC721Token', () => {
|
||||
provider,
|
||||
txDefaults,
|
||||
);
|
||||
logDecoder = new LogDecoder(web3Wrapper);
|
||||
logDecoder = new LogDecoder(web3Wrapper, artifacts);
|
||||
await web3Wrapper.awaitTransactionSuccessAsync(
|
||||
await token.mint.sendTransactionAsync(owner, tokenId, { from: owner }),
|
||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
||||
|
@ -1,3 +1,11 @@
|
||||
import {
|
||||
chaiSetup,
|
||||
constants,
|
||||
expectContractCallFailedAsync,
|
||||
provider,
|
||||
txDefaults,
|
||||
web3Wrapper,
|
||||
} from '@0x/contracts-test-utils';
|
||||
import { BlockchainLifecycle } from '@0x/dev-utils';
|
||||
import { RevertReason } from '@0x/types';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
@ -5,10 +13,6 @@ import * as chai from 'chai';
|
||||
|
||||
import { DummyERC20TokenContract } from '../../generated-wrappers/dummy_erc20_token';
|
||||
import { artifacts } from '../../src/artifacts';
|
||||
import { expectContractCallFailedAsync } from '../utils/assertions';
|
||||
import { chaiSetup } from '../utils/chai_setup';
|
||||
import { constants } from '../utils/constants';
|
||||
import { provider, txDefaults, web3Wrapper } from '../utils/web3_wrapper';
|
||||
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
|
@ -1,3 +1,12 @@
|
||||
import {
|
||||
chaiSetup,
|
||||
constants,
|
||||
expectInsufficientFundsAsync,
|
||||
expectTransactionFailedWithoutReasonAsync,
|
||||
provider,
|
||||
txDefaults,
|
||||
web3Wrapper,
|
||||
} from '@0x/contracts-test-utils';
|
||||
import { BlockchainLifecycle } from '@0x/dev-utils';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
@ -5,10 +14,6 @@ import * as chai from 'chai';
|
||||
|
||||
import { WETH9Contract } from '../../generated-wrappers/weth9';
|
||||
import { artifacts } from '../../src/artifacts';
|
||||
import { expectInsufficientFundsAsync, expectTransactionFailedWithoutReasonAsync } from '../utils/assertions';
|
||||
import { chaiSetup } from '../utils/chai_setup';
|
||||
import { constants } from '../utils/constants';
|
||||
import { provider, txDefaults, web3Wrapper } from '../utils/web3_wrapper';
|
||||
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { chaiSetup, constants, provider, txDefaults, web3Wrapper } from '@0x/contracts-test-utils';
|
||||
import { BlockchainLifecycle } from '@0x/dev-utils';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
@ -5,9 +6,6 @@ import * as chai from 'chai';
|
||||
|
||||
import { ZRXTokenContract } from '../../generated-wrappers/zrx_token';
|
||||
import { artifacts } from '../../src/artifacts';
|
||||
import { chaiSetup } from '../utils/chai_setup';
|
||||
import { constants } from '../utils/constants';
|
||||
import { provider, txDefaults, web3Wrapper } from '../utils/web3_wrapper';
|
||||
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
|
@ -1,10 +1,9 @@
|
||||
import { AbstractAssetWrapper, constants } from '@0x/contracts-test-utils';
|
||||
import { assetDataUtils } from '@0x/order-utils';
|
||||
import { AssetProxyId } from '@0x/types';
|
||||
import { BigNumber, errorUtils } from '@0x/utils';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { AbstractAssetWrapper } from './abstract_asset_wrapper';
|
||||
import { constants } from './constants';
|
||||
import { ERC20Wrapper } from './erc20_wrapper';
|
||||
import { ERC721Wrapper } from './erc721_wrapper';
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import * as combinatorics from 'js-combinatorics';
|
||||
|
||||
import { testWithReferenceFuncAsync } from './test_with_reference';
|
||||
import { testWithReferenceFuncAsync } from '@0x/contracts-test-utils';
|
||||
|
||||
// A set of values corresponding to the uint256 type in Solidity. This set
|
||||
// contains some notable edge cases, including some values which will overflow
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { constants, ERC20BalancesByOwner, txDefaults } from '@0x/contracts-test-utils';
|
||||
import { assetDataUtils } from '@0x/order-utils';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
@ -8,10 +9,6 @@ import { DummyERC20TokenContract } from '../../generated-wrappers/dummy_erc20_to
|
||||
import { ERC20ProxyContract } from '../../generated-wrappers/erc20_proxy';
|
||||
import { artifacts } from '../../src/artifacts';
|
||||
|
||||
import { constants } from './constants';
|
||||
import { ERC20BalancesByOwner } from './types';
|
||||
import { txDefaults } from './web3_wrapper';
|
||||
|
||||
export class ERC20Wrapper {
|
||||
private readonly _tokenOwnerAddresses: string[];
|
||||
private readonly _contractOwnerAddress: string;
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { constants, ERC721TokenIdsByOwner, txDefaults } from '@0x/contracts-test-utils';
|
||||
import { generatePseudoRandomSalt } from '@0x/order-utils';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
@ -8,10 +9,6 @@ import { DummyERC721TokenContract } from '../../generated-wrappers/dummy_erc721_
|
||||
import { ERC721ProxyContract } from '../../generated-wrappers/erc721_proxy';
|
||||
import { artifacts } from '../../src/artifacts';
|
||||
|
||||
import { constants } from './constants';
|
||||
import { ERC721TokenIdsByOwner } from './types';
|
||||
import { txDefaults } from './web3_wrapper';
|
||||
|
||||
export class ERC721Wrapper {
|
||||
private readonly _tokenOwnerAddresses: string[];
|
||||
private readonly _contractOwnerAddress: string;
|
||||
|
@ -1,14 +1,18 @@
|
||||
import {
|
||||
FillResults,
|
||||
formatters,
|
||||
LogDecoder,
|
||||
OrderInfo,
|
||||
orderUtils,
|
||||
SignedTransaction,
|
||||
} from '@0x/contracts-test-utils';
|
||||
import { SignedOrder } from '@0x/types';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import { Provider, TransactionReceiptWithDecodedLogs } from 'ethereum-types';
|
||||
|
||||
import { ExchangeContract } from '../../generated-wrappers/exchange';
|
||||
|
||||
import { formatters } from './formatters';
|
||||
import { LogDecoder } from './log_decoder';
|
||||
import { orderUtils } from './order_utils';
|
||||
import { FillResults, OrderInfo, SignedTransaction } from './types';
|
||||
import { artifacts } from '../../src/artifacts';
|
||||
|
||||
export class ExchangeWrapper {
|
||||
private readonly _exchange: ExchangeContract;
|
||||
@ -17,7 +21,7 @@ export class ExchangeWrapper {
|
||||
constructor(exchangeContract: ExchangeContract, provider: Provider) {
|
||||
this._exchange = exchangeContract;
|
||||
this._web3Wrapper = new Web3Wrapper(provider);
|
||||
this._logDecoder = new LogDecoder(this._web3Wrapper);
|
||||
this._logDecoder = new LogDecoder(this._web3Wrapper, artifacts);
|
||||
}
|
||||
public async fillOrderAsync(
|
||||
signedOrder: SignedOrder,
|
||||
|
@ -1,3 +1,20 @@
|
||||
import {
|
||||
AllowanceAmountScenario,
|
||||
AssetDataScenario,
|
||||
BalanceAmountScenario,
|
||||
chaiSetup,
|
||||
constants,
|
||||
expectTransactionFailedAsync,
|
||||
ExpirationTimeSecondsScenario,
|
||||
FeeRecipientAddressScenario,
|
||||
FillScenario,
|
||||
OrderAssetAmountScenario,
|
||||
orderUtils,
|
||||
signingUtils,
|
||||
TakerAssetFillAmountScenario,
|
||||
TakerScenario,
|
||||
TraderStateScenario,
|
||||
} from '@0x/contracts-test-utils';
|
||||
import {
|
||||
assetDataUtils,
|
||||
BalanceAndProxyAllowanceLazyStore,
|
||||
@ -18,30 +35,13 @@ import { ExchangeContract, ExchangeFillEventArgs } from '../../generated-wrapper
|
||||
import { TestLibsContract } from '../../generated-wrappers/test_libs';
|
||||
import { artifacts } from '../../src/artifacts';
|
||||
|
||||
import { expectTransactionFailedAsync } from './assertions';
|
||||
import { AssetWrapper } from './asset_wrapper';
|
||||
import { chaiSetup } from './chai_setup';
|
||||
import { constants } from './constants';
|
||||
import { ERC20Wrapper } from './erc20_wrapper';
|
||||
import { ERC721Wrapper } from './erc721_wrapper';
|
||||
import { ExchangeWrapper } from './exchange_wrapper';
|
||||
import { OrderFactoryFromScenario } from './order_factory_from_scenario';
|
||||
import { orderUtils } from './order_utils';
|
||||
import { signingUtils } from './signing_utils';
|
||||
import { SimpleAssetBalanceAndProxyAllowanceFetcher } from './simple_asset_balance_and_proxy_allowance_fetcher';
|
||||
import { SimpleOrderFilledCancelledFetcher } from './simple_order_filled_cancelled_fetcher';
|
||||
import {
|
||||
AllowanceAmountScenario,
|
||||
AssetDataScenario,
|
||||
BalanceAmountScenario,
|
||||
ExpirationTimeSecondsScenario,
|
||||
FeeRecipientAddressScenario,
|
||||
FillScenario,
|
||||
OrderAssetAmountScenario,
|
||||
TakerAssetFillAmountScenario,
|
||||
TakerScenario,
|
||||
TraderStateScenario,
|
||||
} from './types';
|
||||
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { constants, formatters, LogDecoder, MarketSellOrders } from '@0x/contracts-test-utils';
|
||||
import { SignedOrder } from '@0x/types';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
@ -5,11 +6,7 @@ import { Provider, TransactionReceiptWithDecodedLogs, TxDataPayable } from 'ethe
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { ForwarderContract } from '../../generated-wrappers/forwarder';
|
||||
|
||||
import { constants } from './constants';
|
||||
import { formatters } from './formatters';
|
||||
import { LogDecoder } from './log_decoder';
|
||||
import { MarketSellOrders } from './types';
|
||||
import { artifacts } from '../../src/artifacts';
|
||||
|
||||
export class ForwarderWrapper {
|
||||
private readonly _web3Wrapper: Web3Wrapper;
|
||||
@ -61,7 +58,7 @@ export class ForwarderWrapper {
|
||||
constructor(contractInstance: ForwarderContract, provider: Provider) {
|
||||
this._forwarderContract = contractInstance;
|
||||
this._web3Wrapper = new Web3Wrapper(provider);
|
||||
this._logDecoder = new LogDecoder(this._web3Wrapper);
|
||||
this._logDecoder = new LogDecoder(this._web3Wrapper, artifacts);
|
||||
}
|
||||
public async marketSellOrdersWithEthAsync(
|
||||
orders: SignedOrder[],
|
||||
|
@ -1,3 +1,12 @@
|
||||
import {
|
||||
chaiSetup,
|
||||
ERC20BalancesByOwner,
|
||||
ERC721TokenIdsByOwner,
|
||||
OrderInfo,
|
||||
OrderStatus,
|
||||
TransferAmountsByMatchOrders as TransferAmounts,
|
||||
TransferAmountsLoggedByMatchOrders as LoggedTransferAmounts,
|
||||
} from '@0x/contracts-test-utils';
|
||||
import { assetDataUtils, orderHashUtils } from '@0x/order-utils';
|
||||
import { AssetProxyId, SignedOrder } from '@0x/types';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
@ -6,18 +15,9 @@ import * as _ from 'lodash';
|
||||
|
||||
import { TransactionReceiptWithDecodedLogs } from '../../../../node_modules/ethereum-types';
|
||||
|
||||
import { chaiSetup } from './chai_setup';
|
||||
import { ERC20Wrapper } from './erc20_wrapper';
|
||||
import { ERC721Wrapper } from './erc721_wrapper';
|
||||
import { ExchangeWrapper } from './exchange_wrapper';
|
||||
import {
|
||||
ERC20BalancesByOwner,
|
||||
ERC721TokenIdsByOwner,
|
||||
OrderInfo,
|
||||
OrderStatus,
|
||||
TransferAmountsByMatchOrders as TransferAmounts,
|
||||
TransferAmountsLoggedByMatchOrders as LoggedTransferAmounts,
|
||||
} from './types';
|
||||
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
@ -270,18 +270,14 @@ export class MatchOrderTester {
|
||||
const leftExpectedStatus = expectedTransferAmounts.amountBoughtByLeftMaker.equals(maxAmountBoughtByLeftMaker)
|
||||
? OrderStatus.FULLY_FILLED
|
||||
: OrderStatus.FILLABLE;
|
||||
expect(leftOrderInfo.orderStatus as OrderStatus, 'Checking exchange status for left order').to.be.equal(
|
||||
leftExpectedStatus,
|
||||
);
|
||||
expect(leftOrderInfo.orderStatus, 'Checking exchange status for left order').to.be.equal(leftExpectedStatus);
|
||||
// Assert right order status
|
||||
const maxAmountBoughtByRightMaker = signedOrderRight.takerAssetAmount.minus(initialRightOrderFilledAmount);
|
||||
const rightOrderInfo: OrderInfo = await this._exchangeWrapper.getOrderInfoAsync(signedOrderRight);
|
||||
const rightExpectedStatus = expectedTransferAmounts.amountBoughtByRightMaker.equals(maxAmountBoughtByRightMaker)
|
||||
? OrderStatus.FULLY_FILLED
|
||||
: OrderStatus.FILLABLE;
|
||||
expect(rightOrderInfo.orderStatus as OrderStatus, 'Checking exchange status for right order').to.be.equal(
|
||||
rightExpectedStatus,
|
||||
);
|
||||
expect(rightOrderInfo.orderStatus, 'Checking exchange status for right order').to.be.equal(rightExpectedStatus);
|
||||
}
|
||||
/// @dev Asserts account balances after matching orders.
|
||||
/// @param signedOrderLeft First matched order.
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { LogDecoder } from '@0x/contracts-test-utils';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import { Provider, TransactionReceiptWithDecodedLogs } from 'ethereum-types';
|
||||
@ -5,8 +6,7 @@ import * as _ from 'lodash';
|
||||
|
||||
import { AssetProxyOwnerContract } from '../../generated-wrappers/asset_proxy_owner';
|
||||
import { MultiSigWalletContract } from '../../generated-wrappers/multi_sig_wallet';
|
||||
|
||||
import { LogDecoder } from './log_decoder';
|
||||
import { artifacts } from '../../src/artifacts';
|
||||
|
||||
export class MultiSigWrapper {
|
||||
private readonly _multiSig: MultiSigWalletContract;
|
||||
@ -15,7 +15,7 @@ export class MultiSigWrapper {
|
||||
constructor(multiSigContract: MultiSigWalletContract, provider: Provider) {
|
||||
this._multiSig = multiSigContract;
|
||||
this._web3Wrapper = new Web3Wrapper(provider);
|
||||
this._logDecoder = new LogDecoder(this._web3Wrapper);
|
||||
this._logDecoder = new LogDecoder(this._web3Wrapper, artifacts);
|
||||
}
|
||||
public async submitTransactionAsync(
|
||||
destination: string,
|
||||
|
@ -1,19 +1,18 @@
|
||||
import { assetDataUtils, generatePseudoRandomSalt } from '@0x/order-utils';
|
||||
import { Order } from '@0x/types';
|
||||
import { BigNumber, errorUtils } from '@0x/utils';
|
||||
|
||||
import { DummyERC721TokenContract } from '../../generated-wrappers/dummy_erc721_token';
|
||||
|
||||
import { constants } from './constants';
|
||||
import {
|
||||
AssetDataScenario,
|
||||
constants,
|
||||
ERC721TokenIdsByOwner,
|
||||
ExpirationTimeSecondsScenario,
|
||||
FeeRecipientAddressScenario,
|
||||
OrderAssetAmountScenario,
|
||||
OrderScenario,
|
||||
TakerScenario,
|
||||
} from './types';
|
||||
} from '@0x/contracts-test-utils';
|
||||
import { assetDataUtils, generatePseudoRandomSalt } from '@0x/order-utils';
|
||||
import { Order } from '@0x/types';
|
||||
import { BigNumber, errorUtils } from '@0x/utils';
|
||||
|
||||
import { DummyERC721TokenContract } from '../../generated-wrappers/dummy_erc721_token';
|
||||
|
||||
const TEN_UNITS_EIGHTEEN_DECIMALS = new BigNumber(10_000_000_000_000_000_000);
|
||||
const FIVE_UNITS_EIGHTEEN_DECIMALS = new BigNumber(5_000_000_000_000_000_000);
|
||||
|
20
contracts/multisig/.solhint.json
Normal file
20
contracts/multisig/.solhint.json
Normal file
@ -0,0 +1,20 @@
|
||||
{
|
||||
"extends": "default",
|
||||
"rules": {
|
||||
"avoid-low-level-calls": false,
|
||||
"avoid-tx-origin": "warn",
|
||||
"bracket-align": false,
|
||||
"code-complexity": false,
|
||||
"const-name-snakecase": "error",
|
||||
"expression-indent": "error",
|
||||
"function-max-lines": false,
|
||||
"func-order": "error",
|
||||
"indent": ["error", 4],
|
||||
"max-line-length": ["warn", 160],
|
||||
"no-inline-assembly": false,
|
||||
"quotes": ["error", "double"],
|
||||
"separate-by-one-line-in-contract": "error",
|
||||
"space-after-comma": "error",
|
||||
"statement-indent": "error"
|
||||
}
|
||||
}
|
3
contracts/multisig/.solhintignore
Normal file
3
contracts/multisig/.solhintignore
Normal file
@ -0,0 +1,3 @@
|
||||
contracts/tokens/ZRXToken/ERC20Token_v1.sol
|
||||
contracts/tokens/ZRXToken/Token_v1.sol
|
||||
contracts/tokens/ZRXToken/UnlimitedAllowanceToken_v1.sol
|
115
contracts/multisig/CHANGELOG.json
Normal file
115
contracts/multisig/CHANGELOG.json
Normal file
@ -0,0 +1,115 @@
|
||||
[
|
||||
{
|
||||
"name": "Forwarder",
|
||||
"version": "1.1.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Round up when calculating remaining amounts in marketBuy functions",
|
||||
"pr": 1162,
|
||||
"networks": {
|
||||
"1": "0x5468a1dc173652ee28d249c271fa9933144746b1",
|
||||
"3": "0x2240dab907db71e64d3e0dba4800c83b5c502d4e",
|
||||
"42": "0x17992e4ffb22730138e4b62aaa6367fa9d3699a6"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Forwarder",
|
||||
"version": "1.0.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "protocol v2 deploy",
|
||||
"networks": {
|
||||
"1": "0x7afc2d5107af94c462a194d2c21b5bdd238709d6",
|
||||
"3": "0x3983e204b12b3c02fb0638caf2cd406a62e0ead3",
|
||||
"42": "0xd85e2fa7e7e252b27b01bf0d65c946959d2f45b8"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "OrderValidator",
|
||||
"version": "1.0.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "protocol v2 deploy",
|
||||
"networks": {
|
||||
"1": "0x9463e518dea6810309563c81d5266c1b1d149138",
|
||||
"3": "0x90431a90516ab49af23a0530e04e8c7836e7122f",
|
||||
"42": "0xb389da3d204b412df2f75c6afb3d0a7ce0bc283d"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Exchange",
|
||||
"version": "2.0.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "protocol v2 deploy",
|
||||
"networks": {
|
||||
"1": "0x4f833a24e1f95d70f028921e27040ca56e09ab0b",
|
||||
"3": "0x4530c0483a1633c7a1c97d2c53721caff2caaaaf",
|
||||
"42": "0x35dd2932454449b14cee11a94d3674a936d5d7b2"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "ERC20Proxy",
|
||||
"version": "1.0.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "protocol v2 deploy",
|
||||
"networks": {
|
||||
"1": "0x2240dab907db71e64d3e0dba4800c83b5c502d4e",
|
||||
"3": "0xb1408f4c245a23c31b98d2c626777d4c0d766caa",
|
||||
"42": "0xf1ec01d6236d3cd881a0bf0130ea25fe4234003e"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "ERC721Proxy",
|
||||
"version": "1.0.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "protocol v2 deploy",
|
||||
"networks": {
|
||||
"1": "0x208e41fb445f1bb1b6780d58356e81405f3e6127",
|
||||
"3": "0xe654aac058bfbf9f83fcaee7793311dd82f6ddb4",
|
||||
"42": "0x2a9127c745688a165106c11cd4d647d2220af821"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "AssetProxyOwner",
|
||||
"version": "1.0.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "protocol v2 deploy",
|
||||
"networks": {
|
||||
"1": "0x17992e4ffb22730138e4b62aaa6367fa9d3699a6",
|
||||
"3": "0xf5fa5b5fed2727a0e44ac67f6772e97977aa358b",
|
||||
"42": "0x2c824d2882baa668e0d5202b1e7f2922278703f8"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "ZRXToken",
|
||||
"version": "1.0.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "protocol v1 deploy",
|
||||
"networks": {
|
||||
"1": "0xe41d2489571d322189246dafa5ebde1f4699f498",
|
||||
"3": "0xff67881f8d12f372d91baae9752eb3631ff0ed00",
|
||||
"42": "0x2002d3812f58e35f0ea1ffbf80a75a38c32175fa"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
129
contracts/multisig/README.md
Normal file
129
contracts/multisig/README.md
Normal file
@ -0,0 +1,129 @@
|
||||
## Contracts
|
||||
|
||||
Smart contracts that implement the 0x protocol. Addresses of the deployed contracts can be found in the 0x [wiki](https://0xproject.com/wiki#Deployed-Addresses) or the [CHANGELOG](./CHANGELOG.json) of this package.
|
||||
|
||||
## Usage
|
||||
|
||||
Contracts that make up and interact with version 2.0.0 of the protocol can be found in the [contracts](./contracts) directory. The contents of this directory are broken down into the following subdirectories:
|
||||
|
||||
* [protocol](./contracts/protocol)
|
||||
* This directory contains the contracts that make up version 2.0.0. A full specification can be found [here](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md).
|
||||
* [extensions](./contracts/extensions)
|
||||
* This directory contains contracts that interact with the 2.0.0 contracts and will be used in production, such as the [Forwarder](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/forwarder-specification.md) contract.
|
||||
* [examples](./contracts/examples)
|
||||
* This directory contains example implementations of contracts that interact with the protocol but are _not_ intended for use in production. Examples include [filter](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#filter-contracts) contracts, a [Wallet](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#wallet) contract, and a [Validator](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#validator) contract, among others.
|
||||
* [tokens](./contracts/tokens)
|
||||
* This directory contains implementations of different tokens and token standards, including [wETH](https://weth.io/), ZRX, [ERC20](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md), and [ERC721](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md).
|
||||
* [multisig](./contracts/multisig)
|
||||
* This directory contains the [Gnosis MultiSigWallet](https://github.com/gnosis/MultiSigWallet) and a custom extension that adds a timelock to transactions within the MultiSigWallet.
|
||||
* [utils](./contracts/utils)
|
||||
* This directory contains libraries and utils that are shared across all of the other directories.
|
||||
* [test](./contracts/test)
|
||||
* This directory contains mocks and other contracts that are used solely for testing contracts within the other directories.
|
||||
|
||||
## Bug bounty
|
||||
|
||||
A bug bounty for the 2.0.0 contracts is ongoing! Instructions can be found [here](https://0xproject.com/wiki#Bug-Bounty).
|
||||
|
||||
## Contributing
|
||||
|
||||
We strongly recommend that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository.
|
||||
|
||||
For proposals regarding the 0x protocol's smart contract architecture, message format, or additional functionality, go to the [0x Improvement Proposals (ZEIPs)](https://github.com/0xProject/ZEIPs) repository and follow the contribution guidelines provided therein.
|
||||
|
||||
Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started.
|
||||
|
||||
### Install Dependencies
|
||||
|
||||
If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them:
|
||||
|
||||
```bash
|
||||
yarn config set workspaces-experimental true
|
||||
```
|
||||
|
||||
Then install dependencies
|
||||
|
||||
```bash
|
||||
yarn install
|
||||
```
|
||||
|
||||
### Build
|
||||
|
||||
To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory:
|
||||
|
||||
```bash
|
||||
PKG=contracts yarn build
|
||||
```
|
||||
|
||||
Or continuously rebuild on change:
|
||||
|
||||
```bash
|
||||
PKG=contracts yarn watch
|
||||
```
|
||||
|
||||
### Clean
|
||||
|
||||
```bash
|
||||
yarn clean
|
||||
```
|
||||
|
||||
### Lint
|
||||
|
||||
```bash
|
||||
yarn lint
|
||||
```
|
||||
|
||||
### Run Tests
|
||||
|
||||
```bash
|
||||
yarn test
|
||||
```
|
||||
|
||||
#### Testing options
|
||||
|
||||
###### Revert stack traces
|
||||
|
||||
If you want to see helpful stack traces (incl. line number, code snippet) for smart contract reverts, run the tests with:
|
||||
|
||||
```
|
||||
yarn test:trace
|
||||
```
|
||||
|
||||
**Note:** This currently slows down the test runs and is therefore not enabled by default.
|
||||
|
||||
###### Backing Ethereum node
|
||||
|
||||
By default, our tests run against an in-process [Ganache](https://github.com/trufflesuite/ganache-core) instance. In order to run the tests against [Geth](https://github.com/ethereum/go-ethereum), first follow the instructions in the README for the devnet package to start the devnet Geth node. Then run:
|
||||
|
||||
```bash
|
||||
TEST_PROVIDER=geth yarn test
|
||||
```
|
||||
|
||||
###### Code coverage
|
||||
|
||||
In order to see the Solidity code coverage output generated by `@0x/sol-cov`, run:
|
||||
|
||||
```
|
||||
yarn test:coverage
|
||||
```
|
||||
|
||||
###### Gas profiler
|
||||
|
||||
In order to profile the gas costs for a specific smart contract call/transaction, you can run the tests in `profiler` mode.
|
||||
|
||||
**Note:** Traces emitted by ganache have incorrect gas costs so we recommend using Geth for profiling.
|
||||
|
||||
```
|
||||
TEST_PROVIDER=geth yarn test:profiler
|
||||
```
|
||||
|
||||
You'll see a warning that you need to explicitly enable and disable the profiler before and after the block of code you want to profile.
|
||||
|
||||
```typescript
|
||||
import { profiler } from './utils/profiler';
|
||||
profiler.start();
|
||||
// Some call to a smart contract
|
||||
profiler.stop();
|
||||
```
|
||||
|
||||
Without explicitly starting and stopping the profiler, the profiler output will be too busy, and therefore unusable.
|
22
contracts/multisig/compiler.json
Normal file
22
contracts/multisig/compiler.json
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"artifactsDir": "./generated-artifacts",
|
||||
"contractsDir": "./contracts",
|
||||
"compilerSettings": {
|
||||
"optimizer": {
|
||||
"enabled": true,
|
||||
"runs": 1000000
|
||||
},
|
||||
"outputSelection": {
|
||||
"*": {
|
||||
"*": [
|
||||
"abi",
|
||||
"evm.bytecode.object",
|
||||
"evm.bytecode.sourceMap",
|
||||
"evm.deployedBytecode.object",
|
||||
"evm.deployedBytecode.sourceMap"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"contracts": ["MultiSigWallet", "MultiSigWalletWithTimeLock", "TestRejectEther"]
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
/*
|
||||
|
||||
Copyright 2018 ZeroEx Intl.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity 0.4.24;
|
||||
|
||||
|
||||
// solhint-disable no-empty-blocks
|
||||
contract TestRejectEther {}
|
591
contracts/multisig/generated-artifacts/MultiSigWallet.json
Normal file
591
contracts/multisig/generated-artifacts/MultiSigWallet.json
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
57
contracts/multisig/generated-artifacts/TestRejectEther.json
Normal file
57
contracts/multisig/generated-artifacts/TestRejectEther.json
Normal file
@ -0,0 +1,57 @@
|
||||
{
|
||||
"schemaVersion": "2.0.0",
|
||||
"contractName": "TestRejectEther",
|
||||
"compilerOutput": {
|
||||
"abi": [],
|
||||
"evm": {
|
||||
"bytecode": {
|
||||
"linkReferences": {},
|
||||
"object":
|
||||
"0x6080604052348015600f57600080fd5b50603580601d6000396000f3006080604052600080fd00a165627a7a72305820ea424ee6408dea2ac74e33b10a7b68bf90463703a311d5c1b7186f81ccf0775c0029",
|
||||
"opcodes":
|
||||
"PUSH1 0x80 PUSH1 0x40 MSTORE CALLVALUE DUP1 ISZERO PUSH1 0xF JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH1 0x35 DUP1 PUSH1 0x1D PUSH1 0x0 CODECOPY PUSH1 0x0 RETURN STOP PUSH1 0x80 PUSH1 0x40 MSTORE PUSH1 0x0 DUP1 REVERT STOP LOG1 PUSH6 0x627A7A723058 KECCAK256 0xea TIMESTAMP 0x4e 0xe6 BLOCKHASH DUP14 0xea 0x2a 0xc7 0x4e CALLER 0xb1 EXP PUSH28 0x68BF90463703A311D5C1B7186F81CCF0775C00290000000000000000 ",
|
||||
"sourceMap": "641:27:2:-;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;641:27:2;;;;;;;"
|
||||
},
|
||||
"deployedBytecode": {
|
||||
"linkReferences": {},
|
||||
"object":
|
||||
"0x6080604052600080fd00a165627a7a72305820ea424ee6408dea2ac74e33b10a7b68bf90463703a311d5c1b7186f81ccf0775c0029",
|
||||
"opcodes":
|
||||
"PUSH1 0x80 PUSH1 0x40 MSTORE PUSH1 0x0 DUP1 REVERT STOP LOG1 PUSH6 0x627A7A723058 KECCAK256 0xea TIMESTAMP 0x4e 0xe6 BLOCKHASH DUP14 0xea 0x2a 0xc7 0x4e CALLER 0xb1 EXP PUSH28 0x68BF90463703A311D5C1B7186F81CCF0775C00290000000000000000 ",
|
||||
"sourceMap": "641:27:2:-;;;;;"
|
||||
}
|
||||
}
|
||||
},
|
||||
"sources": {
|
||||
"test/TestRejectEther/TestRejectEther.sol": {
|
||||
"id": 2
|
||||
}
|
||||
},
|
||||
"sourceCodes": {
|
||||
"test/TestRejectEther/TestRejectEther.sol":
|
||||
"/*\n\n Copyright 2018 ZeroEx Intl.\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\n\n\n// solhint-disable no-empty-blocks\ncontract TestRejectEther {}\n"
|
||||
},
|
||||
"sourceTreeHashHex": "0xad117870d1c81a5a5082749d69414a6a80cfd9fc0d7ed2a73c506e84c6e7ddaf",
|
||||
"compiler": {
|
||||
"name": "solc",
|
||||
"version": "soljson-v0.4.24+commit.e67f0147.js",
|
||||
"settings": {
|
||||
"optimizer": {
|
||||
"enabled": true,
|
||||
"runs": 1000000
|
||||
},
|
||||
"outputSelection": {
|
||||
"*": {
|
||||
"*": [
|
||||
"abi",
|
||||
"evm.bytecode.object",
|
||||
"evm.bytecode.sourceMap",
|
||||
"evm.deployedBytecode.object",
|
||||
"evm.deployedBytecode.sourceMap"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"networks": {}
|
||||
}
|
1449
contracts/multisig/generated-wrappers/multi_sig_wallet.ts
Normal file
1449
contracts/multisig/generated-wrappers/multi_sig_wallet.ts
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
75
contracts/multisig/generated-wrappers/test_reject_ether.ts
Normal file
75
contracts/multisig/generated-wrappers/test_reject_ether.ts
Normal file
@ -0,0 +1,75 @@
|
||||
// tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma whitespace class-name
|
||||
// tslint:disable:no-unused-variable
|
||||
// tslint:disable:no-unbound-method
|
||||
import { BaseContract } from '@0x/base-contract';
|
||||
import {
|
||||
BlockParam,
|
||||
BlockParamLiteral,
|
||||
CallData,
|
||||
ContractAbi,
|
||||
ContractArtifact,
|
||||
DecodedLogArgs,
|
||||
MethodAbi,
|
||||
Provider,
|
||||
TxData,
|
||||
TxDataPayable,
|
||||
} from 'ethereum-types';
|
||||
import { BigNumber, classUtils, logUtils } from '@0x/utils';
|
||||
import { SimpleContractArtifact } from '@0x/types';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import * as ethers from 'ethers';
|
||||
import * as _ from 'lodash';
|
||||
// tslint:enable:no-unused-variable
|
||||
|
||||
/* istanbul ignore next */
|
||||
// tslint:disable:no-parameter-reassignment
|
||||
// tslint:disable-next-line:class-name
|
||||
export class TestRejectEtherContract extends BaseContract {
|
||||
public static async deployFrom0xArtifactAsync(
|
||||
artifact: ContractArtifact | SimpleContractArtifact,
|
||||
provider: Provider,
|
||||
txDefaults: Partial<TxData>,
|
||||
): Promise<TestRejectEtherContract> {
|
||||
if (_.isUndefined(artifact.compilerOutput)) {
|
||||
throw new Error('Compiler output not found in the artifact file');
|
||||
}
|
||||
const bytecode = artifact.compilerOutput.evm.bytecode.object;
|
||||
const abi = artifact.compilerOutput.abi;
|
||||
return TestRejectEtherContract.deployAsync(bytecode, abi, provider, txDefaults);
|
||||
}
|
||||
public static async deployAsync(
|
||||
bytecode: string,
|
||||
abi: ContractAbi,
|
||||
provider: Provider,
|
||||
txDefaults: Partial<TxData>,
|
||||
): Promise<TestRejectEtherContract> {
|
||||
const constructorAbi = BaseContract._lookupConstructorAbi(abi);
|
||||
[] = BaseContract._formatABIDataItemList(constructorAbi.inputs, [], BaseContract._bigNumberToString);
|
||||
const iface = new ethers.utils.Interface(abi);
|
||||
const deployInfo = iface.deployFunction;
|
||||
const txData = deployInfo.encode(bytecode, []);
|
||||
const web3Wrapper = new Web3Wrapper(provider);
|
||||
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||
{ data: txData },
|
||||
txDefaults,
|
||||
web3Wrapper.estimateGasAsync.bind(web3Wrapper),
|
||||
);
|
||||
const txHash = await web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||
logUtils.log(`transactionHash: ${txHash}`);
|
||||
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
|
||||
logUtils.log(`TestRejectEther successfully deployed at ${txReceipt.contractAddress}`);
|
||||
const contractInstance = new TestRejectEtherContract(
|
||||
abi,
|
||||
txReceipt.contractAddress as string,
|
||||
provider,
|
||||
txDefaults,
|
||||
);
|
||||
contractInstance.constructorArgs = [];
|
||||
return contractInstance;
|
||||
}
|
||||
constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) {
|
||||
super('TestRejectEther', abi, address, provider, txDefaults);
|
||||
classUtils.bindAll(this, ['_ethersInterfacesByFunctionSignature', 'address', 'abi', '_web3Wrapper']);
|
||||
}
|
||||
} // tslint:disable:max-file-line-count
|
||||
// tslint:enable:no-unbound-method
|
93
contracts/multisig/package.json
Normal file
93
contracts/multisig/package.json
Normal file
@ -0,0 +1,93 @@
|
||||
{
|
||||
"private": true,
|
||||
"name": "@0x/contracts-multisig",
|
||||
"version": "1.0.0",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
"description": "Smart contract components of 0x protocol",
|
||||
"main": "lib/src/index.js",
|
||||
"directories": {
|
||||
"test": "test"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "yarn pre_build && tsc -b",
|
||||
"build:ci": "yarn build",
|
||||
"pre_build": "run-s compile generate_contract_wrappers",
|
||||
"test": "yarn run_mocha",
|
||||
"rebuild_and_test": "run-s build test",
|
||||
"test:coverage": "SOLIDITY_COVERAGE=true run-s build run_mocha coverage:report:text coverage:report:lcov",
|
||||
"test:profiler": "SOLIDITY_PROFILER=true run-s build run_mocha profiler:report:html",
|
||||
"test:trace": "SOLIDITY_REVERT_TRACE=true run-s build run_mocha",
|
||||
"run_mocha": "mocha --require source-map-support/register --require make-promises-safe 'lib/test/**/*.js' --timeout 100000 --bail --exit",
|
||||
"compile": "sol-compiler --contracts-dir contracts",
|
||||
"clean": "shx rm -rf lib generated-artifacts generated-wrappers",
|
||||
"generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --template ../../packages/contract_templates/contract.handlebars --partials '../../packages/contract_templates/partials/**/*.handlebars' --output generated-wrappers --backend ethers",
|
||||
"lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
||||
"coverage:report:text": "istanbul report text",
|
||||
"coverage:report:html": "istanbul report html && open coverage/index.html",
|
||||
"profiler:report:html": "istanbul report html && open coverage/index.html",
|
||||
"coverage:report:lcov": "istanbul report lcov",
|
||||
"test:circleci": "yarn test",
|
||||
"lint-contracts": "solhint contracts/**/**/**/**/*.sol"
|
||||
},
|
||||
"config": {
|
||||
"abis": "generated-artifacts/@(MultiSigWallet|MultiSigWalletWithTimeLock|TestRejectEther).json"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/0xProject/0x-monorepo.git"
|
||||
},
|
||||
"author": "Amir Bandeali",
|
||||
"license": "Apache-2.0",
|
||||
"bugs": {
|
||||
"url": "https://github.com/0xProject/0x-monorepo/issues"
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/core/README.md",
|
||||
"devDependencies": {
|
||||
"@0x/contracts-test-utils": "^1.0.0",
|
||||
"@0x/abi-gen": "^1.0.17",
|
||||
"@0x/dev-utils": "^1.0.18",
|
||||
"@0x/sol-compiler": "^1.1.13",
|
||||
"@0x/sol-cov": "^2.1.13",
|
||||
"@0x/subproviders": "^2.1.5",
|
||||
"@0x/tslint-config": "^1.0.10",
|
||||
"@types/bn.js": "^4.11.0",
|
||||
"@types/ethereumjs-abi": "^0.6.0",
|
||||
"@types/lodash": "4.14.104",
|
||||
"@types/node": "*",
|
||||
"@types/yargs": "^10.0.0",
|
||||
"chai": "^4.0.1",
|
||||
"chai-as-promised": "^7.1.0",
|
||||
"chai-bignumber": "^2.0.1",
|
||||
"dirty-chai": "^2.0.1",
|
||||
"make-promises-safe": "^1.1.0",
|
||||
"mocha": "^4.1.0",
|
||||
"npm-run-all": "^4.1.2",
|
||||
"shx": "^0.2.2",
|
||||
"solc": "^0.4.24",
|
||||
"solhint": "^1.2.1",
|
||||
"tslint": "5.11.0",
|
||||
"typescript": "3.0.1",
|
||||
"yargs": "^10.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0x/base-contract": "^3.0.7",
|
||||
"@0x/order-utils": "^3.0.3",
|
||||
"@0x/types": "^1.3.0",
|
||||
"@0x/typescript-typings": "^3.0.4",
|
||||
"@0x/utils": "^2.0.6",
|
||||
"@0x/web3-wrapper": "^3.1.5",
|
||||
"@types/js-combinatorics": "^0.5.29",
|
||||
"bn.js": "^4.11.8",
|
||||
"ethereum-types": "^1.1.2",
|
||||
"ethereumjs-abi": "0.6.5",
|
||||
"ethereumjs-util": "^5.1.1",
|
||||
"ethers": "~4.0.4",
|
||||
"js-combinatorics": "^0.5.3",
|
||||
"lodash": "^4.17.5"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
}
|
||||
}
|
11
contracts/multisig/src/artifacts/index.ts
Normal file
11
contracts/multisig/src/artifacts/index.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import { ContractArtifact } from 'ethereum-types';
|
||||
|
||||
import * as MultiSigWallet from '../../generated-artifacts/MultiSigWallet.json';
|
||||
import * as MultiSigWalletWithTimeLock from '../../generated-artifacts/MultiSigWalletWithTimeLock.json';
|
||||
import * as TestRejectEther from '../../generated-artifacts/TestRejectEther.json';
|
||||
|
||||
export const artifacts = {
|
||||
TestRejectEther: TestRejectEther as ContractArtifact,
|
||||
MultiSigWallet: MultiSigWallet as ContractArtifact,
|
||||
MultiSigWalletWithTimeLock: MultiSigWalletWithTimeLock as ContractArtifact,
|
||||
};
|
2
contracts/multisig/src/wrappers/index.ts
Normal file
2
contracts/multisig/src/wrappers/index.ts
Normal file
@ -0,0 +1,2 @@
|
||||
export * from '../../generated-wrappers/multi_sig_wallet';
|
||||
export * from '../../generated-wrappers/multi_sig_wallet_with_time_lock';
|
@ -1,3 +1,13 @@
|
||||
import {
|
||||
chaiSetup,
|
||||
constants,
|
||||
expectTransactionFailedAsync,
|
||||
expectTransactionFailedWithoutReasonAsync,
|
||||
increaseTimeAndMineBlockAsync,
|
||||
provider,
|
||||
txDefaults,
|
||||
web3Wrapper,
|
||||
} from '@0x/contracts-test-utils';
|
||||
import { BlockchainLifecycle } from '@0x/dev-utils';
|
||||
import { RevertReason } from '@0x/types';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
@ -5,7 +15,6 @@ import * as chai from 'chai';
|
||||
import { LogWithDecodedArgs } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { DummyERC20TokenContract } from '../../generated-wrappers/dummy_erc20_token';
|
||||
import {
|
||||
MultiSigWalletWithTimeLockConfirmationEventArgs,
|
||||
MultiSigWalletWithTimeLockConfirmationTimeSetEventArgs,
|
||||
@ -13,14 +22,11 @@ import {
|
||||
MultiSigWalletWithTimeLockExecutionEventArgs,
|
||||
MultiSigWalletWithTimeLockExecutionFailureEventArgs,
|
||||
MultiSigWalletWithTimeLockSubmissionEventArgs,
|
||||
} from '../../generated-wrappers/multi_sig_wallet_with_time_lock';
|
||||
import { artifacts } from '../../src/artifacts';
|
||||
import { expectTransactionFailedAsync, expectTransactionFailedWithoutReasonAsync } from '../utils/assertions';
|
||||
import { increaseTimeAndMineBlockAsync } from '../utils/block_timestamp';
|
||||
import { chaiSetup } from '../utils/chai_setup';
|
||||
import { constants } from '../utils/constants';
|
||||
import { MultiSigWrapper } from '../utils/multi_sig_wrapper';
|
||||
import { provider, txDefaults, web3Wrapper } from '../utils/web3_wrapper';
|
||||
} from '../generated-wrappers/multi_sig_wallet_with_time_lock';
|
||||
import { TestRejectEtherContract } from '../generated-wrappers/test_reject_ether';
|
||||
import { artifacts } from '../src/artifacts';
|
||||
|
||||
import { MultiSigWrapper } from './utils/multi_sig_wrapper';
|
||||
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
@ -189,14 +195,10 @@ describe('MultiSigWalletWithTimeLock', () => {
|
||||
await expectTransactionFailedWithoutReasonAsync(multiSigWrapper.executeTransactionAsync(txId, owners[1]));
|
||||
});
|
||||
it("should log an ExecutionFailure event and not update the transaction's execution state if unsuccessful", async () => {
|
||||
const contractWithoutFallback = await DummyERC20TokenContract.deployFrom0xArtifactAsync(
|
||||
artifacts.DummyERC20Token,
|
||||
const contractWithoutFallback = await TestRejectEtherContract.deployFrom0xArtifactAsync(
|
||||
artifacts.TestRejectEther,
|
||||
provider,
|
||||
txDefaults,
|
||||
constants.DUMMY_TOKEN_NAME,
|
||||
constants.DUMMY_TOKEN_SYMBOL,
|
||||
constants.DUMMY_TOKEN_DECIMALS,
|
||||
constants.DUMMY_TOKEN_TOTAL_SUPPLY,
|
||||
);
|
||||
const data = constants.NULL_BYTES;
|
||||
const value = new BigNumber(10);
|
54
contracts/multisig/test/utils/multi_sig_wrapper.ts
Normal file
54
contracts/multisig/test/utils/multi_sig_wrapper.ts
Normal file
@ -0,0 +1,54 @@
|
||||
import { LogDecoder } from '@0x/contracts-test-utils';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import { Provider, TransactionReceiptWithDecodedLogs } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { MultiSigWalletContract } from '../../generated-wrappers/multi_sig_wallet';
|
||||
import { artifacts } from '../../src/artifacts';
|
||||
|
||||
export class MultiSigWrapper {
|
||||
private readonly _multiSig: MultiSigWalletContract;
|
||||
private readonly _web3Wrapper: Web3Wrapper;
|
||||
private readonly _logDecoder: LogDecoder;
|
||||
constructor(multiSigContract: MultiSigWalletContract, provider: Provider) {
|
||||
this._multiSig = multiSigContract;
|
||||
this._web3Wrapper = new Web3Wrapper(provider);
|
||||
this._logDecoder = new LogDecoder(this._web3Wrapper, artifacts);
|
||||
}
|
||||
public async submitTransactionAsync(
|
||||
destination: string,
|
||||
data: string,
|
||||
from: string,
|
||||
opts: { value?: BigNumber } = {},
|
||||
): Promise<TransactionReceiptWithDecodedLogs> {
|
||||
const value = _.isUndefined(opts.value) ? new BigNumber(0) : opts.value;
|
||||
const txHash = await this._multiSig.submitTransaction.sendTransactionAsync(destination, value, data, {
|
||||
from,
|
||||
});
|
||||
const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
|
||||
return tx;
|
||||
}
|
||||
public async confirmTransactionAsync(txId: BigNumber, from: string): Promise<TransactionReceiptWithDecodedLogs> {
|
||||
const txHash = await this._multiSig.confirmTransaction.sendTransactionAsync(txId, { from });
|
||||
const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
|
||||
return tx;
|
||||
}
|
||||
public async revokeConfirmationAsync(txId: BigNumber, from: string): Promise<TransactionReceiptWithDecodedLogs> {
|
||||
const txHash = await this._multiSig.revokeConfirmation.sendTransactionAsync(txId, { from });
|
||||
const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
|
||||
return tx;
|
||||
}
|
||||
public async executeTransactionAsync(
|
||||
txId: BigNumber,
|
||||
from: string,
|
||||
opts: { gas?: number } = {},
|
||||
): Promise<TransactionReceiptWithDecodedLogs> {
|
||||
const txHash = await this._multiSig.executeTransaction.sendTransactionAsync(txId, {
|
||||
from,
|
||||
gas: opts.gas,
|
||||
});
|
||||
const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
|
||||
return tx;
|
||||
}
|
||||
}
|
15
contracts/multisig/tsconfig.json
Normal file
15
contracts/multisig/tsconfig.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"extends": "../../tsconfig",
|
||||
"compilerOptions": {
|
||||
"outDir": "lib",
|
||||
"rootDir": ".",
|
||||
"resolveJsonModule": true
|
||||
},
|
||||
"include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*"],
|
||||
"files": [
|
||||
"./generated-artifacts/MultiSigWallet.json",
|
||||
"./generated-artifacts/MultiSigWalletWithTimeLock.json",
|
||||
"./generated-artifacts/TestRejectEther.json"
|
||||
],
|
||||
"exclude": ["./deploy/solc/solc_bin"]
|
||||
}
|
6
contracts/multisig/tslint.json
Normal file
6
contracts/multisig/tslint.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"extends": ["@0x/tslint-config"],
|
||||
"rules": {
|
||||
"custom-no-magic-numbers": false
|
||||
}
|
||||
}
|
1
contracts/test-utils/CHANGELOG.json
Normal file
1
contracts/test-utils/CHANGELOG.json
Normal file
@ -0,0 +1 @@
|
||||
[]
|
129
contracts/test-utils/README.md
Normal file
129
contracts/test-utils/README.md
Normal file
@ -0,0 +1,129 @@
|
||||
## Contracts
|
||||
|
||||
Smart contracts that implement the 0x protocol. Addresses of the deployed contracts can be found in the 0x [wiki](https://0xproject.com/wiki#Deployed-Addresses) or the [CHANGELOG](./CHANGELOG.json) of this package.
|
||||
|
||||
## Usage
|
||||
|
||||
Contracts that make up and interact with version 2.0.0 of the protocol can be found in the [contracts](./contracts) directory. The contents of this directory are broken down into the following subdirectories:
|
||||
|
||||
* [protocol](./contracts/protocol)
|
||||
* This directory contains the contracts that make up version 2.0.0. A full specification can be found [here](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md).
|
||||
* [extensions](./contracts/extensions)
|
||||
* This directory contains contracts that interact with the 2.0.0 contracts and will be used in production, such as the [Forwarder](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/forwarder-specification.md) contract.
|
||||
* [examples](./contracts/examples)
|
||||
* This directory contains example implementations of contracts that interact with the protocol but are _not_ intended for use in production. Examples include [filter](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#filter-contracts) contracts, a [Wallet](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#wallet) contract, and a [Validator](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#validator) contract, among others.
|
||||
* [tokens](./contracts/tokens)
|
||||
* This directory contains implementations of different tokens and token standards, including [wETH](https://weth.io/), ZRX, [ERC20](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md), and [ERC721](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md).
|
||||
* [multisig](./contracts/multisig)
|
||||
* This directory contains the [Gnosis MultiSigWallet](https://github.com/gnosis/MultiSigWallet) and a custom extension that adds a timelock to transactions within the MultiSigWallet.
|
||||
* [utils](./contracts/utils)
|
||||
* This directory contains libraries and utils that are shared across all of the other directories.
|
||||
* [test](./contracts/test)
|
||||
* This directory contains mocks and other contracts that are used solely for testing contracts within the other directories.
|
||||
|
||||
## Bug bounty
|
||||
|
||||
A bug bounty for the 2.0.0 contracts is ongoing! Instructions can be found [here](https://0xproject.com/wiki#Bug-Bounty).
|
||||
|
||||
## Contributing
|
||||
|
||||
We strongly recommend that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository.
|
||||
|
||||
For proposals regarding the 0x protocol's smart contract architecture, message format, or additional functionality, go to the [0x Improvement Proposals (ZEIPs)](https://github.com/0xProject/ZEIPs) repository and follow the contribution guidelines provided therein.
|
||||
|
||||
Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started.
|
||||
|
||||
### Install Dependencies
|
||||
|
||||
If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them:
|
||||
|
||||
```bash
|
||||
yarn config set workspaces-experimental true
|
||||
```
|
||||
|
||||
Then install dependencies
|
||||
|
||||
```bash
|
||||
yarn install
|
||||
```
|
||||
|
||||
### Build
|
||||
|
||||
To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory:
|
||||
|
||||
```bash
|
||||
PKG=contracts yarn build
|
||||
```
|
||||
|
||||
Or continuously rebuild on change:
|
||||
|
||||
```bash
|
||||
PKG=contracts yarn watch
|
||||
```
|
||||
|
||||
### Clean
|
||||
|
||||
```bash
|
||||
yarn clean
|
||||
```
|
||||
|
||||
### Lint
|
||||
|
||||
```bash
|
||||
yarn lint
|
||||
```
|
||||
|
||||
### Run Tests
|
||||
|
||||
```bash
|
||||
yarn test
|
||||
```
|
||||
|
||||
#### Testing options
|
||||
|
||||
###### Revert stack traces
|
||||
|
||||
If you want to see helpful stack traces (incl. line number, code snippet) for smart contract reverts, run the tests with:
|
||||
|
||||
```
|
||||
yarn test:trace
|
||||
```
|
||||
|
||||
**Note:** This currently slows down the test runs and is therefore not enabled by default.
|
||||
|
||||
###### Backing Ethereum node
|
||||
|
||||
By default, our tests run against an in-process [Ganache](https://github.com/trufflesuite/ganache-core) instance. In order to run the tests against [Geth](https://github.com/ethereum/go-ethereum), first follow the instructions in the README for the devnet package to start the devnet Geth node. Then run:
|
||||
|
||||
```bash
|
||||
TEST_PROVIDER=geth yarn test
|
||||
```
|
||||
|
||||
###### Code coverage
|
||||
|
||||
In order to see the Solidity code coverage output generated by `@0x/sol-cov`, run:
|
||||
|
||||
```
|
||||
yarn test:coverage
|
||||
```
|
||||
|
||||
###### Gas profiler
|
||||
|
||||
In order to profile the gas costs for a specific smart contract call/transaction, you can run the tests in `profiler` mode.
|
||||
|
||||
**Note:** Traces emitted by ganache have incorrect gas costs so we recommend using Geth for profiling.
|
||||
|
||||
```
|
||||
TEST_PROVIDER=geth yarn test:profiler
|
||||
```
|
||||
|
||||
You'll see a warning that you need to explicitly enable and disable the profiler before and after the block of code you want to profile.
|
||||
|
||||
```typescript
|
||||
import { profiler } from './utils/profiler';
|
||||
profiler.start();
|
||||
// Some call to a smart contract
|
||||
profiler.stop();
|
||||
```
|
||||
|
||||
Without explicitly starting and stopping the profiler, the profiler output will be too busy, and therefore unusable.
|
76
contracts/test-utils/package.json
Normal file
76
contracts/test-utils/package.json
Normal file
@ -0,0 +1,76 @@
|
||||
{
|
||||
"name": "@0x/contracts-test-utils",
|
||||
"version": "1.0.0",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
"description": "Test utils for 0x contracts",
|
||||
"main": "lib/src/index.js",
|
||||
"directories": {
|
||||
"test": "test"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc -b",
|
||||
"build:ci": "yarn build",
|
||||
"test": "yarn run_mocha",
|
||||
"test:coverage": "run-s build run_mocha coverage:report:text coverage:report:lcov",
|
||||
"run_mocha": "mocha --require source-map-support/register --require make-promises-safe 'lib/test/**/*.js' --timeout 100000 --bail --exit",
|
||||
"clean": "shx rm -rf lib",
|
||||
"lint": "tslint --format stylish --project .",
|
||||
"coverage:report:text": "istanbul report text",
|
||||
"coverage:report:html": "istanbul report html && open coverage/index.html",
|
||||
"profiler:report:html": "istanbul report html && open coverage/index.html",
|
||||
"coverage:report:lcov": "istanbul report lcov",
|
||||
"test:circleci": "yarn test"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/0xProject/0x-monorepo.git"
|
||||
},
|
||||
"author": "Amir Bandeali",
|
||||
"license": "Apache-2.0",
|
||||
"bugs": {
|
||||
"url": "https://github.com/0xProject/0x-monorepo/issues"
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/test-utils/README.md",
|
||||
"devDependencies": {
|
||||
"@0x/abi-gen": "^1.0.17",
|
||||
"@0x/dev-utils": "^1.0.18",
|
||||
"@0x/sol-compiler": "^1.1.13",
|
||||
"@0x/sol-cov": "^2.1.13",
|
||||
"@0x/subproviders": "^2.1.5",
|
||||
"@0x/tslint-config": "^1.0.10",
|
||||
"@types/bn.js": "^4.11.0",
|
||||
"@types/ethereumjs-abi": "^0.6.0",
|
||||
"@types/lodash": "4.14.104",
|
||||
"@types/node": "*",
|
||||
"chai": "^4.0.1",
|
||||
"chai-as-promised": "^7.1.0",
|
||||
"chai-bignumber": "^2.0.1",
|
||||
"dirty-chai": "^2.0.1",
|
||||
"make-promises-safe": "^1.1.0",
|
||||
"mocha": "^4.1.0",
|
||||
"npm-run-all": "^4.1.2",
|
||||
"shx": "^0.2.2",
|
||||
"tslint": "5.11.0",
|
||||
"typescript": "3.0.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0x/order-utils": "^3.0.3",
|
||||
"@0x/types": "^1.3.0",
|
||||
"@0x/typescript-typings": "^3.0.4",
|
||||
"@0x/utils": "^2.0.6",
|
||||
"@0x/web3-wrapper": "^3.1.5",
|
||||
"@types/js-combinatorics": "^0.5.29",
|
||||
"bn.js": "^4.11.8",
|
||||
"ethereum-types": "^1.1.2",
|
||||
"ethereumjs-abi": "0.6.5",
|
||||
"ethereumjs-util": "^5.1.1",
|
||||
"ethers": "~4.0.4",
|
||||
"js-combinatorics": "^0.5.3",
|
||||
"lodash": "^4.17.5"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
}
|
||||
}
|
113
contracts/test-utils/src/combinatorial_utils.ts
Normal file
113
contracts/test-utils/src/combinatorial_utils.ts
Normal file
@ -0,0 +1,113 @@
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import * as combinatorics from 'js-combinatorics';
|
||||
|
||||
import { testWithReferenceFuncAsync } from './test_with_reference';
|
||||
|
||||
// A set of values corresponding to the uint256 type in Solidity. This set
|
||||
// contains some notable edge cases, including some values which will overflow
|
||||
// the uint256 type when used in different mathematical operations.
|
||||
export const uint256Values = [
|
||||
new BigNumber(0),
|
||||
new BigNumber(1),
|
||||
new BigNumber(2),
|
||||
// Non-trivial big number.
|
||||
new BigNumber(2).pow(64),
|
||||
// Max that does not overflow when squared.
|
||||
new BigNumber(2).pow(128).minus(1),
|
||||
// Min that does overflow when squared.
|
||||
new BigNumber(2).pow(128),
|
||||
// Max that does not overflow when doubled.
|
||||
new BigNumber(2).pow(255).minus(1),
|
||||
// Min that does overflow when doubled.
|
||||
new BigNumber(2).pow(255),
|
||||
// Max that does not overflow.
|
||||
new BigNumber(2).pow(256).minus(1),
|
||||
];
|
||||
|
||||
// A set of values corresponding to the bytes32 type in Solidity.
|
||||
export const bytes32Values = [
|
||||
// Min
|
||||
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
||||
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
||||
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
||||
// Non-trivial big number.
|
||||
'0x000000000000f000000000000000000000000000000000000000000000000000',
|
||||
// Max
|
||||
'0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
|
||||
];
|
||||
|
||||
export async function testCombinatoriallyWithReferenceFuncAsync<P0, P1, R>(
|
||||
name: string,
|
||||
referenceFunc: (p0: P0, p1: P1) => Promise<R>,
|
||||
testFunc: (p0: P0, p1: P1) => Promise<R>,
|
||||
allValues: [P0[], P1[]],
|
||||
): Promise<void>;
|
||||
export async function testCombinatoriallyWithReferenceFuncAsync<P0, P1, P2, R>(
|
||||
name: string,
|
||||
referenceFunc: (p0: P0, p1: P1, p2: P2) => Promise<R>,
|
||||
testFunc: (p0: P0, p1: P1, p2: P2) => Promise<R>,
|
||||
allValues: [P0[], P1[], P2[]],
|
||||
): Promise<void>;
|
||||
export async function testCombinatoriallyWithReferenceFuncAsync<P0, P1, P2, P3, R>(
|
||||
name: string,
|
||||
referenceFunc: (p0: P0, p1: P1, p2: P2, p3: P3) => Promise<R>,
|
||||
testFunc: (p0: P0, p1: P1, p2: P2, p3: P3) => Promise<R>,
|
||||
allValues: [P0[], P1[], P2[], P3[]],
|
||||
): Promise<void>;
|
||||
export async function testCombinatoriallyWithReferenceFuncAsync<P0, P1, P2, P3, P4, R>(
|
||||
name: string,
|
||||
referenceFunc: (p0: P0, p1: P1, p2: P2, p3: P3, p4: P4) => Promise<R>,
|
||||
testFunc: (p0: P0, p1: P1, p2: P2, p3: P3, p4: P4) => Promise<R>,
|
||||
allValues: [P0[], P1[], P2[], P3[], P4[]],
|
||||
): Promise<void>;
|
||||
|
||||
/**
|
||||
* Uses combinatorics to test the behavior of a test function by comparing it to
|
||||
* the expected behavior (defined by a reference function) for a large number of
|
||||
* possible input values.
|
||||
*
|
||||
* First generates test cases by taking the cartesian product of the given
|
||||
* values. Each test case is a set of N values corresponding to the N arguments
|
||||
* for the test func and the reference func. For each test case, first the
|
||||
* reference function will be called to obtain an "expected result", or if the
|
||||
* reference function throws/rejects, an "expected error". Next, the test
|
||||
* function will be called to obtain an "actual result", or if the test function
|
||||
* throws/rejects, an "actual error". Each test case passes if at least one of
|
||||
* the following conditions is met:
|
||||
*
|
||||
* 1) Neither the reference function or the test function throw and the
|
||||
* "expected result" equals the "actual result".
|
||||
*
|
||||
* 2) Both the reference function and the test function throw and the "actual
|
||||
* error" message *contains* the "expected error" message.
|
||||
*
|
||||
* The first test case which does not meet one of these conditions will cause
|
||||
* the entire test to fail and this function will throw/reject.
|
||||
*
|
||||
* @param referenceFuncAsync a reference function implemented in pure
|
||||
* JavaScript/TypeScript which accepts N arguments and returns the "expected
|
||||
* result" or "expected error" for a given test case.
|
||||
* @param testFuncAsync a test function which, e.g., makes a call or sends a
|
||||
* transaction to a contract. It accepts the same N arguments returns the
|
||||
* "actual result" or "actual error" for a given test case.
|
||||
* @param values an array of N arrays. Each inner array is a set of possible
|
||||
* values which are passed into both the reference function and the test
|
||||
* function.
|
||||
* @return A Promise that resolves if the test passes and rejects if the test
|
||||
* fails, according to the rules described above.
|
||||
*/
|
||||
export async function testCombinatoriallyWithReferenceFuncAsync(
|
||||
name: string,
|
||||
referenceFuncAsync: (...args: any[]) => Promise<any>,
|
||||
testFuncAsync: (...args: any[]) => Promise<any>,
|
||||
allValues: any[],
|
||||
): Promise<void> {
|
||||
const testCases = combinatorics.cartesianProduct(...allValues);
|
||||
let counter = 0;
|
||||
testCases.forEach(async testCase => {
|
||||
counter += 1;
|
||||
it(`${name} ${counter}/${testCases.length}`, async () => {
|
||||
await testWithReferenceFuncAsync(referenceFuncAsync, testFuncAsync, testCase as any);
|
||||
});
|
||||
});
|
||||
}
|
15
contracts/test-utils/src/global_hooks.ts
Normal file
15
contracts/test-utils/src/global_hooks.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import { env, EnvVars } from '@0x/dev-utils';
|
||||
|
||||
import { coverage } from './coverage';
|
||||
import { profiler } from './profiler';
|
||||
|
||||
after('generate coverage report', async () => {
|
||||
if (env.parseBoolean(EnvVars.SolidityCoverage)) {
|
||||
const coverageSubprovider = coverage.getCoverageSubproviderSingleton();
|
||||
await coverageSubprovider.writeCoverageAsync();
|
||||
}
|
||||
if (env.parseBoolean(EnvVars.SolidityProfiler)) {
|
||||
const profilerSubprovider = profiler.getProfilerSubproviderSingleton();
|
||||
await profilerSubprovider.writeProfilerOutputAsync();
|
||||
}
|
||||
});
|
54
contracts/test-utils/src/index.ts
Normal file
54
contracts/test-utils/src/index.ts
Normal file
@ -0,0 +1,54 @@
|
||||
export { AbstractAssetWrapper } from './abstract_asset_wrapper';
|
||||
export { chaiSetup } from './chai_setup';
|
||||
export { constants } from './constants';
|
||||
export {
|
||||
expectContractCallFailedAsync,
|
||||
expectContractCallFailedWithoutReasonAsync,
|
||||
expectContractCreationFailedAsync,
|
||||
expectContractCreationFailedWithoutReasonAsync,
|
||||
expectInsufficientFundsAsync,
|
||||
expectTransactionFailedAsync,
|
||||
sendTransactionResult,
|
||||
expectTransactionFailedWithoutReasonAsync,
|
||||
getInvalidOpcodeErrorMessageForCallAsync,
|
||||
getRevertReasonOrErrorMessageForSendTransactionAsync,
|
||||
} from './assertions';
|
||||
export { getLatestBlockTimestampAsync, increaseTimeAndMineBlockAsync } from './block_timestamp';
|
||||
export { provider, txDefaults, web3Wrapper } from './web3_wrapper';
|
||||
export { LogDecoder } from './log_decoder';
|
||||
export { formatters } from './formatters';
|
||||
export { signingUtils } from './signing_utils';
|
||||
export { orderUtils } from './order_utils';
|
||||
export { typeEncodingUtils } from './type_encoding_utils';
|
||||
export { profiler } from './profiler';
|
||||
export { coverage } from './coverage';
|
||||
export { addressUtils } from './address_utils';
|
||||
export { OrderFactory } from './order_factory';
|
||||
export { TransactionFactory } from './transaction_factory';
|
||||
export { testWithReferenceFuncAsync } from './test_with_reference';
|
||||
export {
|
||||
MarketBuyOrders,
|
||||
MarketSellOrders,
|
||||
ERC721TokenIdsByOwner,
|
||||
SignedTransaction,
|
||||
OrderStatus,
|
||||
AllowanceAmountScenario,
|
||||
AssetDataScenario,
|
||||
BalanceAmountScenario,
|
||||
ContractName,
|
||||
ExpirationTimeSecondsScenario,
|
||||
TransferAmountsLoggedByMatchOrders,
|
||||
TransferAmountsByMatchOrders,
|
||||
OrderScenario,
|
||||
TraderStateScenario,
|
||||
TransactionDataParams,
|
||||
Token,
|
||||
FillScenario,
|
||||
FeeRecipientAddressScenario,
|
||||
OrderAssetAmountScenario,
|
||||
TakerAssetFillAmountScenario,
|
||||
TakerScenario,
|
||||
OrderInfo,
|
||||
ERC20BalancesByOwner,
|
||||
FillResults,
|
||||
} from './types';
|
@ -11,8 +11,6 @@ import {
|
||||
} from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { artifacts } from '../../src/artifacts';
|
||||
|
||||
import { constants } from './constants';
|
||||
|
||||
export class LogDecoder {
|
||||
@ -27,7 +25,7 @@ export class LogDecoder {
|
||||
}
|
||||
}
|
||||
}
|
||||
constructor(web3Wrapper: Web3Wrapper) {
|
||||
constructor(web3Wrapper: Web3Wrapper, artifacts: { [contractName: string]: ContractArtifact }) {
|
||||
this._web3Wrapper = web3Wrapper;
|
||||
const abiArrays: AbiDefinition[][] = [];
|
||||
_.forEach(artifacts, (artifact: ContractArtifact) => {
|
@ -1,7 +1,7 @@
|
||||
import * as chai from 'chai';
|
||||
|
||||
import { chaiSetup } from '../utils/chai_setup';
|
||||
import { testWithReferenceFuncAsync } from '../utils/test_with_reference';
|
||||
import { chaiSetup } from '../src/chai_setup';
|
||||
import { testWithReferenceFuncAsync } from '../src/test_with_reference';
|
||||
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
7
contracts/test-utils/tsconfig.json
Normal file
7
contracts/test-utils/tsconfig.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"extends": "../../tsconfig",
|
||||
"compilerOptions": {
|
||||
"outDir": "lib"
|
||||
},
|
||||
"include": ["./src/**/*", "./test/**/*"]
|
||||
}
|
6
contracts/test-utils/tslint.json
Normal file
6
contracts/test-utils/tslint.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"extends": ["@0x/tslint-config"],
|
||||
"rules": {
|
||||
"custom-no-magic-numbers": false
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user