diff options
author | Amir Bandeali <abandeali1@gmail.com> | 2018-05-31 08:53:22 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-31 08:53:22 +0800 |
commit | 5b31d0aa3635ea524fb42d73cd6c713887dfef6a (patch) | |
tree | 5d80666f6521737879e2e700afd5ef1d1a55b0e6 | |
parent | c0cf55b40bb4a13cfd94a506bf125f6eb57c6767 (diff) | |
parent | 79e7c44884f81f12733d555314c54d4c912f0e88 (diff) | |
download | dexon-sol-tools-5b31d0aa3635ea524fb42d73cd6c713887dfef6a.tar.gz dexon-sol-tools-5b31d0aa3635ea524fb42d73cd6c713887dfef6a.tar.zst dexon-sol-tools-5b31d0aa3635ea524fb42d73cd6c713887dfef6a.zip |
Merge pull request #561 from 0xProject/feature/contracts/txorigin
Add Validator signature type
46 files changed, 955 insertions, 154 deletions
diff --git a/packages/0x.js/test/global_hooks.ts b/packages/0x.js/test/global_hooks.ts index d9768e61c..6d2c3219b 100644 --- a/packages/0x.js/test/global_hooks.ts +++ b/packages/0x.js/test/global_hooks.ts @@ -11,7 +11,7 @@ before('migrate contracts', async function(): Promise<void> { const mochaTestTimeoutMs = 20000; this.timeout(mochaTestTimeoutMs); const txDefaults = { - gas: devConstants.GAS_ESTIMATE, + gas: devConstants.GAS_LIMIT, from: devConstants.TESTRPC_FIRST_ADDRESS, }; const artifactsDir = `../migrations/artifacts/1.0.0`; diff --git a/packages/contract-wrappers/test/global_hooks.ts b/packages/contract-wrappers/test/global_hooks.ts index d9768e61c..6d2c3219b 100644 --- a/packages/contract-wrappers/test/global_hooks.ts +++ b/packages/contract-wrappers/test/global_hooks.ts @@ -11,7 +11,7 @@ before('migrate contracts', async function(): Promise<void> { const mochaTestTimeoutMs = 20000; this.timeout(mochaTestTimeoutMs); const txDefaults = { - gas: devConstants.GAS_ESTIMATE, + gas: devConstants.GAS_LIMIT, from: devConstants.TESTRPC_FIRST_ADDRESS, }; const artifactsDir = `../migrations/artifacts/1.0.0`; diff --git a/packages/contracts/compiler.json b/packages/contracts/compiler.json index 7d469d2c3..ed59069fe 100644 --- a/packages/contracts/compiler.json +++ b/packages/contracts/compiler.json @@ -33,6 +33,7 @@ "TestLibs", "TestSignatureValidator", "TokenRegistry", + "Whitelist", "WETH9", "ZRXToken" ] diff --git a/packages/contracts/package.json b/packages/contracts/package.json index 037cb7a04..7bd0cf571 100644 --- a/packages/contracts/package.json +++ b/packages/contracts/package.json @@ -29,7 +29,7 @@ "test:circleci": "yarn test" }, "config": { - "abis": "../migrations/artifacts/2.0.0/@(AssetProxyOwner|DummyERC20Token|DummyERC721Token|ERC20Proxy|ERC721Proxy|Exchange|MixinAuthorizable|MultiSigWallet|MultiSigWalletWithTimeLock||TestAssetProxyDispatcher|TestLibBytes|TestLibs|TestSignatureValidator|TokenRegistry|WETH9|ZRXToken).json" + "abis": "../migrations/artifacts/2.0.0/@(AssetProxyOwner|DummyERC20Token|DummyERC721Token|ERC20Proxy|ERC721Proxy|Exchange|MixinAuthorizable|MultiSigWallet|MultiSigWalletWithTimeLock|TestAssetProxyDispatcher|TestLibBytes|TestLibs|TestSignatureValidator|TokenRegistry|Whitelist|WETH9|ZRXToken).json" }, "repository": { "type": "git", diff --git a/packages/contracts/src/contracts/current/protocol/AssetProxy/ERC20Proxy.sol b/packages/contracts/src/contracts/current/protocol/AssetProxy/ERC20Proxy.sol index ee0c66fdc..79824fbbb 100644 --- a/packages/contracts/src/contracts/current/protocol/AssetProxy/ERC20Proxy.sol +++ b/packages/contracts/src/contracts/current/protocol/AssetProxy/ERC20Proxy.sol @@ -47,21 +47,25 @@ contract ERC20Proxy is bytes memory assetMetadata, address from, address to, - uint256 amount) + uint256 amount + ) internal { // Data must be intended for this proxy. + uint256 length = assetMetadata.length; + require( - uint8(assetMetadata[0]) == PROXY_ID, - PROXY_ID_MISMATCH + length == 21, + INVALID_METADATA_LENGTH ); - // Decode metadata. require( - assetMetadata.length == 21, - INVALID_METADATA_LENGTH + uint8(assetMetadata[length - 1]) == PROXY_ID, + PROXY_ID_MISMATCH ); - address token = readAddress(assetMetadata, 1); + + // Decode metadata. + address token = readAddress(assetMetadata, 0); // Transfer tokens. bool success = IERC20Token(token).transferFrom(from, to, amount); diff --git a/packages/contracts/src/contracts/current/protocol/AssetProxy/ERC721Proxy.sol b/packages/contracts/src/contracts/current/protocol/AssetProxy/ERC721Proxy.sol index 94aab9139..ace3570bc 100644 --- a/packages/contracts/src/contracts/current/protocol/AssetProxy/ERC721Proxy.sol +++ b/packages/contracts/src/contracts/current/protocol/AssetProxy/ERC721Proxy.sol @@ -47,12 +47,20 @@ contract ERC721Proxy is bytes memory assetMetadata, address from, address to, - uint256 amount) + uint256 amount + ) internal { // Data must be intended for this proxy. + uint256 length = assetMetadata.length; + + require( + length == 53, + INVALID_METADATA_LENGTH + ); + require( - uint8(assetMetadata[0]) == PROXY_ID, + uint8(assetMetadata[length - 1]) == PROXY_ID, PROXY_ID_MISMATCH ); @@ -63,12 +71,8 @@ contract ERC721Proxy is ); // Decode metadata - require( - assetMetadata.length == 53, - INVALID_METADATA_LENGTH - ); - address token = readAddress(assetMetadata, 1); - uint256 tokenId = readUint256(assetMetadata, 21); + address token = readAddress(assetMetadata, 0); + uint256 tokenId = readUint256(assetMetadata, 20); // Transfer token. // Either succeeds or throws. diff --git a/packages/contracts/src/contracts/current/protocol/AssetProxy/MixinAssetProxy.sol b/packages/contracts/src/contracts/current/protocol/AssetProxy/MixinAssetProxy.sol index 4ec31304f..4bd533148 100644 --- a/packages/contracts/src/contracts/current/protocol/AssetProxy/MixinAssetProxy.sol +++ b/packages/contracts/src/contracts/current/protocol/AssetProxy/MixinAssetProxy.sol @@ -36,7 +36,8 @@ contract MixinAssetProxy is bytes assetMetadata, address from, address to, - uint256 amount) + uint256 amount + ) external onlyAuthorized { @@ -57,7 +58,8 @@ contract MixinAssetProxy is bytes[] memory assetMetadata, address[] memory from, address[] memory to, - uint256[] memory amounts) + uint256[] memory amounts + ) public onlyAuthorized { diff --git a/packages/contracts/src/contracts/current/protocol/AssetProxy/MixinAuthorizable.sol b/packages/contracts/src/contracts/current/protocol/AssetProxy/MixinAuthorizable.sol index 0bbd3b318..4aaeb66d1 100644 --- a/packages/contracts/src/contracts/current/protocol/AssetProxy/MixinAuthorizable.sol +++ b/packages/contracts/src/contracts/current/protocol/AssetProxy/MixinAuthorizable.sol @@ -87,7 +87,10 @@ contract MixinAuthorizable is /// @dev Removes authorizion of an address. /// @param target Address to remove authorization from. /// @param index Index of target in authorities array. - function removeAuthorizedAddressAtIndex(address target, uint256 index) + function removeAuthorizedAddressAtIndex( + address target, + uint256 index + ) external { require( diff --git a/packages/contracts/src/contracts/current/protocol/AssetProxy/interfaces/IAssetProxy.sol b/packages/contracts/src/contracts/current/protocol/AssetProxy/interfaces/IAssetProxy.sol index 8b30dfabb..7e1848889 100644 --- a/packages/contracts/src/contracts/current/protocol/AssetProxy/interfaces/IAssetProxy.sol +++ b/packages/contracts/src/contracts/current/protocol/AssetProxy/interfaces/IAssetProxy.sol @@ -34,7 +34,8 @@ contract IAssetProxy is bytes assetMetadata, address from, address to, - uint256 amount) + uint256 amount + ) external; /// @dev Makes multiple transfers of assets. Either succeeds or throws. @@ -46,7 +47,8 @@ contract IAssetProxy is bytes[] memory assetMetadata, address[] memory from, address[] memory to, - uint256[] memory amounts) + uint256[] memory amounts + ) public; /// @dev Gets the proxy id associated with the proxy address. diff --git a/packages/contracts/src/contracts/current/protocol/AssetProxy/interfaces/IAuthorizable.sol b/packages/contracts/src/contracts/current/protocol/AssetProxy/interfaces/IAuthorizable.sol index d6fe03898..cedd1744c 100644 --- a/packages/contracts/src/contracts/current/protocol/AssetProxy/interfaces/IAuthorizable.sol +++ b/packages/contracts/src/contracts/current/protocol/AssetProxy/interfaces/IAuthorizable.sol @@ -45,6 +45,9 @@ contract IAuthorizable is /// @dev Removes authorizion of an address. /// @param target Address to remove authorization from. /// @param index Index of target in authorities array. - function removeAuthorizedAddressAtIndex(address target, uint256 index) + function removeAuthorizedAddressAtIndex( + address target, + uint256 index + ) external; } diff --git a/packages/contracts/src/contracts/current/protocol/AssetProxy/mixins/MAssetProxy.sol b/packages/contracts/src/contracts/current/protocol/AssetProxy/mixins/MAssetProxy.sol index 3800bf04c..de9d65a53 100644 --- a/packages/contracts/src/contracts/current/protocol/AssetProxy/mixins/MAssetProxy.sol +++ b/packages/contracts/src/contracts/current/protocol/AssetProxy/mixins/MAssetProxy.sol @@ -34,6 +34,7 @@ contract MAssetProxy is bytes memory assetMetadata, address from, address to, - uint256 amount) + uint256 amount + ) internal; } diff --git a/packages/contracts/src/contracts/current/protocol/AssetProxy/mixins/MAuthorizable.sol b/packages/contracts/src/contracts/current/protocol/AssetProxy/mixins/MAuthorizable.sol index cdf60bdee..6f35bd7ec 100644 --- a/packages/contracts/src/contracts/current/protocol/AssetProxy/mixins/MAuthorizable.sol +++ b/packages/contracts/src/contracts/current/protocol/AssetProxy/mixins/MAuthorizable.sol @@ -38,5 +38,5 @@ contract MAuthorizable is ); /// @dev Only authorized addresses can invoke functions with this modifier. - modifier onlyAuthorized { _; } + modifier onlyAuthorized { revert(); _; } } diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/MixinAssetProxyDispatcher.sol b/packages/contracts/src/contracts/current/protocol/Exchange/MixinAssetProxyDispatcher.sol index 3b38d1f37..d996f933c 100644 --- a/packages/contracts/src/contracts/current/protocol/Exchange/MixinAssetProxyDispatcher.sol +++ b/packages/contracts/src/contracts/current/protocol/Exchange/MixinAssetProxyDispatcher.sol @@ -39,7 +39,8 @@ contract MixinAssetProxyDispatcher is function registerAssetProxy( uint8 assetProxyId, address newAssetProxy, - address oldAssetProxy) + address oldAssetProxy + ) external onlyOwner { @@ -86,17 +87,20 @@ contract MixinAssetProxyDispatcher is bytes memory assetMetadata, address from, address to, - uint256 amount) + uint256 amount + ) internal { // Do nothing if no amount should be transferred. if (amount > 0) { + // Lookup asset proxy + uint256 length = assetMetadata.length; require( - assetMetadata.length >= 1, + length > 0, GT_ZERO_LENGTH_REQUIRED ); - uint8 assetProxyId = uint8(assetMetadata[0]); + uint8 assetProxyId = uint8(assetMetadata[length - 1]); IAssetProxy assetProxy = assetProxies[assetProxyId]; // transferFrom will either succeed or throw. diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/MixinSignatureValidator.sol b/packages/contracts/src/contracts/current/protocol/Exchange/MixinSignatureValidator.sol index f7fcd36b6..d40974e5f 100644 --- a/packages/contracts/src/contracts/current/protocol/Exchange/MixinSignatureValidator.sol +++ b/packages/contracts/src/contracts/current/protocol/Exchange/MixinSignatureValidator.sol @@ -19,18 +19,24 @@ pragma solidity ^0.4.24; import "./mixins/MSignatureValidator.sol"; -import "./interfaces/ISigner.sol"; +import "./mixins/MTransactions.sol"; +import "./interfaces/IWallet.sol"; +import "./interfaces/IValidator.sol"; import "./libs/LibExchangeErrors.sol"; import "../../utils/LibBytes/LibBytes.sol"; contract MixinSignatureValidator is LibBytes, LibExchangeErrors, - MSignatureValidator + MSignatureValidator, + MTransactions { // Mapping of hash => signer => signed - mapping(bytes32 => mapping(address => bool)) preSigned; + mapping (bytes32 => mapping (address => bool)) public preSigned; + + // Mapping of signer => validator => approved + mapping (address => mapping (address => bool)) public allowedValidators; /// @dev Approves a hash on-chain using any valid signature type. /// After presigning a hash, the preSign signature type will become valid for that hash and signer. @@ -39,7 +45,8 @@ contract MixinSignatureValidator is function preSign( bytes32 hash, address signer, - bytes signature) + bytes signature + ) external { require( @@ -49,6 +56,19 @@ contract MixinSignatureValidator is preSigned[hash][signer] = true; } + /// @dev Approves/unnapproves a Validator contract to verify signatures on signer's behalf. + /// @param validator Address of Validator contract. + /// @param approval Approval or disapproval of Validator contract. + function setSignatureValidatorApproval( + address validator, + bool approval + ) + external + { + address signer = getCurrentContextAddress(); + allowedValidators[signer][validator] = approval; + } + /// @dev Verifies that a hash has been signed by the given signer. /// @param hash Any 32 byte hash. /// @param signer Address that should have signed the given hash. @@ -57,71 +77,69 @@ contract MixinSignatureValidator is function isValidSignature( bytes32 hash, address signer, - bytes memory signature) + bytes memory signature + ) internal view returns (bool isValid) { // TODO: Domain separation: make hash depend on role. (Taker sig should not be valid as maker sig, etc.) - require( signature.length >= 1, INVALID_SIGNATURE_LENGTH ); - SignatureType signatureType = SignatureType(uint8(signature[0])); - // Variables are not scoped in Solidity + // Pop last byte off of signature byte array. + SignatureType signatureType = SignatureType(uint8(popByte(signature))); + + // Variables are not scoped in Solidity. uint8 v; bytes32 r; bytes32 s; address recovered; - - // Always illegal signature + + // Always illegal signature. // This is always an implicit option since a signer can create a // signature array with invalid type or length. We may as well make // it an explicit option. This aids testing and analysis. It is // also the initialization value for the enum type. if (signatureType == SignatureType.Illegal) { - // NOTE: Reason cannot be assigned to a variable because of https://github.com/ethereum/solidity/issues/4051 - revert("Illegal signature type."); + revert(ILLEGAL_SIGNATURE_TYPE); - // Always invalid signature + // Always invalid signature. // Like Illegal, this is always implicitly available and therefore // offered explicitly. It can be implicitly created by providing // a correctly formatted but incorrect signature. } else if (signatureType == SignatureType.Invalid) { require( - signature.length == 1, + signature.length == 0, INVALID_SIGNATURE_LENGTH ); isValid = false; return isValid; - // Implicitly signed by caller - // The signer has initiated the call. In the case of non-contract - // accounts it means the transaction itself was signed. - // Example: let's say for a particular operation three signatures - // A, B and C are required. To submit the transaction, A and B can - // give a signature to C, who can then submit the transaction using - // `Caller` for his own signature. Or A and C can sign and B can - // submit using `Caller`. Having `Caller` allows this flexibility. - } else if (signatureType == SignatureType.Caller) { + // Signature using EIP712 + } else if (signatureType == SignatureType.EIP712) { require( - signature.length == 1, + signature.length == 65, INVALID_SIGNATURE_LENGTH ); - isValid = signer == msg.sender; + v = uint8(signature[0]); + r = readBytes32(signature, 1); + s = readBytes32(signature, 33); + recovered = ecrecover(hash, v, r, s); + isValid = signer == recovered; return isValid; // Signed using web3.eth_sign - } else if (signatureType == SignatureType.Ecrecover) { + } else if (signatureType == SignatureType.EthSign) { require( - signature.length == 66, + signature.length == 65, INVALID_SIGNATURE_LENGTH ); - v = uint8(signature[1]); - r = readBytes32(signature, 2); - s = readBytes32(signature, 34); + v = uint8(signature[0]); + r = readBytes32(signature, 1); + s = readBytes32(signature, 33); recovered = ecrecover( keccak256("\x19Ethereum Signed Message:\n32", hash), v, @@ -131,20 +149,55 @@ contract MixinSignatureValidator is isValid = signer == recovered; return isValid; - // Signature using EIP712 - } else if (signatureType == SignatureType.EIP712) { + // Implicitly signed by caller. + // The signer has initiated the call. In the case of non-contract + // accounts it means the transaction itself was signed. + // Example: let's say for a particular operation three signatures + // A, B and C are required. To submit the transaction, A and B can + // give a signature to C, who can then submit the transaction using + // `Caller` for his own signature. Or A and C can sign and B can + // submit using `Caller`. Having `Caller` allows this flexibility. + } else if (signatureType == SignatureType.Caller) { require( - signature.length == 66, + signature.length == 0, INVALID_SIGNATURE_LENGTH ); - v = uint8(signature[1]); - r = readBytes32(signature, 2); - s = readBytes32(signature, 34); - recovered = ecrecover(hash, v, r, s); - isValid = signer == recovered; + isValid = signer == msg.sender; return isValid; - // Signature from Trezor hardware wallet + // Signature verified by wallet contract. + // If used with an order, the maker of the order is the wallet contract. + } else if (signatureType == SignatureType.Wallet) { + isValid = IWallet(signer).isValidSignature(hash, signature); + return isValid; + + // Signature verified by validator contract. + // If used with an order, the maker of the order can still be an EOA. + // A signature using this type should be encoded as: + // | Offset | Length | Contents | + // | 0x00 | x | Signature to validate | + // | 0x00 + x | 20 | Address of validator contract | + // | 0x14 + x | 1 | Signature type is always "\x06" | + } else if (signatureType == SignatureType.Validator) { + // Pop last 20 bytes off of signature byte array. + address validator = popAddress(signature); + // Ensure signer has approved validator. + if (!allowedValidators[signer][validator]) { + return false; + } + isValid = IValidator(validator).isValidSignature( + hash, + signer, + signature + ); + return isValid; + + // Signer signed hash previously using the preSign function. + } else if (signatureType == SignatureType.PreSigned) { + isValid = preSigned[hash][signer]; + return isValid; + + // Signature from Trezor hardware wallet. // It differs from web3.eth_sign in the encoding of message length // (Bitcoin varint encoding vs ascii-decimal, the latter is not // self-terminating which leads to ambiguities). @@ -154,12 +207,12 @@ contract MixinSignatureValidator is // https://github.com/trezor/trezor-mcu/blob/master/firmware/crypto.c#L36 } else if (signatureType == SignatureType.Trezor) { require( - signature.length == 66, + signature.length == 65, INVALID_SIGNATURE_LENGTH ); - v = uint8(signature[1]); - r = readBytes32(signature, 2); - s = readBytes32(signature, 34); + v = uint8(signature[0]); + r = readBytes32(signature, 1); + s = readBytes32(signature, 33); recovered = ecrecover( keccak256("\x19Ethereum Signed Message:\n\x41", hash), v, @@ -169,11 +222,6 @@ contract MixinSignatureValidator is isValid = signer == recovered; return isValid; - // Signature verified by signer contract - } else if (signatureType == SignatureType.Contract) { - isValid = ISigner(signer).isValidSignature(hash, signature); - return isValid; - // Signer signed hash previously using the preSign function } else if (signatureType == SignatureType.PreSigned) { isValid = preSigned[hash][signer]; @@ -185,7 +233,6 @@ contract MixinSignatureValidator is // that we currently support. In this case returning false // may lead the caller to incorrectly believe that the // signature was invalid.) - // NOTE: Reason cannot be assigned to a variable because of https://github.com/ethereum/solidity/issues/4051 - revert("Unsupported signature type."); + revert(UNSUPPORTED_SIGNATURE_TYPE); } } diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/MixinTransactions.sol b/packages/contracts/src/contracts/current/protocol/Exchange/MixinTransactions.sol index f93a80705..d153dfa5c 100644 --- a/packages/contracts/src/contracts/current/protocol/Exchange/MixinTransactions.sol +++ b/packages/contracts/src/contracts/current/protocol/Exchange/MixinTransactions.sol @@ -43,15 +43,20 @@ contract MixinTransactions is uint256 salt, address signer, bytes data, - bytes signature) + bytes signature + ) external { // Prevent reentrancy - require(currentContextAddress == address(0)); + require( + currentContextAddress == address(0), + REENTRANCY_NOT_ALLOWED + ); // Calculate transaction hash bytes32 transactionHash = keccak256( address(this), + signer, salt, data ); diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/interfaces/IExchange.sol b/packages/contracts/src/contracts/current/protocol/Exchange/interfaces/IExchange.sol index fc428e9c0..9f21c18d7 100644 --- a/packages/contracts/src/contracts/current/protocol/Exchange/interfaces/IExchange.sol +++ b/packages/contracts/src/contracts/current/protocol/Exchange/interfaces/IExchange.sol @@ -20,17 +20,15 @@ pragma solidity ^0.4.24; pragma experimental ABIEncoderV2; import "./IExchangeCore.sol"; -import "./IMatchOrders"; -import "./ISettlement"; -import "./ISignatureValidator"; -import "./ITransactions"; -import "./IAssetProxyDispatcher"; -import "./IWrapperFunctions"; +import "./IMatchOrders.sol"; +import "./ISignatureValidator.sol"; +import "./ITransactions.sol"; +import "./IAssetProxyDispatcher.sol"; +import "./IWrapperFunctions.sol"; contract IExchange is IExchangeCore, IMatchOrders, - ISettlement, ISignatureValidator, ITransactions, IAssetProxyDispatcher, diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/interfaces/ISignatureValidator.sol b/packages/contracts/src/contracts/current/protocol/Exchange/interfaces/ISignatureValidator.sol index 65ff45f7b..26e360c91 100644 --- a/packages/contracts/src/contracts/current/protocol/Exchange/interfaces/ISignatureValidator.sol +++ b/packages/contracts/src/contracts/current/protocol/Exchange/interfaces/ISignatureValidator.sol @@ -27,6 +27,16 @@ contract ISignatureValidator { function preSign( bytes32 hash, address signer, - bytes signature) + bytes signature + ) + external; + + /// @dev Approves/unnapproves a Validator contract to verify signatures on signer's behalf. + /// @param validator Address of Validator contract. + /// @param approval Approval or disapproval of Validator contract. + function setSignatureValidatorApproval( + address validator, + bool approval + ) external; } diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/interfaces/IValidator.sol b/packages/contracts/src/contracts/current/protocol/Exchange/interfaces/IValidator.sol new file mode 100644 index 000000000..3e5ccc190 --- /dev/null +++ b/packages/contracts/src/contracts/current/protocol/Exchange/interfaces/IValidator.sol @@ -0,0 +1,36 @@ +/* + + 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.23; + +contract IValidator { + + /// @dev Verifies that a signature is valid. + /// @param hash Message hash that is signed. + /// @param signer Address that should have signed the given hash. + /// @param signature Proof of signing. + /// @return Validity of order signature. + function isValidSignature( + bytes32 hash, + address signer, + bytes signature + ) + external + view + returns (bool isValid); +} diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/interfaces/ISigner.sol b/packages/contracts/src/contracts/current/protocol/Exchange/interfaces/IWallet.sol index 53c41d331..c86a2c057 100644 --- a/packages/contracts/src/contracts/current/protocol/Exchange/interfaces/ISigner.sol +++ b/packages/contracts/src/contracts/current/protocol/Exchange/interfaces/IWallet.sol @@ -18,7 +18,7 @@ pragma solidity ^0.4.24; -contract ISigner { +contract IWallet { /// @dev Verifies that a signature is valid. /// @param hash Message hash that is signed. @@ -26,7 +26,8 @@ contract ISigner { /// @return Validity of order signature. function isValidSignature( bytes32 hash, - bytes signature) + bytes signature + ) external view returns (bool isValid); diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/interfaces/IWrapperFunctions.sol b/packages/contracts/src/contracts/current/protocol/Exchange/interfaces/IWrapperFunctions.sol index 1eb1233ed..8682b394a 100644 --- a/packages/contracts/src/contracts/current/protocol/Exchange/interfaces/IWrapperFunctions.sol +++ b/packages/contracts/src/contracts/current/protocol/Exchange/interfaces/IWrapperFunctions.sol @@ -19,27 +19,23 @@ pragma solidity ^0.4.24; pragma experimental ABIEncoderV2; -import "./libs/LibOrder.sol"; -import "./libs/LibFillResults.sol"; +import "../libs/LibOrder.sol"; +import "../libs/LibFillResults.sol"; contract IWrapperFunctions is - LibBytes, - LibMath, LibOrder, - LibFillResults, - LibExchangeErrors, - MExchangeCore + LibFillResults { /// @dev Fills the input order. Reverts if exact takerAssetFillAmount not filled. /// @param order LibOrder.Order struct containing order specifications. /// @param takerAssetFillAmount Desired amount of takerAsset to sell. /// @param signature Proof that order has been created by maker. function fillOrKillOrder( - LibOrder.LibOrder.Order memory order, + LibOrder.Order memory order, uint256 takerAssetFillAmount, bytes memory signature) public - returns (LibFillResults.LibFillResults.FillResults memory fillResults); + returns (LibFillResults.FillResults memory fillResults); /// @dev Fills an order with specified parameters and ECDSA signature. /// Returns false if the transaction would otherwise revert. diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/libs/LibExchangeErrors.sol b/packages/contracts/src/contracts/current/protocol/Exchange/libs/LibExchangeErrors.sol index 4712ee36c..7d67e5080 100644 --- a/packages/contracts/src/contracts/current/protocol/Exchange/libs/LibExchangeErrors.sol +++ b/packages/contracts/src/contracts/current/protocol/Exchange/libs/LibExchangeErrors.sol @@ -32,6 +32,7 @@ contract LibExchangeErrors { string constant INVALID_ORDER_MAKER_ASSET_AMOUNT = "Invalid order maker asset amount: expected a non-zero value."; // Transaction revert reasons + string constant REENTRANCY_NOT_ALLOWED = "`executeTransaction` is not allowed to call itself recursively."; string constant DUPLICATE_TRANSACTION_HASH = "Transaction has already been executed."; string constant TRANSACTION_EXECUTION_FAILED = "Transaction execution failed."; diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/mixins/MAssetProxyDispatcher.sol b/packages/contracts/src/contracts/current/protocol/Exchange/mixins/MAssetProxyDispatcher.sol index ccc960d6e..87c5f6361 100644 --- a/packages/contracts/src/contracts/current/protocol/Exchange/mixins/MAssetProxyDispatcher.sol +++ b/packages/contracts/src/contracts/current/protocol/Exchange/mixins/MAssetProxyDispatcher.sol @@ -41,6 +41,7 @@ contract MAssetProxyDispatcher is bytes memory assetMetadata, address from, address to, - uint256 amount) + uint256 amount + ) internal; } diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/mixins/MSignatureValidator.sol b/packages/contracts/src/contracts/current/protocol/Exchange/mixins/MSignatureValidator.sol index 3658e7c6f..7eed453ff 100644 --- a/packages/contracts/src/contracts/current/protocol/Exchange/mixins/MSignatureValidator.sol +++ b/packages/contracts/src/contracts/current/protocol/Exchange/mixins/MSignatureValidator.sol @@ -25,14 +25,15 @@ contract MSignatureValidator is { // Allowed signature types. enum SignatureType { - Illegal, // Default value - Invalid, - Caller, - Ecrecover, - EIP712, - Trezor, - Contract, - PreSigned + Illegal, // 0x00, default value + Invalid, // 0x01 + EIP712, // 0x02 + EthSign, // 0x03 + Caller, // 0x04 + Wallet, // 0x05 + Validator, // 0x06 + PreSigned, // 0x07 + Trezor // 0x08 } /// @dev Verifies that a signature is valid. @@ -43,7 +44,8 @@ contract MSignatureValidator is function isValidSignature( bytes32 hash, address signer, - bytes memory signature) + bytes memory signature + ) internal view returns (bool isValid); diff --git a/packages/contracts/src/contracts/current/test/TestLibBytes/TestLibBytes.sol b/packages/contracts/src/contracts/current/test/TestLibBytes/TestLibBytes.sol index 5a6801262..69554605d 100644 --- a/packages/contracts/src/contracts/current/test/TestLibBytes/TestLibBytes.sol +++ b/packages/contracts/src/contracts/current/test/TestLibBytes/TestLibBytes.sol @@ -25,6 +25,30 @@ contract TestLibBytes is LibBytes { + /// @dev Pops the last byte off of a byte array by modifying its length. + /// @param b Byte array that will be modified. + /// @return The byte that was popped off. + function publicPopByte(bytes memory b) + public + pure + returns (bytes memory, bytes1 result) + { + result = popByte(b); + return (b, result); + } + + /// @dev Pops the last 20 bytes off of a byte array by modifying its length. + /// @param b Byte array that will be modified. + /// @return The 20 byte address that was popped off. + function publicPopAddress(bytes memory b) + public + pure + returns (bytes memory, address result) + { + result = popAddress(b); + return (b, result); + } + /// @dev Tests equality of two byte arrays. /// @param lhs First byte array to compare. /// @param rhs Second byte array to compare. diff --git a/packages/contracts/src/contracts/current/test/TestSignatureValidator/TestSignatureValidator.sol b/packages/contracts/src/contracts/current/test/TestSignatureValidator/TestSignatureValidator.sol index 15d9ca189..0f84678cf 100644 --- a/packages/contracts/src/contracts/current/test/TestSignatureValidator/TestSignatureValidator.sol +++ b/packages/contracts/src/contracts/current/test/TestSignatureValidator/TestSignatureValidator.sol @@ -20,13 +20,18 @@ pragma solidity ^0.4.24; pragma experimental ABIEncoderV2; import "../../protocol/Exchange/MixinSignatureValidator.sol"; +import "../../protocol/Exchange/MixinTransactions.sol"; -contract TestSignatureValidator is MixinSignatureValidator { +contract TestSignatureValidator is + MixinSignatureValidator, + MixinTransactions +{ function publicIsValidSignature( bytes32 hash, address signer, - bytes memory signature) + bytes memory signature + ) public view returns (bool isValid) diff --git a/packages/contracts/src/contracts/current/test/Whitelist/Whitelist.sol b/packages/contracts/src/contracts/current/test/Whitelist/Whitelist.sol new file mode 100644 index 000000000..0594e2767 --- /dev/null +++ b/packages/contracts/src/contracts/current/test/Whitelist/Whitelist.sol @@ -0,0 +1,133 @@ +/* + + 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.23; +pragma experimental ABIEncoderV2; + +import "../../protocol/Exchange/interfaces/IExchange.sol"; +import "../../protocol/Exchange/libs/LibOrder.sol"; +import "../../utils/Ownable/Ownable.sol"; + +contract Whitelist is + Ownable +{ + // Revert reasons + string constant MAKER_NOT_WHITELISTED = "Maker address not whitelisted."; + string constant TAKER_NOT_WHITELISTED = "Taker address not whitelisted."; + string constant INVALID_SENDER = "Sender must equal transaction origin."; + + // Mapping of address => whitelist status. + mapping (address => bool) public isWhitelisted; + + // Exchange contract. + IExchange EXCHANGE; + + byte constant VALIDATOR_SIGNATURE_BYTE = "\x06"; + bytes TX_ORIGIN_SIGNATURE; + + constructor (address _exchange) + public + { + EXCHANGE = IExchange(_exchange); + TX_ORIGIN_SIGNATURE = abi.encodePacked(address(this), VALIDATOR_SIGNATURE_BYTE); + } + + /// @dev Adds or removes an address from the whitelist. + /// @param target Address to add or remove from whitelist. + /// @param isApproved Whitelist status to assign to address. + function updateWhitelistStatus( + address target, + bool isApproved + ) + external + onlyOwner + { + isWhitelisted[target] = isApproved; + } + + /// @dev Fills an order using `msg.sender` as the taker. + /// The transaction will revert if both the maker and taker are not whitelisted. + /// Orders should specify this contract as the `senderAddress` in order to gaurantee + /// that both maker and taker have been whitelisted. + /// @param order Order struct containing order specifications. + /// @param takerAssetFillAmount Desired amount of takerAsset to sell. + /// @param salt Arbitrary value to gaurantee uniqueness of 0x transaction hash. + /// @param orderSignature Proof that order has been created by maker. + function fillOrderIfWhitelisted( + LibOrder.Order memory order, + uint256 takerAssetFillAmount, + uint256 salt, + bytes memory orderSignature + ) + public + { + address takerAddress = msg.sender; + + // This contract must be the entry point for the transaction. + require( + takerAddress == tx.origin, + INVALID_SENDER + ); + + // Check if maker is on the whitelist. + require( + isWhitelisted[order.makerAddress], + MAKER_NOT_WHITELISTED + ); + + // Check if taker is on the whitelist. + require( + isWhitelisted[takerAddress], + TAKER_NOT_WHITELISTED + ); + + // Encode arguments into byte array. + bytes memory data = abi.encodeWithSelector( + EXCHANGE.fillOrder.selector, + order, + takerAssetFillAmount, + orderSignature + ); + + // Call `fillOrder` via `executeTransaction`. + EXCHANGE.executeTransaction( + salt, + takerAddress, + data, + TX_ORIGIN_SIGNATURE + ); + } + + /// @dev Verifies signer is same as signer of current Ethereum transaction. + /// NOTE: This function can currently be used to validate signatures coming from outside of this contract. + /// Extra safety checks can be added for a production contract. + /// @param signer Address that should have signed the given hash. + /// @param signature Proof of signing. + /// @return Validity of order signature. + function isValidSignature( + bytes32 hash, + address signer, + bytes signature + ) + external + view + returns (bool isValid) + { + return signer == tx.origin; + } +} diff --git a/packages/contracts/src/contracts/current/utils/LibBytes/LibBytes.sol b/packages/contracts/src/contracts/current/utils/LibBytes/LibBytes.sol index 975565773..df2221c93 100644 --- a/packages/contracts/src/contracts/current/utils/LibBytes/LibBytes.sol +++ b/packages/contracts/src/contracts/current/utils/LibBytes/LibBytes.sol @@ -21,15 +21,68 @@ pragma solidity ^0.4.24; contract LibBytes { // Revert reasons + string constant GT_ZERO_LENGTH_REQUIRED = "Length must be greater than 0."; string constant GTE_4_LENGTH_REQUIRED = "Length must be greater than or equal to 4."; string constant GTE_20_LENGTH_REQUIRED = "Length must be greater than or equal to 20."; string constant GTE_32_LENGTH_REQUIRED = "Length must be greater than or equal to 32."; + string constant INDEX_OUT_OF_BOUNDS = "Specified array index is out of bounds."; + + /// @dev Pops the last byte off of a byte array by modifying its length. + /// @param b Byte array that will be modified. + /// @return The byte that was popped off. + function popByte(bytes memory b) + internal + pure + returns (bytes1 result) + { + require( + b.length > 0, + GT_ZERO_LENGTH_REQUIRED + ); + + // Store last byte. + result = b[b.length - 1]; + + assembly { + // Decrement length of byte array. + let newLen := sub(mload(b), 1) + mstore(b, newLen) + } + return result; + } + + /// @dev Pops the last 20 bytes off of a byte array by modifying its length. + /// @param b Byte array that will be modified. + /// @return The 20 byte address that was popped off. + function popAddress(bytes memory b) + internal + pure + returns (address result) + { + require( + b.length >= 20, + GTE_20_LENGTH_REQUIRED + ); + + // Store last 20 bytes. + result = readAddress(b, b.length - 20); + + assembly { + // Subtract 20 from byte array length. + let newLen := sub(mload(b), 20) + mstore(b, newLen) + } + return result; + } /// @dev Tests equality of two byte arrays. /// @param lhs First byte array to compare. /// @param rhs Second byte array to compare. /// @return True if arrays are the same. False otherwise. - function areBytesEqual(bytes memory lhs, bytes memory rhs) + function areBytesEqual( + bytes memory lhs, + bytes memory rhs + ) internal pure returns (bool equal) @@ -63,7 +116,8 @@ contract LibBytes { /// @return address from byte array. function readAddress( bytes memory b, - uint256 index) + uint256 index + ) internal pure returns (address result) @@ -95,7 +149,8 @@ contract LibBytes { function writeAddress( bytes memory b, uint256 index, - address input) + address input + ) internal pure { @@ -132,7 +187,8 @@ contract LibBytes { /// @return bytes32 value from byte array. function readBytes32( bytes memory b, - uint256 index) + uint256 index + ) internal pure returns (bytes32 result) @@ -159,7 +215,8 @@ contract LibBytes { function writeBytes32( bytes memory b, uint256 index, - bytes32 input) + bytes32 input + ) internal pure { @@ -183,7 +240,8 @@ contract LibBytes { /// @return uint256 value from byte array. function readUint256( bytes memory b, - uint256 index) + uint256 index + ) internal pure returns (uint256 result) @@ -198,7 +256,8 @@ contract LibBytes { function writeUint256( bytes memory b, uint256 index, - uint256 input) + uint256 input + ) internal pure { diff --git a/packages/contracts/src/utils/artifacts.ts b/packages/contracts/src/utils/artifacts.ts index fe74ea072..357c66a0a 100644 --- a/packages/contracts/src/utils/artifacts.ts +++ b/packages/contracts/src/utils/artifacts.ts @@ -15,6 +15,7 @@ import * as TestLibs from '../artifacts/TestLibs.json'; import * as TestSignatureValidator from '../artifacts/TestSignatureValidator.json'; import * as TokenRegistry from '../artifacts/TokenRegistry.json'; import * as EtherToken from '../artifacts/WETH9.json'; +import * as Whitelist from '../artifacts/Whitelist.json'; import * as ZRX from '../artifacts/ZRXToken.json'; export const artifacts = { @@ -33,5 +34,6 @@ export const artifacts = { TestLibs: (TestLibs as any) as ContractArtifact, TestSignatureValidator: (TestSignatureValidator as any) as ContractArtifact, TokenRegistry: (TokenRegistry as any) as ContractArtifact, + Whitelist: (Whitelist as any) as ContractArtifact, ZRX: (ZRX as any) as ContractArtifact, }; diff --git a/packages/contracts/src/utils/asset_proxy_utils.ts b/packages/contracts/src/utils/asset_proxy_utils.ts index c042da5d0..a17d4cdfa 100644 --- a/packages/contracts/src/utils/asset_proxy_utils.ts +++ b/packages/contracts/src/utils/asset_proxy_utils.ts @@ -39,7 +39,7 @@ export const assetProxyUtils = { encodeERC20ProxyData(tokenAddress: string): string { const encodedAssetProxyId = assetProxyUtils.encodeAssetProxyId(AssetProxyId.ERC20); const encodedAddress = assetProxyUtils.encodeAddress(tokenAddress); - const encodedMetadata = Buffer.concat([encodedAssetProxyId, encodedAddress]); + const encodedMetadata = Buffer.concat([encodedAddress, encodedAssetProxyId]); const encodedMetadataHex = ethUtil.bufferToHex(encodedMetadata); return encodedMetadataHex; }, @@ -52,7 +52,7 @@ export const assetProxyUtils = { }`, ); } - const encodedAssetProxyId = encodedProxyMetadata.slice(0, 1); + const encodedAssetProxyId = encodedProxyMetadata.slice(-1); const assetProxyId = assetProxyUtils.decodeAssetProxyId(encodedAssetProxyId); if (assetProxyId !== AssetProxyId.ERC20) { throw new Error( @@ -61,7 +61,7 @@ export const assetProxyUtils = { }), but got ${assetProxyId}`, ); } - const encodedTokenAddress = encodedProxyMetadata.slice(1, 21); + const encodedTokenAddress = encodedProxyMetadata.slice(0, 20); const tokenAddress = assetProxyUtils.decodeAddress(encodedTokenAddress); const erc20ProxyData = { assetProxyId, @@ -73,7 +73,7 @@ export const assetProxyUtils = { const encodedAssetProxyId = assetProxyUtils.encodeAssetProxyId(AssetProxyId.ERC721); const encodedAddress = assetProxyUtils.encodeAddress(tokenAddress); const encodedTokenId = assetProxyUtils.encodeUint256(tokenId); - const encodedMetadata = Buffer.concat([encodedAssetProxyId, encodedAddress, encodedTokenId]); + const encodedMetadata = Buffer.concat([encodedAddress, encodedTokenId, encodedAssetProxyId]); const encodedMetadataHex = ethUtil.bufferToHex(encodedMetadata); return encodedMetadataHex; }, @@ -86,7 +86,7 @@ export const assetProxyUtils = { }`, ); } - const encodedAssetProxyId = encodedProxyMetadata.slice(0, 1); + const encodedAssetProxyId = encodedProxyMetadata.slice(-1); const assetProxyId = assetProxyUtils.decodeAssetProxyId(encodedAssetProxyId); if (assetProxyId !== AssetProxyId.ERC721) { throw new Error( @@ -95,9 +95,9 @@ export const assetProxyUtils = { }), but got ${assetProxyId}`, ); } - const encodedTokenAddress = encodedProxyMetadata.slice(1, 21); + const encodedTokenAddress = encodedProxyMetadata.slice(0, 20); const tokenAddress = assetProxyUtils.decodeAddress(encodedTokenAddress); - const encodedTokenId = encodedProxyMetadata.slice(21, 53); + const encodedTokenId = encodedProxyMetadata.slice(20, 52); const tokenId = assetProxyUtils.decodeUint256(encodedTokenId); const erc721ProxyData = { assetProxyId, @@ -115,7 +115,7 @@ export const assetProxyUtils = { }`, ); } - const encodedAssetProxyId = encodedProxyMetadata.slice(0, 1); + const encodedAssetProxyId = encodedProxyMetadata.slice(-1); const assetProxyId = assetProxyUtils.decodeAssetProxyId(encodedAssetProxyId); return assetProxyId; }, diff --git a/packages/contracts/src/utils/constants.ts b/packages/contracts/src/utils/constants.ts index 7a0e26a48..9b0b92545 100644 --- a/packages/contracts/src/utils/constants.ts +++ b/packages/contracts/src/utils/constants.ts @@ -28,6 +28,7 @@ export const constants = { 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: 1, NUM_ERC721_TOKENS_TO_MINT: 2, diff --git a/packages/contracts/src/utils/signing_utils.ts b/packages/contracts/src/utils/signing_utils.ts index 61ab1f138..4c36c8310 100644 --- a/packages/contracts/src/utils/signing_utils.ts +++ b/packages/contracts/src/utils/signing_utils.ts @@ -8,19 +8,19 @@ export const signingUtils = { const prefixedMessage = ethUtil.hashPersonalMessage(message); const ecSignature = ethUtil.ecsign(prefixedMessage, privateKey); const signature = Buffer.concat([ - ethUtil.toBuffer(signatureType), 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(signatureType), ethUtil.toBuffer(ecSignature.v), ecSignature.r, ecSignature.s, + ethUtil.toBuffer(signatureType), ]); return signature; } else { diff --git a/packages/contracts/src/utils/transaction_factory.ts b/packages/contracts/src/utils/transaction_factory.ts index 941bff96d..65cdb3f89 100644 --- a/packages/contracts/src/utils/transaction_factory.ts +++ b/packages/contracts/src/utils/transaction_factory.ts @@ -7,26 +7,25 @@ import { signingUtils } from './signing_utils'; import { SignatureType, SignedTransaction } from './types'; export class TransactionFactory { - private _signer: string; + private _signerBuff: Buffer; private _exchangeAddress: string; private _privateKey: Buffer; constructor(privateKey: Buffer, exchangeAddress: string) { this._privateKey = privateKey; this._exchangeAddress = exchangeAddress; - const signerBuff = ethUtil.privateToAddress(this._privateKey); - this._signer = `0x${signerBuff.toString('hex')}`; + this._signerBuff = ethUtil.privateToAddress(this._privateKey); } public newSignedTransaction( data: string, signatureType: SignatureType = SignatureType.Ecrecover, ): SignedTransaction { const salt = generatePseudoRandomSalt(); - const txHash = crypto.solSHA3([this._exchangeAddress, salt, ethUtil.toBuffer(data)]); + const txHash = crypto.solSHA3([this._exchangeAddress, this._signerBuff, salt, ethUtil.toBuffer(data)]); const signature = signingUtils.signMessage(txHash, this._privateKey, signatureType); const signedTx = { exchangeAddress: this._exchangeAddress, salt, - signer: this._signer, + signer: `0x${this._signerBuff.toString('hex')}`, data, signature: `0x${signature.toString('hex')}`, }; diff --git a/packages/contracts/src/utils/types.ts b/packages/contracts/src/utils/types.ts index 90f90ec27..1eeffc70e 100644 --- a/packages/contracts/src/utils/types.ts +++ b/packages/contracts/src/utils/types.ts @@ -111,16 +111,19 @@ export enum ContractName { DummyERC721Token = 'DummyERC721Token', TestLibBytes = 'TestLibBytes', Authorizable = 'Authorizable', + Whitelist = 'Whitelist', } export enum SignatureType { Illegal, Invalid, - Caller, - Ecrecover, EIP712, - Trezor, + Ecrecover, + TxOrigin, + Caller, Contract, + PreSigned, + Trezor, } export interface SignedTransaction { diff --git a/packages/contracts/src/utils/web3_wrapper.ts b/packages/contracts/src/utils/web3_wrapper.ts index 02595506b..4b8512222 100644 --- a/packages/contracts/src/utils/web3_wrapper.ts +++ b/packages/contracts/src/utils/web3_wrapper.ts @@ -7,7 +7,7 @@ import { coverage } from './coverage'; export const txDefaults = { from: devConstants.TESTRPC_FIRST_ADDRESS, - gas: devConstants.GAS_ESTIMATE, + gas: devConstants.GAS_LIMIT, }; const providerConfigs = { shouldUseInProcessGanache: true }; export const provider = web3Factory.getRpcProvider(providerConfigs); diff --git a/packages/contracts/test/asset_proxy_owner.ts b/packages/contracts/test/asset_proxy_owner.ts index db68b5678..43c5da512 100644 --- a/packages/contracts/test/asset_proxy_owner.ts +++ b/packages/contracts/test/asset_proxy_owner.ts @@ -36,6 +36,12 @@ describe('AssetProxyOwner', () => { let multiSigWrapper: MultiSigWrapper; before(async () => { + await blockchainLifecycle.startAsync(); + }); + after(async () => { + await blockchainLifecycle.revertAsync(); + }); + before(async () => { const accounts = await web3Wrapper.getAvailableAddressesAsync(); owners = [accounts[0], accounts[1]]; const initialOwner = (authorized = accounts[0]); diff --git a/packages/contracts/test/exchange/core.ts b/packages/contracts/test/exchange/core.ts index be8d14cb0..bc476a5ee 100644 --- a/packages/contracts/test/exchange/core.ts +++ b/packages/contracts/test/exchange/core.ts @@ -460,10 +460,11 @@ describe('Exchange core', () => { makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18), }); + const v = ethUtil.toBuffer(signedOrder.signature.slice(0, 4)); const invalidR = ethUtil.sha3('invalidR'); const invalidS = ethUtil.sha3('invalidS'); - const signatureTypeAndV = signedOrder.signature.slice(0, 6); - const invalidSigBuff = Buffer.concat([ethUtil.toBuffer(signatureTypeAndV), invalidR, invalidS]); + const signatureType = ethUtil.toBuffer(`0x${signedOrder.signature.slice(-2)}`); + const invalidSigBuff = Buffer.concat([v, invalidR, invalidS, signatureType]); const invalidSigHex = `0x${invalidSigBuff.toString('hex')}`; signedOrder.signature = invalidSigHex; return expect(exchangeWrapper.fillOrderAsync(signedOrder, takerAddress)).to.be.rejectedWith( diff --git a/packages/contracts/test/exchange/libs.ts b/packages/contracts/test/exchange/libs.ts index bbca54274..a3282876b 100644 --- a/packages/contracts/test/exchange/libs.ts +++ b/packages/contracts/test/exchange/libs.ts @@ -49,7 +49,6 @@ describe('Exchange libs', () => { beforeEach(async () => { await blockchainLifecycle.startAsync(); - signedOrder = orderFactory.newSignedOrder(); }); afterEach(async () => { await blockchainLifecycle.revertAsync(); @@ -69,7 +68,8 @@ describe('Exchange libs', () => { }); }); describe('getOrderHash', () => { - it('should output the correct order hash', async () => { + it('should output the correct orderHash', async () => { + signedOrder = orderFactory.newSignedOrder(); const orderHashHex = await libs.publicGetOrderHash.callAsync(signedOrder); expect(orderUtils.getOrderHashHex(signedOrder)).to.be.equal(orderHashHex); }); diff --git a/packages/contracts/test/exchange/signature_validator.ts b/packages/contracts/test/exchange/signature_validator.ts index 376fff438..1f030b742 100644 --- a/packages/contracts/test/exchange/signature_validator.ts +++ b/packages/contracts/test/exchange/signature_validator.ts @@ -53,7 +53,6 @@ describe('MixinSignatureValidator', () => { beforeEach(async () => { await blockchainLifecycle.startAsync(); - signedOrder = orderFactory.newSignedOrder(); }); afterEach(async () => { await blockchainLifecycle.revertAsync(); @@ -75,13 +74,11 @@ describe('MixinSignatureValidator', () => { }); it('should return false with an invalid signature', async () => { + const v = ethUtil.toBuffer(signedOrder.signature.slice(0, 4)); const invalidR = ethUtil.sha3('invalidR'); const invalidS = ethUtil.sha3('invalidS'); - const invalidSigBuff = Buffer.concat([ - ethUtil.toBuffer(signedOrder.signature.slice(0, 6)), - invalidR, - invalidS, - ]); + const signatureType = ethUtil.toBuffer(`0x${signedOrder.signature.slice(-2)}`); + const invalidSigBuff = Buffer.concat([v, invalidR, invalidS, signatureType]); const invalidSigHex = `0x${invalidSigBuff.toString('hex')}`; signedOrder.signature = invalidSigHex; const orderHashHex = orderUtils.getOrderHashHex(signedOrder); diff --git a/packages/contracts/test/exchange/transactions.ts b/packages/contracts/test/exchange/transactions.ts index 33fe11bfa..6b3083ae5 100644 --- a/packages/contracts/test/exchange/transactions.ts +++ b/packages/contracts/test/exchange/transactions.ts @@ -1,4 +1,5 @@ import { BlockchainLifecycle } from '@0xproject/dev-utils'; +import { generatePseudoRandomSalt } from '@0xproject/order-utils'; import { Order, SignedOrder } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; import * as chai from 'chai'; @@ -8,6 +9,7 @@ import * as Web3 from 'web3'; import { DummyERC20TokenContract } from '../../src/contract_wrappers/generated/dummy_e_r_c20_token'; import { ERC20ProxyContract } from '../../src/contract_wrappers/generated/e_r_c20_proxy'; import { ExchangeContract } from '../../src/contract_wrappers/generated/exchange'; +import { WhitelistContract } from '../../src/contract_wrappers/generated/whitelist'; import { artifacts } from '../../src/utils/artifacts'; import { assetProxyUtils } from '../../src/utils/asset_proxy_utils'; import { chaiSetup } from '../../src/utils/chai_setup'; @@ -55,6 +57,8 @@ describe('Exchange transactions', () => { let defaultMakerTokenAddress: string; let defaultTakerTokenAddress: string; + let makerPrivateKey: Buffer; + let takerPrivateKey: Buffer; before(async () => { await blockchainLifecycle.startAsync(); @@ -98,8 +102,8 @@ describe('Exchange transactions', () => { makerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultMakerTokenAddress), takerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultTakerTokenAddress), }; - const makerPrivateKey = constants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(makerAddress)]; - const takerPrivateKey = constants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(takerAddress)]; + makerPrivateKey = constants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(makerAddress)]; + takerPrivateKey = constants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(takerAddress)]; orderFactory = new OrderFactory(makerPrivateKey, defaultOrderParams); makerTransactionFactory = new TransactionFactory(makerPrivateKey, exchange.address); takerTransactionFactory = new TransactionFactory(takerPrivateKey, exchange.address); @@ -203,4 +207,131 @@ describe('Exchange transactions', () => { }); }); }); + + describe('Whitelist', () => { + let whitelist: WhitelistContract; + let whitelistOrderFactory: OrderFactory; + + before(async () => { + whitelist = await WhitelistContract.deployFrom0xArtifactAsync( + artifacts.Whitelist, + provider, + txDefaults, + exchange.address, + ); + const isApproved = true; + await web3Wrapper.awaitTransactionSuccessAsync( + await exchange.approveSignatureValidator.sendTransactionAsync(whitelist.address, isApproved, { + from: takerAddress, + }), + ); + const defaultOrderParams = { + ...constants.STATIC_ORDER_PARAMS, + senderAddress: whitelist.address, + exchangeAddress: exchange.address, + makerAddress, + feeRecipientAddress, + makerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultMakerTokenAddress), + takerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultTakerTokenAddress), + }; + whitelistOrderFactory = new OrderFactory(makerPrivateKey, defaultOrderParams); + }); + + beforeEach(async () => { + signedOrder = whitelistOrderFactory.newSignedOrder(); + erc20Balances = await erc20Wrapper.getBalancesAsync(); + }); + + it('should revert if maker has not been whitelisted', async () => { + const isApproved = true; + await web3Wrapper.awaitTransactionSuccessAsync( + await whitelist.updateWhitelistStatus.sendTransactionAsync(takerAddress, isApproved, { from: owner }), + ); + + const orderStruct = orderUtils.getOrderStruct(signedOrder); + const takerAssetFillAmount = signedOrder.takerAssetAmount; + const salt = generatePseudoRandomSalt(); + return expect( + whitelist.fillOrderIfWhitelisted.sendTransactionAsync( + orderStruct, + takerAssetFillAmount, + salt, + signedOrder.signature, + { from: takerAddress }, + ), + ).to.be.rejectedWith(constants.REVERT); + }); + + it('should revert if taker has not been whitelisted', async () => { + const isApproved = true; + await web3Wrapper.awaitTransactionSuccessAsync( + await whitelist.updateWhitelistStatus.sendTransactionAsync(makerAddress, isApproved, { from: owner }), + ); + + const orderStruct = orderUtils.getOrderStruct(signedOrder); + const takerAssetFillAmount = signedOrder.takerAssetAmount; + const salt = generatePseudoRandomSalt(); + return expect( + whitelist.fillOrderIfWhitelisted.sendTransactionAsync( + orderStruct, + takerAssetFillAmount, + salt, + signedOrder.signature, + { from: takerAddress }, + ), + ).to.be.rejectedWith(constants.REVERT); + }); + + it('should fill the order if maker and taker have been whitelisted', async () => { + const isApproved = true; + await web3Wrapper.awaitTransactionSuccessAsync( + await whitelist.updateWhitelistStatus.sendTransactionAsync(makerAddress, isApproved, { from: owner }), + ); + + await web3Wrapper.awaitTransactionSuccessAsync( + await whitelist.updateWhitelistStatus.sendTransactionAsync(takerAddress, isApproved, { from: owner }), + ); + + const orderStruct = orderUtils.getOrderStruct(signedOrder); + const takerAssetFillAmount = signedOrder.takerAssetAmount; + const salt = generatePseudoRandomSalt(); + await web3Wrapper.awaitTransactionSuccessAsync( + await whitelist.fillOrderIfWhitelisted.sendTransactionAsync( + orderStruct, + takerAssetFillAmount, + salt, + signedOrder.signature, + { from: takerAddress }, + ), + ); + + const newBalances = await erc20Wrapper.getBalancesAsync(); + + const makerAssetFillAmount = signedOrder.makerAssetAmount; + const makerFeePaid = signedOrder.makerFee; + const takerFeePaid = signedOrder.takerFee; + + expect(newBalances[makerAddress][defaultMakerTokenAddress]).to.be.bignumber.equal( + erc20Balances[makerAddress][defaultMakerTokenAddress].minus(makerAssetFillAmount), + ); + expect(newBalances[makerAddress][defaultTakerTokenAddress]).to.be.bignumber.equal( + erc20Balances[makerAddress][defaultTakerTokenAddress].add(takerAssetFillAmount), + ); + expect(newBalances[makerAddress][zrxToken.address]).to.be.bignumber.equal( + erc20Balances[makerAddress][zrxToken.address].minus(makerFeePaid), + ); + expect(newBalances[takerAddress][defaultTakerTokenAddress]).to.be.bignumber.equal( + erc20Balances[takerAddress][defaultTakerTokenAddress].minus(takerAssetFillAmount), + ); + expect(newBalances[takerAddress][defaultMakerTokenAddress]).to.be.bignumber.equal( + erc20Balances[takerAddress][defaultMakerTokenAddress].add(makerAssetFillAmount), + ); + expect(newBalances[takerAddress][zrxToken.address]).to.be.bignumber.equal( + erc20Balances[takerAddress][zrxToken.address].minus(takerFeePaid), + ); + expect(newBalances[feeRecipientAddress][zrxToken.address]).to.be.bignumber.equal( + erc20Balances[feeRecipientAddress][zrxToken.address].add(makerFeePaid.add(takerFeePaid)), + ); + }); + }); }); diff --git a/packages/contracts/test/libraries/lib_bytes.ts b/packages/contracts/test/libraries/lib_bytes.ts index 968bac300..e817951ab 100644 --- a/packages/contracts/test/libraries/lib_bytes.ts +++ b/packages/contracts/test/libraries/lib_bytes.ts @@ -22,6 +22,7 @@ describe('LibBytes', () => { let owner: string; let libBytes: TestLibBytesContract; const byteArrayShorterThan32Bytes = '0x012345'; + const byteArrayShorterThan20Bytes = byteArrayShorterThan32Bytes; const byteArrayLongerThan32Bytes = '0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef'; const byteArrayLongerThan32BytesFirstBytesSwapped = @@ -60,6 +61,36 @@ describe('LibBytes', () => { await blockchainLifecycle.revertAsync(); }); + describe('popByte', () => { + it('should revert if length is 0', async () => { + return expect(libBytes.publicPopByte.callAsync(constants.NULL_BYTES)).to.be.rejectedWith(constants.REVERT); + }); + + it('should pop the last byte from the input and return it', async () => { + const [newBytes, poppedByte] = await libBytes.publicPopByte.callAsync(byteArrayLongerThan32Bytes); + const expectedNewBytes = byteArrayLongerThan32Bytes.slice(0, -2); + const expectedPoppedByte = `0x${byteArrayLongerThan32Bytes.slice(-2)}`; + expect(newBytes).to.equal(expectedNewBytes); + expect(poppedByte).to.equal(expectedPoppedByte); + }); + }); + + describe('popAddress', () => { + it('should revert if length is less than 20', async () => { + return expect(libBytes.publicPopAddress.callAsync(byteArrayShorterThan20Bytes)).to.be.rejectedWith( + constants.REVERT, + ); + }); + + it('should pop the last 20 bytes from the input and return it', async () => { + const [newBytes, poppedAddress] = await libBytes.publicPopAddress.callAsync(byteArrayLongerThan32Bytes); + const expectedNewBytes = byteArrayLongerThan32Bytes.slice(0, -40); + const expectedPoppedAddress = `0x${byteArrayLongerThan32Bytes.slice(-40)}`; + expect(newBytes).to.equal(expectedNewBytes); + expect(poppedAddress).to.equal(expectedPoppedAddress); + }); + }); + describe('areBytesEqual', () => { it('should return true if byte arrays are equal (both arrays < 32 bytes)', async () => { const areBytesEqual = await libBytes.publicAreBytesEqual.callAsync( diff --git a/packages/contracts/test/multi_sig_with_time_lock.ts b/packages/contracts/test/multi_sig_with_time_lock.ts index ace0f0045..7b7885a00 100644 --- a/packages/contracts/test/multi_sig_with_time_lock.ts +++ b/packages/contracts/test/multi_sig_with_time_lock.ts @@ -27,6 +27,12 @@ describe('MultiSigWalletWithTimeLock', () => { 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]]; }); diff --git a/packages/contracts/test/token_registry.ts b/packages/contracts/test/token_registry.ts index 1cc519c53..7980977c8 100644 --- a/packages/contracts/test/token_registry.ts +++ b/packages/contracts/test/token_registry.ts @@ -23,6 +23,7 @@ describe('TokenRegistry', () => { let notOwner: string; let tokenReg: TokenRegistryContract; let tokenRegWrapper: TokenRegWrapper; + before(async () => { await blockchainLifecycle.startAsync(); }); diff --git a/packages/dev-utils/src/constants.ts b/packages/dev-utils/src/constants.ts index 05bcc1638..56e87d764 100644 --- a/packages/dev-utils/src/constants.ts +++ b/packages/dev-utils/src/constants.ts @@ -1,6 +1,6 @@ export const constants = { RPC_URL: 'http://localhost:8545', RPC_PORT: 8545, - GAS_ESTIMATE: 5000000, + GAS_LIMIT: 7000000, TESTRPC_FIRST_ADDRESS: '0x5409ed021d9299bf6814279a6a1411a7e866a631', }; diff --git a/packages/dev-utils/src/web3_factory.ts b/packages/dev-utils/src/web3_factory.ts index 5b32d3930..c273035da 100644 --- a/packages/dev-utils/src/web3_factory.ts +++ b/packages/dev-utils/src/web3_factory.ts @@ -28,7 +28,7 @@ export const web3Factory = { if (!hasAddresses) { provider.addProvider(new EmptyWalletSubprovider()); } - provider.addProvider(new FakeGasEstimateSubprovider(constants.GAS_ESTIMATE)); + provider.addProvider(new FakeGasEstimateSubprovider(constants.GAS_LIMIT)); const logger = { log: (arg: any) => { fs.appendFileSync('ganache.log', `${arg}\n`); @@ -41,6 +41,7 @@ export const web3Factory = { } provider.addProvider( new GanacheSubprovider({ + gasLimit: constants.GAS_LIMIT, logger, verbose: env.parseBoolean(EnvVars.VerboseGanache), port: 8545, diff --git a/packages/migrations/artifacts/2.0.0/Whitelist.json b/packages/migrations/artifacts/2.0.0/Whitelist.json new file mode 100644 index 000000000..fb2389cb8 --- /dev/null +++ b/packages/migrations/artifacts/2.0.0/Whitelist.json @@ -0,0 +1,280 @@ +{ + "schemaVersion": "2.0.0", + "contractName": "Whitelist", + "compilerOutput": { + "abi": [ + { + "constant": false, + "inputs": [ + { + "components": [ + { + "name": "makerAddress", + "type": "address" + }, + { + "name": "takerAddress", + "type": "address" + }, + { + "name": "feeRecipientAddress", + "type": "address" + }, + { + "name": "senderAddress", + "type": "address" + }, + { + "name": "makerAssetAmount", + "type": "uint256" + }, + { + "name": "takerAssetAmount", + "type": "uint256" + }, + { + "name": "makerFee", + "type": "uint256" + }, + { + "name": "takerFee", + "type": "uint256" + }, + { + "name": "expirationTimeSeconds", + "type": "uint256" + }, + { + "name": "salt", + "type": "uint256" + }, + { + "name": "makerAssetData", + "type": "bytes" + }, + { + "name": "takerAssetData", + "type": "bytes" + } + ], + "name": "order", + "type": "tuple" + }, + { + "name": "takerAssetFillAmount", + "type": "uint256" + }, + { + "name": "salt", + "type": "uint256" + }, + { + "name": "orderSignature", + "type": "bytes" + } + ], + "name": "fillOrderIfWhitelisted", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "", + "type": "address" + } + ], + "name": "isWhitelisted", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "owner", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "hash", + "type": "bytes32" + }, + { + "name": "signer", + "type": "address" + }, + { + "name": "signature", + "type": "bytes" + } + ], + "name": "isValidSignature", + "outputs": [ + { + "name": "isValid", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "target", + "type": "address" + }, + { + "name": "isApproved", + "type": "bool" + } + ], + "name": "updateWhitelistStatus", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "name": "_exchange", + "type": "address" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" + } + ], + "evm": { + "bytecode": { + "linkReferences": {}, + "object": "0x608060405234801561001057600080fd5b5060405160208062000d4883398101806040526100309190810190610173565b6000805433600160a060020a03199182161790915560028054909116600160a060020a038316179055604080517f0600000000000000000000000000000000000000000000000000000000000000602080830191909152306c0100000000000000000000000002602183015282518083036015018152603590920190925280516100be9260039201906100c5565b50506101a5565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061010657805160ff1916838001178555610133565b82800160010185558215610133579182015b82811115610133578251825591602001919060010190610118565b5061013f929150610143565b5090565b61015d91905b8082111561013f5760008155600101610149565b90565b600061016c8251610199565b9392505050565b60006020828403121561018557600080fd5b60006101918484610160565b949350505050565b600160a060020a031690565b610b9380620001b56000396000f30060806040526004361061005e5763ffffffff60e060020a600035041663141da87681146100635780633af32abf146100855780638da5cb5b146100bb57806393634702146100dd578063c07732a3146100fd578063f2fde38b1461011d575b600080fd5b34801561006f57600080fd5b5061008361007e36600461072d565b61013d565b005b34801561009157600080fd5b506100a56100a0366004610666565b61036d565b6040516100b291906109f6565b60405180910390f35b3480156100c757600080fd5b506100d0610382565b6040516100b291906109e2565b3480156100e957600080fd5b506100a56100f83660046106c6565b610391565b34801561010957600080fd5b5061008361011836600461068c565b6103a5565b34801561012957600080fd5b50610083610138366004610666565b6103fd565b6040805160608181018352602582527f53656e646572206d75737420657175616c207472616e73616374696f6e206f72602083015260d960020a6434b3b4b71702928201929092523391903283146101b45760405160e560020a62461bcd0281526004016101ab9190610a04565b60405180910390fd5b508551600160a060020a0316600090815260016020908152604091829020548251808401909352601e83527f4d616b65722061646472657373206e6f742077686974656c69737465642e00009183019190915260ff16151561022c5760405160e560020a62461bcd0281526004016101ab9190610a04565b50600160a060020a038216600090815260016020908152604091829020548251808401909352601e83527f54616b65722061646472657373206e6f742077686974656c69737465642e00009183019190915260ff1615156102a35760405160e560020a62461bcd0281526004016101ab9190610a04565b5060405160e060020a63b4be83d502906102c590889088908790602401610a25565b60408051601f19818403018152918152602082018051600160e060020a0316600160e060020a031990941693909317909252600254915160e160020a635fe45fe7028152909250600160a060020a039091169063bfc8bfce9061033390879086908690600390600401610a57565b600060405180830381600087803b15801561034d57600080fd5b505af1158015610361573d6000803e3d6000fd5b50505050505050505050565b60016020526000908152604090205460ff1681565b600054600160a060020a031681565b600160a060020a0383163214949350505050565b600054600160a060020a031633146103d25760405160e560020a62461bcd0281526004016101ab90610a15565b600160a060020a03919091166000908152600160205260409020805460ff1916911515919091179055565b600054600160a060020a0316331461042a5760405160e560020a62461bcd0281526004016101ab90610a15565b600160a060020a038116156104555760008054600160a060020a031916600160a060020a0383161790555b50565b60006104648235610aff565b9392505050565b60006104648235610b0b565b60006104648235610b10565b600080601f8301841361049557600080fd5b5081356001604060020a038111156104ac57600080fd5b6020830191508360018202830111156104c457600080fd5b9250929050565b6000601f820183136104dc57600080fd5b81356104ef6104ea82610ac8565b610aa2565b9150808252602083016020830185838301111561050b57600080fd5b610516838284610b13565b50505092915050565b6000610180828403121561053257600080fd5b61053d610180610aa2565b9050600061054b8484610458565b825250602061055c84848301610458565b602083015250604061057084828501610458565b604083015250606061058484828501610458565b606083015250608061059884828501610477565b60808301525060a06105ac84828501610477565b60a08301525060c06105c084828501610477565b60c08301525060e06105d484828501610477565b60e0830152506101006105e984828501610477565b610100830152506101206105ff84828501610477565b610120830152506101408201356001604060020a0381111561062057600080fd5b61062c848285016104cb565b610140830152506101608201356001604060020a0381111561064d57600080fd5b610659848285016104cb565b6101608301525092915050565b60006020828403121561067857600080fd5b60006106848484610458565b949350505050565b6000806040838503121561069f57600080fd5b60006106ab8585610458565b92505060206106bc8582860161046b565b9150509250929050565b600080600080606085870312156106dc57600080fd5b60006106e88787610477565b94505060206106f987828801610458565b93505060408501356001604060020a0381111561071557600080fd5b61072187828801610483565b95989497509550505050565b6000806000806080858703121561074357600080fd5b84356001604060020a0381111561075957600080fd5b6107658782880161051f565b945050602061077687828801610477565b935050604061078787828801610477565b92505060608501356001604060020a038111156107a357600080fd5b6107af878288016104cb565b91505092959194509250565b6107c481610aff565b82525050565b6107c481610b0b565b60006107de82610afb565b8084526107f2816020860160208601610b1f565b6107fb81610b4f565b9093016020019392505050565b60008154600181166000811461082557600181146108435761087f565b60028204607f16855260ff198216602086015260408501925061087f565b6002820480865260208601955061085985610aef565b60005b828110156108785781548882015260019091019060200161085c565b8701945050505b505092915050565b603381527f4f6e6c7920636f6e7472616374206f776e657220697320616c6c6f77656420746020820152606960020a72379031b0b636103a3434b99036b2ba3437b21702604082015260600190565b80516000906101808401906108eb85826107bb565b5060208301516108fe60208601826107bb565b50604083015161091160408601826107bb565b50606083015161092460608601826107bb565b50608083015161093760808601826109d9565b5060a083015161094a60a08601826109d9565b5060c083015161095d60c08601826109d9565b5060e083015161097060e08601826109d9565b506101008301516109856101008601826109d9565b5061012083015161099a6101208601826109d9565b506101408301518482036101408601526109b482826107d3565b9150506101608301518482036101608601526109d082826107d3565b95945050505050565b6107c481610b10565b602081016109f082846107bb565b92915050565b602081016109f082846107ca565b6020808252810161046481846107d3565b602080825281016109f081610887565b60608082528101610a3681866108d6565b9050610a4560208301856109d9565b81810360408301526109d081846107d3565b60808101610a6582876109d9565b610a7260208301866107bb565b8181036040830152610a8481856107d3565b90508181036060830152610a988184610808565b9695505050505050565b6040518181016001604060020a0381118282101715610ac057600080fd5b604052919050565b60006001604060020a03821115610ade57600080fd5b506020601f91909101601f19160190565b60009081526020902090565b5190565b600160a060020a031690565b151590565b90565b82818337506000910152565b60005b83811015610b3a578181015183820152602001610b22565b83811115610b49576000848401525b50505050565b601f01601f1916905600a265627a7a72305820774bf0f42469906b3f8faa7f7824ccf722967b92f0cbb483f9f82b52b91e07186c6578706572696d656e74616cf50037", + "opcodes": "PUSH1 0x80 PUSH1 0x40 MSTORE CALLVALUE DUP1 ISZERO PUSH2 0x10 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH1 0x40 MLOAD PUSH1 0x20 DUP1 PUSH3 0xD48 DUP4 CODECOPY DUP2 ADD DUP1 PUSH1 0x40 MSTORE PUSH2 0x30 SWAP2 SWAP1 DUP2 ADD SWAP1 PUSH2 0x173 JUMP JUMPDEST PUSH1 0x0 DUP1 SLOAD CALLER PUSH1 0x1 PUSH1 0xA0 PUSH1 0x2 EXP SUB NOT SWAP2 DUP3 AND OR SWAP1 SWAP2 SSTORE PUSH1 0x2 DUP1 SLOAD SWAP1 SWAP2 AND PUSH1 0x1 PUSH1 0xA0 PUSH1 0x2 EXP SUB DUP4 AND OR SWAP1 SSTORE PUSH1 0x40 DUP1 MLOAD PUSH32 0x600000000000000000000000000000000000000000000000000000000000000 PUSH1 0x20 DUP1 DUP4 ADD SWAP2 SWAP1 SWAP2 MSTORE ADDRESS PUSH13 0x1000000000000000000000000 MUL PUSH1 0x21 DUP4 ADD MSTORE DUP3 MLOAD DUP1 DUP4 SUB PUSH1 0x15 ADD DUP2 MSTORE PUSH1 0x35 SWAP1 SWAP3 ADD SWAP1 SWAP3 MSTORE DUP1 MLOAD PUSH2 0xBE SWAP3 PUSH1 0x3 SWAP3 ADD SWAP1 PUSH2 0xC5 JUMP JUMPDEST POP POP PUSH2 0x1A5 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 0x106 JUMPI DUP1 MLOAD PUSH1 0xFF NOT AND DUP4 DUP1 ADD OR DUP6 SSTORE PUSH2 0x133 JUMP JUMPDEST DUP3 DUP1 ADD PUSH1 0x1 ADD DUP6 SSTORE DUP3 ISZERO PUSH2 0x133 JUMPI SWAP2 DUP3 ADD JUMPDEST DUP3 DUP2 GT ISZERO PUSH2 0x133 JUMPI DUP3 MLOAD DUP3 SSTORE SWAP2 PUSH1 0x20 ADD SWAP2 SWAP1 PUSH1 0x1 ADD SWAP1 PUSH2 0x118 JUMP JUMPDEST POP PUSH2 0x13F SWAP3 SWAP2 POP PUSH2 0x143 JUMP JUMPDEST POP SWAP1 JUMP JUMPDEST PUSH2 0x15D SWAP2 SWAP1 JUMPDEST DUP1 DUP3 GT ISZERO PUSH2 0x13F JUMPI PUSH1 0x0 DUP2 SSTORE PUSH1 0x1 ADD PUSH2 0x149 JUMP JUMPDEST SWAP1 JUMP JUMPDEST PUSH1 0x0 PUSH2 0x16C DUP3 MLOAD PUSH2 0x199 JUMP JUMPDEST SWAP4 SWAP3 POP POP POP JUMP JUMPDEST PUSH1 0x0 PUSH1 0x20 DUP3 DUP5 SUB SLT ISZERO PUSH2 0x185 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH1 0x0 PUSH2 0x191 DUP5 DUP5 PUSH2 0x160 JUMP JUMPDEST SWAP5 SWAP4 POP POP POP POP JUMP JUMPDEST PUSH1 0x1 PUSH1 0xA0 PUSH1 0x2 EXP SUB AND SWAP1 JUMP JUMPDEST PUSH2 0xB93 DUP1 PUSH3 0x1B5 PUSH1 0x0 CODECOPY PUSH1 0x0 RETURN STOP PUSH1 0x80 PUSH1 0x40 MSTORE PUSH1 0x4 CALLDATASIZE LT PUSH2 0x5E JUMPI PUSH4 0xFFFFFFFF PUSH1 0xE0 PUSH1 0x2 EXP PUSH1 0x0 CALLDATALOAD DIV AND PUSH4 0x141DA876 DUP2 EQ PUSH2 0x63 JUMPI DUP1 PUSH4 0x3AF32ABF EQ PUSH2 0x85 JUMPI DUP1 PUSH4 0x8DA5CB5B EQ PUSH2 0xBB JUMPI DUP1 PUSH4 0x93634702 EQ PUSH2 0xDD JUMPI DUP1 PUSH4 0xC07732A3 EQ PUSH2 0xFD JUMPI DUP1 PUSH4 0xF2FDE38B EQ PUSH2 0x11D JUMPI JUMPDEST PUSH1 0x0 DUP1 REVERT JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x6F JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x83 PUSH2 0x7E CALLDATASIZE PUSH1 0x4 PUSH2 0x72D JUMP JUMPDEST PUSH2 0x13D JUMP JUMPDEST STOP JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x91 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0xA5 PUSH2 0xA0 CALLDATASIZE PUSH1 0x4 PUSH2 0x666 JUMP JUMPDEST PUSH2 0x36D JUMP JUMPDEST PUSH1 0x40 MLOAD PUSH2 0xB2 SWAP2 SWAP1 PUSH2 0x9F6 JUMP JUMPDEST PUSH1 0x40 MLOAD DUP1 SWAP2 SUB SWAP1 RETURN JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0xC7 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0xD0 PUSH2 0x382 JUMP JUMPDEST PUSH1 0x40 MLOAD PUSH2 0xB2 SWAP2 SWAP1 PUSH2 0x9E2 JUMP JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0xE9 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0xA5 PUSH2 0xF8 CALLDATASIZE PUSH1 0x4 PUSH2 0x6C6 JUMP JUMPDEST PUSH2 0x391 JUMP JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x109 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x83 PUSH2 0x118 CALLDATASIZE PUSH1 0x4 PUSH2 0x68C JUMP JUMPDEST PUSH2 0x3A5 JUMP JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x129 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x83 PUSH2 0x138 CALLDATASIZE PUSH1 0x4 PUSH2 0x666 JUMP JUMPDEST PUSH2 0x3FD JUMP JUMPDEST PUSH1 0x40 DUP1 MLOAD PUSH1 0x60 DUP2 DUP2 ADD DUP4 MSTORE PUSH1 0x25 DUP3 MSTORE PUSH32 0x53656E646572206D75737420657175616C207472616E73616374696F6E206F72 PUSH1 0x20 DUP4 ADD MSTORE PUSH1 0xD9 PUSH1 0x2 EXP PUSH5 0x34B3B4B717 MUL SWAP3 DUP3 ADD SWAP3 SWAP1 SWAP3 MSTORE CALLER SWAP2 SWAP1 ORIGIN DUP4 EQ PUSH2 0x1B4 JUMPI PUSH1 0x40 MLOAD PUSH1 0xE5 PUSH1 0x2 EXP PUSH3 0x461BCD MUL DUP2 MSTORE PUSH1 0x4 ADD PUSH2 0x1AB SWAP2 SWAP1 PUSH2 0xA04 JUMP JUMPDEST PUSH1 0x40 MLOAD DUP1 SWAP2 SUB SWAP1 REVERT JUMPDEST POP DUP6 MLOAD PUSH1 0x1 PUSH1 0xA0 PUSH1 0x2 EXP SUB AND PUSH1 0x0 SWAP1 DUP2 MSTORE PUSH1 0x1 PUSH1 0x20 SWAP1 DUP2 MSTORE PUSH1 0x40 SWAP2 DUP3 SWAP1 KECCAK256 SLOAD DUP3 MLOAD DUP1 DUP5 ADD SWAP1 SWAP4 MSTORE PUSH1 0x1E DUP4 MSTORE PUSH32 0x4D616B65722061646472657373206E6F742077686974656C69737465642E0000 SWAP2 DUP4 ADD SWAP2 SWAP1 SWAP2 MSTORE PUSH1 0xFF AND ISZERO ISZERO PUSH2 0x22C JUMPI PUSH1 0x40 MLOAD PUSH1 0xE5 PUSH1 0x2 EXP PUSH3 0x461BCD MUL DUP2 MSTORE PUSH1 0x4 ADD PUSH2 0x1AB SWAP2 SWAP1 PUSH2 0xA04 JUMP JUMPDEST POP PUSH1 0x1 PUSH1 0xA0 PUSH1 0x2 EXP SUB DUP3 AND PUSH1 0x0 SWAP1 DUP2 MSTORE PUSH1 0x1 PUSH1 0x20 SWAP1 DUP2 MSTORE PUSH1 0x40 SWAP2 DUP3 SWAP1 KECCAK256 SLOAD DUP3 MLOAD DUP1 DUP5 ADD SWAP1 SWAP4 MSTORE PUSH1 0x1E DUP4 MSTORE PUSH32 0x54616B65722061646472657373206E6F742077686974656C69737465642E0000 SWAP2 DUP4 ADD SWAP2 SWAP1 SWAP2 MSTORE PUSH1 0xFF AND ISZERO ISZERO PUSH2 0x2A3 JUMPI PUSH1 0x40 MLOAD PUSH1 0xE5 PUSH1 0x2 EXP PUSH3 0x461BCD MUL DUP2 MSTORE PUSH1 0x4 ADD PUSH2 0x1AB SWAP2 SWAP1 PUSH2 0xA04 JUMP JUMPDEST POP PUSH1 0x40 MLOAD PUSH1 0xE0 PUSH1 0x2 EXP PUSH4 0xB4BE83D5 MUL SWAP1 PUSH2 0x2C5 SWAP1 DUP9 SWAP1 DUP9 SWAP1 DUP8 SWAP1 PUSH1 0x24 ADD PUSH2 0xA25 JUMP JUMPDEST PUSH1 0x40 DUP1 MLOAD PUSH1 0x1F NOT DUP2 DUP5 SUB ADD DUP2 MSTORE SWAP2 DUP2 MSTORE PUSH1 0x20 DUP3 ADD DUP1 MLOAD PUSH1 0x1 PUSH1 0xE0 PUSH1 0x2 EXP SUB AND PUSH1 0x1 PUSH1 0xE0 PUSH1 0x2 EXP SUB NOT SWAP1 SWAP5 AND SWAP4 SWAP1 SWAP4 OR SWAP1 SWAP3 MSTORE PUSH1 0x2 SLOAD SWAP2 MLOAD PUSH1 0xE1 PUSH1 0x2 EXP PUSH4 0x5FE45FE7 MUL DUP2 MSTORE SWAP1 SWAP3 POP PUSH1 0x1 PUSH1 0xA0 PUSH1 0x2 EXP SUB SWAP1 SWAP2 AND SWAP1 PUSH4 0xBFC8BFCE SWAP1 PUSH2 0x333 SWAP1 DUP8 SWAP1 DUP7 SWAP1 DUP7 SWAP1 PUSH1 0x3 SWAP1 PUSH1 0x4 ADD PUSH2 0xA57 JUMP JUMPDEST PUSH1 0x0 PUSH1 0x40 MLOAD DUP1 DUP4 SUB DUP2 PUSH1 0x0 DUP8 DUP1 EXTCODESIZE ISZERO DUP1 ISZERO PUSH2 0x34D JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP GAS CALL ISZERO DUP1 ISZERO PUSH2 0x361 JUMPI RETURNDATASIZE PUSH1 0x0 DUP1 RETURNDATACOPY RETURNDATASIZE PUSH1 0x0 REVERT JUMPDEST POP POP POP POP POP POP POP POP POP POP JUMP JUMPDEST PUSH1 0x1 PUSH1 0x20 MSTORE PUSH1 0x0 SWAP1 DUP2 MSTORE PUSH1 0x40 SWAP1 KECCAK256 SLOAD PUSH1 0xFF AND DUP2 JUMP JUMPDEST PUSH1 0x0 SLOAD PUSH1 0x1 PUSH1 0xA0 PUSH1 0x2 EXP SUB AND DUP2 JUMP JUMPDEST PUSH1 0x1 PUSH1 0xA0 PUSH1 0x2 EXP SUB DUP4 AND ORIGIN EQ SWAP5 SWAP4 POP POP POP POP JUMP JUMPDEST PUSH1 0x0 SLOAD PUSH1 0x1 PUSH1 0xA0 PUSH1 0x2 EXP SUB AND CALLER EQ PUSH2 0x3D2 JUMPI PUSH1 0x40 MLOAD PUSH1 0xE5 PUSH1 0x2 EXP PUSH3 0x461BCD MUL DUP2 MSTORE PUSH1 0x4 ADD PUSH2 0x1AB SWAP1 PUSH2 0xA15 JUMP JUMPDEST PUSH1 0x1 PUSH1 0xA0 PUSH1 0x2 EXP SUB SWAP2 SWAP1 SWAP2 AND PUSH1 0x0 SWAP1 DUP2 MSTORE PUSH1 0x1 PUSH1 0x20 MSTORE PUSH1 0x40 SWAP1 KECCAK256 DUP1 SLOAD PUSH1 0xFF NOT AND SWAP2 ISZERO ISZERO SWAP2 SWAP1 SWAP2 OR SWAP1 SSTORE JUMP JUMPDEST PUSH1 0x0 SLOAD PUSH1 0x1 PUSH1 0xA0 PUSH1 0x2 EXP SUB AND CALLER EQ PUSH2 0x42A JUMPI PUSH1 0x40 MLOAD PUSH1 0xE5 PUSH1 0x2 EXP PUSH3 0x461BCD MUL DUP2 MSTORE PUSH1 0x4 ADD PUSH2 0x1AB SWAP1 PUSH2 0xA15 JUMP JUMPDEST PUSH1 0x1 PUSH1 0xA0 PUSH1 0x2 EXP SUB DUP2 AND ISZERO PUSH2 0x455 JUMPI PUSH1 0x0 DUP1 SLOAD PUSH1 0x1 PUSH1 0xA0 PUSH1 0x2 EXP SUB NOT AND PUSH1 0x1 PUSH1 0xA0 PUSH1 0x2 EXP SUB DUP4 AND OR SWAP1 SSTORE JUMPDEST POP JUMP JUMPDEST PUSH1 0x0 PUSH2 0x464 DUP3 CALLDATALOAD PUSH2 0xAFF JUMP JUMPDEST SWAP4 SWAP3 POP POP POP JUMP JUMPDEST PUSH1 0x0 PUSH2 0x464 DUP3 CALLDATALOAD PUSH2 0xB0B JUMP JUMPDEST PUSH1 0x0 PUSH2 0x464 DUP3 CALLDATALOAD PUSH2 0xB10 JUMP JUMPDEST PUSH1 0x0 DUP1 PUSH1 0x1F DUP4 ADD DUP5 SGT PUSH2 0x495 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP DUP2 CALLDATALOAD PUSH1 0x1 PUSH1 0x40 PUSH1 0x2 EXP SUB DUP2 GT ISZERO PUSH2 0x4AC JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH1 0x20 DUP4 ADD SWAP2 POP DUP4 PUSH1 0x1 DUP3 MUL DUP4 ADD GT ISZERO PUSH2 0x4C4 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST SWAP3 POP SWAP3 SWAP1 POP JUMP JUMPDEST PUSH1 0x0 PUSH1 0x1F DUP3 ADD DUP4 SGT PUSH2 0x4DC JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST DUP2 CALLDATALOAD PUSH2 0x4EF PUSH2 0x4EA DUP3 PUSH2 0xAC8 JUMP JUMPDEST PUSH2 0xAA2 JUMP JUMPDEST SWAP2 POP DUP1 DUP3 MSTORE PUSH1 0x20 DUP4 ADD PUSH1 0x20 DUP4 ADD DUP6 DUP4 DUP4 ADD GT ISZERO PUSH2 0x50B JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH2 0x516 DUP4 DUP3 DUP5 PUSH2 0xB13 JUMP JUMPDEST POP POP POP SWAP3 SWAP2 POP POP JUMP JUMPDEST PUSH1 0x0 PUSH2 0x180 DUP3 DUP5 SUB SLT ISZERO PUSH2 0x532 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH2 0x53D PUSH2 0x180 PUSH2 0xAA2 JUMP JUMPDEST SWAP1 POP PUSH1 0x0 PUSH2 0x54B DUP5 DUP5 PUSH2 0x458 JUMP JUMPDEST DUP3 MSTORE POP PUSH1 0x20 PUSH2 0x55C DUP5 DUP5 DUP4 ADD PUSH2 0x458 JUMP JUMPDEST PUSH1 0x20 DUP4 ADD MSTORE POP PUSH1 0x40 PUSH2 0x570 DUP5 DUP3 DUP6 ADD PUSH2 0x458 JUMP JUMPDEST PUSH1 0x40 DUP4 ADD MSTORE POP PUSH1 0x60 PUSH2 0x584 DUP5 DUP3 DUP6 ADD PUSH2 0x458 JUMP JUMPDEST PUSH1 0x60 DUP4 ADD MSTORE POP PUSH1 0x80 PUSH2 0x598 DUP5 DUP3 DUP6 ADD PUSH2 0x477 JUMP JUMPDEST PUSH1 0x80 DUP4 ADD MSTORE POP PUSH1 0xA0 PUSH2 0x5AC DUP5 DUP3 DUP6 ADD PUSH2 0x477 JUMP JUMPDEST PUSH1 0xA0 DUP4 ADD MSTORE POP PUSH1 0xC0 PUSH2 0x5C0 DUP5 DUP3 DUP6 ADD PUSH2 0x477 JUMP JUMPDEST PUSH1 0xC0 DUP4 ADD MSTORE POP PUSH1 0xE0 PUSH2 0x5D4 DUP5 DUP3 DUP6 ADD PUSH2 0x477 JUMP JUMPDEST PUSH1 0xE0 DUP4 ADD MSTORE POP PUSH2 0x100 PUSH2 0x5E9 DUP5 DUP3 DUP6 ADD PUSH2 0x477 JUMP JUMPDEST PUSH2 0x100 DUP4 ADD MSTORE POP PUSH2 0x120 PUSH2 0x5FF DUP5 DUP3 DUP6 ADD PUSH2 0x477 JUMP JUMPDEST PUSH2 0x120 DUP4 ADD MSTORE POP PUSH2 0x140 DUP3 ADD CALLDATALOAD PUSH1 0x1 PUSH1 0x40 PUSH1 0x2 EXP SUB DUP2 GT ISZERO PUSH2 0x620 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH2 0x62C DUP5 DUP3 DUP6 ADD PUSH2 0x4CB JUMP JUMPDEST PUSH2 0x140 DUP4 ADD MSTORE POP PUSH2 0x160 DUP3 ADD CALLDATALOAD PUSH1 0x1 PUSH1 0x40 PUSH1 0x2 EXP SUB DUP2 GT ISZERO PUSH2 0x64D JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH2 0x659 DUP5 DUP3 DUP6 ADD PUSH2 0x4CB JUMP JUMPDEST PUSH2 0x160 DUP4 ADD MSTORE POP SWAP3 SWAP2 POP POP JUMP JUMPDEST PUSH1 0x0 PUSH1 0x20 DUP3 DUP5 SUB SLT ISZERO PUSH2 0x678 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH1 0x0 PUSH2 0x684 DUP5 DUP5 PUSH2 0x458 JUMP JUMPDEST SWAP5 SWAP4 POP POP POP POP JUMP JUMPDEST PUSH1 0x0 DUP1 PUSH1 0x40 DUP4 DUP6 SUB SLT ISZERO PUSH2 0x69F JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH1 0x0 PUSH2 0x6AB DUP6 DUP6 PUSH2 0x458 JUMP JUMPDEST SWAP3 POP POP PUSH1 0x20 PUSH2 0x6BC DUP6 DUP3 DUP7 ADD PUSH2 0x46B JUMP JUMPDEST SWAP2 POP POP SWAP3 POP SWAP3 SWAP1 POP JUMP JUMPDEST PUSH1 0x0 DUP1 PUSH1 0x0 DUP1 PUSH1 0x60 DUP6 DUP8 SUB SLT ISZERO PUSH2 0x6DC JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH1 0x0 PUSH2 0x6E8 DUP8 DUP8 PUSH2 0x477 JUMP JUMPDEST SWAP5 POP POP PUSH1 0x20 PUSH2 0x6F9 DUP8 DUP3 DUP9 ADD PUSH2 0x458 JUMP JUMPDEST SWAP4 POP POP PUSH1 0x40 DUP6 ADD CALLDATALOAD PUSH1 0x1 PUSH1 0x40 PUSH1 0x2 EXP SUB DUP2 GT ISZERO PUSH2 0x715 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH2 0x721 DUP8 DUP3 DUP9 ADD PUSH2 0x483 JUMP JUMPDEST SWAP6 SWAP9 SWAP5 SWAP8 POP SWAP6 POP POP POP POP JUMP JUMPDEST PUSH1 0x0 DUP1 PUSH1 0x0 DUP1 PUSH1 0x80 DUP6 DUP8 SUB SLT ISZERO PUSH2 0x743 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST DUP5 CALLDATALOAD PUSH1 0x1 PUSH1 0x40 PUSH1 0x2 EXP SUB DUP2 GT ISZERO PUSH2 0x759 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH2 0x765 DUP8 DUP3 DUP9 ADD PUSH2 0x51F JUMP JUMPDEST SWAP5 POP POP PUSH1 0x20 PUSH2 0x776 DUP8 DUP3 DUP9 ADD PUSH2 0x477 JUMP JUMPDEST SWAP4 POP POP PUSH1 0x40 PUSH2 0x787 DUP8 DUP3 DUP9 ADD PUSH2 0x477 JUMP JUMPDEST SWAP3 POP POP PUSH1 0x60 DUP6 ADD CALLDATALOAD PUSH1 0x1 PUSH1 0x40 PUSH1 0x2 EXP SUB DUP2 GT ISZERO PUSH2 0x7A3 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH2 0x7AF DUP8 DUP3 DUP9 ADD PUSH2 0x4CB JUMP JUMPDEST SWAP2 POP POP SWAP3 SWAP6 SWAP2 SWAP5 POP SWAP3 POP JUMP JUMPDEST PUSH2 0x7C4 DUP2 PUSH2 0xAFF JUMP JUMPDEST DUP3 MSTORE POP POP JUMP JUMPDEST PUSH2 0x7C4 DUP2 PUSH2 0xB0B JUMP JUMPDEST PUSH1 0x0 PUSH2 0x7DE DUP3 PUSH2 0xAFB JUMP JUMPDEST DUP1 DUP5 MSTORE PUSH2 0x7F2 DUP2 PUSH1 0x20 DUP7 ADD PUSH1 0x20 DUP7 ADD PUSH2 0xB1F JUMP JUMPDEST PUSH2 0x7FB DUP2 PUSH2 0xB4F JUMP JUMPDEST SWAP1 SWAP4 ADD PUSH1 0x20 ADD SWAP4 SWAP3 POP POP POP JUMP JUMPDEST PUSH1 0x0 DUP2 SLOAD PUSH1 0x1 DUP2 AND PUSH1 0x0 DUP2 EQ PUSH2 0x825 JUMPI PUSH1 0x1 DUP2 EQ PUSH2 0x843 JUMPI PUSH2 0x87F JUMP JUMPDEST PUSH1 0x2 DUP3 DIV PUSH1 0x7F AND DUP6 MSTORE PUSH1 0xFF NOT DUP3 AND PUSH1 0x20 DUP7 ADD MSTORE PUSH1 0x40 DUP6 ADD SWAP3 POP PUSH2 0x87F JUMP JUMPDEST PUSH1 0x2 DUP3 DIV DUP1 DUP7 MSTORE PUSH1 0x20 DUP7 ADD SWAP6 POP PUSH2 0x859 DUP6 PUSH2 0xAEF JUMP JUMPDEST PUSH1 0x0 JUMPDEST DUP3 DUP2 LT ISZERO PUSH2 0x878 JUMPI DUP2 SLOAD DUP9 DUP3 ADD MSTORE PUSH1 0x1 SWAP1 SWAP2 ADD SWAP1 PUSH1 0x20 ADD PUSH2 0x85C JUMP JUMPDEST DUP8 ADD SWAP5 POP POP POP JUMPDEST POP POP SWAP3 SWAP2 POP POP JUMP JUMPDEST PUSH1 0x33 DUP2 MSTORE PUSH32 0x4F6E6C7920636F6E7472616374206F776E657220697320616C6C6F7765642074 PUSH1 0x20 DUP3 ADD MSTORE PUSH1 0x69 PUSH1 0x2 EXP PUSH19 0x379031B0B636103A3434B99036B2BA3437B217 MUL PUSH1 0x40 DUP3 ADD MSTORE PUSH1 0x60 ADD SWAP1 JUMP JUMPDEST DUP1 MLOAD PUSH1 0x0 SWAP1 PUSH2 0x180 DUP5 ADD SWAP1 PUSH2 0x8EB DUP6 DUP3 PUSH2 0x7BB JUMP JUMPDEST POP PUSH1 0x20 DUP4 ADD MLOAD PUSH2 0x8FE PUSH1 0x20 DUP7 ADD DUP3 PUSH2 0x7BB JUMP JUMPDEST POP PUSH1 0x40 DUP4 ADD MLOAD PUSH2 0x911 PUSH1 0x40 DUP7 ADD DUP3 PUSH2 0x7BB JUMP JUMPDEST POP PUSH1 0x60 DUP4 ADD MLOAD PUSH2 0x924 PUSH1 0x60 DUP7 ADD DUP3 PUSH2 0x7BB JUMP JUMPDEST POP PUSH1 0x80 DUP4 ADD MLOAD PUSH2 0x937 PUSH1 0x80 DUP7 ADD DUP3 PUSH2 0x9D9 JUMP JUMPDEST POP PUSH1 0xA0 DUP4 ADD MLOAD PUSH2 0x94A PUSH1 0xA0 DUP7 ADD DUP3 PUSH2 0x9D9 JUMP JUMPDEST POP PUSH1 0xC0 DUP4 ADD MLOAD PUSH2 0x95D PUSH1 0xC0 DUP7 ADD DUP3 PUSH2 0x9D9 JUMP JUMPDEST POP PUSH1 0xE0 DUP4 ADD MLOAD PUSH2 0x970 PUSH1 0xE0 DUP7 ADD DUP3 PUSH2 0x9D9 JUMP JUMPDEST POP PUSH2 0x100 DUP4 ADD MLOAD PUSH2 0x985 PUSH2 0x100 DUP7 ADD DUP3 PUSH2 0x9D9 JUMP JUMPDEST POP PUSH2 0x120 DUP4 ADD MLOAD PUSH2 0x99A PUSH2 0x120 DUP7 ADD DUP3 PUSH2 0x9D9 JUMP JUMPDEST POP PUSH2 0x140 DUP4 ADD MLOAD DUP5 DUP3 SUB PUSH2 0x140 DUP7 ADD MSTORE PUSH2 0x9B4 DUP3 DUP3 PUSH2 0x7D3 JUMP JUMPDEST SWAP2 POP POP PUSH2 0x160 DUP4 ADD MLOAD DUP5 DUP3 SUB PUSH2 0x160 DUP7 ADD MSTORE PUSH2 0x9D0 DUP3 DUP3 PUSH2 0x7D3 JUMP JUMPDEST SWAP6 SWAP5 POP POP POP POP POP JUMP JUMPDEST PUSH2 0x7C4 DUP2 PUSH2 0xB10 JUMP JUMPDEST PUSH1 0x20 DUP2 ADD PUSH2 0x9F0 DUP3 DUP5 PUSH2 0x7BB JUMP JUMPDEST SWAP3 SWAP2 POP POP JUMP JUMPDEST PUSH1 0x20 DUP2 ADD PUSH2 0x9F0 DUP3 DUP5 PUSH2 0x7CA JUMP JUMPDEST PUSH1 0x20 DUP1 DUP3 MSTORE DUP2 ADD PUSH2 0x464 DUP2 DUP5 PUSH2 0x7D3 JUMP JUMPDEST PUSH1 0x20 DUP1 DUP3 MSTORE DUP2 ADD PUSH2 0x9F0 DUP2 PUSH2 0x887 JUMP JUMPDEST PUSH1 0x60 DUP1 DUP3 MSTORE DUP2 ADD PUSH2 0xA36 DUP2 DUP7 PUSH2 0x8D6 JUMP JUMPDEST SWAP1 POP PUSH2 0xA45 PUSH1 0x20 DUP4 ADD DUP6 PUSH2 0x9D9 JUMP JUMPDEST DUP2 DUP2 SUB PUSH1 0x40 DUP4 ADD MSTORE PUSH2 0x9D0 DUP2 DUP5 PUSH2 0x7D3 JUMP JUMPDEST PUSH1 0x80 DUP2 ADD PUSH2 0xA65 DUP3 DUP8 PUSH2 0x9D9 JUMP JUMPDEST PUSH2 0xA72 PUSH1 0x20 DUP4 ADD DUP7 PUSH2 0x7BB JUMP JUMPDEST DUP2 DUP2 SUB PUSH1 0x40 DUP4 ADD MSTORE PUSH2 0xA84 DUP2 DUP6 PUSH2 0x7D3 JUMP JUMPDEST SWAP1 POP DUP2 DUP2 SUB PUSH1 0x60 DUP4 ADD MSTORE PUSH2 0xA98 DUP2 DUP5 PUSH2 0x808 JUMP JUMPDEST SWAP7 SWAP6 POP POP POP POP POP POP JUMP JUMPDEST PUSH1 0x40 MLOAD DUP2 DUP2 ADD PUSH1 0x1 PUSH1 0x40 PUSH1 0x2 EXP SUB DUP2 GT DUP3 DUP3 LT OR ISZERO PUSH2 0xAC0 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH1 0x40 MSTORE SWAP2 SWAP1 POP JUMP JUMPDEST PUSH1 0x0 PUSH1 0x1 PUSH1 0x40 PUSH1 0x2 EXP SUB DUP3 GT ISZERO PUSH2 0xADE JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH1 0x20 PUSH1 0x1F SWAP2 SWAP1 SWAP2 ADD PUSH1 0x1F NOT AND ADD SWAP1 JUMP JUMPDEST PUSH1 0x0 SWAP1 DUP2 MSTORE PUSH1 0x20 SWAP1 KECCAK256 SWAP1 JUMP JUMPDEST MLOAD SWAP1 JUMP JUMPDEST PUSH1 0x1 PUSH1 0xA0 PUSH1 0x2 EXP SUB AND SWAP1 JUMP JUMPDEST ISZERO ISZERO SWAP1 JUMP JUMPDEST SWAP1 JUMP JUMPDEST DUP3 DUP2 DUP4 CALLDATACOPY POP PUSH1 0x0 SWAP2 ADD MSTORE JUMP JUMPDEST PUSH1 0x0 JUMPDEST DUP4 DUP2 LT ISZERO PUSH2 0xB3A JUMPI DUP2 DUP2 ADD MLOAD DUP4 DUP3 ADD MSTORE PUSH1 0x20 ADD PUSH2 0xB22 JUMP JUMPDEST DUP4 DUP2 GT ISZERO PUSH2 0xB49 JUMPI PUSH1 0x0 DUP5 DUP5 ADD MSTORE JUMPDEST POP POP POP POP JUMP JUMPDEST PUSH1 0x1F ADD PUSH1 0x1F NOT AND SWAP1 JUMP STOP LOG2 PUSH6 0x627A7A723058 KECCAK256 PUSH24 0x4BF0F42469906B3F8FAA7F7824CCF722967B92F0CBB483F9 0xf8 0x2b MSTORE 0xb9 0x1e SMOD XOR PUSH13 0x6578706572696D656E74616CF5 STOP CALLDATACOPY ", + "sourceMap": "794:3284:9:-;;;1328:188;8:9:-1;5:2;;;30:1;27;20:12;5:2;1328:188:9;;;;;;;;;;;;;;;;;;;;;;363:5:11;:18;;371:10;-1:-1:-1;;;;;;363:18:11;;;;;;;1389:8:9;:31;;;;;-1:-1:-1;;;;;1389:31:9;;;;;1452:57;;;1469:24;1452:57;;;;;;;;1503:4;1452:57;;;;;;;;26:21:-1;;;22:32;;6:49;;1452:57:9;;;;;;;1430:79;;;;:19;;:79;;;:::i;:::-;;1328:188;794:3284;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;794:3284:9;;;-1:-1:-1;794:3284:9;:::i;:::-;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;:::o;5:122:-1:-;;83:39;114:6;108:13;83:39;;;74:48;68:59;-1:-1;;;68:59;134:263;;249:2;237:9;228:7;224:23;220:32;217:2;;;265:1;262;255:12;217:2;300:1;317:64;373:7;353:9;317:64;;;307:74;211:186;-1:-1;;;;211:186;404:128;-1:-1;;;;;473:54;;456:76;;794:3284:9;;;;;;" + }, + "deployedBytecode": { + "linkReferences": {}, + "object": "0x60806040526004361061005e5763ffffffff60e060020a600035041663141da87681146100635780633af32abf146100855780638da5cb5b146100bb57806393634702146100dd578063c07732a3146100fd578063f2fde38b1461011d575b600080fd5b34801561006f57600080fd5b5061008361007e36600461072d565b61013d565b005b34801561009157600080fd5b506100a56100a0366004610666565b61036d565b6040516100b291906109f6565b60405180910390f35b3480156100c757600080fd5b506100d0610382565b6040516100b291906109e2565b3480156100e957600080fd5b506100a56100f83660046106c6565b610391565b34801561010957600080fd5b5061008361011836600461068c565b6103a5565b34801561012957600080fd5b50610083610138366004610666565b6103fd565b6040805160608181018352602582527f53656e646572206d75737420657175616c207472616e73616374696f6e206f72602083015260d960020a6434b3b4b71702928201929092523391903283146101b45760405160e560020a62461bcd0281526004016101ab9190610a04565b60405180910390fd5b508551600160a060020a0316600090815260016020908152604091829020548251808401909352601e83527f4d616b65722061646472657373206e6f742077686974656c69737465642e00009183019190915260ff16151561022c5760405160e560020a62461bcd0281526004016101ab9190610a04565b50600160a060020a038216600090815260016020908152604091829020548251808401909352601e83527f54616b65722061646472657373206e6f742077686974656c69737465642e00009183019190915260ff1615156102a35760405160e560020a62461bcd0281526004016101ab9190610a04565b5060405160e060020a63b4be83d502906102c590889088908790602401610a25565b60408051601f19818403018152918152602082018051600160e060020a0316600160e060020a031990941693909317909252600254915160e160020a635fe45fe7028152909250600160a060020a039091169063bfc8bfce9061033390879086908690600390600401610a57565b600060405180830381600087803b15801561034d57600080fd5b505af1158015610361573d6000803e3d6000fd5b50505050505050505050565b60016020526000908152604090205460ff1681565b600054600160a060020a031681565b600160a060020a0383163214949350505050565b600054600160a060020a031633146103d25760405160e560020a62461bcd0281526004016101ab90610a15565b600160a060020a03919091166000908152600160205260409020805460ff1916911515919091179055565b600054600160a060020a0316331461042a5760405160e560020a62461bcd0281526004016101ab90610a15565b600160a060020a038116156104555760008054600160a060020a031916600160a060020a0383161790555b50565b60006104648235610aff565b9392505050565b60006104648235610b0b565b60006104648235610b10565b600080601f8301841361049557600080fd5b5081356001604060020a038111156104ac57600080fd5b6020830191508360018202830111156104c457600080fd5b9250929050565b6000601f820183136104dc57600080fd5b81356104ef6104ea82610ac8565b610aa2565b9150808252602083016020830185838301111561050b57600080fd5b610516838284610b13565b50505092915050565b6000610180828403121561053257600080fd5b61053d610180610aa2565b9050600061054b8484610458565b825250602061055c84848301610458565b602083015250604061057084828501610458565b604083015250606061058484828501610458565b606083015250608061059884828501610477565b60808301525060a06105ac84828501610477565b60a08301525060c06105c084828501610477565b60c08301525060e06105d484828501610477565b60e0830152506101006105e984828501610477565b610100830152506101206105ff84828501610477565b610120830152506101408201356001604060020a0381111561062057600080fd5b61062c848285016104cb565b610140830152506101608201356001604060020a0381111561064d57600080fd5b610659848285016104cb565b6101608301525092915050565b60006020828403121561067857600080fd5b60006106848484610458565b949350505050565b6000806040838503121561069f57600080fd5b60006106ab8585610458565b92505060206106bc8582860161046b565b9150509250929050565b600080600080606085870312156106dc57600080fd5b60006106e88787610477565b94505060206106f987828801610458565b93505060408501356001604060020a0381111561071557600080fd5b61072187828801610483565b95989497509550505050565b6000806000806080858703121561074357600080fd5b84356001604060020a0381111561075957600080fd5b6107658782880161051f565b945050602061077687828801610477565b935050604061078787828801610477565b92505060608501356001604060020a038111156107a357600080fd5b6107af878288016104cb565b91505092959194509250565b6107c481610aff565b82525050565b6107c481610b0b565b60006107de82610afb565b8084526107f2816020860160208601610b1f565b6107fb81610b4f565b9093016020019392505050565b60008154600181166000811461082557600181146108435761087f565b60028204607f16855260ff198216602086015260408501925061087f565b6002820480865260208601955061085985610aef565b60005b828110156108785781548882015260019091019060200161085c565b8701945050505b505092915050565b603381527f4f6e6c7920636f6e7472616374206f776e657220697320616c6c6f77656420746020820152606960020a72379031b0b636103a3434b99036b2ba3437b21702604082015260600190565b80516000906101808401906108eb85826107bb565b5060208301516108fe60208601826107bb565b50604083015161091160408601826107bb565b50606083015161092460608601826107bb565b50608083015161093760808601826109d9565b5060a083015161094a60a08601826109d9565b5060c083015161095d60c08601826109d9565b5060e083015161097060e08601826109d9565b506101008301516109856101008601826109d9565b5061012083015161099a6101208601826109d9565b506101408301518482036101408601526109b482826107d3565b9150506101608301518482036101608601526109d082826107d3565b95945050505050565b6107c481610b10565b602081016109f082846107bb565b92915050565b602081016109f082846107ca565b6020808252810161046481846107d3565b602080825281016109f081610887565b60608082528101610a3681866108d6565b9050610a4560208301856109d9565b81810360408301526109d081846107d3565b60808101610a6582876109d9565b610a7260208301866107bb565b8181036040830152610a8481856107d3565b90508181036060830152610a988184610808565b9695505050505050565b6040518181016001604060020a0381118282101715610ac057600080fd5b604052919050565b60006001604060020a03821115610ade57600080fd5b506020601f91909101601f19160190565b60009081526020902090565b5190565b600160a060020a031690565b151590565b90565b82818337506000910152565b60005b83811015610b3a578181015183820152602001610b22565b83811115610b49576000848401525b50505050565b601f01601f1916905600a265627a7a72305820774bf0f42469906b3f8faa7f7824ccf722967b92f0cbb483f9f82b52b91e07186c6578706572696d656e74616cf50037", + "opcodes": "PUSH1 0x80 PUSH1 0x40 MSTORE PUSH1 0x4 CALLDATASIZE LT PUSH2 0x5E JUMPI PUSH4 0xFFFFFFFF PUSH1 0xE0 PUSH1 0x2 EXP PUSH1 0x0 CALLDATALOAD DIV AND PUSH4 0x141DA876 DUP2 EQ PUSH2 0x63 JUMPI DUP1 PUSH4 0x3AF32ABF EQ PUSH2 0x85 JUMPI DUP1 PUSH4 0x8DA5CB5B EQ PUSH2 0xBB JUMPI DUP1 PUSH4 0x93634702 EQ PUSH2 0xDD JUMPI DUP1 PUSH4 0xC07732A3 EQ PUSH2 0xFD JUMPI DUP1 PUSH4 0xF2FDE38B EQ PUSH2 0x11D JUMPI JUMPDEST PUSH1 0x0 DUP1 REVERT JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x6F JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x83 PUSH2 0x7E CALLDATASIZE PUSH1 0x4 PUSH2 0x72D JUMP JUMPDEST PUSH2 0x13D JUMP JUMPDEST STOP JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x91 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0xA5 PUSH2 0xA0 CALLDATASIZE PUSH1 0x4 PUSH2 0x666 JUMP JUMPDEST PUSH2 0x36D JUMP JUMPDEST PUSH1 0x40 MLOAD PUSH2 0xB2 SWAP2 SWAP1 PUSH2 0x9F6 JUMP JUMPDEST PUSH1 0x40 MLOAD DUP1 SWAP2 SUB SWAP1 RETURN JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0xC7 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0xD0 PUSH2 0x382 JUMP JUMPDEST PUSH1 0x40 MLOAD PUSH2 0xB2 SWAP2 SWAP1 PUSH2 0x9E2 JUMP JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0xE9 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0xA5 PUSH2 0xF8 CALLDATASIZE PUSH1 0x4 PUSH2 0x6C6 JUMP JUMPDEST PUSH2 0x391 JUMP JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x109 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x83 PUSH2 0x118 CALLDATASIZE PUSH1 0x4 PUSH2 0x68C JUMP JUMPDEST PUSH2 0x3A5 JUMP JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x129 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x83 PUSH2 0x138 CALLDATASIZE PUSH1 0x4 PUSH2 0x666 JUMP JUMPDEST PUSH2 0x3FD JUMP JUMPDEST PUSH1 0x40 DUP1 MLOAD PUSH1 0x60 DUP2 DUP2 ADD DUP4 MSTORE PUSH1 0x25 DUP3 MSTORE PUSH32 0x53656E646572206D75737420657175616C207472616E73616374696F6E206F72 PUSH1 0x20 DUP4 ADD MSTORE PUSH1 0xD9 PUSH1 0x2 EXP PUSH5 0x34B3B4B717 MUL SWAP3 DUP3 ADD SWAP3 SWAP1 SWAP3 MSTORE CALLER SWAP2 SWAP1 ORIGIN DUP4 EQ PUSH2 0x1B4 JUMPI PUSH1 0x40 MLOAD PUSH1 0xE5 PUSH1 0x2 EXP PUSH3 0x461BCD MUL DUP2 MSTORE PUSH1 0x4 ADD PUSH2 0x1AB SWAP2 SWAP1 PUSH2 0xA04 JUMP JUMPDEST PUSH1 0x40 MLOAD DUP1 SWAP2 SUB SWAP1 REVERT JUMPDEST POP DUP6 MLOAD PUSH1 0x1 PUSH1 0xA0 PUSH1 0x2 EXP SUB AND PUSH1 0x0 SWAP1 DUP2 MSTORE PUSH1 0x1 PUSH1 0x20 SWAP1 DUP2 MSTORE PUSH1 0x40 SWAP2 DUP3 SWAP1 KECCAK256 SLOAD DUP3 MLOAD DUP1 DUP5 ADD SWAP1 SWAP4 MSTORE PUSH1 0x1E DUP4 MSTORE PUSH32 0x4D616B65722061646472657373206E6F742077686974656C69737465642E0000 SWAP2 DUP4 ADD SWAP2 SWAP1 SWAP2 MSTORE PUSH1 0xFF AND ISZERO ISZERO PUSH2 0x22C JUMPI PUSH1 0x40 MLOAD PUSH1 0xE5 PUSH1 0x2 EXP PUSH3 0x461BCD MUL DUP2 MSTORE PUSH1 0x4 ADD PUSH2 0x1AB SWAP2 SWAP1 PUSH2 0xA04 JUMP JUMPDEST POP PUSH1 0x1 PUSH1 0xA0 PUSH1 0x2 EXP SUB DUP3 AND PUSH1 0x0 SWAP1 DUP2 MSTORE PUSH1 0x1 PUSH1 0x20 SWAP1 DUP2 MSTORE PUSH1 0x40 SWAP2 DUP3 SWAP1 KECCAK256 SLOAD DUP3 MLOAD DUP1 DUP5 ADD SWAP1 SWAP4 MSTORE PUSH1 0x1E DUP4 MSTORE PUSH32 0x54616B65722061646472657373206E6F742077686974656C69737465642E0000 SWAP2 DUP4 ADD SWAP2 SWAP1 SWAP2 MSTORE PUSH1 0xFF AND ISZERO ISZERO PUSH2 0x2A3 JUMPI PUSH1 0x40 MLOAD PUSH1 0xE5 PUSH1 0x2 EXP PUSH3 0x461BCD MUL DUP2 MSTORE PUSH1 0x4 ADD PUSH2 0x1AB SWAP2 SWAP1 PUSH2 0xA04 JUMP JUMPDEST POP PUSH1 0x40 MLOAD PUSH1 0xE0 PUSH1 0x2 EXP PUSH4 0xB4BE83D5 MUL SWAP1 PUSH2 0x2C5 SWAP1 DUP9 SWAP1 DUP9 SWAP1 DUP8 SWAP1 PUSH1 0x24 ADD PUSH2 0xA25 JUMP JUMPDEST PUSH1 0x40 DUP1 MLOAD PUSH1 0x1F NOT DUP2 DUP5 SUB ADD DUP2 MSTORE SWAP2 DUP2 MSTORE PUSH1 0x20 DUP3 ADD DUP1 MLOAD PUSH1 0x1 PUSH1 0xE0 PUSH1 0x2 EXP SUB AND PUSH1 0x1 PUSH1 0xE0 PUSH1 0x2 EXP SUB NOT SWAP1 SWAP5 AND SWAP4 SWAP1 SWAP4 OR SWAP1 SWAP3 MSTORE PUSH1 0x2 SLOAD SWAP2 MLOAD PUSH1 0xE1 PUSH1 0x2 EXP PUSH4 0x5FE45FE7 MUL DUP2 MSTORE SWAP1 SWAP3 POP PUSH1 0x1 PUSH1 0xA0 PUSH1 0x2 EXP SUB SWAP1 SWAP2 AND SWAP1 PUSH4 0xBFC8BFCE SWAP1 PUSH2 0x333 SWAP1 DUP8 SWAP1 DUP7 SWAP1 DUP7 SWAP1 PUSH1 0x3 SWAP1 PUSH1 0x4 ADD PUSH2 0xA57 JUMP JUMPDEST PUSH1 0x0 PUSH1 0x40 MLOAD DUP1 DUP4 SUB DUP2 PUSH1 0x0 DUP8 DUP1 EXTCODESIZE ISZERO DUP1 ISZERO PUSH2 0x34D JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP GAS CALL ISZERO DUP1 ISZERO PUSH2 0x361 JUMPI RETURNDATASIZE PUSH1 0x0 DUP1 RETURNDATACOPY RETURNDATASIZE PUSH1 0x0 REVERT JUMPDEST POP POP POP POP POP POP POP POP POP POP JUMP JUMPDEST PUSH1 0x1 PUSH1 0x20 MSTORE PUSH1 0x0 SWAP1 DUP2 MSTORE PUSH1 0x40 SWAP1 KECCAK256 SLOAD PUSH1 0xFF AND DUP2 JUMP JUMPDEST PUSH1 0x0 SLOAD PUSH1 0x1 PUSH1 0xA0 PUSH1 0x2 EXP SUB AND DUP2 JUMP JUMPDEST PUSH1 0x1 PUSH1 0xA0 PUSH1 0x2 EXP SUB DUP4 AND ORIGIN EQ SWAP5 SWAP4 POP POP POP POP JUMP JUMPDEST PUSH1 0x0 SLOAD PUSH1 0x1 PUSH1 0xA0 PUSH1 0x2 EXP SUB AND CALLER EQ PUSH2 0x3D2 JUMPI PUSH1 0x40 MLOAD PUSH1 0xE5 PUSH1 0x2 EXP PUSH3 0x461BCD MUL DUP2 MSTORE PUSH1 0x4 ADD PUSH2 0x1AB SWAP1 PUSH2 0xA15 JUMP JUMPDEST PUSH1 0x1 PUSH1 0xA0 PUSH1 0x2 EXP SUB SWAP2 SWAP1 SWAP2 AND PUSH1 0x0 SWAP1 DUP2 MSTORE PUSH1 0x1 PUSH1 0x20 MSTORE PUSH1 0x40 SWAP1 KECCAK256 DUP1 SLOAD PUSH1 0xFF NOT AND SWAP2 ISZERO ISZERO SWAP2 SWAP1 SWAP2 OR SWAP1 SSTORE JUMP JUMPDEST PUSH1 0x0 SLOAD PUSH1 0x1 PUSH1 0xA0 PUSH1 0x2 EXP SUB AND CALLER EQ PUSH2 0x42A JUMPI PUSH1 0x40 MLOAD PUSH1 0xE5 PUSH1 0x2 EXP PUSH3 0x461BCD MUL DUP2 MSTORE PUSH1 0x4 ADD PUSH2 0x1AB SWAP1 PUSH2 0xA15 JUMP JUMPDEST PUSH1 0x1 PUSH1 0xA0 PUSH1 0x2 EXP SUB DUP2 AND ISZERO PUSH2 0x455 JUMPI PUSH1 0x0 DUP1 SLOAD PUSH1 0x1 PUSH1 0xA0 PUSH1 0x2 EXP SUB NOT AND PUSH1 0x1 PUSH1 0xA0 PUSH1 0x2 EXP SUB DUP4 AND OR SWAP1 SSTORE JUMPDEST POP JUMP JUMPDEST PUSH1 0x0 PUSH2 0x464 DUP3 CALLDATALOAD PUSH2 0xAFF JUMP JUMPDEST SWAP4 SWAP3 POP POP POP JUMP JUMPDEST PUSH1 0x0 PUSH2 0x464 DUP3 CALLDATALOAD PUSH2 0xB0B JUMP JUMPDEST PUSH1 0x0 PUSH2 0x464 DUP3 CALLDATALOAD PUSH2 0xB10 JUMP JUMPDEST PUSH1 0x0 DUP1 PUSH1 0x1F DUP4 ADD DUP5 SGT PUSH2 0x495 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP DUP2 CALLDATALOAD PUSH1 0x1 PUSH1 0x40 PUSH1 0x2 EXP SUB DUP2 GT ISZERO PUSH2 0x4AC JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH1 0x20 DUP4 ADD SWAP2 POP DUP4 PUSH1 0x1 DUP3 MUL DUP4 ADD GT ISZERO PUSH2 0x4C4 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST SWAP3 POP SWAP3 SWAP1 POP JUMP JUMPDEST PUSH1 0x0 PUSH1 0x1F DUP3 ADD DUP4 SGT PUSH2 0x4DC JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST DUP2 CALLDATALOAD PUSH2 0x4EF PUSH2 0x4EA DUP3 PUSH2 0xAC8 JUMP JUMPDEST PUSH2 0xAA2 JUMP JUMPDEST SWAP2 POP DUP1 DUP3 MSTORE PUSH1 0x20 DUP4 ADD PUSH1 0x20 DUP4 ADD DUP6 DUP4 DUP4 ADD GT ISZERO PUSH2 0x50B JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH2 0x516 DUP4 DUP3 DUP5 PUSH2 0xB13 JUMP JUMPDEST POP POP POP SWAP3 SWAP2 POP POP JUMP JUMPDEST PUSH1 0x0 PUSH2 0x180 DUP3 DUP5 SUB SLT ISZERO PUSH2 0x532 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH2 0x53D PUSH2 0x180 PUSH2 0xAA2 JUMP JUMPDEST SWAP1 POP PUSH1 0x0 PUSH2 0x54B DUP5 DUP5 PUSH2 0x458 JUMP JUMPDEST DUP3 MSTORE POP PUSH1 0x20 PUSH2 0x55C DUP5 DUP5 DUP4 ADD PUSH2 0x458 JUMP JUMPDEST PUSH1 0x20 DUP4 ADD MSTORE POP PUSH1 0x40 PUSH2 0x570 DUP5 DUP3 DUP6 ADD PUSH2 0x458 JUMP JUMPDEST PUSH1 0x40 DUP4 ADD MSTORE POP PUSH1 0x60 PUSH2 0x584 DUP5 DUP3 DUP6 ADD PUSH2 0x458 JUMP JUMPDEST PUSH1 0x60 DUP4 ADD MSTORE POP PUSH1 0x80 PUSH2 0x598 DUP5 DUP3 DUP6 ADD PUSH2 0x477 JUMP JUMPDEST PUSH1 0x80 DUP4 ADD MSTORE POP PUSH1 0xA0 PUSH2 0x5AC DUP5 DUP3 DUP6 ADD PUSH2 0x477 JUMP JUMPDEST PUSH1 0xA0 DUP4 ADD MSTORE POP PUSH1 0xC0 PUSH2 0x5C0 DUP5 DUP3 DUP6 ADD PUSH2 0x477 JUMP JUMPDEST PUSH1 0xC0 DUP4 ADD MSTORE POP PUSH1 0xE0 PUSH2 0x5D4 DUP5 DUP3 DUP6 ADD PUSH2 0x477 JUMP JUMPDEST PUSH1 0xE0 DUP4 ADD MSTORE POP PUSH2 0x100 PUSH2 0x5E9 DUP5 DUP3 DUP6 ADD PUSH2 0x477 JUMP JUMPDEST PUSH2 0x100 DUP4 ADD MSTORE POP PUSH2 0x120 PUSH2 0x5FF DUP5 DUP3 DUP6 ADD PUSH2 0x477 JUMP JUMPDEST PUSH2 0x120 DUP4 ADD MSTORE POP PUSH2 0x140 DUP3 ADD CALLDATALOAD PUSH1 0x1 PUSH1 0x40 PUSH1 0x2 EXP SUB DUP2 GT ISZERO PUSH2 0x620 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH2 0x62C DUP5 DUP3 DUP6 ADD PUSH2 0x4CB JUMP JUMPDEST PUSH2 0x140 DUP4 ADD MSTORE POP PUSH2 0x160 DUP3 ADD CALLDATALOAD PUSH1 0x1 PUSH1 0x40 PUSH1 0x2 EXP SUB DUP2 GT ISZERO PUSH2 0x64D JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH2 0x659 DUP5 DUP3 DUP6 ADD PUSH2 0x4CB JUMP JUMPDEST PUSH2 0x160 DUP4 ADD MSTORE POP SWAP3 SWAP2 POP POP JUMP JUMPDEST PUSH1 0x0 PUSH1 0x20 DUP3 DUP5 SUB SLT ISZERO PUSH2 0x678 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH1 0x0 PUSH2 0x684 DUP5 DUP5 PUSH2 0x458 JUMP JUMPDEST SWAP5 SWAP4 POP POP POP POP JUMP JUMPDEST PUSH1 0x0 DUP1 PUSH1 0x40 DUP4 DUP6 SUB SLT ISZERO PUSH2 0x69F JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH1 0x0 PUSH2 0x6AB DUP6 DUP6 PUSH2 0x458 JUMP JUMPDEST SWAP3 POP POP PUSH1 0x20 PUSH2 0x6BC DUP6 DUP3 DUP7 ADD PUSH2 0x46B JUMP JUMPDEST SWAP2 POP POP SWAP3 POP SWAP3 SWAP1 POP JUMP JUMPDEST PUSH1 0x0 DUP1 PUSH1 0x0 DUP1 PUSH1 0x60 DUP6 DUP8 SUB SLT ISZERO PUSH2 0x6DC JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH1 0x0 PUSH2 0x6E8 DUP8 DUP8 PUSH2 0x477 JUMP JUMPDEST SWAP5 POP POP PUSH1 0x20 PUSH2 0x6F9 DUP8 DUP3 DUP9 ADD PUSH2 0x458 JUMP JUMPDEST SWAP4 POP POP PUSH1 0x40 DUP6 ADD CALLDATALOAD PUSH1 0x1 PUSH1 0x40 PUSH1 0x2 EXP SUB DUP2 GT ISZERO PUSH2 0x715 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH2 0x721 DUP8 DUP3 DUP9 ADD PUSH2 0x483 JUMP JUMPDEST SWAP6 SWAP9 SWAP5 SWAP8 POP SWAP6 POP POP POP POP JUMP JUMPDEST PUSH1 0x0 DUP1 PUSH1 0x0 DUP1 PUSH1 0x80 DUP6 DUP8 SUB SLT ISZERO PUSH2 0x743 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST DUP5 CALLDATALOAD PUSH1 0x1 PUSH1 0x40 PUSH1 0x2 EXP SUB DUP2 GT ISZERO PUSH2 0x759 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH2 0x765 DUP8 DUP3 DUP9 ADD PUSH2 0x51F JUMP JUMPDEST SWAP5 POP POP PUSH1 0x20 PUSH2 0x776 DUP8 DUP3 DUP9 ADD PUSH2 0x477 JUMP JUMPDEST SWAP4 POP POP PUSH1 0x40 PUSH2 0x787 DUP8 DUP3 DUP9 ADD PUSH2 0x477 JUMP JUMPDEST SWAP3 POP POP PUSH1 0x60 DUP6 ADD CALLDATALOAD PUSH1 0x1 PUSH1 0x40 PUSH1 0x2 EXP SUB DUP2 GT ISZERO PUSH2 0x7A3 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH2 0x7AF DUP8 DUP3 DUP9 ADD PUSH2 0x4CB JUMP JUMPDEST SWAP2 POP POP SWAP3 SWAP6 SWAP2 SWAP5 POP SWAP3 POP JUMP JUMPDEST PUSH2 0x7C4 DUP2 PUSH2 0xAFF JUMP JUMPDEST DUP3 MSTORE POP POP JUMP JUMPDEST PUSH2 0x7C4 DUP2 PUSH2 0xB0B JUMP JUMPDEST PUSH1 0x0 PUSH2 0x7DE DUP3 PUSH2 0xAFB JUMP JUMPDEST DUP1 DUP5 MSTORE PUSH2 0x7F2 DUP2 PUSH1 0x20 DUP7 ADD PUSH1 0x20 DUP7 ADD PUSH2 0xB1F JUMP JUMPDEST PUSH2 0x7FB DUP2 PUSH2 0xB4F JUMP JUMPDEST SWAP1 SWAP4 ADD PUSH1 0x20 ADD SWAP4 SWAP3 POP POP POP JUMP JUMPDEST PUSH1 0x0 DUP2 SLOAD PUSH1 0x1 DUP2 AND PUSH1 0x0 DUP2 EQ PUSH2 0x825 JUMPI PUSH1 0x1 DUP2 EQ PUSH2 0x843 JUMPI PUSH2 0x87F JUMP JUMPDEST PUSH1 0x2 DUP3 DIV PUSH1 0x7F AND DUP6 MSTORE PUSH1 0xFF NOT DUP3 AND PUSH1 0x20 DUP7 ADD MSTORE PUSH1 0x40 DUP6 ADD SWAP3 POP PUSH2 0x87F JUMP JUMPDEST PUSH1 0x2 DUP3 DIV DUP1 DUP7 MSTORE PUSH1 0x20 DUP7 ADD SWAP6 POP PUSH2 0x859 DUP6 PUSH2 0xAEF JUMP JUMPDEST PUSH1 0x0 JUMPDEST DUP3 DUP2 LT ISZERO PUSH2 0x878 JUMPI DUP2 SLOAD DUP9 DUP3 ADD MSTORE PUSH1 0x1 SWAP1 SWAP2 ADD SWAP1 PUSH1 0x20 ADD PUSH2 0x85C JUMP JUMPDEST DUP8 ADD SWAP5 POP POP POP JUMPDEST POP POP SWAP3 SWAP2 POP POP JUMP JUMPDEST PUSH1 0x33 DUP2 MSTORE PUSH32 0x4F6E6C7920636F6E7472616374206F776E657220697320616C6C6F7765642074 PUSH1 0x20 DUP3 ADD MSTORE PUSH1 0x69 PUSH1 0x2 EXP PUSH19 0x379031B0B636103A3434B99036B2BA3437B217 MUL PUSH1 0x40 DUP3 ADD MSTORE PUSH1 0x60 ADD SWAP1 JUMP JUMPDEST DUP1 MLOAD PUSH1 0x0 SWAP1 PUSH2 0x180 DUP5 ADD SWAP1 PUSH2 0x8EB DUP6 DUP3 PUSH2 0x7BB JUMP JUMPDEST POP PUSH1 0x20 DUP4 ADD MLOAD PUSH2 0x8FE PUSH1 0x20 DUP7 ADD DUP3 PUSH2 0x7BB JUMP JUMPDEST POP PUSH1 0x40 DUP4 ADD MLOAD PUSH2 0x911 PUSH1 0x40 DUP7 ADD DUP3 PUSH2 0x7BB JUMP JUMPDEST POP PUSH1 0x60 DUP4 ADD MLOAD PUSH2 0x924 PUSH1 0x60 DUP7 ADD DUP3 PUSH2 0x7BB JUMP JUMPDEST POP PUSH1 0x80 DUP4 ADD MLOAD PUSH2 0x937 PUSH1 0x80 DUP7 ADD DUP3 PUSH2 0x9D9 JUMP JUMPDEST POP PUSH1 0xA0 DUP4 ADD MLOAD PUSH2 0x94A PUSH1 0xA0 DUP7 ADD DUP3 PUSH2 0x9D9 JUMP JUMPDEST POP PUSH1 0xC0 DUP4 ADD MLOAD PUSH2 0x95D PUSH1 0xC0 DUP7 ADD DUP3 PUSH2 0x9D9 JUMP JUMPDEST POP PUSH1 0xE0 DUP4 ADD MLOAD PUSH2 0x970 PUSH1 0xE0 DUP7 ADD DUP3 PUSH2 0x9D9 JUMP JUMPDEST POP PUSH2 0x100 DUP4 ADD MLOAD PUSH2 0x985 PUSH2 0x100 DUP7 ADD DUP3 PUSH2 0x9D9 JUMP JUMPDEST POP PUSH2 0x120 DUP4 ADD MLOAD PUSH2 0x99A PUSH2 0x120 DUP7 ADD DUP3 PUSH2 0x9D9 JUMP JUMPDEST POP PUSH2 0x140 DUP4 ADD MLOAD DUP5 DUP3 SUB PUSH2 0x140 DUP7 ADD MSTORE PUSH2 0x9B4 DUP3 DUP3 PUSH2 0x7D3 JUMP JUMPDEST SWAP2 POP POP PUSH2 0x160 DUP4 ADD MLOAD DUP5 DUP3 SUB PUSH2 0x160 DUP7 ADD MSTORE PUSH2 0x9D0 DUP3 DUP3 PUSH2 0x7D3 JUMP JUMPDEST SWAP6 SWAP5 POP POP POP POP POP JUMP JUMPDEST PUSH2 0x7C4 DUP2 PUSH2 0xB10 JUMP JUMPDEST PUSH1 0x20 DUP2 ADD PUSH2 0x9F0 DUP3 DUP5 PUSH2 0x7BB JUMP JUMPDEST SWAP3 SWAP2 POP POP JUMP JUMPDEST PUSH1 0x20 DUP2 ADD PUSH2 0x9F0 DUP3 DUP5 PUSH2 0x7CA JUMP JUMPDEST PUSH1 0x20 DUP1 DUP3 MSTORE DUP2 ADD PUSH2 0x464 DUP2 DUP5 PUSH2 0x7D3 JUMP JUMPDEST PUSH1 0x20 DUP1 DUP3 MSTORE DUP2 ADD PUSH2 0x9F0 DUP2 PUSH2 0x887 JUMP JUMPDEST PUSH1 0x60 DUP1 DUP3 MSTORE DUP2 ADD PUSH2 0xA36 DUP2 DUP7 PUSH2 0x8D6 JUMP JUMPDEST SWAP1 POP PUSH2 0xA45 PUSH1 0x20 DUP4 ADD DUP6 PUSH2 0x9D9 JUMP JUMPDEST DUP2 DUP2 SUB PUSH1 0x40 DUP4 ADD MSTORE PUSH2 0x9D0 DUP2 DUP5 PUSH2 0x7D3 JUMP JUMPDEST PUSH1 0x80 DUP2 ADD PUSH2 0xA65 DUP3 DUP8 PUSH2 0x9D9 JUMP JUMPDEST PUSH2 0xA72 PUSH1 0x20 DUP4 ADD DUP7 PUSH2 0x7BB JUMP JUMPDEST DUP2 DUP2 SUB PUSH1 0x40 DUP4 ADD MSTORE PUSH2 0xA84 DUP2 DUP6 PUSH2 0x7D3 JUMP JUMPDEST SWAP1 POP DUP2 DUP2 SUB PUSH1 0x60 DUP4 ADD MSTORE PUSH2 0xA98 DUP2 DUP5 PUSH2 0x808 JUMP JUMPDEST SWAP7 SWAP6 POP POP POP POP POP POP JUMP JUMPDEST PUSH1 0x40 MLOAD DUP2 DUP2 ADD PUSH1 0x1 PUSH1 0x40 PUSH1 0x2 EXP SUB DUP2 GT DUP3 DUP3 LT OR ISZERO PUSH2 0xAC0 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH1 0x40 MSTORE SWAP2 SWAP1 POP JUMP JUMPDEST PUSH1 0x0 PUSH1 0x1 PUSH1 0x40 PUSH1 0x2 EXP SUB DUP3 GT ISZERO PUSH2 0xADE JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH1 0x20 PUSH1 0x1F SWAP2 SWAP1 SWAP2 ADD PUSH1 0x1F NOT AND ADD SWAP1 JUMP JUMPDEST PUSH1 0x0 SWAP1 DUP2 MSTORE PUSH1 0x20 SWAP1 KECCAK256 SWAP1 JUMP JUMPDEST MLOAD SWAP1 JUMP JUMPDEST PUSH1 0x1 PUSH1 0xA0 PUSH1 0x2 EXP SUB AND SWAP1 JUMP JUMPDEST ISZERO ISZERO SWAP1 JUMP JUMPDEST SWAP1 JUMP JUMPDEST DUP3 DUP2 DUP4 CALLDATACOPY POP PUSH1 0x0 SWAP2 ADD MSTORE JUMP JUMPDEST PUSH1 0x0 JUMPDEST DUP4 DUP2 LT ISZERO PUSH2 0xB3A JUMPI DUP2 DUP2 ADD MLOAD DUP4 DUP3 ADD MSTORE PUSH1 0x20 ADD PUSH2 0xB22 JUMP JUMPDEST DUP4 DUP2 GT ISZERO PUSH2 0xB49 JUMPI PUSH1 0x0 DUP5 DUP5 ADD MSTORE JUMPDEST POP POP POP POP JUMP JUMPDEST PUSH1 0x1F ADD PUSH1 0x1F NOT AND SWAP1 JUMP STOP LOG2 PUSH6 0x627A7A723058 KECCAK256 PUSH24 0x4BF0F42469906B3F8FAA7F7824CCF722967B92F0CBB483F9 0xf8 0x2b MSTORE 0xb9 0x1e SMOD XOR PUSH13 0x6578706572696D656E74616CF5 STOP CALLDATACOPY ", + "sourceMap": "794:3284:9:-;;;;;;;;;-1:-1:-1;;;794:3284:9;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2476:1145;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;2476:1145:9;;;;;;;;;;;1139:46;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;1139:46:9;;;;;;;;;;;;;;;;;;;;;;;;;292:20:11;;8:9:-1;5:2;;;30:1;27;20:12;5:2;292:20:11;;;;;;;;;;;;3865:211:9;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;3865:211:9;;;;;;;;;1710:154;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;1710:154:9;;;;;;;;;566:167:11;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;566:167:11;;;;;;;;;2476:1145:9;2855:14;;;3243:17;2855:14;;;;;;;;;;;;;-1:-1:-1;;;;;2855:14:9;;;;;;;2700:10;;3243:17;2832:9;2816:25;;2795:84;;;;-1:-1:-1;;;;;2795:84:9;;;;;;;;;;;;;;;;;;-1:-1:-1;2972:18:9;;-1:-1:-1;;;;;2958:33:9;;;;;:13;:33;;;;;;;;;;3005:21;;;;;;;;;;;;;;;;;;;2958:33;;2937:99;;;;;;-1:-1:-1;;;;;2937:99:9;;;;;;;;;;-1:-1:-1;;;;;;3115:27:9;;;;;;:13;:27;;;;;;;;;;3156:21;;;;;;;;;;;;;;;;;;;3115:27;;3094:93;;;;;;-1:-1:-1;;;;;3094:93:9;;;;;;;;;;-1:-1:-1;3263:154:9;;-1:-1:-1;;;;;3299:27:9;3263:154;;3340:5;;3359:20;;3393:14;;3263:154;;;;;;;;-1:-1:-1;;26:21;;;22:32;6:49;;3263:154:9;;;49:4:-1;25:18;;61:17;;-1:-1;;;;;182:15;-1:-1;;;;;;3263:154:9;;;179:29:-1;;;;160:49;;;3482:8:9;;:132;;-1:-1:-1;;;;;3482:132:9;;3263:154;;-1:-1:-1;;;;;;3482:8:9;;;;:27;;:132;;3523:4;;3541:12;;3263:154;;3585:19;;3482:132;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;3482:132:9;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;3482:132:9;;;;2476:1145;;;;;;:::o;1139:46::-;;;;;;;;;;;;;;;:::o;292:20:11:-;;;-1:-1:-1;;;;;292:20:11;;:::o;3865:211:9:-;-1:-1:-1;;;;;4050:19:9;;4060:9;4050:19;3865:211;;;;;;:::o;1710:154::-;460:5:11;;-1:-1:-1;;;;;460:5:11;446:10;:19;425:117;;;;-1:-1:-1;;;;;425:117:11;;;;;;;;;-1:-1:-1;;;;;1823:21:9;;;;;;;;:13;:21;;;;;:34;;-1:-1:-1;;1823:34:9;;;;;;;;;;1710:154::o;566:167:11:-;460:5;;-1:-1:-1;;;;;460:5:11;446:10;:19;425:117;;;;-1:-1:-1;;;;;425:117:11;;;;;;;;;-1:-1:-1;;;;;662:22:11;;;658:69;;700:5;:16;;-1:-1:-1;;;;;;700:16:11;-1:-1:-1;;;;;700:16:11;;;;;658:69;566:167;:::o;5:118:-1:-;;72:46;110:6;97:20;72:46;;;63:55;57:66;-1:-1;;;57:66;130:112;;194:43;229:6;216:20;194:43;;249:118;;316:46;354:6;341:20;316:46;;388:335;;;495:4;483:17;;479:27;-1:-1;469:2;;520:1;517;510:12;469:2;-1:-1;540:20;;-1:-1;;;;;569:30;;566:2;;;612:1;609;602:12;566:2;646:4;638:6;634:17;622:29;;696:3;689;681:6;677:16;667:8;663:31;660:40;657:2;;;713:1;710;703:12;657:2;462:261;;;;;;732:432;;822:4;810:17;;806:27;-1:-1;796:2;;847:1;844;837:12;796:2;884:6;871:20;906:60;921:44;958:6;921:44;;;906:60;;;897:69;;986:6;979:5;972:21;1022:4;1014:6;1010:17;1055:4;1048:5;1044:16;1090:3;1081:6;1076:3;1072:16;1069:25;1066:2;;;1107:1;1104;1097:12;1066:2;1117:41;1151:6;1146:3;1141;1117:41;;;789:375;;;;;;;;1649:2208;;1760:5;1748:9;1743:3;1739:19;1735:31;1732:2;;;1779:1;1776;1769:12;1732:2;1797:21;1812:5;1797:21;;;1788:30;-1:-1;1876:1;1907:49;1952:3;1932:9;1907:49;;;1883:74;;-1:-1;2026:2;2059:49;2104:3;2080:22;;;2059:49;;;2052:4;2045:5;2041:16;2034:75;1978:142;2185:2;2218:49;2263:3;2254:6;2243:9;2239:22;2218:49;;;2211:4;2204:5;2200:16;2193:75;2130:149;2338:2;2371:49;2416:3;2407:6;2396:9;2392:22;2371:49;;;2364:4;2357:5;2353:16;2346:75;2289:143;2494:3;2528:49;2573:3;2564:6;2553:9;2549:22;2528:49;;;2521:4;2514:5;2510:16;2503:75;2442:147;2651:3;2685:49;2730:3;2721:6;2710:9;2706:22;2685:49;;;2678:4;2671:5;2667:16;2660:75;2599:147;2800:3;2834:49;2879:3;2870:6;2859:9;2855:22;2834:49;;;2827:4;2820:5;2816:16;2809:75;2756:139;2949:3;2983:49;3028:3;3019:6;3008:9;3004:22;2983:49;;;2976:4;2969:5;2965:16;2958:75;2905:139;3111:3;3146:49;3191:3;3182:6;3171:9;3167:22;3146:49;;;3138:5;3131;3127:17;3120:76;3054:153;3257:3;3292:49;3337:3;3328:6;3317:9;3313:22;3292:49;;;3284:5;3277;3273:17;3266:76;3217:136;3441:3;3430:9;3426:19;3413:33;-1:-1;;;;;3458:6;3455:30;3452:2;;;3498:1;3495;3488:12;3452:2;3534:54;3584:3;3575:6;3564:9;3560:22;3534:54;;;3526:5;3519;3515:17;3508:81;3363:237;3688:3;3677:9;3673:19;3660:33;-1:-1;;;;;3705:6;3702:30;3699:2;;;3745:1;3742;3735:12;3699:2;3781:54;3831:3;3822:6;3811:9;3807:22;3781:54;;;3773:5;3766;3762:17;3755:81;3610:237;1726:2131;;;;;3989:241;;4093:2;4081:9;4072:7;4068:23;4064:32;4061:2;;;4109:1;4106;4099:12;4061:2;4144:1;4161:53;4206:7;4186:9;4161:53;;;4151:63;4055:175;-1:-1;;;;4055:175;4237:360;;;4355:2;4343:9;4334:7;4330:23;4326:32;4323:2;;;4371:1;4368;4361:12;4323:2;4406:1;4423:53;4468:7;4448:9;4423:53;;;4413:63;;4385:97;4513:2;4531:50;4573:7;4564:6;4553:9;4549:22;4531:50;;;4521:60;;4492:95;4317:280;;;;;;4604:615;;;;;4761:2;4749:9;4740:7;4736:23;4732:32;4729:2;;;4777:1;4774;4767:12;4729:2;4812:1;4829:53;4874:7;4854:9;4829:53;;;4819:63;;4791:97;4919:2;4937:53;4982:7;4973:6;4962:9;4958:22;4937:53;;;4927:63;;4898:98;5055:2;5044:9;5040:18;5027:32;-1:-1;;;;;5071:6;5068:30;5065:2;;;5111:1;5108;5101:12;5065:2;5139:64;5195:7;5186:6;5175:9;5171:22;5139:64;;;4723:496;;;;-1:-1;5121:82;-1:-1;;;;4723:496;5226:851;;;;;5412:3;5400:9;5391:7;5387:23;5383:33;5380:2;;;5429:1;5426;5419:12;5380:2;5464:31;;-1:-1;;;;;5504:30;;5501:2;;;5547:1;5544;5537:12;5501:2;5567:75;5634:7;5625:6;5614:9;5610:22;5567:75;;;5557:85;;5443:205;5679:2;5697:53;5742:7;5733:6;5722:9;5718:22;5697:53;;;5687:63;;5658:98;5787:2;5805:53;5850:7;5841:6;5830:9;5826:22;5805:53;;;5795:63;;5766:98;5923:2;5912:9;5908:18;5895:32;-1:-1;;;;;5939:6;5936:30;5933:2;;;5979:1;5976;5969:12;5933:2;5999:62;6053:7;6044:6;6033:9;6029:22;5999:62;;;5989:72;;5874:193;5374:703;;;;;;;;6084:110;6157:31;6182:5;6157:31;;;6152:3;6145:44;6139:55;;;6201:101;6268:28;6290:5;6268:28;;6309:297;;6409:38;6441:5;6409:38;;;6464:6;6459:3;6452:19;6476:63;6532:6;6525:4;6520:3;6516:14;6509:4;6502:5;6498:16;6476:63;;;6571:29;6593:6;6571:29;;;6551:50;;;6564:4;6551:50;;6389:217;-1:-1;;;6389:217;6932:731;;7039:5;7033:12;7073:1;7062:9;7058:17;7086:1;7081:200;;;;7292:1;7287:370;;;;7051:606;;7081:200;7155:1;7140:17;;7159:4;7136:28;7171:19;;-1:-1;;7220:25;;7213:4;7204:14;;7197:49;7269:4;7260:14;;;-1:-1;7081:200;;7287:370;7356:1;7345:9;7341:17;7377:6;7372:3;7365:19;7407:4;7402:3;7398:14;7391:21;;7434:37;7465:5;7434:37;;;7487:1;7495:130;7509:6;7506:1;7503:13;7495:130;;;7568:14;;7555:11;;;7548:35;7615:1;7602:15;;;;7531:4;7524:12;7495:130;;;7639:11;;;-1:-1;;;7051:606;;7009:654;;;;;;7971:397;8126:2;8114:15;;8163:66;8158:2;8149:12;;8142:88;-1:-1;;;;;8259:2;8250:12;;8243:88;8359:2;8350:12;;8107:261;8429:2417;8642:22;;8429:2417;;8564:5;8555:15;;;8676:61;8559:3;8642:22;8676:61;;;8585:164;8833:4;8826:5;8822:16;8816:23;8851:62;8907:4;8902:3;8898:14;8885:11;8851:62;;;8759:166;9016:4;9009:5;9005:16;8999:23;9034:62;9090:4;9085:3;9081:14;9068:11;9034:62;;;8935:173;9193:4;9186:5;9182:16;9176:23;9211:62;9267:4;9262:3;9258:14;9245:11;9211:62;;;9118:167;9373:4;9366:5;9362:16;9356:23;9391:62;9447:4;9442:3;9438:14;9425:11;9391:62;;;9295:170;9553:4;9546:5;9542:16;9536:23;9571:62;9627:4;9622:3;9618:14;9605:11;9571:62;;;9475:170;9725:4;9718:5;9714:16;9708:23;9743:62;9799:4;9794:3;9790:14;9777:11;9743:62;;;9655:162;9897:4;9890:5;9886:16;9880:23;9915:62;9971:4;9966:3;9962:14;9949:11;9915:62;;;9827:162;10082:5;10075;10071:17;10065:24;10101:63;10157:5;10152:3;10148:15;10135:11;10101:63;;;9999:177;10252:5;10245;10241:17;10235:24;10271:63;10327:5;10322:3;10318:15;10305:11;10271:63;;;10186:160;10432:5;10425;10421:17;10415:24;10485:3;10479:4;10475:14;10467:5;10462:3;10458:15;10451:39;10505:66;10566:4;10553:11;10505:66;;;10497:74;;10356:227;10669:5;10662;10658:17;10652:24;10722:3;10716:4;10712:14;10704:5;10699:3;10695:15;10688:39;10742:66;10803:4;10790:11;10742:66;;;10734:74;8537:2309;-1:-1;;;;;8537:2309;10853:110;10926:31;10951:5;10926:31;;10970:193;11078:2;11063:18;;11092:61;11067:9;11126:6;11092:61;;;11049:114;;;;;11170:181;11272:2;11257:18;;11286:55;11261:9;11314:6;11286:55;;11358:273;11482:2;11496:47;;;11467:18;;11557:64;11467:18;11607:6;11557:64;;11638:387;11819:2;11833:47;;;11804:18;;11894:121;11804:18;11894:121;;12032:615;12258:2;12272:47;;;12243:18;;12333:92;12243:18;12411:6;12333:92;;;12325:100;;12436:62;12494:2;12483:9;12479:18;12470:6;12436:62;;;12546:9;12540:4;12536:20;12531:2;12520:9;12516:18;12509:48;12571:66;12632:4;12623:6;12571:66;;12654:659;12879:3;12864:19;;12894:61;12868:9;12928:6;12894:61;;;12966:62;13024:2;13013:9;13009:18;13000:6;12966:62;;;13076:9;13070:4;13066:20;13061:2;13050:9;13046:18;13039:48;13101:66;13162:4;13153:6;13101:66;;;13093:74;;13215:9;13209:4;13205:20;13200:2;13189:9;13185:18;13178:48;13240:63;13298:4;13289:6;13240:63;;;13232:71;12850:463;-1:-1;;;;;;12850:463;13320:256;13382:2;13376:9;13408:17;;;-1:-1;;;;;13468:34;;13504:22;;;13465:62;13462:2;;;13540:1;13537;13530:12;13462:2;13556;13549:22;13360:216;;-1:-1;13360:216;13583:254;;-1:-1;;;;;13714:6;13711:30;13708:2;;;13754:1;13751;13744:12;13708:2;-1:-1;13827:4;13798;13775:17;;;;-1:-1;;13771:33;13817:15;;13645:192;14111:125;;14177:15;;;14224:4;14211:18;;;14169:67;14245:87;14315:12;;14299:33;14532:128;-1:-1;;;;;14601:54;;14584:76;14667:92;14740:13;14733:21;;14716:43;14766:79;14835:5;14818:27;15259:145;15340:6;15335:3;15330;15317:30;-1:-1;15396:1;15378:16;;15371:27;15310:94;15413:268;15478:1;15485:101;15499:6;15496:1;15493:13;15485:101;;;15566:11;;;15560:18;15547:11;;;15540:39;15521:2;15514:10;15485:101;;;15601:6;15598:1;15595:13;15592:2;;;15666:1;15657:6;15652:3;15648:16;15641:27;15592:2;15462:219;;;;;15689:97;15777:2;15757:14;-1:-1;;15753:28;;15737:49" + } + } + }, + "sources": { + "current/protocol/Exchange/interfaces/IAssetProxyDispatcher.sol": { + "id": 0 + }, + "current/protocol/Exchange/interfaces/IExchange.sol": { + "id": 1 + }, + "current/protocol/Exchange/interfaces/IExchangeCore.sol": { + "id": 2 + }, + "current/protocol/Exchange/interfaces/IMatchOrders.sol": { + "id": 3 + }, + "current/protocol/Exchange/interfaces/ISignatureValidator.sol": { + "id": 4 + }, + "current/protocol/Exchange/interfaces/ITransactions.sol": { + "id": 5 + }, + "current/protocol/Exchange/interfaces/IWrapperFunctions.sol": { + "id": 6 + }, + "current/protocol/Exchange/libs/LibFillResults.sol": { + "id": 7 + }, + "current/protocol/Exchange/libs/LibOrder.sol": { + "id": 8 + }, + "current/test/Whitelist/Whitelist.sol": { + "id": 9 + }, + "current/utils/Ownable/IOwnable.sol": { + "id": 10 + }, + "current/utils/Ownable/Ownable.sol": { + "id": 11 + }, + "current/utils/SafeMath/SafeMath.sol": { + "id": 12 + } + }, + "sourceCodes": { + "current/protocol/Exchange/interfaces/IAssetProxyDispatcher.sol": "/*\n\n Copyright 2018 ZeroEx Intl.\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n*/\n\npragma solidity ^0.4.24;\n\ncontract IAssetProxyDispatcher {\n\n /// @dev Registers an asset proxy to an asset proxy id.\n /// An id can only be assigned to a single proxy at a given time.\n /// @param assetProxyId Id to register`newAssetProxy` under.\n /// @param newAssetProxy Address of new asset proxy to register, or 0x0 to unset assetProxyId.\n /// @param oldAssetProxy Existing asset proxy to overwrite, or 0x0 if assetProxyId is currently unused.\n function registerAssetProxy(\n uint8 assetProxyId,\n address newAssetProxy,\n address oldAssetProxy)\n external;\n\n /// @dev Gets an asset proxy.\n /// @param assetProxyId Id of the asset proxy.\n /// @return The asset proxy registered to assetProxyId. Returns 0x0 if no proxy is registered.\n function getAssetProxy(uint8 assetProxyId)\n external\n view\n returns (address);\n}\n", + "current/protocol/Exchange/interfaces/IExchange.sol": "/*\n\n Copyright 2018 ZeroEx Intl.\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n*/\n\npragma solidity ^0.4.24;\npragma experimental ABIEncoderV2;\n\nimport \"./IExchangeCore.sol\";\nimport \"./IMatchOrders.sol\";\nimport \"./ISignatureValidator.sol\";\nimport \"./ITransactions.sol\";\nimport \"./IAssetProxyDispatcher.sol\";\nimport \"./IWrapperFunctions.sol\";\n\ncontract IExchange is\n IExchangeCore,\n IMatchOrders,\n ISignatureValidator,\n ITransactions,\n IAssetProxyDispatcher,\n IWrapperFunctions\n{}\n", + "current/protocol/Exchange/interfaces/IExchangeCore.sol": "/*\n\n Copyright 2018 ZeroEx Intl.\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n*/\n\npragma solidity ^0.4.24;\npragma experimental ABIEncoderV2;\n\nimport \"../libs/LibOrder.sol\";\nimport \"../libs/LibFillResults.sol\";\n\ncontract IExchangeCore {\n\n /// @dev Cancels all orders reated by sender with a salt less than or equal to the specified salt value.\n /// @param salt Orders created with a salt less or equal to this value will be cancelled.\n function cancelOrdersUpTo(uint256 salt)\n external;\n\n /// @dev Fills the input order.\n /// @param order Order struct containing order specifications.\n /// @param takerAssetFillAmount Desired amount of takerAsset to sell.\n /// @param signature Proof that order has been created by maker.\n /// @return Amounts filled and fees paid by maker and taker.\n function fillOrder(\n LibOrder.Order memory order,\n uint256 takerAssetFillAmount,\n bytes memory signature)\n public\n returns (LibFillResults.FillResults memory fillResults);\n\n /// @dev After calling, the order can not be filled anymore.\n /// @param order Order struct containing order specifications.\n /// @return True if the order state changed to cancelled.\n /// False if the transaction was already cancelled or expired.\n function cancelOrder(LibOrder.Order memory order)\n public\n returns (bool);\n\n /// @dev Gets information about an order: status, hash, and amount filled.\n /// @param order Order to gather information on.\n /// @return OrderInfo Information about the order and its state.\n /// See LibOrder.OrderInfo for a complete description.\n function getOrderInfo(LibOrder.Order memory order)\n public\n view\n returns (LibOrder.OrderInfo memory orderInfo);\n\n /// @dev Calculates amounts filled and fees paid by maker and taker.\n /// @param order to be filled.\n /// @param orderStatus Status of order to be filled.\n /// @param orderTakerAssetFilledAmount Amount of order already filled.\n /// @param takerAssetFillAmount Desired amount of order to fill by taker.\n /// @return status Return status of calculating fill amounts. Returns Status.SUCCESS on success.\n /// @return fillResults Amounts filled and fees paid by maker and taker.\n function calculateFillResults(\n LibOrder.Order memory order,\n uint8 orderStatus,\n uint256 orderTakerAssetFilledAmount,\n uint256 takerAssetFillAmount\n )\n public\n pure\n returns (\n uint8 status,\n LibFillResults.FillResults memory fillResults\n );\n}\n", + "current/protocol/Exchange/interfaces/IMatchOrders.sol": "/*\n\n Copyright 2018 ZeroEx Intl.\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n*/\npragma solidity ^0.4.24;\npragma experimental ABIEncoderV2;\n\nimport \"../libs/LibOrder.sol\";\nimport \"../libs/LibFillResults.sol\";\n\ncontract IMatchOrders {\n\n /// @dev Match two complementary orders that have a profitable spread.\n /// Each order is filled at their respective price point. However, the calculations are\n /// carried out as though the orders are both being filled at the right order's price point.\n /// The profit made by the left order goes to the taker (who matched the two orders).\n /// @param leftOrder First order to match.\n /// @param rightOrder Second order to match.\n /// @param leftSignature Proof that order was created by the left maker.\n /// @param rightSignature Proof that order was created by the right maker.\n /// @return matchedFillResults Amounts filled and fees paid by maker and taker of matched orders.\n /// TODO: Make this function external once supported by Solidity (See Solidity Issues #3199, #1603)\n function matchOrders(\n LibOrder.Order memory leftOrder,\n LibOrder.Order memory rightOrder,\n bytes memory leftSignature,\n bytes memory rightSignature\n )\n public\n returns (LibFillResults.MatchedFillResults memory matchedFillResults);\n}\n", + "current/protocol/Exchange/interfaces/ISignatureValidator.sol": "/*\n\n Copyright 2018 ZeroEx Intl.\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n*/\n\npragma solidity ^0.4.24;\n\ncontract ISignatureValidator {\n\n /// @dev Approves a hash on-chain using any valid signature type.\n /// After presigning a hash, the preSign signature type will become valid for that hash and signer.\n /// @param signer Address that should have signed the given hash.\n /// @param signature Proof that the hash has been signed by signer.\n function preSign(\n bytes32 hash,\n address signer,\n bytes signature)\n external;\n}\n", + "current/protocol/Exchange/interfaces/ITransactions.sol": "/*\n\n Copyright 2018 ZeroEx Intl.\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n*/\npragma solidity ^0.4.24;\n\ncontract ITransactions {\n\n /// @dev Executes an exchange method call in the context of signer.\n /// @param salt Arbitrary number to ensure uniqueness of transaction hash.\n /// @param signer Address of transaction signer.\n /// @param data AbiV2 encoded calldata.\n /// @param signature Proof of signer transaction by signer.\n function executeTransaction(\n uint256 salt,\n address signer,\n bytes data,\n bytes signature)\n external;\n}\n", + "current/protocol/Exchange/interfaces/IWrapperFunctions.sol": "/*\n\n Copyright 2018 ZeroEx Intl.\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n*/\n\npragma solidity ^0.4.24;\npragma experimental ABIEncoderV2;\n\nimport \"../libs/LibOrder.sol\";\nimport \"../libs/LibFillResults.sol\";\n\ncontract IWrapperFunctions is\n LibOrder,\n LibFillResults\n{\n /// @dev Fills the input order. Reverts if exact takerAssetFillAmount not filled.\n /// @param order LibOrder.Order struct containing order specifications.\n /// @param takerAssetFillAmount Desired amount of takerAsset to sell.\n /// @param signature Proof that order has been created by maker.\n function fillOrKillOrder(\n LibOrder.Order memory order,\n uint256 takerAssetFillAmount,\n bytes memory signature)\n public\n returns (LibFillResults.FillResults memory fillResults);\n\n /// @dev Fills an order with specified parameters and ECDSA signature.\n /// Returns false if the transaction would otherwise revert.\n /// @param order LibOrder.Order struct containing order specifications.\n /// @param takerAssetFillAmount Desired amount of takerAsset to sell.\n /// @param signature Proof that order has been created by maker.\n /// @return Amounts filled and fees paid by maker and taker.\n function fillOrderNoThrow(\n LibOrder.Order memory order,\n uint256 takerAssetFillAmount,\n bytes memory signature)\n public\n returns (LibFillResults.FillResults memory fillResults);\n\n /// @dev Synchronously executes multiple calls of fillOrder.\n /// @param orders Array of order specifications.\n /// @param takerAssetFillAmounts Array of desired amounts of takerAsset to sell in orders.\n /// @param signatures Proofs that orders have been created by makers.\n function batchFillOrders(\n LibOrder.Order[] memory orders,\n uint256[] memory takerAssetFillAmounts,\n bytes[] memory signatures)\n public;\n\n /// @dev Synchronously executes multiple calls of fillOrKill.\n /// @param orders Array of order specifications.\n /// @param takerAssetFillAmounts Array of desired amounts of takerAsset to sell in orders.\n /// @param signatures Proofs that orders have been created by makers.\n function batchFillOrKillOrders(\n LibOrder.Order[] memory orders,\n uint256[] memory takerAssetFillAmounts,\n bytes[] memory signatures)\n public;\n\n /// @dev Fills an order with specified parameters and ECDSA signature.\n /// Returns false if the transaction would otherwise revert.\n /// @param orders Array of order specifications.\n /// @param takerAssetFillAmounts Array of desired amounts of takerAsset to sell in orders.\n /// @param signatures Proofs that orders have been created by makers.\n function batchFillOrdersNoThrow(\n LibOrder.Order[] memory orders,\n uint256[] memory takerAssetFillAmounts,\n bytes[] memory signatures)\n public;\n\n /// @dev Synchronously executes multiple calls of fillOrder until total amount of takerAsset is sold by taker.\n /// @param orders Array of order specifications.\n /// @param takerAssetFillAmount Desired amount of takerAsset to sell.\n /// @param signatures Proofs that orders have been created by makers.\n /// @return Amounts filled and fees paid by makers and taker.\n function marketSellOrders(\n LibOrder.Order[] memory orders,\n uint256 takerAssetFillAmount,\n bytes[] memory signatures)\n public\n returns (LibFillResults.FillResults memory totalFillResults);\n\n /// @dev Synchronously executes multiple calls of fillOrder until total amount of takerAsset is sold by taker.\n /// Returns false if the transaction would otherwise revert.\n /// @param orders Array of order specifications.\n /// @param takerAssetFillAmount Desired amount of takerAsset to sell.\n /// @param signatures Proofs that orders have been signed by makers.\n /// @return Amounts filled and fees paid by makers and taker.\n function marketSellOrdersNoThrow(\n LibOrder.Order[] memory orders,\n uint256 takerAssetFillAmount,\n bytes[] memory signatures)\n public\n returns (LibFillResults.FillResults memory totalFillResults);\n\n /// @dev Synchronously executes multiple calls of fillOrder until total amount of makerAsset is bought by taker.\n /// @param orders Array of order specifications.\n /// @param makerAssetFillAmount Desired amount of makerAsset to buy.\n /// @param signatures Proofs that orders have been signed by makers.\n /// @return Amounts filled and fees paid by makers and taker.\n function marketBuyOrders(\n LibOrder.Order[] memory orders,\n uint256 makerAssetFillAmount,\n bytes[] memory signatures)\n public\n returns (LibFillResults.FillResults memory totalFillResults);\n\n /// @dev Synchronously executes multiple fill orders in a single transaction until total amount is bought by taker.\n /// Returns false if the transaction would otherwise revert.\n /// @param orders Array of order specifications.\n /// @param makerAssetFillAmount Desired amount of makerAsset to buy.\n /// @param signatures Proofs that orders have been signed by makers.\n /// @return Amounts filled and fees paid by makers and taker.\n function marketBuyOrdersNoThrow(\n LibOrder.Order[] memory orders,\n uint256 makerAssetFillAmount,\n bytes[] memory signatures)\n public\n returns (LibFillResults.FillResults memory totalFillResults);\n\n /// @dev Synchronously cancels multiple orders in a single transaction.\n /// @param orders Array of order specifications.\n function batchCancelOrders(LibOrder.Order[] memory orders)\n public;\n}\n", + "current/protocol/Exchange/libs/LibFillResults.sol": "/*\n\n Copyright 2018 ZeroEx Intl.\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n*/\n\npragma solidity ^0.4.24;\n\nimport \"../../../utils/SafeMath/SafeMath.sol\";\n\ncontract LibFillResults is\n SafeMath\n{\n\n struct FillResults {\n uint256 makerAssetFilledAmount;\n uint256 takerAssetFilledAmount;\n uint256 makerFeePaid;\n uint256 takerFeePaid;\n }\n\n struct MatchedFillResults {\n LibFillResults.FillResults left;\n LibFillResults.FillResults right;\n uint256 takerFillAmount;\n }\n\n /// @dev Adds properties of both FillResults instances.\n /// Modifies the first FillResults instance specified.\n /// @param totalFillResults Fill results instance that will be added onto.\n /// @param singleFillResults Fill results instance that will be added to totalFillResults.\n function addFillResults(FillResults memory totalFillResults, FillResults memory singleFillResults)\n internal\n pure\n {\n totalFillResults.makerAssetFilledAmount = safeAdd(totalFillResults.makerAssetFilledAmount, singleFillResults.makerAssetFilledAmount);\n totalFillResults.takerAssetFilledAmount = safeAdd(totalFillResults.takerAssetFilledAmount, singleFillResults.takerAssetFilledAmount);\n totalFillResults.makerFeePaid = safeAdd(totalFillResults.makerFeePaid, singleFillResults.makerFeePaid);\n totalFillResults.takerFeePaid = safeAdd(totalFillResults.takerFeePaid, singleFillResults.takerFeePaid);\n }\n\n /// @dev Returns a null fill results struct\n function getNullFillResults()\n internal\n pure\n returns (FillResults memory)\n {\n // returns zeroed out FillResults instance\n return FillResults({\n makerAssetFilledAmount: 0,\n takerAssetFilledAmount: 0,\n makerFeePaid: 0,\n takerFeePaid: 0\n });\n }\n}\n", + "current/protocol/Exchange/libs/LibOrder.sol": "/*\n\n Copyright 2018 ZeroEx Intl.\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n*/\n\npragma solidity ^0.4.24;\n\ncontract LibOrder {\n\n bytes32 constant ORDER_SCHEMA_HASH = keccak256(\n \"address exchangeAddress\",\n \"address makerAddress\",\n \"address takerAddress\",\n \"address feeRecipientAddress\",\n \"address senderAddress\",\n \"uint256 makerAssetAmount\",\n \"uint256 takerAssetAmount\",\n \"uint256 makerFee\",\n \"uint256 takerFee\",\n \"uint256 expirationTimeSeconds\",\n \"uint256 salt\",\n \"bytes makerAssetData\",\n \"bytes takerAssetData\"\n );\n\n struct Order {\n address makerAddress;\n address takerAddress;\n address feeRecipientAddress;\n address senderAddress;\n uint256 makerAssetAmount;\n uint256 takerAssetAmount;\n uint256 makerFee;\n uint256 takerFee;\n uint256 expirationTimeSeconds;\n uint256 salt;\n bytes makerAssetData;\n bytes takerAssetData;\n }\n\n struct OrderInfo {\n // See LibStatus for a complete description of order statuses\n uint8 orderStatus;\n // Keccak-256 EIP712 hash of the order\n bytes32 orderHash;\n // Amount of order that has been filled\n uint256 orderTakerAssetFilledAmount;\n }\n\n /// @dev Calculates Keccak-256 hash of the order.\n /// @param order The order structure.\n /// @return Keccak-256 EIP712 hash of the order.\n function getOrderHash(Order memory order)\n internal\n view\n returns (bytes32 orderHash)\n {\n // TODO: EIP712 is not finalized yet\n // Source: https://github.com/ethereum/EIPs/pull/712\n orderHash = keccak256(\n ORDER_SCHEMA_HASH,\n keccak256(\n address(this),\n order.makerAddress,\n order.takerAddress,\n order.feeRecipientAddress,\n order.senderAddress,\n order.makerAssetAmount,\n order.takerAssetAmount,\n order.makerFee,\n order.takerFee,\n order.expirationTimeSeconds,\n order.salt,\n order.makerAssetData,\n order.takerAssetData\n )\n );\n return orderHash;\n }\n}\n", + "current/test/Whitelist/Whitelist.sol": "/*\n\n Copyright 2018 ZeroEx Intl.\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n*/\n\npragma solidity ^0.4.23;\npragma experimental ABIEncoderV2;\n\nimport \"../../protocol/Exchange/interfaces/IExchange.sol\";\nimport \"../../protocol/Exchange/libs/LibOrder.sol\";\nimport \"../../utils/Ownable/Ownable.sol\";\n\ncontract Whitelist is \n Ownable\n{\n // Revert reasons\n string constant MAKER_NOT_WHITELISTED = \"Maker address not whitelisted.\";\n string constant TAKER_NOT_WHITELISTED = \"Taker address not whitelisted.\";\n string constant INVALID_SENDER = \"Sender must equal transaction origin.\";\n\n // Mapping of address => whitelist status.\n mapping (address => bool) public isWhitelisted;\n\n // Exchange contract.\n IExchange EXCHANGE;\n\n byte constant VALIDATOR_SIGNATURE_BYTE = \"\\x06\";\n bytes TX_ORIGIN_SIGNATURE;\n\n constructor (address _exchange)\n public\n {\n EXCHANGE = IExchange(_exchange);\n TX_ORIGIN_SIGNATURE = abi.encodePacked(VALIDATOR_SIGNATURE_BYTE, address(this));\n }\n\n /// @dev Adds or removes an address from the whitelist.\n /// @param target Address to add or remove from whitelist.\n /// @param isApproved Whitelist status to assign to address.\n function updateWhitelistStatus(address target, bool isApproved)\n external\n onlyOwner\n {\n isWhitelisted[target] = isApproved;\n }\n\n /// @dev Fills an order using `msg.sender` as the taker.\n /// The transaction will revert if both the maker and taker are not whitelisted.\n /// Orders should specify this contract as the `senderAddress` in order to gaurantee\n /// that both maker and taker have been whitelisted.\n /// @param order Order struct containing order specifications.\n /// @param takerAssetFillAmount Desired amount of takerAsset to sell.\n /// @param salt Arbitrary value to gaurantee uniqueness of 0x transaction hash.\n /// @param orderSignature Proof that order has been created by maker.\n function fillOrderIfWhitelisted(\n LibOrder.Order memory order,\n uint256 takerAssetFillAmount,\n uint256 salt,\n bytes memory orderSignature\n )\n public\n {\n address takerAddress = msg.sender;\n \n // This contract must be the entry point for the transaction.\n require(\n takerAddress == tx.origin,\n INVALID_SENDER\n );\n\n // Check if maker is on the whitelist.\n require(\n isWhitelisted[order.makerAddress],\n MAKER_NOT_WHITELISTED\n );\n\n // Check if taker is on the whitelist.\n require(\n isWhitelisted[takerAddress],\n TAKER_NOT_WHITELISTED\n );\n\n // Encode arguments into byte array.\n bytes memory data = abi.encodeWithSelector(\n EXCHANGE.fillOrder.selector,\n order,\n takerAssetFillAmount,\n orderSignature\n );\n\n // Call `fillOrder` via `executeTransaction`.\n EXCHANGE.executeTransaction(\n salt,\n takerAddress,\n data,\n TX_ORIGIN_SIGNATURE\n );\n }\n\n /// @dev Verifies signer is same as signer of current Ethereum transaction.\n /// @param signer Address that should have signed the given hash.\n /// @param signature Proof of signing.\n /// @return Validity of order signature.\n function isValidSignature(\n bytes32 hash,\n address signer,\n bytes signature\n )\n external\n view\n returns (bool isValid)\n {\n return signer == tx.origin;\n }\n}\n", + "current/utils/Ownable/IOwnable.sol": "pragma solidity ^0.4.24;\npragma experimental ABIEncoderV2;\n\n/*\n * Ownable\n *\n * Base contract with an owner.\n * Provides onlyOwner modifier, which prevents function from running if it is called by anyone other than the owner.\n */\n\ncontract IOwnable {\n function transferOwnership(address newOwner)\n public;\n}\n", + "current/utils/Ownable/Ownable.sol": "pragma solidity ^0.4.24;\npragma experimental ABIEncoderV2;\n\n/*\n * Ownable\n *\n * Base contract with an owner.\n * Provides onlyOwner modifier, which prevents function from running if it is called by anyone other than the owner.\n */\n\nimport \"./IOwnable.sol\";\n\ncontract Ownable is IOwnable {\n address public owner;\n\n constructor ()\n public\n {\n owner = msg.sender;\n }\n\n modifier onlyOwner() {\n require(\n msg.sender == owner,\n \"Only contract owner is allowed to call this method.\"\n );\n _;\n }\n\n function transferOwnership(address newOwner)\n public\n onlyOwner\n {\n if (newOwner != address(0)) {\n owner = newOwner;\n }\n }\n}\n", + "current/utils/SafeMath/SafeMath.sol": "pragma solidity ^0.4.24;\npragma experimental ABIEncoderV2;\n\ncontract SafeMath {\n function safeMul(uint a, uint b)\n internal\n pure\n returns (uint256)\n {\n uint c = a * b;\n assert(a == 0 || c / a == b);\n return c;\n }\n\n function safeDiv(uint a, uint b)\n internal\n pure\n returns (uint256)\n {\n uint c = a / b;\n return c;\n }\n\n function safeSub(uint a, uint b)\n internal\n pure\n returns (uint256)\n {\n assert(b <= a);\n return a - b;\n }\n\n function safeAdd(uint a, uint b)\n internal\n pure\n returns (uint256)\n {\n uint c = a + b;\n assert(c >= a);\n return c;\n }\n\n function max64(uint64 a, uint64 b)\n internal\n pure\n returns (uint256)\n {\n return a >= b ? a : b;\n }\n\n function min64(uint64 a, uint64 b)\n internal\n pure\n returns (uint256)\n {\n return a < b ? a : b;\n }\n\n function max256(uint256 a, uint256 b)\n internal\n pure\n returns (uint256)\n {\n return a >= b ? a : b;\n }\n\n function min256(uint256 a, uint256 b)\n internal\n pure\n returns (uint256)\n {\n return a < b ? a : b;\n }\n}\n" + }, + "sourceTreeHashHex": "0xadef3b68898dff059b4d42f371acda2bb7516edd9b6bb9d49276993088960a33", + "compiler": { + "name": "solc", + "version": "0.4.24", + "settings": { + "optimizer": { + "enabled": true, + "runs": 0 + }, + "outputSelection": { + "*": { + "*": [ + "abi", + "evm.bytecode.object", + "evm.bytecode.sourceMap", + "evm.deployedBytecode.object", + "evm.deployedBytecode.sourceMap" + ] + } + } + } + }, + "networks": {} +}
\ No newline at end of file diff --git a/packages/order-watcher/test/global_hooks.ts b/packages/order-watcher/test/global_hooks.ts index 1df80533c..3d3f0e474 100644 --- a/packages/order-watcher/test/global_hooks.ts +++ b/packages/order-watcher/test/global_hooks.ts @@ -12,7 +12,7 @@ before('migrate contracts', async function(): Promise<void> { const mochaTestTimeoutMs = 20000; this.timeout(mochaTestTimeoutMs); const txDefaults = { - gas: devConstants.GAS_ESTIMATE, + gas: devConstants.GAS_LIMIT, from: devConstants.TESTRPC_FIRST_ADDRESS, }; const artifactsDir = `../migrations/artifacts/1.0.0`; |