aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-06-01 01:45:34 +0800
committerFabio Berger <me@fabioberger.com>2018-06-01 01:45:34 +0800
commit94ee82e076d85b64063b5c71be13b1ebe0bb8c10 (patch)
tree53524249da4c5b907e1489d8677a7cc1edf069a2 /packages
parent0beab9eec45508fb6163bd6c0fd3970f0b61a91d (diff)
parent5b31d0aa3635ea524fb42d73cd6c713887dfef6a (diff)
downloaddexon-sol-tools-94ee82e076d85b64063b5c71be13b1ebe0bb8c10.tar
dexon-sol-tools-94ee82e076d85b64063b5c71be13b1ebe0bb8c10.tar.gz
dexon-sol-tools-94ee82e076d85b64063b5c71be13b1ebe0bb8c10.tar.bz2
dexon-sol-tools-94ee82e076d85b64063b5c71be13b1ebe0bb8c10.tar.lz
dexon-sol-tools-94ee82e076d85b64063b5c71be13b1ebe0bb8c10.tar.xz
dexon-sol-tools-94ee82e076d85b64063b5c71be13b1ebe0bb8c10.tar.zst
dexon-sol-tools-94ee82e076d85b64063b5c71be13b1ebe0bb8c10.zip
Merge branch 'v2-prototype' into refactor/order-utils/for-v2
* v2-prototype: (45 commits) Check length before accessing indices, add awaitTransactionSuccess where needed, and rename function Add back before/after snapshots for each test Rename Signer to Wallet, rename GAS_ESTIMATE to GAS_LIMIT Make preSigned and allowedValidators mappings public Change names of signature types Fix formatting and tests Make AssetProxyId last byte of assetData Add signer to txHash, allow approveValidator to be used with executeTransaction Update Whitelist Fix Exchange interface Increase block gas limit Use last byte of signature as signature type Remove TxOrigin signature type, modify whitelist to use Validator signature type Update Whitelist contract with comments, also require maker to be whitelisted Fix build Add example whitelist contract and minimum tests Add sample whitelist contract Add TxOrigin signature type and rearrange order of types Add approveValidator function Add Validator signature type ... # Conflicts: # packages/contracts/src/contracts/current/protocol/Exchange/MixinSignatureValidator.sol # packages/contracts/src/utils/types.ts # packages/contracts/test/exchange/transactions.ts # packages/order-utils/src/asset_proxy_utils.ts
Diffstat (limited to 'packages')
-rw-r--r--packages/0x.js/test/global_hooks.ts2
-rw-r--r--packages/assert/src/index.ts3
-rw-r--r--packages/contract-wrappers/test/global_hooks.ts2
-rw-r--r--packages/contracts/compiler.json1
-rw-r--r--packages/contracts/package.json2
-rw-r--r--packages/contracts/src/contracts/current/protocol/AssetProxy/ERC20Proxy.sol18
-rw-r--r--packages/contracts/src/contracts/current/protocol/AssetProxy/ERC721Proxy.sol20
-rw-r--r--packages/contracts/src/contracts/current/protocol/AssetProxy/MixinAssetProxy.sol6
-rw-r--r--packages/contracts/src/contracts/current/protocol/AssetProxy/MixinAuthorizable.sol5
-rw-r--r--packages/contracts/src/contracts/current/protocol/AssetProxy/interfaces/IAssetProxy.sol6
-rw-r--r--packages/contracts/src/contracts/current/protocol/AssetProxy/interfaces/IAuthorizable.sol5
-rw-r--r--packages/contracts/src/contracts/current/protocol/AssetProxy/mixins/MAssetProxy.sol3
-rw-r--r--packages/contracts/src/contracts/current/protocol/AssetProxy/mixins/MAuthorizable.sol2
-rw-r--r--packages/contracts/src/contracts/current/protocol/Exchange/MixinAssetProxyDispatcher.sol12
-rw-r--r--packages/contracts/src/contracts/current/protocol/Exchange/MixinSignatureValidator.sol145
-rw-r--r--packages/contracts/src/contracts/current/protocol/Exchange/MixinTransactions.sol9
-rw-r--r--packages/contracts/src/contracts/current/protocol/Exchange/interfaces/IExchange.sol12
-rw-r--r--packages/contracts/src/contracts/current/protocol/Exchange/interfaces/ISignatureValidator.sol12
-rw-r--r--packages/contracts/src/contracts/current/protocol/Exchange/interfaces/IValidator.sol36
-rw-r--r--packages/contracts/src/contracts/current/protocol/Exchange/interfaces/IWallet.sol (renamed from packages/contracts/src/contracts/current/protocol/Exchange/interfaces/ISigner.sol)5
-rw-r--r--packages/contracts/src/contracts/current/protocol/Exchange/interfaces/IWrapperFunctions.sol14
-rw-r--r--packages/contracts/src/contracts/current/protocol/Exchange/libs/LibExchangeErrors.sol1
-rw-r--r--packages/contracts/src/contracts/current/protocol/Exchange/mixins/MAssetProxyDispatcher.sol3
-rw-r--r--packages/contracts/src/contracts/current/protocol/Exchange/mixins/MSignatureValidator.sol20
-rw-r--r--packages/contracts/src/contracts/current/test/TestLibBytes/TestLibBytes.sol24
-rw-r--r--packages/contracts/src/contracts/current/test/TestSignatureValidator/TestSignatureValidator.sol9
-rw-r--r--packages/contracts/src/contracts/current/test/Whitelist/Whitelist.sol133
-rw-r--r--packages/contracts/src/contracts/current/utils/LibBytes/LibBytes.sol73
-rw-r--r--packages/contracts/src/utils/artifacts.ts2
-rw-r--r--packages/contracts/src/utils/constants.ts1
-rw-r--r--packages/contracts/src/utils/exchange_wrapper.ts42
-rw-r--r--packages/contracts/src/utils/log_decoder.ts52
-rw-r--r--packages/contracts/src/utils/multi_sig_wrapper.ts18
-rw-r--r--packages/contracts/src/utils/signing_utils.ts4
-rw-r--r--packages/contracts/src/utils/transaction_factory.ts9
-rw-r--r--packages/contracts/src/utils/types.ts1
-rw-r--r--packages/contracts/src/utils/web3_wrapper.ts2
-rw-r--r--packages/contracts/test/asset_proxy_owner.ts6
-rw-r--r--packages/contracts/test/exchange/core.ts5
-rw-r--r--packages/contracts/test/exchange/libs.ts4
-rw-r--r--packages/contracts/test/exchange/signature_validator.ts9
-rw-r--r--packages/contracts/test/exchange/transactions.ts136
-rw-r--r--packages/contracts/test/libraries/lib_bytes.ts31
-rw-r--r--packages/contracts/test/multi_sig_with_time_lock.ts6
-rw-r--r--packages/contracts/test/token_registry.ts1
-rw-r--r--packages/dev-utils/src/constants.ts2
-rw-r--r--packages/dev-utils/src/web3_factory.ts3
-rw-r--r--packages/migrations/artifacts/2.0.0/Whitelist.json280
-rw-r--r--packages/order-utils/src/asset_proxy_utils.ts20
-rw-r--r--packages/order-utils/src/signature_utils.ts41
-rw-r--r--packages/order-utils/test/signature_utils_test.ts6
-rw-r--r--packages/order-watcher/test/global_hooks.ts2
-rw-r--r--packages/sol-compiler/CHANGELOG.json14
-rw-r--r--packages/sol-compiler/package.json1
-rw-r--r--packages/sol-compiler/src/cli.ts2
-rw-r--r--packages/sol-compiler/src/compiler.ts17
-rw-r--r--packages/sol-compiler/src/schemas/compiler_options_schema.ts26
-rw-r--r--packages/types/src/index.ts9
-rw-r--r--packages/typescript-typings/CHANGELOG.json8
-rw-r--r--packages/typescript-typings/types/react-joyride/index.d.ts86
-rw-r--r--packages/typescript-typings/types/react-popper/index.d.ts49
-rw-r--r--packages/website/package.json15
-rw-r--r--packages/website/public/index.html68
-rw-r--r--packages/website/ts/components/onboarding/onboarding_flow.tsx93
-rw-r--r--packages/website/ts/components/onboarding/onboarding_tooltip.tsx56
-rw-r--r--packages/website/ts/components/onboarding/portal_onboarding_flow.tsx119
-rw-r--r--packages/website/ts/components/portal/drawer_menu.tsx2
-rw-r--r--packages/website/ts/components/top_bar/provider_display.tsx13
-rw-r--r--packages/website/ts/components/ui/container.tsx15
-rw-r--r--packages/website/ts/components/ui/overlay.tsx34
-rw-r--r--packages/website/ts/components/wallet/wallet.tsx33
-rw-r--r--packages/website/ts/components/wallet/wallet_disconnected_item.tsx4
-rw-r--r--packages/website/ts/containers/portal_onboarding_flow.ts30
-rw-r--r--packages/website/ts/index.tsx8
-rw-r--r--packages/website/ts/local_storage/local_storage.ts10
-rw-r--r--packages/website/ts/local_storage/state_storage.ts16
-rw-r--r--packages/website/ts/redux/reducer.ts5
-rw-r--r--packages/website/ts/redux/store.ts21
-rw-r--r--packages/website/ts/utils/constants.ts3
-rw-r--r--packages/website/ts/utils/style.ts3
-rw-r--r--packages/website/ts/utils/utils.ts9
81 files changed, 1600 insertions, 435 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/assert/src/index.ts b/packages/assert/src/index.ts
index f3b3651d5..95c7b658b 100644
--- a/packages/assert/src/index.ts
+++ b/packages/assert/src/index.ts
@@ -64,6 +64,9 @@ export const assert = {
this.assert(isWeb3Provider, this.typeAssertionMessage(variableName, 'Provider', value));
},
doesConformToSchema(variableName: string, value: any, schema: Schema, subSchemas?: Schema[]): void {
+ if (_.isUndefined(value)) {
+ throw new Error(`${variableName} can't be undefined`);
+ }
const schemaValidator = new SchemaValidator();
if (!_.isUndefined(subSchemas)) {
_.map(subSchemas, schemaValidator.addSchema.bind(schemaValidator));
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 4e9eaba76..8d29366a4 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 af1199f66..79dc87af0 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)) public 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/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/exchange_wrapper.ts b/packages/contracts/src/utils/exchange_wrapper.ts
index f7bd207a4..8f5915d97 100644
--- a/packages/contracts/src/utils/exchange_wrapper.ts
+++ b/packages/contracts/src/utils/exchange_wrapper.ts
@@ -7,16 +7,18 @@ import { ExchangeContract } from '../contract_wrappers/generated/exchange';
import { constants } from './constants';
import { formatters } from './formatters';
-import { logDecoder } from './log_decoder';
+import { LogDecoder } from './log_decoder';
import { orderUtils } from './order_utils';
import { OrderInfo, SignedTransaction } from './types';
export class ExchangeWrapper {
private _exchange: ExchangeContract;
private _web3Wrapper: Web3Wrapper;
+ private _logDecoder: LogDecoder;
constructor(exchangeContract: ExchangeContract, provider: Provider) {
this._exchange = exchangeContract;
this._web3Wrapper = new Web3Wrapper(provider);
+ this._logDecoder = new LogDecoder(this._web3Wrapper, this._exchange.address);
}
public async fillOrderAsync(
signedOrder: SignedOrder,
@@ -30,13 +32,13 @@ export class ExchangeWrapper {
params.signature,
{ from },
);
- const tx = await this._getTxWithDecodedExchangeLogsAsync(txHash);
+ const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
return tx;
}
public async cancelOrderAsync(signedOrder: SignedOrder, from: string): Promise<TransactionReceiptWithDecodedLogs> {
const params = orderUtils.createCancel(signedOrder);
const txHash = await this._exchange.cancelOrder.sendTransactionAsync(params.order, { from });
- const tx = await this._getTxWithDecodedExchangeLogsAsync(txHash);
+ const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
return tx;
}
public async fillOrKillOrderAsync(
@@ -51,7 +53,7 @@ export class ExchangeWrapper {
params.signature,
{ from },
);
- const tx = await this._getTxWithDecodedExchangeLogsAsync(txHash);
+ const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
return tx;
}
public async fillOrderNoThrowAsync(
@@ -66,7 +68,7 @@ export class ExchangeWrapper {
params.signature,
{ from },
);
- const tx = await this._getTxWithDecodedExchangeLogsAsync(txHash);
+ const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
return tx;
}
public async batchFillOrdersAsync(
@@ -81,7 +83,7 @@ export class ExchangeWrapper {
params.signatures,
{ from },
);
- const tx = await this._getTxWithDecodedExchangeLogsAsync(txHash);
+ const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
return tx;
}
public async batchFillOrKillOrdersAsync(
@@ -96,7 +98,7 @@ export class ExchangeWrapper {
params.signatures,
{ from },
);
- const tx = await this._getTxWithDecodedExchangeLogsAsync(txHash);
+ const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
return tx;
}
public async batchFillOrdersNoThrowAsync(
@@ -111,7 +113,7 @@ export class ExchangeWrapper {
params.signatures,
{ from },
);
- const tx = await this._getTxWithDecodedExchangeLogsAsync(txHash);
+ const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
return tx;
}
public async marketSellOrdersAsync(
@@ -126,7 +128,7 @@ export class ExchangeWrapper {
params.signatures,
{ from },
);
- const tx = await this._getTxWithDecodedExchangeLogsAsync(txHash);
+ const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
return tx;
}
public async marketSellOrdersNoThrowAsync(
@@ -141,7 +143,7 @@ export class ExchangeWrapper {
params.signatures,
{ from },
);
- const tx = await this._getTxWithDecodedExchangeLogsAsync(txHash);
+ const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
return tx;
}
public async marketBuyOrdersAsync(
@@ -156,7 +158,7 @@ export class ExchangeWrapper {
params.signatures,
{ from },
);
- const tx = await this._getTxWithDecodedExchangeLogsAsync(txHash);
+ const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
return tx;
}
public async marketBuyOrdersNoThrowAsync(
@@ -171,7 +173,7 @@ export class ExchangeWrapper {
params.signatures,
{ from },
);
- const tx = await this._getTxWithDecodedExchangeLogsAsync(txHash);
+ const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
return tx;
}
public async batchCancelOrdersAsync(
@@ -180,12 +182,12 @@ export class ExchangeWrapper {
): Promise<TransactionReceiptWithDecodedLogs> {
const params = formatters.createBatchCancel(orders);
const txHash = await this._exchange.batchCancelOrders.sendTransactionAsync(params.orders, { from });
- const tx = await this._getTxWithDecodedExchangeLogsAsync(txHash);
+ const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
return tx;
}
public async cancelOrdersUpToAsync(salt: BigNumber, from: string): Promise<TransactionReceiptWithDecodedLogs> {
const txHash = await this._exchange.cancelOrdersUpTo.sendTransactionAsync(salt, { from });
- const tx = await this._getTxWithDecodedExchangeLogsAsync(txHash);
+ const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
return tx;
}
public async registerAssetProxyAsync(
@@ -203,7 +205,7 @@ export class ExchangeWrapper {
oldAssetProxyAddress,
{ from },
);
- const tx = await this._getTxWithDecodedExchangeLogsAsync(txHash);
+ const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
return tx;
}
public async executeTransactionAsync(
@@ -217,7 +219,7 @@ export class ExchangeWrapper {
signedTx.signature,
{ from },
);
- const tx = await this._getTxWithDecodedExchangeLogsAsync(txHash);
+ const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
return tx;
}
public async getTakerAssetFilledAmountAsync(orderHashHex: string): Promise<BigNumber> {
@@ -241,13 +243,7 @@ export class ExchangeWrapper {
params.rightSignature,
{ from },
);
- const tx = await this._getTxWithDecodedExchangeLogsAsync(txHash);
- return tx;
- }
- private async _getTxWithDecodedExchangeLogsAsync(txHash: string): Promise<TransactionReceiptWithDecodedLogs> {
- const tx = await this._web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
- tx.logs = _.filter(tx.logs, log => log.address === this._exchange.address);
- tx.logs = _.map(tx.logs, log => logDecoder.decodeLogOrThrow(log));
+ const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
return tx;
}
}
diff --git a/packages/contracts/src/utils/log_decoder.ts b/packages/contracts/src/utils/log_decoder.ts
index d2e65d176..32819b657 100644
--- a/packages/contracts/src/utils/log_decoder.ts
+++ b/packages/contracts/src/utils/log_decoder.ts
@@ -1,19 +1,23 @@
import { ContractArtifact } from '@0xproject/sol-compiler';
-import { AbiDefinition, LogEntry, LogWithDecodedArgs, RawLog } from '@0xproject/types';
+import {
+ AbiDefinition,
+ LogEntry,
+ LogWithDecodedArgs,
+ RawLog,
+ TransactionReceiptWithDecodedLogs,
+} from '@0xproject/types';
import { AbiDecoder, BigNumber } from '@0xproject/utils';
+import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as _ from 'lodash';
import { artifacts } from './artifacts';
+import { constants } from './constants';
-const abiArrays: AbiDefinition[][] = [];
-_.forEach(artifacts, (artifact: ContractArtifact) => {
- const compilerOutput = artifact.compilerOutput;
- abiArrays.push(compilerOutput.abi);
-});
-const abiDecoder = new AbiDecoder(abiArrays);
-
-export const logDecoder = {
- wrapLogBigNumbers(log: any): any {
+export class LogDecoder {
+ private _web3Wrapper: Web3Wrapper;
+ private _contractAddress: string;
+ private _abiDecoder: AbiDecoder;
+ public static wrapLogBigNumbers(log: any): any {
const argNames = _.keys(log.args);
for (const argName of argNames) {
const isWeb3BigNumber = _.startsWith(log.args[argName].constructor.toString(), 'function BigNumber(');
@@ -21,13 +25,29 @@ export const logDecoder = {
log.args[argName] = new BigNumber(log.args[argName]);
}
}
- },
- decodeLogOrThrow<ArgsType>(log: LogEntry): LogWithDecodedArgs<ArgsType> | RawLog {
- const logWithDecodedArgsOrLog = abiDecoder.tryToDecodeLogOrNoop(log);
+ }
+ constructor(web3Wrapper: Web3Wrapper, contractAddress: string) {
+ this._web3Wrapper = web3Wrapper;
+ this._contractAddress = contractAddress;
+ const abiArrays: AbiDefinition[][] = [];
+ _.forEach(artifacts, (artifact: ContractArtifact) => {
+ const compilerOutput = artifact.compilerOutput;
+ abiArrays.push(compilerOutput.abi);
+ });
+ this._abiDecoder = new AbiDecoder(abiArrays);
+ }
+ public decodeLogOrThrow<ArgsType>(log: LogEntry): LogWithDecodedArgs<ArgsType> | RawLog {
+ const logWithDecodedArgsOrLog = this._abiDecoder.tryToDecodeLogOrNoop(log);
if (_.isUndefined((logWithDecodedArgsOrLog as LogWithDecodedArgs<ArgsType>).args)) {
throw new Error(`Unable to decode log: ${JSON.stringify(log)}`);
}
- logDecoder.wrapLogBigNumbers(logWithDecodedArgsOrLog);
+ LogDecoder.wrapLogBigNumbers(logWithDecodedArgsOrLog);
return logWithDecodedArgsOrLog;
- },
-};
+ }
+ public async getTxWithDecodedLogsAsync(txHash: string): Promise<TransactionReceiptWithDecodedLogs> {
+ const tx = await this._web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
+ tx.logs = _.filter(tx.logs, log => log.address === this._contractAddress);
+ tx.logs = _.map(tx.logs, log => this.decodeLogOrThrow(log));
+ return tx;
+ }
+}
diff --git a/packages/contracts/src/utils/multi_sig_wrapper.ts b/packages/contracts/src/utils/multi_sig_wrapper.ts
index 5c73cdf5a..d67692194 100644
--- a/packages/contracts/src/utils/multi_sig_wrapper.ts
+++ b/packages/contracts/src/utils/multi_sig_wrapper.ts
@@ -7,14 +7,16 @@ import { AssetProxyOwnerContract } from '../contract_wrappers/generated/asset_pr
import { MultiSigWalletContract } from '../contract_wrappers/generated/multi_sig_wallet';
import { constants } from './constants';
-import { logDecoder } from './log_decoder';
+import { LogDecoder } from './log_decoder';
export class MultiSigWrapper {
private _multiSig: MultiSigWalletContract;
private _web3Wrapper: Web3Wrapper;
+ private _logDecoder: LogDecoder;
constructor(multiSigContract: MultiSigWalletContract, provider: Provider) {
this._multiSig = multiSigContract;
this._web3Wrapper = new Web3Wrapper(provider);
+ this._logDecoder = new LogDecoder(this._web3Wrapper, this._multiSig.address);
}
public async submitTransactionAsync(
destination: string,
@@ -26,17 +28,17 @@ export class MultiSigWrapper {
const txHash = await this._multiSig.submitTransaction.sendTransactionAsync(destination, value, data, {
from,
});
- const tx = await this._getTxWithDecodedMultiSigLogsAsync(txHash);
+ const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
return tx;
}
public async confirmTransactionAsync(txId: BigNumber, from: string): Promise<TransactionReceiptWithDecodedLogs> {
const txHash = await this._multiSig.confirmTransaction.sendTransactionAsync(txId, { from });
- const tx = await this._getTxWithDecodedMultiSigLogsAsync(txHash);
+ const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
return tx;
}
public async executeTransactionAsync(txId: BigNumber, from: string): Promise<TransactionReceiptWithDecodedLogs> {
const txHash = await this._multiSig.executeTransaction.sendTransactionAsync(txId, { from });
- const tx = await this._getTxWithDecodedMultiSigLogsAsync(txHash);
+ const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
return tx;
}
public async executeRemoveAuthorizedAddressAsync(
@@ -45,13 +47,7 @@ export class MultiSigWrapper {
): Promise<TransactionReceiptWithDecodedLogs> {
const txHash = await (this
._multiSig as AssetProxyOwnerContract).executeRemoveAuthorizedAddress.sendTransactionAsync(txId, { from });
- const tx = await this._getTxWithDecodedMultiSigLogsAsync(txHash);
- return tx;
- }
- private async _getTxWithDecodedMultiSigLogsAsync(txHash: string): Promise<TransactionReceiptWithDecodedLogs> {
- const tx = await this._web3Wrapper.awaitTransactionMinedAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
- tx.logs = _.filter(tx.logs, log => log.address === this._multiSig.address);
- tx.logs = _.map(tx.logs, log => logDecoder.decodeLogOrThrow(log));
+ const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
return tx;
}
}
diff --git a/packages/contracts/src/utils/signing_utils.ts b/packages/contracts/src/utils/signing_utils.ts
index 41d63832e..d56d2cd44 100644
--- a/packages/contracts/src/utils/signing_utils.ts
+++ b/packages/contracts/src/utils/signing_utils.ts
@@ -7,19 +7,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 41907132a..f66d55f9b 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 { 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 9a0c95504..a6c90dae0 100644
--- a/packages/contracts/src/utils/types.ts
+++ b/packages/contracts/src/utils/types.ts
@@ -105,6 +105,7 @@ export enum ContractName {
DummyERC721Token = 'DummyERC721Token',
TestLibBytes = 'TestLibBytes',
Authorizable = 'Authorizable',
+ Whitelist = 'Whitelist',
}
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 e8397f8a2..adc57c7a4 100644
--- a/packages/contracts/test/exchange/core.ts
+++ b/packages/contracts/test/exchange/core.ts
@@ -457,10 +457,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 5f2c24ac0..10cb8b34e 100644
--- a/packages/contracts/test/exchange/libs.ts
+++ b/packages/contracts/test/exchange/libs.ts
@@ -48,7 +48,6 @@ describe('Exchange libs', () => {
beforeEach(async () => {
await blockchainLifecycle.startAsync();
- signedOrder = orderFactory.newSignedOrder();
});
afterEach(async () => {
await blockchainLifecycle.revertAsync();
@@ -68,7 +67,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(orderHashUtils.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 a41a19426..194053abc 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 = orderHashUtils.getOrderHashHex(signedOrder);
diff --git a/packages/contracts/test/exchange/transactions.ts b/packages/contracts/test/exchange/transactions.ts
index 7ee194aa1..ef7595562 100644
--- a/packages/contracts/test/exchange/transactions.ts
+++ b/packages/contracts/test/exchange/transactions.ts
@@ -1,5 +1,5 @@
import { BlockchainLifecycle } from '@0xproject/dev-utils';
-import { assetProxyUtils } from '@0xproject/order-utils';
+import { assetProxyUtils, generatePseudoRandomSalt } from '@0xproject/order-utils';
import { AssetProxyId, Order, OrderWithoutExchangeAddress, SignatureType, SignedOrder } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
import * as chai from 'chai';
@@ -9,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 { chaiSetup } from '../../src/utils/chai_setup';
import { constants } from '../../src/utils/constants';
@@ -49,6 +50,8 @@ describe('Exchange transactions', () => {
let defaultMakerTokenAddress: string;
let defaultTakerTokenAddress: string;
+ let makerPrivateKey: Buffer;
+ let takerPrivateKey: Buffer;
before(async () => {
await blockchainLifecycle.startAsync();
@@ -92,8 +95,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);
@@ -197,4 +200,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 }),
+ );
+
+ orderWithoutExchangeAddress = orderUtils.getOrderWithoutExchangeAddress(signedOrder);
+ const takerAssetFillAmount = signedOrder.takerAssetAmount;
+ const salt = generatePseudoRandomSalt();
+ return expect(
+ whitelist.fillOrderIfWhitelisted.sendTransactionAsync(
+ orderWithoutExchangeAddress,
+ 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 }),
+ );
+
+ orderWithoutExchangeAddress = orderUtils.getOrderWithoutExchangeAddress(signedOrder);
+ const takerAssetFillAmount = signedOrder.takerAssetAmount;
+ const salt = generatePseudoRandomSalt();
+ return expect(
+ whitelist.fillOrderIfWhitelisted.sendTransactionAsync(
+ orderWithoutExchangeAddress,
+ 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 }),
+ );
+
+ orderWithoutExchangeAddress = orderUtils.getOrderWithoutExchangeAddress(signedOrder);
+ const takerAssetFillAmount = signedOrder.takerAssetAmount;
+ const salt = generatePseudoRandomSalt();
+ await web3Wrapper.awaitTransactionSuccessAsync(
+ await whitelist.fillOrderIfWhitelisted.sendTransactionAsync(
+ orderWithoutExchangeAddress,
+ 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 de4011853..32b319e56 100644
--- a/packages/contracts/test/libraries/lib_bytes.ts
+++ b/packages/contracts/test/libraries/lib_bytes.ts
@@ -21,6 +21,7 @@ describe('LibBytes', () => {
let owner: string;
let libBytes: TestLibBytesContract;
const byteArrayShorterThan32Bytes = '0x012345';
+ const byteArrayShorterThan20Bytes = byteArrayShorterThan32Bytes;
const byteArrayLongerThan32Bytes =
'0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef';
const byteArrayLongerThan32BytesFirstBytesSwapped =
@@ -59,6 +60,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-utils/src/asset_proxy_utils.ts b/packages/order-utils/src/asset_proxy_utils.ts
index 11f81c656..5a084deba 100644
--- a/packages/order-utils/src/asset_proxy_utils.ts
+++ b/packages/order-utils/src/asset_proxy_utils.ts
@@ -3,8 +3,8 @@ import { BigNumber } from '@0xproject/utils';
import BN = require('bn.js');
import ethUtil = require('ethereumjs-util');
-const ERC20_PROXY_METADATA_BYTE_LENGTH = 21;
-const ERC721_PROXY_METADATA_BYTE_LENGTH = 53;
+const ERC20_PROXY_METADATA_BYTE_LENGTH = 20;
+const ERC721_PROXY_METADATA_BYTE_LENGTH = 52;
export const assetProxyUtils = {
encodeAssetProxyId(assetProxyId: AssetProxyId): Buffer {
@@ -43,7 +43,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;
},
@@ -56,7 +56,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(
@@ -65,7 +65,7 @@ export const assetProxyUtils = {
}), but got ${assetProxyId}`,
);
}
- const encodedTokenAddress = encodedProxyMetadata.slice(1, ERC20_PROXY_METADATA_BYTE_LENGTH);
+ const encodedTokenAddress = encodedProxyMetadata.slice(0, ERC20_PROXY_METADATA_BYTE_LENGTH);
const tokenAddress = assetProxyUtils.decodeAddress(encodedTokenAddress);
const erc20ProxyData = {
assetProxyId,
@@ -77,7 +77,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;
},
@@ -90,7 +90,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(
@@ -99,8 +99,8 @@ export const assetProxyUtils = {
}), but got ${assetProxyId}`,
);
}
- const addressOffset = 21;
- const encodedTokenAddress = encodedProxyMetadata.slice(1, addressOffset);
+ const addressOffset = 20;
+ const encodedTokenAddress = encodedProxyMetadata.slice(0, addressOffset);
const tokenAddress = assetProxyUtils.decodeAddress(encodedTokenAddress);
const encodedTokenId = encodedProxyMetadata.slice(addressOffset, ERC721_PROXY_METADATA_BYTE_LENGTH);
const tokenId = assetProxyUtils.decodeUint256(encodedTokenId);
@@ -120,7 +120,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/order-utils/src/signature_utils.ts b/packages/order-utils/src/signature_utils.ts
index f1466973c..8e387a6ae 100644
--- a/packages/order-utils/src/signature_utils.ts
+++ b/packages/order-utils/src/signature_utils.ts
@@ -34,41 +34,40 @@ export async function isValidSignatureAsync(
case SignatureType.Invalid:
return false;
- case SignatureType.Caller:
- // HACK: We currently do not "validate" the caller signature type.
- // It can only be validated during Exchange contract execution.
- throw new Error('Caller signature type cannot be validated off-chain');
-
- // TODO: Rename this type to `EthSign` b/c multiple of the signature
- // types use ECRecover...
- case SignatureType.Ecrecover: {
- const ecSignature = parseECSignature(signature);
- const prefixedMessageHex = addSignedMessagePrefix(data, MessagePrefixType.EthSign);
- return isValidECSignature(prefixedMessageHex, ecSignature, signerAddress);
- }
-
case SignatureType.EIP712: {
const ecSignature = parseECSignature(signature);
return isValidECSignature(data, ecSignature, signerAddress);
}
- case SignatureType.Trezor: {
- const prefixedMessageHex = addSignedMessagePrefix(data, MessagePrefixType.Trezor);
+ case SignatureType.EthSign: {
const ecSignature = parseECSignature(signature);
+ const prefixedMessageHex = addSignedMessagePrefix(data, MessagePrefixType.EthSign);
return isValidECSignature(prefixedMessageHex, ecSignature, signerAddress);
}
- // TODO: Rename Contract -> Wallet
- case SignatureType.Contract: {
+ case SignatureType.Caller:
+ // HACK: We currently do not "validate" the caller signature type.
+ // It can only be validated during Exchange contract execution.
+ throw new Error('Caller signature type cannot be validated off-chain');
+
+ case SignatureType.Wallet: {
const signerContract = new ISignerContract(artifacts.ISigner.abi, signerAddress, provider);
const isValid = await signerContract.isValidSignature.callAsync(data, signature);
return isValid;
}
+ // TODO: Add SignatureType.Validator
+
case SignatureType.PreSigned: {
return isValidPresignedSignatureAsync(provider, data, signature, signerAddress);
}
+ case SignatureType.Trezor: {
+ const prefixedMessageHex = addSignedMessagePrefix(data, MessagePrefixType.Trezor);
+ const ecSignature = parseECSignature(signature);
+ return isValidECSignature(prefixedMessageHex, ecSignature, signerAddress);
+ }
+
default:
throw new Error(`Unhandled SignatureType: ${signatureTypeIndexIfExists}`);
}
@@ -205,15 +204,16 @@ function hashTrezorPersonalMessage(message: Buffer): Buffer {
}
function parseECSignature(signature: string): ECSignature {
+ assert.isHexString('signature', signature);
const signatureTypeIndexIfExists = getSignatureTypeIndexIfExists(signature);
- const ecSignatureTypes = [SignatureType.Ecrecover, SignatureType.EIP712, SignatureType.Trezor];
+ const ecSignatureTypes = [SignatureType.EthSign, SignatureType.EIP712, SignatureType.Trezor];
const isECSignatureType = _.includes(ecSignatureTypes, signatureTypeIndexIfExists);
if (!isECSignatureType) {
throw new Error(`Cannot parse non-ECSignature type: ${signatureTypeIndexIfExists}`);
}
// tslint:disable-next-line:custom-no-magic-numbers
- const vrsHex = `0x${signature.substr(4)}`;
+ const vrsHex = signature.slice(0, -2);
const ecSignature = parseSignatureHexAsVRS(vrsHex);
return ecSignature;
@@ -221,7 +221,8 @@ function parseECSignature(signature: string): ECSignature {
function getSignatureTypeIndexIfExists(signature: string): number {
const unprefixedSignature = ethUtil.stripHexPrefix(signature);
- const signatureTypeHex = unprefixedSignature.substr(0, 2);
+ // tslint:disable-next-line:custom-no-magic-numbers
+ const signatureTypeHex = unprefixedSignature.slice(-2);
const base = 16;
const signatureTypeInt = parseInt(signatureTypeHex, base);
return signatureTypeInt;
diff --git a/packages/order-utils/test/signature_utils_test.ts b/packages/order-utils/test/signature_utils_test.ts
index 321e7313f..d7d895204 100644
--- a/packages/order-utils/test/signature_utils_test.ts
+++ b/packages/order-utils/test/signature_utils_test.ts
@@ -20,7 +20,7 @@ describe('Signature utils', () => {
describe('#isValidSignature', () => {
let dataHex = '0x6927e990021d23b1eb7b8789f6a6feaf98fe104bb0cf8259421b79f9a34222b0';
const ethSignSignature =
- '0x031B61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc3340349190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254';
+ '0x1B61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc3340349190569279751135161d22529dc25add4f6069af05be04cacbda2ace225403';
let address = '0x5409ed021d9299bf6814279a6a1411a7e866a631';
it("should return false if the data doesn't pertain to the signature & address", async () => {
@@ -56,7 +56,7 @@ describe('Signature utils', () => {
dataHex = '0xa1d7403bcbbcd75ec233cfd6584ff8dabed677d0e9bb32c2bea94e9dd8a109da';
address = '0x6ecbe1db9ef729cbe972c83fb886247691fb6beb';
const eip712Signature =
- '0x041bdde07aac4bf12c12ddbb155919c43eba4146a2cfcf904a862950dbebe332554c6674975603eb5a4eaf8fd7f2e06350267e5b36cda9851a89f8bb49fe2fc9afe2';
+ '0x1bdde07aac4bf12c12ddbb155919c43eba4146a2cfcf904a862950dbebe332554c6674975603eb5a4eaf8fd7f2e06350267e5b36cda9851a89f8bb49fe2fc9afe202';
const isValidSignatureLocal = await isValidSignatureAsync(provider, dataHex, eip712Signature, address);
expect(isValidSignatureLocal).to.be.true();
});
@@ -65,7 +65,7 @@ describe('Signature utils', () => {
dataHex = '0xd0d994e31c88f33fd8a572552a70ed339de579e5ba49ee1d17cc978bbe1cdd21';
address = '0x6ecbe1db9ef729cbe972c83fb886247691fb6beb';
const trezorSignature =
- '0x051ce4760660e6495b5ae6723087bea073b3a99ce98ea81fdf00c240279c010e63d05b87bc34c4d67d4776e8d5aeb023a67484f4eaf0fd353b40893e5101e845cd99';
+ '0x1ce4760660e6495b5ae6723087bea073b3a99ce98ea81fdf00c240279c010e63d05b87bc34c4d67d4776e8d5aeb023a67484f4eaf0fd353b40893e5101e845cd9908';
const isValidSignatureLocal = await isValidSignatureAsync(provider, dataHex, trezorSignature, address);
expect(isValidSignatureLocal).to.be.true();
});
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`;
diff --git a/packages/sol-compiler/CHANGELOG.json b/packages/sol-compiler/CHANGELOG.json
index 33fd99e4f..e0ebd3a2d 100644
--- a/packages/sol-compiler/CHANGELOG.json
+++ b/packages/sol-compiler/CHANGELOG.json
@@ -1,5 +1,19 @@
[
{
+ "version": "0.5.1",
+ "changes": [
+ {
+ "note": "Make `opts` constructor parameter optional",
+ "pr": 621
+ },
+ {
+ "note": "Add schema validation for compiler configuration",
+ "pr": 621
+ }
+ ],
+ "timestamp": 1527009133
+ },
+ {
"version": "0.5.0",
"changes": [
{
diff --git a/packages/sol-compiler/package.json b/packages/sol-compiler/package.json
index 7e55d718d..a74e4ae3e 100644
--- a/packages/sol-compiler/package.json
+++ b/packages/sol-compiler/package.json
@@ -72,6 +72,7 @@
"zeppelin-solidity": "1.8.0"
},
"dependencies": {
+ "@0xproject/assert": "0.2.10",
"@0xproject/json-schemas": "0.7.22",
"@0xproject/sol-resolver": "^0.0.5",
"@0xproject/types": "^0.7.0",
diff --git a/packages/sol-compiler/src/cli.ts b/packages/sol-compiler/src/cli.ts
index d107e8b37..b97cf4cab 100644
--- a/packages/sol-compiler/src/cli.ts
+++ b/packages/sol-compiler/src/cli.ts
@@ -35,7 +35,7 @@ const SEPARATOR = ',';
: argv.contracts === DEFAULT_CONTRACTS_LIST
? DEFAULT_CONTRACTS_LIST
: argv.contracts.split(SEPARATOR);
- const opts: CompilerOptions = {
+ const opts = {
contractsDir: argv.contractsDir,
artifactsDir: argv.artifactsDir,
contracts,
diff --git a/packages/sol-compiler/src/compiler.ts b/packages/sol-compiler/src/compiler.ts
index 2ebc5228e..1d5bdb940 100644
--- a/packages/sol-compiler/src/compiler.ts
+++ b/packages/sol-compiler/src/compiler.ts
@@ -1,3 +1,4 @@
+import { assert } from '@0xproject/assert';
import {
ContractSource,
ContractSources,
@@ -22,6 +23,7 @@ import * as requireFromString from 'require-from-string';
import * as semver from 'semver';
import solc = require('solc');
+import { compilerOptionsSchema } from './schemas/compiler_options_schema';
import { binPaths } from './solc/bin_paths';
import {
createDirIfDoesNotExistAsync,
@@ -80,16 +82,19 @@ export class Compiler {
* Instantiates a new instance of the Compiler class.
* @return An instance of the Compiler class.
*/
- constructor(opts: CompilerOptions) {
+ constructor(opts?: CompilerOptions) {
+ assert.doesConformToSchema('opts', opts, compilerOptionsSchema);
// TODO: Look for config file in parent directories if not found in current directory
const config: CompilerOptions = fs.existsSync(CONFIG_FILE)
? JSON.parse(fs.readFileSync(CONFIG_FILE).toString())
: {};
- this._contractsDir = opts.contractsDir || config.contractsDir || DEFAULT_CONTRACTS_DIR;
- this._solcVersionIfExists = opts.solcVersion || config.solcVersion;
- this._compilerSettings = opts.compilerSettings || config.compilerSettings || DEFAULT_COMPILER_SETTINGS;
- this._artifactsDir = opts.artifactsDir || config.artifactsDir || DEFAULT_ARTIFACTS_DIR;
- this._specifiedContracts = opts.contracts || config.contracts || ALL_CONTRACTS_IDENTIFIER;
+ const passedOpts = opts || {};
+ assert.doesConformToSchema('compiler.json', config, compilerOptionsSchema);
+ this._contractsDir = passedOpts.contractsDir || config.contractsDir || DEFAULT_CONTRACTS_DIR;
+ this._solcVersionIfExists = passedOpts.solcVersion || config.solcVersion;
+ this._compilerSettings = passedOpts.compilerSettings || config.compilerSettings || DEFAULT_COMPILER_SETTINGS;
+ this._artifactsDir = passedOpts.artifactsDir || config.artifactsDir || DEFAULT_ARTIFACTS_DIR;
+ this._specifiedContracts = passedOpts.contracts || config.contracts || ALL_CONTRACTS_IDENTIFIER;
this._nameResolver = new NameResolver(path.resolve(this._contractsDir));
const resolver = new FallthroughResolver();
resolver.appendResolver(new URLResolver());
diff --git a/packages/sol-compiler/src/schemas/compiler_options_schema.ts b/packages/sol-compiler/src/schemas/compiler_options_schema.ts
new file mode 100644
index 000000000..43a9c0879
--- /dev/null
+++ b/packages/sol-compiler/src/schemas/compiler_options_schema.ts
@@ -0,0 +1,26 @@
+export const compilerOptionsSchema = {
+ id: '/CompilerOptions',
+ properties: {
+ contractsDir: { type: 'string' },
+ artifactsDir: { type: 'string' },
+ solcVersion: { type: 'string', pattern: '^d+.d+.d+$' },
+ compilerSettings: { type: 'object' },
+ contracts: {
+ oneOf: [
+ {
+ type: 'string',
+ pattern: '^\\*$',
+ },
+ {
+ type: 'array',
+ items: {
+ type: 'string',
+ },
+ },
+ ],
+ },
+ },
+ type: 'object',
+ required: [],
+ additionalProperties: false,
+};
diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts
index f89c3c306..bb8fe896d 100644
--- a/packages/types/src/index.ts
+++ b/packages/types/src/index.ts
@@ -402,12 +402,13 @@ export interface Token {
export enum SignatureType {
Illegal,
Invalid,
- Caller,
- Ecrecover,
EIP712,
- Trezor,
- Contract,
+ EthSign,
+ Caller,
+ Wallet,
+ Validator,
PreSigned,
+ Trezor,
}
/**
diff --git a/packages/typescript-typings/CHANGELOG.json b/packages/typescript-typings/CHANGELOG.json
index 77a5ffad2..86b4a5078 100644
--- a/packages/typescript-typings/CHANGELOG.json
+++ b/packages/typescript-typings/CHANGELOG.json
@@ -1,5 +1,13 @@
[
{
+ "version": "0.5.0",
+ "changes": [
+ {
+ "note": "Add types for `react-popper`, remove types for `react-joyride`"
+ }
+ ]
+ },
+ {
"version": "0.4.0",
"changes": [
{
diff --git a/packages/typescript-typings/types/react-joyride/index.d.ts b/packages/typescript-typings/types/react-joyride/index.d.ts
deleted file mode 100644
index f126e4c86..000000000
--- a/packages/typescript-typings/types/react-joyride/index.d.ts
+++ /dev/null
@@ -1,86 +0,0 @@
-// Type definitions for react-joyride 2.0.0-11
-// Project: https://github.com/gilbarbara/react-joyride
-
-declare module 'react-joyride' {
- import * as React from 'react';
- export interface StyleOptions {
- arrowColor?: string;
- backgroundColor?: string;
- primaryColor?: string;
- textColor?: string;
- overlayColor?: string;
- spotlightShadow?: string;
- beaconSize?: number;
- zIndex?: number;
- }
-
- export type Placement =
- | 'top'
- | 'top-left'
- | 'top-right'
- | 'bottom'
- | 'bottom-left'
- | 'bottom-right'
- | 'right'
- | 'left';
-
- export interface Step {
- title?: string;
- content: React.ReactNode;
- target: string;
- placement?: Placement;
- type?: 'click' | 'hover';
- isFixed?: boolean;
- allowClicksThruHole?: boolean;
- disableBeacon?: boolean;
- style?: StyleOptions;
- [prop: string]: any;
- }
-
- export interface StyleOptionsProp {
- options: StyleOptions;
- }
-
- interface CallbackMetadata {
- type:
- | 'tour:start'
- | 'step:before'
- | 'beacon'
- | 'tooltip'
- | 'close'
- | 'step:after'
- | 'tour:end'
- | 'tour:status'
- | 'error:target_not_found'
- | 'error';
- step: number;
- }
-
- export type CallbackData = CallbackMetadata & State;
-
- export interface Props {
- steps?: Step[];
- beaconComponent?: React.ReactNode;
- disableOverlayClose?: boolean;
- run?: boolean;
- stepIndex?: number;
- callback?: (data: CallbackData) => void;
- debug?: boolean;
- styles?: StyleOptionsProp;
- }
-
- export interface State {
- action: string;
- controlled: boolean;
- index: number;
- lifecycle: string;
- size: 0;
- status: string;
- }
-
- export default class Joyride extends React.Component<Props, State> {
- constructor(props: Props);
-
- static defaultProps: Props;
- }
-}
diff --git a/packages/typescript-typings/types/react-popper/index.d.ts b/packages/typescript-typings/types/react-popper/index.d.ts
new file mode 100644
index 000000000..d7dbca17f
--- /dev/null
+++ b/packages/typescript-typings/types/react-popper/index.d.ts
@@ -0,0 +1,49 @@
+// Type definitions for react-popper 1.0.0-beta.6
+// Project: https://github.com/gilbarbara/react-joyride
+
+declare module 'react-popper' {
+ import * as React from 'react';
+ import * as PopperJS from 'popper.js';
+
+ interface ManagerProps {
+ children: React.ReactNode;
+ }
+ export class Manager extends React.Component<ManagerProps, {}> {}
+
+ type RefHandler = (ref: HTMLElement | null) => void;
+
+ export interface ReferenceChildrenProps {
+ ref: RefHandler;
+ }
+
+ export interface ReferenceProps {
+ children: (props: ReferenceChildrenProps) => React.ReactNode;
+ }
+ export class Reference extends React.Component<ReferenceProps, {}> {}
+
+ export interface PopperArrowProps {
+ ref: RefHandler;
+ style: React.CSSProperties;
+ }
+
+ export type Placement = PopperJS.Placement;
+
+ export interface PopperChildrenProps {
+ arrowProps: PopperArrowProps;
+ outOfBoundaries: boolean | null;
+ placement: PopperJS.Placement;
+ ref: RefHandler;
+ scheduleUpdate: () => void;
+ style: React.CSSProperties;
+ }
+
+ export interface PopperProps {
+ children: (props: PopperChildrenProps) => React.ReactNode;
+ eventsEnabled?: boolean;
+ modifiers?: PopperJS.Modifiers;
+ placement?: PopperJS.Placement;
+ positionFixed?: boolean;
+ referenceElement?: Element;
+ }
+ export class Popper extends React.Component<PopperProps, {}> {}
+}
diff --git a/packages/website/package.json b/packages/website/package.json
index 69115be9a..95804f988 100644
--- a/packages/website/package.json
+++ b/packages/website/package.json
@@ -11,22 +11,19 @@
"clean": "shx rm -f public/bundle*",
"lint": "tslint --project . 'ts/**/*.ts' 'ts/**/*.tsx'",
"watch": "webpack-dev-server --content-base public --https",
- "deploy_dogfood":
- "npm run build; aws s3 sync ./public/. s3://dogfood.0xproject.com --profile 0xproject --region us-east-1 --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers",
- "deploy_staging":
- "npm run build; aws s3 sync ./public/. s3://staging-0xproject --profile 0xproject --region us-east-1 --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers",
- "deploy_live":
- "npm run build; aws s3 sync ./public/. s3://0xproject.com --profile 0xproject --region us-east-1 --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers"
+ "deploy_dogfood": "npm run build; aws s3 sync ./public/. s3://dogfood.0xproject.com --profile 0xproject --region us-east-1 --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers",
+ "deploy_staging": "npm run build; aws s3 sync ./public/. s3://staging-0xproject --profile 0xproject --region us-east-1 --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers",
+ "deploy_live": "npm run build; aws s3 sync ./public/. s3://0xproject.com --profile 0xproject --region us-east-1 --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers"
},
"author": "Fabio Berger",
"license": "Apache-2.0",
"dependencies": {
+ "@0xproject/contract-wrappers": "^0.0.2",
"@0xproject/react-docs": "^0.0.12",
"@0xproject/react-shared": "^0.1.7",
"@0xproject/subproviders": "^0.10.2",
- "@0xproject/contract-wrappers": "^0.0.2",
- "@0xproject/typescript-typings": "^0.3.2",
"@0xproject/types": "0.7.0",
+ "@0xproject/typescript-typings": "^0.3.2",
"@0xproject/utils": "^0.6.2",
"@0xproject/web3-wrapper": "^0.6.4",
"accounting": "^0.4.1",
@@ -46,7 +43,7 @@
"react-document-title": "^2.0.3",
"react-dom": "15.6.1",
"react-ga": "^2.4.1",
- "react-joyride": "^2.0.0-11",
+ "react-popper": "^1.0.0-beta.6",
"react-redux": "^5.0.3",
"react-router-dom": "^4.1.1",
"react-scroll": "^1.5.2",
diff --git a/packages/website/public/index.html b/packages/website/public/index.html
index c28e4abf4..4c0985c71 100644
--- a/packages/website/public/index.html
+++ b/packages/website/public/index.html
@@ -26,53 +26,53 @@
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-98720122-1"></script>
<script>
- window.dataLayer = window.dataLayer || [];
-function gtag() {
- dataLayer.push(arguments);
-}
-gtag('js', new Date());
+ window.dataLayer = window.dataLayer || [];
+ function gtag() {
+ dataLayer.push(arguments);
+ }
+ gtag('js', new Date());
-gtag('config', 'UA-98720122-1');
-</script>
+ gtag('config', 'UA-98720122-1');
+ </script>
<!-- End Google Analytics -->
<!-- Facebook SDK -->
<div id="fb-root"></div>
<script>
- (function(d, s, id) {
- var js,
- fjs = d.getElementsByTagName(s)[0];
- if (d.getElementById(id)) return;
- js = d.createElement(s);
- js.id = id;
- js.src = '//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.8&appId=1687545238205192';
- fjs.parentNode.insertBefore(js, fjs);
-})(document, 'script', 'facebook-jssdk');
-</script>
+ (function (d, s, id) {
+ var js,
+ fjs = d.getElementsByTagName(s)[0];
+ if (d.getElementById(id)) return;
+ js = d.createElement(s);
+ js.id = id;
+ js.src = '//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.8&appId=1687545238205192';
+ fjs.parentNode.insertBefore(js, fjs);
+ })(document, 'script', 'facebook-jssdk');
+ </script>
<div id="app"></div>
<!-- End Facebook SDK -->
<!-- Twitter SDK -->
<script>
- window.twttr = (function(d, s, id) {
- var js,
- fjs = d.getElementsByTagName(s)[0],
- t = window.twttr || {};
- if (d.getElementById(id)) return t;
- js = d.createElement(s);
- js.id = id;
- js.src = 'https://platform.twitter.com/widgets.js';
- fjs.parentNode.insertBefore(js, fjs);
+ window.twttr = (function (d, s, id) {
+ var js,
+ fjs = d.getElementsByTagName(s)[0],
+ t = window.twttr || {};
+ if (d.getElementById(id)) return t;
+ js = d.createElement(s);
+ js.id = id;
+ js.src = 'https://platform.twitter.com/widgets.js';
+ fjs.parentNode.insertBefore(js, fjs);
- t._e = [];
- t.ready = function(f) {
- t._e.push(f);
- };
- return t;
-})(document, 'script', 'twitter-wjs');
-</script>
+ t._e = [];
+ t.ready = function (f) {
+ t._e.push(f);
+ };
+ return t;
+ })(document, 'script', 'twitter-wjs');
+ </script>
<!-- End Twitter SDK -->
<!-- Main -->
<script type="text/javascript" crossorigin="anonymous" src="/bundle.js" charset="utf-8"></script>
</body>
-</html>
+</html> \ No newline at end of file
diff --git a/packages/website/ts/components/onboarding/onboarding_flow.tsx b/packages/website/ts/components/onboarding/onboarding_flow.tsx
index 621d14260..4066babaf 100644
--- a/packages/website/ts/components/onboarding/onboarding_flow.tsx
+++ b/packages/website/ts/components/onboarding/onboarding_flow.tsx
@@ -1,39 +1,96 @@
import * as _ from 'lodash';
import * as React from 'react';
-import Joyride, { CallbackData, Step, StyleOptions } from 'react-joyride';
+import { Placement, Popper, PopperChildrenProps } from 'react-popper';
+import { ContinueButtonDisplay, OnboardingTooltip } from 'ts/components/onboarding/onboarding_tooltip';
+import { Container } from 'ts/components/ui/container';
+import { Overlay } from 'ts/components/ui/overlay';
import { zIndex } from 'ts/utils/style';
+export interface Step {
+ target: string;
+ title?: string;
+ content: React.ReactNode;
+ placement?: Placement;
+ hideBackButton?: boolean;
+ hideNextButton?: boolean;
+ continueButtonDisplay?: ContinueButtonDisplay;
+}
+
export interface OnboardingFlowProps {
steps: Step[];
stepIndex: number;
isRunning: boolean;
onClose: () => void;
+ updateOnboardingStep: (stepIndex: number) => void;
}
-const joyrideStyleOptions: StyleOptions = {
- zIndex: zIndex.overlay,
-};
-
-// Wrapper around Joyride with defaults and styles set
export class OnboardingFlow extends React.Component<OnboardingFlowProps> {
public render(): React.ReactNode {
+ if (!this.props.isRunning) {
+ return null;
+ }
+ return (
+ <Overlay>
+ <Popper referenceElement={this._getElementForStep()} placement={this._getCurrentStep().placement}>
+ {this._renderPopperChildren.bind(this)}
+ </Popper>
+ </Overlay>
+ );
+ }
+
+ private _getElementForStep(): Element {
+ return document.querySelector(this._getCurrentStep().target);
+ }
+
+ private _renderPopperChildren(props: PopperChildrenProps): React.ReactNode {
return (
- <Joyride
- run={this.props.isRunning}
- debug={true}
- steps={this.props.steps}
- stepIndex={this.props.stepIndex}
- styles={{ options: joyrideStyleOptions }}
- callback={this._handleChange.bind(this)}
- />
+ <div ref={props.ref} style={props.style} data-placement={props.placement}>
+ {this._renderToolTip()}
+ </div>
);
}
- private _handleChange(data: CallbackData): void {
- switch (data.action) {
- case 'close':
- this.props.onClose();
+ private _renderToolTip(): React.ReactNode {
+ const { steps, stepIndex } = this.props;
+ const step = steps[stepIndex];
+ const isLastStep = steps.length - 1 === stepIndex;
+ return (
+ <Container marginLeft="15px">
+ <OnboardingTooltip
+ title={step.title}
+ content={step.content}
+ isLastStep={isLastStep}
+ hideBackButton={step.hideBackButton}
+ hideNextButton={step.hideNextButton}
+ onClose={this.props.onClose}
+ onClickNext={this._goToNextStep.bind(this)}
+ onClickBack={this._goToPrevStep.bind(this)}
+ continueButtonDisplay={step.continueButtonDisplay}
+ />
+ </Container>
+ );
+ }
+
+ private _getCurrentStep(): Step {
+ return this.props.steps[this.props.stepIndex];
+ }
+
+ private _goToNextStep(): void {
+ const nextStep = this.props.stepIndex + 1;
+ if (nextStep < this.props.steps.length) {
+ this.props.updateOnboardingStep(nextStep);
+ } else {
+ this.props.onClose();
+ }
+ }
+
+ private _goToPrevStep(): void {
+ const nextStep = this.props.stepIndex - 1;
+ if (nextStep >= 0) {
+ this.props.updateOnboardingStep(nextStep);
+ } else {
+ this.props.onClose();
}
}
}
diff --git a/packages/website/ts/components/onboarding/onboarding_tooltip.tsx b/packages/website/ts/components/onboarding/onboarding_tooltip.tsx
new file mode 100644
index 000000000..eb34a87f2
--- /dev/null
+++ b/packages/website/ts/components/onboarding/onboarding_tooltip.tsx
@@ -0,0 +1,56 @@
+import * as React from 'react';
+
+import { colors } from '@0xproject/react-shared';
+import { Container } from 'ts/components/ui/container';
+import { Island } from 'ts/components/ui/island';
+
+export type ContinueButtonDisplay = 'enabled' | 'disabled';
+
+export interface OnboardingTooltipProps {
+ title?: string;
+ content: React.ReactNode;
+ isLastStep: boolean;
+ onClose: () => void;
+ onClickNext: () => void;
+ onClickBack: () => void;
+ continueButtonDisplay?: ContinueButtonDisplay;
+ hideBackButton?: boolean;
+ hideNextButton?: boolean;
+}
+
+// TODO: Make this more general button.
+export interface ContinueButtonProps {
+ display: ContinueButtonDisplay;
+ children?: string;
+ onClick: () => void;
+}
+
+export const ContinueButton: React.StatelessComponent<ContinueButtonProps> = (props: ContinueButtonProps) => {
+ const isDisabled = props.display === 'disabled';
+ return (
+ <button disabled={isDisabled} onClick={isDisabled ? undefined : props.onClick}>
+ {props.children}
+ </button>
+ );
+};
+
+export const OnboardingTooltip: React.StatelessComponent<OnboardingTooltipProps> = (props: OnboardingTooltipProps) => (
+ <Island>
+ <Container paddingRight="30px" paddingLeft="30px" maxWidth={350} paddingTop="15px" paddingBottom="15px">
+ <div className="flex flex-column">
+ {props.title}
+ {props.content}
+ {props.continueButtonDisplay && (
+ <ContinueButton onClick={props.onClickNext} display={props.continueButtonDisplay}>
+ Continue
+ </ContinueButton>
+ )}
+ {!props.hideBackButton && <button onClick={props.onClickBack}>Back</button>}
+ {!props.hideNextButton && <button onClick={props.onClickNext}>Skip</button>}
+ <button onClick={props.onClose}>Close</button>
+ </div>
+ </Container>
+ </Island>
+);
+
+OnboardingTooltip.displayName = 'OnboardingTooltip';
diff --git a/packages/website/ts/components/onboarding/portal_onboarding_flow.tsx b/packages/website/ts/components/onboarding/portal_onboarding_flow.tsx
index 11684aaee..edaeb3736 100644
--- a/packages/website/ts/components/onboarding/portal_onboarding_flow.tsx
+++ b/packages/website/ts/components/onboarding/portal_onboarding_flow.tsx
@@ -1,32 +1,123 @@
+import * as _ from 'lodash';
import * as React from 'react';
-import { Step } from 'react-joyride';
-import { OnboardingFlow } from 'ts/components/onboarding/onboarding_flow';
+import { BigNumber } from '@0xproject/utils';
+import { OnboardingFlow, Step } from 'ts/components/onboarding/onboarding_flow';
+import { ProviderType, TokenByAddress } from 'ts/types';
+import { utils } from 'ts/utils/utils';
export interface PortalOnboardingFlowProps {
stepIndex: number;
isRunning: boolean;
- onClose: () => void;
+ userAddress: string;
+ hasBeenSeen: boolean;
+ providerType: ProviderType;
+ injectedProviderName: string;
+ blockchainIsLoaded: boolean;
+ userEthBalanceInWei: BigNumber;
+ tokenByAddress: TokenByAddress;
+ updateIsRunning: (isRunning: boolean) => void;
+ updateOnboardingStep: (stepIndex: number) => void;
}
-const steps: Step[] = [
- {
- target: '.wallet',
- content: 'You are onboarding right now!',
- placement: 'right',
- disableBeacon: true,
- },
-];
-
export class PortalOnboardingFlow extends React.Component<PortalOnboardingFlowProps> {
+ public componentDidMount(): void {
+ this._overrideOnboardingStateIfShould();
+ }
+ public componentDidUpdate(): void {
+ this._overrideOnboardingStateIfShould();
+ }
public render(): React.ReactNode {
return (
<OnboardingFlow
- steps={steps}
+ steps={this._getSteps()}
stepIndex={this.props.stepIndex}
isRunning={this.props.isRunning}
- onClose={this.props.onClose}
+ onClose={this.props.updateIsRunning.bind(this, false)}
+ updateOnboardingStep={this.props.updateOnboardingStep}
/>
);
}
+
+ private _getSteps(): Step[] {
+ const steps: Step[] = [
+ {
+ target: '.wallet',
+ content:
+ 'Before you begin, you need to connect to a wallet. This will be used across all 0x relayers and dApps',
+ placement: 'right',
+ hideBackButton: true,
+ hideNextButton: true,
+ },
+ {
+ target: '.wallet',
+ content: 'Unlock your metamask extension to begin',
+ placement: 'right',
+ hideBackButton: true,
+ hideNextButton: true,
+ },
+ {
+ target: '.wallet',
+ content:
+ 'In order to start trading on any 0x relayer in the 0x ecosystem, you need to complete two simple steps',
+ placement: 'right',
+ hideBackButton: true,
+ continueButtonDisplay: 'enabled',
+ },
+ {
+ target: '.eth-row',
+ content: 'Before you begin you will need to send some ETH to your metamask wallet',
+ placement: 'right',
+ continueButtonDisplay: this._userHasEth() ? 'enabled' : 'disabled',
+ },
+ {
+ target: '.weth-row',
+ content: 'You need to convert some of your ETH into tradeable Wrapped ETH (WETH)',
+ placement: 'right',
+ continueButtonDisplay: this._userHasWeth() ? 'enabled' : 'disabled',
+ },
+ ];
+ return steps;
+ }
+
+ private _isAddressAvailable(): boolean {
+ return !_.isEmpty(this.props.userAddress);
+ }
+
+ private _userHasEth(): boolean {
+ return this.props.userEthBalanceInWei > new BigNumber(0);
+ }
+
+ private _userHasWeth(): boolean {
+ // TODO: https://app.asana.com/0/681385331277907/690722374136933
+ return false;
+ }
+
+ private _overrideOnboardingStateIfShould(): void {
+ this._autoStartOnboardingIfShould();
+ this._adjustStepIfShould();
+ }
+
+ private _adjustStepIfShould(): void {
+ if (this._isAddressAvailable()) {
+ if (this.props.stepIndex < 2) {
+ this.props.updateOnboardingStep(2);
+ }
+ return;
+ }
+ const isExternallyInjected = utils.isExternallyInjected(
+ this.props.providerType,
+ this.props.injectedProviderName,
+ );
+ if (isExternallyInjected) {
+ this.props.updateOnboardingStep(1);
+ return;
+ }
+ this.props.updateOnboardingStep(0);
+ }
+ private _autoStartOnboardingIfShould(): void {
+ if (!this.props.isRunning && !this.props.hasBeenSeen && this.props.blockchainIsLoaded) {
+ this.props.updateIsRunning(true);
+ }
+ }
}
diff --git a/packages/website/ts/components/portal/drawer_menu.tsx b/packages/website/ts/components/portal/drawer_menu.tsx
index 75c8ac6c2..ace11639a 100644
--- a/packages/website/ts/components/portal/drawer_menu.tsx
+++ b/packages/website/ts/components/portal/drawer_menu.tsx
@@ -36,7 +36,7 @@ export interface DrawerMenuProps {
}
export const DrawerMenu = (props: DrawerMenuProps) => {
const relayerItemEntry = {
- to: `${WebsitePaths.Portal}/`,
+ to: `${WebsitePaths.Portal}`,
labelText: 'Relayer ecosystem',
iconName: 'zmdi-portable-wifi',
};
diff --git a/packages/website/ts/components/top_bar/provider_display.tsx b/packages/website/ts/components/top_bar/provider_display.tsx
index fc516882a..679ec07dc 100644
--- a/packages/website/ts/components/top_bar/provider_display.tsx
+++ b/packages/website/ts/components/top_bar/provider_display.tsx
@@ -11,6 +11,7 @@ import { Dispatcher } from 'ts/redux/dispatcher';
import { ProviderType } from 'ts/types';
import { colors } from 'ts/utils/colors';
import { constants } from 'ts/utils/constants';
+import { zIndex } from 'ts/utils/style';
import { utils } from 'ts/utils/utils';
const ROOT_HEIGHT = 24;
@@ -39,8 +40,10 @@ const styles: Styles = {
export class ProviderDisplay extends React.Component<ProviderDisplayProps, ProviderDisplayState> {
public render(): React.ReactNode {
const isAddressAvailable = !_.isEmpty(this.props.userAddress);
- const isExternallyInjectedProvider =
- this.props.providerType === ProviderType.Injected && this.props.injectedProviderName !== '0x Public';
+ const isExternallyInjectedProvider = utils.isExternallyInjected(
+ this.props.providerType,
+ this.props.injectedProviderName,
+ );
const displayAddress = isAddressAvailable
? utils.getAddressBeginAndEnd(this.props.userAddress)
: isExternallyInjectedProvider
@@ -69,15 +72,13 @@ export class ProviderDisplay extends React.Component<ProviderDisplayProps, Provi
)}
</div>
);
- const hasInjectedProvider =
- this.props.injectedProviderName !== '0x Public' && this.props.providerType === ProviderType.Injected;
const hasLedgerProvider = this.props.providerType === ProviderType.Ledger;
- const horizontalPosition = hasInjectedProvider || hasLedgerProvider ? 'left' : 'middle';
+ const horizontalPosition = isExternallyInjectedProvider || hasLedgerProvider ? 'left' : 'middle';
return (
<div style={{ width: 'fit-content', height: 48, float: 'right' }}>
<DropDown
hoverActiveNode={hoverActiveNode}
- popoverContent={this.renderPopoverContent(hasInjectedProvider, hasLedgerProvider)}
+ popoverContent={this.renderPopoverContent(isExternallyInjectedProvider, hasLedgerProvider)}
anchorOrigin={{ horizontal: horizontalPosition, vertical: 'bottom' }}
targetOrigin={{ horizontal: horizontalPosition, vertical: 'top' }}
zDepth={1}
diff --git a/packages/website/ts/components/ui/container.tsx b/packages/website/ts/components/ui/container.tsx
index 07868608c..d577447b0 100644
--- a/packages/website/ts/components/ui/container.tsx
+++ b/packages/website/ts/components/ui/container.tsx
@@ -1,10 +1,17 @@
import * as React from 'react';
+type StringOrNum = string | number;
+
export interface ContainerProps {
- marginTop?: string | number;
- marginBottom?: string | number;
- marginRight?: string | number;
- marginLeft?: string | number;
+ marginTop?: StringOrNum;
+ marginBottom?: StringOrNum;
+ marginRight?: StringOrNum;
+ marginLeft?: StringOrNum;
+ paddingTop?: StringOrNum;
+ paddingBottom?: StringOrNum;
+ paddingRight?: StringOrNum;
+ paddingLeft?: StringOrNum;
+ maxWidth?: StringOrNum;
children?: React.ReactNode;
}
diff --git a/packages/website/ts/components/ui/overlay.tsx b/packages/website/ts/components/ui/overlay.tsx
new file mode 100644
index 000000000..bb2ed8e59
--- /dev/null
+++ b/packages/website/ts/components/ui/overlay.tsx
@@ -0,0 +1,34 @@
+import { colors } from '@0xproject/react-shared';
+import * as _ from 'lodash';
+import * as React from 'react';
+
+import { zIndex } from 'ts/utils/style';
+
+export interface OverlayProps {
+ children?: React.ReactNode;
+ style?: React.CSSProperties;
+ onClick?: () => void;
+}
+
+const style: React.CSSProperties = {
+ position: 'fixed',
+ top: 0,
+ right: 0,
+ bottom: 0,
+ left: 0,
+ zIndex: zIndex.overlay,
+ backgroundColor: 'rgba(0, 0, 0, 0.6)',
+};
+
+export const Overlay: React.StatelessComponent = (props: OverlayProps) => (
+ <div style={{ ...style, ...props.style }} onClick={props.onClick}>
+ {props.children}
+ </div>
+);
+
+Overlay.defaultProps = {
+ style: {},
+ onClick: _.noop,
+};
+
+Overlay.displayName = 'Overlay';
diff --git a/packages/website/ts/components/wallet/wallet.tsx b/packages/website/ts/components/wallet/wallet.tsx
index 10ee31619..30d1285f4 100644
--- a/packages/website/ts/components/wallet/wallet.tsx
+++ b/packages/website/ts/components/wallet/wallet.tsx
@@ -46,6 +46,7 @@ import {
import { backendClient } from 'ts/utils/backend_client';
import { colors } from 'ts/utils/colors';
import { constants } from 'ts/utils/constants';
+import { zIndex } from 'ts/utils/style';
import { utils } from 'ts/utils/utils';
import { styles as walletItemStyles } from 'ts/utils/wallet_item_styles';
@@ -88,6 +89,8 @@ interface AccessoryItemConfig {
const styles: Styles = {
root: {
width: '100%',
+ zIndex: zIndex.aboveOverlay,
+ position: 'relative',
},
headerItemInnerDiv: {
paddingLeft: 65,
@@ -129,9 +132,6 @@ const styles: Styles = {
};
const ETHER_ICON_PATH = '/images/ether.png';
-const ETHER_TOKEN_SYMBOL = 'WETH';
-const ZRX_TOKEN_SYMBOL = 'ZRX';
-const ETHER_SYMBOL = 'ETH';
const ICON_DIMENSION = 24;
const TOKEN_AMOUNT_DISPLAY_PRECISION = 3;
const BODY_ITEM_KEY = 'BODY';
@@ -322,7 +322,7 @@ export class Wallet extends React.Component<WalletProps, WalletState> {
const primaryText = this._renderAmount(
this.props.userEtherBalanceInWei,
constants.DECIMAL_PLACES_ETH,
- ETHER_SYMBOL,
+ constants.ETHER_SYMBOL,
);
const etherToken = this._getEthToken();
const etherPrice = this.state.trackedTokenStateByAddress[etherToken.address].price;
@@ -341,13 +341,13 @@ export class Wallet extends React.Component<WalletProps, WalletState> {
? { ...walletItemStyles.focusedItem, ...styles.paddedItem }
: { ...styles.tokenItem, ...styles.borderedItem, ...styles.paddedItem };
const key = ETHER_ITEM_KEY;
- return this._renderBalanceRow(key, icon, primaryText, secondaryText, accessoryItemConfig);
+ return this._renderBalanceRow(key, icon, primaryText, secondaryText, accessoryItemConfig, 'eth-row');
}
private _renderTokenRows(): React.ReactNode {
const trackedTokens = this.props.trackedTokens;
const trackedTokensStartingWithEtherToken = trackedTokens.sort(
- firstBy((t: Token) => t.symbol !== ETHER_TOKEN_SYMBOL)
- .thenBy((t: Token) => t.symbol !== ZRX_TOKEN_SYMBOL)
+ firstBy((t: Token) => t.symbol !== constants.ETHER_TOKEN_SYMBOL)
+ .thenBy((t: Token) => t.symbol !== constants.ZRX_TOKEN_SYMBOL)
.thenBy('address'),
);
return _.map(trackedTokensStartingWithEtherToken, this._renderTokenRow.bind(this));
@@ -362,7 +362,8 @@ export class Wallet extends React.Component<WalletProps, WalletState> {
const icon = <TokenIcon token={token} diameter={ICON_DIMENSION} link={tokenLink} />;
const primaryText = this._renderAmount(tokenState.balance, token.decimals, token.symbol);
const secondaryText = this._renderValue(tokenState.balance, token.decimals, tokenState.price);
- const wrappedEtherDirection = token.symbol === ETHER_TOKEN_SYMBOL ? Side.Receive : undefined;
+ const isWeth = token.symbol === constants.ETHER_TOKEN_SYMBOL;
+ const wrappedEtherDirection = isWeth ? Side.Receive : undefined;
const accessoryItemConfig: AccessoryItemConfig = {
wrappedEtherDirection,
allowanceToggleConfig: {
@@ -371,7 +372,14 @@ export class Wallet extends React.Component<WalletProps, WalletState> {
},
};
const key = token.address;
- return this._renderBalanceRow(key, icon, primaryText, secondaryText, accessoryItemConfig);
+ return this._renderBalanceRow(
+ key,
+ icon,
+ primaryText,
+ secondaryText,
+ accessoryItemConfig,
+ isWeth ? 'weth-row' : undefined,
+ );
}
private _renderBalanceRow(
key: string,
@@ -379,6 +387,7 @@ export class Wallet extends React.Component<WalletProps, WalletState> {
primaryText: React.ReactNode,
secondaryText: React.ReactNode,
accessoryItemConfig: AccessoryItemConfig,
+ className?: string,
): React.ReactNode {
const shouldShowWrapEtherItem =
!_.isUndefined(this.state.wrappedEtherDirection) &&
@@ -388,7 +397,7 @@ export class Wallet extends React.Component<WalletProps, WalletState> {
: { ...styles.tokenItem, ...styles.borderedItem, ...styles.paddedItem };
const etherToken = this._getEthToken();
return (
- <div key={key} className="flex flex-column">
+ <div key={key} className={`flex flex-column ${className || ''}`}>
<div className="flex items-center" style={style}>
<div className="px2">{icon}</div>
<div className="flex-none pr2 pt2 pb2">
@@ -578,8 +587,6 @@ export class Wallet extends React.Component<WalletProps, WalletState> {
});
}
private _getEthToken(): Token {
- const tokens = _.values(this.props.tokenByAddress);
- const etherToken = _.find(tokens, { symbol: ETHER_TOKEN_SYMBOL });
- return etherToken;
+ return utils.getEthToken(this.props.tokenByAddress);
}
} // tslint:disable:max-file-line-count
diff --git a/packages/website/ts/components/wallet/wallet_disconnected_item.tsx b/packages/website/ts/components/wallet/wallet_disconnected_item.tsx
index d334f1748..39a62e1fb 100644
--- a/packages/website/ts/components/wallet/wallet_disconnected_item.tsx
+++ b/packages/website/ts/components/wallet/wallet_disconnected_item.tsx
@@ -6,6 +6,7 @@ import * as React from 'react';
import { ProviderType } from 'ts/types';
import { colors } from 'ts/utils/colors';
import { constants } from 'ts/utils/constants';
+import { utils } from 'ts/utils/utils';
export interface WalletDisconnectedItemProps {
providerType: ProviderType;
@@ -38,8 +39,7 @@ const BUTTON_BOTTOM_PADDING = 80;
export const WalletDisconnectedItem: React.StatelessComponent<WalletDisconnectedItemProps> = (
props: WalletDisconnectedItemProps,
) => {
- const isExternallyInjectedProvider =
- props.providerType === ProviderType.Injected && props.injectedProviderName !== '0x Public';
+ const isExternallyInjectedProvider = utils.isExternallyInjected(props.providerType, props.injectedProviderName);
return (
<div className="flex flex-center">
<div className="mx-auto">
diff --git a/packages/website/ts/containers/portal_onboarding_flow.ts b/packages/website/ts/containers/portal_onboarding_flow.ts
index 3cd4e8510..84739192f 100644
--- a/packages/website/ts/containers/portal_onboarding_flow.ts
+++ b/packages/website/ts/containers/portal_onboarding_flow.ts
@@ -1,7 +1,8 @@
+import { BigNumber } from '@0xproject/utils';
import * as React from 'react';
import { connect } from 'react-redux';
import { Dispatch } from 'redux';
-import { ActionTypes } from 'ts/types';
+import { ActionTypes, ProviderType, TokenByAddress } from 'ts/types';
import { PortalOnboardingFlow as PortalOnboardingFlowComponent } from 'ts/components/onboarding/portal_onboarding_flow';
import { State } from 'ts/redux/reducer';
@@ -11,22 +12,43 @@ interface PortalOnboardingFlowProps {}
interface ConnectedState {
stepIndex: number;
isRunning: boolean;
+ userAddress: string;
+ hasBeenSeen: boolean;
+ providerType: ProviderType;
+ injectedProviderName: string;
+ blockchainIsLoaded: boolean;
+ userEthBalanceInWei: BigNumber;
+ tokenByAddress: TokenByAddress;
}
interface ConnectedDispatch {
- onClose: () => void;
+ updateIsRunning: (isRunning: boolean) => void;
+ updateOnboardingStep: (stepIndex: number) => void;
}
const mapStateToProps = (state: State): ConnectedState => ({
stepIndex: state.portalOnboardingStep,
isRunning: state.isPortalOnboardingShowing,
+ userAddress: state.userAddress,
+ providerType: state.providerType,
+ injectedProviderName: state.injectedProviderName,
+ blockchainIsLoaded: state.blockchainIsLoaded,
+ userEthBalanceInWei: state.userEtherBalanceInWei,
+ tokenByAddress: state.tokenByAddress,
+ hasBeenSeen: state.hasPortalOnboardingBeenSeen,
});
const mapDispatchToProps = (dispatch: Dispatch<State>): ConnectedDispatch => ({
- onClose: (): void => {
+ updateIsRunning: (isRunning: boolean): void => {
dispatch({
type: ActionTypes.UpdatePortalOnboardingShowing,
- data: false,
+ data: isRunning,
+ });
+ },
+ updateOnboardingStep: (stepIndex: number): void => {
+ dispatch({
+ type: ActionTypes.UpdatePortalOnboardingStep,
+ data: stepIndex,
});
},
});
diff --git a/packages/website/ts/index.tsx b/packages/website/ts/index.tsx
index 4fe81a91e..a6bfe7dd2 100644
--- a/packages/website/ts/index.tsx
+++ b/packages/website/ts/index.tsx
@@ -1,12 +1,9 @@
-// Polyfills
import { MuiThemeProvider } from 'material-ui/styles';
import * as React from 'react';
import { render } from 'react-dom';
import { Provider } from 'react-redux';
import { BrowserRouter as Router, Redirect, Route, Switch } from 'react-router-dom';
import * as injectTapEventPlugin from 'react-tap-event-plugin';
-import { createStore, Store as ReduxStore } from 'redux';
-import { devToolsEnhancer } from 'redux-devtools-extension/developmentOnly';
import { Redirecter } from 'ts/components/redirecter';
import { About } from 'ts/containers/about';
import { FAQ } from 'ts/containers/faq';
@@ -16,11 +13,12 @@ import { Wiki } from 'ts/containers/wiki';
import { createLazyComponent } from 'ts/lazy_component';
import { trackedTokenStorage } from 'ts/local_storage/tracked_token_storage';
import { tradeHistoryStorage } from 'ts/local_storage/trade_history_storage';
-import { reducer, State } from 'ts/redux/reducer';
+import { store } from 'ts/redux/store';
import { WebsiteLegacyPaths, WebsitePaths } from 'ts/types';
import { analytics } from 'ts/utils/analytics';
import { muiTheme } from 'ts/utils/mui_theme';
import { utils } from 'ts/utils/utils';
+// Polyfills
import 'whatwg-fetch';
injectTapEventPlugin();
@@ -75,7 +73,7 @@ const LazyOrderUtilsDocumentation = createLazyComponent('Documentation', async (
analytics.init();
// tslint:disable-next-line:no-floating-promises
analytics.logProviderAsync((window as any).web3);
-const store: ReduxStore<State> = createStore(reducer, devToolsEnhancer({ name: '0x Website Redux Store' }));
+
render(
<Router>
<div>
diff --git a/packages/website/ts/local_storage/local_storage.ts b/packages/website/ts/local_storage/local_storage.ts
index 20a533a91..1e3258ce0 100644
--- a/packages/website/ts/local_storage/local_storage.ts
+++ b/packages/website/ts/local_storage/local_storage.ts
@@ -26,6 +26,16 @@ export const localStorage = {
}
window.localStorage.removeItem(key);
},
+ getObject(key: string): object | undefined {
+ const item = localStorage.getItemIfExists(key);
+ if (item) {
+ return JSON.parse(item);
+ }
+ return undefined;
+ },
+ setObject(key: string, value: object): void {
+ localStorage.setItem(key, JSON.stringify(value));
+ },
getAllKeys(): string[] {
if (!this.doesExist) {
return [];
diff --git a/packages/website/ts/local_storage/state_storage.ts b/packages/website/ts/local_storage/state_storage.ts
new file mode 100644
index 000000000..517784b5b
--- /dev/null
+++ b/packages/website/ts/local_storage/state_storage.ts
@@ -0,0 +1,16 @@
+import { localStorage } from 'ts/local_storage/local_storage';
+import { INITIAL_STATE, State } from 'ts/redux/reducer';
+
+const STORAGE_NAME = 'persistedState';
+
+export const stateStorage = {
+ saveState(partialState: Partial<State>): void {
+ localStorage.setObject(STORAGE_NAME, partialState);
+ },
+ getPersistedState(): Partial<State> {
+ return localStorage.getObject(STORAGE_NAME);
+ },
+ getPersistedDefaultState(): State {
+ return { ...INITIAL_STATE, ...stateStorage.getPersistedState() };
+ },
+};
diff --git a/packages/website/ts/redux/reducer.ts b/packages/website/ts/redux/reducer.ts
index e61345c87..5c57792f7 100644
--- a/packages/website/ts/redux/reducer.ts
+++ b/packages/website/ts/redux/reducer.ts
@@ -42,6 +42,7 @@ export interface State {
userEtherBalanceInWei: BigNumber;
portalOnboardingStep: number;
isPortalOnboardingShowing: boolean;
+ hasPortalOnboardingBeenSeen: boolean;
// Note: cache of supplied orderJSON in fill order step. Do not use for anything else.
userSuppliedOrderCache: Order;
@@ -56,7 +57,7 @@ export interface State {
translate: Translate;
}
-const INITIAL_STATE: State = {
+export const INITIAL_STATE: State = {
// Portal
blockchainErr: BlockchainErrs.NoError,
blockchainIsLoaded: false,
@@ -84,6 +85,7 @@ const INITIAL_STATE: State = {
userSuppliedOrderCache: undefined,
portalOnboardingStep: 0,
isPortalOnboardingShowing: false,
+ hasPortalOnboardingBeenSeen: false,
// Docs
docsVersion: DEFAULT_DOCS_VERSION,
availableDocVersions: [DEFAULT_DOCS_VERSION],
@@ -309,6 +311,7 @@ export function reducer(state: State = INITIAL_STATE, action: Action): State {
return {
...state,
isPortalOnboardingShowing,
+ hasPortalOnboardingBeenSeen: true,
};
}
diff --git a/packages/website/ts/redux/store.ts b/packages/website/ts/redux/store.ts
new file mode 100644
index 000000000..203f068a1
--- /dev/null
+++ b/packages/website/ts/redux/store.ts
@@ -0,0 +1,21 @@
+import * as _ from 'lodash';
+import { createStore, Store as ReduxStore } from 'redux';
+import { devToolsEnhancer } from 'redux-devtools-extension/developmentOnly';
+import { stateStorage } from 'ts/local_storage/state_storage';
+import { reducer, State } from 'ts/redux/reducer';
+
+const ONE_SECOND = 1000;
+
+export const store: ReduxStore<State> = createStore(
+ reducer,
+ stateStorage.getPersistedDefaultState(),
+ devToolsEnhancer({ name: '0x Website Redux Store' }),
+);
+store.subscribe(
+ _.throttle(() => {
+ // Persisted state
+ stateStorage.saveState({
+ hasPortalOnboardingBeenSeen: store.getState().hasPortalOnboardingBeenSeen,
+ });
+ }, ONE_SECOND),
+);
diff --git a/packages/website/ts/utils/constants.ts b/packages/website/ts/utils/constants.ts
index f8710b349..9dc1d492c 100644
--- a/packages/website/ts/utils/constants.ts
+++ b/packages/website/ts/utils/constants.ts
@@ -4,6 +4,9 @@ import { BigNumber } from '@0xproject/utils';
export const constants = {
DECIMAL_PLACES_ETH: 18,
DECIMAL_PLACES_ZRX: 18,
+ ETHER_TOKEN_SYMBOL: 'WETH',
+ ZRX_TOKEN_SYMBOL: 'ZRX',
+ ETHER_SYMBOL: 'ETH',
GENESIS_ORDER_BLOCK_BY_NETWORK_ID: {
1: 4145578,
42: 3117574,
diff --git a/packages/website/ts/utils/style.ts b/packages/website/ts/utils/style.ts
index 51b6e4eb6..0411cdd91 100644
--- a/packages/website/ts/utils/style.ts
+++ b/packages/website/ts/utils/style.ts
@@ -1,4 +1,5 @@
export const zIndex = {
topBar: 1100,
- overlay: 1101,
+ overlay: 1105,
+ aboveOverlay: 1106,
};
diff --git a/packages/website/ts/utils/utils.ts b/packages/website/ts/utils/utils.ts
index e79a873e0..b9d962b75 100644
--- a/packages/website/ts/utils/utils.ts
+++ b/packages/website/ts/utils/utils.ts
@@ -11,6 +11,7 @@ import {
Environments,
Order,
Providers,
+ ProviderType,
ScreenWidths,
Side,
SideToAssetToken,
@@ -313,8 +314,16 @@ export const utils = {
isStaging(): boolean {
return _.includes(window.location.href, configs.DOMAIN_STAGING);
},
+ isExternallyInjected(providerType: ProviderType, injectedProviderName: string): boolean {
+ return providerType === ProviderType.Injected && injectedProviderName !== constants.PROVIDER_NAME_PUBLIC;
+ },
isDogfood,
shouldShowPortalV2(): boolean {
return this.isDevelopment() || this.isStaging() || this.isDogfood();
},
+ getEthToken(tokenByAddress: TokenByAddress): Token {
+ const tokens = _.values(tokenByAddress);
+ const etherToken = _.find(tokens, { symbol: constants.ETHER_TOKEN_SYMBOL });
+ return etherToken;
+ },
};