move nonReentrant modifier

This commit is contained in:
Alexey 2019-11-14 20:49:34 +03:00
parent 0393ee9c05
commit a6519fb280
3 changed files with 6 additions and 6 deletions

View File

@ -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);

View File

@ -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");

View File

@ -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