Make deployment constants private and use string reverts for constructor assertions

This commit is contained in:
Amir Bandeali 2019-09-24 13:36:08 -07:00
parent 6d7bf12ade
commit b8b21cefe3
2 changed files with 29 additions and 27 deletions

View File

@ -35,40 +35,48 @@ contract MixinDeploymentConstants {
// @TODO SET THESE VALUES FOR DEPLOYMENT // @TODO SET THESE VALUES FOR DEPLOYMENT
// Mainnet WETH9 Address // Mainnet WETH9 Address
address constant internal WETH_ADDRESS = address(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2); address constant private WETH_ADDRESS = address(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);
// Kovan WETH9 Address // Kovan WETH9 Address
// address constant internal WETH_ADDRESS = address(0xd0a1e359811322d97991e03f863a0c30c2cf029c); // address constant private WETH_ADDRESS = address(0xd0a1e359811322d97991e03f863a0c30c2cf029c);
// Ropsten & Rinkeby WETH9 Address // Ropsten & Rinkeby WETH9 Address
// address constant internal WETH_ADDRESS = address(0xc778417e063141139fce010982780140aa0cd5ab); // address constant private WETH_ADDRESS = address(0xc778417e063141139fce010982780140aa0cd5ab);
// Mainnet Weth Asset Data // Mainnet Weth Asset Data
bytes constant internal WETH_ASSET_DATA = hex"f47261b0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"; bytes constant private WETH_ASSET_DATA = hex"f47261b0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2";
// Kovan Weth Asset Data // Kovan Weth Asset Data
// bytes constant internal WETH_ASSET_DATA = hex"f47261b0000000000000000000000000d0a1e359811322d97991e03f863a0c30c2cf029c"; // bytes constant private WETH_ASSET_DATA = hex"f47261b0000000000000000000000000d0a1e359811322d97991e03f863a0c30c2cf029c";
// Ropsten & Rinkeby Weth Asset Data // Ropsten & Rinkeby Weth Asset Data
// bytes constant internal WETH_ASSET_DATA = hex"f47261b0000000000000000000000000c778417e063141139fce010982780140aa0cd5ab"; // bytes constant private WETH_ASSET_DATA = hex"f47261b0000000000000000000000000c778417e063141139fce010982780140aa0cd5ab";
// @TODO SET THESE VALUES FOR DEPLOYMENT // @TODO SET THESE VALUES FOR DEPLOYMENT
address constant public WETH_ASSET_PROXY_ADDRESS = address(1); address constant private WETH_ASSET_PROXY_ADDRESS = address(1);
address constant public ZRX_VAULT_ADDRESS = address(1); address constant private ZRX_VAULT_ADDRESS = address(1);
/// @dev Ensures that the WETH_ASSET_DATA is correct. /// @dev Ensures that the WETH_ASSET_DATA is correct.
constructor() constructor()
public public
{ {
// Ensure that the WETH_ASSET_DATA is correct. require(
if (!WETH_ASSET_DATA.equals( WETH_ASSET_DATA.equals(abi.encodeWithSelector(
abi.encodeWithSelector(
IAssetData(address(0)).ERC20Token.selector, IAssetData(address(0)).ERC20Token.selector,
WETH_ADDRESS WETH_ADDRESS
) )),
)) { "INVALID_WETH_ASSET_DATA"
LibRichErrors.rrevert(LibStakingRichErrors.InvalidWethAssetDataError()); );
}
require(
WETH_ASSET_PROXY_ADDRESS != address(0),
"WETH_ASSET_PROXY_MUST_BE_SET"
);
require(
ZRX_VAULT_ADDRESS != address(0),
"ZRX_VAULT_MUST_BE_SET"
);
} }
/// @dev An overridable way to access the deployed WETH contract. /// @dev An overridable way to access the deployed WETH contract.
@ -95,6 +103,9 @@ contract MixinDeploymentConstants {
return wethAssetData; return wethAssetData;
} }
/// @dev An overridable way to access the deployed WETH assetProxy.
/// Must be view to allow overrides to access state.
/// @return wethAssetProxy The assetProxy used to transfer WETH.
function _getWethAssetProxy() function _getWethAssetProxy()
internal internal
view view
@ -104,6 +115,9 @@ contract MixinDeploymentConstants {
return wethAssetProxy; return wethAssetProxy;
} }
/// @dev An overridable way to access the deployed zrxVault.
/// Must be view to allow overrides to access state.
/// @return zrxVault The zrxVault contract.
function _getZrxVault() function _getZrxVault()
internal internal
view view

View File

@ -133,10 +133,6 @@ library LibStakingRichErrors {
bytes4 internal constant INVALID_PROTOCOL_FEE_PAYMENT_ERROR_SELECTOR = bytes4 internal constant INVALID_PROTOCOL_FEE_PAYMENT_ERROR_SELECTOR =
0xefd6cb33; 0xefd6cb33;
// bytes4(keccak256("InvalidWethAssetDataError()"))
bytes internal constant INVALID_WETH_ASSET_DATA_ERROR =
hex"24bf322c";
// bytes4(keccak256("PreviousEpochNotFinalizedError(uint256,uint256)")) // bytes4(keccak256("PreviousEpochNotFinalizedError(uint256,uint256)"))
bytes4 internal constant PREVIOUS_EPOCH_NOT_FINALIZED_ERROR_SELECTOR = bytes4 internal constant PREVIOUS_EPOCH_NOT_FINALIZED_ERROR_SELECTOR =
0x614b800a; 0x614b800a;
@ -407,14 +403,6 @@ library LibStakingRichErrors {
return PROXY_DESTINATION_CANNOT_BE_NIL_ERROR; return PROXY_DESTINATION_CANNOT_BE_NIL_ERROR;
} }
function InvalidWethAssetDataError()
internal
pure
returns (bytes memory)
{
return INVALID_WETH_ASSET_DATA_ERROR;
}
function PreviousEpochNotFinalizedError( function PreviousEpochNotFinalizedError(
uint256 unfinalizedEpoch, uint256 unfinalizedEpoch,
uint256 unfinalizedPoolsRemaining uint256 unfinalizedPoolsRemaining