Skip to content

Commit

Permalink
debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
vincent-merkl committed Feb 5, 2025
1 parent 3e0c326 commit 3db302f
Showing 1 changed file with 7 additions and 21 deletions.
28 changes: 7 additions & 21 deletions contracts/ReferralRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ pragma solidity ^0.8.17;
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import { SafeCast } from "@openzeppelin/contracts/utils/math/SafeCast.sol";
import { ReentrancyGuardUpgradeable } from "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";

import { UUPSHelper } from "./utils/UUPSHelper.sol";
import { IAccessControlManager } from "./interfaces/IAccessControlManager.sol";
Expand All @@ -14,7 +13,7 @@ import { Errors } from "./utils/Errors.sol";
/// @title ReferralRegistry
/// @notice Allows to manage referral programs and claim rewards distributed through Merkl
/// @dev This contract uses UUPS upgradeability pattern and ReentrancyGuard for security
contract ReferralRegistry is UUPSHelper, ReentrancyGuardUpgradeable {
contract ReferralRegistry is UUPSHelper {
using SafeERC20 for IERC20;
struct ReferralProgram {
address owner;
Expand All @@ -25,12 +24,12 @@ contract ReferralRegistry is UUPSHelper, ReentrancyGuardUpgradeable {
}
enum ReferralStatus { NotAllowed, Allowed, Set }

/// @notice Address to receive fees
address public feeRecipient;

/// @notice `AccessControlManager` contract handling access control
IAccessControlManager public accessControlManager;

/// @notice Reentrancy status
uint96 private _status;

/// @notice Whether the contract has been made non upgradeable or not
uint128 public upgradeabilityDeactivated;

Expand Down Expand Up @@ -65,7 +64,7 @@ contract ReferralRegistry is UUPSHelper, ReentrancyGuardUpgradeable {
function addReferralKey(bytes calldata key, uint256 _cost, bool _requiresRefererToBeSet, address _owner, bool _requiresAuthorization, IERC20 _paymentToken) external payable {
require(msg.value == costReferralProgram, "Incorrect ETH amount sent");
if (costReferralProgram > 0) {
payable(accessControlManager.governor()).transfer(msg.value);
payable(feeRecipient).transfer(msg.value);
}
referralKeys.push(key);
require(referralPrograms[key].owner == address(0), "Key already used");
Expand Down Expand Up @@ -179,29 +178,16 @@ contract ReferralRegistry is UUPSHelper, ReentrancyGuardUpgradeable {
_;
}

/// @notice Checks whether a call is reentrant or not
modifier nonReentrant() {
if (_status == 2) revert Errors.ReentrantCall();

// Any calls to nonReentrant after this point will fail
_status = 2;

_;

// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = 1;
}

/*//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
CONSTRUCTOR
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/

constructor() initializer {}
function initialize(IAccessControlManager _accessControlManager, uint256 _costReferralProgram) external initializer {
function initialize(IAccessControlManager _accessControlManager, uint256 _costReferralProgram, address _feeRecipient) external initializer {
if (address(_accessControlManager) == address(0)) revert Errors.ZeroAddress();
accessControlManager = _accessControlManager;
costReferralProgram = _costReferralProgram;
feeRecipient = _feeRecipient;
}

/// @inheritdoc UUPSHelper
Expand Down

0 comments on commit 3db302f

Please sign in to comment.