Skip to content

Commit

Permalink
Code423n4 #162, Use enum Mode in Factory
Browse files Browse the repository at this point in the history
  • Loading branch information
Splidge committed Jun 21, 2021
1 parent 98191b7 commit 9655789
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions contracts/RCFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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 /////
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 2 additions & 3 deletions contracts/RCMarket.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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) -
Expand Down
3 changes: 2 additions & 1 deletion contracts/interfaces/IRCMarket.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -13,7 +14,7 @@ interface IRCMarket {
function sponsor(uint256 _amount) external;

function initialize(
uint256 _mode,
Mode _mode,
uint32[] calldata _timestamps,
uint256 _numberOfTokens,
uint256 _totalNftMintCount,
Expand Down

0 comments on commit 9655789

Please sign in to comment.