mirror of
https://github.com/tornadocash/tornado-core.git
synced 2024-11-22 17:50:19 +01:00
move nonReentrant modifier
This commit is contained in:
parent
0393ee9c05
commit
a6519fb280
@ -26,12 +26,12 @@ contract ERC20Mixer is Mixer {
|
|||||||
token = _token;
|
token = _token;
|
||||||
}
|
}
|
||||||
|
|
||||||
function _processDeposit() internal nonReentrant {
|
function _processDeposit() internal {
|
||||||
require(msg.value == 0, "ETH value is supposed to be 0 for ERC20 mixer");
|
require(msg.value == 0, "ETH value is supposed to be 0 for ERC20 mixer");
|
||||||
_safeErc20TransferFrom(msg.sender, address(this), denomination);
|
_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");
|
require(msg.value == _refund, "Incorrect refund amount received by the contract");
|
||||||
|
|
||||||
_safeErc20Transfer(_recipient, denomination - _fee);
|
_safeErc20Transfer(_recipient, denomination - _fee);
|
||||||
|
@ -22,11 +22,11 @@ contract ETHMixer is Mixer {
|
|||||||
) Mixer(_verifier, _denomination, _merkleTreeHeight, _operator) public {
|
) Mixer(_verifier, _denomination, _merkleTreeHeight, _operator) public {
|
||||||
}
|
}
|
||||||
|
|
||||||
function _processDeposit() internal nonReentrant {
|
function _processDeposit() internal {
|
||||||
require(msg.value == denomination, "Please send `mixDenomination` ETH along with transaction");
|
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
|
// sanity checks
|
||||||
require(msg.value == 0, "Message value is supposed to be zero for ETH mixer");
|
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");
|
require(_refund == 0, "Refund value is supposed to be zero for ETH mixer");
|
||||||
|
@ -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.
|
@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)
|
@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");
|
require(!commitments[_commitment], "The commitment has been submitted");
|
||||||
|
|
||||||
uint32 insertedIndex = _insert(_commitment);
|
uint32 insertedIndex = _insert(_commitment);
|
||||||
@ -80,7 +80,7 @@ contract Mixer is MerkleTreeWithHistory, ReentrancyGuard {
|
|||||||
- the recipient of funds
|
- the recipient of funds
|
||||||
- optional fee that goes to the transaction sender (usually a relay)
|
- 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(_fee <= denomination, "Fee exceeds transfer value");
|
||||||
require(!nullifierHashes[_nullifierHash], "The note has been already spent");
|
require(!nullifierHashes[_nullifierHash], "The note has been already spent");
|
||||||
require(isKnownRoot(_root), "Cannot find your merkle root"); // Make sure to use a recent one
|
require(isKnownRoot(_root), "Cannot find your merkle root"); // Make sure to use a recent one
|
||||||
|
Loading…
Reference in New Issue
Block a user