diff --git a/contracts/ERC20Mixer.sol b/contracts/ERC20Mixer.sol index 92677f1..144c786 100644 --- a/contracts/ERC20Mixer.sol +++ b/contracts/ERC20Mixer.sol @@ -26,12 +26,12 @@ contract ERC20Mixer is Mixer { token = _token; } - function _processDeposit() internal nonReentrant { + function _processDeposit() internal { require(msg.value == 0, "ETH value is supposed to be 0 for ERC20 mixer"); _safeErc20TransferFrom(msg.sender, address(this), denomination); } - function _processWithdraw(address payable _recipient, address payable _relayer, uint256 _fee, uint256 _refund) internal nonReentrant { + function _processWithdraw(address payable _recipient, address payable _relayer, uint256 _fee, uint256 _refund) internal { require(msg.value == _refund, "Incorrect refund amount received by the contract"); _safeErc20Transfer(_recipient, denomination - _fee); diff --git a/contracts/ETHMixer.sol b/contracts/ETHMixer.sol index bc2859b..2996b5e 100644 --- a/contracts/ETHMixer.sol +++ b/contracts/ETHMixer.sol @@ -22,11 +22,11 @@ contract ETHMixer is Mixer { ) Mixer(_verifier, _denomination, _merkleTreeHeight, _operator) public { } - function _processDeposit() internal nonReentrant { + function _processDeposit() internal { require(msg.value == denomination, "Please send `mixDenomination` ETH along with transaction"); } - function _processWithdraw(address payable _recipient, address payable _relayer, uint256 _fee, uint256 _refund) internal nonReentrant { + function _processWithdraw(address payable _recipient, address payable _relayer, uint256 _fee, uint256 _refund) internal { // sanity checks require(msg.value == 0, "Message value is supposed to be zero for ETH mixer"); require(_refund == 0, "Refund value is supposed to be zero for ETH mixer"); diff --git a/contracts/Mixer.sol b/contracts/Mixer.sol index 039de94..a17f827 100644 --- a/contracts/Mixer.sol +++ b/contracts/Mixer.sol @@ -59,7 +59,7 @@ contract Mixer is MerkleTreeWithHistory, ReentrancyGuard { @dev Deposit funds into mixer. The caller must send (for ETH) or approve (for ERC20) value equal to or `denomination` of this mixer. @param _commitment the note commitment, which is PedersenHash(nullifier + secret) */ - function deposit(bytes32 _commitment) external payable { + function deposit(bytes32 _commitment) external payable nonReentrant { require(!commitments[_commitment], "The commitment has been submitted"); uint32 insertedIndex = _insert(_commitment); @@ -80,7 +80,7 @@ contract Mixer is MerkleTreeWithHistory, ReentrancyGuard { - the recipient of funds - optional fee that goes to the transaction sender (usually a relay) */ - function withdraw(bytes calldata _proof, bytes32 _root, bytes32 _nullifierHash, address payable _recipient, address payable _relayer, uint256 _fee, uint256 _refund) external payable { + function withdraw(bytes calldata _proof, bytes32 _root, bytes32 _nullifierHash, address payable _recipient, address payable _relayer, uint256 _fee, uint256 _refund) external payable nonReentrant { require(_fee <= denomination, "Fee exceeds transfer value"); require(!nullifierHashes[_nullifierHash], "The note has been already spent"); require(isKnownRoot(_root), "Cannot find your merkle root"); // Make sure to use a recent one