Improve parameters naming and remove unecessary returns (#2891)

pull/2834/head^2
Hadrien Croubois 3 years ago committed by GitHub
parent 29eeb2828e
commit e2fa301bfb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 52
      contracts/token/ERC1155/ERC1155.sol
  2. 4
      contracts/token/ERC20/extensions/ERC20Votes.sol

@ -249,32 +249,32 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI {
} }
/** /**
* @dev Creates `amount` tokens of token type `id`, and assigns them to `account`. * @dev Creates `amount` tokens of token type `id`, and assigns them to `to`.
* *
* Emits a {TransferSingle} event. * Emits a {TransferSingle} event.
* *
* Requirements: * Requirements:
* *
* - `account` cannot be the zero address. * - `to` cannot be the zero address.
* - If `account` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value. * acceptance magic value.
*/ */
function _mint( function _mint(
address account, address to,
uint256 id, uint256 id,
uint256 amount, uint256 amount,
bytes memory data bytes memory data
) internal virtual { ) internal virtual {
require(account != address(0), "ERC1155: mint to the zero address"); require(to != address(0), "ERC1155: mint to the zero address");
address operator = _msgSender(); address operator = _msgSender();
_beforeTokenTransfer(operator, address(0), account, _asSingletonArray(id), _asSingletonArray(amount), data); _beforeTokenTransfer(operator, address(0), to, _asSingletonArray(id), _asSingletonArray(amount), data);
_balances[id][account] += amount; _balances[id][to] += amount;
emit TransferSingle(operator, address(0), account, id, amount); emit TransferSingle(operator, address(0), to, id, amount);
_doSafeTransferAcceptanceCheck(operator, address(0), account, id, amount, data); _doSafeTransferAcceptanceCheck(operator, address(0), to, id, amount, data);
} }
/** /**
@ -309,31 +309,31 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI {
} }
/** /**
* @dev Destroys `amount` tokens of token type `id` from `account` * @dev Destroys `amount` tokens of token type `id` from `from`
* *
* Requirements: * Requirements:
* *
* - `account` cannot be the zero address. * - `from` cannot be the zero address.
* - `account` must have at least `amount` tokens of token type `id`. * - `from` must have at least `amount` tokens of token type `id`.
*/ */
function _burn( function _burn(
address account, address from,
uint256 id, uint256 id,
uint256 amount uint256 amount
) internal virtual { ) internal virtual {
require(account != address(0), "ERC1155: burn from the zero address"); require(from != address(0), "ERC1155: burn from the zero address");
address operator = _msgSender(); address operator = _msgSender();
_beforeTokenTransfer(operator, account, address(0), _asSingletonArray(id), _asSingletonArray(amount), ""); _beforeTokenTransfer(operator, from, address(0), _asSingletonArray(id), _asSingletonArray(amount), "");
uint256 accountBalance = _balances[id][account]; uint256 fromBalance = _balances[id][from];
require(accountBalance >= amount, "ERC1155: burn amount exceeds balance"); require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
unchecked { unchecked {
_balances[id][account] = accountBalance - amount; _balances[id][from] = fromBalance - amount;
} }
emit TransferSingle(operator, account, address(0), id, amount); emit TransferSingle(operator, from, address(0), id, amount);
} }
/** /**
@ -344,29 +344,29 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI {
* - `ids` and `amounts` must have the same length. * - `ids` and `amounts` must have the same length.
*/ */
function _burnBatch( function _burnBatch(
address account, address from,
uint256[] memory ids, uint256[] memory ids,
uint256[] memory amounts uint256[] memory amounts
) internal virtual { ) internal virtual {
require(account != address(0), "ERC1155: burn from the zero address"); require(from != address(0), "ERC1155: burn from the zero address");
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
address operator = _msgSender(); address operator = _msgSender();
_beforeTokenTransfer(operator, account, address(0), ids, amounts, ""); _beforeTokenTransfer(operator, from, address(0), ids, amounts, "");
for (uint256 i = 0; i < ids.length; i++) { for (uint256 i = 0; i < ids.length; i++) {
uint256 id = ids[i]; uint256 id = ids[i];
uint256 amount = amounts[i]; uint256 amount = amounts[i];
uint256 accountBalance = _balances[id][account]; uint256 fromBalance = _balances[id][from];
require(accountBalance >= amount, "ERC1155: burn amount exceeds balance"); require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
unchecked { unchecked {
_balances[id][account] = accountBalance - amount; _balances[id][from] = fromBalance - amount;
} }
} }
emit TransferBatch(operator, account, address(0), ids, amounts); emit TransferBatch(operator, from, address(0), ids, amounts);
} }
/** /**

@ -134,7 +134,7 @@ abstract contract ERC20Votes is ERC20Permit {
* @dev Delegate votes from the sender to `delegatee`. * @dev Delegate votes from the sender to `delegatee`.
*/ */
function delegate(address delegatee) public virtual { function delegate(address delegatee) public virtual {
return _delegate(_msgSender(), delegatee); _delegate(_msgSender(), delegatee);
} }
/** /**
@ -156,7 +156,7 @@ abstract contract ERC20Votes is ERC20Permit {
s s
); );
require(nonce == _useNonce(signer), "ERC20Votes: invalid nonce"); require(nonce == _useNonce(signer), "ERC20Votes: invalid nonce");
return _delegate(signer, delegatee); _delegate(signer, delegatee);
} }
/** /**

Loading…
Cancel
Save