From 0faa8b3231ddfc15723a4bdda0b6ed7aeb742bd4 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Fri, 23 Nov 2018 14:03:48 +0100 Subject: Refactor contracts-core into contracts-multisig, contracts-core and contracts-test-utils --- contracts/core/compiler.json | 2 - .../core/contracts/multisig/MultiSigWallet.sol | 393 ----- .../multisig/MultiSigWalletWithTimeLock.sol | 127 -- .../protocol/AssetProxyOwner/AssetProxyOwner.sol | 2 +- contracts/core/package.json | 9 +- contracts/core/test/asset_proxy/authorizable.ts | 12 +- contracts/core/test/asset_proxy/proxies.ts | 17 +- contracts/core/test/exchange/core.ts | 20 +- contracts/core/test/exchange/dispatcher.ts | 16 +- contracts/core/test/exchange/fill_order.ts | 22 +- contracts/core/test/exchange/internal.ts | 14 +- contracts/core/test/exchange/libs.ts | 14 +- contracts/core/test/exchange/match_orders.ts | 17 +- .../core/test/exchange/signature_validator.ts | 20 +- contracts/core/test/exchange/transactions.ts | 21 +- contracts/core/test/exchange/wrapper.ts | 20 +- contracts/core/test/extensions/forwarder.ts | 23 +- contracts/core/test/extensions/order_validator.ts | 14 +- contracts/core/test/global_hooks.ts | 3 +- contracts/core/test/libraries/lib_bytes.ts | 14 +- contracts/core/test/multisig/asset_proxy_owner.ts | 25 +- .../core/test/multisig/multi_sig_with_time_lock.ts | 347 ---- contracts/core/test/tokens/erc721_token.ts | 17 +- .../core/test/tokens/unlimited_allowance_token.ts | 12 +- contracts/core/test/tokens/weth9.ts | 13 +- contracts/core/test/tokens/zrx_token.ts | 4 +- .../core/test/utils/abstract_asset_wrapper.ts | 3 - contracts/core/test/utils/address_utils.ts | 11 - contracts/core/test/utils/assertions.ts | 199 --- contracts/core/test/utils/asset_wrapper.ts | 3 +- contracts/core/test/utils/block_timestamp.ts | 43 - contracts/core/test/utils/chai_setup.ts | 13 - contracts/core/test/utils/combinatorial_utils.ts | 2 +- contracts/core/test/utils/constants.ts | 67 - contracts/core/test/utils/coverage.ts | 21 - contracts/core/test/utils/erc20_wrapper.ts | 5 +- contracts/core/test/utils/erc721_wrapper.ts | 5 +- contracts/core/test/utils/exchange_wrapper.ts | 16 +- .../test/utils/fill_order_combinatorial_utils.ts | 34 +- contracts/core/test/utils/formatters.ts | 68 - contracts/core/test/utils/forwarder_wrapper.ts | 9 +- contracts/core/test/utils/log_decoder.ts | 53 - contracts/core/test/utils/match_order_tester.ts | 26 +- contracts/core/test/utils/multi_sig_wrapper.ts | 6 +- contracts/core/test/utils/order_factory.ts | 38 - .../core/test/utils/order_factory_from_scenario.ts | 15 +- contracts/core/test/utils/order_utils.ts | 58 - contracts/core/test/utils/profiler.ts | 27 - contracts/core/test/utils/revert_trace.ts | 21 - contracts/core/test/utils/signing_utils.ts | 29 - contracts/core/test/utils/test_with_reference.ts | 139 -- contracts/core/test/utils/transaction_factory.ts | 37 - contracts/core/test/utils/type_encoding_utils.ts | 21 - contracts/core/test/utils/types.ts | 241 --- contracts/core/test/utils/web3_wrapper.ts | 84 - .../core/test/utils_test/test_with_reference.ts | 63 - contracts/multisig/.solhint.json | 20 + contracts/multisig/.solhintignore | 3 + contracts/multisig/CHANGELOG.json | 115 ++ contracts/multisig/README.md | 129 ++ contracts/multisig/compiler.json | 22 + .../multisig/contracts/multisig/MultiSigWallet.sol | 393 +++++ .../multisig/MultiSigWalletWithTimeLock.sol | 127 ++ .../test/TestRejectEther/TestRejectEther.sol | 23 + .../generated-artifacts/MultiSigWallet.json | 591 +++++++ .../MultiSigWalletWithTimeLock.json | 676 ++++++++ .../generated-artifacts/TestRejectEther.json | 57 + .../generated-wrappers/multi_sig_wallet.ts | 1449 +++++++++++++++++ .../multi_sig_wallet_with_time_lock.ts | 1649 ++++++++++++++++++++ .../generated-wrappers/test_reject_ether.ts | 75 + contracts/multisig/package.json | 93 ++ contracts/multisig/src/artifacts/index.ts | 11 + contracts/multisig/src/wrappers/index.ts | 2 + .../multisig/test/multi_sig_with_time_lock.ts | 349 +++++ contracts/multisig/test/utils/multi_sig_wrapper.ts | 54 + contracts/multisig/tsconfig.json | 15 + contracts/multisig/tslint.json | 6 + contracts/test-utils/CHANGELOG.json | 1 + contracts/test-utils/README.md | 129 ++ contracts/test-utils/package.json | 76 + contracts/test-utils/src/abstract_asset_wrapper.ts | 3 + contracts/test-utils/src/address_utils.ts | 11 + contracts/test-utils/src/assertions.ts | 199 +++ contracts/test-utils/src/block_timestamp.ts | 43 + contracts/test-utils/src/chai_setup.ts | 13 + contracts/test-utils/src/combinatorial_utils.ts | 113 ++ contracts/test-utils/src/constants.ts | 67 + contracts/test-utils/src/coverage.ts | 21 + contracts/test-utils/src/formatters.ts | 68 + contracts/test-utils/src/global_hooks.ts | 15 + contracts/test-utils/src/index.ts | 54 + contracts/test-utils/src/log_decoder.ts | 51 + contracts/test-utils/src/order_factory.ts | 38 + contracts/test-utils/src/order_utils.ts | 58 + contracts/test-utils/src/profiler.ts | 27 + contracts/test-utils/src/revert_trace.ts | 21 + contracts/test-utils/src/signing_utils.ts | 29 + contracts/test-utils/src/test_with_reference.ts | 139 ++ contracts/test-utils/src/transaction_factory.ts | 37 + contracts/test-utils/src/type_encoding_utils.ts | 21 + contracts/test-utils/src/types.ts | 241 +++ contracts/test-utils/src/web3_wrapper.ts | 84 + contracts/test-utils/test/test_with_reference.ts | 63 + contracts/test-utils/tsconfig.json | 7 + contracts/test-utils/tslint.json | 6 + 105 files changed, 7753 insertions(+), 2296 deletions(-) delete mode 100644 contracts/core/contracts/multisig/MultiSigWallet.sol delete mode 100644 contracts/core/contracts/multisig/MultiSigWalletWithTimeLock.sol delete mode 100644 contracts/core/test/multisig/multi_sig_with_time_lock.ts delete mode 100644 contracts/core/test/utils/abstract_asset_wrapper.ts delete mode 100644 contracts/core/test/utils/address_utils.ts delete mode 100644 contracts/core/test/utils/assertions.ts delete mode 100644 contracts/core/test/utils/block_timestamp.ts delete mode 100644 contracts/core/test/utils/chai_setup.ts delete mode 100644 contracts/core/test/utils/constants.ts delete mode 100644 contracts/core/test/utils/coverage.ts delete mode 100644 contracts/core/test/utils/formatters.ts delete mode 100644 contracts/core/test/utils/log_decoder.ts delete mode 100644 contracts/core/test/utils/order_factory.ts delete mode 100644 contracts/core/test/utils/order_utils.ts delete mode 100644 contracts/core/test/utils/profiler.ts delete mode 100644 contracts/core/test/utils/revert_trace.ts delete mode 100644 contracts/core/test/utils/signing_utils.ts delete mode 100644 contracts/core/test/utils/test_with_reference.ts delete mode 100644 contracts/core/test/utils/transaction_factory.ts delete mode 100644 contracts/core/test/utils/type_encoding_utils.ts delete mode 100644 contracts/core/test/utils/types.ts delete mode 100644 contracts/core/test/utils/web3_wrapper.ts delete mode 100644 contracts/core/test/utils_test/test_with_reference.ts create mode 100644 contracts/multisig/.solhint.json create mode 100644 contracts/multisig/.solhintignore create mode 100644 contracts/multisig/CHANGELOG.json create mode 100644 contracts/multisig/README.md create mode 100644 contracts/multisig/compiler.json create mode 100644 contracts/multisig/contracts/multisig/MultiSigWallet.sol create mode 100644 contracts/multisig/contracts/multisig/MultiSigWalletWithTimeLock.sol create mode 100644 contracts/multisig/contracts/test/TestRejectEther/TestRejectEther.sol create mode 100644 contracts/multisig/generated-artifacts/MultiSigWallet.json create mode 100644 contracts/multisig/generated-artifacts/MultiSigWalletWithTimeLock.json create mode 100644 contracts/multisig/generated-artifacts/TestRejectEther.json create mode 100644 contracts/multisig/generated-wrappers/multi_sig_wallet.ts create mode 100644 contracts/multisig/generated-wrappers/multi_sig_wallet_with_time_lock.ts create mode 100644 contracts/multisig/generated-wrappers/test_reject_ether.ts create mode 100644 contracts/multisig/package.json create mode 100644 contracts/multisig/src/artifacts/index.ts create mode 100644 contracts/multisig/src/wrappers/index.ts create mode 100644 contracts/multisig/test/multi_sig_with_time_lock.ts create mode 100644 contracts/multisig/test/utils/multi_sig_wrapper.ts create mode 100644 contracts/multisig/tsconfig.json create mode 100644 contracts/multisig/tslint.json create mode 100644 contracts/test-utils/CHANGELOG.json create mode 100644 contracts/test-utils/README.md create mode 100644 contracts/test-utils/package.json create mode 100644 contracts/test-utils/src/abstract_asset_wrapper.ts create mode 100644 contracts/test-utils/src/address_utils.ts create mode 100644 contracts/test-utils/src/assertions.ts create mode 100644 contracts/test-utils/src/block_timestamp.ts create mode 100644 contracts/test-utils/src/chai_setup.ts create mode 100644 contracts/test-utils/src/combinatorial_utils.ts create mode 100644 contracts/test-utils/src/constants.ts create mode 100644 contracts/test-utils/src/coverage.ts create mode 100644 contracts/test-utils/src/formatters.ts create mode 100644 contracts/test-utils/src/global_hooks.ts create mode 100644 contracts/test-utils/src/index.ts create mode 100644 contracts/test-utils/src/log_decoder.ts create mode 100644 contracts/test-utils/src/order_factory.ts create mode 100644 contracts/test-utils/src/order_utils.ts create mode 100644 contracts/test-utils/src/profiler.ts create mode 100644 contracts/test-utils/src/revert_trace.ts create mode 100644 contracts/test-utils/src/signing_utils.ts create mode 100644 contracts/test-utils/src/test_with_reference.ts create mode 100644 contracts/test-utils/src/transaction_factory.ts create mode 100644 contracts/test-utils/src/type_encoding_utils.ts create mode 100644 contracts/test-utils/src/types.ts create mode 100644 contracts/test-utils/src/web3_wrapper.ts create mode 100644 contracts/test-utils/test/test_with_reference.ts create mode 100644 contracts/test-utils/tsconfig.json create mode 100644 contracts/test-utils/tslint.json (limited to 'contracts') diff --git a/contracts/core/compiler.json b/contracts/core/compiler.json index c824e4645..ea9e43f12 100644 --- a/contracts/core/compiler.json +++ b/contracts/core/compiler.json @@ -39,8 +39,6 @@ "IWallet", "MixinAuthorizable", "MultiAssetProxy", - "MultiSigWallet", - "MultiSigWalletWithTimeLock", "OrderValidator", "ReentrantERC20Token", "TestAssetProxyOwner", diff --git a/contracts/core/contracts/multisig/MultiSigWallet.sol b/contracts/core/contracts/multisig/MultiSigWallet.sol deleted file mode 100644 index 516e7391c..000000000 --- a/contracts/core/contracts/multisig/MultiSigWallet.sol +++ /dev/null @@ -1,393 +0,0 @@ -// solhint-disable -pragma solidity ^0.4.15; - - -/// @title Multisignature wallet - Allows multiple parties to agree on transactions before execution. -/// @author Stefan George - -contract MultiSigWallet { - - /* - * Events - */ - event Confirmation(address indexed sender, uint indexed transactionId); - event Revocation(address indexed sender, uint indexed transactionId); - event Submission(uint indexed transactionId); - event Execution(uint indexed transactionId); - event ExecutionFailure(uint indexed transactionId); - event Deposit(address indexed sender, uint value); - event OwnerAddition(address indexed owner); - event OwnerRemoval(address indexed owner); - event RequirementChange(uint required); - - /* - * Constants - */ - uint constant public MAX_OWNER_COUNT = 50; - - /* - * Storage - */ - mapping (uint => Transaction) public transactions; - mapping (uint => mapping (address => bool)) public confirmations; - mapping (address => bool) public isOwner; - address[] public owners; - uint public required; - uint public transactionCount; - - struct Transaction { - address destination; - uint value; - bytes data; - bool executed; - } - - /* - * Modifiers - */ - modifier onlyWallet() { - require(msg.sender == address(this)); - _; - } - - modifier ownerDoesNotExist(address owner) { - require(!isOwner[owner]); - _; - } - - modifier ownerExists(address owner) { - require(isOwner[owner]); - _; - } - - modifier transactionExists(uint transactionId) { - require(transactions[transactionId].destination != 0); - _; - } - - modifier confirmed(uint transactionId, address owner) { - require(confirmations[transactionId][owner]); - _; - } - - modifier notConfirmed(uint transactionId, address owner) { - require(!confirmations[transactionId][owner]); - _; - } - - modifier notExecuted(uint transactionId) { - require(!transactions[transactionId].executed); - _; - } - - modifier notNull(address _address) { - require(_address != 0); - _; - } - - modifier validRequirement(uint ownerCount, uint _required) { - require(ownerCount <= MAX_OWNER_COUNT - && _required <= ownerCount - && _required != 0 - && ownerCount != 0); - _; - } - - /// @dev Fallback function allows to deposit ether. - function() - payable - { - if (msg.value > 0) - Deposit(msg.sender, msg.value); - } - - /* - * Public functions - */ - /// @dev Contract constructor sets initial owners and required number of confirmations. - /// @param _owners List of initial owners. - /// @param _required Number of required confirmations. - function MultiSigWallet(address[] _owners, uint _required) - public - validRequirement(_owners.length, _required) - { - for (uint i=0; i<_owners.length; i++) { - require(!isOwner[_owners[i]] && _owners[i] != 0); - isOwner[_owners[i]] = true; - } - owners = _owners; - required = _required; - } - - /// @dev Allows to add a new owner. Transaction has to be sent by wallet. - /// @param owner Address of new owner. - function addOwner(address owner) - public - onlyWallet - ownerDoesNotExist(owner) - notNull(owner) - validRequirement(owners.length + 1, required) - { - isOwner[owner] = true; - owners.push(owner); - OwnerAddition(owner); - } - - /// @dev Allows to remove an owner. Transaction has to be sent by wallet. - /// @param owner Address of owner. - function removeOwner(address owner) - public - onlyWallet - ownerExists(owner) - { - isOwner[owner] = false; - for (uint i=0; i owners.length) - changeRequirement(owners.length); - OwnerRemoval(owner); - } - - /// @dev Allows to replace an owner with a new owner. Transaction has to be sent by wallet. - /// @param owner Address of owner to be replaced. - /// @param newOwner Address of new owner. - function replaceOwner(address owner, address newOwner) - public - onlyWallet - ownerExists(owner) - ownerDoesNotExist(newOwner) - { - for (uint i=0; i -// solhint-disable not-rely-on-time -contract MultiSigWalletWithTimeLock is - MultiSigWallet -{ - event ConfirmationTimeSet(uint256 indexed transactionId, uint256 confirmationTime); - event TimeLockChange(uint256 secondsTimeLocked); - - uint256 public secondsTimeLocked; - - mapping (uint256 => uint256) public confirmationTimes; - - modifier notFullyConfirmed(uint256 transactionId) { - require( - !isConfirmed(transactionId), - "TX_FULLY_CONFIRMED" - ); - _; - } - - modifier fullyConfirmed(uint256 transactionId) { - require( - isConfirmed(transactionId), - "TX_NOT_FULLY_CONFIRMED" - ); - _; - } - - modifier pastTimeLock(uint256 transactionId) { - require( - block.timestamp >= confirmationTimes[transactionId] + secondsTimeLocked, - "TIME_LOCK_INCOMPLETE" - ); - _; - } - - /// @dev Contract constructor sets initial owners, required number of confirmations, and time lock. - /// @param _owners List of initial owners. - /// @param _required Number of required confirmations. - /// @param _secondsTimeLocked Duration needed after a transaction is confirmed and before it becomes executable, in seconds. - constructor ( - address[] _owners, - uint256 _required, - uint256 _secondsTimeLocked - ) - public - MultiSigWallet(_owners, _required) - { - secondsTimeLocked = _secondsTimeLocked; - } - - /// @dev Changes the duration of the time lock for transactions. - /// @param _secondsTimeLocked Duration needed after a transaction is confirmed and before it becomes executable, in seconds. - function changeTimeLock(uint256 _secondsTimeLocked) - public - onlyWallet - { - secondsTimeLocked = _secondsTimeLocked; - emit TimeLockChange(_secondsTimeLocked); - } - - /// @dev Allows an owner to confirm a transaction. - /// @param transactionId Transaction ID. - function confirmTransaction(uint256 transactionId) - public - ownerExists(msg.sender) - transactionExists(transactionId) - notConfirmed(transactionId, msg.sender) - notFullyConfirmed(transactionId) - { - confirmations[transactionId][msg.sender] = true; - emit Confirmation(msg.sender, transactionId); - if (isConfirmed(transactionId)) { - setConfirmationTime(transactionId, block.timestamp); - } - } - - /// @dev Allows anyone to execute a confirmed transaction. - /// @param transactionId Transaction ID. - function executeTransaction(uint256 transactionId) - public - notExecuted(transactionId) - fullyConfirmed(transactionId) - pastTimeLock(transactionId) - { - Transaction storage txn = transactions[transactionId]; - txn.executed = true; - if (external_call(txn.destination, txn.value, txn.data.length, txn.data)) { - emit Execution(transactionId); - } else { - emit ExecutionFailure(transactionId); - txn.executed = false; - } - } - - /// @dev Sets the time of when a submission first passed. - function setConfirmationTime(uint256 transactionId, uint256 confirmationTime) - internal - { - confirmationTimes[transactionId] = confirmationTime; - emit ConfirmationTimeSet(transactionId, confirmationTime); - } -} diff --git a/contracts/core/contracts/protocol/AssetProxyOwner/AssetProxyOwner.sol b/contracts/core/contracts/protocol/AssetProxyOwner/AssetProxyOwner.sol index edb788fab..3096340b9 100644 --- a/contracts/core/contracts/protocol/AssetProxyOwner/AssetProxyOwner.sol +++ b/contracts/core/contracts/protocol/AssetProxyOwner/AssetProxyOwner.sol @@ -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"; diff --git a/contracts/core/package.json b/contracts/core/package.json index b20b0ef3f..bdfd7078f 100644 --- a/contracts/core/package.json +++ b/contracts/core/package.json @@ -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", diff --git a/contracts/core/test/asset_proxy/authorizable.ts b/contracts/core/test/asset_proxy/authorizable.ts index e21af9b81..853d18be0 100644 --- a/contracts/core/test/asset_proxy/authorizable.ts +++ b/contracts/core/test/asset_proxy/authorizable.ts @@ -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; diff --git a/contracts/core/test/asset_proxy/proxies.ts b/contracts/core/test/asset_proxy/proxies.ts index 8fa1e602a..2527b0fbf 100644 --- a/contracts/core/test/asset_proxy/proxies.ts +++ b/contracts/core/test/asset_proxy/proxies.ts @@ -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, diff --git a/contracts/core/test/exchange/core.ts b/contracts/core/test/exchange/core.ts index 9159b0d8f..fd6b9ee6b 100644 --- a/contracts/core/test/exchange/core.ts +++ b/contracts/core/test/exchange/core.ts @@ -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; diff --git a/contracts/core/test/exchange/dispatcher.ts b/contracts/core/test/exchange/dispatcher.ts index 3d3aa42c2..9bc5cbcce 100644 --- a/contracts/core/test/exchange/dispatcher.ts +++ b/contracts/core/test/exchange/dispatcher.ts @@ -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 }), ); diff --git a/contracts/core/test/exchange/fill_order.ts b/contracts/core/test/exchange/fill_order.ts index 37efaad2b..2bdbe4855 100644 --- a/contracts/core/test/exchange/fill_order.ts +++ b/contracts/core/test/exchange/fill_order.ts @@ -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); diff --git a/contracts/core/test/exchange/internal.ts b/contracts/core/test/exchange/internal.ts index 109be29c6..cff8f630c 100644 --- a/contracts/core/test/exchange/internal.ts +++ b/contracts/core/test/exchange/internal.ts @@ -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; diff --git a/contracts/core/test/exchange/libs.ts b/contracts/core/test/exchange/libs.ts index 503ef0e0f..f52992c13 100644 --- a/contracts/core/test/exchange/libs.ts +++ b/contracts/core/test/exchange/libs.ts @@ -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; diff --git a/contracts/core/test/exchange/match_orders.ts b/contracts/core/test/exchange/match_orders.ts index eea9992d9..0e841b359 100644 --- a/contracts/core/test/exchange/match_orders.ts +++ b/contracts/core/test/exchange/match_orders.ts @@ -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(); diff --git a/contracts/core/test/exchange/signature_validator.ts b/contracts/core/test/exchange/signature_validator.ts index 756c72766..b84a488a1 100644 --- a/contracts/core/test/exchange/signature_validator.ts +++ b/contracts/core/test/exchange/signature_validator.ts @@ -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, diff --git a/contracts/core/test/exchange/transactions.ts b/contracts/core/test/exchange/transactions.ts index 1b5eef295..c4086d9be 100644 --- a/contracts/core/test/exchange/transactions.ts +++ b/contracts/core/test/exchange/transactions.ts @@ -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; diff --git a/contracts/core/test/exchange/wrapper.ts b/contracts/core/test/exchange/wrapper.ts index 6b660aac5..17cb7a3bb 100644 --- a/contracts/core/test/exchange/wrapper.ts +++ b/contracts/core/test/exchange/wrapper.ts @@ -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; diff --git a/contracts/core/test/extensions/forwarder.ts b/contracts/core/test/extensions/forwarder.ts index c006be0fe..44ad4d6ff 100644 --- a/contracts/core/test/extensions/forwarder.ts +++ b/contracts/core/test/extensions/forwarder.ts @@ -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; diff --git a/contracts/core/test/extensions/order_validator.ts b/contracts/core/test/extensions/order_validator.ts index 37d7c4c5a..3dbe76f6e 100644 --- a/contracts/core/test/extensions/order_validator.ts +++ b/contracts/core/test/extensions/order_validator.ts @@ -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; diff --git a/contracts/core/test/global_hooks.ts b/contracts/core/test/global_hooks.ts index 2e9ac9e21..847b8ea91 100644 --- a/contracts/core/test/global_hooks.ts +++ b/contracts/core/test/global_hooks.ts @@ -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)) { diff --git a/contracts/core/test/libraries/lib_bytes.ts b/contracts/core/test/libraries/lib_bytes.ts index b1a389f00..9338e6e7f 100644 --- a/contracts/core/test/libraries/lib_bytes.ts +++ b/contracts/core/test/libraries/lib_bytes.ts @@ -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; diff --git a/contracts/core/test/multisig/asset_proxy_owner.ts b/contracts/core/test/multisig/asset_proxy_owner.ts index 087152316..f9ff9fe1e 100644 --- a/contracts/core/test/multisig/asset_proxy_owner.ts +++ b/contracts/core/test/multisig/asset_proxy_owner.ts @@ -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 diff --git a/contracts/core/test/multisig/multi_sig_with_time_lock.ts b/contracts/core/test/multisig/multi_sig_with_time_lock.ts deleted file mode 100644 index 1c0cb0515..000000000 --- a/contracts/core/test/multisig/multi_sig_with_time_lock.ts +++ /dev/null @@ -1,347 +0,0 @@ -import { BlockchainLifecycle } from '@0x/dev-utils'; -import { RevertReason } from '@0x/types'; -import { BigNumber } from '@0x/utils'; -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, - MultiSigWalletWithTimeLockContract, - 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'; - -chaiSetup.configure(); -const expect = chai.expect; -const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper); -// tslint:disable:no-unnecessary-type-assertion -describe('MultiSigWalletWithTimeLock', () => { - let owners: string[]; - let notOwner: string; - const REQUIRED_APPROVALS = new BigNumber(2); - const SECONDS_TIME_LOCKED = new BigNumber(1000000); - - before(async () => { - await blockchainLifecycle.startAsync(); - }); - after(async () => { - await blockchainLifecycle.revertAsync(); - }); - before(async () => { - const accounts = await web3Wrapper.getAvailableAddressesAsync(); - owners = [accounts[0], accounts[1], accounts[2]]; - notOwner = accounts[3]; - }); - - let multiSig: MultiSigWalletWithTimeLockContract; - let multiSigWrapper: MultiSigWrapper; - - beforeEach(async () => { - await blockchainLifecycle.startAsync(); - }); - afterEach(async () => { - await blockchainLifecycle.revertAsync(); - }); - - describe('external_call', () => { - it('should be internal', async () => { - const secondsTimeLocked = new BigNumber(0); - multiSig = await MultiSigWalletWithTimeLockContract.deployFrom0xArtifactAsync( - artifacts.MultiSigWalletWithTimeLock, - provider, - txDefaults, - owners, - REQUIRED_APPROVALS, - secondsTimeLocked, - ); - expect(_.isUndefined((multiSig as any).external_call)).to.be.equal(true); - }); - }); - describe('confirmTransaction', () => { - let txId: BigNumber; - beforeEach(async () => { - const secondsTimeLocked = new BigNumber(0); - multiSig = await MultiSigWalletWithTimeLockContract.deployFrom0xArtifactAsync( - artifacts.MultiSigWalletWithTimeLock, - provider, - txDefaults, - owners, - REQUIRED_APPROVALS, - secondsTimeLocked, - ); - multiSigWrapper = new MultiSigWrapper(multiSig, provider); - const destination = notOwner; - const data = constants.NULL_BYTES; - const txReceipt = await multiSigWrapper.submitTransactionAsync(destination, data, owners[0]); - txId = (txReceipt.logs[0] as LogWithDecodedArgs).args - .transactionId; - }); - it('should revert if called by a non-owner', async () => { - await expectTransactionFailedWithoutReasonAsync(multiSigWrapper.confirmTransactionAsync(txId, notOwner)); - }); - it('should revert if transaction does not exist', async () => { - const nonexistentTxId = new BigNumber(123456789); - await expectTransactionFailedWithoutReasonAsync( - multiSigWrapper.confirmTransactionAsync(nonexistentTxId, owners[1]), - ); - }); - it('should revert if transaction is already confirmed by caller', async () => { - await expectTransactionFailedWithoutReasonAsync(multiSigWrapper.confirmTransactionAsync(txId, owners[0])); - }); - it('should confirm transaction for caller and log a Confirmation event', async () => { - const txReceipt = await multiSigWrapper.confirmTransactionAsync(txId, owners[1]); - const log = txReceipt.logs[0] as LogWithDecodedArgs; - expect(log.event).to.be.equal('Confirmation'); - expect(log.args.sender).to.be.equal(owners[1]); - expect(log.args.transactionId).to.be.bignumber.equal(txId); - }); - it('should revert if fully confirmed', async () => { - await multiSigWrapper.confirmTransactionAsync(txId, owners[1]); - await expectTransactionFailedAsync( - multiSigWrapper.confirmTransactionAsync(txId, owners[2]), - RevertReason.TxFullyConfirmed, - ); - }); - it('should set the confirmation time of the transaction if it becomes fully confirmed', async () => { - const txReceipt = await multiSigWrapper.confirmTransactionAsync(txId, owners[1]); - const blockNum = await web3Wrapper.getBlockNumberAsync(); - const timestamp = new BigNumber(await web3Wrapper.getBlockTimestampAsync(blockNum)); - const log = txReceipt.logs[1] as LogWithDecodedArgs; - expect(log.args.confirmationTime).to.be.bignumber.equal(timestamp); - expect(log.args.transactionId).to.be.bignumber.equal(txId); - }); - }); - describe('executeTransaction', () => { - let txId: BigNumber; - const secondsTimeLocked = new BigNumber(1000000); - beforeEach(async () => { - multiSig = await MultiSigWalletWithTimeLockContract.deployFrom0xArtifactAsync( - artifacts.MultiSigWalletWithTimeLock, - provider, - txDefaults, - owners, - REQUIRED_APPROVALS, - secondsTimeLocked, - ); - multiSigWrapper = new MultiSigWrapper(multiSig, provider); - const destination = notOwner; - const data = constants.NULL_BYTES; - const txReceipt = await multiSigWrapper.submitTransactionAsync(destination, data, owners[0]); - txId = (txReceipt.logs[0] as LogWithDecodedArgs).args - .transactionId; - }); - it('should revert if transaction has not been fully confirmed', async () => { - await increaseTimeAndMineBlockAsync(secondsTimeLocked.toNumber()); - await expectTransactionFailedAsync( - multiSigWrapper.executeTransactionAsync(txId, owners[1]), - RevertReason.TxNotFullyConfirmed, - ); - }); - it('should revert if time lock has not passed', async () => { - await multiSigWrapper.confirmTransactionAsync(txId, owners[1]); - await expectTransactionFailedAsync( - multiSigWrapper.executeTransactionAsync(txId, owners[1]), - RevertReason.TimeLockIncomplete, - ); - }); - it('should execute a transaction and log an Execution event if successful and called by owner', async () => { - await multiSigWrapper.confirmTransactionAsync(txId, owners[1]); - await increaseTimeAndMineBlockAsync(secondsTimeLocked.toNumber()); - const txReceipt = await multiSigWrapper.executeTransactionAsync(txId, owners[1]); - const log = txReceipt.logs[0] as LogWithDecodedArgs; - expect(log.event).to.be.equal('Execution'); - expect(log.args.transactionId).to.be.bignumber.equal(txId); - }); - it('should execute a transaction and log an Execution event if successful and called by non-owner', async () => { - await multiSigWrapper.confirmTransactionAsync(txId, owners[1]); - await increaseTimeAndMineBlockAsync(secondsTimeLocked.toNumber()); - const txReceipt = await multiSigWrapper.executeTransactionAsync(txId, notOwner); - const log = txReceipt.logs[0] as LogWithDecodedArgs; - expect(log.event).to.be.equal('Execution'); - expect(log.args.transactionId).to.be.bignumber.equal(txId); - }); - it('should revert if a required confirmation is revoked before executeTransaction is called', async () => { - await multiSigWrapper.confirmTransactionAsync(txId, owners[1]); - await increaseTimeAndMineBlockAsync(secondsTimeLocked.toNumber()); - await multiSigWrapper.revokeConfirmationAsync(txId, owners[0]); - await expectTransactionFailedAsync( - multiSigWrapper.executeTransactionAsync(txId, owners[1]), - RevertReason.TxNotFullyConfirmed, - ); - }); - it('should revert if transaction has been executed', async () => { - await multiSigWrapper.confirmTransactionAsync(txId, owners[1]); - await increaseTimeAndMineBlockAsync(secondsTimeLocked.toNumber()); - const txReceipt = await multiSigWrapper.executeTransactionAsync(txId, owners[1]); - const log = txReceipt.logs[0] as LogWithDecodedArgs; - expect(log.args.transactionId).to.be.bignumber.equal(txId); - 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, - 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); - const submissionTxReceipt = await multiSigWrapper.submitTransactionAsync( - contractWithoutFallback.address, - data, - owners[0], - { value }, - ); - const newTxId = (submissionTxReceipt.logs[0] as LogWithDecodedArgs< - MultiSigWalletWithTimeLockSubmissionEventArgs - >).args.transactionId; - await multiSigWrapper.confirmTransactionAsync(newTxId, owners[1]); - await increaseTimeAndMineBlockAsync(secondsTimeLocked.toNumber()); - const txReceipt = await multiSigWrapper.executeTransactionAsync(newTxId, owners[1]); - const executionFailureLog = txReceipt.logs[0] as LogWithDecodedArgs< - MultiSigWalletWithTimeLockExecutionFailureEventArgs - >; - expect(executionFailureLog.event).to.be.equal('ExecutionFailure'); - expect(executionFailureLog.args.transactionId).to.be.bignumber.equal(newTxId); - }); - }); - describe('changeTimeLock', () => { - describe('initially non-time-locked', async () => { - before(async () => { - await blockchainLifecycle.startAsync(); - }); - after(async () => { - await blockchainLifecycle.revertAsync(); - }); - before('deploy a wallet', async () => { - const secondsTimeLocked = new BigNumber(0); - multiSig = await MultiSigWalletWithTimeLockContract.deployFrom0xArtifactAsync( - artifacts.MultiSigWalletWithTimeLock, - provider, - txDefaults, - owners, - REQUIRED_APPROVALS, - secondsTimeLocked, - ); - multiSigWrapper = new MultiSigWrapper(multiSig, provider); - }); - - it('should throw when not called by wallet', async () => { - return expectTransactionFailedWithoutReasonAsync( - multiSig.changeTimeLock.sendTransactionAsync(SECONDS_TIME_LOCKED, { from: owners[0] }), - ); - }); - - it('should throw without enough confirmations', async () => { - const destination = multiSig.address; - const changeTimeLockData = multiSig.changeTimeLock.getABIEncodedTransactionData(SECONDS_TIME_LOCKED); - const res = await multiSigWrapper.submitTransactionAsync(destination, changeTimeLockData, owners[0]); - const log = res.logs[0] as LogWithDecodedArgs; - const txId = log.args.transactionId; - return expectTransactionFailedAsync( - multiSig.executeTransaction.sendTransactionAsync(txId, { from: owners[0] }), - RevertReason.TxNotFullyConfirmed, - ); - }); - - it('should set confirmation time with enough confirmations', async () => { - const destination = multiSig.address; - const changeTimeLockData = multiSig.changeTimeLock.getABIEncodedTransactionData(SECONDS_TIME_LOCKED); - const subRes = await multiSigWrapper.submitTransactionAsync(destination, changeTimeLockData, owners[0]); - const subLog = subRes.logs[0] as LogWithDecodedArgs; - const txId = subLog.args.transactionId; - - const confirmRes = await multiSigWrapper.confirmTransactionAsync(txId, owners[1]); - expect(confirmRes.logs).to.have.length(2); - - const blockNum = await web3Wrapper.getBlockNumberAsync(); - const blockInfo = await web3Wrapper.getBlockIfExistsAsync(blockNum); - if (_.isUndefined(blockInfo)) { - throw new Error(`Unexpectedly failed to fetch block at #${blockNum}`); - } - const timestamp = new BigNumber(blockInfo.timestamp); - const confirmationTimeBigNum = new BigNumber(await multiSig.confirmationTimes.callAsync(txId)); - - expect(timestamp).to.be.bignumber.equal(confirmationTimeBigNum); - }); - - it('should be executable with enough confirmations and secondsTimeLocked of 0', async () => { - const destination = multiSig.address; - const changeTimeLockData = multiSig.changeTimeLock.getABIEncodedTransactionData(SECONDS_TIME_LOCKED); - const subRes = await multiSigWrapper.submitTransactionAsync(destination, changeTimeLockData, owners[0]); - const subLog = subRes.logs[0] as LogWithDecodedArgs; - const txId = subLog.args.transactionId; - - await multiSigWrapper.confirmTransactionAsync(txId, owners[1]); - await multiSigWrapper.executeTransactionAsync(txId, owners[1]); - - const secondsTimeLocked = new BigNumber(await multiSig.secondsTimeLocked.callAsync()); - expect(secondsTimeLocked).to.be.bignumber.equal(SECONDS_TIME_LOCKED); - }); - }); - describe('initially time-locked', async () => { - before(async () => { - await blockchainLifecycle.startAsync(); - }); - after(async () => { - await blockchainLifecycle.revertAsync(); - }); - let txId: BigNumber; - const newSecondsTimeLocked = new BigNumber(0); - before('deploy a wallet, submit transaction to change timelock, and confirm the transaction', async () => { - multiSig = await MultiSigWalletWithTimeLockContract.deployFrom0xArtifactAsync( - artifacts.MultiSigWalletWithTimeLock, - provider, - txDefaults, - owners, - REQUIRED_APPROVALS, - SECONDS_TIME_LOCKED, - ); - multiSigWrapper = new MultiSigWrapper(multiSig, provider); - - const changeTimeLockData = multiSig.changeTimeLock.getABIEncodedTransactionData(newSecondsTimeLocked); - const res = await multiSigWrapper.submitTransactionAsync( - multiSig.address, - changeTimeLockData, - owners[0], - ); - const log = res.logs[0] as LogWithDecodedArgs; - txId = log.args.transactionId; - await multiSigWrapper.confirmTransactionAsync(txId, owners[1]); - }); - - it('should throw if it has enough confirmations but is not past the time lock', async () => { - return expectTransactionFailedAsync( - multiSig.executeTransaction.sendTransactionAsync(txId, { from: owners[0] }), - RevertReason.TimeLockIncomplete, - ); - }); - - it('should execute if it has enough confirmations and is past the time lock', async () => { - await increaseTimeAndMineBlockAsync(SECONDS_TIME_LOCKED.toNumber()); - await web3Wrapper.awaitTransactionSuccessAsync( - await multiSig.executeTransaction.sendTransactionAsync(txId, { from: owners[0] }), - constants.AWAIT_TRANSACTION_MINED_MS, - ); - - const secondsTimeLocked = new BigNumber(await multiSig.secondsTimeLocked.callAsync()); - expect(secondsTimeLocked).to.be.bignumber.equal(newSecondsTimeLocked); - }); - }); - }); -}); -// tslint:enable:no-unnecessary-type-assertion diff --git a/contracts/core/test/tokens/erc721_token.ts b/contracts/core/test/tokens/erc721_token.ts index 72407748f..3b0a5f001 100644 --- a/contracts/core/test/tokens/erc721_token.ts +++ b/contracts/core/test/tokens/erc721_token.ts @@ -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, diff --git a/contracts/core/test/tokens/unlimited_allowance_token.ts b/contracts/core/test/tokens/unlimited_allowance_token.ts index ea5a50522..c3e4072c5 100644 --- a/contracts/core/test/tokens/unlimited_allowance_token.ts +++ b/contracts/core/test/tokens/unlimited_allowance_token.ts @@ -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; diff --git a/contracts/core/test/tokens/weth9.ts b/contracts/core/test/tokens/weth9.ts index 9a31dc3f2..225481904 100644 --- a/contracts/core/test/tokens/weth9.ts +++ b/contracts/core/test/tokens/weth9.ts @@ -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; diff --git a/contracts/core/test/tokens/zrx_token.ts b/contracts/core/test/tokens/zrx_token.ts index cab62c205..6bc5e164c 100644 --- a/contracts/core/test/tokens/zrx_token.ts +++ b/contracts/core/test/tokens/zrx_token.ts @@ -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; diff --git a/contracts/core/test/utils/abstract_asset_wrapper.ts b/contracts/core/test/utils/abstract_asset_wrapper.ts deleted file mode 100644 index 4b56a8502..000000000 --- a/contracts/core/test/utils/abstract_asset_wrapper.ts +++ /dev/null @@ -1,3 +0,0 @@ -export abstract class AbstractAssetWrapper { - public abstract getProxyId(): string; -} diff --git a/contracts/core/test/utils/address_utils.ts b/contracts/core/test/utils/address_utils.ts deleted file mode 100644 index 634da0c16..000000000 --- a/contracts/core/test/utils/address_utils.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { generatePseudoRandomSalt } from '@0x/order-utils'; -import { crypto } from '@0x/order-utils/lib/src/crypto'; - -export const addressUtils = { - generatePseudoRandomAddress(): string { - const randomBigNum = generatePseudoRandomSalt(); - const randomBuff = crypto.solSHA3([randomBigNum]); - const randomAddress = `0x${randomBuff.slice(0, 20).toString('hex')}`; - return randomAddress; - }, -}; diff --git a/contracts/core/test/utils/assertions.ts b/contracts/core/test/utils/assertions.ts deleted file mode 100644 index 5b1cedfcc..000000000 --- a/contracts/core/test/utils/assertions.ts +++ /dev/null @@ -1,199 +0,0 @@ -import { RevertReason } from '@0x/types'; -import { logUtils } from '@0x/utils'; -import { NodeType } from '@0x/web3-wrapper'; -import * as chai from 'chai'; -import { TransactionReceipt, TransactionReceiptStatus, TransactionReceiptWithDecodedLogs } from 'ethereum-types'; -import * as _ from 'lodash'; - -import { web3Wrapper } from './web3_wrapper'; - -const expect = chai.expect; - -let nodeType: NodeType | undefined; - -// Represents the return value of a `sendTransaction` call. The Promise should -// resolve with either a transaction receipt or a transaction hash. -export type sendTransactionResult = Promise; - -/** - * Returns ganacheError if the backing Ethereum node is Ganache and gethError - * if it is Geth. - * @param ganacheError the error to be returned if the backing node is Ganache. - * @param gethError the error to be returned if the backing node is Geth. - * @returns either the given ganacheError or gethError depending on the backing - * node. - */ -async function _getGanacheOrGethError(ganacheError: string, gethError: string): Promise { - if (_.isUndefined(nodeType)) { - nodeType = await web3Wrapper.getNodeTypeAsync(); - } - switch (nodeType) { - case NodeType.Ganache: - return ganacheError; - case NodeType.Geth: - return gethError; - default: - throw new Error(`Unknown node type: ${nodeType}`); - } -} - -async function _getInsufficientFundsErrorMessageAsync(): Promise { - return _getGanacheOrGethError("sender doesn't have enough funds", 'insufficient funds'); -} - -async function _getTransactionFailedErrorMessageAsync(): Promise { - return _getGanacheOrGethError('revert', 'always failing transaction'); -} - -async function _getContractCallFailedErrorMessageAsync(): Promise { - return _getGanacheOrGethError('revert', 'Contract call failed'); -} - -/** - * Returns the expected error message for an 'invalid opcode' resulting from a - * contract call. The exact error message depends on the backing Ethereum node. - */ -export async function getInvalidOpcodeErrorMessageForCallAsync(): Promise { - return _getGanacheOrGethError('invalid opcode', 'Contract call failed'); -} - -/** - * Returns the expected error message for the given revert reason resulting from - * a sendTransaction call. The exact error message depends on the backing - * Ethereum node and whether it supports revert reasons. - * @param reason a specific revert reason. - * @returns the expected error message. - */ -export async function getRevertReasonOrErrorMessageForSendTransactionAsync(reason: RevertReason): Promise { - return _getGanacheOrGethError(reason, 'always failing transaction'); -} - -/** - * Rejects if the given Promise does not reject with an error indicating - * insufficient funds. - * @param p a promise resulting from a contract call or sendTransaction call. - * @returns a new Promise which will reject if the conditions are not met and - * otherwise resolve with no value. - */ -export async function expectInsufficientFundsAsync(p: Promise): Promise { - const errMessage = await _getInsufficientFundsErrorMessageAsync(); - return expect(p).to.be.rejectedWith(errMessage); -} - -/** - * Resolves if the the sendTransaction call fails with the given revert reason. - * However, since Geth does not support revert reasons for sendTransaction, this - * falls back to expectTransactionFailedWithoutReasonAsync if the backing - * Ethereum node is Geth. - * @param p a Promise resulting from a sendTransaction call - * @param reason a specific revert reason - * @returns a new Promise which will reject if the conditions are not met and - * otherwise resolve with no value. - */ -export async function expectTransactionFailedAsync(p: sendTransactionResult, reason: RevertReason): Promise { - // HACK(albrow): This dummy `catch` should not be necessary, but if you - // remove it, there is an uncaught exception and the Node process will - // forcibly exit. It's possible this is a false positive in - // make-promises-safe. - p.catch(e => { - _.noop(e); - }); - - if (_.isUndefined(nodeType)) { - nodeType = await web3Wrapper.getNodeTypeAsync(); - } - switch (nodeType) { - case NodeType.Ganache: - return expect(p).to.be.rejectedWith(reason); - case NodeType.Geth: - logUtils.warn( - 'WARNING: Geth does not support revert reasons for sendTransaction. This test will pass if the transaction fails for any reason.', - ); - return expectTransactionFailedWithoutReasonAsync(p); - default: - throw new Error(`Unknown node type: ${nodeType}`); - } -} - -/** - * Resolves if the transaction fails without a revert reason, or if the - * corresponding transactionReceipt has a status of 0 or '0', indicating - * failure. - * @param p a Promise resulting from a sendTransaction call - * @returns a new Promise which will reject if the conditions are not met and - * otherwise resolve with no value. - */ -export async function expectTransactionFailedWithoutReasonAsync(p: sendTransactionResult): Promise { - return p - .then(async result => { - let txReceiptStatus: TransactionReceiptStatus; - if (_.isString(result)) { - // Result is a txHash. We need to make a web3 call to get the - // receipt, then get the status from the receipt. - const txReceipt = await web3Wrapper.awaitTransactionMinedAsync(result); - txReceiptStatus = txReceipt.status; - } else if ('status' in result) { - // Result is a transaction receipt, so we can get the status - // directly. - txReceiptStatus = result.status; - } else { - throw new Error('Unexpected result type: ' + typeof result); - } - expect(_.toString(txReceiptStatus)).to.equal( - '0', - 'Expected transaction to fail but receipt had a non-zero status, indicating success', - ); - }) - .catch(async err => { - // If the promise rejects, we expect a specific error message, - // depending on the backing Ethereum node type. - const errMessage = await _getTransactionFailedErrorMessageAsync(); - expect(err.message).to.include(errMessage); - }); -} - -/** - * Resolves if the the contract call fails with the given revert reason. - * @param p a Promise resulting from a contract call - * @param reason a specific revert reason - * @returns a new Promise which will reject if the conditions are not met and - * otherwise resolve with no value. - */ -export async function expectContractCallFailedAsync(p: Promise, reason: RevertReason): Promise { - return expect(p).to.be.rejectedWith(reason); -} - -/** - * Resolves if the contract call fails without a revert reason. - * @param p a Promise resulting from a contract call - * @returns a new Promise which will reject if the conditions are not met and - * otherwise resolve with no value. - */ -export async function expectContractCallFailedWithoutReasonAsync(p: Promise): Promise { - const errMessage = await _getContractCallFailedErrorMessageAsync(); - return expect(p).to.be.rejectedWith(errMessage); -} - -/** - * Resolves if the contract creation/deployment fails without a revert reason. - * @param p a Promise resulting from a contract creation/deployment - * @returns a new Promise which will reject if the conditions are not met and - * otherwise resolve with no value. - */ -export async function expectContractCreationFailedAsync( - p: sendTransactionResult, - reason: RevertReason, -): Promise { - return expectTransactionFailedAsync(p, reason); -} - -/** - * Resolves if the contract creation/deployment fails without a revert reason. - * @param p a Promise resulting from a contract creation/deployment - * @returns a new Promise which will reject if the conditions are not met and - * otherwise resolve with no value. - */ -export async function expectContractCreationFailedWithoutReasonAsync(p: Promise): Promise { - const errMessage = await _getTransactionFailedErrorMessageAsync(); - return expect(p).to.be.rejectedWith(errMessage); -} diff --git a/contracts/core/test/utils/asset_wrapper.ts b/contracts/core/test/utils/asset_wrapper.ts index 4e7696066..e4090ad74 100644 --- a/contracts/core/test/utils/asset_wrapper.ts +++ b/contracts/core/test/utils/asset_wrapper.ts @@ -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'; diff --git a/contracts/core/test/utils/block_timestamp.ts b/contracts/core/test/utils/block_timestamp.ts deleted file mode 100644 index 66c13eed1..000000000 --- a/contracts/core/test/utils/block_timestamp.ts +++ /dev/null @@ -1,43 +0,0 @@ -import * as _ from 'lodash'; - -import { constants } from './constants'; -import { web3Wrapper } from './web3_wrapper'; - -let firstAccount: string | undefined; - -/** - * Increases time by the given number of seconds and then mines a block so that - * the current block timestamp has the offset applied. - * @param seconds the number of seconds by which to incrase the time offset. - * @returns a new Promise which will resolve with the new total time offset or - * reject if the time could not be increased. - */ -export async function increaseTimeAndMineBlockAsync(seconds: number): Promise { - if (_.isUndefined(firstAccount)) { - const accounts = await web3Wrapper.getAvailableAddressesAsync(); - firstAccount = accounts[0]; - } - - const offset = await web3Wrapper.increaseTimeAsync(seconds); - // Note: we need to send a transaction after increasing time so - // that a block is actually mined. The contract looks at the - // last mined block for the timestamp. - await web3Wrapper.awaitTransactionSuccessAsync( - await web3Wrapper.sendTransactionAsync({ from: firstAccount, to: firstAccount, value: 0 }), - constants.AWAIT_TRANSACTION_MINED_MS, - ); - - return offset; -} - -/** - * Returns the timestamp of the latest block in seconds since the Unix epoch. - * @returns a new Promise which will resolve with the timestamp in seconds. - */ -export async function getLatestBlockTimestampAsync(): Promise { - const currentBlockIfExists = await web3Wrapper.getBlockIfExistsAsync('latest'); - if (_.isUndefined(currentBlockIfExists)) { - throw new Error(`Unable to fetch latest block.`); - } - return currentBlockIfExists.timestamp; -} diff --git a/contracts/core/test/utils/chai_setup.ts b/contracts/core/test/utils/chai_setup.ts deleted file mode 100644 index 1a8733093..000000000 --- a/contracts/core/test/utils/chai_setup.ts +++ /dev/null @@ -1,13 +0,0 @@ -import * as chai from 'chai'; -import chaiAsPromised = require('chai-as-promised'); -import ChaiBigNumber = require('chai-bignumber'); -import * as dirtyChai from 'dirty-chai'; - -export const chaiSetup = { - configure(): void { - chai.config.includeStack = true; - chai.use(ChaiBigNumber()); - chai.use(dirtyChai); - chai.use(chaiAsPromised); - }, -}; diff --git a/contracts/core/test/utils/combinatorial_utils.ts b/contracts/core/test/utils/combinatorial_utils.ts index bb1b55b4d..d6e339f94 100644 --- a/contracts/core/test/utils/combinatorial_utils.ts +++ b/contracts/core/test/utils/combinatorial_utils.ts @@ -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 diff --git a/contracts/core/test/utils/constants.ts b/contracts/core/test/utils/constants.ts deleted file mode 100644 index d2c3ab512..000000000 --- a/contracts/core/test/utils/constants.ts +++ /dev/null @@ -1,67 +0,0 @@ -import { BigNumber } from '@0x/utils'; -import { Web3Wrapper } from '@0x/web3-wrapper'; -import * as ethUtil from 'ethereumjs-util'; -import * as _ from 'lodash'; - -const TESTRPC_PRIVATE_KEYS_STRINGS = [ - '0xf2f48ee19680706196e2e339e5da3491186e0c4c5030670656b0e0164837257d', - '0x5d862464fe9303452126c8bc94274b8c5f9874cbd219789b3eb2128075a76f72', - '0xdf02719c4df8b9b8ac7f551fcb5d9ef48fa27eef7a66453879f4d8fdc6e78fb1', - '0xff12e391b79415e941a94de3bf3a9aee577aed0731e297d5cfa0b8a1e02fa1d0', - '0x752dd9cf65e68cfaba7d60225cbdbc1f4729dd5e5507def72815ed0d8abc6249', - '0xefb595a0178eb79a8df953f87c5148402a224cdf725e88c0146727c6aceadccd', - '0x83c6d2cc5ddcf9711a6d59b417dc20eb48afd58d45290099e5987e3d768f328f', - '0xbb2d3f7c9583780a7d3904a2f55d792707c345f21de1bacb2d389934d82796b2', - '0xb2fd4d29c1390b71b8795ae81196bfd60293adf99f9d32a0aff06288fcdac55f', - '0x23cb7121166b9a2f93ae0b7c05bde02eae50d64449b2cbb42bc84e9d38d6cc89', -]; - -export const constants = { - BASE_16: 16, - INVALID_OPCODE: 'invalid opcode', - TESTRPC_NETWORK_ID: 50, - // Note(albrow): In practice V8 and most other engines limit the minimum - // interval for setInterval to 10ms. We still set it to 0 here in order to - // ensure we always use the minimum interval. - AWAIT_TRANSACTION_MINED_MS: 0, - MAX_ETHERTOKEN_WITHDRAW_GAS: 43000, - MAX_EXECUTE_TRANSACTION_GAS: 1000000, - MAX_TOKEN_TRANSFERFROM_GAS: 80000, - MAX_TOKEN_APPROVE_GAS: 60000, - MAX_TRANSFER_FROM_GAS: 150000, - DUMMY_TOKEN_NAME: '', - DUMMY_TOKEN_SYMBOL: '', - DUMMY_TOKEN_DECIMALS: new BigNumber(18), - DUMMY_TOKEN_TOTAL_SUPPLY: new BigNumber(0), - NULL_BYTES: '0x', - NUM_DUMMY_ERC20_TO_DEPLOY: 3, - NUM_DUMMY_ERC721_TO_DEPLOY: 2, - NUM_ERC721_TOKENS_TO_MINT: 2, - NULL_ADDRESS: '0x0000000000000000000000000000000000000000', - UNLIMITED_ALLOWANCE_IN_BASE_UNITS: new BigNumber(2).pow(256).minus(1), - TESTRPC_PRIVATE_KEYS: _.map(TESTRPC_PRIVATE_KEYS_STRINGS, privateKeyString => ethUtil.toBuffer(privateKeyString)), - INITIAL_ERC20_BALANCE: Web3Wrapper.toBaseUnitAmount(new BigNumber(10000), 18), - INITIAL_ERC20_ALLOWANCE: Web3Wrapper.toBaseUnitAmount(new BigNumber(10000), 18), - STATIC_ORDER_PARAMS: { - makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(100), 18), - takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(200), 18), - makerFee: Web3Wrapper.toBaseUnitAmount(new BigNumber(1), 18), - takerFee: Web3Wrapper.toBaseUnitAmount(new BigNumber(1), 18), - }, - WORD_LENGTH: 32, - ZERO_AMOUNT: new BigNumber(0), - PERCENTAGE_DENOMINATOR: new BigNumber(10).pow(18), - FUNCTIONS_WITH_MUTEX: [ - 'FILL_ORDER', - 'FILL_OR_KILL_ORDER', - 'BATCH_FILL_ORDERS', - 'BATCH_FILL_OR_KILL_ORDERS', - 'MARKET_BUY_ORDERS', - 'MARKET_SELL_ORDERS', - 'MATCH_ORDERS', - 'CANCEL_ORDER', - 'BATCH_CANCEL_ORDERS', - 'CANCEL_ORDERS_UP_TO', - 'SET_SIGNATURE_VALIDATOR_APPROVAL', - ], -}; diff --git a/contracts/core/test/utils/coverage.ts b/contracts/core/test/utils/coverage.ts deleted file mode 100644 index 5becfa1b6..000000000 --- a/contracts/core/test/utils/coverage.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { devConstants } from '@0x/dev-utils'; -import { CoverageSubprovider, SolCompilerArtifactAdapter } from '@0x/sol-cov'; -import * as _ from 'lodash'; - -let coverageSubprovider: CoverageSubprovider; - -export const coverage = { - getCoverageSubproviderSingleton(): CoverageSubprovider { - if (_.isUndefined(coverageSubprovider)) { - coverageSubprovider = coverage._getCoverageSubprovider(); - } - return coverageSubprovider; - }, - _getCoverageSubprovider(): CoverageSubprovider { - const defaultFromAddress = devConstants.TESTRPC_FIRST_ADDRESS; - const solCompilerArtifactAdapter = new SolCompilerArtifactAdapter(); - const isVerbose = true; - const subprovider = new CoverageSubprovider(solCompilerArtifactAdapter, defaultFromAddress, isVerbose); - return subprovider; - }, -}; diff --git a/contracts/core/test/utils/erc20_wrapper.ts b/contracts/core/test/utils/erc20_wrapper.ts index c281a2abf..d6210646c 100644 --- a/contracts/core/test/utils/erc20_wrapper.ts +++ b/contracts/core/test/utils/erc20_wrapper.ts @@ -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; diff --git a/contracts/core/test/utils/erc721_wrapper.ts b/contracts/core/test/utils/erc721_wrapper.ts index e9da553d0..b5ae34e60 100644 --- a/contracts/core/test/utils/erc721_wrapper.ts +++ b/contracts/core/test/utils/erc721_wrapper.ts @@ -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; diff --git a/contracts/core/test/utils/exchange_wrapper.ts b/contracts/core/test/utils/exchange_wrapper.ts index c28989d3f..2a24b880f 100644 --- a/contracts/core/test/utils/exchange_wrapper.ts +++ b/contracts/core/test/utils/exchange_wrapper.ts @@ -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, diff --git a/contracts/core/test/utils/fill_order_combinatorial_utils.ts b/contracts/core/test/utils/fill_order_combinatorial_utils.ts index 8046771f9..6372ad29a 100644 --- a/contracts/core/test/utils/fill_order_combinatorial_utils.ts +++ b/contracts/core/test/utils/fill_order_combinatorial_utils.ts @@ -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; diff --git a/contracts/core/test/utils/formatters.ts b/contracts/core/test/utils/formatters.ts deleted file mode 100644 index 813eb45db..000000000 --- a/contracts/core/test/utils/formatters.ts +++ /dev/null @@ -1,68 +0,0 @@ -import { SignedOrder } from '@0x/types'; -import { BigNumber } from '@0x/utils'; -import * as _ from 'lodash'; - -import { constants } from './constants'; -import { orderUtils } from './order_utils'; -import { BatchCancelOrders, BatchFillOrders, MarketBuyOrders, MarketSellOrders } from './types'; - -export const formatters = { - createBatchFill(signedOrders: SignedOrder[], takerAssetFillAmounts: BigNumber[] = []): BatchFillOrders { - const batchFill: BatchFillOrders = { - orders: [], - signatures: [], - takerAssetFillAmounts, - }; - _.forEach(signedOrders, signedOrder => { - const orderWithoutExchangeAddress = orderUtils.getOrderWithoutExchangeAddress(signedOrder); - batchFill.orders.push(orderWithoutExchangeAddress); - batchFill.signatures.push(signedOrder.signature); - if (takerAssetFillAmounts.length < signedOrders.length) { - batchFill.takerAssetFillAmounts.push(signedOrder.takerAssetAmount); - } - }); - return batchFill; - }, - createMarketSellOrders(signedOrders: SignedOrder[], takerAssetFillAmount: BigNumber): MarketSellOrders { - const marketSellOrders: MarketSellOrders = { - orders: [], - signatures: [], - takerAssetFillAmount, - }; - _.forEach(signedOrders, (signedOrder, i) => { - const orderWithoutExchangeAddress = orderUtils.getOrderWithoutExchangeAddress(signedOrder); - if (i !== 0) { - orderWithoutExchangeAddress.takerAssetData = constants.NULL_BYTES; - } - marketSellOrders.orders.push(orderWithoutExchangeAddress); - marketSellOrders.signatures.push(signedOrder.signature); - }); - return marketSellOrders; - }, - createMarketBuyOrders(signedOrders: SignedOrder[], makerAssetFillAmount: BigNumber): MarketBuyOrders { - const marketBuyOrders: MarketBuyOrders = { - orders: [], - signatures: [], - makerAssetFillAmount, - }; - _.forEach(signedOrders, (signedOrder, i) => { - const orderWithoutExchangeAddress = orderUtils.getOrderWithoutExchangeAddress(signedOrder); - if (i !== 0) { - orderWithoutExchangeAddress.makerAssetData = constants.NULL_BYTES; - } - marketBuyOrders.orders.push(orderWithoutExchangeAddress); - marketBuyOrders.signatures.push(signedOrder.signature); - }); - return marketBuyOrders; - }, - createBatchCancel(signedOrders: SignedOrder[]): BatchCancelOrders { - const batchCancel: BatchCancelOrders = { - orders: [], - }; - _.forEach(signedOrders, signedOrder => { - const orderWithoutExchangeAddress = orderUtils.getOrderWithoutExchangeAddress(signedOrder); - batchCancel.orders.push(orderWithoutExchangeAddress); - }); - return batchCancel; - }, -}; diff --git a/contracts/core/test/utils/forwarder_wrapper.ts b/contracts/core/test/utils/forwarder_wrapper.ts index a0bfcfe1d..9c5560381 100644 --- a/contracts/core/test/utils/forwarder_wrapper.ts +++ b/contracts/core/test/utils/forwarder_wrapper.ts @@ -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[], diff --git a/contracts/core/test/utils/log_decoder.ts b/contracts/core/test/utils/log_decoder.ts deleted file mode 100644 index 05b0a9204..000000000 --- a/contracts/core/test/utils/log_decoder.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { AbiDecoder, BigNumber } from '@0x/utils'; -import { Web3Wrapper } from '@0x/web3-wrapper'; -import { - AbiDefinition, - ContractArtifact, - DecodedLogArgs, - LogEntry, - LogWithDecodedArgs, - RawLog, - TransactionReceiptWithDecodedLogs, -} from 'ethereum-types'; -import * as _ from 'lodash'; - -import { artifacts } from '../../src/artifacts'; - -import { constants } from './constants'; - -export class LogDecoder { - private readonly _web3Wrapper: Web3Wrapper; - private readonly _abiDecoder: AbiDecoder; - public static wrapLogBigNumbers(log: any): any { - const argNames = _.keys(log.args); - for (const argName of argNames) { - const isWeb3BigNumber = _.startsWith(log.args[argName].constructor.toString(), 'function BigNumber('); - if (isWeb3BigNumber) { - log.args[argName] = new BigNumber(log.args[argName]); - } - } - } - constructor(web3Wrapper: Web3Wrapper) { - this._web3Wrapper = web3Wrapper; - const abiArrays: AbiDefinition[][] = []; - _.forEach(artifacts, (artifact: ContractArtifact) => { - const compilerOutput = artifact.compilerOutput; - abiArrays.push(compilerOutput.abi); - }); - this._abiDecoder = new AbiDecoder(abiArrays); - } - public decodeLogOrThrow(log: LogEntry): LogWithDecodedArgs | RawLog { - const logWithDecodedArgsOrLog = this._abiDecoder.tryToDecodeLogOrNoop(log); - // tslint:disable-next-line:no-unnecessary-type-assertion - if (_.isUndefined((logWithDecodedArgsOrLog as LogWithDecodedArgs).args)) { - throw new Error(`Unable to decode log: ${JSON.stringify(log)}`); - } - LogDecoder.wrapLogBigNumbers(logWithDecodedArgsOrLog); - return logWithDecodedArgsOrLog; - } - public async getTxWithDecodedLogsAsync(txHash: string): Promise { - const tx = await this._web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS); - tx.logs = _.map(tx.logs, log => this.decodeLogOrThrow(log)); - return tx; - } -} diff --git a/contracts/core/test/utils/match_order_tester.ts b/contracts/core/test/utils/match_order_tester.ts index 6c2c84959..8f574704e 100644 --- a/contracts/core/test/utils/match_order_tester.ts +++ b/contracts/core/test/utils/match_order_tester.ts @@ -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. diff --git a/contracts/core/test/utils/multi_sig_wrapper.ts b/contracts/core/test/utils/multi_sig_wrapper.ts index 74fd3b4d6..34c9c2578 100644 --- a/contracts/core/test/utils/multi_sig_wrapper.ts +++ b/contracts/core/test/utils/multi_sig_wrapper.ts @@ -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, diff --git a/contracts/core/test/utils/order_factory.ts b/contracts/core/test/utils/order_factory.ts deleted file mode 100644 index 2449d1a8a..000000000 --- a/contracts/core/test/utils/order_factory.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { generatePseudoRandomSalt, orderHashUtils } from '@0x/order-utils'; -import { Order, SignatureType, SignedOrder } from '@0x/types'; -import { BigNumber } from '@0x/utils'; - -import { getLatestBlockTimestampAsync } from './block_timestamp'; -import { constants } from './constants'; -import { signingUtils } from './signing_utils'; - -export class OrderFactory { - private readonly _defaultOrderParams: Partial; - private readonly _privateKey: Buffer; - constructor(privateKey: Buffer, defaultOrderParams: Partial) { - this._defaultOrderParams = defaultOrderParams; - this._privateKey = privateKey; - } - public async newSignedOrderAsync( - customOrderParams: Partial = {}, - signatureType: SignatureType = SignatureType.EthSign, - ): Promise { - const tenMinutesInSeconds = 10 * 60; - const currentBlockTimestamp = await getLatestBlockTimestampAsync(); - const order = ({ - senderAddress: constants.NULL_ADDRESS, - expirationTimeSeconds: new BigNumber(currentBlockTimestamp).add(tenMinutesInSeconds), - salt: generatePseudoRandomSalt(), - takerAddress: constants.NULL_ADDRESS, - ...this._defaultOrderParams, - ...customOrderParams, - } as any) as Order; - const orderHashBuff = orderHashUtils.getOrderHashBuffer(order); - const signature = signingUtils.signMessage(orderHashBuff, this._privateKey, signatureType); - const signedOrder = { - ...order, - signature: `0x${signature.toString('hex')}`, - }; - return signedOrder; - } -} diff --git a/contracts/core/test/utils/order_factory_from_scenario.ts b/contracts/core/test/utils/order_factory_from_scenario.ts index 60c8606c4..1cc962020 100644 --- a/contracts/core/test/utils/order_factory_from_scenario.ts +++ b/contracts/core/test/utils/order_factory_from_scenario.ts @@ -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); diff --git a/contracts/core/test/utils/order_utils.ts b/contracts/core/test/utils/order_utils.ts deleted file mode 100644 index 4f7a34011..000000000 --- a/contracts/core/test/utils/order_utils.ts +++ /dev/null @@ -1,58 +0,0 @@ -import { OrderWithoutExchangeAddress, SignedOrder } from '@0x/types'; -import { BigNumber } from '@0x/utils'; - -import { constants } from './constants'; -import { CancelOrder, MatchOrder } from './types'; - -export const orderUtils = { - getPartialAmountFloor(numerator: BigNumber, denominator: BigNumber, target: BigNumber): BigNumber { - const partialAmount = numerator - .mul(target) - .div(denominator) - .floor(); - return partialAmount; - }, - createFill: (signedOrder: SignedOrder, takerAssetFillAmount?: BigNumber) => { - const fill = { - order: orderUtils.getOrderWithoutExchangeAddress(signedOrder), - takerAssetFillAmount: takerAssetFillAmount || signedOrder.takerAssetAmount, - signature: signedOrder.signature, - }; - return fill; - }, - createCancel(signedOrder: SignedOrder, takerAssetCancelAmount?: BigNumber): CancelOrder { - const cancel = { - order: orderUtils.getOrderWithoutExchangeAddress(signedOrder), - takerAssetCancelAmount: takerAssetCancelAmount || signedOrder.takerAssetAmount, - }; - return cancel; - }, - getOrderWithoutExchangeAddress(signedOrder: SignedOrder): OrderWithoutExchangeAddress { - const orderStruct = { - senderAddress: signedOrder.senderAddress, - makerAddress: signedOrder.makerAddress, - takerAddress: signedOrder.takerAddress, - feeRecipientAddress: signedOrder.feeRecipientAddress, - makerAssetAmount: signedOrder.makerAssetAmount, - takerAssetAmount: signedOrder.takerAssetAmount, - makerFee: signedOrder.makerFee, - takerFee: signedOrder.takerFee, - expirationTimeSeconds: signedOrder.expirationTimeSeconds, - salt: signedOrder.salt, - makerAssetData: signedOrder.makerAssetData, - takerAssetData: signedOrder.takerAssetData, - }; - return orderStruct; - }, - createMatchOrders(signedOrderLeft: SignedOrder, signedOrderRight: SignedOrder): MatchOrder { - const fill = { - left: orderUtils.getOrderWithoutExchangeAddress(signedOrderLeft), - right: orderUtils.getOrderWithoutExchangeAddress(signedOrderRight), - leftSignature: signedOrderLeft.signature, - rightSignature: signedOrderRight.signature, - }; - fill.right.makerAssetData = constants.NULL_BYTES; - fill.right.takerAssetData = constants.NULL_BYTES; - return fill; - }, -}; diff --git a/contracts/core/test/utils/profiler.ts b/contracts/core/test/utils/profiler.ts deleted file mode 100644 index 2c7c1d66c..000000000 --- a/contracts/core/test/utils/profiler.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { devConstants } from '@0x/dev-utils'; -import { ProfilerSubprovider, SolCompilerArtifactAdapter } from '@0x/sol-cov'; -import * as _ from 'lodash'; - -let profilerSubprovider: ProfilerSubprovider; - -export const profiler = { - start(): void { - profiler.getProfilerSubproviderSingleton().start(); - }, - stop(): void { - profiler.getProfilerSubproviderSingleton().stop(); - }, - getProfilerSubproviderSingleton(): ProfilerSubprovider { - if (_.isUndefined(profilerSubprovider)) { - profilerSubprovider = profiler._getProfilerSubprovider(); - } - return profilerSubprovider; - }, - _getProfilerSubprovider(): ProfilerSubprovider { - const defaultFromAddress = devConstants.TESTRPC_FIRST_ADDRESS; - const solCompilerArtifactAdapter = new SolCompilerArtifactAdapter(); - const isVerbose = true; - const subprovider = new ProfilerSubprovider(solCompilerArtifactAdapter, defaultFromAddress, isVerbose); - return subprovider; - }, -}; diff --git a/contracts/core/test/utils/revert_trace.ts b/contracts/core/test/utils/revert_trace.ts deleted file mode 100644 index 3f74fd28b..000000000 --- a/contracts/core/test/utils/revert_trace.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { devConstants } from '@0x/dev-utils'; -import { RevertTraceSubprovider, SolCompilerArtifactAdapter } from '@0x/sol-cov'; -import * as _ from 'lodash'; - -let revertTraceSubprovider: RevertTraceSubprovider; - -export const revertTrace = { - getRevertTraceSubproviderSingleton(): RevertTraceSubprovider { - if (_.isUndefined(revertTraceSubprovider)) { - revertTraceSubprovider = revertTrace._getRevertTraceSubprovider(); - } - return revertTraceSubprovider; - }, - _getRevertTraceSubprovider(): RevertTraceSubprovider { - const defaultFromAddress = devConstants.TESTRPC_FIRST_ADDRESS; - const solCompilerArtifactAdapter = new SolCompilerArtifactAdapter(); - const isVerbose = true; - const subprovider = new RevertTraceSubprovider(solCompilerArtifactAdapter, defaultFromAddress, isVerbose); - return subprovider; - }, -}; diff --git a/contracts/core/test/utils/signing_utils.ts b/contracts/core/test/utils/signing_utils.ts deleted file mode 100644 index 21f864bfa..000000000 --- a/contracts/core/test/utils/signing_utils.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { SignatureType } from '@0x/types'; -import * as ethUtil from 'ethereumjs-util'; - -export const signingUtils = { - signMessage(message: Buffer, privateKey: Buffer, signatureType: SignatureType): Buffer { - if (signatureType === SignatureType.EthSign) { - const prefixedMessage = ethUtil.hashPersonalMessage(message); - const ecSignature = ethUtil.ecsign(prefixedMessage, privateKey); - const signature = Buffer.concat([ - ethUtil.toBuffer(ecSignature.v), - ecSignature.r, - ecSignature.s, - ethUtil.toBuffer(signatureType), - ]); - return signature; - } else if (signatureType === SignatureType.EIP712) { - const ecSignature = ethUtil.ecsign(message, privateKey); - const signature = Buffer.concat([ - ethUtil.toBuffer(ecSignature.v), - ecSignature.r, - ecSignature.s, - ethUtil.toBuffer(signatureType), - ]); - return signature; - } else { - throw new Error(`${signatureType} is not a valid signature type`); - } - }, -}; diff --git a/contracts/core/test/utils/test_with_reference.ts b/contracts/core/test/utils/test_with_reference.ts deleted file mode 100644 index b80be4a6c..000000000 --- a/contracts/core/test/utils/test_with_reference.ts +++ /dev/null @@ -1,139 +0,0 @@ -import * as chai from 'chai'; -import * as _ from 'lodash'; - -import { chaiSetup } from './chai_setup'; - -chaiSetup.configure(); -const expect = chai.expect; - -class Value { - public value: T; - constructor(value: T) { - this.value = value; - } -} - -// tslint:disable-next-line: max-classes-per-file -class ErrorMessage { - public error: string; - constructor(message: string) { - this.error = message; - } -} - -type PromiseResult = Value | ErrorMessage; - -// TODO(albrow): This seems like a generic utility function that could exist in -// lodash. We should replace it by a library implementation, or move it to our -// own. -async function evaluatePromise(promise: Promise): Promise> { - try { - return new Value(await promise); - } catch (e) { - return new ErrorMessage(e.message); - } -} - -export async function testWithReferenceFuncAsync( - referenceFunc: (p0: P0) => Promise, - testFunc: (p0: P0) => Promise, - values: [P0], -): Promise; -export async function testWithReferenceFuncAsync( - referenceFunc: (p0: P0, p1: P1) => Promise, - testFunc: (p0: P0, p1: P1) => Promise, - values: [P0, P1], -): Promise; -export async function testWithReferenceFuncAsync( - referenceFunc: (p0: P0, p1: P1, p2: P2) => Promise, - testFunc: (p0: P0, p1: P1, p2: P2) => Promise, - values: [P0, P1, P2], -): Promise; -export async function testWithReferenceFuncAsync( - referenceFunc: (p0: P0, p1: P1, p2: P2, p3: P3) => Promise, - testFunc: (p0: P0, p1: P1, p2: P2, p3: P3) => Promise, - values: [P0, P1, P2, P3], -): Promise; -export async function testWithReferenceFuncAsync( - referenceFunc: (p0: P0, p1: P1, p2: P2, p3: P3, p4: P4) => Promise, - testFunc: (p0: P0, p1: P1, p2: P2, p3: P3, p4: P4) => Promise, - values: [P0, P1, P2, P3, P4], -): Promise; - -/** - * Tests the behavior of a test function by comparing it to the expected - * behavior (defined by a reference function). - * - * 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". The test 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. - * - * @param referenceFuncAsync a reference function implemented in pure - * JavaScript/TypeScript which accepts N arguments and returns the "expected - * result" or throws/rejects with the "expected error". - * @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 throws/rejects with the "actual error". - * @param values an array of N values, where each value corresponds in-order to - * an argument to both the test function and the reference 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 testWithReferenceFuncAsync( - referenceFuncAsync: (...args: any[]) => Promise, - testFuncAsync: (...args: any[]) => Promise, - values: any[], -): Promise { - // Measure correct behaviour - const expected = await evaluatePromise(referenceFuncAsync(...values)); - - // Measure actual behaviour - const actual = await evaluatePromise(testFuncAsync(...values)); - - // Compare behaviour - if (expected instanceof ErrorMessage) { - // If we expected an error, check if the actual error message contains the - // expected error message. - if (!(actual instanceof ErrorMessage)) { - throw new Error( - `Expected error containing ${expected.error} but got no error\n\tTest case: ${_getTestCaseString( - referenceFuncAsync, - values, - )}`, - ); - } - expect(actual.error).to.contain( - expected.error, - `${actual.error}\n\tTest case: ${_getTestCaseString(referenceFuncAsync, values)}`, - ); - } else { - // If we do not expect an error, compare actual and expected directly. - expect(actual).to.deep.equal(expected, `Test case ${_getTestCaseString(referenceFuncAsync, values)}`); - } -} - -function _getTestCaseString(referenceFuncAsync: (...args: any[]) => Promise, values: any[]): string { - const paramNames = _getParameterNames(referenceFuncAsync); - return JSON.stringify(_.zipObject(paramNames, values)); -} - -// Source: https://stackoverflow.com/questions/1007981/how-to-get-function-parameter-names-values-dynamically -function _getParameterNames(func: (...args: any[]) => any): string[] { - return _.toString(func) - .replace(/[/][/].*$/gm, '') // strip single-line comments - .replace(/\s+/g, '') // strip white space - .replace(/[/][*][^/*]*[*][/]/g, '') // strip multi-line comments - .split('){', 1)[0] - .replace(/^[^(]*[(]/, '') // extract the parameters - .replace(/=[^,]+/g, '') // strip any ES6 defaults - .split(',') - .filter(Boolean); // split & filter [""] -} diff --git a/contracts/core/test/utils/transaction_factory.ts b/contracts/core/test/utils/transaction_factory.ts deleted file mode 100644 index dbab3ade4..000000000 --- a/contracts/core/test/utils/transaction_factory.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { eip712Utils, generatePseudoRandomSalt } from '@0x/order-utils'; -import { SignatureType } from '@0x/types'; -import { signTypedDataUtils } from '@0x/utils'; -import * as ethUtil from 'ethereumjs-util'; - -import { signingUtils } from './signing_utils'; -import { SignedTransaction } from './types'; - -export class TransactionFactory { - private readonly _signerBuff: Buffer; - private readonly _exchangeAddress: string; - private readonly _privateKey: Buffer; - constructor(privateKey: Buffer, exchangeAddress: string) { - this._privateKey = privateKey; - this._exchangeAddress = exchangeAddress; - this._signerBuff = ethUtil.privateToAddress(this._privateKey); - } - public newSignedTransaction(data: string, signatureType: SignatureType = SignatureType.EthSign): SignedTransaction { - const salt = generatePseudoRandomSalt(); - const signerAddress = `0x${this._signerBuff.toString('hex')}`; - const executeTransactionData = { - salt, - signerAddress, - data, - }; - - const typedData = eip712Utils.createZeroExTransactionTypedData(executeTransactionData, this._exchangeAddress); - const eip712MessageBuffer = signTypedDataUtils.generateTypedDataHash(typedData); - const signature = signingUtils.signMessage(eip712MessageBuffer, this._privateKey, signatureType); - const signedTx = { - exchangeAddress: this._exchangeAddress, - signature: `0x${signature.toString('hex')}`, - ...executeTransactionData, - }; - return signedTx; - } -} diff --git a/contracts/core/test/utils/type_encoding_utils.ts b/contracts/core/test/utils/type_encoding_utils.ts deleted file mode 100644 index bfd9c9ef5..000000000 --- a/contracts/core/test/utils/type_encoding_utils.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { BigNumber } from '@0x/utils'; -import BN = require('bn.js'); -import ethUtil = require('ethereumjs-util'); - -import { constants } from './constants'; - -export const typeEncodingUtils = { - encodeUint256(value: BigNumber): Buffer { - const base = 10; - const formattedValue = new BN(value.toString(base)); - const encodedValue = ethUtil.toBuffer(formattedValue); - // tslint:disable-next-line:custom-no-magic-numbers - const paddedValue = ethUtil.setLengthLeft(encodedValue, constants.WORD_LENGTH); - return paddedValue; - }, - decodeUint256(encodedValue: Buffer): BigNumber { - const formattedValue = ethUtil.bufferToHex(encodedValue); - const value = new BigNumber(formattedValue, constants.BASE_16); - return value; - }, -}; diff --git a/contracts/core/test/utils/types.ts b/contracts/core/test/utils/types.ts deleted file mode 100644 index 9fc9e1570..000000000 --- a/contracts/core/test/utils/types.ts +++ /dev/null @@ -1,241 +0,0 @@ -import { OrderWithoutExchangeAddress } from '@0x/types'; -import { BigNumber } from '@0x/utils'; -import { AbiDefinition } from 'ethereum-types'; - -export interface ERC20BalancesByOwner { - [ownerAddress: string]: { - [tokenAddress: string]: BigNumber; - }; -} - -export interface ERC721TokenIdsByOwner { - [ownerAddress: string]: { - [tokenAddress: string]: BigNumber[]; - }; -} - -export interface SubmissionContractEventArgs { - transactionId: BigNumber; -} - -export interface BatchFillOrders { - orders: OrderWithoutExchangeAddress[]; - signatures: string[]; - takerAssetFillAmounts: BigNumber[]; -} - -export interface MarketSellOrders { - orders: OrderWithoutExchangeAddress[]; - signatures: string[]; - takerAssetFillAmount: BigNumber; -} - -export interface MarketBuyOrders { - orders: OrderWithoutExchangeAddress[]; - signatures: string[]; - makerAssetFillAmount: BigNumber; -} - -export interface BatchCancelOrders { - orders: OrderWithoutExchangeAddress[]; -} - -export interface CancelOrdersBefore { - salt: BigNumber; -} - -export interface TransactionDataParams { - name: string; - abi: AbiDefinition[]; - args: any[]; -} - -export interface MultiSigConfig { - owners: string[]; - confirmationsRequired: number; - secondsRequired: number; -} - -export interface MultiSigConfigByNetwork { - [networkName: string]: MultiSigConfig; -} - -export interface Token { - address?: string; - name: string; - symbol: string; - decimals: number; - ipfsHash: string; - swarmHash: string; -} - -export enum OrderStatus { - INVALID, - INVALID_MAKER_ASSET_AMOUNT, - INVALID_TAKER_ASSET_AMOUNT, - FILLABLE, - EXPIRED, - FULLY_FILLED, - CANCELLED, -} - -export enum ContractName { - TokenRegistry = 'TokenRegistry', - MultiSigWalletWithTimeLock = 'MultiSigWalletWithTimeLock', - Exchange = 'Exchange', - ZRXToken = 'ZRXToken', - DummyERC20Token = 'DummyERC20Token', - EtherToken = 'WETH9', - AssetProxyOwner = 'AssetProxyOwner', - AccountLevels = 'AccountLevels', - EtherDelta = 'EtherDelta', - Arbitrage = 'Arbitrage', - TestAssetDataDecoders = 'TestAssetDataDecoders', - TestAssetProxyDispatcher = 'TestAssetProxyDispatcher', - TestLibs = 'TestLibs', - TestSignatureValidator = 'TestSignatureValidator', - ERC20Proxy = 'ERC20Proxy', - ERC721Proxy = 'ERC721Proxy', - DummyERC721Receiver = 'DummyERC721Receiver', - DummyERC721Token = 'DummyERC721Token', - TestLibBytes = 'TestLibBytes', - TestWallet = 'TestWallet', - Authorizable = 'Authorizable', - Whitelist = 'Whitelist', - Forwarder = 'Forwarder', -} - -export interface SignedTransaction { - exchangeAddress: string; - salt: BigNumber; - signerAddress: string; - data: string; - signature: string; -} - -export interface TransferAmountsByMatchOrders { - // Left Maker - amountBoughtByLeftMaker: BigNumber; - amountSoldByLeftMaker: BigNumber; - feePaidByLeftMaker: BigNumber; - // Right Maker - amountBoughtByRightMaker: BigNumber; - amountSoldByRightMaker: BigNumber; - feePaidByRightMaker: BigNumber; - // Taker - amountReceivedByTaker: BigNumber; - feePaidByTakerLeft: BigNumber; - feePaidByTakerRight: BigNumber; -} - -export interface TransferAmountsLoggedByMatchOrders { - makerAddress: string; - takerAddress: string; - makerAssetFilledAmount: string; - takerAssetFilledAmount: string; - makerFeePaid: string; - takerFeePaid: string; -} - -export interface OrderInfo { - orderStatus: number; - orderHash: string; - orderTakerAssetFilledAmount: BigNumber; -} - -export interface CancelOrder { - order: OrderWithoutExchangeAddress; - takerAssetCancelAmount: BigNumber; -} - -export interface MatchOrder { - left: OrderWithoutExchangeAddress; - right: OrderWithoutExchangeAddress; - leftSignature: string; - rightSignature: string; -} - -// Combinatorial testing types - -export enum FeeRecipientAddressScenario { - BurnAddress = 'BURN_ADDRESS', - EthUserAddress = 'ETH_USER_ADDRESS', -} - -export enum OrderAssetAmountScenario { - Zero = 'ZERO', - Large = 'LARGE', - Small = 'SMALL', -} - -export enum TakerScenario { - CorrectlySpecified = 'CORRECTLY_SPECIFIED', - IncorrectlySpecified = 'INCORRECTLY_SPECIFIED', - Unspecified = 'UNSPECIFIED', -} - -export enum ExpirationTimeSecondsScenario { - InPast = 'IN_PAST', - InFuture = 'IN_FUTURE', -} - -export enum AssetDataScenario { - ERC20ZeroDecimals = 'ERC20_ZERO_DECIMALS', - ZRXFeeToken = 'ZRX_FEE_TOKEN', - ERC20FiveDecimals = 'ERC20_FIVE_DECIMALS', - ERC20NonZRXEighteenDecimals = 'ERC20_NON_ZRX_EIGHTEEN_DECIMALS', - ERC721 = 'ERC721', -} - -export enum TakerAssetFillAmountScenario { - Zero = 'ZERO', - GreaterThanRemainingFillableTakerAssetAmount = 'GREATER_THAN_REMAINING_FILLABLE_TAKER_ASSET_AMOUNT', - LessThanRemainingFillableTakerAssetAmount = 'LESS_THAN_REMAINING_FILLABLE_TAKER_ASSET_AMOUNT', - ExactlyRemainingFillableTakerAssetAmount = 'EXACTLY_REMAINING_FILLABLE_TAKER_ASSET_AMOUNT', -} - -export interface OrderScenario { - takerScenario: TakerScenario; - feeRecipientScenario: FeeRecipientAddressScenario; - makerAssetAmountScenario: OrderAssetAmountScenario; - takerAssetAmountScenario: OrderAssetAmountScenario; - makerFeeScenario: OrderAssetAmountScenario; - takerFeeScenario: OrderAssetAmountScenario; - expirationTimeSecondsScenario: ExpirationTimeSecondsScenario; - makerAssetDataScenario: AssetDataScenario; - takerAssetDataScenario: AssetDataScenario; -} - -export enum BalanceAmountScenario { - Exact = 'EXACT', - TooLow = 'TOO_LOW', - Higher = 'HIGHER', -} - -export enum AllowanceAmountScenario { - Exact = 'EXACT', - TooLow = 'TOO_LOW', - Higher = 'HIGHER', - Unlimited = 'UNLIMITED', -} - -export interface TraderStateScenario { - traderAssetBalance: BalanceAmountScenario; - traderAssetAllowance: AllowanceAmountScenario; - zrxFeeBalance: BalanceAmountScenario; - zrxFeeAllowance: AllowanceAmountScenario; -} - -export interface FillScenario { - orderScenario: OrderScenario; - takerAssetFillAmountScenario: TakerAssetFillAmountScenario; - makerStateScenario: TraderStateScenario; - takerStateScenario: TraderStateScenario; -} - -export interface FillResults { - makerAssetFilledAmount: BigNumber; - takerAssetFilledAmount: BigNumber; - makerFeePaid: BigNumber; - takerFeePaid: BigNumber; -} diff --git a/contracts/core/test/utils/web3_wrapper.ts b/contracts/core/test/utils/web3_wrapper.ts deleted file mode 100644 index f7b1a732a..000000000 --- a/contracts/core/test/utils/web3_wrapper.ts +++ /dev/null @@ -1,84 +0,0 @@ -import { devConstants, env, EnvVars, web3Factory } from '@0x/dev-utils'; -import { prependSubprovider, Web3ProviderEngine } from '@0x/subproviders'; -import { logUtils } from '@0x/utils'; -import { Web3Wrapper } from '@0x/web3-wrapper'; -import * as _ from 'lodash'; - -import { coverage } from './coverage'; -import { profiler } from './profiler'; -import { revertTrace } from './revert_trace'; - -enum ProviderType { - Ganache = 'ganache', - Geth = 'geth', -} - -let testProvider: ProviderType; -switch (process.env.TEST_PROVIDER) { - case undefined: - testProvider = ProviderType.Ganache; - break; - case 'ganache': - testProvider = ProviderType.Ganache; - break; - case 'geth': - testProvider = ProviderType.Geth; - break; - default: - throw new Error(`Unknown TEST_PROVIDER: ${process.env.TEST_PROVIDER}`); -} - -const ganacheTxDefaults = { - from: devConstants.TESTRPC_FIRST_ADDRESS, - gas: devConstants.GAS_LIMIT, -}; -const gethTxDefaults = { - from: devConstants.TESTRPC_FIRST_ADDRESS, -}; -export const txDefaults = testProvider === ProviderType.Ganache ? ganacheTxDefaults : gethTxDefaults; - -const gethConfigs = { - shouldUseInProcessGanache: false, - rpcUrl: 'http://localhost:8501', - shouldUseFakeGasEstimate: false, -}; -const ganacheConfigs = { - shouldUseInProcessGanache: true, -}; -const providerConfigs = testProvider === ProviderType.Ganache ? ganacheConfigs : gethConfigs; - -export const provider: Web3ProviderEngine = web3Factory.getRpcProvider(providerConfigs); -const isCoverageEnabled = env.parseBoolean(EnvVars.SolidityCoverage); -const isProfilerEnabled = env.parseBoolean(EnvVars.SolidityProfiler); -const isRevertTraceEnabled = env.parseBoolean(EnvVars.SolidityRevertTrace); -const enabledSubproviderCount = _.filter( - [isCoverageEnabled, isProfilerEnabled, isRevertTraceEnabled], - _.identity.bind(_), -).length; -if (enabledSubproviderCount > 1) { - throw new Error(`Only one of coverage, profiler, or revert trace subproviders can be enabled at a time`); -} -if (isCoverageEnabled) { - const coverageSubprovider = coverage.getCoverageSubproviderSingleton(); - prependSubprovider(provider, coverageSubprovider); -} -if (isProfilerEnabled) { - if (testProvider === ProviderType.Ganache) { - logUtils.warn( - "Gas costs in Ganache traces are incorrect and we don't recommend using it for profiling. Please switch to Geth", - ); - process.exit(1); - } - const profilerSubprovider = profiler.getProfilerSubproviderSingleton(); - logUtils.log( - "By default profilerSubprovider is stopped so that you don't get noise from setup code. Don't forget to start it before the code you want to profile and stop it afterwards", - ); - profilerSubprovider.stop(); - prependSubprovider(provider, profilerSubprovider); -} -if (isRevertTraceEnabled) { - const revertTraceSubprovider = revertTrace.getRevertTraceSubproviderSingleton(); - prependSubprovider(provider, revertTraceSubprovider); -} - -export const web3Wrapper = new Web3Wrapper(provider); diff --git a/contracts/core/test/utils_test/test_with_reference.ts b/contracts/core/test/utils_test/test_with_reference.ts deleted file mode 100644 index 8d633cd1f..000000000 --- a/contracts/core/test/utils_test/test_with_reference.ts +++ /dev/null @@ -1,63 +0,0 @@ -import * as chai from 'chai'; - -import { chaiSetup } from '../utils/chai_setup'; -import { testWithReferenceFuncAsync } from '../utils/test_with_reference'; - -chaiSetup.configure(); -const expect = chai.expect; - -async function divAsync(x: number, y: number): Promise { - if (y === 0) { - throw new Error('MathError: divide by zero'); - } - return x / y; -} - -// returns an async function that always returns the given value. -function alwaysValueFunc(value: number): (x: number, y: number) => Promise { - return async (x: number, y: number) => value; -} - -// returns an async function which always throws/rejects with the given error -// message. -function alwaysFailFunc(errMessage: string): (x: number, y: number) => Promise { - return async (x: number, y: number) => { - throw new Error(errMessage); - }; -} - -describe('testWithReferenceFuncAsync', () => { - it('passes when both succeed and actual === expected', async () => { - await testWithReferenceFuncAsync(alwaysValueFunc(0.5), divAsync, [1, 2]); - }); - - it('passes when both fail and actual error contains expected error', async () => { - await testWithReferenceFuncAsync(alwaysFailFunc('divide by zero'), divAsync, [1, 0]); - }); - - it('fails when both succeed and actual !== expected', async () => { - expect(testWithReferenceFuncAsync(alwaysValueFunc(3), divAsync, [1, 2])).to.be.rejectedWith( - 'Test case {"x":1,"y":2}: expected { value: 0.5 } to deeply equal { value: 3 }', - ); - }); - - it('fails when both fail and actual error does not contain expected error', async () => { - expect( - testWithReferenceFuncAsync(alwaysFailFunc('Unexpected math error'), divAsync, [1, 0]), - ).to.be.rejectedWith( - 'MathError: divide by zero\n\tTest case: {"x":1,"y":0}: expected \'MathError: divide by zero\' to include \'Unexpected math error\'', - ); - }); - - it('fails when referenceFunc succeeds and testFunc fails', async () => { - expect(testWithReferenceFuncAsync(alwaysValueFunc(0), divAsync, [1, 0])).to.be.rejectedWith( - 'Test case {"x":1,"y":0}: expected { error: \'MathError: divide by zero\' } to deeply equal { value: 0 }', - ); - }); - - it('fails when referenceFunc fails and testFunc succeeds', async () => { - expect(testWithReferenceFuncAsync(alwaysFailFunc('divide by zero'), divAsync, [1, 2])).to.be.rejectedWith( - 'Expected error containing divide by zero but got no error\n\tTest case: {"x":1,"y":2}', - ); - }); -}); diff --git a/contracts/multisig/.solhint.json b/contracts/multisig/.solhint.json new file mode 100644 index 000000000..076afe9f3 --- /dev/null +++ b/contracts/multisig/.solhint.json @@ -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" + } +} diff --git a/contracts/multisig/.solhintignore b/contracts/multisig/.solhintignore new file mode 100644 index 000000000..1e33ec53b --- /dev/null +++ b/contracts/multisig/.solhintignore @@ -0,0 +1,3 @@ +contracts/tokens/ZRXToken/ERC20Token_v1.sol +contracts/tokens/ZRXToken/Token_v1.sol +contracts/tokens/ZRXToken/UnlimitedAllowanceToken_v1.sol diff --git a/contracts/multisig/CHANGELOG.json b/contracts/multisig/CHANGELOG.json new file mode 100644 index 000000000..3f57a33d6 --- /dev/null +++ b/contracts/multisig/CHANGELOG.json @@ -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" + } + } + ] + } +] diff --git a/contracts/multisig/README.md b/contracts/multisig/README.md new file mode 100644 index 000000000..97a2816ff --- /dev/null +++ b/contracts/multisig/README.md @@ -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. diff --git a/contracts/multisig/compiler.json b/contracts/multisig/compiler.json new file mode 100644 index 000000000..5a1f689e2 --- /dev/null +++ b/contracts/multisig/compiler.json @@ -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"] +} diff --git a/contracts/multisig/contracts/multisig/MultiSigWallet.sol b/contracts/multisig/contracts/multisig/MultiSigWallet.sol new file mode 100644 index 000000000..516e7391c --- /dev/null +++ b/contracts/multisig/contracts/multisig/MultiSigWallet.sol @@ -0,0 +1,393 @@ +// solhint-disable +pragma solidity ^0.4.15; + + +/// @title Multisignature wallet - Allows multiple parties to agree on transactions before execution. +/// @author Stefan George - +contract MultiSigWallet { + + /* + * Events + */ + event Confirmation(address indexed sender, uint indexed transactionId); + event Revocation(address indexed sender, uint indexed transactionId); + event Submission(uint indexed transactionId); + event Execution(uint indexed transactionId); + event ExecutionFailure(uint indexed transactionId); + event Deposit(address indexed sender, uint value); + event OwnerAddition(address indexed owner); + event OwnerRemoval(address indexed owner); + event RequirementChange(uint required); + + /* + * Constants + */ + uint constant public MAX_OWNER_COUNT = 50; + + /* + * Storage + */ + mapping (uint => Transaction) public transactions; + mapping (uint => mapping (address => bool)) public confirmations; + mapping (address => bool) public isOwner; + address[] public owners; + uint public required; + uint public transactionCount; + + struct Transaction { + address destination; + uint value; + bytes data; + bool executed; + } + + /* + * Modifiers + */ + modifier onlyWallet() { + require(msg.sender == address(this)); + _; + } + + modifier ownerDoesNotExist(address owner) { + require(!isOwner[owner]); + _; + } + + modifier ownerExists(address owner) { + require(isOwner[owner]); + _; + } + + modifier transactionExists(uint transactionId) { + require(transactions[transactionId].destination != 0); + _; + } + + modifier confirmed(uint transactionId, address owner) { + require(confirmations[transactionId][owner]); + _; + } + + modifier notConfirmed(uint transactionId, address owner) { + require(!confirmations[transactionId][owner]); + _; + } + + modifier notExecuted(uint transactionId) { + require(!transactions[transactionId].executed); + _; + } + + modifier notNull(address _address) { + require(_address != 0); + _; + } + + modifier validRequirement(uint ownerCount, uint _required) { + require(ownerCount <= MAX_OWNER_COUNT + && _required <= ownerCount + && _required != 0 + && ownerCount != 0); + _; + } + + /// @dev Fallback function allows to deposit ether. + function() + payable + { + if (msg.value > 0) + Deposit(msg.sender, msg.value); + } + + /* + * Public functions + */ + /// @dev Contract constructor sets initial owners and required number of confirmations. + /// @param _owners List of initial owners. + /// @param _required Number of required confirmations. + function MultiSigWallet(address[] _owners, uint _required) + public + validRequirement(_owners.length, _required) + { + for (uint i=0; i<_owners.length; i++) { + require(!isOwner[_owners[i]] && _owners[i] != 0); + isOwner[_owners[i]] = true; + } + owners = _owners; + required = _required; + } + + /// @dev Allows to add a new owner. Transaction has to be sent by wallet. + /// @param owner Address of new owner. + function addOwner(address owner) + public + onlyWallet + ownerDoesNotExist(owner) + notNull(owner) + validRequirement(owners.length + 1, required) + { + isOwner[owner] = true; + owners.push(owner); + OwnerAddition(owner); + } + + /// @dev Allows to remove an owner. Transaction has to be sent by wallet. + /// @param owner Address of owner. + function removeOwner(address owner) + public + onlyWallet + ownerExists(owner) + { + isOwner[owner] = false; + for (uint i=0; i owners.length) + changeRequirement(owners.length); + OwnerRemoval(owner); + } + + /// @dev Allows to replace an owner with a new owner. Transaction has to be sent by wallet. + /// @param owner Address of owner to be replaced. + /// @param newOwner Address of new owner. + function replaceOwner(address owner, address newOwner) + public + onlyWallet + ownerExists(owner) + ownerDoesNotExist(newOwner) + { + for (uint i=0; i +// solhint-disable not-rely-on-time +contract MultiSigWalletWithTimeLock is + MultiSigWallet +{ + event ConfirmationTimeSet(uint256 indexed transactionId, uint256 confirmationTime); + event TimeLockChange(uint256 secondsTimeLocked); + + uint256 public secondsTimeLocked; + + mapping (uint256 => uint256) public confirmationTimes; + + modifier notFullyConfirmed(uint256 transactionId) { + require( + !isConfirmed(transactionId), + "TX_FULLY_CONFIRMED" + ); + _; + } + + modifier fullyConfirmed(uint256 transactionId) { + require( + isConfirmed(transactionId), + "TX_NOT_FULLY_CONFIRMED" + ); + _; + } + + modifier pastTimeLock(uint256 transactionId) { + require( + block.timestamp >= confirmationTimes[transactionId] + secondsTimeLocked, + "TIME_LOCK_INCOMPLETE" + ); + _; + } + + /// @dev Contract constructor sets initial owners, required number of confirmations, and time lock. + /// @param _owners List of initial owners. + /// @param _required Number of required confirmations. + /// @param _secondsTimeLocked Duration needed after a transaction is confirmed and before it becomes executable, in seconds. + constructor ( + address[] _owners, + uint256 _required, + uint256 _secondsTimeLocked + ) + public + MultiSigWallet(_owners, _required) + { + secondsTimeLocked = _secondsTimeLocked; + } + + /// @dev Changes the duration of the time lock for transactions. + /// @param _secondsTimeLocked Duration needed after a transaction is confirmed and before it becomes executable, in seconds. + function changeTimeLock(uint256 _secondsTimeLocked) + public + onlyWallet + { + secondsTimeLocked = _secondsTimeLocked; + emit TimeLockChange(_secondsTimeLocked); + } + + /// @dev Allows an owner to confirm a transaction. + /// @param transactionId Transaction ID. + function confirmTransaction(uint256 transactionId) + public + ownerExists(msg.sender) + transactionExists(transactionId) + notConfirmed(transactionId, msg.sender) + notFullyConfirmed(transactionId) + { + confirmations[transactionId][msg.sender] = true; + emit Confirmation(msg.sender, transactionId); + if (isConfirmed(transactionId)) { + setConfirmationTime(transactionId, block.timestamp); + } + } + + /// @dev Allows anyone to execute a confirmed transaction. + /// @param transactionId Transaction ID. + function executeTransaction(uint256 transactionId) + public + notExecuted(transactionId) + fullyConfirmed(transactionId) + pastTimeLock(transactionId) + { + Transaction storage txn = transactions[transactionId]; + txn.executed = true; + if (external_call(txn.destination, txn.value, txn.data.length, txn.data)) { + emit Execution(transactionId); + } else { + emit ExecutionFailure(transactionId); + txn.executed = false; + } + } + + /// @dev Sets the time of when a submission first passed. + function setConfirmationTime(uint256 transactionId, uint256 confirmationTime) + internal + { + confirmationTimes[transactionId] = confirmationTime; + emit ConfirmationTimeSet(transactionId, confirmationTime); + } +} diff --git a/contracts/multisig/contracts/test/TestRejectEther/TestRejectEther.sol b/contracts/multisig/contracts/test/TestRejectEther/TestRejectEther.sol new file mode 100644 index 000000000..e523f591d --- /dev/null +++ b/contracts/multisig/contracts/test/TestRejectEther/TestRejectEther.sol @@ -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 {} diff --git a/contracts/multisig/generated-artifacts/MultiSigWallet.json b/contracts/multisig/generated-artifacts/MultiSigWallet.json new file mode 100644 index 000000000..f3a1b6249 --- /dev/null +++ b/contracts/multisig/generated-artifacts/MultiSigWallet.json @@ -0,0 +1,591 @@ +{ + "schemaVersion": "2.0.0", + "contractName": "MultiSigWallet", + "compilerOutput": { + "abi": [ + { + "constant": true, + "inputs": [ + { + "name": "", + "type": "uint256" + } + ], + "name": "owners", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "owner", + "type": "address" + } + ], + "name": "removeOwner", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "transactionId", + "type": "uint256" + } + ], + "name": "revokeConfirmation", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "", + "type": "address" + } + ], + "name": "isOwner", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "", + "type": "uint256" + }, + { + "name": "", + "type": "address" + } + ], + "name": "confirmations", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "pending", + "type": "bool" + }, + { + "name": "executed", + "type": "bool" + } + ], + "name": "getTransactionCount", + "outputs": [ + { + "name": "count", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "owner", + "type": "address" + } + ], + "name": "addOwner", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "transactionId", + "type": "uint256" + } + ], + "name": "isConfirmed", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "transactionId", + "type": "uint256" + } + ], + "name": "getConfirmationCount", + "outputs": [ + { + "name": "count", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "", + "type": "uint256" + } + ], + "name": "transactions", + "outputs": [ + { + "name": "destination", + "type": "address" + }, + { + "name": "value", + "type": "uint256" + }, + { + "name": "data", + "type": "bytes" + }, + { + "name": "executed", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getOwners", + "outputs": [ + { + "name": "", + "type": "address[]" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "from", + "type": "uint256" + }, + { + "name": "to", + "type": "uint256" + }, + { + "name": "pending", + "type": "bool" + }, + { + "name": "executed", + "type": "bool" + } + ], + "name": "getTransactionIds", + "outputs": [ + { + "name": "_transactionIds", + "type": "uint256[]" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "transactionId", + "type": "uint256" + } + ], + "name": "getConfirmations", + "outputs": [ + { + "name": "_confirmations", + "type": "address[]" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "transactionCount", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_required", + "type": "uint256" + } + ], + "name": "changeRequirement", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "transactionId", + "type": "uint256" + } + ], + "name": "confirmTransaction", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "destination", + "type": "address" + }, + { + "name": "value", + "type": "uint256" + }, + { + "name": "data", + "type": "bytes" + } + ], + "name": "submitTransaction", + "outputs": [ + { + "name": "transactionId", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MAX_OWNER_COUNT", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "required", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "owner", + "type": "address" + }, + { + "name": "newOwner", + "type": "address" + } + ], + "name": "replaceOwner", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "transactionId", + "type": "uint256" + } + ], + "name": "executeTransaction", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "name": "_owners", + "type": "address[]" + }, + { + "name": "_required", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "payable": true, + "stateMutability": "payable", + "type": "fallback" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "sender", + "type": "address" + }, + { + "indexed": true, + "name": "transactionId", + "type": "uint256" + } + ], + "name": "Confirmation", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "sender", + "type": "address" + }, + { + "indexed": true, + "name": "transactionId", + "type": "uint256" + } + ], + "name": "Revocation", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "transactionId", + "type": "uint256" + } + ], + "name": "Submission", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "transactionId", + "type": "uint256" + } + ], + "name": "Execution", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "transactionId", + "type": "uint256" + } + ], + "name": "ExecutionFailure", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "name": "value", + "type": "uint256" + } + ], + "name": "Deposit", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "owner", + "type": "address" + } + ], + "name": "OwnerAddition", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "owner", + "type": "address" + } + ], + "name": "OwnerRemoval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "name": "required", + "type": "uint256" + } + ], + "name": "RequirementChange", + "type": "event" + } + ], + "evm": { + "bytecode": { + "linkReferences": {}, + "object": + "0x60806040523480156200001157600080fd5b5060405162001a8638038062001a8683398101604052805160208201519101805190919060009082603282118015906200004b5750818111155b80156200005757508015155b80156200006357508115155b15156200006f57600080fd5b600092505b845183101562000147576002600086858151811015156200009157fe5b6020908102909101810151600160a060020a031682528101919091526040016000205460ff16158015620000e757508483815181101515620000cf57fe5b90602001906020020151600160a060020a0316600014155b1515620000f357600080fd5b60016002600087868151811015156200010857fe5b602090810291909101810151600160a060020a03168252810191909152604001600020805460ff19169115159190911790556001929092019162000074565b84516200015c9060039060208801906200016e565b50505060049190915550620002029050565b828054828255906000526020600020908101928215620001c6579160200282015b82811115620001c65782518254600160a060020a031916600160a060020a039091161782556020909201916001909101906200018f565b50620001d4929150620001d8565b5090565b620001ff91905b80821115620001d4578054600160a060020a0319168155600101620001df565b90565b61187480620002126000396000f30060806040526004361061011c5763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663025e7c27811461015e578063173825d91461019f57806320ea8d86146101cd5780632f54bf6e146101e55780633411c81c1461022757806354741525146102585780637065cb4814610289578063784547a7146102b75780638b51d13f146102cf5780639ace38c2146102e7578063a0e67e2b146103bc578063a8abe69a14610421578063b5dc40c314610446578063b77bf6001461045e578063ba51a6df14610473578063c01a8c841461048b578063c6427474146104a3578063d74f8edd14610519578063dc8452cd1461052e578063e20056e614610543578063ee22610b14610577575b600034111561015c5760408051348152905133917fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c919081900360200190a25b005b34801561016a57600080fd5b5061017660043561058f565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b3480156101ab57600080fd5b5061015c73ffffffffffffffffffffffffffffffffffffffff600435166105c4565b3480156101d957600080fd5b5061015c60043561081b565b3480156101f157600080fd5b5061021373ffffffffffffffffffffffffffffffffffffffff600435166108f3565b604080519115158252519081900360200190f35b34801561023357600080fd5b5061021360043573ffffffffffffffffffffffffffffffffffffffff60243516610908565b34801561026457600080fd5b5061027760043515156024351515610928565b60408051918252519081900360200190f35b34801561029557600080fd5b5061015c73ffffffffffffffffffffffffffffffffffffffff60043516610994565b3480156102c357600080fd5b50610213600435610b09565b3480156102db57600080fd5b50610277600435610b9a565b3480156102f357600080fd5b506102ff600435610c16565b604051808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018060200183151515158152602001828103825284818151815260200191508051906020019080838360005b8381101561037e578181015183820152602001610366565b50505050905090810190601f1680156103ab5780820380516001836020036101000a031916815260200191505b509550505050505060405180910390f35b3480156103c857600080fd5b506103d1610cff565b60408051602080825283518183015283519192839290830191858101910280838360005b8381101561040d5781810151838201526020016103f5565b505050509050019250505060405180910390f35b34801561042d57600080fd5b506103d160043560243560443515156064351515610d6f565b34801561045257600080fd5b506103d1600435610ea8565b34801561046a57600080fd5b50610277611055565b34801561047f57600080fd5b5061015c60043561105b565b34801561049757600080fd5b5061015c6004356110da565b3480156104af57600080fd5b50604080516020600460443581810135601f810184900484028501840190955284845261027794823573ffffffffffffffffffffffffffffffffffffffff169460248035953695946064949201919081908401838280828437509497506111d09650505050505050565b34801561052557600080fd5b506102776111ef565b34801561053a57600080fd5b506102776111f4565b34801561054f57600080fd5b5061015c73ffffffffffffffffffffffffffffffffffffffff600435811690602435166111fa565b34801561058357600080fd5b5061015c60043561140a565b600380548290811061059d57fe5b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff16905081565b60003330146105d257600080fd5b73ffffffffffffffffffffffffffffffffffffffff8216600090815260026020526040902054829060ff16151561060857600080fd5b73ffffffffffffffffffffffffffffffffffffffff8316600090815260026020526040812080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905591505b6003547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0182101561078b578273ffffffffffffffffffffffffffffffffffffffff166003838154811015156106a857fe5b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff16141561078057600380547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff810190811061070057fe5b6000918252602090912001546003805473ffffffffffffffffffffffffffffffffffffffff909216918490811061073357fe5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555061078b565b600190910190610656565b600380547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01906107bc9082611787565b5060035460045411156107d5576003546107d59061105b565b60405173ffffffffffffffffffffffffffffffffffffffff8416907f8001553a916ef2f495d26a907cc54d96ed840d7bda71e73194bf5a9df7a76b9090600090a2505050565b3360008181526002602052604090205460ff16151561083957600080fd5b60008281526001602090815260408083203380855292529091205483919060ff16151561086557600080fd5b600084815260208190526040902060030154849060ff161561088657600080fd5b600085815260016020908152604080832033808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690555187927ff6a317157440607f36269043eb55f1287a5a19ba2216afeab88cd46cbcfb88e991a35050505050565b60026020526000908152604090205460ff1681565b600160209081526000928352604080842090915290825290205460ff1681565b6000805b60055481101561098d57838015610955575060008181526020819052604090206003015460ff16155b806109795750828015610979575060008181526020819052604090206003015460ff165b15610985576001820191505b60010161092c565b5092915050565b3330146109a057600080fd5b73ffffffffffffffffffffffffffffffffffffffff8116600090815260026020526040902054819060ff16156109d557600080fd5b8173ffffffffffffffffffffffffffffffffffffffff811615156109f857600080fd5b60038054905060010160045460328211158015610a155750818111155b8015610a2057508015155b8015610a2b57508115155b1515610a3657600080fd5b73ffffffffffffffffffffffffffffffffffffffff851660008181526002602052604080822080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600190811790915560038054918201815583527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b0180547fffffffffffffffffffffffff00000000000000000000000000000000000000001684179055517ff39e6e1eb0edcf53c221607b54b00cd28f3196fed0a24994dc308b8f611b682d9190a25050505050565b600080805b600354811015610b935760008481526001602052604081206003805491929184908110610b3757fe5b600091825260208083209091015473ffffffffffffffffffffffffffffffffffffffff16835282019290925260400190205460ff1615610b78576001820191505b600454821415610b8b5760019250610b93565b600101610b0e565b5050919050565b6000805b600354811015610c105760008381526001602052604081206003805491929184908110610bc757fe5b600091825260208083209091015473ffffffffffffffffffffffffffffffffffffffff16835282019290925260400190205460ff1615610c08576001820191505b600101610b9e565b50919050565b60006020818152918152604090819020805460018083015460028085018054875161010095821615959095027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff011691909104601f810188900488028401880190965285835273ffffffffffffffffffffffffffffffffffffffff90931695909491929190830182828015610cec5780601f10610cc157610100808354040283529160200191610cec565b820191906000526020600020905b815481529060010190602001808311610ccf57829003601f168201915b5050506003909301549192505060ff1684565b60606003805480602002602001604051908101604052809291908181526020018280548015610d6457602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff168152600190910190602001808311610d39575b505050505090505b90565b606080600080600554604051908082528060200260200182016040528015610da1578160200160208202803883390190505b50925060009150600090505b600554811015610e2857858015610dd6575060008181526020819052604090206003015460ff16155b80610dfa5750848015610dfa575060008181526020819052604090206003015460ff165b15610e2057808383815181101515610e0e57fe5b60209081029091010152600191909101905b600101610dad565b878703604051908082528060200260200182016040528015610e54578160200160208202803883390190505b5093508790505b86811015610e9d578281815181101515610e7157fe5b9060200190602002015184898303815181101515610e8b57fe5b60209081029091010152600101610e5b565b505050949350505050565b606080600080600380549050604051908082528060200260200182016040528015610edd578160200160208202803883390190505b50925060009150600090505b600354811015610fc15760008581526001602052604081206003805491929184908110610f1257fe5b600091825260208083209091015473ffffffffffffffffffffffffffffffffffffffff16835282019290925260400190205460ff1615610fb9576003805482908110610f5a57fe5b600091825260209091200154835173ffffffffffffffffffffffffffffffffffffffff90911690849084908110610f8d57fe5b73ffffffffffffffffffffffffffffffffffffffff909216602092830290910190910152600191909101905b600101610ee9565b81604051908082528060200260200182016040528015610feb578160200160208202803883390190505b509350600090505b8181101561104d57828181518110151561100957fe5b90602001906020020151848281518110151561102157fe5b73ffffffffffffffffffffffffffffffffffffffff909216602092830290910190910152600101610ff3565b505050919050565b60055481565b33301461106757600080fd5b600354816032821180159061107c5750818111155b801561108757508015155b801561109257508115155b151561109d57600080fd5b60048390556040805184815290517fa3f1ee9126a074d9326c682f561767f710e927faa811f7a99829d49dc421797a9181900360200190a1505050565b3360008181526002602052604090205460ff1615156110f857600080fd5b600082815260208190526040902054829073ffffffffffffffffffffffffffffffffffffffff16151561112a57600080fd5b60008381526001602090815260408083203380855292529091205484919060ff161561115557600080fd5b600085815260016020818152604080842033808652925280842080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016909317909255905187927f4a504a94899432a9846e1aa406dceb1bcfd538bb839071d49d1e5e23f5be30ef91a36111c98561140a565b5050505050565b60006111dd848484611631565b90506111e8816110da565b9392505050565b603281565b60045481565b600033301461120857600080fd5b73ffffffffffffffffffffffffffffffffffffffff8316600090815260026020526040902054839060ff16151561123e57600080fd5b73ffffffffffffffffffffffffffffffffffffffff8316600090815260026020526040902054839060ff161561127357600080fd5b600092505b600354831015611338578473ffffffffffffffffffffffffffffffffffffffff166003848154811015156112a857fe5b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff16141561132d57836003848154811015156112e057fe5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550611338565b600190920191611278565b73ffffffffffffffffffffffffffffffffffffffff80861660008181526002602052604080822080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0090811690915593881682528082208054909416600117909355915190917f8001553a916ef2f495d26a907cc54d96ed840d7bda71e73194bf5a9df7a76b9091a260405173ffffffffffffffffffffffffffffffffffffffff8516907ff39e6e1eb0edcf53c221607b54b00cd28f3196fed0a24994dc308b8f611b682d90600090a25050505050565b3360008181526002602052604081205490919060ff16151561142b57600080fd5b60008381526001602090815260408083203380855292529091205484919060ff16151561145757600080fd5b600085815260208190526040902060030154859060ff161561147857600080fd5b61148186610b09565b1561162957600086815260208181526040918290206003810180547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001908117909155815481830154600280850180548851601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff97831615610100029790970190911692909204948501879004870282018701909752838152939a5061159e9573ffffffffffffffffffffffffffffffffffffffff909216949093919083908301828280156115945780601f1061156957610100808354040283529160200191611594565b820191906000526020600020905b81548152906001019060200180831161157757829003601f168201915b5050505050611764565b156115d35760405186907f33e13ecb54c3076d8e8bb8c2881800a4d972b792045ffae98fdf46df365fed7590600090a2611629565b60405186907f526441bb6c1aba3c9a4a6ca1d6545da9c2333c8c48343ef398eb858d72b7923690600090a26003850180547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690555b505050505050565b60008373ffffffffffffffffffffffffffffffffffffffff8116151561165657600080fd5b6005546040805160808101825273ffffffffffffffffffffffffffffffffffffffff8881168252602080830189815283850189815260006060860181905287815280845295909520845181547fffffffffffffffffffffffff000000000000000000000000000000000000000016941693909317835551600183015592518051949650919390926116ee9260028501929101906117b0565b5060609190910151600390910180547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001691151591909117905560058054600101905560405182907fc0ba8fe4b176c1714197d43b9cc6bcf797a4a7461c5fe8d0ef6e184ae7601e5190600090a2509392505050565b6000806040516020840160008287838a8c6187965a03f198975050505050505050565b8154818355818111156117ab576000838152602090206117ab91810190830161182e565b505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106117f157805160ff191683800117855561181e565b8280016001018555821561181e579182015b8281111561181e578251825591602001919060010190611803565b5061182a92915061182e565b5090565b610d6c91905b8082111561182a57600081556001016118345600a165627a7a723058205ec9b1f0864ae69331e894f69421e6389dd3d49c0192e2c2478ea678b4158e440029", + "opcodes": + "PUSH1 0x80 PUSH1 0x40 MSTORE CALLVALUE DUP1 ISZERO PUSH3 0x11 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH1 0x40 MLOAD PUSH3 0x1A86 CODESIZE SUB DUP1 PUSH3 0x1A86 DUP4 CODECOPY DUP2 ADD PUSH1 0x40 MSTORE DUP1 MLOAD PUSH1 0x20 DUP3 ADD MLOAD SWAP2 ADD DUP1 MLOAD SWAP1 SWAP2 SWAP1 PUSH1 0x0 SWAP1 DUP3 PUSH1 0x32 DUP3 GT DUP1 ISZERO SWAP1 PUSH3 0x4B JUMPI POP DUP2 DUP2 GT ISZERO JUMPDEST DUP1 ISZERO PUSH3 0x57 JUMPI POP DUP1 ISZERO ISZERO JUMPDEST DUP1 ISZERO PUSH3 0x63 JUMPI POP DUP2 ISZERO ISZERO JUMPDEST ISZERO ISZERO PUSH3 0x6F JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH1 0x0 SWAP3 POP JUMPDEST DUP5 MLOAD DUP4 LT ISZERO PUSH3 0x147 JUMPI PUSH1 0x2 PUSH1 0x0 DUP7 DUP6 DUP2 MLOAD DUP2 LT ISZERO ISZERO PUSH3 0x91 JUMPI INVALID JUMPDEST PUSH1 0x20 SWAP1 DUP2 MUL SWAP1 SWAP2 ADD DUP2 ADD MLOAD PUSH1 0x1 PUSH1 0xA0 PUSH1 0x2 EXP SUB AND DUP3 MSTORE DUP2 ADD SWAP2 SWAP1 SWAP2 MSTORE PUSH1 0x40 ADD PUSH1 0x0 KECCAK256 SLOAD PUSH1 0xFF AND ISZERO DUP1 ISZERO PUSH3 0xE7 JUMPI POP DUP5 DUP4 DUP2 MLOAD DUP2 LT ISZERO ISZERO PUSH3 0xCF JUMPI INVALID JUMPDEST SWAP1 PUSH1 0x20 ADD SWAP1 PUSH1 0x20 MUL ADD MLOAD PUSH1 0x1 PUSH1 0xA0 PUSH1 0x2 EXP SUB AND PUSH1 0x0 EQ ISZERO JUMPDEST ISZERO ISZERO PUSH3 0xF3 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH1 0x1 PUSH1 0x2 PUSH1 0x0 DUP8 DUP7 DUP2 MLOAD DUP2 LT ISZERO ISZERO PUSH3 0x108 JUMPI INVALID JUMPDEST PUSH1 0x20 SWAP1 DUP2 MUL SWAP2 SWAP1 SWAP2 ADD DUP2 ADD MLOAD PUSH1 0x1 PUSH1 0xA0 PUSH1 0x2 EXP SUB AND DUP3 MSTORE DUP2 ADD SWAP2 SWAP1 SWAP2 MSTORE PUSH1 0x40 ADD PUSH1 0x0 KECCAK256 DUP1 SLOAD PUSH1 0xFF NOT AND SWAP2 ISZERO ISZERO SWAP2 SWAP1 SWAP2 OR SWAP1 SSTORE PUSH1 0x1 SWAP3 SWAP1 SWAP3 ADD SWAP2 PUSH3 0x74 JUMP JUMPDEST DUP5 MLOAD PUSH3 0x15C SWAP1 PUSH1 0x3 SWAP1 PUSH1 0x20 DUP9 ADD SWAP1 PUSH3 0x16E JUMP JUMPDEST POP POP POP PUSH1 0x4 SWAP2 SWAP1 SWAP2 SSTORE POP PUSH3 0x202 SWAP1 POP JUMP JUMPDEST DUP3 DUP1 SLOAD DUP3 DUP3 SSTORE SWAP1 PUSH1 0x0 MSTORE PUSH1 0x20 PUSH1 0x0 KECCAK256 SWAP1 DUP2 ADD SWAP3 DUP3 ISZERO PUSH3 0x1C6 JUMPI SWAP2 PUSH1 0x20 MUL DUP3 ADD JUMPDEST DUP3 DUP2 GT ISZERO PUSH3 0x1C6 JUMPI DUP3 MLOAD DUP3 SLOAD PUSH1 0x1 PUSH1 0xA0 PUSH1 0x2 EXP SUB NOT AND PUSH1 0x1 PUSH1 0xA0 PUSH1 0x2 EXP SUB SWAP1 SWAP2 AND OR DUP3 SSTORE PUSH1 0x20 SWAP1 SWAP3 ADD SWAP2 PUSH1 0x1 SWAP1 SWAP2 ADD SWAP1 PUSH3 0x18F JUMP JUMPDEST POP PUSH3 0x1D4 SWAP3 SWAP2 POP PUSH3 0x1D8 JUMP JUMPDEST POP SWAP1 JUMP JUMPDEST PUSH3 0x1FF SWAP2 SWAP1 JUMPDEST DUP1 DUP3 GT ISZERO PUSH3 0x1D4 JUMPI DUP1 SLOAD PUSH1 0x1 PUSH1 0xA0 PUSH1 0x2 EXP SUB NOT AND DUP2 SSTORE PUSH1 0x1 ADD PUSH3 0x1DF JUMP JUMPDEST SWAP1 JUMP JUMPDEST PUSH2 0x1874 DUP1 PUSH3 0x212 PUSH1 0x0 CODECOPY PUSH1 0x0 RETURN STOP PUSH1 0x80 PUSH1 0x40 MSTORE PUSH1 0x4 CALLDATASIZE LT PUSH2 0x11C JUMPI PUSH4 0xFFFFFFFF PUSH29 0x100000000000000000000000000000000000000000000000000000000 PUSH1 0x0 CALLDATALOAD DIV AND PUSH4 0x25E7C27 DUP2 EQ PUSH2 0x15E JUMPI DUP1 PUSH4 0x173825D9 EQ PUSH2 0x19F JUMPI DUP1 PUSH4 0x20EA8D86 EQ PUSH2 0x1CD JUMPI DUP1 PUSH4 0x2F54BF6E EQ PUSH2 0x1E5 JUMPI DUP1 PUSH4 0x3411C81C EQ PUSH2 0x227 JUMPI DUP1 PUSH4 0x54741525 EQ PUSH2 0x258 JUMPI DUP1 PUSH4 0x7065CB48 EQ PUSH2 0x289 JUMPI DUP1 PUSH4 0x784547A7 EQ PUSH2 0x2B7 JUMPI DUP1 PUSH4 0x8B51D13F EQ PUSH2 0x2CF JUMPI DUP1 PUSH4 0x9ACE38C2 EQ PUSH2 0x2E7 JUMPI DUP1 PUSH4 0xA0E67E2B EQ PUSH2 0x3BC JUMPI DUP1 PUSH4 0xA8ABE69A EQ PUSH2 0x421 JUMPI DUP1 PUSH4 0xB5DC40C3 EQ PUSH2 0x446 JUMPI DUP1 PUSH4 0xB77BF600 EQ PUSH2 0x45E JUMPI DUP1 PUSH4 0xBA51A6DF EQ PUSH2 0x473 JUMPI DUP1 PUSH4 0xC01A8C84 EQ PUSH2 0x48B JUMPI DUP1 PUSH4 0xC6427474 EQ PUSH2 0x4A3 JUMPI DUP1 PUSH4 0xD74F8EDD EQ PUSH2 0x519 JUMPI DUP1 PUSH4 0xDC8452CD EQ PUSH2 0x52E JUMPI DUP1 PUSH4 0xE20056E6 EQ PUSH2 0x543 JUMPI DUP1 PUSH4 0xEE22610B EQ PUSH2 0x577 JUMPI JUMPDEST PUSH1 0x0 CALLVALUE GT ISZERO PUSH2 0x15C JUMPI PUSH1 0x40 DUP1 MLOAD CALLVALUE DUP2 MSTORE SWAP1 MLOAD CALLER SWAP2 PUSH32 0xE1FFFCC4923D04B559F4D29A8BFC6CDA04EB5B0D3C460751C2402C5C5CC9109C SWAP2 SWAP1 DUP2 SWAP1 SUB PUSH1 0x20 ADD SWAP1 LOG2 JUMPDEST STOP JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x16A JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x176 PUSH1 0x4 CALLDATALOAD PUSH2 0x58F JUMP JUMPDEST PUSH1 0x40 DUP1 MLOAD PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF SWAP1 SWAP3 AND DUP3 MSTORE MLOAD SWAP1 DUP2 SWAP1 SUB PUSH1 0x20 ADD SWAP1 RETURN JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x1AB JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x15C PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF PUSH1 0x4 CALLDATALOAD AND PUSH2 0x5C4 JUMP JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x1D9 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x15C PUSH1 0x4 CALLDATALOAD PUSH2 0x81B JUMP JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x1F1 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x213 PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF PUSH1 0x4 CALLDATALOAD AND PUSH2 0x8F3 JUMP JUMPDEST PUSH1 0x40 DUP1 MLOAD SWAP2 ISZERO ISZERO DUP3 MSTORE MLOAD SWAP1 DUP2 SWAP1 SUB PUSH1 0x20 ADD SWAP1 RETURN JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x233 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x213 PUSH1 0x4 CALLDATALOAD PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF PUSH1 0x24 CALLDATALOAD AND PUSH2 0x908 JUMP JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x264 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x277 PUSH1 0x4 CALLDATALOAD ISZERO ISZERO PUSH1 0x24 CALLDATALOAD ISZERO ISZERO PUSH2 0x928 JUMP JUMPDEST PUSH1 0x40 DUP1 MLOAD SWAP2 DUP3 MSTORE MLOAD SWAP1 DUP2 SWAP1 SUB PUSH1 0x20 ADD SWAP1 RETURN JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x295 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x15C PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF PUSH1 0x4 CALLDATALOAD AND PUSH2 0x994 JUMP JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x2C3 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x213 PUSH1 0x4 CALLDATALOAD PUSH2 0xB09 JUMP JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x2DB JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x277 PUSH1 0x4 CALLDATALOAD PUSH2 0xB9A JUMP JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x2F3 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x2FF PUSH1 0x4 CALLDATALOAD PUSH2 0xC16 JUMP JUMPDEST PUSH1 0x40 MLOAD DUP1 DUP6 PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND DUP2 MSTORE PUSH1 0x20 ADD DUP5 DUP2 MSTORE PUSH1 0x20 ADD DUP1 PUSH1 0x20 ADD DUP4 ISZERO ISZERO ISZERO ISZERO DUP2 MSTORE PUSH1 0x20 ADD DUP3 DUP2 SUB DUP3 MSTORE DUP5 DUP2 DUP2 MLOAD DUP2 MSTORE PUSH1 0x20 ADD SWAP2 POP DUP1 MLOAD SWAP1 PUSH1 0x20 ADD SWAP1 DUP1 DUP4 DUP4 PUSH1 0x0 JUMPDEST DUP4 DUP2 LT ISZERO PUSH2 0x37E JUMPI DUP2 DUP2 ADD MLOAD DUP4 DUP3 ADD MSTORE PUSH1 0x20 ADD PUSH2 0x366 JUMP JUMPDEST POP POP POP POP SWAP1 POP SWAP1 DUP2 ADD SWAP1 PUSH1 0x1F AND DUP1 ISZERO PUSH2 0x3AB JUMPI DUP1 DUP3 SUB DUP1 MLOAD PUSH1 0x1 DUP4 PUSH1 0x20 SUB PUSH2 0x100 EXP SUB NOT AND DUP2 MSTORE PUSH1 0x20 ADD SWAP2 POP JUMPDEST POP SWAP6 POP POP POP POP POP POP PUSH1 0x40 MLOAD DUP1 SWAP2 SUB SWAP1 RETURN JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x3C8 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x3D1 PUSH2 0xCFF JUMP JUMPDEST PUSH1 0x40 DUP1 MLOAD PUSH1 0x20 DUP1 DUP3 MSTORE DUP4 MLOAD DUP2 DUP4 ADD MSTORE DUP4 MLOAD SWAP2 SWAP3 DUP4 SWAP3 SWAP1 DUP4 ADD SWAP2 DUP6 DUP2 ADD SWAP2 MUL DUP1 DUP4 DUP4 PUSH1 0x0 JUMPDEST DUP4 DUP2 LT ISZERO PUSH2 0x40D JUMPI DUP2 DUP2 ADD MLOAD DUP4 DUP3 ADD MSTORE PUSH1 0x20 ADD PUSH2 0x3F5 JUMP JUMPDEST POP POP POP POP SWAP1 POP ADD SWAP3 POP POP POP PUSH1 0x40 MLOAD DUP1 SWAP2 SUB SWAP1 RETURN JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x42D JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x3D1 PUSH1 0x4 CALLDATALOAD PUSH1 0x24 CALLDATALOAD PUSH1 0x44 CALLDATALOAD ISZERO ISZERO PUSH1 0x64 CALLDATALOAD ISZERO ISZERO PUSH2 0xD6F JUMP JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x452 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x3D1 PUSH1 0x4 CALLDATALOAD PUSH2 0xEA8 JUMP JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x46A JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x277 PUSH2 0x1055 JUMP JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x47F JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x15C PUSH1 0x4 CALLDATALOAD PUSH2 0x105B JUMP JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x497 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x15C PUSH1 0x4 CALLDATALOAD PUSH2 0x10DA JUMP JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x4AF JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH1 0x40 DUP1 MLOAD PUSH1 0x20 PUSH1 0x4 PUSH1 0x44 CALLDATALOAD DUP2 DUP2 ADD CALLDATALOAD PUSH1 0x1F DUP2 ADD DUP5 SWAP1 DIV DUP5 MUL DUP6 ADD DUP5 ADD SWAP1 SWAP6 MSTORE DUP5 DUP5 MSTORE PUSH2 0x277 SWAP5 DUP3 CALLDATALOAD PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND SWAP5 PUSH1 0x24 DUP1 CALLDATALOAD SWAP6 CALLDATASIZE SWAP6 SWAP5 PUSH1 0x64 SWAP5 SWAP3 ADD SWAP2 SWAP1 DUP2 SWAP1 DUP5 ADD DUP4 DUP3 DUP1 DUP3 DUP5 CALLDATACOPY POP SWAP5 SWAP8 POP PUSH2 0x11D0 SWAP7 POP POP POP POP POP POP POP JUMP JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x525 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x277 PUSH2 0x11EF JUMP JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x53A JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x277 PUSH2 0x11F4 JUMP JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x54F JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x15C PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF PUSH1 0x4 CALLDATALOAD DUP2 AND SWAP1 PUSH1 0x24 CALLDATALOAD AND PUSH2 0x11FA JUMP JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x583 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x15C PUSH1 0x4 CALLDATALOAD PUSH2 0x140A JUMP JUMPDEST PUSH1 0x3 DUP1 SLOAD DUP3 SWAP1 DUP2 LT PUSH2 0x59D JUMPI INVALID JUMPDEST PUSH1 0x0 SWAP2 DUP3 MSTORE PUSH1 0x20 SWAP1 SWAP2 KECCAK256 ADD SLOAD PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND SWAP1 POP DUP2 JUMP JUMPDEST PUSH1 0x0 CALLER ADDRESS EQ PUSH2 0x5D2 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF DUP3 AND PUSH1 0x0 SWAP1 DUP2 MSTORE PUSH1 0x2 PUSH1 0x20 MSTORE PUSH1 0x40 SWAP1 KECCAK256 SLOAD DUP3 SWAP1 PUSH1 0xFF AND ISZERO ISZERO PUSH2 0x608 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF DUP4 AND PUSH1 0x0 SWAP1 DUP2 MSTORE PUSH1 0x2 PUSH1 0x20 MSTORE PUSH1 0x40 DUP2 KECCAK256 DUP1 SLOAD PUSH32 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00 AND SWAP1 SSTORE SWAP2 POP JUMPDEST PUSH1 0x3 SLOAD PUSH32 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF ADD DUP3 LT ISZERO PUSH2 0x78B JUMPI DUP3 PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND PUSH1 0x3 DUP4 DUP2 SLOAD DUP2 LT ISZERO ISZERO PUSH2 0x6A8 JUMPI INVALID JUMPDEST PUSH1 0x0 SWAP2 DUP3 MSTORE PUSH1 0x20 SWAP1 SWAP2 KECCAK256 ADD SLOAD PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND EQ ISZERO PUSH2 0x780 JUMPI PUSH1 0x3 DUP1 SLOAD PUSH32 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF DUP2 ADD SWAP1 DUP2 LT PUSH2 0x700 JUMPI INVALID JUMPDEST PUSH1 0x0 SWAP2 DUP3 MSTORE PUSH1 0x20 SWAP1 SWAP2 KECCAK256 ADD SLOAD PUSH1 0x3 DUP1 SLOAD PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF SWAP1 SWAP3 AND SWAP2 DUP5 SWAP1 DUP2 LT PUSH2 0x733 JUMPI INVALID JUMPDEST SWAP1 PUSH1 0x0 MSTORE PUSH1 0x20 PUSH1 0x0 KECCAK256 ADD PUSH1 0x0 PUSH2 0x100 EXP DUP2 SLOAD DUP2 PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF MUL NOT AND SWAP1 DUP4 PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND MUL OR SWAP1 SSTORE POP PUSH2 0x78B JUMP JUMPDEST PUSH1 0x1 SWAP1 SWAP2 ADD SWAP1 PUSH2 0x656 JUMP JUMPDEST PUSH1 0x3 DUP1 SLOAD PUSH32 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF ADD SWAP1 PUSH2 0x7BC SWAP1 DUP3 PUSH2 0x1787 JUMP JUMPDEST POP PUSH1 0x3 SLOAD PUSH1 0x4 SLOAD GT ISZERO PUSH2 0x7D5 JUMPI PUSH1 0x3 SLOAD PUSH2 0x7D5 SWAP1 PUSH2 0x105B JUMP JUMPDEST PUSH1 0x40 MLOAD PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF DUP5 AND SWAP1 PUSH32 0x8001553A916EF2F495D26A907CC54D96ED840D7BDA71E73194BF5A9DF7A76B90 SWAP1 PUSH1 0x0 SWAP1 LOG2 POP POP POP JUMP JUMPDEST CALLER PUSH1 0x0 DUP2 DUP2 MSTORE PUSH1 0x2 PUSH1 0x20 MSTORE PUSH1 0x40 SWAP1 KECCAK256 SLOAD PUSH1 0xFF AND ISZERO ISZERO PUSH2 0x839 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH1 0x0 DUP3 DUP2 MSTORE PUSH1 0x1 PUSH1 0x20 SWAP1 DUP2 MSTORE PUSH1 0x40 DUP1 DUP4 KECCAK256 CALLER DUP1 DUP6 MSTORE SWAP3 MSTORE SWAP1 SWAP2 KECCAK256 SLOAD DUP4 SWAP2 SWAP1 PUSH1 0xFF AND ISZERO ISZERO PUSH2 0x865 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH1 0x0 DUP5 DUP2 MSTORE PUSH1 0x20 DUP2 SWAP1 MSTORE PUSH1 0x40 SWAP1 KECCAK256 PUSH1 0x3 ADD SLOAD DUP5 SWAP1 PUSH1 0xFF AND ISZERO PUSH2 0x886 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH1 0x0 DUP6 DUP2 MSTORE PUSH1 0x1 PUSH1 0x20 SWAP1 DUP2 MSTORE PUSH1 0x40 DUP1 DUP4 KECCAK256 CALLER DUP1 DUP6 MSTORE SWAP3 MSTORE DUP1 DUP4 KECCAK256 DUP1 SLOAD PUSH32 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00 AND SWAP1 SSTORE MLOAD DUP8 SWAP3 PUSH32 0xF6A317157440607F36269043EB55F1287A5A19BA2216AFEAB88CD46CBCFB88E9 SWAP2 LOG3 POP POP POP POP POP JUMP JUMPDEST PUSH1 0x2 PUSH1 0x20 MSTORE PUSH1 0x0 SWAP1 DUP2 MSTORE PUSH1 0x40 SWAP1 KECCAK256 SLOAD PUSH1 0xFF AND DUP2 JUMP JUMPDEST PUSH1 0x1 PUSH1 0x20 SWAP1 DUP2 MSTORE PUSH1 0x0 SWAP3 DUP4 MSTORE PUSH1 0x40 DUP1 DUP5 KECCAK256 SWAP1 SWAP2 MSTORE SWAP1 DUP3 MSTORE SWAP1 KECCAK256 SLOAD PUSH1 0xFF AND DUP2 JUMP JUMPDEST PUSH1 0x0 DUP1 JUMPDEST PUSH1 0x5 SLOAD DUP2 LT ISZERO PUSH2 0x98D JUMPI DUP4 DUP1 ISZERO PUSH2 0x955 JUMPI POP PUSH1 0x0 DUP2 DUP2 MSTORE PUSH1 0x20 DUP2 SWAP1 MSTORE PUSH1 0x40 SWAP1 KECCAK256 PUSH1 0x3 ADD SLOAD PUSH1 0xFF AND ISZERO JUMPDEST DUP1 PUSH2 0x979 JUMPI POP DUP3 DUP1 ISZERO PUSH2 0x979 JUMPI POP PUSH1 0x0 DUP2 DUP2 MSTORE PUSH1 0x20 DUP2 SWAP1 MSTORE PUSH1 0x40 SWAP1 KECCAK256 PUSH1 0x3 ADD SLOAD PUSH1 0xFF AND JUMPDEST ISZERO PUSH2 0x985 JUMPI PUSH1 0x1 DUP3 ADD SWAP2 POP JUMPDEST PUSH1 0x1 ADD PUSH2 0x92C JUMP JUMPDEST POP SWAP3 SWAP2 POP POP JUMP JUMPDEST CALLER ADDRESS EQ PUSH2 0x9A0 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF DUP2 AND PUSH1 0x0 SWAP1 DUP2 MSTORE PUSH1 0x2 PUSH1 0x20 MSTORE PUSH1 0x40 SWAP1 KECCAK256 SLOAD DUP2 SWAP1 PUSH1 0xFF AND ISZERO PUSH2 0x9D5 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST DUP2 PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF DUP2 AND ISZERO ISZERO PUSH2 0x9F8 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH1 0x3 DUP1 SLOAD SWAP1 POP PUSH1 0x1 ADD PUSH1 0x4 SLOAD PUSH1 0x32 DUP3 GT ISZERO DUP1 ISZERO PUSH2 0xA15 JUMPI POP DUP2 DUP2 GT ISZERO JUMPDEST DUP1 ISZERO PUSH2 0xA20 JUMPI POP DUP1 ISZERO ISZERO JUMPDEST DUP1 ISZERO PUSH2 0xA2B JUMPI POP DUP2 ISZERO ISZERO JUMPDEST ISZERO ISZERO PUSH2 0xA36 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF DUP6 AND PUSH1 0x0 DUP2 DUP2 MSTORE PUSH1 0x2 PUSH1 0x20 MSTORE PUSH1 0x40 DUP1 DUP3 KECCAK256 DUP1 SLOAD PUSH32 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00 AND PUSH1 0x1 SWAP1 DUP2 OR SWAP1 SWAP2 SSTORE PUSH1 0x3 DUP1 SLOAD SWAP2 DUP3 ADD DUP2 SSTORE DUP4 MSTORE PUSH32 0xC2575A0E9E593C00F959F8C92F12DB2869C3395A3B0502D05E2516446F71F85B ADD DUP1 SLOAD PUSH32 0xFFFFFFFFFFFFFFFFFFFFFFFF0000000000000000000000000000000000000000 AND DUP5 OR SWAP1 SSTORE MLOAD PUSH32 0xF39E6E1EB0EDCF53C221607B54B00CD28F3196FED0A24994DC308B8F611B682D SWAP2 SWAP1 LOG2 POP POP POP POP POP JUMP JUMPDEST PUSH1 0x0 DUP1 DUP1 JUMPDEST PUSH1 0x3 SLOAD DUP2 LT ISZERO PUSH2 0xB93 JUMPI PUSH1 0x0 DUP5 DUP2 MSTORE PUSH1 0x1 PUSH1 0x20 MSTORE PUSH1 0x40 DUP2 KECCAK256 PUSH1 0x3 DUP1 SLOAD SWAP2 SWAP3 SWAP2 DUP5 SWAP1 DUP2 LT PUSH2 0xB37 JUMPI INVALID JUMPDEST PUSH1 0x0 SWAP2 DUP3 MSTORE PUSH1 0x20 DUP1 DUP4 KECCAK256 SWAP1 SWAP2 ADD SLOAD PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND DUP4 MSTORE DUP3 ADD SWAP3 SWAP1 SWAP3 MSTORE PUSH1 0x40 ADD SWAP1 KECCAK256 SLOAD PUSH1 0xFF AND ISZERO PUSH2 0xB78 JUMPI PUSH1 0x1 DUP3 ADD SWAP2 POP JUMPDEST PUSH1 0x4 SLOAD DUP3 EQ ISZERO PUSH2 0xB8B JUMPI PUSH1 0x1 SWAP3 POP PUSH2 0xB93 JUMP JUMPDEST PUSH1 0x1 ADD PUSH2 0xB0E JUMP JUMPDEST POP POP SWAP2 SWAP1 POP JUMP JUMPDEST PUSH1 0x0 DUP1 JUMPDEST PUSH1 0x3 SLOAD DUP2 LT ISZERO PUSH2 0xC10 JUMPI PUSH1 0x0 DUP4 DUP2 MSTORE PUSH1 0x1 PUSH1 0x20 MSTORE PUSH1 0x40 DUP2 KECCAK256 PUSH1 0x3 DUP1 SLOAD SWAP2 SWAP3 SWAP2 DUP5 SWAP1 DUP2 LT PUSH2 0xBC7 JUMPI INVALID JUMPDEST PUSH1 0x0 SWAP2 DUP3 MSTORE PUSH1 0x20 DUP1 DUP4 KECCAK256 SWAP1 SWAP2 ADD SLOAD PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND DUP4 MSTORE DUP3 ADD SWAP3 SWAP1 SWAP3 MSTORE PUSH1 0x40 ADD SWAP1 KECCAK256 SLOAD PUSH1 0xFF AND ISZERO PUSH2 0xC08 JUMPI PUSH1 0x1 DUP3 ADD SWAP2 POP JUMPDEST PUSH1 0x1 ADD PUSH2 0xB9E JUMP JUMPDEST POP SWAP2 SWAP1 POP JUMP JUMPDEST PUSH1 0x0 PUSH1 0x20 DUP2 DUP2 MSTORE SWAP2 DUP2 MSTORE PUSH1 0x40 SWAP1 DUP2 SWAP1 KECCAK256 DUP1 SLOAD PUSH1 0x1 DUP1 DUP4 ADD SLOAD PUSH1 0x2 DUP1 DUP6 ADD DUP1 SLOAD DUP8 MLOAD PUSH2 0x100 SWAP6 DUP3 AND ISZERO SWAP6 SWAP1 SWAP6 MUL PUSH32 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF ADD AND SWAP2 SWAP1 SWAP2 DIV PUSH1 0x1F DUP2 ADD DUP9 SWAP1 DIV DUP9 MUL DUP5 ADD DUP9 ADD SWAP1 SWAP7 MSTORE DUP6 DUP4 MSTORE PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF SWAP1 SWAP4 AND SWAP6 SWAP1 SWAP5 SWAP2 SWAP3 SWAP2 SWAP1 DUP4 ADD DUP3 DUP3 DUP1 ISZERO PUSH2 0xCEC JUMPI DUP1 PUSH1 0x1F LT PUSH2 0xCC1 JUMPI PUSH2 0x100 DUP1 DUP4 SLOAD DIV MUL DUP4 MSTORE SWAP2 PUSH1 0x20 ADD SWAP2 PUSH2 0xCEC JUMP JUMPDEST DUP3 ADD SWAP2 SWAP1 PUSH1 0x0 MSTORE PUSH1 0x20 PUSH1 0x0 KECCAK256 SWAP1 JUMPDEST DUP2 SLOAD DUP2 MSTORE SWAP1 PUSH1 0x1 ADD SWAP1 PUSH1 0x20 ADD DUP1 DUP4 GT PUSH2 0xCCF JUMPI DUP3 SWAP1 SUB PUSH1 0x1F AND DUP3 ADD SWAP2 JUMPDEST POP POP POP PUSH1 0x3 SWAP1 SWAP4 ADD SLOAD SWAP2 SWAP3 POP POP PUSH1 0xFF AND DUP5 JUMP JUMPDEST PUSH1 0x60 PUSH1 0x3 DUP1 SLOAD DUP1 PUSH1 0x20 MUL PUSH1 0x20 ADD PUSH1 0x40 MLOAD SWAP1 DUP2 ADD PUSH1 0x40 MSTORE DUP1 SWAP3 SWAP2 SWAP1 DUP2 DUP2 MSTORE PUSH1 0x20 ADD DUP3 DUP1 SLOAD DUP1 ISZERO PUSH2 0xD64 JUMPI PUSH1 0x20 MUL DUP3 ADD SWAP2 SWAP1 PUSH1 0x0 MSTORE PUSH1 0x20 PUSH1 0x0 KECCAK256 SWAP1 JUMPDEST DUP2 SLOAD PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND DUP2 MSTORE PUSH1 0x1 SWAP1 SWAP2 ADD SWAP1 PUSH1 0x20 ADD DUP1 DUP4 GT PUSH2 0xD39 JUMPI JUMPDEST POP POP POP POP POP SWAP1 POP JUMPDEST SWAP1 JUMP JUMPDEST PUSH1 0x60 DUP1 PUSH1 0x0 DUP1 PUSH1 0x5 SLOAD PUSH1 0x40 MLOAD SWAP1 DUP1 DUP3 MSTORE DUP1 PUSH1 0x20 MUL PUSH1 0x20 ADD DUP3 ADD PUSH1 0x40 MSTORE DUP1 ISZERO PUSH2 0xDA1 JUMPI DUP2 PUSH1 0x20 ADD PUSH1 0x20 DUP3 MUL DUP1 CODESIZE DUP4 CODECOPY ADD SWAP1 POP JUMPDEST POP SWAP3 POP PUSH1 0x0 SWAP2 POP PUSH1 0x0 SWAP1 POP JUMPDEST PUSH1 0x5 SLOAD DUP2 LT ISZERO PUSH2 0xE28 JUMPI DUP6 DUP1 ISZERO PUSH2 0xDD6 JUMPI POP PUSH1 0x0 DUP2 DUP2 MSTORE PUSH1 0x20 DUP2 SWAP1 MSTORE PUSH1 0x40 SWAP1 KECCAK256 PUSH1 0x3 ADD SLOAD PUSH1 0xFF AND ISZERO JUMPDEST DUP1 PUSH2 0xDFA JUMPI POP DUP5 DUP1 ISZERO PUSH2 0xDFA JUMPI POP PUSH1 0x0 DUP2 DUP2 MSTORE PUSH1 0x20 DUP2 SWAP1 MSTORE PUSH1 0x40 SWAP1 KECCAK256 PUSH1 0x3 ADD SLOAD PUSH1 0xFF AND JUMPDEST ISZERO PUSH2 0xE20 JUMPI DUP1 DUP4 DUP4 DUP2 MLOAD DUP2 LT ISZERO ISZERO PUSH2 0xE0E JUMPI INVALID JUMPDEST PUSH1 0x20 SWAP1 DUP2 MUL SWAP1 SWAP2 ADD ADD MSTORE PUSH1 0x1 SWAP2 SWAP1 SWAP2 ADD SWAP1 JUMPDEST PUSH1 0x1 ADD PUSH2 0xDAD JUMP JUMPDEST DUP8 DUP8 SUB PUSH1 0x40 MLOAD SWAP1 DUP1 DUP3 MSTORE DUP1 PUSH1 0x20 MUL PUSH1 0x20 ADD DUP3 ADD PUSH1 0x40 MSTORE DUP1 ISZERO PUSH2 0xE54 JUMPI DUP2 PUSH1 0x20 ADD PUSH1 0x20 DUP3 MUL DUP1 CODESIZE DUP4 CODECOPY ADD SWAP1 POP JUMPDEST POP SWAP4 POP DUP8 SWAP1 POP JUMPDEST DUP7 DUP2 LT ISZERO PUSH2 0xE9D JUMPI DUP3 DUP2 DUP2 MLOAD DUP2 LT ISZERO ISZERO PUSH2 0xE71 JUMPI INVALID JUMPDEST SWAP1 PUSH1 0x20 ADD SWAP1 PUSH1 0x20 MUL ADD MLOAD DUP5 DUP10 DUP4 SUB DUP2 MLOAD DUP2 LT ISZERO ISZERO PUSH2 0xE8B JUMPI INVALID JUMPDEST PUSH1 0x20 SWAP1 DUP2 MUL SWAP1 SWAP2 ADD ADD MSTORE PUSH1 0x1 ADD PUSH2 0xE5B JUMP JUMPDEST POP POP POP SWAP5 SWAP4 POP POP POP POP JUMP JUMPDEST PUSH1 0x60 DUP1 PUSH1 0x0 DUP1 PUSH1 0x3 DUP1 SLOAD SWAP1 POP PUSH1 0x40 MLOAD SWAP1 DUP1 DUP3 MSTORE DUP1 PUSH1 0x20 MUL PUSH1 0x20 ADD DUP3 ADD PUSH1 0x40 MSTORE DUP1 ISZERO PUSH2 0xEDD JUMPI DUP2 PUSH1 0x20 ADD PUSH1 0x20 DUP3 MUL DUP1 CODESIZE DUP4 CODECOPY ADD SWAP1 POP JUMPDEST POP SWAP3 POP PUSH1 0x0 SWAP2 POP PUSH1 0x0 SWAP1 POP JUMPDEST PUSH1 0x3 SLOAD DUP2 LT ISZERO PUSH2 0xFC1 JUMPI PUSH1 0x0 DUP6 DUP2 MSTORE PUSH1 0x1 PUSH1 0x20 MSTORE PUSH1 0x40 DUP2 KECCAK256 PUSH1 0x3 DUP1 SLOAD SWAP2 SWAP3 SWAP2 DUP5 SWAP1 DUP2 LT PUSH2 0xF12 JUMPI INVALID JUMPDEST PUSH1 0x0 SWAP2 DUP3 MSTORE PUSH1 0x20 DUP1 DUP4 KECCAK256 SWAP1 SWAP2 ADD SLOAD PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND DUP4 MSTORE DUP3 ADD SWAP3 SWAP1 SWAP3 MSTORE PUSH1 0x40 ADD SWAP1 KECCAK256 SLOAD PUSH1 0xFF AND ISZERO PUSH2 0xFB9 JUMPI PUSH1 0x3 DUP1 SLOAD DUP3 SWAP1 DUP2 LT PUSH2 0xF5A JUMPI INVALID JUMPDEST PUSH1 0x0 SWAP2 DUP3 MSTORE PUSH1 0x20 SWAP1 SWAP2 KECCAK256 ADD SLOAD DUP4 MLOAD PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF SWAP1 SWAP2 AND SWAP1 DUP5 SWAP1 DUP5 SWAP1 DUP2 LT PUSH2 0xF8D JUMPI INVALID JUMPDEST PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF SWAP1 SWAP3 AND PUSH1 0x20 SWAP3 DUP4 MUL SWAP1 SWAP2 ADD SWAP1 SWAP2 ADD MSTORE PUSH1 0x1 SWAP2 SWAP1 SWAP2 ADD SWAP1 JUMPDEST PUSH1 0x1 ADD PUSH2 0xEE9 JUMP JUMPDEST DUP2 PUSH1 0x40 MLOAD SWAP1 DUP1 DUP3 MSTORE DUP1 PUSH1 0x20 MUL PUSH1 0x20 ADD DUP3 ADD PUSH1 0x40 MSTORE DUP1 ISZERO PUSH2 0xFEB JUMPI DUP2 PUSH1 0x20 ADD PUSH1 0x20 DUP3 MUL DUP1 CODESIZE DUP4 CODECOPY ADD SWAP1 POP JUMPDEST POP SWAP4 POP PUSH1 0x0 SWAP1 POP JUMPDEST DUP2 DUP2 LT ISZERO PUSH2 0x104D JUMPI DUP3 DUP2 DUP2 MLOAD DUP2 LT ISZERO ISZERO PUSH2 0x1009 JUMPI INVALID JUMPDEST SWAP1 PUSH1 0x20 ADD SWAP1 PUSH1 0x20 MUL ADD MLOAD DUP5 DUP3 DUP2 MLOAD DUP2 LT ISZERO ISZERO PUSH2 0x1021 JUMPI INVALID JUMPDEST PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF SWAP1 SWAP3 AND PUSH1 0x20 SWAP3 DUP4 MUL SWAP1 SWAP2 ADD SWAP1 SWAP2 ADD MSTORE PUSH1 0x1 ADD PUSH2 0xFF3 JUMP JUMPDEST POP POP POP SWAP2 SWAP1 POP JUMP JUMPDEST PUSH1 0x5 SLOAD DUP2 JUMP JUMPDEST CALLER ADDRESS EQ PUSH2 0x1067 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH1 0x3 SLOAD DUP2 PUSH1 0x32 DUP3 GT DUP1 ISZERO SWAP1 PUSH2 0x107C JUMPI POP DUP2 DUP2 GT ISZERO JUMPDEST DUP1 ISZERO PUSH2 0x1087 JUMPI POP DUP1 ISZERO ISZERO JUMPDEST DUP1 ISZERO PUSH2 0x1092 JUMPI POP DUP2 ISZERO ISZERO JUMPDEST ISZERO ISZERO PUSH2 0x109D JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH1 0x4 DUP4 SWAP1 SSTORE PUSH1 0x40 DUP1 MLOAD DUP5 DUP2 MSTORE SWAP1 MLOAD PUSH32 0xA3F1EE9126A074D9326C682F561767F710E927FAA811F7A99829D49DC421797A SWAP2 DUP2 SWAP1 SUB PUSH1 0x20 ADD SWAP1 LOG1 POP POP POP JUMP JUMPDEST CALLER PUSH1 0x0 DUP2 DUP2 MSTORE PUSH1 0x2 PUSH1 0x20 MSTORE PUSH1 0x40 SWAP1 KECCAK256 SLOAD PUSH1 0xFF AND ISZERO ISZERO PUSH2 0x10F8 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH1 0x0 DUP3 DUP2 MSTORE PUSH1 0x20 DUP2 SWAP1 MSTORE PUSH1 0x40 SWAP1 KECCAK256 SLOAD DUP3 SWAP1 PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND ISZERO ISZERO PUSH2 0x112A JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH1 0x0 DUP4 DUP2 MSTORE PUSH1 0x1 PUSH1 0x20 SWAP1 DUP2 MSTORE PUSH1 0x40 DUP1 DUP4 KECCAK256 CALLER DUP1 DUP6 MSTORE SWAP3 MSTORE SWAP1 SWAP2 KECCAK256 SLOAD DUP5 SWAP2 SWAP1 PUSH1 0xFF AND ISZERO PUSH2 0x1155 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH1 0x0 DUP6 DUP2 MSTORE PUSH1 0x1 PUSH1 0x20 DUP2 DUP2 MSTORE PUSH1 0x40 DUP1 DUP5 KECCAK256 CALLER DUP1 DUP7 MSTORE SWAP3 MSTORE DUP1 DUP5 KECCAK256 DUP1 SLOAD PUSH32 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00 AND SWAP1 SWAP4 OR SWAP1 SWAP3 SSTORE SWAP1 MLOAD DUP8 SWAP3 PUSH32 0x4A504A94899432A9846E1AA406DCEB1BCFD538BB839071D49D1E5E23F5BE30EF SWAP2 LOG3 PUSH2 0x11C9 DUP6 PUSH2 0x140A JUMP JUMPDEST POP POP POP POP POP JUMP JUMPDEST PUSH1 0x0 PUSH2 0x11DD DUP5 DUP5 DUP5 PUSH2 0x1631 JUMP JUMPDEST SWAP1 POP PUSH2 0x11E8 DUP2 PUSH2 0x10DA JUMP JUMPDEST SWAP4 SWAP3 POP POP POP JUMP JUMPDEST PUSH1 0x32 DUP2 JUMP JUMPDEST PUSH1 0x4 SLOAD DUP2 JUMP JUMPDEST PUSH1 0x0 CALLER ADDRESS EQ PUSH2 0x1208 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF DUP4 AND PUSH1 0x0 SWAP1 DUP2 MSTORE PUSH1 0x2 PUSH1 0x20 MSTORE PUSH1 0x40 SWAP1 KECCAK256 SLOAD DUP4 SWAP1 PUSH1 0xFF AND ISZERO ISZERO PUSH2 0x123E JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF DUP4 AND PUSH1 0x0 SWAP1 DUP2 MSTORE PUSH1 0x2 PUSH1 0x20 MSTORE PUSH1 0x40 SWAP1 KECCAK256 SLOAD DUP4 SWAP1 PUSH1 0xFF AND ISZERO PUSH2 0x1273 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH1 0x0 SWAP3 POP JUMPDEST PUSH1 0x3 SLOAD DUP4 LT ISZERO PUSH2 0x1338 JUMPI DUP5 PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND PUSH1 0x3 DUP5 DUP2 SLOAD DUP2 LT ISZERO ISZERO PUSH2 0x12A8 JUMPI INVALID JUMPDEST PUSH1 0x0 SWAP2 DUP3 MSTORE PUSH1 0x20 SWAP1 SWAP2 KECCAK256 ADD SLOAD PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND EQ ISZERO PUSH2 0x132D JUMPI DUP4 PUSH1 0x3 DUP5 DUP2 SLOAD DUP2 LT ISZERO ISZERO PUSH2 0x12E0 JUMPI INVALID JUMPDEST SWAP1 PUSH1 0x0 MSTORE PUSH1 0x20 PUSH1 0x0 KECCAK256 ADD PUSH1 0x0 PUSH2 0x100 EXP DUP2 SLOAD DUP2 PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF MUL NOT AND SWAP1 DUP4 PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND MUL OR SWAP1 SSTORE POP PUSH2 0x1338 JUMP JUMPDEST PUSH1 0x1 SWAP1 SWAP3 ADD SWAP2 PUSH2 0x1278 JUMP JUMPDEST PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF DUP1 DUP7 AND PUSH1 0x0 DUP2 DUP2 MSTORE PUSH1 0x2 PUSH1 0x20 MSTORE PUSH1 0x40 DUP1 DUP3 KECCAK256 DUP1 SLOAD PUSH32 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00 SWAP1 DUP2 AND SWAP1 SWAP2 SSTORE SWAP4 DUP9 AND DUP3 MSTORE DUP1 DUP3 KECCAK256 DUP1 SLOAD SWAP1 SWAP5 AND PUSH1 0x1 OR SWAP1 SWAP4 SSTORE SWAP2 MLOAD SWAP1 SWAP2 PUSH32 0x8001553A916EF2F495D26A907CC54D96ED840D7BDA71E73194BF5A9DF7A76B90 SWAP2 LOG2 PUSH1 0x40 MLOAD PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF DUP6 AND SWAP1 PUSH32 0xF39E6E1EB0EDCF53C221607B54B00CD28F3196FED0A24994DC308B8F611B682D SWAP1 PUSH1 0x0 SWAP1 LOG2 POP POP POP POP POP JUMP JUMPDEST CALLER PUSH1 0x0 DUP2 DUP2 MSTORE PUSH1 0x2 PUSH1 0x20 MSTORE PUSH1 0x40 DUP2 KECCAK256 SLOAD SWAP1 SWAP2 SWAP1 PUSH1 0xFF AND ISZERO ISZERO PUSH2 0x142B JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH1 0x0 DUP4 DUP2 MSTORE PUSH1 0x1 PUSH1 0x20 SWAP1 DUP2 MSTORE PUSH1 0x40 DUP1 DUP4 KECCAK256 CALLER DUP1 DUP6 MSTORE SWAP3 MSTORE SWAP1 SWAP2 KECCAK256 SLOAD DUP5 SWAP2 SWAP1 PUSH1 0xFF AND ISZERO ISZERO PUSH2 0x1457 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH1 0x0 DUP6 DUP2 MSTORE PUSH1 0x20 DUP2 SWAP1 MSTORE PUSH1 0x40 SWAP1 KECCAK256 PUSH1 0x3 ADD SLOAD DUP6 SWAP1 PUSH1 0xFF AND ISZERO PUSH2 0x1478 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH2 0x1481 DUP7 PUSH2 0xB09 JUMP JUMPDEST ISZERO PUSH2 0x1629 JUMPI PUSH1 0x0 DUP7 DUP2 MSTORE PUSH1 0x20 DUP2 DUP2 MSTORE PUSH1 0x40 SWAP2 DUP3 SWAP1 KECCAK256 PUSH1 0x3 DUP2 ADD DUP1 SLOAD PUSH32 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00 AND PUSH1 0x1 SWAP1 DUP2 OR SWAP1 SWAP2 SSTORE DUP2 SLOAD DUP2 DUP4 ADD SLOAD PUSH1 0x2 DUP1 DUP6 ADD DUP1 SLOAD DUP9 MLOAD PUSH1 0x1F PUSH32 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF SWAP8 DUP4 AND ISZERO PUSH2 0x100 MUL SWAP8 SWAP1 SWAP8 ADD SWAP1 SWAP2 AND SWAP3 SWAP1 SWAP3 DIV SWAP5 DUP6 ADD DUP8 SWAP1 DIV DUP8 MUL DUP3 ADD DUP8 ADD SWAP1 SWAP8 MSTORE DUP4 DUP2 MSTORE SWAP4 SWAP11 POP PUSH2 0x159E SWAP6 PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF SWAP1 SWAP3 AND SWAP5 SWAP1 SWAP4 SWAP2 SWAP1 DUP4 SWAP1 DUP4 ADD DUP3 DUP3 DUP1 ISZERO PUSH2 0x1594 JUMPI DUP1 PUSH1 0x1F LT PUSH2 0x1569 JUMPI PUSH2 0x100 DUP1 DUP4 SLOAD DIV MUL DUP4 MSTORE SWAP2 PUSH1 0x20 ADD SWAP2 PUSH2 0x1594 JUMP JUMPDEST DUP3 ADD SWAP2 SWAP1 PUSH1 0x0 MSTORE PUSH1 0x20 PUSH1 0x0 KECCAK256 SWAP1 JUMPDEST DUP2 SLOAD DUP2 MSTORE SWAP1 PUSH1 0x1 ADD SWAP1 PUSH1 0x20 ADD DUP1 DUP4 GT PUSH2 0x1577 JUMPI DUP3 SWAP1 SUB PUSH1 0x1F AND DUP3 ADD SWAP2 JUMPDEST POP POP POP POP POP PUSH2 0x1764 JUMP JUMPDEST ISZERO PUSH2 0x15D3 JUMPI PUSH1 0x40 MLOAD DUP7 SWAP1 PUSH32 0x33E13ECB54C3076D8E8BB8C2881800A4D972B792045FFAE98FDF46DF365FED75 SWAP1 PUSH1 0x0 SWAP1 LOG2 PUSH2 0x1629 JUMP JUMPDEST PUSH1 0x40 MLOAD DUP7 SWAP1 PUSH32 0x526441BB6C1ABA3C9A4A6CA1D6545DA9C2333C8C48343EF398EB858D72B79236 SWAP1 PUSH1 0x0 SWAP1 LOG2 PUSH1 0x3 DUP6 ADD DUP1 SLOAD PUSH32 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00 AND SWAP1 SSTORE JUMPDEST POP POP POP POP POP POP JUMP JUMPDEST PUSH1 0x0 DUP4 PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF DUP2 AND ISZERO ISZERO PUSH2 0x1656 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH1 0x5 SLOAD PUSH1 0x40 DUP1 MLOAD PUSH1 0x80 DUP2 ADD DUP3 MSTORE PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF DUP9 DUP2 AND DUP3 MSTORE PUSH1 0x20 DUP1 DUP4 ADD DUP10 DUP2 MSTORE DUP4 DUP6 ADD DUP10 DUP2 MSTORE PUSH1 0x0 PUSH1 0x60 DUP7 ADD DUP2 SWAP1 MSTORE DUP8 DUP2 MSTORE DUP1 DUP5 MSTORE SWAP6 SWAP1 SWAP6 KECCAK256 DUP5 MLOAD DUP2 SLOAD PUSH32 0xFFFFFFFFFFFFFFFFFFFFFFFF0000000000000000000000000000000000000000 AND SWAP5 AND SWAP4 SWAP1 SWAP4 OR DUP4 SSTORE MLOAD PUSH1 0x1 DUP4 ADD SSTORE SWAP3 MLOAD DUP1 MLOAD SWAP5 SWAP7 POP SWAP2 SWAP4 SWAP1 SWAP3 PUSH2 0x16EE SWAP3 PUSH1 0x2 DUP6 ADD SWAP3 SWAP2 ADD SWAP1 PUSH2 0x17B0 JUMP JUMPDEST POP PUSH1 0x60 SWAP2 SWAP1 SWAP2 ADD MLOAD PUSH1 0x3 SWAP1 SWAP2 ADD DUP1 SLOAD PUSH32 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00 AND SWAP2 ISZERO ISZERO SWAP2 SWAP1 SWAP2 OR SWAP1 SSTORE PUSH1 0x5 DUP1 SLOAD PUSH1 0x1 ADD SWAP1 SSTORE PUSH1 0x40 MLOAD DUP3 SWAP1 PUSH32 0xC0BA8FE4B176C1714197D43B9CC6BCF797A4A7461C5FE8D0EF6E184AE7601E51 SWAP1 PUSH1 0x0 SWAP1 LOG2 POP SWAP4 SWAP3 POP POP POP JUMP JUMPDEST PUSH1 0x0 DUP1 PUSH1 0x40 MLOAD PUSH1 0x20 DUP5 ADD PUSH1 0x0 DUP3 DUP8 DUP4 DUP11 DUP13 PUSH2 0x8796 GAS SUB CALL SWAP9 SWAP8 POP POP POP POP POP POP POP POP JUMP JUMPDEST DUP2 SLOAD DUP2 DUP4 SSTORE DUP2 DUP2 GT ISZERO PUSH2 0x17AB JUMPI PUSH1 0x0 DUP4 DUP2 MSTORE PUSH1 0x20 SWAP1 KECCAK256 PUSH2 0x17AB SWAP2 DUP2 ADD SWAP1 DUP4 ADD PUSH2 0x182E JUMP JUMPDEST POP POP POP JUMP JUMPDEST DUP3 DUP1 SLOAD PUSH1 0x1 DUP2 PUSH1 0x1 AND ISZERO PUSH2 0x100 MUL SUB AND PUSH1 0x2 SWAP1 DIV SWAP1 PUSH1 0x0 MSTORE PUSH1 0x20 PUSH1 0x0 KECCAK256 SWAP1 PUSH1 0x1F ADD PUSH1 0x20 SWAP1 DIV DUP2 ADD SWAP3 DUP3 PUSH1 0x1F LT PUSH2 0x17F1 JUMPI DUP1 MLOAD PUSH1 0xFF NOT AND DUP4 DUP1 ADD OR DUP6 SSTORE PUSH2 0x181E JUMP JUMPDEST DUP3 DUP1 ADD PUSH1 0x1 ADD DUP6 SSTORE DUP3 ISZERO PUSH2 0x181E JUMPI SWAP2 DUP3 ADD JUMPDEST DUP3 DUP2 GT ISZERO PUSH2 0x181E JUMPI DUP3 MLOAD DUP3 SSTORE SWAP2 PUSH1 0x20 ADD SWAP2 SWAP1 PUSH1 0x1 ADD SWAP1 PUSH2 0x1803 JUMP JUMPDEST POP PUSH2 0x182A SWAP3 SWAP2 POP PUSH2 0x182E JUMP JUMPDEST POP SWAP1 JUMP JUMPDEST PUSH2 0xD6C SWAP2 SWAP1 JUMPDEST DUP1 DUP3 GT ISZERO PUSH2 0x182A JUMPI PUSH1 0x0 DUP2 SSTORE PUSH1 0x1 ADD PUSH2 0x1834 JUMP STOP LOG1 PUSH6 0x627A7A723058 KECCAK256 0x5e 0xc9 0xb1 CREATE DUP7 0x4a 0xe6 SWAP4 BALANCE 0xe8 SWAP5 0xf6 SWAP5 0x21 0xe6 CODESIZE SWAP14 0xd3 0xd4 SWAP13 ADD SWAP3 0xe2 0xc2 0x47 DUP15 0xa6 PUSH25 0xB4158E44002900000000000000000000000000000000000000 ", + "sourceMap": + "206:12628:0:-;;;2835:353;8:9:-1;5:2;;;30:1;27;20:12;5:2;2835:353:0;;;;;;;;;;;;;;;;;;;;;;2934:14;;2835:353;;;2980:6;;2835:353;839:2;2273:29;;;;;:68;;;2331:10;2318:9;:23;;2273:68;:98;;;;-1:-1:-1;2357:14:0;;;2273:98;:129;;;;-1:-1:-1;2387:15:0;;;2273:129;2265:138;;;;;;;;2987:1;2980:8;;2975:151;2992:7;:14;2990:1;:16;2975:151;;;3036:7;:19;3044:7;3052:1;3044:10;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;3036:19:0;;;;;;;;;;;-1:-1:-1;3036:19:0;;;;3035:20;:39;;;;;3059:7;3067:1;3059:10;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;3059:15:0;3073:1;3059:15;;3035:39;3027:48;;;;;;;;3111:4;3089:7;:19;3097:7;3105:1;3097:10;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;3089:19:0;;;;;;;;;;;-1:-1:-1;3089:19:0;:26;;-1:-1:-1;;3089:26:0;;;;;;;;;;-1:-1:-1;3008:3:0;;;;;2975:151;;;3135:16;;;;:6;;:16;;;;;:::i;:::-;-1:-1:-1;;;3161:8:0;:20;;;;-1:-1:-1;206:12628:0;;-1:-1:-1;206:12628:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;;206:12628:0;-1:-1:-1;;;;;206:12628:0;;;;;;;;;;;-1:-1:-1;206:12628:0;;;;;;;-1:-1:-1;206:12628:0;;;-1:-1:-1;206:12628:0;:::i;:::-;;;:::o;:::-;;;;;;;;;;;;;-1:-1:-1;;;;;;206:12628:0;;;;;;;;;:::o;:::-;;;;;;;" + }, + "deployedBytecode": { + "linkReferences": {}, + "object": + "0x60806040526004361061011c5763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663025e7c27811461015e578063173825d91461019f57806320ea8d86146101cd5780632f54bf6e146101e55780633411c81c1461022757806354741525146102585780637065cb4814610289578063784547a7146102b75780638b51d13f146102cf5780639ace38c2146102e7578063a0e67e2b146103bc578063a8abe69a14610421578063b5dc40c314610446578063b77bf6001461045e578063ba51a6df14610473578063c01a8c841461048b578063c6427474146104a3578063d74f8edd14610519578063dc8452cd1461052e578063e20056e614610543578063ee22610b14610577575b600034111561015c5760408051348152905133917fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c919081900360200190a25b005b34801561016a57600080fd5b5061017660043561058f565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b3480156101ab57600080fd5b5061015c73ffffffffffffffffffffffffffffffffffffffff600435166105c4565b3480156101d957600080fd5b5061015c60043561081b565b3480156101f157600080fd5b5061021373ffffffffffffffffffffffffffffffffffffffff600435166108f3565b604080519115158252519081900360200190f35b34801561023357600080fd5b5061021360043573ffffffffffffffffffffffffffffffffffffffff60243516610908565b34801561026457600080fd5b5061027760043515156024351515610928565b60408051918252519081900360200190f35b34801561029557600080fd5b5061015c73ffffffffffffffffffffffffffffffffffffffff60043516610994565b3480156102c357600080fd5b50610213600435610b09565b3480156102db57600080fd5b50610277600435610b9a565b3480156102f357600080fd5b506102ff600435610c16565b604051808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018060200183151515158152602001828103825284818151815260200191508051906020019080838360005b8381101561037e578181015183820152602001610366565b50505050905090810190601f1680156103ab5780820380516001836020036101000a031916815260200191505b509550505050505060405180910390f35b3480156103c857600080fd5b506103d1610cff565b60408051602080825283518183015283519192839290830191858101910280838360005b8381101561040d5781810151838201526020016103f5565b505050509050019250505060405180910390f35b34801561042d57600080fd5b506103d160043560243560443515156064351515610d6f565b34801561045257600080fd5b506103d1600435610ea8565b34801561046a57600080fd5b50610277611055565b34801561047f57600080fd5b5061015c60043561105b565b34801561049757600080fd5b5061015c6004356110da565b3480156104af57600080fd5b50604080516020600460443581810135601f810184900484028501840190955284845261027794823573ffffffffffffffffffffffffffffffffffffffff169460248035953695946064949201919081908401838280828437509497506111d09650505050505050565b34801561052557600080fd5b506102776111ef565b34801561053a57600080fd5b506102776111f4565b34801561054f57600080fd5b5061015c73ffffffffffffffffffffffffffffffffffffffff600435811690602435166111fa565b34801561058357600080fd5b5061015c60043561140a565b600380548290811061059d57fe5b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff16905081565b60003330146105d257600080fd5b73ffffffffffffffffffffffffffffffffffffffff8216600090815260026020526040902054829060ff16151561060857600080fd5b73ffffffffffffffffffffffffffffffffffffffff8316600090815260026020526040812080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905591505b6003547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0182101561078b578273ffffffffffffffffffffffffffffffffffffffff166003838154811015156106a857fe5b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff16141561078057600380547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff810190811061070057fe5b6000918252602090912001546003805473ffffffffffffffffffffffffffffffffffffffff909216918490811061073357fe5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555061078b565b600190910190610656565b600380547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01906107bc9082611787565b5060035460045411156107d5576003546107d59061105b565b60405173ffffffffffffffffffffffffffffffffffffffff8416907f8001553a916ef2f495d26a907cc54d96ed840d7bda71e73194bf5a9df7a76b9090600090a2505050565b3360008181526002602052604090205460ff16151561083957600080fd5b60008281526001602090815260408083203380855292529091205483919060ff16151561086557600080fd5b600084815260208190526040902060030154849060ff161561088657600080fd5b600085815260016020908152604080832033808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690555187927ff6a317157440607f36269043eb55f1287a5a19ba2216afeab88cd46cbcfb88e991a35050505050565b60026020526000908152604090205460ff1681565b600160209081526000928352604080842090915290825290205460ff1681565b6000805b60055481101561098d57838015610955575060008181526020819052604090206003015460ff16155b806109795750828015610979575060008181526020819052604090206003015460ff165b15610985576001820191505b60010161092c565b5092915050565b3330146109a057600080fd5b73ffffffffffffffffffffffffffffffffffffffff8116600090815260026020526040902054819060ff16156109d557600080fd5b8173ffffffffffffffffffffffffffffffffffffffff811615156109f857600080fd5b60038054905060010160045460328211158015610a155750818111155b8015610a2057508015155b8015610a2b57508115155b1515610a3657600080fd5b73ffffffffffffffffffffffffffffffffffffffff851660008181526002602052604080822080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600190811790915560038054918201815583527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b0180547fffffffffffffffffffffffff00000000000000000000000000000000000000001684179055517ff39e6e1eb0edcf53c221607b54b00cd28f3196fed0a24994dc308b8f611b682d9190a25050505050565b600080805b600354811015610b935760008481526001602052604081206003805491929184908110610b3757fe5b600091825260208083209091015473ffffffffffffffffffffffffffffffffffffffff16835282019290925260400190205460ff1615610b78576001820191505b600454821415610b8b5760019250610b93565b600101610b0e565b5050919050565b6000805b600354811015610c105760008381526001602052604081206003805491929184908110610bc757fe5b600091825260208083209091015473ffffffffffffffffffffffffffffffffffffffff16835282019290925260400190205460ff1615610c08576001820191505b600101610b9e565b50919050565b60006020818152918152604090819020805460018083015460028085018054875161010095821615959095027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff011691909104601f810188900488028401880190965285835273ffffffffffffffffffffffffffffffffffffffff90931695909491929190830182828015610cec5780601f10610cc157610100808354040283529160200191610cec565b820191906000526020600020905b815481529060010190602001808311610ccf57829003601f168201915b5050506003909301549192505060ff1684565b60606003805480602002602001604051908101604052809291908181526020018280548015610d6457602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff168152600190910190602001808311610d39575b505050505090505b90565b606080600080600554604051908082528060200260200182016040528015610da1578160200160208202803883390190505b50925060009150600090505b600554811015610e2857858015610dd6575060008181526020819052604090206003015460ff16155b80610dfa5750848015610dfa575060008181526020819052604090206003015460ff165b15610e2057808383815181101515610e0e57fe5b60209081029091010152600191909101905b600101610dad565b878703604051908082528060200260200182016040528015610e54578160200160208202803883390190505b5093508790505b86811015610e9d578281815181101515610e7157fe5b9060200190602002015184898303815181101515610e8b57fe5b60209081029091010152600101610e5b565b505050949350505050565b606080600080600380549050604051908082528060200260200182016040528015610edd578160200160208202803883390190505b50925060009150600090505b600354811015610fc15760008581526001602052604081206003805491929184908110610f1257fe5b600091825260208083209091015473ffffffffffffffffffffffffffffffffffffffff16835282019290925260400190205460ff1615610fb9576003805482908110610f5a57fe5b600091825260209091200154835173ffffffffffffffffffffffffffffffffffffffff90911690849084908110610f8d57fe5b73ffffffffffffffffffffffffffffffffffffffff909216602092830290910190910152600191909101905b600101610ee9565b81604051908082528060200260200182016040528015610feb578160200160208202803883390190505b509350600090505b8181101561104d57828181518110151561100957fe5b90602001906020020151848281518110151561102157fe5b73ffffffffffffffffffffffffffffffffffffffff909216602092830290910190910152600101610ff3565b505050919050565b60055481565b33301461106757600080fd5b600354816032821180159061107c5750818111155b801561108757508015155b801561109257508115155b151561109d57600080fd5b60048390556040805184815290517fa3f1ee9126a074d9326c682f561767f710e927faa811f7a99829d49dc421797a9181900360200190a1505050565b3360008181526002602052604090205460ff1615156110f857600080fd5b600082815260208190526040902054829073ffffffffffffffffffffffffffffffffffffffff16151561112a57600080fd5b60008381526001602090815260408083203380855292529091205484919060ff161561115557600080fd5b600085815260016020818152604080842033808652925280842080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016909317909255905187927f4a504a94899432a9846e1aa406dceb1bcfd538bb839071d49d1e5e23f5be30ef91a36111c98561140a565b5050505050565b60006111dd848484611631565b90506111e8816110da565b9392505050565b603281565b60045481565b600033301461120857600080fd5b73ffffffffffffffffffffffffffffffffffffffff8316600090815260026020526040902054839060ff16151561123e57600080fd5b73ffffffffffffffffffffffffffffffffffffffff8316600090815260026020526040902054839060ff161561127357600080fd5b600092505b600354831015611338578473ffffffffffffffffffffffffffffffffffffffff166003848154811015156112a857fe5b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff16141561132d57836003848154811015156112e057fe5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550611338565b600190920191611278565b73ffffffffffffffffffffffffffffffffffffffff80861660008181526002602052604080822080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0090811690915593881682528082208054909416600117909355915190917f8001553a916ef2f495d26a907cc54d96ed840d7bda71e73194bf5a9df7a76b9091a260405173ffffffffffffffffffffffffffffffffffffffff8516907ff39e6e1eb0edcf53c221607b54b00cd28f3196fed0a24994dc308b8f611b682d90600090a25050505050565b3360008181526002602052604081205490919060ff16151561142b57600080fd5b60008381526001602090815260408083203380855292529091205484919060ff16151561145757600080fd5b600085815260208190526040902060030154859060ff161561147857600080fd5b61148186610b09565b1561162957600086815260208181526040918290206003810180547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001908117909155815481830154600280850180548851601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff97831615610100029790970190911692909204948501879004870282018701909752838152939a5061159e9573ffffffffffffffffffffffffffffffffffffffff909216949093919083908301828280156115945780601f1061156957610100808354040283529160200191611594565b820191906000526020600020905b81548152906001019060200180831161157757829003601f168201915b5050505050611764565b156115d35760405186907f33e13ecb54c3076d8e8bb8c2881800a4d972b792045ffae98fdf46df365fed7590600090a2611629565b60405186907f526441bb6c1aba3c9a4a6ca1d6545da9c2333c8c48343ef398eb858d72b7923690600090a26003850180547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690555b505050505050565b60008373ffffffffffffffffffffffffffffffffffffffff8116151561165657600080fd5b6005546040805160808101825273ffffffffffffffffffffffffffffffffffffffff8881168252602080830189815283850189815260006060860181905287815280845295909520845181547fffffffffffffffffffffffff000000000000000000000000000000000000000016941693909317835551600183015592518051949650919390926116ee9260028501929101906117b0565b5060609190910151600390910180547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001691151591909117905560058054600101905560405182907fc0ba8fe4b176c1714197d43b9cc6bcf797a4a7461c5fe8d0ef6e184ae7601e5190600090a2509392505050565b6000806040516020840160008287838a8c6187965a03f198975050505050505050565b8154818355818111156117ab576000838152602090206117ab91810190830161182e565b505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106117f157805160ff191683800117855561181e565b8280016001018555821561181e579182015b8281111561181e578251825591602001919060010190611803565b5061182a92915061182e565b5090565b610d6c91905b8082111561182a57600081556001016118345600a165627a7a723058205ec9b1f0864ae69331e894f69421e6389dd3d49c0192e2c2478ea678b4158e440029", + "opcodes": + "PUSH1 0x80 PUSH1 0x40 MSTORE PUSH1 0x4 CALLDATASIZE LT PUSH2 0x11C JUMPI PUSH4 0xFFFFFFFF PUSH29 0x100000000000000000000000000000000000000000000000000000000 PUSH1 0x0 CALLDATALOAD DIV AND PUSH4 0x25E7C27 DUP2 EQ PUSH2 0x15E JUMPI DUP1 PUSH4 0x173825D9 EQ PUSH2 0x19F JUMPI DUP1 PUSH4 0x20EA8D86 EQ PUSH2 0x1CD JUMPI DUP1 PUSH4 0x2F54BF6E EQ PUSH2 0x1E5 JUMPI DUP1 PUSH4 0x3411C81C EQ PUSH2 0x227 JUMPI DUP1 PUSH4 0x54741525 EQ PUSH2 0x258 JUMPI DUP1 PUSH4 0x7065CB48 EQ PUSH2 0x289 JUMPI DUP1 PUSH4 0x784547A7 EQ PUSH2 0x2B7 JUMPI DUP1 PUSH4 0x8B51D13F EQ PUSH2 0x2CF JUMPI DUP1 PUSH4 0x9ACE38C2 EQ PUSH2 0x2E7 JUMPI DUP1 PUSH4 0xA0E67E2B EQ PUSH2 0x3BC JUMPI DUP1 PUSH4 0xA8ABE69A EQ PUSH2 0x421 JUMPI DUP1 PUSH4 0xB5DC40C3 EQ PUSH2 0x446 JUMPI DUP1 PUSH4 0xB77BF600 EQ PUSH2 0x45E JUMPI DUP1 PUSH4 0xBA51A6DF EQ PUSH2 0x473 JUMPI DUP1 PUSH4 0xC01A8C84 EQ PUSH2 0x48B JUMPI DUP1 PUSH4 0xC6427474 EQ PUSH2 0x4A3 JUMPI DUP1 PUSH4 0xD74F8EDD EQ PUSH2 0x519 JUMPI DUP1 PUSH4 0xDC8452CD EQ PUSH2 0x52E JUMPI DUP1 PUSH4 0xE20056E6 EQ PUSH2 0x543 JUMPI DUP1 PUSH4 0xEE22610B EQ PUSH2 0x577 JUMPI JUMPDEST PUSH1 0x0 CALLVALUE GT ISZERO PUSH2 0x15C JUMPI PUSH1 0x40 DUP1 MLOAD CALLVALUE DUP2 MSTORE SWAP1 MLOAD CALLER SWAP2 PUSH32 0xE1FFFCC4923D04B559F4D29A8BFC6CDA04EB5B0D3C460751C2402C5C5CC9109C SWAP2 SWAP1 DUP2 SWAP1 SUB PUSH1 0x20 ADD SWAP1 LOG2 JUMPDEST STOP JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x16A JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x176 PUSH1 0x4 CALLDATALOAD PUSH2 0x58F JUMP JUMPDEST PUSH1 0x40 DUP1 MLOAD PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF SWAP1 SWAP3 AND DUP3 MSTORE MLOAD SWAP1 DUP2 SWAP1 SUB PUSH1 0x20 ADD SWAP1 RETURN JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x1AB JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x15C PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF PUSH1 0x4 CALLDATALOAD AND PUSH2 0x5C4 JUMP JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x1D9 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x15C PUSH1 0x4 CALLDATALOAD PUSH2 0x81B JUMP JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x1F1 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x213 PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF PUSH1 0x4 CALLDATALOAD AND PUSH2 0x8F3 JUMP JUMPDEST PUSH1 0x40 DUP1 MLOAD SWAP2 ISZERO ISZERO DUP3 MSTORE MLOAD SWAP1 DUP2 SWAP1 SUB PUSH1 0x20 ADD SWAP1 RETURN JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x233 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x213 PUSH1 0x4 CALLDATALOAD PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF PUSH1 0x24 CALLDATALOAD AND PUSH2 0x908 JUMP JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x264 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x277 PUSH1 0x4 CALLDATALOAD ISZERO ISZERO PUSH1 0x24 CALLDATALOAD ISZERO ISZERO PUSH2 0x928 JUMP JUMPDEST PUSH1 0x40 DUP1 MLOAD SWAP2 DUP3 MSTORE MLOAD SWAP1 DUP2 SWAP1 SUB PUSH1 0x20 ADD SWAP1 RETURN JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x295 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x15C PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF PUSH1 0x4 CALLDATALOAD AND PUSH2 0x994 JUMP JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x2C3 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x213 PUSH1 0x4 CALLDATALOAD PUSH2 0xB09 JUMP JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x2DB JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x277 PUSH1 0x4 CALLDATALOAD PUSH2 0xB9A JUMP JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x2F3 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x2FF PUSH1 0x4 CALLDATALOAD PUSH2 0xC16 JUMP JUMPDEST PUSH1 0x40 MLOAD DUP1 DUP6 PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND DUP2 MSTORE PUSH1 0x20 ADD DUP5 DUP2 MSTORE PUSH1 0x20 ADD DUP1 PUSH1 0x20 ADD DUP4 ISZERO ISZERO ISZERO ISZERO DUP2 MSTORE PUSH1 0x20 ADD DUP3 DUP2 SUB DUP3 MSTORE DUP5 DUP2 DUP2 MLOAD DUP2 MSTORE PUSH1 0x20 ADD SWAP2 POP DUP1 MLOAD SWAP1 PUSH1 0x20 ADD SWAP1 DUP1 DUP4 DUP4 PUSH1 0x0 JUMPDEST DUP4 DUP2 LT ISZERO PUSH2 0x37E JUMPI DUP2 DUP2 ADD MLOAD DUP4 DUP3 ADD MSTORE PUSH1 0x20 ADD PUSH2 0x366 JUMP JUMPDEST POP POP POP POP SWAP1 POP SWAP1 DUP2 ADD SWAP1 PUSH1 0x1F AND DUP1 ISZERO PUSH2 0x3AB JUMPI DUP1 DUP3 SUB DUP1 MLOAD PUSH1 0x1 DUP4 PUSH1 0x20 SUB PUSH2 0x100 EXP SUB NOT AND DUP2 MSTORE PUSH1 0x20 ADD SWAP2 POP JUMPDEST POP SWAP6 POP POP POP POP POP POP PUSH1 0x40 MLOAD DUP1 SWAP2 SUB SWAP1 RETURN JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x3C8 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x3D1 PUSH2 0xCFF JUMP JUMPDEST PUSH1 0x40 DUP1 MLOAD PUSH1 0x20 DUP1 DUP3 MSTORE DUP4 MLOAD DUP2 DUP4 ADD MSTORE DUP4 MLOAD SWAP2 SWAP3 DUP4 SWAP3 SWAP1 DUP4 ADD SWAP2 DUP6 DUP2 ADD SWAP2 MUL DUP1 DUP4 DUP4 PUSH1 0x0 JUMPDEST DUP4 DUP2 LT ISZERO PUSH2 0x40D JUMPI DUP2 DUP2 ADD MLOAD DUP4 DUP3 ADD MSTORE PUSH1 0x20 ADD PUSH2 0x3F5 JUMP JUMPDEST POP POP POP POP SWAP1 POP ADD SWAP3 POP POP POP PUSH1 0x40 MLOAD DUP1 SWAP2 SUB SWAP1 RETURN JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x42D JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x3D1 PUSH1 0x4 CALLDATALOAD PUSH1 0x24 CALLDATALOAD PUSH1 0x44 CALLDATALOAD ISZERO ISZERO PUSH1 0x64 CALLDATALOAD ISZERO ISZERO PUSH2 0xD6F JUMP JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x452 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x3D1 PUSH1 0x4 CALLDATALOAD PUSH2 0xEA8 JUMP JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x46A JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x277 PUSH2 0x1055 JUMP JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x47F JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x15C PUSH1 0x4 CALLDATALOAD PUSH2 0x105B JUMP JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x497 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x15C PUSH1 0x4 CALLDATALOAD PUSH2 0x10DA JUMP JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x4AF JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH1 0x40 DUP1 MLOAD PUSH1 0x20 PUSH1 0x4 PUSH1 0x44 CALLDATALOAD DUP2 DUP2 ADD CALLDATALOAD PUSH1 0x1F DUP2 ADD DUP5 SWAP1 DIV DUP5 MUL DUP6 ADD DUP5 ADD SWAP1 SWAP6 MSTORE DUP5 DUP5 MSTORE PUSH2 0x277 SWAP5 DUP3 CALLDATALOAD PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND SWAP5 PUSH1 0x24 DUP1 CALLDATALOAD SWAP6 CALLDATASIZE SWAP6 SWAP5 PUSH1 0x64 SWAP5 SWAP3 ADD SWAP2 SWAP1 DUP2 SWAP1 DUP5 ADD DUP4 DUP3 DUP1 DUP3 DUP5 CALLDATACOPY POP SWAP5 SWAP8 POP PUSH2 0x11D0 SWAP7 POP POP POP POP POP POP POP JUMP JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x525 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x277 PUSH2 0x11EF JUMP JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x53A JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x277 PUSH2 0x11F4 JUMP JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x54F JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x15C PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF PUSH1 0x4 CALLDATALOAD DUP2 AND SWAP1 PUSH1 0x24 CALLDATALOAD AND PUSH2 0x11FA JUMP JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x583 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x15C PUSH1 0x4 CALLDATALOAD PUSH2 0x140A JUMP JUMPDEST PUSH1 0x3 DUP1 SLOAD DUP3 SWAP1 DUP2 LT PUSH2 0x59D JUMPI INVALID JUMPDEST PUSH1 0x0 SWAP2 DUP3 MSTORE PUSH1 0x20 SWAP1 SWAP2 KECCAK256 ADD SLOAD PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND SWAP1 POP DUP2 JUMP JUMPDEST PUSH1 0x0 CALLER ADDRESS EQ PUSH2 0x5D2 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF DUP3 AND PUSH1 0x0 SWAP1 DUP2 MSTORE PUSH1 0x2 PUSH1 0x20 MSTORE PUSH1 0x40 SWAP1 KECCAK256 SLOAD DUP3 SWAP1 PUSH1 0xFF AND ISZERO ISZERO PUSH2 0x608 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF DUP4 AND PUSH1 0x0 SWAP1 DUP2 MSTORE PUSH1 0x2 PUSH1 0x20 MSTORE PUSH1 0x40 DUP2 KECCAK256 DUP1 SLOAD PUSH32 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00 AND SWAP1 SSTORE SWAP2 POP JUMPDEST PUSH1 0x3 SLOAD PUSH32 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF ADD DUP3 LT ISZERO PUSH2 0x78B JUMPI DUP3 PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND PUSH1 0x3 DUP4 DUP2 SLOAD DUP2 LT ISZERO ISZERO PUSH2 0x6A8 JUMPI INVALID JUMPDEST PUSH1 0x0 SWAP2 DUP3 MSTORE PUSH1 0x20 SWAP1 SWAP2 KECCAK256 ADD SLOAD PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND EQ ISZERO PUSH2 0x780 JUMPI PUSH1 0x3 DUP1 SLOAD PUSH32 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF DUP2 ADD SWAP1 DUP2 LT PUSH2 0x700 JUMPI INVALID JUMPDEST PUSH1 0x0 SWAP2 DUP3 MSTORE PUSH1 0x20 SWAP1 SWAP2 KECCAK256 ADD SLOAD PUSH1 0x3 DUP1 SLOAD PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF SWAP1 SWAP3 AND SWAP2 DUP5 SWAP1 DUP2 LT PUSH2 0x733 JUMPI INVALID JUMPDEST SWAP1 PUSH1 0x0 MSTORE PUSH1 0x20 PUSH1 0x0 KECCAK256 ADD PUSH1 0x0 PUSH2 0x100 EXP DUP2 SLOAD DUP2 PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF MUL NOT AND SWAP1 DUP4 PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND MUL OR SWAP1 SSTORE POP PUSH2 0x78B JUMP JUMPDEST PUSH1 0x1 SWAP1 SWAP2 ADD SWAP1 PUSH2 0x656 JUMP JUMPDEST PUSH1 0x3 DUP1 SLOAD PUSH32 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF ADD SWAP1 PUSH2 0x7BC SWAP1 DUP3 PUSH2 0x1787 JUMP JUMPDEST POP PUSH1 0x3 SLOAD PUSH1 0x4 SLOAD GT ISZERO PUSH2 0x7D5 JUMPI PUSH1 0x3 SLOAD PUSH2 0x7D5 SWAP1 PUSH2 0x105B JUMP JUMPDEST PUSH1 0x40 MLOAD PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF DUP5 AND SWAP1 PUSH32 0x8001553A916EF2F495D26A907CC54D96ED840D7BDA71E73194BF5A9DF7A76B90 SWAP1 PUSH1 0x0 SWAP1 LOG2 POP POP POP JUMP JUMPDEST CALLER PUSH1 0x0 DUP2 DUP2 MSTORE PUSH1 0x2 PUSH1 0x20 MSTORE PUSH1 0x40 SWAP1 KECCAK256 SLOAD PUSH1 0xFF AND ISZERO ISZERO PUSH2 0x839 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH1 0x0 DUP3 DUP2 MSTORE PUSH1 0x1 PUSH1 0x20 SWAP1 DUP2 MSTORE PUSH1 0x40 DUP1 DUP4 KECCAK256 CALLER DUP1 DUP6 MSTORE SWAP3 MSTORE SWAP1 SWAP2 KECCAK256 SLOAD DUP4 SWAP2 SWAP1 PUSH1 0xFF AND ISZERO ISZERO PUSH2 0x865 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH1 0x0 DUP5 DUP2 MSTORE PUSH1 0x20 DUP2 SWAP1 MSTORE PUSH1 0x40 SWAP1 KECCAK256 PUSH1 0x3 ADD SLOAD DUP5 SWAP1 PUSH1 0xFF AND ISZERO PUSH2 0x886 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH1 0x0 DUP6 DUP2 MSTORE PUSH1 0x1 PUSH1 0x20 SWAP1 DUP2 MSTORE PUSH1 0x40 DUP1 DUP4 KECCAK256 CALLER DUP1 DUP6 MSTORE SWAP3 MSTORE DUP1 DUP4 KECCAK256 DUP1 SLOAD PUSH32 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00 AND SWAP1 SSTORE MLOAD DUP8 SWAP3 PUSH32 0xF6A317157440607F36269043EB55F1287A5A19BA2216AFEAB88CD46CBCFB88E9 SWAP2 LOG3 POP POP POP POP POP JUMP JUMPDEST PUSH1 0x2 PUSH1 0x20 MSTORE PUSH1 0x0 SWAP1 DUP2 MSTORE PUSH1 0x40 SWAP1 KECCAK256 SLOAD PUSH1 0xFF AND DUP2 JUMP JUMPDEST PUSH1 0x1 PUSH1 0x20 SWAP1 DUP2 MSTORE PUSH1 0x0 SWAP3 DUP4 MSTORE PUSH1 0x40 DUP1 DUP5 KECCAK256 SWAP1 SWAP2 MSTORE SWAP1 DUP3 MSTORE SWAP1 KECCAK256 SLOAD PUSH1 0xFF AND DUP2 JUMP JUMPDEST PUSH1 0x0 DUP1 JUMPDEST PUSH1 0x5 SLOAD DUP2 LT ISZERO PUSH2 0x98D JUMPI DUP4 DUP1 ISZERO PUSH2 0x955 JUMPI POP PUSH1 0x0 DUP2 DUP2 MSTORE PUSH1 0x20 DUP2 SWAP1 MSTORE PUSH1 0x40 SWAP1 KECCAK256 PUSH1 0x3 ADD SLOAD PUSH1 0xFF AND ISZERO JUMPDEST DUP1 PUSH2 0x979 JUMPI POP DUP3 DUP1 ISZERO PUSH2 0x979 JUMPI POP PUSH1 0x0 DUP2 DUP2 MSTORE PUSH1 0x20 DUP2 SWAP1 MSTORE PUSH1 0x40 SWAP1 KECCAK256 PUSH1 0x3 ADD SLOAD PUSH1 0xFF AND JUMPDEST ISZERO PUSH2 0x985 JUMPI PUSH1 0x1 DUP3 ADD SWAP2 POP JUMPDEST PUSH1 0x1 ADD PUSH2 0x92C JUMP JUMPDEST POP SWAP3 SWAP2 POP POP JUMP JUMPDEST CALLER ADDRESS EQ PUSH2 0x9A0 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF DUP2 AND PUSH1 0x0 SWAP1 DUP2 MSTORE PUSH1 0x2 PUSH1 0x20 MSTORE PUSH1 0x40 SWAP1 KECCAK256 SLOAD DUP2 SWAP1 PUSH1 0xFF AND ISZERO PUSH2 0x9D5 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST DUP2 PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF DUP2 AND ISZERO ISZERO PUSH2 0x9F8 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH1 0x3 DUP1 SLOAD SWAP1 POP PUSH1 0x1 ADD PUSH1 0x4 SLOAD PUSH1 0x32 DUP3 GT ISZERO DUP1 ISZERO PUSH2 0xA15 JUMPI POP DUP2 DUP2 GT ISZERO JUMPDEST DUP1 ISZERO PUSH2 0xA20 JUMPI POP DUP1 ISZERO ISZERO JUMPDEST DUP1 ISZERO PUSH2 0xA2B JUMPI POP DUP2 ISZERO ISZERO JUMPDEST ISZERO ISZERO PUSH2 0xA36 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF DUP6 AND PUSH1 0x0 DUP2 DUP2 MSTORE PUSH1 0x2 PUSH1 0x20 MSTORE PUSH1 0x40 DUP1 DUP3 KECCAK256 DUP1 SLOAD PUSH32 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00 AND PUSH1 0x1 SWAP1 DUP2 OR SWAP1 SWAP2 SSTORE PUSH1 0x3 DUP1 SLOAD SWAP2 DUP3 ADD DUP2 SSTORE DUP4 MSTORE PUSH32 0xC2575A0E9E593C00F959F8C92F12DB2869C3395A3B0502D05E2516446F71F85B ADD DUP1 SLOAD PUSH32 0xFFFFFFFFFFFFFFFFFFFFFFFF0000000000000000000000000000000000000000 AND DUP5 OR SWAP1 SSTORE MLOAD PUSH32 0xF39E6E1EB0EDCF53C221607B54B00CD28F3196FED0A24994DC308B8F611B682D SWAP2 SWAP1 LOG2 POP POP POP POP POP JUMP JUMPDEST PUSH1 0x0 DUP1 DUP1 JUMPDEST PUSH1 0x3 SLOAD DUP2 LT ISZERO PUSH2 0xB93 JUMPI PUSH1 0x0 DUP5 DUP2 MSTORE PUSH1 0x1 PUSH1 0x20 MSTORE PUSH1 0x40 DUP2 KECCAK256 PUSH1 0x3 DUP1 SLOAD SWAP2 SWAP3 SWAP2 DUP5 SWAP1 DUP2 LT PUSH2 0xB37 JUMPI INVALID JUMPDEST PUSH1 0x0 SWAP2 DUP3 MSTORE PUSH1 0x20 DUP1 DUP4 KECCAK256 SWAP1 SWAP2 ADD SLOAD PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND DUP4 MSTORE DUP3 ADD SWAP3 SWAP1 SWAP3 MSTORE PUSH1 0x40 ADD SWAP1 KECCAK256 SLOAD PUSH1 0xFF AND ISZERO PUSH2 0xB78 JUMPI PUSH1 0x1 DUP3 ADD SWAP2 POP JUMPDEST PUSH1 0x4 SLOAD DUP3 EQ ISZERO PUSH2 0xB8B JUMPI PUSH1 0x1 SWAP3 POP PUSH2 0xB93 JUMP JUMPDEST PUSH1 0x1 ADD PUSH2 0xB0E JUMP JUMPDEST POP POP SWAP2 SWAP1 POP JUMP JUMPDEST PUSH1 0x0 DUP1 JUMPDEST PUSH1 0x3 SLOAD DUP2 LT ISZERO PUSH2 0xC10 JUMPI PUSH1 0x0 DUP4 DUP2 MSTORE PUSH1 0x1 PUSH1 0x20 MSTORE PUSH1 0x40 DUP2 KECCAK256 PUSH1 0x3 DUP1 SLOAD SWAP2 SWAP3 SWAP2 DUP5 SWAP1 DUP2 LT PUSH2 0xBC7 JUMPI INVALID JUMPDEST PUSH1 0x0 SWAP2 DUP3 MSTORE PUSH1 0x20 DUP1 DUP4 KECCAK256 SWAP1 SWAP2 ADD SLOAD PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND DUP4 MSTORE DUP3 ADD SWAP3 SWAP1 SWAP3 MSTORE PUSH1 0x40 ADD SWAP1 KECCAK256 SLOAD PUSH1 0xFF AND ISZERO PUSH2 0xC08 JUMPI PUSH1 0x1 DUP3 ADD SWAP2 POP JUMPDEST PUSH1 0x1 ADD PUSH2 0xB9E JUMP JUMPDEST POP SWAP2 SWAP1 POP JUMP JUMPDEST PUSH1 0x0 PUSH1 0x20 DUP2 DUP2 MSTORE SWAP2 DUP2 MSTORE PUSH1 0x40 SWAP1 DUP2 SWAP1 KECCAK256 DUP1 SLOAD PUSH1 0x1 DUP1 DUP4 ADD SLOAD PUSH1 0x2 DUP1 DUP6 ADD DUP1 SLOAD DUP8 MLOAD PUSH2 0x100 SWAP6 DUP3 AND ISZERO SWAP6 SWAP1 SWAP6 MUL PUSH32 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF ADD AND SWAP2 SWAP1 SWAP2 DIV PUSH1 0x1F DUP2 ADD DUP9 SWAP1 DIV DUP9 MUL DUP5 ADD DUP9 ADD SWAP1 SWAP7 MSTORE DUP6 DUP4 MSTORE PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF SWAP1 SWAP4 AND SWAP6 SWAP1 SWAP5 SWAP2 SWAP3 SWAP2 SWAP1 DUP4 ADD DUP3 DUP3 DUP1 ISZERO PUSH2 0xCEC JUMPI DUP1 PUSH1 0x1F LT PUSH2 0xCC1 JUMPI PUSH2 0x100 DUP1 DUP4 SLOAD DIV MUL DUP4 MSTORE SWAP2 PUSH1 0x20 ADD SWAP2 PUSH2 0xCEC JUMP JUMPDEST DUP3 ADD SWAP2 SWAP1 PUSH1 0x0 MSTORE PUSH1 0x20 PUSH1 0x0 KECCAK256 SWAP1 JUMPDEST DUP2 SLOAD DUP2 MSTORE SWAP1 PUSH1 0x1 ADD SWAP1 PUSH1 0x20 ADD DUP1 DUP4 GT PUSH2 0xCCF JUMPI DUP3 SWAP1 SUB PUSH1 0x1F AND DUP3 ADD SWAP2 JUMPDEST POP POP POP PUSH1 0x3 SWAP1 SWAP4 ADD SLOAD SWAP2 SWAP3 POP POP PUSH1 0xFF AND DUP5 JUMP JUMPDEST PUSH1 0x60 PUSH1 0x3 DUP1 SLOAD DUP1 PUSH1 0x20 MUL PUSH1 0x20 ADD PUSH1 0x40 MLOAD SWAP1 DUP2 ADD PUSH1 0x40 MSTORE DUP1 SWAP3 SWAP2 SWAP1 DUP2 DUP2 MSTORE PUSH1 0x20 ADD DUP3 DUP1 SLOAD DUP1 ISZERO PUSH2 0xD64 JUMPI PUSH1 0x20 MUL DUP3 ADD SWAP2 SWAP1 PUSH1 0x0 MSTORE PUSH1 0x20 PUSH1 0x0 KECCAK256 SWAP1 JUMPDEST DUP2 SLOAD PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND DUP2 MSTORE PUSH1 0x1 SWAP1 SWAP2 ADD SWAP1 PUSH1 0x20 ADD DUP1 DUP4 GT PUSH2 0xD39 JUMPI JUMPDEST POP POP POP POP POP SWAP1 POP JUMPDEST SWAP1 JUMP JUMPDEST PUSH1 0x60 DUP1 PUSH1 0x0 DUP1 PUSH1 0x5 SLOAD PUSH1 0x40 MLOAD SWAP1 DUP1 DUP3 MSTORE DUP1 PUSH1 0x20 MUL PUSH1 0x20 ADD DUP3 ADD PUSH1 0x40 MSTORE DUP1 ISZERO PUSH2 0xDA1 JUMPI DUP2 PUSH1 0x20 ADD PUSH1 0x20 DUP3 MUL DUP1 CODESIZE DUP4 CODECOPY ADD SWAP1 POP JUMPDEST POP SWAP3 POP PUSH1 0x0 SWAP2 POP PUSH1 0x0 SWAP1 POP JUMPDEST PUSH1 0x5 SLOAD DUP2 LT ISZERO PUSH2 0xE28 JUMPI DUP6 DUP1 ISZERO PUSH2 0xDD6 JUMPI POP PUSH1 0x0 DUP2 DUP2 MSTORE PUSH1 0x20 DUP2 SWAP1 MSTORE PUSH1 0x40 SWAP1 KECCAK256 PUSH1 0x3 ADD SLOAD PUSH1 0xFF AND ISZERO JUMPDEST DUP1 PUSH2 0xDFA JUMPI POP DUP5 DUP1 ISZERO PUSH2 0xDFA JUMPI POP PUSH1 0x0 DUP2 DUP2 MSTORE PUSH1 0x20 DUP2 SWAP1 MSTORE PUSH1 0x40 SWAP1 KECCAK256 PUSH1 0x3 ADD SLOAD PUSH1 0xFF AND JUMPDEST ISZERO PUSH2 0xE20 JUMPI DUP1 DUP4 DUP4 DUP2 MLOAD DUP2 LT ISZERO ISZERO PUSH2 0xE0E JUMPI INVALID JUMPDEST PUSH1 0x20 SWAP1 DUP2 MUL SWAP1 SWAP2 ADD ADD MSTORE PUSH1 0x1 SWAP2 SWAP1 SWAP2 ADD SWAP1 JUMPDEST PUSH1 0x1 ADD PUSH2 0xDAD JUMP JUMPDEST DUP8 DUP8 SUB PUSH1 0x40 MLOAD SWAP1 DUP1 DUP3 MSTORE DUP1 PUSH1 0x20 MUL PUSH1 0x20 ADD DUP3 ADD PUSH1 0x40 MSTORE DUP1 ISZERO PUSH2 0xE54 JUMPI DUP2 PUSH1 0x20 ADD PUSH1 0x20 DUP3 MUL DUP1 CODESIZE DUP4 CODECOPY ADD SWAP1 POP JUMPDEST POP SWAP4 POP DUP8 SWAP1 POP JUMPDEST DUP7 DUP2 LT ISZERO PUSH2 0xE9D JUMPI DUP3 DUP2 DUP2 MLOAD DUP2 LT ISZERO ISZERO PUSH2 0xE71 JUMPI INVALID JUMPDEST SWAP1 PUSH1 0x20 ADD SWAP1 PUSH1 0x20 MUL ADD MLOAD DUP5 DUP10 DUP4 SUB DUP2 MLOAD DUP2 LT ISZERO ISZERO PUSH2 0xE8B JUMPI INVALID JUMPDEST PUSH1 0x20 SWAP1 DUP2 MUL SWAP1 SWAP2 ADD ADD MSTORE PUSH1 0x1 ADD PUSH2 0xE5B JUMP JUMPDEST POP POP POP SWAP5 SWAP4 POP POP POP POP JUMP JUMPDEST PUSH1 0x60 DUP1 PUSH1 0x0 DUP1 PUSH1 0x3 DUP1 SLOAD SWAP1 POP PUSH1 0x40 MLOAD SWAP1 DUP1 DUP3 MSTORE DUP1 PUSH1 0x20 MUL PUSH1 0x20 ADD DUP3 ADD PUSH1 0x40 MSTORE DUP1 ISZERO PUSH2 0xEDD JUMPI DUP2 PUSH1 0x20 ADD PUSH1 0x20 DUP3 MUL DUP1 CODESIZE DUP4 CODECOPY ADD SWAP1 POP JUMPDEST POP SWAP3 POP PUSH1 0x0 SWAP2 POP PUSH1 0x0 SWAP1 POP JUMPDEST PUSH1 0x3 SLOAD DUP2 LT ISZERO PUSH2 0xFC1 JUMPI PUSH1 0x0 DUP6 DUP2 MSTORE PUSH1 0x1 PUSH1 0x20 MSTORE PUSH1 0x40 DUP2 KECCAK256 PUSH1 0x3 DUP1 SLOAD SWAP2 SWAP3 SWAP2 DUP5 SWAP1 DUP2 LT PUSH2 0xF12 JUMPI INVALID JUMPDEST PUSH1 0x0 SWAP2 DUP3 MSTORE PUSH1 0x20 DUP1 DUP4 KECCAK256 SWAP1 SWAP2 ADD SLOAD PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND DUP4 MSTORE DUP3 ADD SWAP3 SWAP1 SWAP3 MSTORE PUSH1 0x40 ADD SWAP1 KECCAK256 SLOAD PUSH1 0xFF AND ISZERO PUSH2 0xFB9 JUMPI PUSH1 0x3 DUP1 SLOAD DUP3 SWAP1 DUP2 LT PUSH2 0xF5A JUMPI INVALID JUMPDEST PUSH1 0x0 SWAP2 DUP3 MSTORE PUSH1 0x20 SWAP1 SWAP2 KECCAK256 ADD SLOAD DUP4 MLOAD PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF SWAP1 SWAP2 AND SWAP1 DUP5 SWAP1 DUP5 SWAP1 DUP2 LT PUSH2 0xF8D JUMPI INVALID JUMPDEST PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF SWAP1 SWAP3 AND PUSH1 0x20 SWAP3 DUP4 MUL SWAP1 SWAP2 ADD SWAP1 SWAP2 ADD MSTORE PUSH1 0x1 SWAP2 SWAP1 SWAP2 ADD SWAP1 JUMPDEST PUSH1 0x1 ADD PUSH2 0xEE9 JUMP JUMPDEST DUP2 PUSH1 0x40 MLOAD SWAP1 DUP1 DUP3 MSTORE DUP1 PUSH1 0x20 MUL PUSH1 0x20 ADD DUP3 ADD PUSH1 0x40 MSTORE DUP1 ISZERO PUSH2 0xFEB JUMPI DUP2 PUSH1 0x20 ADD PUSH1 0x20 DUP3 MUL DUP1 CODESIZE DUP4 CODECOPY ADD SWAP1 POP JUMPDEST POP SWAP4 POP PUSH1 0x0 SWAP1 POP JUMPDEST DUP2 DUP2 LT ISZERO PUSH2 0x104D JUMPI DUP3 DUP2 DUP2 MLOAD DUP2 LT ISZERO ISZERO PUSH2 0x1009 JUMPI INVALID JUMPDEST SWAP1 PUSH1 0x20 ADD SWAP1 PUSH1 0x20 MUL ADD MLOAD DUP5 DUP3 DUP2 MLOAD DUP2 LT ISZERO ISZERO PUSH2 0x1021 JUMPI INVALID JUMPDEST PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF SWAP1 SWAP3 AND PUSH1 0x20 SWAP3 DUP4 MUL SWAP1 SWAP2 ADD SWAP1 SWAP2 ADD MSTORE PUSH1 0x1 ADD PUSH2 0xFF3 JUMP JUMPDEST POP POP POP SWAP2 SWAP1 POP JUMP JUMPDEST PUSH1 0x5 SLOAD DUP2 JUMP JUMPDEST CALLER ADDRESS EQ PUSH2 0x1067 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH1 0x3 SLOAD DUP2 PUSH1 0x32 DUP3 GT DUP1 ISZERO SWAP1 PUSH2 0x107C JUMPI POP DUP2 DUP2 GT ISZERO JUMPDEST DUP1 ISZERO PUSH2 0x1087 JUMPI POP DUP1 ISZERO ISZERO JUMPDEST DUP1 ISZERO PUSH2 0x1092 JUMPI POP DUP2 ISZERO ISZERO JUMPDEST ISZERO ISZERO PUSH2 0x109D JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH1 0x4 DUP4 SWAP1 SSTORE PUSH1 0x40 DUP1 MLOAD DUP5 DUP2 MSTORE SWAP1 MLOAD PUSH32 0xA3F1EE9126A074D9326C682F561767F710E927FAA811F7A99829D49DC421797A SWAP2 DUP2 SWAP1 SUB PUSH1 0x20 ADD SWAP1 LOG1 POP POP POP JUMP JUMPDEST CALLER PUSH1 0x0 DUP2 DUP2 MSTORE PUSH1 0x2 PUSH1 0x20 MSTORE PUSH1 0x40 SWAP1 KECCAK256 SLOAD PUSH1 0xFF AND ISZERO ISZERO PUSH2 0x10F8 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH1 0x0 DUP3 DUP2 MSTORE PUSH1 0x20 DUP2 SWAP1 MSTORE PUSH1 0x40 SWAP1 KECCAK256 SLOAD DUP3 SWAP1 PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND ISZERO ISZERO PUSH2 0x112A JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH1 0x0 DUP4 DUP2 MSTORE PUSH1 0x1 PUSH1 0x20 SWAP1 DUP2 MSTORE PUSH1 0x40 DUP1 DUP4 KECCAK256 CALLER DUP1 DUP6 MSTORE SWAP3 MSTORE SWAP1 SWAP2 KECCAK256 SLOAD DUP5 SWAP2 SWAP1 PUSH1 0xFF AND ISZERO PUSH2 0x1155 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH1 0x0 DUP6 DUP2 MSTORE PUSH1 0x1 PUSH1 0x20 DUP2 DUP2 MSTORE PUSH1 0x40 DUP1 DUP5 KECCAK256 CALLER DUP1 DUP7 MSTORE SWAP3 MSTORE DUP1 DUP5 KECCAK256 DUP1 SLOAD PUSH32 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00 AND SWAP1 SWAP4 OR SWAP1 SWAP3 SSTORE SWAP1 MLOAD DUP8 SWAP3 PUSH32 0x4A504A94899432A9846E1AA406DCEB1BCFD538BB839071D49D1E5E23F5BE30EF SWAP2 LOG3 PUSH2 0x11C9 DUP6 PUSH2 0x140A JUMP JUMPDEST POP POP POP POP POP JUMP JUMPDEST PUSH1 0x0 PUSH2 0x11DD DUP5 DUP5 DUP5 PUSH2 0x1631 JUMP JUMPDEST SWAP1 POP PUSH2 0x11E8 DUP2 PUSH2 0x10DA JUMP JUMPDEST SWAP4 SWAP3 POP POP POP JUMP JUMPDEST PUSH1 0x32 DUP2 JUMP JUMPDEST PUSH1 0x4 SLOAD DUP2 JUMP JUMPDEST PUSH1 0x0 CALLER ADDRESS EQ PUSH2 0x1208 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF DUP4 AND PUSH1 0x0 SWAP1 DUP2 MSTORE PUSH1 0x2 PUSH1 0x20 MSTORE PUSH1 0x40 SWAP1 KECCAK256 SLOAD DUP4 SWAP1 PUSH1 0xFF AND ISZERO ISZERO PUSH2 0x123E JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF DUP4 AND PUSH1 0x0 SWAP1 DUP2 MSTORE PUSH1 0x2 PUSH1 0x20 MSTORE PUSH1 0x40 SWAP1 KECCAK256 SLOAD DUP4 SWAP1 PUSH1 0xFF AND ISZERO PUSH2 0x1273 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH1 0x0 SWAP3 POP JUMPDEST PUSH1 0x3 SLOAD DUP4 LT ISZERO PUSH2 0x1338 JUMPI DUP5 PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND PUSH1 0x3 DUP5 DUP2 SLOAD DUP2 LT ISZERO ISZERO PUSH2 0x12A8 JUMPI INVALID JUMPDEST PUSH1 0x0 SWAP2 DUP3 MSTORE PUSH1 0x20 SWAP1 SWAP2 KECCAK256 ADD SLOAD PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND EQ ISZERO PUSH2 0x132D JUMPI DUP4 PUSH1 0x3 DUP5 DUP2 SLOAD DUP2 LT ISZERO ISZERO PUSH2 0x12E0 JUMPI INVALID JUMPDEST SWAP1 PUSH1 0x0 MSTORE PUSH1 0x20 PUSH1 0x0 KECCAK256 ADD PUSH1 0x0 PUSH2 0x100 EXP DUP2 SLOAD DUP2 PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF MUL NOT AND SWAP1 DUP4 PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND MUL OR SWAP1 SSTORE POP PUSH2 0x1338 JUMP JUMPDEST PUSH1 0x1 SWAP1 SWAP3 ADD SWAP2 PUSH2 0x1278 JUMP JUMPDEST PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF DUP1 DUP7 AND PUSH1 0x0 DUP2 DUP2 MSTORE PUSH1 0x2 PUSH1 0x20 MSTORE PUSH1 0x40 DUP1 DUP3 KECCAK256 DUP1 SLOAD PUSH32 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00 SWAP1 DUP2 AND SWAP1 SWAP2 SSTORE SWAP4 DUP9 AND DUP3 MSTORE DUP1 DUP3 KECCAK256 DUP1 SLOAD SWAP1 SWAP5 AND PUSH1 0x1 OR SWAP1 SWAP4 SSTORE SWAP2 MLOAD SWAP1 SWAP2 PUSH32 0x8001553A916EF2F495D26A907CC54D96ED840D7BDA71E73194BF5A9DF7A76B90 SWAP2 LOG2 PUSH1 0x40 MLOAD PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF DUP6 AND SWAP1 PUSH32 0xF39E6E1EB0EDCF53C221607B54B00CD28F3196FED0A24994DC308B8F611B682D SWAP1 PUSH1 0x0 SWAP1 LOG2 POP POP POP POP POP JUMP JUMPDEST CALLER PUSH1 0x0 DUP2 DUP2 MSTORE PUSH1 0x2 PUSH1 0x20 MSTORE PUSH1 0x40 DUP2 KECCAK256 SLOAD SWAP1 SWAP2 SWAP1 PUSH1 0xFF AND ISZERO ISZERO PUSH2 0x142B JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH1 0x0 DUP4 DUP2 MSTORE PUSH1 0x1 PUSH1 0x20 SWAP1 DUP2 MSTORE PUSH1 0x40 DUP1 DUP4 KECCAK256 CALLER DUP1 DUP6 MSTORE SWAP3 MSTORE SWAP1 SWAP2 KECCAK256 SLOAD DUP5 SWAP2 SWAP1 PUSH1 0xFF AND ISZERO ISZERO PUSH2 0x1457 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH1 0x0 DUP6 DUP2 MSTORE PUSH1 0x20 DUP2 SWAP1 MSTORE PUSH1 0x40 SWAP1 KECCAK256 PUSH1 0x3 ADD SLOAD DUP6 SWAP1 PUSH1 0xFF AND ISZERO PUSH2 0x1478 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH2 0x1481 DUP7 PUSH2 0xB09 JUMP JUMPDEST ISZERO PUSH2 0x1629 JUMPI PUSH1 0x0 DUP7 DUP2 MSTORE PUSH1 0x20 DUP2 DUP2 MSTORE PUSH1 0x40 SWAP2 DUP3 SWAP1 KECCAK256 PUSH1 0x3 DUP2 ADD DUP1 SLOAD PUSH32 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00 AND PUSH1 0x1 SWAP1 DUP2 OR SWAP1 SWAP2 SSTORE DUP2 SLOAD DUP2 DUP4 ADD SLOAD PUSH1 0x2 DUP1 DUP6 ADD DUP1 SLOAD DUP9 MLOAD PUSH1 0x1F PUSH32 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF SWAP8 DUP4 AND ISZERO PUSH2 0x100 MUL SWAP8 SWAP1 SWAP8 ADD SWAP1 SWAP2 AND SWAP3 SWAP1 SWAP3 DIV SWAP5 DUP6 ADD DUP8 SWAP1 DIV DUP8 MUL DUP3 ADD DUP8 ADD SWAP1 SWAP8 MSTORE DUP4 DUP2 MSTORE SWAP4 SWAP11 POP PUSH2 0x159E SWAP6 PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF SWAP1 SWAP3 AND SWAP5 SWAP1 SWAP4 SWAP2 SWAP1 DUP4 SWAP1 DUP4 ADD DUP3 DUP3 DUP1 ISZERO PUSH2 0x1594 JUMPI DUP1 PUSH1 0x1F LT PUSH2 0x1569 JUMPI PUSH2 0x100 DUP1 DUP4 SLOAD DIV MUL DUP4 MSTORE SWAP2 PUSH1 0x20 ADD SWAP2 PUSH2 0x1594 JUMP JUMPDEST DUP3 ADD SWAP2 SWAP1 PUSH1 0x0 MSTORE PUSH1 0x20 PUSH1 0x0 KECCAK256 SWAP1 JUMPDEST DUP2 SLOAD DUP2 MSTORE SWAP1 PUSH1 0x1 ADD SWAP1 PUSH1 0x20 ADD DUP1 DUP4 GT PUSH2 0x1577 JUMPI DUP3 SWAP1 SUB PUSH1 0x1F AND DUP3 ADD SWAP2 JUMPDEST POP POP POP POP POP PUSH2 0x1764 JUMP JUMPDEST ISZERO PUSH2 0x15D3 JUMPI PUSH1 0x40 MLOAD DUP7 SWAP1 PUSH32 0x33E13ECB54C3076D8E8BB8C2881800A4D972B792045FFAE98FDF46DF365FED75 SWAP1 PUSH1 0x0 SWAP1 LOG2 PUSH2 0x1629 JUMP JUMPDEST PUSH1 0x40 MLOAD DUP7 SWAP1 PUSH32 0x526441BB6C1ABA3C9A4A6CA1D6545DA9C2333C8C48343EF398EB858D72B79236 SWAP1 PUSH1 0x0 SWAP1 LOG2 PUSH1 0x3 DUP6 ADD DUP1 SLOAD PUSH32 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00 AND SWAP1 SSTORE JUMPDEST POP POP POP POP POP POP JUMP JUMPDEST PUSH1 0x0 DUP4 PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF DUP2 AND ISZERO ISZERO PUSH2 0x1656 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH1 0x5 SLOAD PUSH1 0x40 DUP1 MLOAD PUSH1 0x80 DUP2 ADD DUP3 MSTORE PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF DUP9 DUP2 AND DUP3 MSTORE PUSH1 0x20 DUP1 DUP4 ADD DUP10 DUP2 MSTORE DUP4 DUP6 ADD DUP10 DUP2 MSTORE PUSH1 0x0 PUSH1 0x60 DUP7 ADD DUP2 SWAP1 MSTORE DUP8 DUP2 MSTORE DUP1 DUP5 MSTORE SWAP6 SWAP1 SWAP6 KECCAK256 DUP5 MLOAD DUP2 SLOAD PUSH32 0xFFFFFFFFFFFFFFFFFFFFFFFF0000000000000000000000000000000000000000 AND SWAP5 AND SWAP4 SWAP1 SWAP4 OR DUP4 SSTORE MLOAD PUSH1 0x1 DUP4 ADD SSTORE SWAP3 MLOAD DUP1 MLOAD SWAP5 SWAP7 POP SWAP2 SWAP4 SWAP1 SWAP3 PUSH2 0x16EE SWAP3 PUSH1 0x2 DUP6 ADD SWAP3 SWAP2 ADD SWAP1 PUSH2 0x17B0 JUMP JUMPDEST POP PUSH1 0x60 SWAP2 SWAP1 SWAP2 ADD MLOAD PUSH1 0x3 SWAP1 SWAP2 ADD DUP1 SLOAD PUSH32 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00 AND SWAP2 ISZERO ISZERO SWAP2 SWAP1 SWAP2 OR SWAP1 SSTORE PUSH1 0x5 DUP1 SLOAD PUSH1 0x1 ADD SWAP1 SSTORE PUSH1 0x40 MLOAD DUP3 SWAP1 PUSH32 0xC0BA8FE4B176C1714197D43B9CC6BCF797A4A7461C5FE8D0EF6E184AE7601E51 SWAP1 PUSH1 0x0 SWAP1 LOG2 POP SWAP4 SWAP3 POP POP POP JUMP JUMPDEST PUSH1 0x0 DUP1 PUSH1 0x40 MLOAD PUSH1 0x20 DUP5 ADD PUSH1 0x0 DUP3 DUP8 DUP4 DUP11 DUP13 PUSH2 0x8796 GAS SUB CALL SWAP9 SWAP8 POP POP POP POP POP POP POP POP JUMP JUMPDEST DUP2 SLOAD DUP2 DUP4 SSTORE DUP2 DUP2 GT ISZERO PUSH2 0x17AB JUMPI PUSH1 0x0 DUP4 DUP2 MSTORE PUSH1 0x20 SWAP1 KECCAK256 PUSH2 0x17AB SWAP2 DUP2 ADD SWAP1 DUP4 ADD PUSH2 0x182E JUMP JUMPDEST POP POP POP JUMP JUMPDEST DUP3 DUP1 SLOAD PUSH1 0x1 DUP2 PUSH1 0x1 AND ISZERO PUSH2 0x100 MUL SUB AND PUSH1 0x2 SWAP1 DIV SWAP1 PUSH1 0x0 MSTORE PUSH1 0x20 PUSH1 0x0 KECCAK256 SWAP1 PUSH1 0x1F ADD PUSH1 0x20 SWAP1 DIV DUP2 ADD SWAP3 DUP3 PUSH1 0x1F LT PUSH2 0x17F1 JUMPI DUP1 MLOAD PUSH1 0xFF NOT AND DUP4 DUP1 ADD OR DUP6 SSTORE PUSH2 0x181E JUMP JUMPDEST DUP3 DUP1 ADD PUSH1 0x1 ADD DUP6 SSTORE DUP3 ISZERO PUSH2 0x181E JUMPI SWAP2 DUP3 ADD JUMPDEST DUP3 DUP2 GT ISZERO PUSH2 0x181E JUMPI DUP3 MLOAD DUP3 SSTORE SWAP2 PUSH1 0x20 ADD SWAP2 SWAP1 PUSH1 0x1 ADD SWAP1 PUSH2 0x1803 JUMP JUMPDEST POP PUSH2 0x182A SWAP3 SWAP2 POP PUSH2 0x182E JUMP JUMPDEST POP SWAP1 JUMP JUMPDEST PUSH2 0xD6C SWAP2 SWAP1 JUMPDEST DUP1 DUP3 GT ISZERO PUSH2 0x182A JUMPI PUSH1 0x0 DUP2 SSTORE PUSH1 0x1 ADD PUSH2 0x1834 JUMP STOP LOG1 PUSH6 0x627A7A723058 KECCAK256 0x5e 0xc9 0xb1 CREATE DUP7 0x4a 0xe6 SWAP4 BALANCE 0xe8 SWAP5 0xf6 SWAP5 0x21 0xe6 CODESIZE SWAP14 0xd3 0xd4 SWAP13 ADD SWAP3 0xe2 0xc2 0x47 DUP15 0xa6 PUSH25 0xB4158E44002900000000000000000000000000000000000000 ", + "sourceMap": + "206:12628:0:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2540:1;2528:9;:13;2524:61;;;2555:30;;;2575:9;2555:30;;;;2563:10;;2555:30;;;;;;;;;;2524:61;206:12628;1050:23;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;1050:23:0;;;;;;;;;;;;;;;;;;;;;;;;3715:460;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;3715:460:0;;;;;;;6281:291;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;6281:291:0;;;;;1004:40;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;1004:40:0;;;;;;;;;;;;;;;;;;;;;;;;;934:64;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;934:64:0;;;;;;;;;10535:319;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;10535:319:0;;;;;;;;;;;;;;;;;;;;;;;;;;;3315:277;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;3315:277:0;;;;;;;8703:337;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;8703:337:0;;;;;10021:252;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;10021:252:0;;;;;879:49;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;879:49:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;;12:14;879:49:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;10938:115;;8:9:-1;5:2;;;30:1;27;20:12;5:2;10938:115:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:100:-1;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;;12:14;10938:115:0;;;;;;;;;;;;;;;;;12156:676;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;12156:676:0;;;;;;;;;;;;;;;11232:575;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;11232:575:0;;;;;1105:28;;8:9:-1;5:2;;;30:1;27;20:12;5:2;1105:28:0;;;;4997:207;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;4997:207:0;;;;;5813:344;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;5813:344:0;;;;;5463:244;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;5463:244:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;5463:244:0;;-1:-1:-1;5463:244:0;;-1:-1:-1;;;;;;;5463:244:0;800:41;;8:9:-1;5:2;;;30:1;27;20:12;5:2;800:41:0;;;;1079:20;;8:9:-1;5:2;;;30:1;27;20:12;5:2;1079:20:0;;;;4377:449;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;4377:449:0;;;;;;;;;;;;6686:586;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;6686:586:0;;;;;1050:23;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;1050:23:0;:::o;3715:460::-;3863:6;1337:10;1359:4;1337:27;1329:36;;;;;;1543:14;;;;;;;:7;:14;;;;;;3805:5;;1543:14;;1535:23;;;;;;;;3826:14;;;3843:5;3826:14;;;:7;:14;;;;;:22;;;;;;3843:5;-1:-1:-1;3858:170:0;3875:6;:13;:17;;3873:19;;3858:170;;;3928:5;3915:18;;:6;3922:1;3915:9;;;;;;;;;;;;;;;;;;;;;;:18;3911:117;;;3965:6;3972:13;;:17;;;;3965:25;;;;;;;;;;;;;;;;3953:6;:9;;3965:25;;;;;3960:1;;3953:9;;;;;;;;;;;;;;:37;;;;;;;;;;;;;;;;;;4008:5;;3911:117;3894:3;;;;;3858:170;;;4037:6;:18;;;;;;;;;:::i;:::-;-1:-1:-1;4080:6:0;:13;4069:8;;:24;4065:74;;;4125:6;:13;4107:32;;:17;:32::i;:::-;4149:19;;;;;;;;;;;1375:1;3715:460;;:::o;6281:291::-;6364:10;1543:14;;;;:7;:14;;;;;;;;1535:23;;;;;;;;1788:28;;;;:13;:28;;;;;;;;6409:10;1788:35;;;;;;;;;6394:13;;6409:10;1788:35;;1780:44;;;;;;;;2044:12;:27;;;;;;;;;;:36;;;6441:13;;2044:36;;2043:37;2035:46;;;;;;6513:5;6470:28;;;:13;:28;;;;;;;;6499:10;6470:40;;;;;;;;:48;;;;;;6528:37;6484:13;;6528:37;;;1834:1;1568;;6281:291;;:::o;1004:40::-;;;;;;;;;;;;;;;:::o;934:64::-;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;10535:319::-;10642:10;;10668:179;10685:16;;10683:1;:18;10668:179;;;10727:7;:36;;;;-1:-1:-1;10739:12:0;:15;;;;;;;;;;:24;;;;;10738:25;10727:36;:92;;;;10783:8;:36;;;;-1:-1:-1;10795:12:0;:15;;;;;;;;;;:24;;;;;10783:36;10720:127;;;10846:1;10837:10;;;;10720:127;10703:3;;10668:179;;;10535:319;;;;;:::o;3315:277::-;1337:10;1359:4;1337:27;1329:36;;;;;;1450:14;;;;;;;:7;:14;;;;;;3408:5;;1450:14;;1449:15;1441:24;;;;;;3431:5;2158:13;;;;;2150:22;;;;;;3463:6;:13;;;;3479:1;3463:17;3482:8;;839:2;2273:10;:29;;:68;;;;;2331:10;2318:9;:23;;2273:68;:98;;;;-1:-1:-1;2357:14:0;;;2273:98;:129;;;;-1:-1:-1;2387:15:0;;;2273:129;2265:138;;;;;;;;3506:14;;;;;;;:7;:14;;;;;;:21;;;;3523:4;3506:21;;;;;;3537:6;27:10:-1;;23:18;;;45:23;;3537:18:0;;;;;;;;;;;;3565:20;;;3506:14;3565:20;2182:1;;1475;1375;3315:277;:::o;8703:337::-;8793:4;;;8837:197;8854:6;:13;8852:15;;8837:197;;;8892:28;;;;:13;:28;;;;;8921:6;:9;;8892:28;;;8928:1;;8921:9;;;;;;;;;;;;;;;;;;;;8892:39;;;;;;;;;;;;;;;8888:71;;;8958:1;8949:10;;;;8888:71;8986:8;;8977:5;:17;8973:50;;;9019:4;9012:11;;;;8973:50;8869:3;;8837:197;;;8703:337;;;;;:::o;10021:252::-;10120:10;;10146:120;10163:6;:13;10161:15;;10146:120;;;10199:28;;;;:13;:28;;;;;10228:6;:9;;10199:28;;;10235:1;;10228:9;;;;;;;;;;;;;;;;;;;;10199:39;;;;;;;;;;;;;;;10195:71;;;10265:1;10256:10;;;;10195:71;10178:3;;10146:120;;;10021:252;;;;:::o;879:49::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;879:49:0;;;;;;;-1:-1:-1;;879:49:0;;;:::o;10938:115::-;11008:9;11040:6;11033:13;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;10938:115;;:::o;12156:676::-;12281:22;12319:32;12392:10;12416:6;12365:16;;12354:28;;;;;;;;;;;;;;;;;;;;;;29:2:-1;21:6;17:15;117:4;105:10;97:6;88:34;136:17;;-1:-1;12354:28:0;;12319:63;;12405:1;12392:14;;12439:1;12437:3;;12432:250;12444:16;;12442:1;:18;12432:250;;;12486:7;:36;;;;-1:-1:-1;12498:12:0;:15;;;;;;;;;;:24;;;;;12497:25;12486:36;:92;;;;12542:8;:36;;;;-1:-1:-1;12554:12:0;:15;;;;;;;;;;:24;;;;;12542:36;12479:203;;;12638:1;12610:18;12629:5;12610:25;;;;;;;;;;;;;;;;;;:29;12666:1;12657:10;;;;;12479:203;12462:3;;12432:250;;;12725:4;12720:2;:9;12709:21;;;;;;;;;;;;;;;;;;;;;;29:2:-1;21:6;17:15;117:4;105:10;97:6;88:34;136:17;;-1:-1;12709:21:0;;12691:39;;12747:4;12745:6;;12740:85;12755:2;12753:1;:4;12740:85;;;12804:18;12823:1;12804:21;;;;;;;;;;;;;;;;;;12776:15;12796:4;12792:1;:8;12776:25;;;;;;;;;;;;;;;;;;:49;12759:3;;12740:85;;;12156:676;;;;;;;;;:::o;11232:575::-;11327:24;11367:34;11442:10;11466:6;11418;:13;;;;11404:28;;;;;;;;;;;;;;;;;;;;;;29:2:-1;21:6;17:15;117:4;105:10;97:6;88:34;136:17;;-1:-1;11404:28:0;;11367:65;;11455:1;11442:14;;11489:1;11487:3;;11482:186;11494:6;:13;11492:15;;11482:186;;;11530:28;;;;:13;:28;;;;;11559:6;:9;;11530:28;;;11566:1;;11559:9;;;;;;;;;;;;;;;;;;;;11530:39;;;;;;;;;;;;;;;11526:142;;;11616:6;:9;;11623:1;;11616:9;;;;;;;;;;;;;;;;11589:24;;11616:9;;;;;11589:17;;11607:5;;11589:24;;;;;;:36;;;;:24;;;;;;;;;;:36;11652:1;11643:10;;;;;11526:142;11509:3;;11482:186;;;11708:5;11694:20;;;;;;;;;;;;;;;;;;;;;;29:2:-1;21:6;17:15;117:4;105:10;97:6;88:34;136:17;;-1:-1;11694:20:0;;11677:37;;11731:1;11729:3;;11724:76;11736:5;11734:1;:7;11724:76;;;11780:17;11798:1;11780:20;;;;;;;;;;;;;;;;;;11760:14;11775:1;11760:17;;;;;;;;;;:40;;;;:17;;;;;;;;;;:40;11743:3;;11724:76;;;11232:575;;;;;;:::o;1105:28::-;;;;:::o;4997:207::-;1337:10;1359:4;1337:27;1329:36;;;;;;5099:6;:13;5114:9;839:2;2273:29;;;;;:68;;;2331:10;2318:9;:23;;2273:68;:98;;;;-1:-1:-1;2357:14:0;;;2273:98;:129;;;;-1:-1:-1;2387:15:0;;;2273:129;2265:138;;;;;;;;5139:8;:20;;;5169:28;;;;;;;;;;;;;;;;;1375:1;;4997:207;:::o;5813:344::-;5896:10;1543:14;;;;:7;:14;;;;;;;;1535:23;;;;;;;;1647:12;:27;;;;;;;;;;:39;5934:13;;1647:39;;:44;;1639:53;;;;;;1924:28;;;;:13;:28;;;;;;;;5985:10;1924:35;;;;;;;;;5970:13;;5985:10;1924:35;;1923:36;1915:45;;;;;;6011:28;;;;6054:4;6011:28;;;;;;;;6040:10;6011:40;;;;;;;;:47;;;;;;;;;;6068:39;;6025:13;;6068:39;;;6117:33;6136:13;6117:18;:33::i;:::-;1702:1;;1568;5813:344;;:::o;5463:244::-;5567:18;5617:40;5632:11;5645:5;5652:4;5617:14;:40::i;:::-;5601:56;;5667:33;5686:13;5667:18;:33::i;:::-;5463:244;;;;;:::o;800:41::-;839:2;800:41;:::o;1079:20::-;;;;:::o;4377:449::-;4548:6;1337:10;1359:4;1337:27;1329:36;;;;;;1543:14;;;;;;;:7;:14;;;;;;4486:5;;1543:14;;1535:23;;;;;;;;1450:14;;;;;;;:7;:14;;;;;;4519:8;;1450:14;;1449:15;1441:24;;;;;;4555:1;4548:8;;4543:149;4560:6;:13;4558:15;;4543:149;;;4609:5;4596:18;;:6;4603:1;4596:9;;;;;;;;;;;;;;;;;;;;;;:18;4592:100;;;4646:8;4634:6;4641:1;4634:9;;;;;;;;;;;;;;;;;;:20;;;;;;;;;;;;;;;;;;4672:5;;4592:100;4575:3;;;;;4543:149;;;4701:14;;;;4718:5;4701:14;;;:7;:14;;;;;;:22;;;;;;;;;4733:17;;;;;;;;:24;;;;;4701:22;4733:24;;;;4767:19;;4701:14;;4767:19;;;4796:23;;;;;;;;;;;1568:1;1375;4377:449;;;:::o;6686:586::-;6769:10;6921:23;1543:14;;;:7;:14;;;;;;6921:23;;6769:10;1543:14;;1535:23;;;;;;;;1788:28;;;;:13;:28;;;;;;;;6814:10;1788:35;;;;;;;;;6799:13;;6814:10;1788:35;;1780:44;;;;;;;;2044:12;:27;;;;;;;;;;:36;;;6846:13;;2044:36;;2043:37;2035:46;;;;;;6879:26;6891:13;6879:11;:26::i;:::-;6875:391;;;6947:12;:27;;;;;;;;;;;;6988:12;;;:19;;;;7003:4;6988:19;;;;;;7039:15;;7056:9;;;;7067:8;;;;:15;;7025:68;;;7067:15;;;;;6988:19;7067:15;;;;;;;;;;;;7025:68;;;;;;;;;;;;;;;;;;6947:27;;-1:-1:-1;7025:68:0;;7039:15;;;;;7056:9;;7025:68;7067:8;:15;;7025:68;;7067:8;:15;7025:68;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:13;:68::i;:::-;7021:235;;;7111:24;;7121:13;;7111:24;;;;;7021:235;;;7172:31;;7189:13;;7172:31;;;;;7221:12;;;:20;;;;;;7021:235;1834:1;1568;;6686:586;;;:::o;9373:451::-;9505:18;9475:11;2158:13;;;;;2150:22;;;;;;9555:16;;9611:140;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;9611:140:0;;;;;;9581:27;;;;;;;;;;:170;;;;;;;;;;;;;;;-1:-1:-1;9581:170:0;;;;;;;9555:16;;-1:-1:-1;9611:140:0;;9581:27;;:170;;;;;;;;;;:::i;:::-;-1:-1:-1;9581:170:0;;;;;;;;;;;;;;;;;;;;;;;9761:16;:21;;-1:-1:-1;9761:21:0;;;9792:25;;9803:13;;9792:25;;-1:-1:-1;;9792:25:0;9373:451;;;;;;:::o;7449:1103::-;7552:4;7568:11;7627:4;7621:11;7760:2;7754:4;7750:13;8425:1;8406;8298:10;8279:1;8256:5;8227:11;7882:5;7877:3;7873:15;7851:662;7841:672;7449:1103;-1:-1:-1;;;;;;;;7449:1103:0:o;206:12628::-;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;206:12628:0;;;-1:-1:-1;206:12628:0;:::i;:::-;;;:::o;:::-;;;;;;;;;;;;;;;;;" + } + } + }, + "sources": { + "multisig/MultiSigWallet.sol": { + "id": 0 + } + }, + "sourceCodes": { + "multisig/MultiSigWallet.sol": + "// solhint-disable\npragma solidity ^0.4.15;\n\n\n/// @title Multisignature wallet - Allows multiple parties to agree on transactions before execution.\n/// @author Stefan George - \ncontract MultiSigWallet {\n\n /*\n * Events\n */\n event Confirmation(address indexed sender, uint indexed transactionId);\n event Revocation(address indexed sender, uint indexed transactionId);\n event Submission(uint indexed transactionId);\n event Execution(uint indexed transactionId);\n event ExecutionFailure(uint indexed transactionId);\n event Deposit(address indexed sender, uint value);\n event OwnerAddition(address indexed owner);\n event OwnerRemoval(address indexed owner);\n event RequirementChange(uint required);\n\n /*\n * Constants\n */\n uint constant public MAX_OWNER_COUNT = 50;\n\n /*\n * Storage\n */\n mapping (uint => Transaction) public transactions;\n mapping (uint => mapping (address => bool)) public confirmations;\n mapping (address => bool) public isOwner;\n address[] public owners;\n uint public required;\n uint public transactionCount;\n\n struct Transaction {\n address destination;\n uint value;\n bytes data;\n bool executed;\n }\n\n /*\n * Modifiers\n */\n modifier onlyWallet() {\n require(msg.sender == address(this));\n _;\n }\n\n modifier ownerDoesNotExist(address owner) {\n require(!isOwner[owner]);\n _;\n }\n\n modifier ownerExists(address owner) {\n require(isOwner[owner]);\n _;\n }\n\n modifier transactionExists(uint transactionId) {\n require(transactions[transactionId].destination != 0);\n _;\n }\n\n modifier confirmed(uint transactionId, address owner) {\n require(confirmations[transactionId][owner]);\n _;\n }\n\n modifier notConfirmed(uint transactionId, address owner) {\n require(!confirmations[transactionId][owner]);\n _;\n }\n\n modifier notExecuted(uint transactionId) {\n require(!transactions[transactionId].executed);\n _;\n }\n\n modifier notNull(address _address) {\n require(_address != 0);\n _;\n }\n\n modifier validRequirement(uint ownerCount, uint _required) {\n require(ownerCount <= MAX_OWNER_COUNT\n && _required <= ownerCount\n && _required != 0\n && ownerCount != 0);\n _;\n }\n\n /// @dev Fallback function allows to deposit ether.\n function()\n payable\n {\n if (msg.value > 0)\n Deposit(msg.sender, msg.value);\n }\n\n /*\n * Public functions\n */\n /// @dev Contract constructor sets initial owners and required number of confirmations.\n /// @param _owners List of initial owners.\n /// @param _required Number of required confirmations.\n function MultiSigWallet(address[] _owners, uint _required)\n public\n validRequirement(_owners.length, _required)\n {\n for (uint i=0; i<_owners.length; i++) {\n require(!isOwner[_owners[i]] && _owners[i] != 0);\n isOwner[_owners[i]] = true;\n }\n owners = _owners;\n required = _required;\n }\n\n /// @dev Allows to add a new owner. Transaction has to be sent by wallet.\n /// @param owner Address of new owner.\n function addOwner(address owner)\n public\n onlyWallet\n ownerDoesNotExist(owner)\n notNull(owner)\n validRequirement(owners.length + 1, required)\n {\n isOwner[owner] = true;\n owners.push(owner);\n OwnerAddition(owner);\n }\n\n /// @dev Allows to remove an owner. Transaction has to be sent by wallet.\n /// @param owner Address of owner.\n function removeOwner(address owner)\n public\n onlyWallet\n ownerExists(owner)\n {\n isOwner[owner] = false;\n for (uint i=0; i owners.length)\n changeRequirement(owners.length);\n OwnerRemoval(owner);\n }\n\n /// @dev Allows to replace an owner with a new owner. Transaction has to be sent by wallet.\n /// @param owner Address of owner to be replaced.\n /// @param newOwner Address of new owner.\n function replaceOwner(address owner, address newOwner)\n public\n onlyWallet\n ownerExists(owner)\n ownerDoesNotExist(newOwner)\n {\n for (uint i=0; i\n// solhint-disable not-rely-on-time\ncontract MultiSigWalletWithTimeLock is\n MultiSigWallet\n{\n event ConfirmationTimeSet(uint256 indexed transactionId, uint256 confirmationTime);\n event TimeLockChange(uint256 secondsTimeLocked);\n\n uint256 public secondsTimeLocked;\n\n mapping (uint256 => uint256) public confirmationTimes;\n\n modifier notFullyConfirmed(uint256 transactionId) {\n require(\n !isConfirmed(transactionId),\n \"TX_FULLY_CONFIRMED\"\n );\n _;\n }\n\n modifier fullyConfirmed(uint256 transactionId) {\n require(\n isConfirmed(transactionId),\n \"TX_NOT_FULLY_CONFIRMED\"\n );\n _;\n }\n\n modifier pastTimeLock(uint256 transactionId) {\n require(\n block.timestamp >= confirmationTimes[transactionId] + secondsTimeLocked,\n \"TIME_LOCK_INCOMPLETE\"\n );\n _;\n }\n\n /// @dev Contract constructor sets initial owners, required number of confirmations, and time lock.\n /// @param _owners List of initial owners.\n /// @param _required Number of required confirmations.\n /// @param _secondsTimeLocked Duration needed after a transaction is confirmed and before it becomes executable, in seconds.\n constructor (\n address[] _owners,\n uint256 _required,\n uint256 _secondsTimeLocked\n )\n public\n MultiSigWallet(_owners, _required)\n {\n secondsTimeLocked = _secondsTimeLocked;\n }\n\n /// @dev Changes the duration of the time lock for transactions.\n /// @param _secondsTimeLocked Duration needed after a transaction is confirmed and before it becomes executable, in seconds.\n function changeTimeLock(uint256 _secondsTimeLocked)\n public\n onlyWallet\n {\n secondsTimeLocked = _secondsTimeLocked;\n emit TimeLockChange(_secondsTimeLocked);\n }\n\n /// @dev Allows an owner to confirm a transaction.\n /// @param transactionId Transaction ID.\n function confirmTransaction(uint256 transactionId)\n public\n ownerExists(msg.sender)\n transactionExists(transactionId)\n notConfirmed(transactionId, msg.sender)\n notFullyConfirmed(transactionId)\n {\n confirmations[transactionId][msg.sender] = true;\n emit Confirmation(msg.sender, transactionId);\n if (isConfirmed(transactionId)) {\n setConfirmationTime(transactionId, block.timestamp);\n }\n }\n\n /// @dev Allows anyone to execute a confirmed transaction.\n /// @param transactionId Transaction ID.\n function executeTransaction(uint256 transactionId)\n public\n notExecuted(transactionId)\n fullyConfirmed(transactionId)\n pastTimeLock(transactionId)\n {\n Transaction storage txn = transactions[transactionId];\n txn.executed = true;\n if (external_call(txn.destination, txn.value, txn.data.length, txn.data)) {\n emit Execution(transactionId);\n } else {\n emit ExecutionFailure(transactionId);\n txn.executed = false;\n }\n }\n\n /// @dev Sets the time of when a submission first passed.\n function setConfirmationTime(uint256 transactionId, uint256 confirmationTime)\n internal\n {\n confirmationTimes[transactionId] = confirmationTime;\n emit ConfirmationTimeSet(transactionId, confirmationTime);\n }\n}\n", + "multisig/MultiSigWallet.sol": + "// solhint-disable\npragma solidity ^0.4.15;\n\n\n/// @title Multisignature wallet - Allows multiple parties to agree on transactions before execution.\n/// @author Stefan George - \ncontract MultiSigWallet {\n\n /*\n * Events\n */\n event Confirmation(address indexed sender, uint indexed transactionId);\n event Revocation(address indexed sender, uint indexed transactionId);\n event Submission(uint indexed transactionId);\n event Execution(uint indexed transactionId);\n event ExecutionFailure(uint indexed transactionId);\n event Deposit(address indexed sender, uint value);\n event OwnerAddition(address indexed owner);\n event OwnerRemoval(address indexed owner);\n event RequirementChange(uint required);\n\n /*\n * Constants\n */\n uint constant public MAX_OWNER_COUNT = 50;\n\n /*\n * Storage\n */\n mapping (uint => Transaction) public transactions;\n mapping (uint => mapping (address => bool)) public confirmations;\n mapping (address => bool) public isOwner;\n address[] public owners;\n uint public required;\n uint public transactionCount;\n\n struct Transaction {\n address destination;\n uint value;\n bytes data;\n bool executed;\n }\n\n /*\n * Modifiers\n */\n modifier onlyWallet() {\n require(msg.sender == address(this));\n _;\n }\n\n modifier ownerDoesNotExist(address owner) {\n require(!isOwner[owner]);\n _;\n }\n\n modifier ownerExists(address owner) {\n require(isOwner[owner]);\n _;\n }\n\n modifier transactionExists(uint transactionId) {\n require(transactions[transactionId].destination != 0);\n _;\n }\n\n modifier confirmed(uint transactionId, address owner) {\n require(confirmations[transactionId][owner]);\n _;\n }\n\n modifier notConfirmed(uint transactionId, address owner) {\n require(!confirmations[transactionId][owner]);\n _;\n }\n\n modifier notExecuted(uint transactionId) {\n require(!transactions[transactionId].executed);\n _;\n }\n\n modifier notNull(address _address) {\n require(_address != 0);\n _;\n }\n\n modifier validRequirement(uint ownerCount, uint _required) {\n require(ownerCount <= MAX_OWNER_COUNT\n && _required <= ownerCount\n && _required != 0\n && ownerCount != 0);\n _;\n }\n\n /// @dev Fallback function allows to deposit ether.\n function()\n payable\n {\n if (msg.value > 0)\n Deposit(msg.sender, msg.value);\n }\n\n /*\n * Public functions\n */\n /// @dev Contract constructor sets initial owners and required number of confirmations.\n /// @param _owners List of initial owners.\n /// @param _required Number of required confirmations.\n function MultiSigWallet(address[] _owners, uint _required)\n public\n validRequirement(_owners.length, _required)\n {\n for (uint i=0; i<_owners.length; i++) {\n require(!isOwner[_owners[i]] && _owners[i] != 0);\n isOwner[_owners[i]] = true;\n }\n owners = _owners;\n required = _required;\n }\n\n /// @dev Allows to add a new owner. Transaction has to be sent by wallet.\n /// @param owner Address of new owner.\n function addOwner(address owner)\n public\n onlyWallet\n ownerDoesNotExist(owner)\n notNull(owner)\n validRequirement(owners.length + 1, required)\n {\n isOwner[owner] = true;\n owners.push(owner);\n OwnerAddition(owner);\n }\n\n /// @dev Allows to remove an owner. Transaction has to be sent by wallet.\n /// @param owner Address of owner.\n function removeOwner(address owner)\n public\n onlyWallet\n ownerExists(owner)\n {\n isOwner[owner] = false;\n for (uint i=0; i owners.length)\n changeRequirement(owners.length);\n OwnerRemoval(owner);\n }\n\n /// @dev Allows to replace an owner with a new owner. Transaction has to be sent by wallet.\n /// @param owner Address of owner to be replaced.\n /// @param newOwner Address of new owner.\n function replaceOwner(address owner, address newOwner)\n public\n onlyWallet\n ownerExists(owner)\n ownerDoesNotExist(newOwner)\n {\n for (uint i=0; i = {}, + defaultBlock?: BlockParam, + ): Promise { + const self = (this as any) as MultiSigWalletContract; + const functionSignature = 'owners(uint256)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [index_0] = BaseContract._formatABIDataItemList( + inputAbi, + [index_0], + BaseContract._bigNumberToString.bind(self), + ); + BaseContract.strictArgumentEncodingCheck(inputAbi, [index_0]); + const ethersFunction = self._lookupEthersInterface(functionSignature).functions.owners; + const encodedData = ethersFunction.encode([index_0]); + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + let resultArray = ethersFunction.decode(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'owners' }) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._lowercaseAddress.bind(this), + ); + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._bnToBigNumber.bind(this), + ); + return resultArray[0]; + }, + }; + public removeOwner = { + async sendTransactionAsync(owner: string, txData: Partial = {}): Promise { + const self = (this as any) as MultiSigWalletContract; + const inputAbi = self._lookupAbi('removeOwner(address)').inputs; + [owner] = BaseContract._formatABIDataItemList( + inputAbi, + [owner], + BaseContract._bigNumberToString.bind(self), + ); + BaseContract.strictArgumentEncodingCheck(inputAbi, [owner]); + const encodedData = self + ._lookupEthersInterface('removeOwner(address)') + .functions.removeOwner.encode([owner]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.removeOwner.estimateGasAsync.bind(self, owner), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync(owner: string, txData: Partial = {}): Promise { + const self = (this as any) as MultiSigWalletContract; + const inputAbi = self._lookupAbi('removeOwner(address)').inputs; + [owner] = BaseContract._formatABIDataItemList(inputAbi, [owner], BaseContract._bigNumberToString); + const encodedData = self + ._lookupEthersInterface('removeOwner(address)') + .functions.removeOwner.encode([owner]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData(owner: string): string { + const self = (this as any) as MultiSigWalletContract; + const inputAbi = self._lookupAbi('removeOwner(address)').inputs; + [owner] = BaseContract._formatABIDataItemList(inputAbi, [owner], BaseContract._bigNumberToString); + const abiEncodedTransactionData = self + ._lookupEthersInterface('removeOwner(address)') + .functions.removeOwner.encode([owner]); + return abiEncodedTransactionData; + }, + async callAsync(owner: string, callData: Partial = {}, defaultBlock?: BlockParam): Promise { + const self = (this as any) as MultiSigWalletContract; + const functionSignature = 'removeOwner(address)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [owner] = BaseContract._formatABIDataItemList( + inputAbi, + [owner], + BaseContract._bigNumberToString.bind(self), + ); + BaseContract.strictArgumentEncodingCheck(inputAbi, [owner]); + const ethersFunction = self._lookupEthersInterface(functionSignature).functions.removeOwner; + const encodedData = ethersFunction.encode([owner]); + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + let resultArray = ethersFunction.decode(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'removeOwner' }) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._lowercaseAddress.bind(this), + ); + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._bnToBigNumber.bind(this), + ); + return resultArray; + }, + }; + public revokeConfirmation = { + async sendTransactionAsync(transactionId: BigNumber, txData: Partial = {}): Promise { + const self = (this as any) as MultiSigWalletContract; + const inputAbi = self._lookupAbi('revokeConfirmation(uint256)').inputs; + [transactionId] = BaseContract._formatABIDataItemList( + inputAbi, + [transactionId], + BaseContract._bigNumberToString.bind(self), + ); + BaseContract.strictArgumentEncodingCheck(inputAbi, [transactionId]); + const encodedData = self + ._lookupEthersInterface('revokeConfirmation(uint256)') + .functions.revokeConfirmation.encode([transactionId]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.revokeConfirmation.estimateGasAsync.bind(self, transactionId), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync(transactionId: BigNumber, txData: Partial = {}): Promise { + const self = (this as any) as MultiSigWalletContract; + const inputAbi = self._lookupAbi('revokeConfirmation(uint256)').inputs; + [transactionId] = BaseContract._formatABIDataItemList( + inputAbi, + [transactionId], + BaseContract._bigNumberToString, + ); + const encodedData = self + ._lookupEthersInterface('revokeConfirmation(uint256)') + .functions.revokeConfirmation.encode([transactionId]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData(transactionId: BigNumber): string { + const self = (this as any) as MultiSigWalletContract; + const inputAbi = self._lookupAbi('revokeConfirmation(uint256)').inputs; + [transactionId] = BaseContract._formatABIDataItemList( + inputAbi, + [transactionId], + BaseContract._bigNumberToString, + ); + const abiEncodedTransactionData = self + ._lookupEthersInterface('revokeConfirmation(uint256)') + .functions.revokeConfirmation.encode([transactionId]); + return abiEncodedTransactionData; + }, + async callAsync( + transactionId: BigNumber, + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise { + const self = (this as any) as MultiSigWalletContract; + const functionSignature = 'revokeConfirmation(uint256)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [transactionId] = BaseContract._formatABIDataItemList( + inputAbi, + [transactionId], + BaseContract._bigNumberToString.bind(self), + ); + BaseContract.strictArgumentEncodingCheck(inputAbi, [transactionId]); + const ethersFunction = self._lookupEthersInterface(functionSignature).functions.revokeConfirmation; + const encodedData = ethersFunction.encode([transactionId]); + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + let resultArray = ethersFunction.decode(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'revokeConfirmation' }) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._lowercaseAddress.bind(this), + ); + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._bnToBigNumber.bind(this), + ); + return resultArray; + }, + }; + public isOwner = { + async callAsync( + index_0: string, + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise { + const self = (this as any) as MultiSigWalletContract; + const functionSignature = 'isOwner(address)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [index_0] = BaseContract._formatABIDataItemList( + inputAbi, + [index_0], + BaseContract._bigNumberToString.bind(self), + ); + BaseContract.strictArgumentEncodingCheck(inputAbi, [index_0]); + const ethersFunction = self._lookupEthersInterface(functionSignature).functions.isOwner; + const encodedData = ethersFunction.encode([index_0]); + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + let resultArray = ethersFunction.decode(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'isOwner' }) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._lowercaseAddress.bind(this), + ); + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._bnToBigNumber.bind(this), + ); + return resultArray[0]; + }, + }; + public confirmations = { + async callAsync( + index_0: BigNumber, + index_1: string, + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise { + const self = (this as any) as MultiSigWalletContract; + const functionSignature = 'confirmations(uint256,address)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [index_0, index_1] = BaseContract._formatABIDataItemList( + inputAbi, + [index_0, index_1], + BaseContract._bigNumberToString.bind(self), + ); + BaseContract.strictArgumentEncodingCheck(inputAbi, [index_0, index_1]); + const ethersFunction = self._lookupEthersInterface(functionSignature).functions.confirmations; + const encodedData = ethersFunction.encode([index_0, index_1]); + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + let resultArray = ethersFunction.decode(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'confirmations' }) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._lowercaseAddress.bind(this), + ); + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._bnToBigNumber.bind(this), + ); + return resultArray[0]; + }, + }; + public getTransactionCount = { + async callAsync( + pending: boolean, + executed: boolean, + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise { + const self = (this as any) as MultiSigWalletContract; + const functionSignature = 'getTransactionCount(bool,bool)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [pending, executed] = BaseContract._formatABIDataItemList( + inputAbi, + [pending, executed], + BaseContract._bigNumberToString.bind(self), + ); + BaseContract.strictArgumentEncodingCheck(inputAbi, [pending, executed]); + const ethersFunction = self._lookupEthersInterface(functionSignature).functions.getTransactionCount; + const encodedData = ethersFunction.encode([pending, executed]); + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + let resultArray = ethersFunction.decode(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'getTransactionCount' }) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._lowercaseAddress.bind(this), + ); + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._bnToBigNumber.bind(this), + ); + return resultArray[0]; + }, + }; + public addOwner = { + async sendTransactionAsync(owner: string, txData: Partial = {}): Promise { + const self = (this as any) as MultiSigWalletContract; + const inputAbi = self._lookupAbi('addOwner(address)').inputs; + [owner] = BaseContract._formatABIDataItemList( + inputAbi, + [owner], + BaseContract._bigNumberToString.bind(self), + ); + BaseContract.strictArgumentEncodingCheck(inputAbi, [owner]); + const encodedData = self._lookupEthersInterface('addOwner(address)').functions.addOwner.encode([owner]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.addOwner.estimateGasAsync.bind(self, owner), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync(owner: string, txData: Partial = {}): Promise { + const self = (this as any) as MultiSigWalletContract; + const inputAbi = self._lookupAbi('addOwner(address)').inputs; + [owner] = BaseContract._formatABIDataItemList(inputAbi, [owner], BaseContract._bigNumberToString); + const encodedData = self._lookupEthersInterface('addOwner(address)').functions.addOwner.encode([owner]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData(owner: string): string { + const self = (this as any) as MultiSigWalletContract; + const inputAbi = self._lookupAbi('addOwner(address)').inputs; + [owner] = BaseContract._formatABIDataItemList(inputAbi, [owner], BaseContract._bigNumberToString); + const abiEncodedTransactionData = self + ._lookupEthersInterface('addOwner(address)') + .functions.addOwner.encode([owner]); + return abiEncodedTransactionData; + }, + async callAsync(owner: string, callData: Partial = {}, defaultBlock?: BlockParam): Promise { + const self = (this as any) as MultiSigWalletContract; + const functionSignature = 'addOwner(address)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [owner] = BaseContract._formatABIDataItemList( + inputAbi, + [owner], + BaseContract._bigNumberToString.bind(self), + ); + BaseContract.strictArgumentEncodingCheck(inputAbi, [owner]); + const ethersFunction = self._lookupEthersInterface(functionSignature).functions.addOwner; + const encodedData = ethersFunction.encode([owner]); + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + let resultArray = ethersFunction.decode(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'addOwner' }) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._lowercaseAddress.bind(this), + ); + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._bnToBigNumber.bind(this), + ); + return resultArray; + }, + }; + public isConfirmed = { + async callAsync( + transactionId: BigNumber, + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise { + const self = (this as any) as MultiSigWalletContract; + const functionSignature = 'isConfirmed(uint256)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [transactionId] = BaseContract._formatABIDataItemList( + inputAbi, + [transactionId], + BaseContract._bigNumberToString.bind(self), + ); + BaseContract.strictArgumentEncodingCheck(inputAbi, [transactionId]); + const ethersFunction = self._lookupEthersInterface(functionSignature).functions.isConfirmed; + const encodedData = ethersFunction.encode([transactionId]); + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + let resultArray = ethersFunction.decode(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'isConfirmed' }) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._lowercaseAddress.bind(this), + ); + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._bnToBigNumber.bind(this), + ); + return resultArray[0]; + }, + }; + public getConfirmationCount = { + async callAsync( + transactionId: BigNumber, + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise { + const self = (this as any) as MultiSigWalletContract; + const functionSignature = 'getConfirmationCount(uint256)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [transactionId] = BaseContract._formatABIDataItemList( + inputAbi, + [transactionId], + BaseContract._bigNumberToString.bind(self), + ); + BaseContract.strictArgumentEncodingCheck(inputAbi, [transactionId]); + const ethersFunction = self._lookupEthersInterface(functionSignature).functions.getConfirmationCount; + const encodedData = ethersFunction.encode([transactionId]); + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + let resultArray = ethersFunction.decode(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'getConfirmationCount' }) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._lowercaseAddress.bind(this), + ); + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._bnToBigNumber.bind(this), + ); + return resultArray[0]; + }, + }; + public transactions = { + async callAsync( + index_0: BigNumber, + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise<[string, BigNumber, string, boolean]> { + const self = (this as any) as MultiSigWalletContract; + const functionSignature = 'transactions(uint256)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [index_0] = BaseContract._formatABIDataItemList( + inputAbi, + [index_0], + BaseContract._bigNumberToString.bind(self), + ); + BaseContract.strictArgumentEncodingCheck(inputAbi, [index_0]); + const ethersFunction = self._lookupEthersInterface(functionSignature).functions.transactions; + const encodedData = ethersFunction.encode([index_0]); + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + let resultArray = ethersFunction.decode(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'transactions' }) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._lowercaseAddress.bind(this), + ); + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._bnToBigNumber.bind(this), + ); + return resultArray; + }, + }; + public getOwners = { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + const self = (this as any) as MultiSigWalletContract; + const functionSignature = 'getOwners()'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); + BaseContract.strictArgumentEncodingCheck(inputAbi, []); + const ethersFunction = self._lookupEthersInterface(functionSignature).functions.getOwners; + const encodedData = ethersFunction.encode([]); + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + let resultArray = ethersFunction.decode(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'getOwners' }) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._lowercaseAddress.bind(this), + ); + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._bnToBigNumber.bind(this), + ); + return resultArray[0]; + }, + }; + public getTransactionIds = { + async callAsync( + from: BigNumber, + to: BigNumber, + pending: boolean, + executed: boolean, + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise { + const self = (this as any) as MultiSigWalletContract; + const functionSignature = 'getTransactionIds(uint256,uint256,bool,bool)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [from, to, pending, executed] = BaseContract._formatABIDataItemList( + inputAbi, + [from, to, pending, executed], + BaseContract._bigNumberToString.bind(self), + ); + BaseContract.strictArgumentEncodingCheck(inputAbi, [from, to, pending, executed]); + const ethersFunction = self._lookupEthersInterface(functionSignature).functions.getTransactionIds; + const encodedData = ethersFunction.encode([from, to, pending, executed]); + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + let resultArray = ethersFunction.decode(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'getTransactionIds' }) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._lowercaseAddress.bind(this), + ); + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._bnToBigNumber.bind(this), + ); + return resultArray[0]; + }, + }; + public getConfirmations = { + async callAsync( + transactionId: BigNumber, + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise { + const self = (this as any) as MultiSigWalletContract; + const functionSignature = 'getConfirmations(uint256)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [transactionId] = BaseContract._formatABIDataItemList( + inputAbi, + [transactionId], + BaseContract._bigNumberToString.bind(self), + ); + BaseContract.strictArgumentEncodingCheck(inputAbi, [transactionId]); + const ethersFunction = self._lookupEthersInterface(functionSignature).functions.getConfirmations; + const encodedData = ethersFunction.encode([transactionId]); + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + let resultArray = ethersFunction.decode(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'getConfirmations' }) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._lowercaseAddress.bind(this), + ); + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._bnToBigNumber.bind(this), + ); + return resultArray[0]; + }, + }; + public transactionCount = { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + const self = (this as any) as MultiSigWalletContract; + const functionSignature = 'transactionCount()'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); + BaseContract.strictArgumentEncodingCheck(inputAbi, []); + const ethersFunction = self._lookupEthersInterface(functionSignature).functions.transactionCount; + const encodedData = ethersFunction.encode([]); + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + let resultArray = ethersFunction.decode(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'transactionCount' }) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._lowercaseAddress.bind(this), + ); + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._bnToBigNumber.bind(this), + ); + return resultArray[0]; + }, + }; + public changeRequirement = { + async sendTransactionAsync(_required: BigNumber, txData: Partial = {}): Promise { + const self = (this as any) as MultiSigWalletContract; + const inputAbi = self._lookupAbi('changeRequirement(uint256)').inputs; + [_required] = BaseContract._formatABIDataItemList( + inputAbi, + [_required], + BaseContract._bigNumberToString.bind(self), + ); + BaseContract.strictArgumentEncodingCheck(inputAbi, [_required]); + const encodedData = self + ._lookupEthersInterface('changeRequirement(uint256)') + .functions.changeRequirement.encode([_required]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.changeRequirement.estimateGasAsync.bind(self, _required), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync(_required: BigNumber, txData: Partial = {}): Promise { + const self = (this as any) as MultiSigWalletContract; + const inputAbi = self._lookupAbi('changeRequirement(uint256)').inputs; + [_required] = BaseContract._formatABIDataItemList(inputAbi, [_required], BaseContract._bigNumberToString); + const encodedData = self + ._lookupEthersInterface('changeRequirement(uint256)') + .functions.changeRequirement.encode([_required]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData(_required: BigNumber): string { + const self = (this as any) as MultiSigWalletContract; + const inputAbi = self._lookupAbi('changeRequirement(uint256)').inputs; + [_required] = BaseContract._formatABIDataItemList(inputAbi, [_required], BaseContract._bigNumberToString); + const abiEncodedTransactionData = self + ._lookupEthersInterface('changeRequirement(uint256)') + .functions.changeRequirement.encode([_required]); + return abiEncodedTransactionData; + }, + async callAsync( + _required: BigNumber, + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise { + const self = (this as any) as MultiSigWalletContract; + const functionSignature = 'changeRequirement(uint256)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [_required] = BaseContract._formatABIDataItemList( + inputAbi, + [_required], + BaseContract._bigNumberToString.bind(self), + ); + BaseContract.strictArgumentEncodingCheck(inputAbi, [_required]); + const ethersFunction = self._lookupEthersInterface(functionSignature).functions.changeRequirement; + const encodedData = ethersFunction.encode([_required]); + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + let resultArray = ethersFunction.decode(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'changeRequirement' }) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._lowercaseAddress.bind(this), + ); + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._bnToBigNumber.bind(this), + ); + return resultArray; + }, + }; + public confirmTransaction = { + async sendTransactionAsync(transactionId: BigNumber, txData: Partial = {}): Promise { + const self = (this as any) as MultiSigWalletContract; + const inputAbi = self._lookupAbi('confirmTransaction(uint256)').inputs; + [transactionId] = BaseContract._formatABIDataItemList( + inputAbi, + [transactionId], + BaseContract._bigNumberToString.bind(self), + ); + BaseContract.strictArgumentEncodingCheck(inputAbi, [transactionId]); + const encodedData = self + ._lookupEthersInterface('confirmTransaction(uint256)') + .functions.confirmTransaction.encode([transactionId]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.confirmTransaction.estimateGasAsync.bind(self, transactionId), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync(transactionId: BigNumber, txData: Partial = {}): Promise { + const self = (this as any) as MultiSigWalletContract; + const inputAbi = self._lookupAbi('confirmTransaction(uint256)').inputs; + [transactionId] = BaseContract._formatABIDataItemList( + inputAbi, + [transactionId], + BaseContract._bigNumberToString, + ); + const encodedData = self + ._lookupEthersInterface('confirmTransaction(uint256)') + .functions.confirmTransaction.encode([transactionId]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData(transactionId: BigNumber): string { + const self = (this as any) as MultiSigWalletContract; + const inputAbi = self._lookupAbi('confirmTransaction(uint256)').inputs; + [transactionId] = BaseContract._formatABIDataItemList( + inputAbi, + [transactionId], + BaseContract._bigNumberToString, + ); + const abiEncodedTransactionData = self + ._lookupEthersInterface('confirmTransaction(uint256)') + .functions.confirmTransaction.encode([transactionId]); + return abiEncodedTransactionData; + }, + async callAsync( + transactionId: BigNumber, + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise { + const self = (this as any) as MultiSigWalletContract; + const functionSignature = 'confirmTransaction(uint256)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [transactionId] = BaseContract._formatABIDataItemList( + inputAbi, + [transactionId], + BaseContract._bigNumberToString.bind(self), + ); + BaseContract.strictArgumentEncodingCheck(inputAbi, [transactionId]); + const ethersFunction = self._lookupEthersInterface(functionSignature).functions.confirmTransaction; + const encodedData = ethersFunction.encode([transactionId]); + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + let resultArray = ethersFunction.decode(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'confirmTransaction' }) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._lowercaseAddress.bind(this), + ); + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._bnToBigNumber.bind(this), + ); + return resultArray; + }, + }; + public submitTransaction = { + async sendTransactionAsync( + destination: string, + value: BigNumber, + data: string, + txData: Partial = {}, + ): Promise { + const self = (this as any) as MultiSigWalletContract; + const inputAbi = self._lookupAbi('submitTransaction(address,uint256,bytes)').inputs; + [destination, value, data] = BaseContract._formatABIDataItemList( + inputAbi, + [destination, value, data], + BaseContract._bigNumberToString.bind(self), + ); + BaseContract.strictArgumentEncodingCheck(inputAbi, [destination, value, data]); + const encodedData = self + ._lookupEthersInterface('submitTransaction(address,uint256,bytes)') + .functions.submitTransaction.encode([destination, value, data]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.submitTransaction.estimateGasAsync.bind(self, destination, value, data), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + destination: string, + value: BigNumber, + data: string, + txData: Partial = {}, + ): Promise { + const self = (this as any) as MultiSigWalletContract; + const inputAbi = self._lookupAbi('submitTransaction(address,uint256,bytes)').inputs; + [destination, value, data] = BaseContract._formatABIDataItemList( + inputAbi, + [destination, value, data], + BaseContract._bigNumberToString, + ); + const encodedData = self + ._lookupEthersInterface('submitTransaction(address,uint256,bytes)') + .functions.submitTransaction.encode([destination, value, data]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData(destination: string, value: BigNumber, data: string): string { + const self = (this as any) as MultiSigWalletContract; + const inputAbi = self._lookupAbi('submitTransaction(address,uint256,bytes)').inputs; + [destination, value, data] = BaseContract._formatABIDataItemList( + inputAbi, + [destination, value, data], + BaseContract._bigNumberToString, + ); + const abiEncodedTransactionData = self + ._lookupEthersInterface('submitTransaction(address,uint256,bytes)') + .functions.submitTransaction.encode([destination, value, data]); + return abiEncodedTransactionData; + }, + async callAsync( + destination: string, + value: BigNumber, + data: string, + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise { + const self = (this as any) as MultiSigWalletContract; + const functionSignature = 'submitTransaction(address,uint256,bytes)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [destination, value, data] = BaseContract._formatABIDataItemList( + inputAbi, + [destination, value, data], + BaseContract._bigNumberToString.bind(self), + ); + BaseContract.strictArgumentEncodingCheck(inputAbi, [destination, value, data]); + const ethersFunction = self._lookupEthersInterface(functionSignature).functions.submitTransaction; + const encodedData = ethersFunction.encode([destination, value, data]); + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + let resultArray = ethersFunction.decode(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'submitTransaction' }) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._lowercaseAddress.bind(this), + ); + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._bnToBigNumber.bind(this), + ); + return resultArray[0]; + }, + }; + public MAX_OWNER_COUNT = { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + const self = (this as any) as MultiSigWalletContract; + const functionSignature = 'MAX_OWNER_COUNT()'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); + BaseContract.strictArgumentEncodingCheck(inputAbi, []); + const ethersFunction = self._lookupEthersInterface(functionSignature).functions.MAX_OWNER_COUNT; + const encodedData = ethersFunction.encode([]); + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + let resultArray = ethersFunction.decode(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'MAX_OWNER_COUNT' }) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._lowercaseAddress.bind(this), + ); + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._bnToBigNumber.bind(this), + ); + return resultArray[0]; + }, + }; + public required = { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + const self = (this as any) as MultiSigWalletContract; + const functionSignature = 'required()'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); + BaseContract.strictArgumentEncodingCheck(inputAbi, []); + const ethersFunction = self._lookupEthersInterface(functionSignature).functions.required; + const encodedData = ethersFunction.encode([]); + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + let resultArray = ethersFunction.decode(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'required' }) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._lowercaseAddress.bind(this), + ); + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._bnToBigNumber.bind(this), + ); + return resultArray[0]; + }, + }; + public replaceOwner = { + async sendTransactionAsync(owner: string, newOwner: string, txData: Partial = {}): Promise { + const self = (this as any) as MultiSigWalletContract; + const inputAbi = self._lookupAbi('replaceOwner(address,address)').inputs; + [owner, newOwner] = BaseContract._formatABIDataItemList( + inputAbi, + [owner, newOwner], + BaseContract._bigNumberToString.bind(self), + ); + BaseContract.strictArgumentEncodingCheck(inputAbi, [owner, newOwner]); + const encodedData = self + ._lookupEthersInterface('replaceOwner(address,address)') + .functions.replaceOwner.encode([owner, newOwner]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.replaceOwner.estimateGasAsync.bind(self, owner, newOwner), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync(owner: string, newOwner: string, txData: Partial = {}): Promise { + const self = (this as any) as MultiSigWalletContract; + const inputAbi = self._lookupAbi('replaceOwner(address,address)').inputs; + [owner, newOwner] = BaseContract._formatABIDataItemList( + inputAbi, + [owner, newOwner], + BaseContract._bigNumberToString, + ); + const encodedData = self + ._lookupEthersInterface('replaceOwner(address,address)') + .functions.replaceOwner.encode([owner, newOwner]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData(owner: string, newOwner: string): string { + const self = (this as any) as MultiSigWalletContract; + const inputAbi = self._lookupAbi('replaceOwner(address,address)').inputs; + [owner, newOwner] = BaseContract._formatABIDataItemList( + inputAbi, + [owner, newOwner], + BaseContract._bigNumberToString, + ); + const abiEncodedTransactionData = self + ._lookupEthersInterface('replaceOwner(address,address)') + .functions.replaceOwner.encode([owner, newOwner]); + return abiEncodedTransactionData; + }, + async callAsync( + owner: string, + newOwner: string, + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise { + const self = (this as any) as MultiSigWalletContract; + const functionSignature = 'replaceOwner(address,address)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [owner, newOwner] = BaseContract._formatABIDataItemList( + inputAbi, + [owner, newOwner], + BaseContract._bigNumberToString.bind(self), + ); + BaseContract.strictArgumentEncodingCheck(inputAbi, [owner, newOwner]); + const ethersFunction = self._lookupEthersInterface(functionSignature).functions.replaceOwner; + const encodedData = ethersFunction.encode([owner, newOwner]); + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + let resultArray = ethersFunction.decode(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'replaceOwner' }) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._lowercaseAddress.bind(this), + ); + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._bnToBigNumber.bind(this), + ); + return resultArray; + }, + }; + public executeTransaction = { + async sendTransactionAsync(transactionId: BigNumber, txData: Partial = {}): Promise { + const self = (this as any) as MultiSigWalletContract; + const inputAbi = self._lookupAbi('executeTransaction(uint256)').inputs; + [transactionId] = BaseContract._formatABIDataItemList( + inputAbi, + [transactionId], + BaseContract._bigNumberToString.bind(self), + ); + BaseContract.strictArgumentEncodingCheck(inputAbi, [transactionId]); + const encodedData = self + ._lookupEthersInterface('executeTransaction(uint256)') + .functions.executeTransaction.encode([transactionId]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.executeTransaction.estimateGasAsync.bind(self, transactionId), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync(transactionId: BigNumber, txData: Partial = {}): Promise { + const self = (this as any) as MultiSigWalletContract; + const inputAbi = self._lookupAbi('executeTransaction(uint256)').inputs; + [transactionId] = BaseContract._formatABIDataItemList( + inputAbi, + [transactionId], + BaseContract._bigNumberToString, + ); + const encodedData = self + ._lookupEthersInterface('executeTransaction(uint256)') + .functions.executeTransaction.encode([transactionId]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData(transactionId: BigNumber): string { + const self = (this as any) as MultiSigWalletContract; + const inputAbi = self._lookupAbi('executeTransaction(uint256)').inputs; + [transactionId] = BaseContract._formatABIDataItemList( + inputAbi, + [transactionId], + BaseContract._bigNumberToString, + ); + const abiEncodedTransactionData = self + ._lookupEthersInterface('executeTransaction(uint256)') + .functions.executeTransaction.encode([transactionId]); + return abiEncodedTransactionData; + }, + async callAsync( + transactionId: BigNumber, + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise { + const self = (this as any) as MultiSigWalletContract; + const functionSignature = 'executeTransaction(uint256)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [transactionId] = BaseContract._formatABIDataItemList( + inputAbi, + [transactionId], + BaseContract._bigNumberToString.bind(self), + ); + BaseContract.strictArgumentEncodingCheck(inputAbi, [transactionId]); + const ethersFunction = self._lookupEthersInterface(functionSignature).functions.executeTransaction; + const encodedData = ethersFunction.encode([transactionId]); + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + let resultArray = ethersFunction.decode(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'executeTransaction' }) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._lowercaseAddress.bind(this), + ); + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._bnToBigNumber.bind(this), + ); + return resultArray; + }, + }; + public static async deployFrom0xArtifactAsync( + artifact: ContractArtifact | SimpleContractArtifact, + provider: Provider, + txDefaults: Partial, + _owners: string[], + _required: BigNumber, + ): Promise { + 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 MultiSigWalletContract.deployAsync(bytecode, abi, provider, txDefaults, _owners, _required); + } + public static async deployAsync( + bytecode: string, + abi: ContractAbi, + provider: Provider, + txDefaults: Partial, + _owners: string[], + _required: BigNumber, + ): Promise { + const constructorAbi = BaseContract._lookupConstructorAbi(abi); + [_owners, _required] = BaseContract._formatABIDataItemList( + constructorAbi.inputs, + [_owners, _required], + BaseContract._bigNumberToString, + ); + const iface = new ethers.utils.Interface(abi); + const deployInfo = iface.deployFunction; + const txData = deployInfo.encode(bytecode, [_owners, _required]); + 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(`MultiSigWallet successfully deployed at ${txReceipt.contractAddress}`); + const contractInstance = new MultiSigWalletContract( + abi, + txReceipt.contractAddress as string, + provider, + txDefaults, + ); + contractInstance.constructorArgs = [_owners, _required]; + return contractInstance; + } + constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial) { + super('MultiSigWallet', abi, address, provider, txDefaults); + classUtils.bindAll(this, ['_ethersInterfacesByFunctionSignature', 'address', 'abi', '_web3Wrapper']); + } +} // tslint:disable:max-file-line-count +// tslint:enable:no-unbound-method diff --git a/contracts/multisig/generated-wrappers/multi_sig_wallet_with_time_lock.ts b/contracts/multisig/generated-wrappers/multi_sig_wallet_with_time_lock.ts new file mode 100644 index 000000000..1108655dd --- /dev/null +++ b/contracts/multisig/generated-wrappers/multi_sig_wallet_with_time_lock.ts @@ -0,0 +1,1649 @@ +// 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 + +export type MultiSigWalletWithTimeLockEventArgs = + | MultiSigWalletWithTimeLockConfirmationTimeSetEventArgs + | MultiSigWalletWithTimeLockTimeLockChangeEventArgs + | MultiSigWalletWithTimeLockConfirmationEventArgs + | MultiSigWalletWithTimeLockRevocationEventArgs + | MultiSigWalletWithTimeLockSubmissionEventArgs + | MultiSigWalletWithTimeLockExecutionEventArgs + | MultiSigWalletWithTimeLockExecutionFailureEventArgs + | MultiSigWalletWithTimeLockDepositEventArgs + | MultiSigWalletWithTimeLockOwnerAdditionEventArgs + | MultiSigWalletWithTimeLockOwnerRemovalEventArgs + | MultiSigWalletWithTimeLockRequirementChangeEventArgs; + +export enum MultiSigWalletWithTimeLockEvents { + ConfirmationTimeSet = 'ConfirmationTimeSet', + TimeLockChange = 'TimeLockChange', + Confirmation = 'Confirmation', + Revocation = 'Revocation', + Submission = 'Submission', + Execution = 'Execution', + ExecutionFailure = 'ExecutionFailure', + Deposit = 'Deposit', + OwnerAddition = 'OwnerAddition', + OwnerRemoval = 'OwnerRemoval', + RequirementChange = 'RequirementChange', +} + +export interface MultiSigWalletWithTimeLockConfirmationTimeSetEventArgs extends DecodedLogArgs { + transactionId: BigNumber; + confirmationTime: BigNumber; +} + +export interface MultiSigWalletWithTimeLockTimeLockChangeEventArgs extends DecodedLogArgs { + secondsTimeLocked: BigNumber; +} + +export interface MultiSigWalletWithTimeLockConfirmationEventArgs extends DecodedLogArgs { + sender: string; + transactionId: BigNumber; +} + +export interface MultiSigWalletWithTimeLockRevocationEventArgs extends DecodedLogArgs { + sender: string; + transactionId: BigNumber; +} + +export interface MultiSigWalletWithTimeLockSubmissionEventArgs extends DecodedLogArgs { + transactionId: BigNumber; +} + +export interface MultiSigWalletWithTimeLockExecutionEventArgs extends DecodedLogArgs { + transactionId: BigNumber; +} + +export interface MultiSigWalletWithTimeLockExecutionFailureEventArgs extends DecodedLogArgs { + transactionId: BigNumber; +} + +export interface MultiSigWalletWithTimeLockDepositEventArgs extends DecodedLogArgs { + sender: string; + value: BigNumber; +} + +export interface MultiSigWalletWithTimeLockOwnerAdditionEventArgs extends DecodedLogArgs { + owner: string; +} + +export interface MultiSigWalletWithTimeLockOwnerRemovalEventArgs extends DecodedLogArgs { + owner: string; +} + +export interface MultiSigWalletWithTimeLockRequirementChangeEventArgs extends DecodedLogArgs { + required: BigNumber; +} + +/* istanbul ignore next */ +// tslint:disable:no-parameter-reassignment +// tslint:disable-next-line:class-name +export class MultiSigWalletWithTimeLockContract extends BaseContract { + public owners = { + async callAsync( + index_0: BigNumber, + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise { + const self = (this as any) as MultiSigWalletWithTimeLockContract; + const functionSignature = 'owners(uint256)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [index_0] = BaseContract._formatABIDataItemList( + inputAbi, + [index_0], + BaseContract._bigNumberToString.bind(self), + ); + BaseContract.strictArgumentEncodingCheck(inputAbi, [index_0]); + const ethersFunction = self._lookupEthersInterface(functionSignature).functions.owners; + const encodedData = ethersFunction.encode([index_0]); + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + let resultArray = ethersFunction.decode(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'owners' }) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._lowercaseAddress.bind(this), + ); + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._bnToBigNumber.bind(this), + ); + return resultArray[0]; + }, + }; + public removeOwner = { + async sendTransactionAsync(owner: string, txData: Partial = {}): Promise { + const self = (this as any) as MultiSigWalletWithTimeLockContract; + const inputAbi = self._lookupAbi('removeOwner(address)').inputs; + [owner] = BaseContract._formatABIDataItemList( + inputAbi, + [owner], + BaseContract._bigNumberToString.bind(self), + ); + BaseContract.strictArgumentEncodingCheck(inputAbi, [owner]); + const encodedData = self + ._lookupEthersInterface('removeOwner(address)') + .functions.removeOwner.encode([owner]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.removeOwner.estimateGasAsync.bind(self, owner), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync(owner: string, txData: Partial = {}): Promise { + const self = (this as any) as MultiSigWalletWithTimeLockContract; + const inputAbi = self._lookupAbi('removeOwner(address)').inputs; + [owner] = BaseContract._formatABIDataItemList(inputAbi, [owner], BaseContract._bigNumberToString); + const encodedData = self + ._lookupEthersInterface('removeOwner(address)') + .functions.removeOwner.encode([owner]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData(owner: string): string { + const self = (this as any) as MultiSigWalletWithTimeLockContract; + const inputAbi = self._lookupAbi('removeOwner(address)').inputs; + [owner] = BaseContract._formatABIDataItemList(inputAbi, [owner], BaseContract._bigNumberToString); + const abiEncodedTransactionData = self + ._lookupEthersInterface('removeOwner(address)') + .functions.removeOwner.encode([owner]); + return abiEncodedTransactionData; + }, + async callAsync(owner: string, callData: Partial = {}, defaultBlock?: BlockParam): Promise { + const self = (this as any) as MultiSigWalletWithTimeLockContract; + const functionSignature = 'removeOwner(address)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [owner] = BaseContract._formatABIDataItemList( + inputAbi, + [owner], + BaseContract._bigNumberToString.bind(self), + ); + BaseContract.strictArgumentEncodingCheck(inputAbi, [owner]); + const ethersFunction = self._lookupEthersInterface(functionSignature).functions.removeOwner; + const encodedData = ethersFunction.encode([owner]); + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + let resultArray = ethersFunction.decode(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'removeOwner' }) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._lowercaseAddress.bind(this), + ); + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._bnToBigNumber.bind(this), + ); + return resultArray; + }, + }; + public revokeConfirmation = { + async sendTransactionAsync(transactionId: BigNumber, txData: Partial = {}): Promise { + const self = (this as any) as MultiSigWalletWithTimeLockContract; + const inputAbi = self._lookupAbi('revokeConfirmation(uint256)').inputs; + [transactionId] = BaseContract._formatABIDataItemList( + inputAbi, + [transactionId], + BaseContract._bigNumberToString.bind(self), + ); + BaseContract.strictArgumentEncodingCheck(inputAbi, [transactionId]); + const encodedData = self + ._lookupEthersInterface('revokeConfirmation(uint256)') + .functions.revokeConfirmation.encode([transactionId]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.revokeConfirmation.estimateGasAsync.bind(self, transactionId), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync(transactionId: BigNumber, txData: Partial = {}): Promise { + const self = (this as any) as MultiSigWalletWithTimeLockContract; + const inputAbi = self._lookupAbi('revokeConfirmation(uint256)').inputs; + [transactionId] = BaseContract._formatABIDataItemList( + inputAbi, + [transactionId], + BaseContract._bigNumberToString, + ); + const encodedData = self + ._lookupEthersInterface('revokeConfirmation(uint256)') + .functions.revokeConfirmation.encode([transactionId]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData(transactionId: BigNumber): string { + const self = (this as any) as MultiSigWalletWithTimeLockContract; + const inputAbi = self._lookupAbi('revokeConfirmation(uint256)').inputs; + [transactionId] = BaseContract._formatABIDataItemList( + inputAbi, + [transactionId], + BaseContract._bigNumberToString, + ); + const abiEncodedTransactionData = self + ._lookupEthersInterface('revokeConfirmation(uint256)') + .functions.revokeConfirmation.encode([transactionId]); + return abiEncodedTransactionData; + }, + async callAsync( + transactionId: BigNumber, + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise { + const self = (this as any) as MultiSigWalletWithTimeLockContract; + const functionSignature = 'revokeConfirmation(uint256)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [transactionId] = BaseContract._formatABIDataItemList( + inputAbi, + [transactionId], + BaseContract._bigNumberToString.bind(self), + ); + BaseContract.strictArgumentEncodingCheck(inputAbi, [transactionId]); + const ethersFunction = self._lookupEthersInterface(functionSignature).functions.revokeConfirmation; + const encodedData = ethersFunction.encode([transactionId]); + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + let resultArray = ethersFunction.decode(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'revokeConfirmation' }) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._lowercaseAddress.bind(this), + ); + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._bnToBigNumber.bind(this), + ); + return resultArray; + }, + }; + public isOwner = { + async callAsync( + index_0: string, + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise { + const self = (this as any) as MultiSigWalletWithTimeLockContract; + const functionSignature = 'isOwner(address)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [index_0] = BaseContract._formatABIDataItemList( + inputAbi, + [index_0], + BaseContract._bigNumberToString.bind(self), + ); + BaseContract.strictArgumentEncodingCheck(inputAbi, [index_0]); + const ethersFunction = self._lookupEthersInterface(functionSignature).functions.isOwner; + const encodedData = ethersFunction.encode([index_0]); + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + let resultArray = ethersFunction.decode(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'isOwner' }) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._lowercaseAddress.bind(this), + ); + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._bnToBigNumber.bind(this), + ); + return resultArray[0]; + }, + }; + public confirmations = { + async callAsync( + index_0: BigNumber, + index_1: string, + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise { + const self = (this as any) as MultiSigWalletWithTimeLockContract; + const functionSignature = 'confirmations(uint256,address)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [index_0, index_1] = BaseContract._formatABIDataItemList( + inputAbi, + [index_0, index_1], + BaseContract._bigNumberToString.bind(self), + ); + BaseContract.strictArgumentEncodingCheck(inputAbi, [index_0, index_1]); + const ethersFunction = self._lookupEthersInterface(functionSignature).functions.confirmations; + const encodedData = ethersFunction.encode([index_0, index_1]); + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + let resultArray = ethersFunction.decode(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'confirmations' }) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._lowercaseAddress.bind(this), + ); + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._bnToBigNumber.bind(this), + ); + return resultArray[0]; + }, + }; + public secondsTimeLocked = { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + const self = (this as any) as MultiSigWalletWithTimeLockContract; + const functionSignature = 'secondsTimeLocked()'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); + BaseContract.strictArgumentEncodingCheck(inputAbi, []); + const ethersFunction = self._lookupEthersInterface(functionSignature).functions.secondsTimeLocked; + const encodedData = ethersFunction.encode([]); + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + let resultArray = ethersFunction.decode(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'secondsTimeLocked' }) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._lowercaseAddress.bind(this), + ); + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._bnToBigNumber.bind(this), + ); + return resultArray[0]; + }, + }; + public getTransactionCount = { + async callAsync( + pending: boolean, + executed: boolean, + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise { + const self = (this as any) as MultiSigWalletWithTimeLockContract; + const functionSignature = 'getTransactionCount(bool,bool)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [pending, executed] = BaseContract._formatABIDataItemList( + inputAbi, + [pending, executed], + BaseContract._bigNumberToString.bind(self), + ); + BaseContract.strictArgumentEncodingCheck(inputAbi, [pending, executed]); + const ethersFunction = self._lookupEthersInterface(functionSignature).functions.getTransactionCount; + const encodedData = ethersFunction.encode([pending, executed]); + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + let resultArray = ethersFunction.decode(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'getTransactionCount' }) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._lowercaseAddress.bind(this), + ); + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._bnToBigNumber.bind(this), + ); + return resultArray[0]; + }, + }; + public addOwner = { + async sendTransactionAsync(owner: string, txData: Partial = {}): Promise { + const self = (this as any) as MultiSigWalletWithTimeLockContract; + const inputAbi = self._lookupAbi('addOwner(address)').inputs; + [owner] = BaseContract._formatABIDataItemList( + inputAbi, + [owner], + BaseContract._bigNumberToString.bind(self), + ); + BaseContract.strictArgumentEncodingCheck(inputAbi, [owner]); + const encodedData = self._lookupEthersInterface('addOwner(address)').functions.addOwner.encode([owner]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.addOwner.estimateGasAsync.bind(self, owner), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync(owner: string, txData: Partial = {}): Promise { + const self = (this as any) as MultiSigWalletWithTimeLockContract; + const inputAbi = self._lookupAbi('addOwner(address)').inputs; + [owner] = BaseContract._formatABIDataItemList(inputAbi, [owner], BaseContract._bigNumberToString); + const encodedData = self._lookupEthersInterface('addOwner(address)').functions.addOwner.encode([owner]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData(owner: string): string { + const self = (this as any) as MultiSigWalletWithTimeLockContract; + const inputAbi = self._lookupAbi('addOwner(address)').inputs; + [owner] = BaseContract._formatABIDataItemList(inputAbi, [owner], BaseContract._bigNumberToString); + const abiEncodedTransactionData = self + ._lookupEthersInterface('addOwner(address)') + .functions.addOwner.encode([owner]); + return abiEncodedTransactionData; + }, + async callAsync(owner: string, callData: Partial = {}, defaultBlock?: BlockParam): Promise { + const self = (this as any) as MultiSigWalletWithTimeLockContract; + const functionSignature = 'addOwner(address)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [owner] = BaseContract._formatABIDataItemList( + inputAbi, + [owner], + BaseContract._bigNumberToString.bind(self), + ); + BaseContract.strictArgumentEncodingCheck(inputAbi, [owner]); + const ethersFunction = self._lookupEthersInterface(functionSignature).functions.addOwner; + const encodedData = ethersFunction.encode([owner]); + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + let resultArray = ethersFunction.decode(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'addOwner' }) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._lowercaseAddress.bind(this), + ); + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._bnToBigNumber.bind(this), + ); + return resultArray; + }, + }; + public isConfirmed = { + async callAsync( + transactionId: BigNumber, + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise { + const self = (this as any) as MultiSigWalletWithTimeLockContract; + const functionSignature = 'isConfirmed(uint256)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [transactionId] = BaseContract._formatABIDataItemList( + inputAbi, + [transactionId], + BaseContract._bigNumberToString.bind(self), + ); + BaseContract.strictArgumentEncodingCheck(inputAbi, [transactionId]); + const ethersFunction = self._lookupEthersInterface(functionSignature).functions.isConfirmed; + const encodedData = ethersFunction.encode([transactionId]); + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + let resultArray = ethersFunction.decode(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'isConfirmed' }) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._lowercaseAddress.bind(this), + ); + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._bnToBigNumber.bind(this), + ); + return resultArray[0]; + }, + }; + public changeTimeLock = { + async sendTransactionAsync(_secondsTimeLocked: BigNumber, txData: Partial = {}): Promise { + const self = (this as any) as MultiSigWalletWithTimeLockContract; + const inputAbi = self._lookupAbi('changeTimeLock(uint256)').inputs; + [_secondsTimeLocked] = BaseContract._formatABIDataItemList( + inputAbi, + [_secondsTimeLocked], + BaseContract._bigNumberToString.bind(self), + ); + BaseContract.strictArgumentEncodingCheck(inputAbi, [_secondsTimeLocked]); + const encodedData = self + ._lookupEthersInterface('changeTimeLock(uint256)') + .functions.changeTimeLock.encode([_secondsTimeLocked]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.changeTimeLock.estimateGasAsync.bind(self, _secondsTimeLocked), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync(_secondsTimeLocked: BigNumber, txData: Partial = {}): Promise { + const self = (this as any) as MultiSigWalletWithTimeLockContract; + const inputAbi = self._lookupAbi('changeTimeLock(uint256)').inputs; + [_secondsTimeLocked] = BaseContract._formatABIDataItemList( + inputAbi, + [_secondsTimeLocked], + BaseContract._bigNumberToString, + ); + const encodedData = self + ._lookupEthersInterface('changeTimeLock(uint256)') + .functions.changeTimeLock.encode([_secondsTimeLocked]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData(_secondsTimeLocked: BigNumber): string { + const self = (this as any) as MultiSigWalletWithTimeLockContract; + const inputAbi = self._lookupAbi('changeTimeLock(uint256)').inputs; + [_secondsTimeLocked] = BaseContract._formatABIDataItemList( + inputAbi, + [_secondsTimeLocked], + BaseContract._bigNumberToString, + ); + const abiEncodedTransactionData = self + ._lookupEthersInterface('changeTimeLock(uint256)') + .functions.changeTimeLock.encode([_secondsTimeLocked]); + return abiEncodedTransactionData; + }, + async callAsync( + _secondsTimeLocked: BigNumber, + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise { + const self = (this as any) as MultiSigWalletWithTimeLockContract; + const functionSignature = 'changeTimeLock(uint256)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [_secondsTimeLocked] = BaseContract._formatABIDataItemList( + inputAbi, + [_secondsTimeLocked], + BaseContract._bigNumberToString.bind(self), + ); + BaseContract.strictArgumentEncodingCheck(inputAbi, [_secondsTimeLocked]); + const ethersFunction = self._lookupEthersInterface(functionSignature).functions.changeTimeLock; + const encodedData = ethersFunction.encode([_secondsTimeLocked]); + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + let resultArray = ethersFunction.decode(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'changeTimeLock' }) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._lowercaseAddress.bind(this), + ); + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._bnToBigNumber.bind(this), + ); + return resultArray; + }, + }; + public getConfirmationCount = { + async callAsync( + transactionId: BigNumber, + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise { + const self = (this as any) as MultiSigWalletWithTimeLockContract; + const functionSignature = 'getConfirmationCount(uint256)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [transactionId] = BaseContract._formatABIDataItemList( + inputAbi, + [transactionId], + BaseContract._bigNumberToString.bind(self), + ); + BaseContract.strictArgumentEncodingCheck(inputAbi, [transactionId]); + const ethersFunction = self._lookupEthersInterface(functionSignature).functions.getConfirmationCount; + const encodedData = ethersFunction.encode([transactionId]); + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + let resultArray = ethersFunction.decode(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'getConfirmationCount' }) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._lowercaseAddress.bind(this), + ); + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._bnToBigNumber.bind(this), + ); + return resultArray[0]; + }, + }; + public transactions = { + async callAsync( + index_0: BigNumber, + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise<[string, BigNumber, string, boolean]> { + const self = (this as any) as MultiSigWalletWithTimeLockContract; + const functionSignature = 'transactions(uint256)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [index_0] = BaseContract._formatABIDataItemList( + inputAbi, + [index_0], + BaseContract._bigNumberToString.bind(self), + ); + BaseContract.strictArgumentEncodingCheck(inputAbi, [index_0]); + const ethersFunction = self._lookupEthersInterface(functionSignature).functions.transactions; + const encodedData = ethersFunction.encode([index_0]); + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + let resultArray = ethersFunction.decode(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'transactions' }) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._lowercaseAddress.bind(this), + ); + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._bnToBigNumber.bind(this), + ); + return resultArray; + }, + }; + public getOwners = { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + const self = (this as any) as MultiSigWalletWithTimeLockContract; + const functionSignature = 'getOwners()'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); + BaseContract.strictArgumentEncodingCheck(inputAbi, []); + const ethersFunction = self._lookupEthersInterface(functionSignature).functions.getOwners; + const encodedData = ethersFunction.encode([]); + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + let resultArray = ethersFunction.decode(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'getOwners' }) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._lowercaseAddress.bind(this), + ); + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._bnToBigNumber.bind(this), + ); + return resultArray[0]; + }, + }; + public getTransactionIds = { + async callAsync( + from: BigNumber, + to: BigNumber, + pending: boolean, + executed: boolean, + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise { + const self = (this as any) as MultiSigWalletWithTimeLockContract; + const functionSignature = 'getTransactionIds(uint256,uint256,bool,bool)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [from, to, pending, executed] = BaseContract._formatABIDataItemList( + inputAbi, + [from, to, pending, executed], + BaseContract._bigNumberToString.bind(self), + ); + BaseContract.strictArgumentEncodingCheck(inputAbi, [from, to, pending, executed]); + const ethersFunction = self._lookupEthersInterface(functionSignature).functions.getTransactionIds; + const encodedData = ethersFunction.encode([from, to, pending, executed]); + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + let resultArray = ethersFunction.decode(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'getTransactionIds' }) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._lowercaseAddress.bind(this), + ); + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._bnToBigNumber.bind(this), + ); + return resultArray[0]; + }, + }; + public getConfirmations = { + async callAsync( + transactionId: BigNumber, + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise { + const self = (this as any) as MultiSigWalletWithTimeLockContract; + const functionSignature = 'getConfirmations(uint256)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [transactionId] = BaseContract._formatABIDataItemList( + inputAbi, + [transactionId], + BaseContract._bigNumberToString.bind(self), + ); + BaseContract.strictArgumentEncodingCheck(inputAbi, [transactionId]); + const ethersFunction = self._lookupEthersInterface(functionSignature).functions.getConfirmations; + const encodedData = ethersFunction.encode([transactionId]); + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + let resultArray = ethersFunction.decode(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'getConfirmations' }) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._lowercaseAddress.bind(this), + ); + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._bnToBigNumber.bind(this), + ); + return resultArray[0]; + }, + }; + public transactionCount = { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + const self = (this as any) as MultiSigWalletWithTimeLockContract; + const functionSignature = 'transactionCount()'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); + BaseContract.strictArgumentEncodingCheck(inputAbi, []); + const ethersFunction = self._lookupEthersInterface(functionSignature).functions.transactionCount; + const encodedData = ethersFunction.encode([]); + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + let resultArray = ethersFunction.decode(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'transactionCount' }) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._lowercaseAddress.bind(this), + ); + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._bnToBigNumber.bind(this), + ); + return resultArray[0]; + }, + }; + public changeRequirement = { + async sendTransactionAsync(_required: BigNumber, txData: Partial = {}): Promise { + const self = (this as any) as MultiSigWalletWithTimeLockContract; + const inputAbi = self._lookupAbi('changeRequirement(uint256)').inputs; + [_required] = BaseContract._formatABIDataItemList( + inputAbi, + [_required], + BaseContract._bigNumberToString.bind(self), + ); + BaseContract.strictArgumentEncodingCheck(inputAbi, [_required]); + const encodedData = self + ._lookupEthersInterface('changeRequirement(uint256)') + .functions.changeRequirement.encode([_required]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.changeRequirement.estimateGasAsync.bind(self, _required), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync(_required: BigNumber, txData: Partial = {}): Promise { + const self = (this as any) as MultiSigWalletWithTimeLockContract; + const inputAbi = self._lookupAbi('changeRequirement(uint256)').inputs; + [_required] = BaseContract._formatABIDataItemList(inputAbi, [_required], BaseContract._bigNumberToString); + const encodedData = self + ._lookupEthersInterface('changeRequirement(uint256)') + .functions.changeRequirement.encode([_required]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData(_required: BigNumber): string { + const self = (this as any) as MultiSigWalletWithTimeLockContract; + const inputAbi = self._lookupAbi('changeRequirement(uint256)').inputs; + [_required] = BaseContract._formatABIDataItemList(inputAbi, [_required], BaseContract._bigNumberToString); + const abiEncodedTransactionData = self + ._lookupEthersInterface('changeRequirement(uint256)') + .functions.changeRequirement.encode([_required]); + return abiEncodedTransactionData; + }, + async callAsync( + _required: BigNumber, + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise { + const self = (this as any) as MultiSigWalletWithTimeLockContract; + const functionSignature = 'changeRequirement(uint256)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [_required] = BaseContract._formatABIDataItemList( + inputAbi, + [_required], + BaseContract._bigNumberToString.bind(self), + ); + BaseContract.strictArgumentEncodingCheck(inputAbi, [_required]); + const ethersFunction = self._lookupEthersInterface(functionSignature).functions.changeRequirement; + const encodedData = ethersFunction.encode([_required]); + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + let resultArray = ethersFunction.decode(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'changeRequirement' }) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._lowercaseAddress.bind(this), + ); + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._bnToBigNumber.bind(this), + ); + return resultArray; + }, + }; + public confirmTransaction = { + async sendTransactionAsync(transactionId: BigNumber, txData: Partial = {}): Promise { + const self = (this as any) as MultiSigWalletWithTimeLockContract; + const inputAbi = self._lookupAbi('confirmTransaction(uint256)').inputs; + [transactionId] = BaseContract._formatABIDataItemList( + inputAbi, + [transactionId], + BaseContract._bigNumberToString.bind(self), + ); + BaseContract.strictArgumentEncodingCheck(inputAbi, [transactionId]); + const encodedData = self + ._lookupEthersInterface('confirmTransaction(uint256)') + .functions.confirmTransaction.encode([transactionId]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.confirmTransaction.estimateGasAsync.bind(self, transactionId), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync(transactionId: BigNumber, txData: Partial = {}): Promise { + const self = (this as any) as MultiSigWalletWithTimeLockContract; + const inputAbi = self._lookupAbi('confirmTransaction(uint256)').inputs; + [transactionId] = BaseContract._formatABIDataItemList( + inputAbi, + [transactionId], + BaseContract._bigNumberToString, + ); + const encodedData = self + ._lookupEthersInterface('confirmTransaction(uint256)') + .functions.confirmTransaction.encode([transactionId]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData(transactionId: BigNumber): string { + const self = (this as any) as MultiSigWalletWithTimeLockContract; + const inputAbi = self._lookupAbi('confirmTransaction(uint256)').inputs; + [transactionId] = BaseContract._formatABIDataItemList( + inputAbi, + [transactionId], + BaseContract._bigNumberToString, + ); + const abiEncodedTransactionData = self + ._lookupEthersInterface('confirmTransaction(uint256)') + .functions.confirmTransaction.encode([transactionId]); + return abiEncodedTransactionData; + }, + async callAsync( + transactionId: BigNumber, + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise { + const self = (this as any) as MultiSigWalletWithTimeLockContract; + const functionSignature = 'confirmTransaction(uint256)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [transactionId] = BaseContract._formatABIDataItemList( + inputAbi, + [transactionId], + BaseContract._bigNumberToString.bind(self), + ); + BaseContract.strictArgumentEncodingCheck(inputAbi, [transactionId]); + const ethersFunction = self._lookupEthersInterface(functionSignature).functions.confirmTransaction; + const encodedData = ethersFunction.encode([transactionId]); + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + let resultArray = ethersFunction.decode(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'confirmTransaction' }) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._lowercaseAddress.bind(this), + ); + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._bnToBigNumber.bind(this), + ); + return resultArray; + }, + }; + public submitTransaction = { + async sendTransactionAsync( + destination: string, + value: BigNumber, + data: string, + txData: Partial = {}, + ): Promise { + const self = (this as any) as MultiSigWalletWithTimeLockContract; + const inputAbi = self._lookupAbi('submitTransaction(address,uint256,bytes)').inputs; + [destination, value, data] = BaseContract._formatABIDataItemList( + inputAbi, + [destination, value, data], + BaseContract._bigNumberToString.bind(self), + ); + BaseContract.strictArgumentEncodingCheck(inputAbi, [destination, value, data]); + const encodedData = self + ._lookupEthersInterface('submitTransaction(address,uint256,bytes)') + .functions.submitTransaction.encode([destination, value, data]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.submitTransaction.estimateGasAsync.bind(self, destination, value, data), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync( + destination: string, + value: BigNumber, + data: string, + txData: Partial = {}, + ): Promise { + const self = (this as any) as MultiSigWalletWithTimeLockContract; + const inputAbi = self._lookupAbi('submitTransaction(address,uint256,bytes)').inputs; + [destination, value, data] = BaseContract._formatABIDataItemList( + inputAbi, + [destination, value, data], + BaseContract._bigNumberToString, + ); + const encodedData = self + ._lookupEthersInterface('submitTransaction(address,uint256,bytes)') + .functions.submitTransaction.encode([destination, value, data]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData(destination: string, value: BigNumber, data: string): string { + const self = (this as any) as MultiSigWalletWithTimeLockContract; + const inputAbi = self._lookupAbi('submitTransaction(address,uint256,bytes)').inputs; + [destination, value, data] = BaseContract._formatABIDataItemList( + inputAbi, + [destination, value, data], + BaseContract._bigNumberToString, + ); + const abiEncodedTransactionData = self + ._lookupEthersInterface('submitTransaction(address,uint256,bytes)') + .functions.submitTransaction.encode([destination, value, data]); + return abiEncodedTransactionData; + }, + async callAsync( + destination: string, + value: BigNumber, + data: string, + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise { + const self = (this as any) as MultiSigWalletWithTimeLockContract; + const functionSignature = 'submitTransaction(address,uint256,bytes)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [destination, value, data] = BaseContract._formatABIDataItemList( + inputAbi, + [destination, value, data], + BaseContract._bigNumberToString.bind(self), + ); + BaseContract.strictArgumentEncodingCheck(inputAbi, [destination, value, data]); + const ethersFunction = self._lookupEthersInterface(functionSignature).functions.submitTransaction; + const encodedData = ethersFunction.encode([destination, value, data]); + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + let resultArray = ethersFunction.decode(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'submitTransaction' }) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._lowercaseAddress.bind(this), + ); + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._bnToBigNumber.bind(this), + ); + return resultArray[0]; + }, + }; + public confirmationTimes = { + async callAsync( + index_0: BigNumber, + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise { + const self = (this as any) as MultiSigWalletWithTimeLockContract; + const functionSignature = 'confirmationTimes(uint256)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [index_0] = BaseContract._formatABIDataItemList( + inputAbi, + [index_0], + BaseContract._bigNumberToString.bind(self), + ); + BaseContract.strictArgumentEncodingCheck(inputAbi, [index_0]); + const ethersFunction = self._lookupEthersInterface(functionSignature).functions.confirmationTimes; + const encodedData = ethersFunction.encode([index_0]); + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + let resultArray = ethersFunction.decode(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'confirmationTimes' }) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._lowercaseAddress.bind(this), + ); + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._bnToBigNumber.bind(this), + ); + return resultArray[0]; + }, + }; + public MAX_OWNER_COUNT = { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + const self = (this as any) as MultiSigWalletWithTimeLockContract; + const functionSignature = 'MAX_OWNER_COUNT()'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); + BaseContract.strictArgumentEncodingCheck(inputAbi, []); + const ethersFunction = self._lookupEthersInterface(functionSignature).functions.MAX_OWNER_COUNT; + const encodedData = ethersFunction.encode([]); + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + let resultArray = ethersFunction.decode(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'MAX_OWNER_COUNT' }) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._lowercaseAddress.bind(this), + ); + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._bnToBigNumber.bind(this), + ); + return resultArray[0]; + }, + }; + public required = { + async callAsync(callData: Partial = {}, defaultBlock?: BlockParam): Promise { + const self = (this as any) as MultiSigWalletWithTimeLockContract; + const functionSignature = 'required()'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self)); + BaseContract.strictArgumentEncodingCheck(inputAbi, []); + const ethersFunction = self._lookupEthersInterface(functionSignature).functions.required; + const encodedData = ethersFunction.encode([]); + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + let resultArray = ethersFunction.decode(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'required' }) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._lowercaseAddress.bind(this), + ); + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._bnToBigNumber.bind(this), + ); + return resultArray[0]; + }, + }; + public replaceOwner = { + async sendTransactionAsync(owner: string, newOwner: string, txData: Partial = {}): Promise { + const self = (this as any) as MultiSigWalletWithTimeLockContract; + const inputAbi = self._lookupAbi('replaceOwner(address,address)').inputs; + [owner, newOwner] = BaseContract._formatABIDataItemList( + inputAbi, + [owner, newOwner], + BaseContract._bigNumberToString.bind(self), + ); + BaseContract.strictArgumentEncodingCheck(inputAbi, [owner, newOwner]); + const encodedData = self + ._lookupEthersInterface('replaceOwner(address,address)') + .functions.replaceOwner.encode([owner, newOwner]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.replaceOwner.estimateGasAsync.bind(self, owner, newOwner), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync(owner: string, newOwner: string, txData: Partial = {}): Promise { + const self = (this as any) as MultiSigWalletWithTimeLockContract; + const inputAbi = self._lookupAbi('replaceOwner(address,address)').inputs; + [owner, newOwner] = BaseContract._formatABIDataItemList( + inputAbi, + [owner, newOwner], + BaseContract._bigNumberToString, + ); + const encodedData = self + ._lookupEthersInterface('replaceOwner(address,address)') + .functions.replaceOwner.encode([owner, newOwner]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData(owner: string, newOwner: string): string { + const self = (this as any) as MultiSigWalletWithTimeLockContract; + const inputAbi = self._lookupAbi('replaceOwner(address,address)').inputs; + [owner, newOwner] = BaseContract._formatABIDataItemList( + inputAbi, + [owner, newOwner], + BaseContract._bigNumberToString, + ); + const abiEncodedTransactionData = self + ._lookupEthersInterface('replaceOwner(address,address)') + .functions.replaceOwner.encode([owner, newOwner]); + return abiEncodedTransactionData; + }, + async callAsync( + owner: string, + newOwner: string, + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise { + const self = (this as any) as MultiSigWalletWithTimeLockContract; + const functionSignature = 'replaceOwner(address,address)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [owner, newOwner] = BaseContract._formatABIDataItemList( + inputAbi, + [owner, newOwner], + BaseContract._bigNumberToString.bind(self), + ); + BaseContract.strictArgumentEncodingCheck(inputAbi, [owner, newOwner]); + const ethersFunction = self._lookupEthersInterface(functionSignature).functions.replaceOwner; + const encodedData = ethersFunction.encode([owner, newOwner]); + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + let resultArray = ethersFunction.decode(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'replaceOwner' }) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._lowercaseAddress.bind(this), + ); + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._bnToBigNumber.bind(this), + ); + return resultArray; + }, + }; + public executeTransaction = { + async sendTransactionAsync(transactionId: BigNumber, txData: Partial = {}): Promise { + const self = (this as any) as MultiSigWalletWithTimeLockContract; + const inputAbi = self._lookupAbi('executeTransaction(uint256)').inputs; + [transactionId] = BaseContract._formatABIDataItemList( + inputAbi, + [transactionId], + BaseContract._bigNumberToString.bind(self), + ); + BaseContract.strictArgumentEncodingCheck(inputAbi, [transactionId]); + const encodedData = self + ._lookupEthersInterface('executeTransaction(uint256)') + .functions.executeTransaction.encode([transactionId]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + self.executeTransaction.estimateGasAsync.bind(self, transactionId), + ); + const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); + return txHash; + }, + async estimateGasAsync(transactionId: BigNumber, txData: Partial = {}): Promise { + const self = (this as any) as MultiSigWalletWithTimeLockContract; + const inputAbi = self._lookupAbi('executeTransaction(uint256)').inputs; + [transactionId] = BaseContract._formatABIDataItemList( + inputAbi, + [transactionId], + BaseContract._bigNumberToString, + ); + const encodedData = self + ._lookupEthersInterface('executeTransaction(uint256)') + .functions.executeTransaction.encode([transactionId]); + const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...txData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + getABIEncodedTransactionData(transactionId: BigNumber): string { + const self = (this as any) as MultiSigWalletWithTimeLockContract; + const inputAbi = self._lookupAbi('executeTransaction(uint256)').inputs; + [transactionId] = BaseContract._formatABIDataItemList( + inputAbi, + [transactionId], + BaseContract._bigNumberToString, + ); + const abiEncodedTransactionData = self + ._lookupEthersInterface('executeTransaction(uint256)') + .functions.executeTransaction.encode([transactionId]); + return abiEncodedTransactionData; + }, + async callAsync( + transactionId: BigNumber, + callData: Partial = {}, + defaultBlock?: BlockParam, + ): Promise { + const self = (this as any) as MultiSigWalletWithTimeLockContract; + const functionSignature = 'executeTransaction(uint256)'; + const inputAbi = self._lookupAbi(functionSignature).inputs; + [transactionId] = BaseContract._formatABIDataItemList( + inputAbi, + [transactionId], + BaseContract._bigNumberToString.bind(self), + ); + BaseContract.strictArgumentEncodingCheck(inputAbi, [transactionId]); + const ethersFunction = self._lookupEthersInterface(functionSignature).functions.executeTransaction; + const encodedData = ethersFunction.encode([transactionId]); + const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( + { + to: self.address, + ...callData, + data: encodedData, + }, + self._web3Wrapper.getContractDefaults(), + ); + const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + let resultArray = ethersFunction.decode(rawCallResult); + const outputAbi = (_.find(self.abi, { name: 'executeTransaction' }) as MethodAbi).outputs; + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._lowercaseAddress.bind(this), + ); + resultArray = BaseContract._formatABIDataItemList( + outputAbi, + resultArray, + BaseContract._bnToBigNumber.bind(this), + ); + return resultArray; + }, + }; + public static async deployFrom0xArtifactAsync( + artifact: ContractArtifact | SimpleContractArtifact, + provider: Provider, + txDefaults: Partial, + _owners: string[], + _required: BigNumber, + _secondsTimeLocked: BigNumber, + ): Promise { + 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 MultiSigWalletWithTimeLockContract.deployAsync( + bytecode, + abi, + provider, + txDefaults, + _owners, + _required, + _secondsTimeLocked, + ); + } + public static async deployAsync( + bytecode: string, + abi: ContractAbi, + provider: Provider, + txDefaults: Partial, + _owners: string[], + _required: BigNumber, + _secondsTimeLocked: BigNumber, + ): Promise { + const constructorAbi = BaseContract._lookupConstructorAbi(abi); + [_owners, _required, _secondsTimeLocked] = BaseContract._formatABIDataItemList( + constructorAbi.inputs, + [_owners, _required, _secondsTimeLocked], + BaseContract._bigNumberToString, + ); + const iface = new ethers.utils.Interface(abi); + const deployInfo = iface.deployFunction; + const txData = deployInfo.encode(bytecode, [_owners, _required, _secondsTimeLocked]); + 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(`MultiSigWalletWithTimeLock successfully deployed at ${txReceipt.contractAddress}`); + const contractInstance = new MultiSigWalletWithTimeLockContract( + abi, + txReceipt.contractAddress as string, + provider, + txDefaults, + ); + contractInstance.constructorArgs = [_owners, _required, _secondsTimeLocked]; + return contractInstance; + } + constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial) { + super('MultiSigWalletWithTimeLock', abi, address, provider, txDefaults); + classUtils.bindAll(this, ['_ethersInterfacesByFunctionSignature', 'address', 'abi', '_web3Wrapper']); + } +} // tslint:disable:max-file-line-count +// tslint:enable:no-unbound-method diff --git a/contracts/multisig/generated-wrappers/test_reject_ether.ts b/contracts/multisig/generated-wrappers/test_reject_ether.ts new file mode 100644 index 000000000..0dd46d3de --- /dev/null +++ b/contracts/multisig/generated-wrappers/test_reject_ether.ts @@ -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, + ): Promise { + 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, + ): Promise { + 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) { + super('TestRejectEther', abi, address, provider, txDefaults); + classUtils.bindAll(this, ['_ethersInterfacesByFunctionSignature', 'address', 'abi', '_web3Wrapper']); + } +} // tslint:disable:max-file-line-count +// tslint:enable:no-unbound-method diff --git a/contracts/multisig/package.json b/contracts/multisig/package.json new file mode 100644 index 000000000..a1a6a7ec6 --- /dev/null +++ b/contracts/multisig/package.json @@ -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" + } +} diff --git a/contracts/multisig/src/artifacts/index.ts b/contracts/multisig/src/artifacts/index.ts new file mode 100644 index 000000000..7cf47be01 --- /dev/null +++ b/contracts/multisig/src/artifacts/index.ts @@ -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, +}; diff --git a/contracts/multisig/src/wrappers/index.ts b/contracts/multisig/src/wrappers/index.ts new file mode 100644 index 000000000..69abd62f2 --- /dev/null +++ b/contracts/multisig/src/wrappers/index.ts @@ -0,0 +1,2 @@ +export * from '../../generated-wrappers/multi_sig_wallet'; +export * from '../../generated-wrappers/multi_sig_wallet_with_time_lock'; diff --git a/contracts/multisig/test/multi_sig_with_time_lock.ts b/contracts/multisig/test/multi_sig_with_time_lock.ts new file mode 100644 index 000000000..31c215505 --- /dev/null +++ b/contracts/multisig/test/multi_sig_with_time_lock.ts @@ -0,0 +1,349 @@ +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'; +import * as chai from 'chai'; +import { LogWithDecodedArgs } from 'ethereum-types'; +import * as _ from 'lodash'; + +import { + MultiSigWalletWithTimeLockConfirmationEventArgs, + MultiSigWalletWithTimeLockConfirmationTimeSetEventArgs, + MultiSigWalletWithTimeLockContract, + MultiSigWalletWithTimeLockExecutionEventArgs, + MultiSigWalletWithTimeLockExecutionFailureEventArgs, + MultiSigWalletWithTimeLockSubmissionEventArgs, +} 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; +const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper); +// tslint:disable:no-unnecessary-type-assertion +describe('MultiSigWalletWithTimeLock', () => { + let owners: string[]; + let notOwner: string; + const REQUIRED_APPROVALS = new BigNumber(2); + const SECONDS_TIME_LOCKED = new BigNumber(1000000); + + before(async () => { + await blockchainLifecycle.startAsync(); + }); + after(async () => { + await blockchainLifecycle.revertAsync(); + }); + before(async () => { + const accounts = await web3Wrapper.getAvailableAddressesAsync(); + owners = [accounts[0], accounts[1], accounts[2]]; + notOwner = accounts[3]; + }); + + let multiSig: MultiSigWalletWithTimeLockContract; + let multiSigWrapper: MultiSigWrapper; + + beforeEach(async () => { + await blockchainLifecycle.startAsync(); + }); + afterEach(async () => { + await blockchainLifecycle.revertAsync(); + }); + + describe('external_call', () => { + it('should be internal', async () => { + const secondsTimeLocked = new BigNumber(0); + multiSig = await MultiSigWalletWithTimeLockContract.deployFrom0xArtifactAsync( + artifacts.MultiSigWalletWithTimeLock, + provider, + txDefaults, + owners, + REQUIRED_APPROVALS, + secondsTimeLocked, + ); + expect(_.isUndefined((multiSig as any).external_call)).to.be.equal(true); + }); + }); + describe('confirmTransaction', () => { + let txId: BigNumber; + beforeEach(async () => { + const secondsTimeLocked = new BigNumber(0); + multiSig = await MultiSigWalletWithTimeLockContract.deployFrom0xArtifactAsync( + artifacts.MultiSigWalletWithTimeLock, + provider, + txDefaults, + owners, + REQUIRED_APPROVALS, + secondsTimeLocked, + ); + multiSigWrapper = new MultiSigWrapper(multiSig, provider); + const destination = notOwner; + const data = constants.NULL_BYTES; + const txReceipt = await multiSigWrapper.submitTransactionAsync(destination, data, owners[0]); + txId = (txReceipt.logs[0] as LogWithDecodedArgs).args + .transactionId; + }); + it('should revert if called by a non-owner', async () => { + await expectTransactionFailedWithoutReasonAsync(multiSigWrapper.confirmTransactionAsync(txId, notOwner)); + }); + it('should revert if transaction does not exist', async () => { + const nonexistentTxId = new BigNumber(123456789); + await expectTransactionFailedWithoutReasonAsync( + multiSigWrapper.confirmTransactionAsync(nonexistentTxId, owners[1]), + ); + }); + it('should revert if transaction is already confirmed by caller', async () => { + await expectTransactionFailedWithoutReasonAsync(multiSigWrapper.confirmTransactionAsync(txId, owners[0])); + }); + it('should confirm transaction for caller and log a Confirmation event', async () => { + const txReceipt = await multiSigWrapper.confirmTransactionAsync(txId, owners[1]); + const log = txReceipt.logs[0] as LogWithDecodedArgs; + expect(log.event).to.be.equal('Confirmation'); + expect(log.args.sender).to.be.equal(owners[1]); + expect(log.args.transactionId).to.be.bignumber.equal(txId); + }); + it('should revert if fully confirmed', async () => { + await multiSigWrapper.confirmTransactionAsync(txId, owners[1]); + await expectTransactionFailedAsync( + multiSigWrapper.confirmTransactionAsync(txId, owners[2]), + RevertReason.TxFullyConfirmed, + ); + }); + it('should set the confirmation time of the transaction if it becomes fully confirmed', async () => { + const txReceipt = await multiSigWrapper.confirmTransactionAsync(txId, owners[1]); + const blockNum = await web3Wrapper.getBlockNumberAsync(); + const timestamp = new BigNumber(await web3Wrapper.getBlockTimestampAsync(blockNum)); + const log = txReceipt.logs[1] as LogWithDecodedArgs; + expect(log.args.confirmationTime).to.be.bignumber.equal(timestamp); + expect(log.args.transactionId).to.be.bignumber.equal(txId); + }); + }); + describe('executeTransaction', () => { + let txId: BigNumber; + const secondsTimeLocked = new BigNumber(1000000); + beforeEach(async () => { + multiSig = await MultiSigWalletWithTimeLockContract.deployFrom0xArtifactAsync( + artifacts.MultiSigWalletWithTimeLock, + provider, + txDefaults, + owners, + REQUIRED_APPROVALS, + secondsTimeLocked, + ); + multiSigWrapper = new MultiSigWrapper(multiSig, provider); + const destination = notOwner; + const data = constants.NULL_BYTES; + const txReceipt = await multiSigWrapper.submitTransactionAsync(destination, data, owners[0]); + txId = (txReceipt.logs[0] as LogWithDecodedArgs).args + .transactionId; + }); + it('should revert if transaction has not been fully confirmed', async () => { + await increaseTimeAndMineBlockAsync(secondsTimeLocked.toNumber()); + await expectTransactionFailedAsync( + multiSigWrapper.executeTransactionAsync(txId, owners[1]), + RevertReason.TxNotFullyConfirmed, + ); + }); + it('should revert if time lock has not passed', async () => { + await multiSigWrapper.confirmTransactionAsync(txId, owners[1]); + await expectTransactionFailedAsync( + multiSigWrapper.executeTransactionAsync(txId, owners[1]), + RevertReason.TimeLockIncomplete, + ); + }); + it('should execute a transaction and log an Execution event if successful and called by owner', async () => { + await multiSigWrapper.confirmTransactionAsync(txId, owners[1]); + await increaseTimeAndMineBlockAsync(secondsTimeLocked.toNumber()); + const txReceipt = await multiSigWrapper.executeTransactionAsync(txId, owners[1]); + const log = txReceipt.logs[0] as LogWithDecodedArgs; + expect(log.event).to.be.equal('Execution'); + expect(log.args.transactionId).to.be.bignumber.equal(txId); + }); + it('should execute a transaction and log an Execution event if successful and called by non-owner', async () => { + await multiSigWrapper.confirmTransactionAsync(txId, owners[1]); + await increaseTimeAndMineBlockAsync(secondsTimeLocked.toNumber()); + const txReceipt = await multiSigWrapper.executeTransactionAsync(txId, notOwner); + const log = txReceipt.logs[0] as LogWithDecodedArgs; + expect(log.event).to.be.equal('Execution'); + expect(log.args.transactionId).to.be.bignumber.equal(txId); + }); + it('should revert if a required confirmation is revoked before executeTransaction is called', async () => { + await multiSigWrapper.confirmTransactionAsync(txId, owners[1]); + await increaseTimeAndMineBlockAsync(secondsTimeLocked.toNumber()); + await multiSigWrapper.revokeConfirmationAsync(txId, owners[0]); + await expectTransactionFailedAsync( + multiSigWrapper.executeTransactionAsync(txId, owners[1]), + RevertReason.TxNotFullyConfirmed, + ); + }); + it('should revert if transaction has been executed', async () => { + await multiSigWrapper.confirmTransactionAsync(txId, owners[1]); + await increaseTimeAndMineBlockAsync(secondsTimeLocked.toNumber()); + const txReceipt = await multiSigWrapper.executeTransactionAsync(txId, owners[1]); + const log = txReceipt.logs[0] as LogWithDecodedArgs; + expect(log.args.transactionId).to.be.bignumber.equal(txId); + 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 TestRejectEtherContract.deployFrom0xArtifactAsync( + artifacts.TestRejectEther, + provider, + txDefaults, + ); + const data = constants.NULL_BYTES; + const value = new BigNumber(10); + const submissionTxReceipt = await multiSigWrapper.submitTransactionAsync( + contractWithoutFallback.address, + data, + owners[0], + { value }, + ); + const newTxId = (submissionTxReceipt.logs[0] as LogWithDecodedArgs< + MultiSigWalletWithTimeLockSubmissionEventArgs + >).args.transactionId; + await multiSigWrapper.confirmTransactionAsync(newTxId, owners[1]); + await increaseTimeAndMineBlockAsync(secondsTimeLocked.toNumber()); + const txReceipt = await multiSigWrapper.executeTransactionAsync(newTxId, owners[1]); + const executionFailureLog = txReceipt.logs[0] as LogWithDecodedArgs< + MultiSigWalletWithTimeLockExecutionFailureEventArgs + >; + expect(executionFailureLog.event).to.be.equal('ExecutionFailure'); + expect(executionFailureLog.args.transactionId).to.be.bignumber.equal(newTxId); + }); + }); + describe('changeTimeLock', () => { + describe('initially non-time-locked', async () => { + before(async () => { + await blockchainLifecycle.startAsync(); + }); + after(async () => { + await blockchainLifecycle.revertAsync(); + }); + before('deploy a wallet', async () => { + const secondsTimeLocked = new BigNumber(0); + multiSig = await MultiSigWalletWithTimeLockContract.deployFrom0xArtifactAsync( + artifacts.MultiSigWalletWithTimeLock, + provider, + txDefaults, + owners, + REQUIRED_APPROVALS, + secondsTimeLocked, + ); + multiSigWrapper = new MultiSigWrapper(multiSig, provider); + }); + + it('should throw when not called by wallet', async () => { + return expectTransactionFailedWithoutReasonAsync( + multiSig.changeTimeLock.sendTransactionAsync(SECONDS_TIME_LOCKED, { from: owners[0] }), + ); + }); + + it('should throw without enough confirmations', async () => { + const destination = multiSig.address; + const changeTimeLockData = multiSig.changeTimeLock.getABIEncodedTransactionData(SECONDS_TIME_LOCKED); + const res = await multiSigWrapper.submitTransactionAsync(destination, changeTimeLockData, owners[0]); + const log = res.logs[0] as LogWithDecodedArgs; + const txId = log.args.transactionId; + return expectTransactionFailedAsync( + multiSig.executeTransaction.sendTransactionAsync(txId, { from: owners[0] }), + RevertReason.TxNotFullyConfirmed, + ); + }); + + it('should set confirmation time with enough confirmations', async () => { + const destination = multiSig.address; + const changeTimeLockData = multiSig.changeTimeLock.getABIEncodedTransactionData(SECONDS_TIME_LOCKED); + const subRes = await multiSigWrapper.submitTransactionAsync(destination, changeTimeLockData, owners[0]); + const subLog = subRes.logs[0] as LogWithDecodedArgs; + const txId = subLog.args.transactionId; + + const confirmRes = await multiSigWrapper.confirmTransactionAsync(txId, owners[1]); + expect(confirmRes.logs).to.have.length(2); + + const blockNum = await web3Wrapper.getBlockNumberAsync(); + const blockInfo = await web3Wrapper.getBlockIfExistsAsync(blockNum); + if (_.isUndefined(blockInfo)) { + throw new Error(`Unexpectedly failed to fetch block at #${blockNum}`); + } + const timestamp = new BigNumber(blockInfo.timestamp); + const confirmationTimeBigNum = new BigNumber(await multiSig.confirmationTimes.callAsync(txId)); + + expect(timestamp).to.be.bignumber.equal(confirmationTimeBigNum); + }); + + it('should be executable with enough confirmations and secondsTimeLocked of 0', async () => { + const destination = multiSig.address; + const changeTimeLockData = multiSig.changeTimeLock.getABIEncodedTransactionData(SECONDS_TIME_LOCKED); + const subRes = await multiSigWrapper.submitTransactionAsync(destination, changeTimeLockData, owners[0]); + const subLog = subRes.logs[0] as LogWithDecodedArgs; + const txId = subLog.args.transactionId; + + await multiSigWrapper.confirmTransactionAsync(txId, owners[1]); + await multiSigWrapper.executeTransactionAsync(txId, owners[1]); + + const secondsTimeLocked = new BigNumber(await multiSig.secondsTimeLocked.callAsync()); + expect(secondsTimeLocked).to.be.bignumber.equal(SECONDS_TIME_LOCKED); + }); + }); + describe('initially time-locked', async () => { + before(async () => { + await blockchainLifecycle.startAsync(); + }); + after(async () => { + await blockchainLifecycle.revertAsync(); + }); + let txId: BigNumber; + const newSecondsTimeLocked = new BigNumber(0); + before('deploy a wallet, submit transaction to change timelock, and confirm the transaction', async () => { + multiSig = await MultiSigWalletWithTimeLockContract.deployFrom0xArtifactAsync( + artifacts.MultiSigWalletWithTimeLock, + provider, + txDefaults, + owners, + REQUIRED_APPROVALS, + SECONDS_TIME_LOCKED, + ); + multiSigWrapper = new MultiSigWrapper(multiSig, provider); + + const changeTimeLockData = multiSig.changeTimeLock.getABIEncodedTransactionData(newSecondsTimeLocked); + const res = await multiSigWrapper.submitTransactionAsync( + multiSig.address, + changeTimeLockData, + owners[0], + ); + const log = res.logs[0] as LogWithDecodedArgs; + txId = log.args.transactionId; + await multiSigWrapper.confirmTransactionAsync(txId, owners[1]); + }); + + it('should throw if it has enough confirmations but is not past the time lock', async () => { + return expectTransactionFailedAsync( + multiSig.executeTransaction.sendTransactionAsync(txId, { from: owners[0] }), + RevertReason.TimeLockIncomplete, + ); + }); + + it('should execute if it has enough confirmations and is past the time lock', async () => { + await increaseTimeAndMineBlockAsync(SECONDS_TIME_LOCKED.toNumber()); + await web3Wrapper.awaitTransactionSuccessAsync( + await multiSig.executeTransaction.sendTransactionAsync(txId, { from: owners[0] }), + constants.AWAIT_TRANSACTION_MINED_MS, + ); + + const secondsTimeLocked = new BigNumber(await multiSig.secondsTimeLocked.callAsync()); + expect(secondsTimeLocked).to.be.bignumber.equal(newSecondsTimeLocked); + }); + }); + }); +}); +// tslint:enable:no-unnecessary-type-assertion diff --git a/contracts/multisig/test/utils/multi_sig_wrapper.ts b/contracts/multisig/test/utils/multi_sig_wrapper.ts new file mode 100644 index 000000000..086143613 --- /dev/null +++ b/contracts/multisig/test/utils/multi_sig_wrapper.ts @@ -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 { + 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 { + 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 { + 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 { + const txHash = await this._multiSig.executeTransaction.sendTransactionAsync(txId, { + from, + gas: opts.gas, + }); + const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash); + return tx; + } +} diff --git a/contracts/multisig/tsconfig.json b/contracts/multisig/tsconfig.json new file mode 100644 index 000000000..6f381620e --- /dev/null +++ b/contracts/multisig/tsconfig.json @@ -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"] +} diff --git a/contracts/multisig/tslint.json b/contracts/multisig/tslint.json new file mode 100644 index 000000000..1bb3ac2a2 --- /dev/null +++ b/contracts/multisig/tslint.json @@ -0,0 +1,6 @@ +{ + "extends": ["@0x/tslint-config"], + "rules": { + "custom-no-magic-numbers": false + } +} diff --git a/contracts/test-utils/CHANGELOG.json b/contracts/test-utils/CHANGELOG.json new file mode 100644 index 000000000..fe51488c7 --- /dev/null +++ b/contracts/test-utils/CHANGELOG.json @@ -0,0 +1 @@ +[] diff --git a/contracts/test-utils/README.md b/contracts/test-utils/README.md new file mode 100644 index 000000000..97a2816ff --- /dev/null +++ b/contracts/test-utils/README.md @@ -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. diff --git a/contracts/test-utils/package.json b/contracts/test-utils/package.json new file mode 100644 index 000000000..a83aa931d --- /dev/null +++ b/contracts/test-utils/package.json @@ -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" + } +} diff --git a/contracts/test-utils/src/abstract_asset_wrapper.ts b/contracts/test-utils/src/abstract_asset_wrapper.ts new file mode 100644 index 000000000..4b56a8502 --- /dev/null +++ b/contracts/test-utils/src/abstract_asset_wrapper.ts @@ -0,0 +1,3 @@ +export abstract class AbstractAssetWrapper { + public abstract getProxyId(): string; +} diff --git a/contracts/test-utils/src/address_utils.ts b/contracts/test-utils/src/address_utils.ts new file mode 100644 index 000000000..634da0c16 --- /dev/null +++ b/contracts/test-utils/src/address_utils.ts @@ -0,0 +1,11 @@ +import { generatePseudoRandomSalt } from '@0x/order-utils'; +import { crypto } from '@0x/order-utils/lib/src/crypto'; + +export const addressUtils = { + generatePseudoRandomAddress(): string { + const randomBigNum = generatePseudoRandomSalt(); + const randomBuff = crypto.solSHA3([randomBigNum]); + const randomAddress = `0x${randomBuff.slice(0, 20).toString('hex')}`; + return randomAddress; + }, +}; diff --git a/contracts/test-utils/src/assertions.ts b/contracts/test-utils/src/assertions.ts new file mode 100644 index 000000000..5b1cedfcc --- /dev/null +++ b/contracts/test-utils/src/assertions.ts @@ -0,0 +1,199 @@ +import { RevertReason } from '@0x/types'; +import { logUtils } from '@0x/utils'; +import { NodeType } from '@0x/web3-wrapper'; +import * as chai from 'chai'; +import { TransactionReceipt, TransactionReceiptStatus, TransactionReceiptWithDecodedLogs } from 'ethereum-types'; +import * as _ from 'lodash'; + +import { web3Wrapper } from './web3_wrapper'; + +const expect = chai.expect; + +let nodeType: NodeType | undefined; + +// Represents the return value of a `sendTransaction` call. The Promise should +// resolve with either a transaction receipt or a transaction hash. +export type sendTransactionResult = Promise; + +/** + * Returns ganacheError if the backing Ethereum node is Ganache and gethError + * if it is Geth. + * @param ganacheError the error to be returned if the backing node is Ganache. + * @param gethError the error to be returned if the backing node is Geth. + * @returns either the given ganacheError or gethError depending on the backing + * node. + */ +async function _getGanacheOrGethError(ganacheError: string, gethError: string): Promise { + if (_.isUndefined(nodeType)) { + nodeType = await web3Wrapper.getNodeTypeAsync(); + } + switch (nodeType) { + case NodeType.Ganache: + return ganacheError; + case NodeType.Geth: + return gethError; + default: + throw new Error(`Unknown node type: ${nodeType}`); + } +} + +async function _getInsufficientFundsErrorMessageAsync(): Promise { + return _getGanacheOrGethError("sender doesn't have enough funds", 'insufficient funds'); +} + +async function _getTransactionFailedErrorMessageAsync(): Promise { + return _getGanacheOrGethError('revert', 'always failing transaction'); +} + +async function _getContractCallFailedErrorMessageAsync(): Promise { + return _getGanacheOrGethError('revert', 'Contract call failed'); +} + +/** + * Returns the expected error message for an 'invalid opcode' resulting from a + * contract call. The exact error message depends on the backing Ethereum node. + */ +export async function getInvalidOpcodeErrorMessageForCallAsync(): Promise { + return _getGanacheOrGethError('invalid opcode', 'Contract call failed'); +} + +/** + * Returns the expected error message for the given revert reason resulting from + * a sendTransaction call. The exact error message depends on the backing + * Ethereum node and whether it supports revert reasons. + * @param reason a specific revert reason. + * @returns the expected error message. + */ +export async function getRevertReasonOrErrorMessageForSendTransactionAsync(reason: RevertReason): Promise { + return _getGanacheOrGethError(reason, 'always failing transaction'); +} + +/** + * Rejects if the given Promise does not reject with an error indicating + * insufficient funds. + * @param p a promise resulting from a contract call or sendTransaction call. + * @returns a new Promise which will reject if the conditions are not met and + * otherwise resolve with no value. + */ +export async function expectInsufficientFundsAsync(p: Promise): Promise { + const errMessage = await _getInsufficientFundsErrorMessageAsync(); + return expect(p).to.be.rejectedWith(errMessage); +} + +/** + * Resolves if the the sendTransaction call fails with the given revert reason. + * However, since Geth does not support revert reasons for sendTransaction, this + * falls back to expectTransactionFailedWithoutReasonAsync if the backing + * Ethereum node is Geth. + * @param p a Promise resulting from a sendTransaction call + * @param reason a specific revert reason + * @returns a new Promise which will reject if the conditions are not met and + * otherwise resolve with no value. + */ +export async function expectTransactionFailedAsync(p: sendTransactionResult, reason: RevertReason): Promise { + // HACK(albrow): This dummy `catch` should not be necessary, but if you + // remove it, there is an uncaught exception and the Node process will + // forcibly exit. It's possible this is a false positive in + // make-promises-safe. + p.catch(e => { + _.noop(e); + }); + + if (_.isUndefined(nodeType)) { + nodeType = await web3Wrapper.getNodeTypeAsync(); + } + switch (nodeType) { + case NodeType.Ganache: + return expect(p).to.be.rejectedWith(reason); + case NodeType.Geth: + logUtils.warn( + 'WARNING: Geth does not support revert reasons for sendTransaction. This test will pass if the transaction fails for any reason.', + ); + return expectTransactionFailedWithoutReasonAsync(p); + default: + throw new Error(`Unknown node type: ${nodeType}`); + } +} + +/** + * Resolves if the transaction fails without a revert reason, or if the + * corresponding transactionReceipt has a status of 0 or '0', indicating + * failure. + * @param p a Promise resulting from a sendTransaction call + * @returns a new Promise which will reject if the conditions are not met and + * otherwise resolve with no value. + */ +export async function expectTransactionFailedWithoutReasonAsync(p: sendTransactionResult): Promise { + return p + .then(async result => { + let txReceiptStatus: TransactionReceiptStatus; + if (_.isString(result)) { + // Result is a txHash. We need to make a web3 call to get the + // receipt, then get the status from the receipt. + const txReceipt = await web3Wrapper.awaitTransactionMinedAsync(result); + txReceiptStatus = txReceipt.status; + } else if ('status' in result) { + // Result is a transaction receipt, so we can get the status + // directly. + txReceiptStatus = result.status; + } else { + throw new Error('Unexpected result type: ' + typeof result); + } + expect(_.toString(txReceiptStatus)).to.equal( + '0', + 'Expected transaction to fail but receipt had a non-zero status, indicating success', + ); + }) + .catch(async err => { + // If the promise rejects, we expect a specific error message, + // depending on the backing Ethereum node type. + const errMessage = await _getTransactionFailedErrorMessageAsync(); + expect(err.message).to.include(errMessage); + }); +} + +/** + * Resolves if the the contract call fails with the given revert reason. + * @param p a Promise resulting from a contract call + * @param reason a specific revert reason + * @returns a new Promise which will reject if the conditions are not met and + * otherwise resolve with no value. + */ +export async function expectContractCallFailedAsync(p: Promise, reason: RevertReason): Promise { + return expect(p).to.be.rejectedWith(reason); +} + +/** + * Resolves if the contract call fails without a revert reason. + * @param p a Promise resulting from a contract call + * @returns a new Promise which will reject if the conditions are not met and + * otherwise resolve with no value. + */ +export async function expectContractCallFailedWithoutReasonAsync(p: Promise): Promise { + const errMessage = await _getContractCallFailedErrorMessageAsync(); + return expect(p).to.be.rejectedWith(errMessage); +} + +/** + * Resolves if the contract creation/deployment fails without a revert reason. + * @param p a Promise resulting from a contract creation/deployment + * @returns a new Promise which will reject if the conditions are not met and + * otherwise resolve with no value. + */ +export async function expectContractCreationFailedAsync( + p: sendTransactionResult, + reason: RevertReason, +): Promise { + return expectTransactionFailedAsync(p, reason); +} + +/** + * Resolves if the contract creation/deployment fails without a revert reason. + * @param p a Promise resulting from a contract creation/deployment + * @returns a new Promise which will reject if the conditions are not met and + * otherwise resolve with no value. + */ +export async function expectContractCreationFailedWithoutReasonAsync(p: Promise): Promise { + const errMessage = await _getTransactionFailedErrorMessageAsync(); + return expect(p).to.be.rejectedWith(errMessage); +} diff --git a/contracts/test-utils/src/block_timestamp.ts b/contracts/test-utils/src/block_timestamp.ts new file mode 100644 index 000000000..66c13eed1 --- /dev/null +++ b/contracts/test-utils/src/block_timestamp.ts @@ -0,0 +1,43 @@ +import * as _ from 'lodash'; + +import { constants } from './constants'; +import { web3Wrapper } from './web3_wrapper'; + +let firstAccount: string | undefined; + +/** + * Increases time by the given number of seconds and then mines a block so that + * the current block timestamp has the offset applied. + * @param seconds the number of seconds by which to incrase the time offset. + * @returns a new Promise which will resolve with the new total time offset or + * reject if the time could not be increased. + */ +export async function increaseTimeAndMineBlockAsync(seconds: number): Promise { + if (_.isUndefined(firstAccount)) { + const accounts = await web3Wrapper.getAvailableAddressesAsync(); + firstAccount = accounts[0]; + } + + const offset = await web3Wrapper.increaseTimeAsync(seconds); + // Note: we need to send a transaction after increasing time so + // that a block is actually mined. The contract looks at the + // last mined block for the timestamp. + await web3Wrapper.awaitTransactionSuccessAsync( + await web3Wrapper.sendTransactionAsync({ from: firstAccount, to: firstAccount, value: 0 }), + constants.AWAIT_TRANSACTION_MINED_MS, + ); + + return offset; +} + +/** + * Returns the timestamp of the latest block in seconds since the Unix epoch. + * @returns a new Promise which will resolve with the timestamp in seconds. + */ +export async function getLatestBlockTimestampAsync(): Promise { + const currentBlockIfExists = await web3Wrapper.getBlockIfExistsAsync('latest'); + if (_.isUndefined(currentBlockIfExists)) { + throw new Error(`Unable to fetch latest block.`); + } + return currentBlockIfExists.timestamp; +} diff --git a/contracts/test-utils/src/chai_setup.ts b/contracts/test-utils/src/chai_setup.ts new file mode 100644 index 000000000..1a8733093 --- /dev/null +++ b/contracts/test-utils/src/chai_setup.ts @@ -0,0 +1,13 @@ +import * as chai from 'chai'; +import chaiAsPromised = require('chai-as-promised'); +import ChaiBigNumber = require('chai-bignumber'); +import * as dirtyChai from 'dirty-chai'; + +export const chaiSetup = { + configure(): void { + chai.config.includeStack = true; + chai.use(ChaiBigNumber()); + chai.use(dirtyChai); + chai.use(chaiAsPromised); + }, +}; diff --git a/contracts/test-utils/src/combinatorial_utils.ts b/contracts/test-utils/src/combinatorial_utils.ts new file mode 100644 index 000000000..bb1b55b4d --- /dev/null +++ b/contracts/test-utils/src/combinatorial_utils.ts @@ -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( + name: string, + referenceFunc: (p0: P0, p1: P1) => Promise, + testFunc: (p0: P0, p1: P1) => Promise, + allValues: [P0[], P1[]], +): Promise; +export async function testCombinatoriallyWithReferenceFuncAsync( + name: string, + referenceFunc: (p0: P0, p1: P1, p2: P2) => Promise, + testFunc: (p0: P0, p1: P1, p2: P2) => Promise, + allValues: [P0[], P1[], P2[]], +): Promise; +export async function testCombinatoriallyWithReferenceFuncAsync( + name: string, + referenceFunc: (p0: P0, p1: P1, p2: P2, p3: P3) => Promise, + testFunc: (p0: P0, p1: P1, p2: P2, p3: P3) => Promise, + allValues: [P0[], P1[], P2[], P3[]], +): Promise; +export async function testCombinatoriallyWithReferenceFuncAsync( + name: string, + referenceFunc: (p0: P0, p1: P1, p2: P2, p3: P3, p4: P4) => Promise, + testFunc: (p0: P0, p1: P1, p2: P2, p3: P3, p4: P4) => Promise, + allValues: [P0[], P1[], P2[], P3[], P4[]], +): Promise; + +/** + * 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, + testFuncAsync: (...args: any[]) => Promise, + allValues: any[], +): Promise { + 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); + }); + }); +} diff --git a/contracts/test-utils/src/constants.ts b/contracts/test-utils/src/constants.ts new file mode 100644 index 000000000..d2c3ab512 --- /dev/null +++ b/contracts/test-utils/src/constants.ts @@ -0,0 +1,67 @@ +import { BigNumber } from '@0x/utils'; +import { Web3Wrapper } from '@0x/web3-wrapper'; +import * as ethUtil from 'ethereumjs-util'; +import * as _ from 'lodash'; + +const TESTRPC_PRIVATE_KEYS_STRINGS = [ + '0xf2f48ee19680706196e2e339e5da3491186e0c4c5030670656b0e0164837257d', + '0x5d862464fe9303452126c8bc94274b8c5f9874cbd219789b3eb2128075a76f72', + '0xdf02719c4df8b9b8ac7f551fcb5d9ef48fa27eef7a66453879f4d8fdc6e78fb1', + '0xff12e391b79415e941a94de3bf3a9aee577aed0731e297d5cfa0b8a1e02fa1d0', + '0x752dd9cf65e68cfaba7d60225cbdbc1f4729dd5e5507def72815ed0d8abc6249', + '0xefb595a0178eb79a8df953f87c5148402a224cdf725e88c0146727c6aceadccd', + '0x83c6d2cc5ddcf9711a6d59b417dc20eb48afd58d45290099e5987e3d768f328f', + '0xbb2d3f7c9583780a7d3904a2f55d792707c345f21de1bacb2d389934d82796b2', + '0xb2fd4d29c1390b71b8795ae81196bfd60293adf99f9d32a0aff06288fcdac55f', + '0x23cb7121166b9a2f93ae0b7c05bde02eae50d64449b2cbb42bc84e9d38d6cc89', +]; + +export const constants = { + BASE_16: 16, + INVALID_OPCODE: 'invalid opcode', + TESTRPC_NETWORK_ID: 50, + // Note(albrow): In practice V8 and most other engines limit the minimum + // interval for setInterval to 10ms. We still set it to 0 here in order to + // ensure we always use the minimum interval. + AWAIT_TRANSACTION_MINED_MS: 0, + MAX_ETHERTOKEN_WITHDRAW_GAS: 43000, + MAX_EXECUTE_TRANSACTION_GAS: 1000000, + MAX_TOKEN_TRANSFERFROM_GAS: 80000, + MAX_TOKEN_APPROVE_GAS: 60000, + MAX_TRANSFER_FROM_GAS: 150000, + DUMMY_TOKEN_NAME: '', + DUMMY_TOKEN_SYMBOL: '', + DUMMY_TOKEN_DECIMALS: new BigNumber(18), + DUMMY_TOKEN_TOTAL_SUPPLY: new BigNumber(0), + NULL_BYTES: '0x', + NUM_DUMMY_ERC20_TO_DEPLOY: 3, + NUM_DUMMY_ERC721_TO_DEPLOY: 2, + NUM_ERC721_TOKENS_TO_MINT: 2, + NULL_ADDRESS: '0x0000000000000000000000000000000000000000', + UNLIMITED_ALLOWANCE_IN_BASE_UNITS: new BigNumber(2).pow(256).minus(1), + TESTRPC_PRIVATE_KEYS: _.map(TESTRPC_PRIVATE_KEYS_STRINGS, privateKeyString => ethUtil.toBuffer(privateKeyString)), + INITIAL_ERC20_BALANCE: Web3Wrapper.toBaseUnitAmount(new BigNumber(10000), 18), + INITIAL_ERC20_ALLOWANCE: Web3Wrapper.toBaseUnitAmount(new BigNumber(10000), 18), + STATIC_ORDER_PARAMS: { + makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(100), 18), + takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(200), 18), + makerFee: Web3Wrapper.toBaseUnitAmount(new BigNumber(1), 18), + takerFee: Web3Wrapper.toBaseUnitAmount(new BigNumber(1), 18), + }, + WORD_LENGTH: 32, + ZERO_AMOUNT: new BigNumber(0), + PERCENTAGE_DENOMINATOR: new BigNumber(10).pow(18), + FUNCTIONS_WITH_MUTEX: [ + 'FILL_ORDER', + 'FILL_OR_KILL_ORDER', + 'BATCH_FILL_ORDERS', + 'BATCH_FILL_OR_KILL_ORDERS', + 'MARKET_BUY_ORDERS', + 'MARKET_SELL_ORDERS', + 'MATCH_ORDERS', + 'CANCEL_ORDER', + 'BATCH_CANCEL_ORDERS', + 'CANCEL_ORDERS_UP_TO', + 'SET_SIGNATURE_VALIDATOR_APPROVAL', + ], +}; diff --git a/contracts/test-utils/src/coverage.ts b/contracts/test-utils/src/coverage.ts new file mode 100644 index 000000000..5becfa1b6 --- /dev/null +++ b/contracts/test-utils/src/coverage.ts @@ -0,0 +1,21 @@ +import { devConstants } from '@0x/dev-utils'; +import { CoverageSubprovider, SolCompilerArtifactAdapter } from '@0x/sol-cov'; +import * as _ from 'lodash'; + +let coverageSubprovider: CoverageSubprovider; + +export const coverage = { + getCoverageSubproviderSingleton(): CoverageSubprovider { + if (_.isUndefined(coverageSubprovider)) { + coverageSubprovider = coverage._getCoverageSubprovider(); + } + return coverageSubprovider; + }, + _getCoverageSubprovider(): CoverageSubprovider { + const defaultFromAddress = devConstants.TESTRPC_FIRST_ADDRESS; + const solCompilerArtifactAdapter = new SolCompilerArtifactAdapter(); + const isVerbose = true; + const subprovider = new CoverageSubprovider(solCompilerArtifactAdapter, defaultFromAddress, isVerbose); + return subprovider; + }, +}; diff --git a/contracts/test-utils/src/formatters.ts b/contracts/test-utils/src/formatters.ts new file mode 100644 index 000000000..813eb45db --- /dev/null +++ b/contracts/test-utils/src/formatters.ts @@ -0,0 +1,68 @@ +import { SignedOrder } from '@0x/types'; +import { BigNumber } from '@0x/utils'; +import * as _ from 'lodash'; + +import { constants } from './constants'; +import { orderUtils } from './order_utils'; +import { BatchCancelOrders, BatchFillOrders, MarketBuyOrders, MarketSellOrders } from './types'; + +export const formatters = { + createBatchFill(signedOrders: SignedOrder[], takerAssetFillAmounts: BigNumber[] = []): BatchFillOrders { + const batchFill: BatchFillOrders = { + orders: [], + signatures: [], + takerAssetFillAmounts, + }; + _.forEach(signedOrders, signedOrder => { + const orderWithoutExchangeAddress = orderUtils.getOrderWithoutExchangeAddress(signedOrder); + batchFill.orders.push(orderWithoutExchangeAddress); + batchFill.signatures.push(signedOrder.signature); + if (takerAssetFillAmounts.length < signedOrders.length) { + batchFill.takerAssetFillAmounts.push(signedOrder.takerAssetAmount); + } + }); + return batchFill; + }, + createMarketSellOrders(signedOrders: SignedOrder[], takerAssetFillAmount: BigNumber): MarketSellOrders { + const marketSellOrders: MarketSellOrders = { + orders: [], + signatures: [], + takerAssetFillAmount, + }; + _.forEach(signedOrders, (signedOrder, i) => { + const orderWithoutExchangeAddress = orderUtils.getOrderWithoutExchangeAddress(signedOrder); + if (i !== 0) { + orderWithoutExchangeAddress.takerAssetData = constants.NULL_BYTES; + } + marketSellOrders.orders.push(orderWithoutExchangeAddress); + marketSellOrders.signatures.push(signedOrder.signature); + }); + return marketSellOrders; + }, + createMarketBuyOrders(signedOrders: SignedOrder[], makerAssetFillAmount: BigNumber): MarketBuyOrders { + const marketBuyOrders: MarketBuyOrders = { + orders: [], + signatures: [], + makerAssetFillAmount, + }; + _.forEach(signedOrders, (signedOrder, i) => { + const orderWithoutExchangeAddress = orderUtils.getOrderWithoutExchangeAddress(signedOrder); + if (i !== 0) { + orderWithoutExchangeAddress.makerAssetData = constants.NULL_BYTES; + } + marketBuyOrders.orders.push(orderWithoutExchangeAddress); + marketBuyOrders.signatures.push(signedOrder.signature); + }); + return marketBuyOrders; + }, + createBatchCancel(signedOrders: SignedOrder[]): BatchCancelOrders { + const batchCancel: BatchCancelOrders = { + orders: [], + }; + _.forEach(signedOrders, signedOrder => { + const orderWithoutExchangeAddress = orderUtils.getOrderWithoutExchangeAddress(signedOrder); + batchCancel.orders.push(orderWithoutExchangeAddress); + }); + return batchCancel; + }, +}; diff --git a/contracts/test-utils/src/global_hooks.ts b/contracts/test-utils/src/global_hooks.ts new file mode 100644 index 000000000..307dd0777 --- /dev/null +++ b/contracts/test-utils/src/global_hooks.ts @@ -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(); + } +}); diff --git a/contracts/test-utils/src/index.ts b/contracts/test-utils/src/index.ts new file mode 100644 index 000000000..efd57903c --- /dev/null +++ b/contracts/test-utils/src/index.ts @@ -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'; diff --git a/contracts/test-utils/src/log_decoder.ts b/contracts/test-utils/src/log_decoder.ts new file mode 100644 index 000000000..54666ea5f --- /dev/null +++ b/contracts/test-utils/src/log_decoder.ts @@ -0,0 +1,51 @@ +import { AbiDecoder, BigNumber } from '@0x/utils'; +import { Web3Wrapper } from '@0x/web3-wrapper'; +import { + AbiDefinition, + ContractArtifact, + DecodedLogArgs, + LogEntry, + LogWithDecodedArgs, + RawLog, + TransactionReceiptWithDecodedLogs, +} from 'ethereum-types'; +import * as _ from 'lodash'; + +import { constants } from './constants'; + +export class LogDecoder { + private readonly _web3Wrapper: Web3Wrapper; + private readonly _abiDecoder: AbiDecoder; + public static wrapLogBigNumbers(log: any): any { + const argNames = _.keys(log.args); + for (const argName of argNames) { + const isWeb3BigNumber = _.startsWith(log.args[argName].constructor.toString(), 'function BigNumber('); + if (isWeb3BigNumber) { + log.args[argName] = new BigNumber(log.args[argName]); + } + } + } + constructor(web3Wrapper: Web3Wrapper, artifacts: { [contractName: string]: ContractArtifact }) { + this._web3Wrapper = web3Wrapper; + const abiArrays: AbiDefinition[][] = []; + _.forEach(artifacts, (artifact: ContractArtifact) => { + const compilerOutput = artifact.compilerOutput; + abiArrays.push(compilerOutput.abi); + }); + this._abiDecoder = new AbiDecoder(abiArrays); + } + public decodeLogOrThrow(log: LogEntry): LogWithDecodedArgs | RawLog { + const logWithDecodedArgsOrLog = this._abiDecoder.tryToDecodeLogOrNoop(log); + // tslint:disable-next-line:no-unnecessary-type-assertion + if (_.isUndefined((logWithDecodedArgsOrLog as LogWithDecodedArgs).args)) { + throw new Error(`Unable to decode log: ${JSON.stringify(log)}`); + } + LogDecoder.wrapLogBigNumbers(logWithDecodedArgsOrLog); + return logWithDecodedArgsOrLog; + } + public async getTxWithDecodedLogsAsync(txHash: string): Promise { + const tx = await this._web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS); + tx.logs = _.map(tx.logs, log => this.decodeLogOrThrow(log)); + return tx; + } +} diff --git a/contracts/test-utils/src/order_factory.ts b/contracts/test-utils/src/order_factory.ts new file mode 100644 index 000000000..2449d1a8a --- /dev/null +++ b/contracts/test-utils/src/order_factory.ts @@ -0,0 +1,38 @@ +import { generatePseudoRandomSalt, orderHashUtils } from '@0x/order-utils'; +import { Order, SignatureType, SignedOrder } from '@0x/types'; +import { BigNumber } from '@0x/utils'; + +import { getLatestBlockTimestampAsync } from './block_timestamp'; +import { constants } from './constants'; +import { signingUtils } from './signing_utils'; + +export class OrderFactory { + private readonly _defaultOrderParams: Partial; + private readonly _privateKey: Buffer; + constructor(privateKey: Buffer, defaultOrderParams: Partial) { + this._defaultOrderParams = defaultOrderParams; + this._privateKey = privateKey; + } + public async newSignedOrderAsync( + customOrderParams: Partial = {}, + signatureType: SignatureType = SignatureType.EthSign, + ): Promise { + const tenMinutesInSeconds = 10 * 60; + const currentBlockTimestamp = await getLatestBlockTimestampAsync(); + const order = ({ + senderAddress: constants.NULL_ADDRESS, + expirationTimeSeconds: new BigNumber(currentBlockTimestamp).add(tenMinutesInSeconds), + salt: generatePseudoRandomSalt(), + takerAddress: constants.NULL_ADDRESS, + ...this._defaultOrderParams, + ...customOrderParams, + } as any) as Order; + const orderHashBuff = orderHashUtils.getOrderHashBuffer(order); + const signature = signingUtils.signMessage(orderHashBuff, this._privateKey, signatureType); + const signedOrder = { + ...order, + signature: `0x${signature.toString('hex')}`, + }; + return signedOrder; + } +} diff --git a/contracts/test-utils/src/order_utils.ts b/contracts/test-utils/src/order_utils.ts new file mode 100644 index 000000000..4f7a34011 --- /dev/null +++ b/contracts/test-utils/src/order_utils.ts @@ -0,0 +1,58 @@ +import { OrderWithoutExchangeAddress, SignedOrder } from '@0x/types'; +import { BigNumber } from '@0x/utils'; + +import { constants } from './constants'; +import { CancelOrder, MatchOrder } from './types'; + +export const orderUtils = { + getPartialAmountFloor(numerator: BigNumber, denominator: BigNumber, target: BigNumber): BigNumber { + const partialAmount = numerator + .mul(target) + .div(denominator) + .floor(); + return partialAmount; + }, + createFill: (signedOrder: SignedOrder, takerAssetFillAmount?: BigNumber) => { + const fill = { + order: orderUtils.getOrderWithoutExchangeAddress(signedOrder), + takerAssetFillAmount: takerAssetFillAmount || signedOrder.takerAssetAmount, + signature: signedOrder.signature, + }; + return fill; + }, + createCancel(signedOrder: SignedOrder, takerAssetCancelAmount?: BigNumber): CancelOrder { + const cancel = { + order: orderUtils.getOrderWithoutExchangeAddress(signedOrder), + takerAssetCancelAmount: takerAssetCancelAmount || signedOrder.takerAssetAmount, + }; + return cancel; + }, + getOrderWithoutExchangeAddress(signedOrder: SignedOrder): OrderWithoutExchangeAddress { + const orderStruct = { + senderAddress: signedOrder.senderAddress, + makerAddress: signedOrder.makerAddress, + takerAddress: signedOrder.takerAddress, + feeRecipientAddress: signedOrder.feeRecipientAddress, + makerAssetAmount: signedOrder.makerAssetAmount, + takerAssetAmount: signedOrder.takerAssetAmount, + makerFee: signedOrder.makerFee, + takerFee: signedOrder.takerFee, + expirationTimeSeconds: signedOrder.expirationTimeSeconds, + salt: signedOrder.salt, + makerAssetData: signedOrder.makerAssetData, + takerAssetData: signedOrder.takerAssetData, + }; + return orderStruct; + }, + createMatchOrders(signedOrderLeft: SignedOrder, signedOrderRight: SignedOrder): MatchOrder { + const fill = { + left: orderUtils.getOrderWithoutExchangeAddress(signedOrderLeft), + right: orderUtils.getOrderWithoutExchangeAddress(signedOrderRight), + leftSignature: signedOrderLeft.signature, + rightSignature: signedOrderRight.signature, + }; + fill.right.makerAssetData = constants.NULL_BYTES; + fill.right.takerAssetData = constants.NULL_BYTES; + return fill; + }, +}; diff --git a/contracts/test-utils/src/profiler.ts b/contracts/test-utils/src/profiler.ts new file mode 100644 index 000000000..2c7c1d66c --- /dev/null +++ b/contracts/test-utils/src/profiler.ts @@ -0,0 +1,27 @@ +import { devConstants } from '@0x/dev-utils'; +import { ProfilerSubprovider, SolCompilerArtifactAdapter } from '@0x/sol-cov'; +import * as _ from 'lodash'; + +let profilerSubprovider: ProfilerSubprovider; + +export const profiler = { + start(): void { + profiler.getProfilerSubproviderSingleton().start(); + }, + stop(): void { + profiler.getProfilerSubproviderSingleton().stop(); + }, + getProfilerSubproviderSingleton(): ProfilerSubprovider { + if (_.isUndefined(profilerSubprovider)) { + profilerSubprovider = profiler._getProfilerSubprovider(); + } + return profilerSubprovider; + }, + _getProfilerSubprovider(): ProfilerSubprovider { + const defaultFromAddress = devConstants.TESTRPC_FIRST_ADDRESS; + const solCompilerArtifactAdapter = new SolCompilerArtifactAdapter(); + const isVerbose = true; + const subprovider = new ProfilerSubprovider(solCompilerArtifactAdapter, defaultFromAddress, isVerbose); + return subprovider; + }, +}; diff --git a/contracts/test-utils/src/revert_trace.ts b/contracts/test-utils/src/revert_trace.ts new file mode 100644 index 000000000..3f74fd28b --- /dev/null +++ b/contracts/test-utils/src/revert_trace.ts @@ -0,0 +1,21 @@ +import { devConstants } from '@0x/dev-utils'; +import { RevertTraceSubprovider, SolCompilerArtifactAdapter } from '@0x/sol-cov'; +import * as _ from 'lodash'; + +let revertTraceSubprovider: RevertTraceSubprovider; + +export const revertTrace = { + getRevertTraceSubproviderSingleton(): RevertTraceSubprovider { + if (_.isUndefined(revertTraceSubprovider)) { + revertTraceSubprovider = revertTrace._getRevertTraceSubprovider(); + } + return revertTraceSubprovider; + }, + _getRevertTraceSubprovider(): RevertTraceSubprovider { + const defaultFromAddress = devConstants.TESTRPC_FIRST_ADDRESS; + const solCompilerArtifactAdapter = new SolCompilerArtifactAdapter(); + const isVerbose = true; + const subprovider = new RevertTraceSubprovider(solCompilerArtifactAdapter, defaultFromAddress, isVerbose); + return subprovider; + }, +}; diff --git a/contracts/test-utils/src/signing_utils.ts b/contracts/test-utils/src/signing_utils.ts new file mode 100644 index 000000000..21f864bfa --- /dev/null +++ b/contracts/test-utils/src/signing_utils.ts @@ -0,0 +1,29 @@ +import { SignatureType } from '@0x/types'; +import * as ethUtil from 'ethereumjs-util'; + +export const signingUtils = { + signMessage(message: Buffer, privateKey: Buffer, signatureType: SignatureType): Buffer { + if (signatureType === SignatureType.EthSign) { + const prefixedMessage = ethUtil.hashPersonalMessage(message); + const ecSignature = ethUtil.ecsign(prefixedMessage, privateKey); + const signature = Buffer.concat([ + ethUtil.toBuffer(ecSignature.v), + ecSignature.r, + ecSignature.s, + ethUtil.toBuffer(signatureType), + ]); + return signature; + } else if (signatureType === SignatureType.EIP712) { + const ecSignature = ethUtil.ecsign(message, privateKey); + const signature = Buffer.concat([ + ethUtil.toBuffer(ecSignature.v), + ecSignature.r, + ecSignature.s, + ethUtil.toBuffer(signatureType), + ]); + return signature; + } else { + throw new Error(`${signatureType} is not a valid signature type`); + } + }, +}; diff --git a/contracts/test-utils/src/test_with_reference.ts b/contracts/test-utils/src/test_with_reference.ts new file mode 100644 index 000000000..b80be4a6c --- /dev/null +++ b/contracts/test-utils/src/test_with_reference.ts @@ -0,0 +1,139 @@ +import * as chai from 'chai'; +import * as _ from 'lodash'; + +import { chaiSetup } from './chai_setup'; + +chaiSetup.configure(); +const expect = chai.expect; + +class Value { + public value: T; + constructor(value: T) { + this.value = value; + } +} + +// tslint:disable-next-line: max-classes-per-file +class ErrorMessage { + public error: string; + constructor(message: string) { + this.error = message; + } +} + +type PromiseResult = Value | ErrorMessage; + +// TODO(albrow): This seems like a generic utility function that could exist in +// lodash. We should replace it by a library implementation, or move it to our +// own. +async function evaluatePromise(promise: Promise): Promise> { + try { + return new Value(await promise); + } catch (e) { + return new ErrorMessage(e.message); + } +} + +export async function testWithReferenceFuncAsync( + referenceFunc: (p0: P0) => Promise, + testFunc: (p0: P0) => Promise, + values: [P0], +): Promise; +export async function testWithReferenceFuncAsync( + referenceFunc: (p0: P0, p1: P1) => Promise, + testFunc: (p0: P0, p1: P1) => Promise, + values: [P0, P1], +): Promise; +export async function testWithReferenceFuncAsync( + referenceFunc: (p0: P0, p1: P1, p2: P2) => Promise, + testFunc: (p0: P0, p1: P1, p2: P2) => Promise, + values: [P0, P1, P2], +): Promise; +export async function testWithReferenceFuncAsync( + referenceFunc: (p0: P0, p1: P1, p2: P2, p3: P3) => Promise, + testFunc: (p0: P0, p1: P1, p2: P2, p3: P3) => Promise, + values: [P0, P1, P2, P3], +): Promise; +export async function testWithReferenceFuncAsync( + referenceFunc: (p0: P0, p1: P1, p2: P2, p3: P3, p4: P4) => Promise, + testFunc: (p0: P0, p1: P1, p2: P2, p3: P3, p4: P4) => Promise, + values: [P0, P1, P2, P3, P4], +): Promise; + +/** + * Tests the behavior of a test function by comparing it to the expected + * behavior (defined by a reference function). + * + * 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". The test 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. + * + * @param referenceFuncAsync a reference function implemented in pure + * JavaScript/TypeScript which accepts N arguments and returns the "expected + * result" or throws/rejects with the "expected error". + * @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 throws/rejects with the "actual error". + * @param values an array of N values, where each value corresponds in-order to + * an argument to both the test function and the reference 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 testWithReferenceFuncAsync( + referenceFuncAsync: (...args: any[]) => Promise, + testFuncAsync: (...args: any[]) => Promise, + values: any[], +): Promise { + // Measure correct behaviour + const expected = await evaluatePromise(referenceFuncAsync(...values)); + + // Measure actual behaviour + const actual = await evaluatePromise(testFuncAsync(...values)); + + // Compare behaviour + if (expected instanceof ErrorMessage) { + // If we expected an error, check if the actual error message contains the + // expected error message. + if (!(actual instanceof ErrorMessage)) { + throw new Error( + `Expected error containing ${expected.error} but got no error\n\tTest case: ${_getTestCaseString( + referenceFuncAsync, + values, + )}`, + ); + } + expect(actual.error).to.contain( + expected.error, + `${actual.error}\n\tTest case: ${_getTestCaseString(referenceFuncAsync, values)}`, + ); + } else { + // If we do not expect an error, compare actual and expected directly. + expect(actual).to.deep.equal(expected, `Test case ${_getTestCaseString(referenceFuncAsync, values)}`); + } +} + +function _getTestCaseString(referenceFuncAsync: (...args: any[]) => Promise, values: any[]): string { + const paramNames = _getParameterNames(referenceFuncAsync); + return JSON.stringify(_.zipObject(paramNames, values)); +} + +// Source: https://stackoverflow.com/questions/1007981/how-to-get-function-parameter-names-values-dynamically +function _getParameterNames(func: (...args: any[]) => any): string[] { + return _.toString(func) + .replace(/[/][/].*$/gm, '') // strip single-line comments + .replace(/\s+/g, '') // strip white space + .replace(/[/][*][^/*]*[*][/]/g, '') // strip multi-line comments + .split('){', 1)[0] + .replace(/^[^(]*[(]/, '') // extract the parameters + .replace(/=[^,]+/g, '') // strip any ES6 defaults + .split(',') + .filter(Boolean); // split & filter [""] +} diff --git a/contracts/test-utils/src/transaction_factory.ts b/contracts/test-utils/src/transaction_factory.ts new file mode 100644 index 000000000..dbab3ade4 --- /dev/null +++ b/contracts/test-utils/src/transaction_factory.ts @@ -0,0 +1,37 @@ +import { eip712Utils, generatePseudoRandomSalt } from '@0x/order-utils'; +import { SignatureType } from '@0x/types'; +import { signTypedDataUtils } from '@0x/utils'; +import * as ethUtil from 'ethereumjs-util'; + +import { signingUtils } from './signing_utils'; +import { SignedTransaction } from './types'; + +export class TransactionFactory { + private readonly _signerBuff: Buffer; + private readonly _exchangeAddress: string; + private readonly _privateKey: Buffer; + constructor(privateKey: Buffer, exchangeAddress: string) { + this._privateKey = privateKey; + this._exchangeAddress = exchangeAddress; + this._signerBuff = ethUtil.privateToAddress(this._privateKey); + } + public newSignedTransaction(data: string, signatureType: SignatureType = SignatureType.EthSign): SignedTransaction { + const salt = generatePseudoRandomSalt(); + const signerAddress = `0x${this._signerBuff.toString('hex')}`; + const executeTransactionData = { + salt, + signerAddress, + data, + }; + + const typedData = eip712Utils.createZeroExTransactionTypedData(executeTransactionData, this._exchangeAddress); + const eip712MessageBuffer = signTypedDataUtils.generateTypedDataHash(typedData); + const signature = signingUtils.signMessage(eip712MessageBuffer, this._privateKey, signatureType); + const signedTx = { + exchangeAddress: this._exchangeAddress, + signature: `0x${signature.toString('hex')}`, + ...executeTransactionData, + }; + return signedTx; + } +} diff --git a/contracts/test-utils/src/type_encoding_utils.ts b/contracts/test-utils/src/type_encoding_utils.ts new file mode 100644 index 000000000..bfd9c9ef5 --- /dev/null +++ b/contracts/test-utils/src/type_encoding_utils.ts @@ -0,0 +1,21 @@ +import { BigNumber } from '@0x/utils'; +import BN = require('bn.js'); +import ethUtil = require('ethereumjs-util'); + +import { constants } from './constants'; + +export const typeEncodingUtils = { + encodeUint256(value: BigNumber): Buffer { + const base = 10; + const formattedValue = new BN(value.toString(base)); + const encodedValue = ethUtil.toBuffer(formattedValue); + // tslint:disable-next-line:custom-no-magic-numbers + const paddedValue = ethUtil.setLengthLeft(encodedValue, constants.WORD_LENGTH); + return paddedValue; + }, + decodeUint256(encodedValue: Buffer): BigNumber { + const formattedValue = ethUtil.bufferToHex(encodedValue); + const value = new BigNumber(formattedValue, constants.BASE_16); + return value; + }, +}; diff --git a/contracts/test-utils/src/types.ts b/contracts/test-utils/src/types.ts new file mode 100644 index 000000000..9fc9e1570 --- /dev/null +++ b/contracts/test-utils/src/types.ts @@ -0,0 +1,241 @@ +import { OrderWithoutExchangeAddress } from '@0x/types'; +import { BigNumber } from '@0x/utils'; +import { AbiDefinition } from 'ethereum-types'; + +export interface ERC20BalancesByOwner { + [ownerAddress: string]: { + [tokenAddress: string]: BigNumber; + }; +} + +export interface ERC721TokenIdsByOwner { + [ownerAddress: string]: { + [tokenAddress: string]: BigNumber[]; + }; +} + +export interface SubmissionContractEventArgs { + transactionId: BigNumber; +} + +export interface BatchFillOrders { + orders: OrderWithoutExchangeAddress[]; + signatures: string[]; + takerAssetFillAmounts: BigNumber[]; +} + +export interface MarketSellOrders { + orders: OrderWithoutExchangeAddress[]; + signatures: string[]; + takerAssetFillAmount: BigNumber; +} + +export interface MarketBuyOrders { + orders: OrderWithoutExchangeAddress[]; + signatures: string[]; + makerAssetFillAmount: BigNumber; +} + +export interface BatchCancelOrders { + orders: OrderWithoutExchangeAddress[]; +} + +export interface CancelOrdersBefore { + salt: BigNumber; +} + +export interface TransactionDataParams { + name: string; + abi: AbiDefinition[]; + args: any[]; +} + +export interface MultiSigConfig { + owners: string[]; + confirmationsRequired: number; + secondsRequired: number; +} + +export interface MultiSigConfigByNetwork { + [networkName: string]: MultiSigConfig; +} + +export interface Token { + address?: string; + name: string; + symbol: string; + decimals: number; + ipfsHash: string; + swarmHash: string; +} + +export enum OrderStatus { + INVALID, + INVALID_MAKER_ASSET_AMOUNT, + INVALID_TAKER_ASSET_AMOUNT, + FILLABLE, + EXPIRED, + FULLY_FILLED, + CANCELLED, +} + +export enum ContractName { + TokenRegistry = 'TokenRegistry', + MultiSigWalletWithTimeLock = 'MultiSigWalletWithTimeLock', + Exchange = 'Exchange', + ZRXToken = 'ZRXToken', + DummyERC20Token = 'DummyERC20Token', + EtherToken = 'WETH9', + AssetProxyOwner = 'AssetProxyOwner', + AccountLevels = 'AccountLevels', + EtherDelta = 'EtherDelta', + Arbitrage = 'Arbitrage', + TestAssetDataDecoders = 'TestAssetDataDecoders', + TestAssetProxyDispatcher = 'TestAssetProxyDispatcher', + TestLibs = 'TestLibs', + TestSignatureValidator = 'TestSignatureValidator', + ERC20Proxy = 'ERC20Proxy', + ERC721Proxy = 'ERC721Proxy', + DummyERC721Receiver = 'DummyERC721Receiver', + DummyERC721Token = 'DummyERC721Token', + TestLibBytes = 'TestLibBytes', + TestWallet = 'TestWallet', + Authorizable = 'Authorizable', + Whitelist = 'Whitelist', + Forwarder = 'Forwarder', +} + +export interface SignedTransaction { + exchangeAddress: string; + salt: BigNumber; + signerAddress: string; + data: string; + signature: string; +} + +export interface TransferAmountsByMatchOrders { + // Left Maker + amountBoughtByLeftMaker: BigNumber; + amountSoldByLeftMaker: BigNumber; + feePaidByLeftMaker: BigNumber; + // Right Maker + amountBoughtByRightMaker: BigNumber; + amountSoldByRightMaker: BigNumber; + feePaidByRightMaker: BigNumber; + // Taker + amountReceivedByTaker: BigNumber; + feePaidByTakerLeft: BigNumber; + feePaidByTakerRight: BigNumber; +} + +export interface TransferAmountsLoggedByMatchOrders { + makerAddress: string; + takerAddress: string; + makerAssetFilledAmount: string; + takerAssetFilledAmount: string; + makerFeePaid: string; + takerFeePaid: string; +} + +export interface OrderInfo { + orderStatus: number; + orderHash: string; + orderTakerAssetFilledAmount: BigNumber; +} + +export interface CancelOrder { + order: OrderWithoutExchangeAddress; + takerAssetCancelAmount: BigNumber; +} + +export interface MatchOrder { + left: OrderWithoutExchangeAddress; + right: OrderWithoutExchangeAddress; + leftSignature: string; + rightSignature: string; +} + +// Combinatorial testing types + +export enum FeeRecipientAddressScenario { + BurnAddress = 'BURN_ADDRESS', + EthUserAddress = 'ETH_USER_ADDRESS', +} + +export enum OrderAssetAmountScenario { + Zero = 'ZERO', + Large = 'LARGE', + Small = 'SMALL', +} + +export enum TakerScenario { + CorrectlySpecified = 'CORRECTLY_SPECIFIED', + IncorrectlySpecified = 'INCORRECTLY_SPECIFIED', + Unspecified = 'UNSPECIFIED', +} + +export enum ExpirationTimeSecondsScenario { + InPast = 'IN_PAST', + InFuture = 'IN_FUTURE', +} + +export enum AssetDataScenario { + ERC20ZeroDecimals = 'ERC20_ZERO_DECIMALS', + ZRXFeeToken = 'ZRX_FEE_TOKEN', + ERC20FiveDecimals = 'ERC20_FIVE_DECIMALS', + ERC20NonZRXEighteenDecimals = 'ERC20_NON_ZRX_EIGHTEEN_DECIMALS', + ERC721 = 'ERC721', +} + +export enum TakerAssetFillAmountScenario { + Zero = 'ZERO', + GreaterThanRemainingFillableTakerAssetAmount = 'GREATER_THAN_REMAINING_FILLABLE_TAKER_ASSET_AMOUNT', + LessThanRemainingFillableTakerAssetAmount = 'LESS_THAN_REMAINING_FILLABLE_TAKER_ASSET_AMOUNT', + ExactlyRemainingFillableTakerAssetAmount = 'EXACTLY_REMAINING_FILLABLE_TAKER_ASSET_AMOUNT', +} + +export interface OrderScenario { + takerScenario: TakerScenario; + feeRecipientScenario: FeeRecipientAddressScenario; + makerAssetAmountScenario: OrderAssetAmountScenario; + takerAssetAmountScenario: OrderAssetAmountScenario; + makerFeeScenario: OrderAssetAmountScenario; + takerFeeScenario: OrderAssetAmountScenario; + expirationTimeSecondsScenario: ExpirationTimeSecondsScenario; + makerAssetDataScenario: AssetDataScenario; + takerAssetDataScenario: AssetDataScenario; +} + +export enum BalanceAmountScenario { + Exact = 'EXACT', + TooLow = 'TOO_LOW', + Higher = 'HIGHER', +} + +export enum AllowanceAmountScenario { + Exact = 'EXACT', + TooLow = 'TOO_LOW', + Higher = 'HIGHER', + Unlimited = 'UNLIMITED', +} + +export interface TraderStateScenario { + traderAssetBalance: BalanceAmountScenario; + traderAssetAllowance: AllowanceAmountScenario; + zrxFeeBalance: BalanceAmountScenario; + zrxFeeAllowance: AllowanceAmountScenario; +} + +export interface FillScenario { + orderScenario: OrderScenario; + takerAssetFillAmountScenario: TakerAssetFillAmountScenario; + makerStateScenario: TraderStateScenario; + takerStateScenario: TraderStateScenario; +} + +export interface FillResults { + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + makerFeePaid: BigNumber; + takerFeePaid: BigNumber; +} diff --git a/contracts/test-utils/src/web3_wrapper.ts b/contracts/test-utils/src/web3_wrapper.ts new file mode 100644 index 000000000..f7b1a732a --- /dev/null +++ b/contracts/test-utils/src/web3_wrapper.ts @@ -0,0 +1,84 @@ +import { devConstants, env, EnvVars, web3Factory } from '@0x/dev-utils'; +import { prependSubprovider, Web3ProviderEngine } from '@0x/subproviders'; +import { logUtils } from '@0x/utils'; +import { Web3Wrapper } from '@0x/web3-wrapper'; +import * as _ from 'lodash'; + +import { coverage } from './coverage'; +import { profiler } from './profiler'; +import { revertTrace } from './revert_trace'; + +enum ProviderType { + Ganache = 'ganache', + Geth = 'geth', +} + +let testProvider: ProviderType; +switch (process.env.TEST_PROVIDER) { + case undefined: + testProvider = ProviderType.Ganache; + break; + case 'ganache': + testProvider = ProviderType.Ganache; + break; + case 'geth': + testProvider = ProviderType.Geth; + break; + default: + throw new Error(`Unknown TEST_PROVIDER: ${process.env.TEST_PROVIDER}`); +} + +const ganacheTxDefaults = { + from: devConstants.TESTRPC_FIRST_ADDRESS, + gas: devConstants.GAS_LIMIT, +}; +const gethTxDefaults = { + from: devConstants.TESTRPC_FIRST_ADDRESS, +}; +export const txDefaults = testProvider === ProviderType.Ganache ? ganacheTxDefaults : gethTxDefaults; + +const gethConfigs = { + shouldUseInProcessGanache: false, + rpcUrl: 'http://localhost:8501', + shouldUseFakeGasEstimate: false, +}; +const ganacheConfigs = { + shouldUseInProcessGanache: true, +}; +const providerConfigs = testProvider === ProviderType.Ganache ? ganacheConfigs : gethConfigs; + +export const provider: Web3ProviderEngine = web3Factory.getRpcProvider(providerConfigs); +const isCoverageEnabled = env.parseBoolean(EnvVars.SolidityCoverage); +const isProfilerEnabled = env.parseBoolean(EnvVars.SolidityProfiler); +const isRevertTraceEnabled = env.parseBoolean(EnvVars.SolidityRevertTrace); +const enabledSubproviderCount = _.filter( + [isCoverageEnabled, isProfilerEnabled, isRevertTraceEnabled], + _.identity.bind(_), +).length; +if (enabledSubproviderCount > 1) { + throw new Error(`Only one of coverage, profiler, or revert trace subproviders can be enabled at a time`); +} +if (isCoverageEnabled) { + const coverageSubprovider = coverage.getCoverageSubproviderSingleton(); + prependSubprovider(provider, coverageSubprovider); +} +if (isProfilerEnabled) { + if (testProvider === ProviderType.Ganache) { + logUtils.warn( + "Gas costs in Ganache traces are incorrect and we don't recommend using it for profiling. Please switch to Geth", + ); + process.exit(1); + } + const profilerSubprovider = profiler.getProfilerSubproviderSingleton(); + logUtils.log( + "By default profilerSubprovider is stopped so that you don't get noise from setup code. Don't forget to start it before the code you want to profile and stop it afterwards", + ); + profilerSubprovider.stop(); + prependSubprovider(provider, profilerSubprovider); +} +if (isRevertTraceEnabled) { + const revertTraceSubprovider = revertTrace.getRevertTraceSubproviderSingleton(); + prependSubprovider(provider, revertTraceSubprovider); +} + +export const web3Wrapper = new Web3Wrapper(provider); diff --git a/contracts/test-utils/test/test_with_reference.ts b/contracts/test-utils/test/test_with_reference.ts new file mode 100644 index 000000000..1c1211003 --- /dev/null +++ b/contracts/test-utils/test/test_with_reference.ts @@ -0,0 +1,63 @@ +import * as chai from 'chai'; + +import { chaiSetup } from '../src/chai_setup'; +import { testWithReferenceFuncAsync } from '../src/test_with_reference'; + +chaiSetup.configure(); +const expect = chai.expect; + +async function divAsync(x: number, y: number): Promise { + if (y === 0) { + throw new Error('MathError: divide by zero'); + } + return x / y; +} + +// returns an async function that always returns the given value. +function alwaysValueFunc(value: number): (x: number, y: number) => Promise { + return async (x: number, y: number) => value; +} + +// returns an async function which always throws/rejects with the given error +// message. +function alwaysFailFunc(errMessage: string): (x: number, y: number) => Promise { + return async (x: number, y: number) => { + throw new Error(errMessage); + }; +} + +describe('testWithReferenceFuncAsync', () => { + it('passes when both succeed and actual === expected', async () => { + await testWithReferenceFuncAsync(alwaysValueFunc(0.5), divAsync, [1, 2]); + }); + + it('passes when both fail and actual error contains expected error', async () => { + await testWithReferenceFuncAsync(alwaysFailFunc('divide by zero'), divAsync, [1, 0]); + }); + + it('fails when both succeed and actual !== expected', async () => { + expect(testWithReferenceFuncAsync(alwaysValueFunc(3), divAsync, [1, 2])).to.be.rejectedWith( + 'Test case {"x":1,"y":2}: expected { value: 0.5 } to deeply equal { value: 3 }', + ); + }); + + it('fails when both fail and actual error does not contain expected error', async () => { + expect( + testWithReferenceFuncAsync(alwaysFailFunc('Unexpected math error'), divAsync, [1, 0]), + ).to.be.rejectedWith( + 'MathError: divide by zero\n\tTest case: {"x":1,"y":0}: expected \'MathError: divide by zero\' to include \'Unexpected math error\'', + ); + }); + + it('fails when referenceFunc succeeds and testFunc fails', async () => { + expect(testWithReferenceFuncAsync(alwaysValueFunc(0), divAsync, [1, 0])).to.be.rejectedWith( + 'Test case {"x":1,"y":0}: expected { error: \'MathError: divide by zero\' } to deeply equal { value: 0 }', + ); + }); + + it('fails when referenceFunc fails and testFunc succeeds', async () => { + expect(testWithReferenceFuncAsync(alwaysFailFunc('divide by zero'), divAsync, [1, 2])).to.be.rejectedWith( + 'Expected error containing divide by zero but got no error\n\tTest case: {"x":1,"y":2}', + ); + }); +}); diff --git a/contracts/test-utils/tsconfig.json b/contracts/test-utils/tsconfig.json new file mode 100644 index 000000000..e35816553 --- /dev/null +++ b/contracts/test-utils/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "../../tsconfig", + "compilerOptions": { + "outDir": "lib" + }, + "include": ["./src/**/*", "./test/**/*"] +} diff --git a/contracts/test-utils/tslint.json b/contracts/test-utils/tslint.json new file mode 100644 index 000000000..1bb3ac2a2 --- /dev/null +++ b/contracts/test-utils/tslint.json @@ -0,0 +1,6 @@ +{ + "extends": ["@0x/tslint-config"], + "rules": { + "custom-no-magic-numbers": false + } +} -- cgit v1.2.3