make underscores consistent - in func args and in internal func names

This commit is contained in:
poma 2019-11-02 15:48:22 +03:00
parent 1fdabcc97c
commit e413ccdc29
2 changed files with 29 additions and 29 deletions

View File

@ -28,30 +28,30 @@ contract ERC20Mixer is Mixer {
function _processDeposit() internal {
require(msg.value == 0, "ETH value is supposed to be 0 for ETH mixer");
safeErc20TransferFrom(msg.sender, address(this), denomination);
_safeErc20TransferFrom(msg.sender, address(this), denomination);
}
function _processWithdraw(address payable _receiver, address payable _relayer, uint256 _fee, uint256 _refund) internal {
require(msg.value == _refund, "Incorrect refund amount received by the contract");
safeErc20Transfer(_receiver, denomination - _fee);
_safeErc20Transfer(_receiver, denomination - _fee);
if (_fee > 0) {
safeErc20Transfer(_relayer, _fee);
_safeErc20Transfer(_relayer, _fee);
}
if (_refund > 0) {
_receiver.transfer(_refund);
}
}
function safeErc20TransferFrom(address from, address to, uint256 amount) internal {
function _safeErc20TransferFrom(address _from, address _to, uint256 _amount) internal {
bool success;
bytes memory data;
bytes4 transferFromSelector = 0x23b872dd;
(success, data) = token.call(
abi.encodeWithSelector(
transferFromSelector,
from, to, amount
)
abi.encodeWithSelector(
transferFromSelector,
_from, _to, _amount
)
);
require(success, "not enough allowed tokens");
@ -64,14 +64,14 @@ contract ERC20Mixer is Mixer {
}
}
function safeErc20Transfer(address to, uint256 amount) internal {
function _safeErc20Transfer(address _to, uint256 _amount) internal {
bool success;
bytes memory data;
bytes4 transferSelector = 0xa9059cbb;
(success, data) = token.call(
abi.encodeWithSelector(
transferSelector,
to, amount
_to, _amount
)
);
require(success, "not enough tokens");

View File

@ -14,7 +14,7 @@ pragma solidity ^0.5.8;
import "./MerkleTreeWithHistory.sol";
contract IVerifier {
function verifyProof(uint256[8] memory proof, uint256[6] memory input) public returns(bool);
function verifyProof(uint256[8] memory _proof, uint256[6] memory _input) public returns(bool);
}
contract Mixer is MerkleTreeWithHistory {
@ -59,16 +59,16 @@ contract Mixer is MerkleTreeWithHistory {
/**
@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(uint256 commitment) public payable {
function deposit(uint256 _commitment) public payable {
require(!isDepositsDisabled, "deposits are disabled");
require(!commitments[commitment], "The commitment has been submitted");
uint256 insertedIndex = _insert(commitment);
commitments[commitment] = true;
require(!commitments[_commitment], "The commitment has been submitted");
uint256 insertedIndex = _insert(_commitment);
commitments[_commitment] = true;
_processDeposit();
emit Deposit(commitment, insertedIndex, block.timestamp);
emit Deposit(_commitment, insertedIndex, block.timestamp);
}
/** @dev this function is defined in a child contract */
@ -82,18 +82,18 @@ contract Mixer is MerkleTreeWithHistory {
- the receiver of funds
- optional fee that goes to the transaction sender (usually a relay)
*/
function withdraw(uint256[8] memory proof, uint256[6] memory input) public payable {
uint256 root = input[0];
uint256 nullifierHash = input[1];
address payable receiver = address(input[2]);
address payable relayer = address(input[3]);
uint256 fee = input[4];
uint256 refund = input[5];
function withdraw(uint256[8] memory _proof, uint256[6] memory _input) public payable {
uint256 root = _input[0];
uint256 nullifierHash = _input[1];
address payable receiver = address(_input[2]);
address payable relayer = address(_input[3]);
uint256 fee = _input[4];
uint256 refund = _input[5];
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
require(verifier.verifyProof(proof, input), "Invalid withdraw proof");
require(verifier.verifyProof(_proof, _input), "Invalid withdraw proof");
nullifierHashes[nullifierHash] = true;
_processWithdraw(receiver, relayer, fee, refund);
emit Withdrawal(receiver, nullifierHash, relayer, fee);
@ -103,8 +103,8 @@ contract Mixer is MerkleTreeWithHistory {
function _processWithdraw(address payable _receiver, address payable _relayer, uint256 _fee, uint256 _refund) internal;
/** @dev whether a note is already spent */
function isSpent(uint256 nullifierHash) public view returns(bool) {
return nullifierHashes[nullifierHash];
function isSpent(uint256 _nullifierHash) public view returns(bool) {
return nullifierHashes[_nullifierHash];
}
/**
@ -119,9 +119,9 @@ contract Mixer is MerkleTreeWithHistory {
@dev allow operator to update SNARK verification keys. This is needed to update keys after the final trusted setup ceremony is held.
After that operator is supposed to permanently disable this ability.
*/
function updateVerifier(address newVerifier) external onlyOperator {
function updateVerifier(address _newVerifier) external onlyOperator {
require(!isVerifierUpdateDisabled, "Verifier updates have been disabled.");
verifier = IVerifier(newVerifier);
verifier = IVerifier(_newVerifier);
}
/**