From 460d5f2517cecda2a091a0867515da1b27a65d84 Mon Sep 17 00:00:00 2001 From: Lawrence Forman Date: Tue, 19 Nov 2019 20:08:35 -0500 Subject: [PATCH] `@0x/contracts-utils`: Add `DeploymentConstants`. --- .../contracts/src/DeploymentConstants.sol | 75 +++++++++++++++++++ contracts/utils/package.json | 2 +- contracts/utils/test/artifacts.ts | 2 + contracts/utils/test/wrappers.ts | 1 + contracts/utils/tsconfig.json | 1 + 5 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 contracts/utils/contracts/src/DeploymentConstants.sol diff --git a/contracts/utils/contracts/src/DeploymentConstants.sol b/contracts/utils/contracts/src/DeploymentConstants.sol new file mode 100644 index 0000000000..d218b80eae --- /dev/null +++ b/contracts/utils/contracts/src/DeploymentConstants.sol @@ -0,0 +1,75 @@ +/* + + Copyright 2019 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.5.9; + +import "./interfaces/IOwnable.sol"; +import "./LibOwnableRichErrors.sol"; +import "./LibRichErrors.sol"; + + +contract DeploymentConstants { + /// @dev Mainnet address of the WETH contract. + address constant private WETH_ADDRESS = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; + /// @dev Mainnet address of the KyberNeworkProxy contract. + address constant private KYBER_NETWORK_PROXY_ADDRESS = 0x818E6FECD516Ecc3849DAf6845e3EC868087B755; + /// @dev Mainnet address of the `UniswapExchangeFactory` contract. + address constant private UNISWAP_EXCHANGE_FACTORY_ADDRESS = 0xc0a47dFe034B400B47bDaD5FecDa2621de6c4d95; + /// @dev Mainnet address of the Eth2Dai `MatchingMarket` contract. + address constant private ETH2DAI_ADDRESS = 0x39755357759cE0d7f32dC8dC45414CCa409AE24e; + + /// @dev Overridable way to get the `KyberNetworkProxy` address. + /// @return kyberAddress The `IKyberNetworkProxy` address. + function _getKyberNetworkProxyAddress() + internal + view + returns (address kyberAddress) + { + return KYBER_NETWORK_PROXY_ADDRESS; + } + + /// @dev Overridable way to get the WETH address. + /// @return wethAddress The WETH address. + function _getWETHAddress() + internal + view + returns (address wethAddress) + { + return WETH_ADDRESS; + } + + /// @dev Overridable way to get the `UniswapExchangeFactory` address. + /// @return uniswapAddress The `UniswapExchangeFactory` address. + function _getUniswapExchangeFactoryAddress() + internal + view + returns (address uniswapAddress) + { + return UNISWAP_EXCHANGE_FACTORY_ADDRESS; + } + + /// @dev An overridable way to retrieve the Eth2Dai `MatchingMarket` contract. + /// @return eth2daiAddress The Eth2Dai `MatchingMarket` contract. + function _getEth2DaiAddress() + internal + view + returns (address eth2daiAddress) + { + return ETH2DAI_ADDRESS; + } +} diff --git a/contracts/utils/package.json b/contracts/utils/package.json index f08edae30a..94678d37ab 100644 --- a/contracts/utils/package.json +++ b/contracts/utils/package.json @@ -38,7 +38,7 @@ "config": { "publicInterfaceContracts": "Authorizable,IAuthorizable,IOwnable,LibAddress,LibAddressArray,LibAddressArrayRichErrors,LibAuthorizableRichErrors,LibBytes,LibBytesRichErrors,LibEIP1271,LibEIP712,LibFractions,LibOwnableRichErrors,LibReentrancyGuardRichErrors,LibRichErrors,LibSafeMath,LibSafeMathRichErrors,Ownable,ReentrancyGuard,Refundable", "abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually.", - "abis": "./test/generated-artifacts/@(Authorizable|IAuthorizable|IOwnable|LibAddress|LibAddressArray|LibAddressArrayRichErrors|LibAuthorizableRichErrors|LibBytes|LibBytesRichErrors|LibEIP1271|LibEIP712|LibFractions|LibOwnableRichErrors|LibReentrancyGuardRichErrors|LibRichErrors|LibSafeMath|LibSafeMathRichErrors|Ownable|ReentrancyGuard|Refundable|TestLibAddress|TestLibAddressArray|TestLibBytes|TestLibEIP712|TestLibRichErrors|TestLibSafeMath|TestLogDecoding|TestLogDecodingDownstream|TestOwnable|TestReentrancyGuard|TestRefundable|TestRefundableReceiver).json" + "abis": "./test/generated-artifacts/@(Authorizable|DeploymentConstants|IAuthorizable|IOwnable|LibAddress|LibAddressArray|LibAddressArrayRichErrors|LibAuthorizableRichErrors|LibBytes|LibBytesRichErrors|LibEIP1271|LibEIP712|LibFractions|LibOwnableRichErrors|LibReentrancyGuardRichErrors|LibRichErrors|LibSafeMath|LibSafeMathRichErrors|Ownable|ReentrancyGuard|Refundable|TestLibAddress|TestLibAddressArray|TestLibBytes|TestLibEIP712|TestLibRichErrors|TestLibSafeMath|TestLogDecoding|TestLogDecodingDownstream|TestOwnable|TestReentrancyGuard|TestRefundable|TestRefundableReceiver).json" }, "repository": { "type": "git", diff --git a/contracts/utils/test/artifacts.ts b/contracts/utils/test/artifacts.ts index 724fb646f9..740accd100 100644 --- a/contracts/utils/test/artifacts.ts +++ b/contracts/utils/test/artifacts.ts @@ -6,6 +6,7 @@ import { ContractArtifact } from 'ethereum-types'; import * as Authorizable from '../test/generated-artifacts/Authorizable.json'; +import * as DeploymentConstants from '../test/generated-artifacts/DeploymentConstants.json'; import * as IAuthorizable from '../test/generated-artifacts/IAuthorizable.json'; import * as IOwnable from '../test/generated-artifacts/IOwnable.json'; import * as LibAddress from '../test/generated-artifacts/LibAddress.json'; @@ -39,6 +40,7 @@ import * as TestRefundable from '../test/generated-artifacts/TestRefundable.json import * as TestRefundableReceiver from '../test/generated-artifacts/TestRefundableReceiver.json'; export const artifacts = { Authorizable: Authorizable as ContractArtifact, + DeploymentConstants: DeploymentConstants as ContractArtifact, LibAddress: LibAddress as ContractArtifact, LibAddressArray: LibAddressArray as ContractArtifact, LibAddressArrayRichErrors: LibAddressArrayRichErrors as ContractArtifact, diff --git a/contracts/utils/test/wrappers.ts b/contracts/utils/test/wrappers.ts index a0397108f0..fa6efefa66 100644 --- a/contracts/utils/test/wrappers.ts +++ b/contracts/utils/test/wrappers.ts @@ -4,6 +4,7 @@ * ----------------------------------------------------------------------------- */ export * from '../test/generated-wrappers/authorizable'; +export * from '../test/generated-wrappers/deployment_constants'; export * from '../test/generated-wrappers/i_authorizable'; export * from '../test/generated-wrappers/i_ownable'; export * from '../test/generated-wrappers/lib_address'; diff --git a/contracts/utils/tsconfig.json b/contracts/utils/tsconfig.json index 5f15b82479..fd68dbba9e 100644 --- a/contracts/utils/tsconfig.json +++ b/contracts/utils/tsconfig.json @@ -24,6 +24,7 @@ "generated-artifacts/ReentrancyGuard.json", "generated-artifacts/Refundable.json", "test/generated-artifacts/Authorizable.json", + "test/generated-artifacts/DeploymentConstants.json", "test/generated-artifacts/IAuthorizable.json", "test/generated-artifacts/IOwnable.json", "test/generated-artifacts/LibAddress.json",