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 { function _processDeposit() internal {
require(msg.value == 0, "ETH value is supposed to be 0 for ETH mixer"); 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 { function _processWithdraw(address payable _receiver, 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(_receiver, denomination - _fee); _safeErc20Transfer(_receiver, denomination - _fee);
if (_fee > 0) { if (_fee > 0) {
safeErc20Transfer(_relayer, _fee); _safeErc20Transfer(_relayer, _fee);
} }
if (_refund > 0) { if (_refund > 0) {
_receiver.transfer(_refund); _receiver.transfer(_refund);
} }
} }
function safeErc20TransferFrom(address from, address to, uint256 amount) internal { function _safeErc20TransferFrom(address _from, address _to, uint256 _amount) internal {
bool success; bool success;
bytes memory data; bytes memory data;
bytes4 transferFromSelector = 0x23b872dd; bytes4 transferFromSelector = 0x23b872dd;
(success, data) = token.call( (success, data) = token.call(
abi.encodeWithSelector( abi.encodeWithSelector(
transferFromSelector, transferFromSelector,
from, to, amount _from, _to, _amount
) )
); );
require(success, "not enough allowed tokens"); 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; bool success;
bytes memory data; bytes memory data;
bytes4 transferSelector = 0xa9059cbb; bytes4 transferSelector = 0xa9059cbb;
(success, data) = token.call( (success, data) = token.call(
abi.encodeWithSelector( abi.encodeWithSelector(
transferSelector, transferSelector,
to, amount _to, _amount
) )
); );
require(success, "not enough tokens"); require(success, "not enough tokens");

View File

@ -14,7 +14,7 @@ pragma solidity ^0.5.8;
import "./MerkleTreeWithHistory.sol"; import "./MerkleTreeWithHistory.sol";
contract IVerifier { 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 { 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. @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(!isDepositsDisabled, "deposits are disabled");
require(!commitments[commitment], "The commitment has been submitted"); require(!commitments[_commitment], "The commitment has been submitted");
uint256 insertedIndex = _insert(commitment); uint256 insertedIndex = _insert(_commitment);
commitments[commitment] = true; commitments[_commitment] = true;
_processDeposit(); _processDeposit();
emit Deposit(commitment, insertedIndex, block.timestamp); emit Deposit(_commitment, insertedIndex, block.timestamp);
} }
/** @dev this function is defined in a child contract */ /** @dev this function is defined in a child contract */
@ -82,18 +82,18 @@ contract Mixer is MerkleTreeWithHistory {
- the receiver of funds - the receiver 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(uint256[8] memory proof, uint256[6] memory input) public payable { function withdraw(uint256[8] memory _proof, uint256[6] memory _input) public payable {
uint256 root = input[0]; uint256 root = _input[0];
uint256 nullifierHash = input[1]; uint256 nullifierHash = _input[1];
address payable receiver = address(input[2]); address payable receiver = address(_input[2]);
address payable relayer = address(input[3]); address payable relayer = address(_input[3]);
uint256 fee = input[4]; uint256 fee = _input[4];
uint256 refund = input[5]; uint256 refund = _input[5];
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
require(verifier.verifyProof(proof, input), "Invalid withdraw proof"); require(verifier.verifyProof(_proof, _input), "Invalid withdraw proof");
nullifierHashes[nullifierHash] = true; nullifierHashes[nullifierHash] = true;
_processWithdraw(receiver, relayer, fee, refund); _processWithdraw(receiver, relayer, fee, refund);
emit Withdrawal(receiver, nullifierHash, relayer, fee); 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; function _processWithdraw(address payable _receiver, address payable _relayer, uint256 _fee, uint256 _refund) internal;
/** @dev whether a note is already spent */ /** @dev whether a note is already spent */
function isSpent(uint256 nullifierHash) public view returns(bool) { function isSpent(uint256 _nullifierHash) public view returns(bool) {
return nullifierHashes[nullifierHash]; 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. @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. 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."); require(!isVerifierUpdateDisabled, "Verifier updates have been disabled.");
verifier = IVerifier(newVerifier); verifier = IVerifier(_newVerifier);
} }
/** /**