From 9655789a928e038d0fa868d2ed6d8cc7b2a4a0a2 Mon Sep 17 00:00:00 2001 From: Splidge <73956628+Splidge@users.noreply.github.com> Date: Mon, 21 Jun 2021 10:33:27 +0100 Subject: [PATCH] Code423n4 #162, Use enum Mode in Factory --- contracts/RCFactory.sol | 10 +++++----- contracts/RCMarket.sol | 5 ++--- contracts/interfaces/IRCMarket.sol | 3 ++- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/contracts/RCFactory.sol b/contracts/RCFactory.sol index 07e3fea2..d2056899 100644 --- a/contracts/RCFactory.sol +++ b/contracts/RCFactory.sol @@ -33,7 +33,7 @@ contract RCFactory is Ownable, NativeMetaTransaction, IRCFactory { uint256 public referenceContractVersion; /// @dev market addresses, mode // address /// @dev these are not used for anything, just an easy way to get markets - mapping(uint256 => address[]) public marketAddresses; + mapping(IRCMarket.Mode => address[]) public marketAddresses; mapping(address => bool) public mappingOfMarkets; ///// GOVERNANCE VARIABLES- OWNER ///// @@ -96,7 +96,7 @@ contract RCFactory is Ownable, NativeMetaTransaction, IRCFactory { ); event LogMarketCreated2( address contractAddress, - uint32 mode, + IRCMarket.Mode mode, string[] tokenURIs, string ipfsHash, uint32[] timestamps, @@ -146,7 +146,7 @@ contract RCFactory is Ownable, NativeMetaTransaction, IRCFactory { /// @notice Fetch the address of the most recently created market /// @param _mode Filter by market mode, 0=Classic 1=Winner Takes All 2=SafeMode /// @return the address of the most recent market in the given mode - function getMostRecentMarket(uint256 _mode) + function getMostRecentMarket(IRCMarket.Mode _mode) external view returns (address) @@ -157,7 +157,7 @@ contract RCFactory is Ownable, NativeMetaTransaction, IRCFactory { /// @notice Fetch all the market addresses for a given mode /// @param _mode Filter by market mode, 0=Classic 1=Winner Takes All 2=SafeMode /// @return an array of all markets in a given mode - function getAllMarkets(uint256 _mode) + function getAllMarkets(IRCMarket.Mode _mode) external view returns (address[] memory) @@ -468,7 +468,7 @@ contract RCFactory is Ownable, NativeMetaTransaction, IRCFactory { /// @param _sponsorship amount of sponsorship to create the market with /// @return The address of the new market function createMarket( - uint32 _mode, + IRCMarket.Mode _mode, string memory _ipfsHash, uint32[] memory _timestamps, string[] memory _tokenURIs, diff --git a/contracts/RCMarket.sol b/contracts/RCMarket.sol index 371f7172..944c0676 100644 --- a/contracts/RCMarket.sol +++ b/contracts/RCMarket.sol @@ -28,7 +28,6 @@ contract RCMarket is Initializable, NativeMetaTransaction, IRCMarket { uint256 public constant MIN_RENTAL_VALUE = 1 ether; States public override state; /// @dev type of event. - enum Mode {CLASSIC, WINNER_TAKES_ALL, SAFE_MODE} Mode public mode; /// @dev so the Factory can check it's a market bool public constant override isMarket = true; @@ -189,7 +188,7 @@ contract RCMarket is Initializable, NativeMetaTransaction, IRCMarket { /// @param _marketCreatorAddress where to send market creator's cut, if any /// @param _realitioQuestion the question posted to the Oracle function initialize( - uint256 _mode, + Mode _mode, uint32[] memory _timestamps, uint256 _numberOfCards, uint256 _totalNftMintCount, @@ -260,7 +259,7 @@ contract RCMarket is Initializable, NativeMetaTransaction, IRCMarket { } // if winner takes all mode, set winnerCut to max - if (_mode == uint8(Mode.WINNER_TAKES_ALL)) { + if (_mode == Mode.WINNER_TAKES_ALL) { winnerCut = (((uint256(PER_MILLE) - artistCut) - creatorCut) - affiliateCut) - diff --git a/contracts/interfaces/IRCMarket.sol b/contracts/interfaces/IRCMarket.sol index 77a9e8b4..56224ccf 100644 --- a/contracts/interfaces/IRCMarket.sol +++ b/contracts/interfaces/IRCMarket.sol @@ -5,6 +5,7 @@ import "../interfaces/IRealitio.sol"; interface IRCMarket { enum States {CLOSED, OPEN, LOCKED, WITHDRAW} + enum Mode {CLASSIC, WINNER_TAKES_ALL, SAFE_MODE} function isMarket() external view returns (bool); @@ -13,7 +14,7 @@ interface IRCMarket { function sponsor(uint256 _amount) external; function initialize( - uint256 _mode, + Mode _mode, uint32[] calldata _timestamps, uint256 _numberOfTokens, uint256 _totalNftMintCount,