From 3a66f1f8ab388f506c8a7a3662336fa61f52c7b2 Mon Sep 17 00:00:00 2001 From: JulissaDantes Date: Thu, 1 Dec 2022 15:20:01 -0400 Subject: [PATCH 01/25] update _safeTransferFrom --- contracts/token/ERC1155/ERC1155.sol | 65 +++++++++-------------------- 1 file changed, 19 insertions(+), 46 deletions(-) diff --git a/contracts/token/ERC1155/ERC1155.sol b/contracts/token/ERC1155/ERC1155.sol index 237e8ba9469..747a93537e0 100644 --- a/contracts/token/ERC1155/ERC1155.sol +++ b/contracts/token/ERC1155/ERC1155.sol @@ -164,26 +164,28 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { uint256 amount, bytes memory data ) internal virtual { - require(to != address(0), "ERC1155: transfer to the zero address"); - address operator = _msgSender(); - uint256[] memory ids = _asSingletonArray(id); - uint256[] memory amounts = _asSingletonArray(amount); - - _beforeTokenTransfer(operator, from, to, ids, amounts, data); - uint256 fromBalance = _balances[id][from]; - require(fromBalance >= amount, "ERC1155: insufficient balance for transfer"); - unchecked { - _balances[id][from] = fromBalance - amount; + if (to == address(0)) { + require(from != address(0), "ERC1155: burn from the zero address"); + require(fromBalance >= amount, "ERC1155: burn amount exceeds balance"); + } else if (to == address(0)) { + require(to != address(0), "ERC1155: mint to the zero address"); + } else { + require(fromBalance >= amount, "ERC1155: insufficient balance for transfer"); } - _balances[id][to] += amount; - - emit TransferSingle(operator, from, to, id, amount); - _afterTokenTransfer(operator, from, to, ids, amounts, data); + if (from != address(0)) { + unchecked { + _balances[id][from] -= amount; + } + } + if (to != address(0)) { + _balances[id][to] += amount; + _doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data); + } - _doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data); + emit TransferSingle(operator, from, to, id, amount); } /** @@ -269,20 +271,7 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { uint256 amount, bytes memory data ) internal virtual { - require(to != address(0), "ERC1155: mint to the zero address"); - - address operator = _msgSender(); - uint256[] memory ids = _asSingletonArray(id); - uint256[] memory amounts = _asSingletonArray(amount); - - _beforeTokenTransfer(operator, address(0), to, ids, amounts, data); - - _balances[id][to] += amount; - emit TransferSingle(operator, address(0), to, id, amount); - - _afterTokenTransfer(operator, address(0), to, ids, amounts, data); - - _doSafeTransferAcceptanceCheck(operator, address(0), to, id, amount, data); + _safeTransferFrom(address(0), to, id, amount, data); } /** @@ -335,23 +324,7 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { uint256 id, uint256 amount ) internal virtual { - require(from != address(0), "ERC1155: burn from the zero address"); - - address operator = _msgSender(); - uint256[] memory ids = _asSingletonArray(id); - uint256[] memory amounts = _asSingletonArray(amount); - - _beforeTokenTransfer(operator, from, address(0), ids, amounts, ""); - - uint256 fromBalance = _balances[id][from]; - require(fromBalance >= amount, "ERC1155: burn amount exceeds balance"); - unchecked { - _balances[id][from] = fromBalance - amount; - } - - emit TransferSingle(operator, from, address(0), id, amount); - - _afterTokenTransfer(operator, from, address(0), ids, amounts, ""); + _safeTransferFrom(from, address(0), id, amount, ""); } /** From 7a695136b1571a247dacc06d3f5c9a3ef6a77644 Mon Sep 17 00:00:00 2001 From: JulissaDantes Date: Thu, 1 Dec 2022 15:31:36 -0400 Subject: [PATCH 02/25] update tests --- contracts/token/ERC1155/ERC1155.sol | 3 ++- test/token/ERC1155/ERC1155.behavior.js | 14 -------------- test/token/ERC1155/ERC1155.test.js | 4 ++-- 3 files changed, 4 insertions(+), 17 deletions(-) diff --git a/contracts/token/ERC1155/ERC1155.sol b/contracts/token/ERC1155/ERC1155.sol index 747a93537e0..398a3c1ae2a 100644 --- a/contracts/token/ERC1155/ERC1155.sol +++ b/contracts/token/ERC1155/ERC1155.sol @@ -166,10 +166,11 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { ) internal virtual { address operator = _msgSender(); uint256 fromBalance = _balances[id][from]; + require(from != address(0) || to != address(0), "ERC1155: invalid transfer operation"); if (to == address(0)) { require(from != address(0), "ERC1155: burn from the zero address"); require(fromBalance >= amount, "ERC1155: burn amount exceeds balance"); - } else if (to == address(0)) { + } else if (from == address(0)) { require(to != address(0), "ERC1155: mint to the zero address"); } else { require(fromBalance >= amount, "ERC1155: insufficient balance for transfer"); diff --git a/test/token/ERC1155/ERC1155.behavior.js b/test/token/ERC1155/ERC1155.behavior.js index 62ba6667721..5714cab26a0 100644 --- a/test/token/ERC1155/ERC1155.behavior.js +++ b/test/token/ERC1155/ERC1155.behavior.js @@ -221,20 +221,6 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder, ); }); - it('reverts when transferring to zero address', async function () { - await expectRevert( - this.token.safeTransferFrom( - multiTokenHolder, - ZERO_ADDRESS, - firstTokenId, - firstAmount, - '0x', - { from: multiTokenHolder }, - ), - 'ERC1155: transfer to the zero address', - ); - }); - function transferWasSuccessful ({ operator, from, id, value }) { it('debits transferred balance from sender', async function () { const newBalance = await this.token.balanceOf(from, id); diff --git a/test/token/ERC1155/ERC1155.test.js b/test/token/ERC1155/ERC1155.test.js index a0a8cf3ff89..48891deb805 100644 --- a/test/token/ERC1155/ERC1155.test.js +++ b/test/token/ERC1155/ERC1155.test.js @@ -32,7 +32,7 @@ contract('ERC1155', function (accounts) { it('reverts with a zero destination address', async function () { await expectRevert( this.token.mint(ZERO_ADDRESS, tokenId, mintAmount, data), - 'ERC1155: mint to the zero address', + 'ERC1155: invalid transfer operation', ); }); @@ -113,7 +113,7 @@ contract('ERC1155', function (accounts) { it('reverts when burning the zero account\'s tokens', async function () { await expectRevert( this.token.burn(ZERO_ADDRESS, tokenId, mintAmount), - 'ERC1155: burn from the zero address', + 'ERC1155: invalid transfer operation', ); }); From 422224e84c70ec9e70b4035237d1e5645bbef9e1 Mon Sep 17 00:00:00 2001 From: JulissaDantes Date: Thu, 1 Dec 2022 15:34:00 -0400 Subject: [PATCH 03/25] Remove hooks --- contracts/token/ERC1155/ERC1155.sol | 70 ----------------------------- 1 file changed, 70 deletions(-) diff --git a/contracts/token/ERC1155/ERC1155.sol b/contracts/token/ERC1155/ERC1155.sol index 398a3c1ae2a..40fba912146 100644 --- a/contracts/token/ERC1155/ERC1155.sol +++ b/contracts/token/ERC1155/ERC1155.sol @@ -211,8 +211,6 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { address operator = _msgSender(); - _beforeTokenTransfer(operator, from, to, ids, amounts, data); - for (uint256 i = 0; i < ids.length; ++i) { uint256 id = ids[i]; uint256 amount = amounts[i]; @@ -227,8 +225,6 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { emit TransferBatch(operator, from, to, ids, amounts); - _afterTokenTransfer(operator, from, to, ids, amounts, data); - _doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data); } @@ -297,16 +293,12 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { address operator = _msgSender(); - _beforeTokenTransfer(operator, address(0), to, ids, amounts, data); - for (uint256 i = 0; i < ids.length; i++) { _balances[ids[i]][to] += amounts[i]; } emit TransferBatch(operator, address(0), to, ids, amounts); - _afterTokenTransfer(operator, address(0), to, ids, amounts, data); - _doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data); } @@ -347,8 +339,6 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { address operator = _msgSender(); - _beforeTokenTransfer(operator, from, address(0), ids, amounts, ""); - for (uint256 i = 0; i < ids.length; i++) { uint256 id = ids[i]; uint256 amount = amounts[i]; @@ -361,8 +351,6 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { } emit TransferBatch(operator, from, address(0), ids, amounts); - - _afterTokenTransfer(operator, from, address(0), ids, amounts, ""); } /** @@ -380,64 +368,6 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { emit ApprovalForAll(owner, operator, approved); } - /** - * @dev Hook that is called before any token transfer. This includes minting - * and burning, as well as batched variants. - * - * The same hook is called on both single and batched variants. For single - * transfers, the length of the `ids` and `amounts` arrays will be 1. - * - * Calling conditions (for each `id` and `amount` pair): - * - * - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens - * of token type `id` will be transferred to `to`. - * - When `from` is zero, `amount` tokens of token type `id` will be minted - * for `to`. - * - when `to` is zero, `amount` of ``from``'s tokens of token type `id` - * will be burned. - * - `from` and `to` are never both zero. - * - `ids` and `amounts` have the same, non-zero length. - * - * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. - */ - function _beforeTokenTransfer( - address operator, - address from, - address to, - uint256[] memory ids, - uint256[] memory amounts, - bytes memory data - ) internal virtual {} - - /** - * @dev Hook that is called after any token transfer. This includes minting - * and burning, as well as batched variants. - * - * The same hook is called on both single and batched variants. For single - * transfers, the length of the `id` and `amount` arrays will be 1. - * - * Calling conditions (for each `id` and `amount` pair): - * - * - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens - * of token type `id` will be transferred to `to`. - * - When `from` is zero, `amount` tokens of token type `id` will be minted - * for `to`. - * - when `to` is zero, `amount` of ``from``'s tokens of token type `id` - * will be burned. - * - `from` and `to` are never both zero. - * - `ids` and `amounts` have the same, non-zero length. - * - * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. - */ - function _afterTokenTransfer( - address operator, - address from, - address to, - uint256[] memory ids, - uint256[] memory amounts, - bytes memory data - ) internal virtual {} - function _doSafeTransferAcceptanceCheck( address operator, address from, From e5057792f118c05e00028112dd7acd1dc3c14e35 Mon Sep 17 00:00:00 2001 From: JulissaDantes Date: Mon, 5 Dec 2022 08:34:54 -0400 Subject: [PATCH 04/25] update extensions --- contracts/mocks/ERC1155PausableMock.sol | 11 ---- contracts/mocks/ERC1155SupplyMock.sol | 11 ---- contracts/token/ERC1155/ERC1155.sol | 57 ++++++------------- .../ERC1155/extensions/ERC1155Pausable.sol | 7 +-- .../ERC1155/extensions/ERC1155Supply.sol | 7 +-- test/token/ERC1155/ERC1155.behavior.js | 2 +- test/token/ERC1155/ERC1155.test.js | 4 +- 7 files changed, 27 insertions(+), 72 deletions(-) diff --git a/contracts/mocks/ERC1155PausableMock.sol b/contracts/mocks/ERC1155PausableMock.sol index cd068234fb5..9c11ec55f3b 100644 --- a/contracts/mocks/ERC1155PausableMock.sol +++ b/contracts/mocks/ERC1155PausableMock.sol @@ -15,15 +15,4 @@ contract ERC1155PausableMock is ERC1155Mock, ERC1155Pausable { function unpause() external { _unpause(); } - - function _beforeTokenTransfer( - address operator, - address from, - address to, - uint256[] memory ids, - uint256[] memory amounts, - bytes memory data - ) internal override(ERC1155, ERC1155Pausable) { - super._beforeTokenTransfer(operator, from, to, ids, amounts, data); - } } diff --git a/contracts/mocks/ERC1155SupplyMock.sol b/contracts/mocks/ERC1155SupplyMock.sol index 9c0cd7b63cb..d7b3ee70bfa 100644 --- a/contracts/mocks/ERC1155SupplyMock.sol +++ b/contracts/mocks/ERC1155SupplyMock.sol @@ -7,15 +7,4 @@ import "../token/ERC1155/extensions/ERC1155Supply.sol"; contract ERC1155SupplyMock is ERC1155Mock, ERC1155Supply { constructor(string memory uri) ERC1155Mock(uri) {} - - function _beforeTokenTransfer( - address operator, - address from, - address to, - uint256[] memory ids, - uint256[] memory amounts, - bytes memory data - ) internal override(ERC1155, ERC1155Supply) { - super._beforeTokenTransfer(operator, from, to, ids, amounts, data); - } } diff --git a/contracts/token/ERC1155/ERC1155.sol b/contracts/token/ERC1155/ERC1155.sol index 40fba912146..afc0b39dd78 100644 --- a/contracts/token/ERC1155/ERC1155.sol +++ b/contracts/token/ERC1155/ERC1155.sol @@ -171,7 +171,7 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { require(from != address(0), "ERC1155: burn from the zero address"); require(fromBalance >= amount, "ERC1155: burn amount exceeds balance"); } else if (from == address(0)) { - require(to != address(0), "ERC1155: mint to the zero address"); + require(to != address(0), "ERC1155: mint to the zero address"); } else { require(fromBalance >= amount, "ERC1155: insufficient balance for transfer"); } @@ -207,7 +207,7 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { bytes memory data ) internal virtual { require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); - require(to != address(0), "ERC1155: transfer to the zero address"); + require(from != address(0) || to != address(0), "ERC1155: invalid transfer operation"); address operator = _msgSender(); @@ -217,15 +217,21 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: insufficient balance for transfer"); - unchecked { - _balances[id][from] = fromBalance - amount; + if (from != address(0)) { + unchecked { + _balances[id][from] = fromBalance - amount; + } + } + + if (to != address(0)) { + _balances[id][to] += amount; } - _balances[id][to] += amount; } emit TransferBatch(operator, from, to, ids, amounts); - - _doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data); + if (to != address(0)) { + _doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data); + } } /** @@ -287,19 +293,8 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { uint256[] memory ids, uint256[] memory amounts, bytes memory data - ) internal virtual { - require(to != address(0), "ERC1155: mint to the zero address"); - require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); - - address operator = _msgSender(); - - for (uint256 i = 0; i < ids.length; i++) { - _balances[ids[i]][to] += amounts[i]; - } - - emit TransferBatch(operator, address(0), to, ids, amounts); - - _doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data); + ) internal { + _safeBatchTransferFrom(address(0), to, ids, amounts, data); } /** @@ -316,7 +311,7 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { address from, uint256 id, uint256 amount - ) internal virtual { + ) internal { _safeTransferFrom(from, address(0), id, amount, ""); } @@ -333,24 +328,8 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { address from, uint256[] memory ids, uint256[] memory amounts - ) internal virtual { - require(from != address(0), "ERC1155: burn from the zero address"); - require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); - - address operator = _msgSender(); - - for (uint256 i = 0; i < ids.length; i++) { - uint256 id = ids[i]; - uint256 amount = amounts[i]; - - uint256 fromBalance = _balances[id][from]; - require(fromBalance >= amount, "ERC1155: burn amount exceeds balance"); - unchecked { - _balances[id][from] = fromBalance - amount; - } - } - - emit TransferBatch(operator, from, address(0), ids, amounts); + ) internal { + _safeBatchTransferFrom(from, address(0), ids, amounts, ""); } /** diff --git a/contracts/token/ERC1155/extensions/ERC1155Pausable.sol b/contracts/token/ERC1155/extensions/ERC1155Pausable.sol index 64790e2aa8d..c2565d6a94f 100644 --- a/contracts/token/ERC1155/extensions/ERC1155Pausable.sol +++ b/contracts/token/ERC1155/extensions/ERC1155Pausable.sol @@ -17,13 +17,13 @@ import "../../../security/Pausable.sol"; */ abstract contract ERC1155Pausable is ERC1155, Pausable { /** - * @dev See {ERC1155-_beforeTokenTransfer}. + * @dev See {ERC1155-_safeTransferFrom}. * * Requirements: * * - the contract must not be paused. */ - function _beforeTokenTransfer( + function _safeTransferFrom( address operator, address from, address to, @@ -31,8 +31,7 @@ abstract contract ERC1155Pausable is ERC1155, Pausable { uint256[] memory amounts, bytes memory data ) internal virtual override { - super._beforeTokenTransfer(operator, from, to, ids, amounts, data); - require(!paused(), "ERC1155Pausable: token transfer while paused"); + super._safeTransferFrom(operator, from, to, ids, amounts, data); } } diff --git a/contracts/token/ERC1155/extensions/ERC1155Supply.sol b/contracts/token/ERC1155/extensions/ERC1155Supply.sol index ec24389a10b..d6d56f1d8bb 100644 --- a/contracts/token/ERC1155/extensions/ERC1155Supply.sol +++ b/contracts/token/ERC1155/extensions/ERC1155Supply.sol @@ -31,9 +31,9 @@ abstract contract ERC1155Supply is ERC1155 { } /** - * @dev See {ERC1155-_beforeTokenTransfer}. + * @dev See {ERC1155-_safeTransferFrom}. */ - function _beforeTokenTransfer( + function _safeTransferFrom( address operator, address from, address to, @@ -41,8 +41,6 @@ abstract contract ERC1155Supply is ERC1155 { uint256[] memory amounts, bytes memory data ) internal virtual override { - super._beforeTokenTransfer(operator, from, to, ids, amounts, data); - if (from == address(0)) { for (uint256 i = 0; i < ids.length; ++i) { _totalSupply[ids[i]] += amounts[i]; @@ -60,5 +58,6 @@ abstract contract ERC1155Supply is ERC1155 { } } } + super._safeTransferFrom(operator, from, to, ids, amounts, data); } } diff --git a/test/token/ERC1155/ERC1155.behavior.js b/test/token/ERC1155/ERC1155.behavior.js index 5714cab26a0..61d5ea1a408 100644 --- a/test/token/ERC1155/ERC1155.behavior.js +++ b/test/token/ERC1155/ERC1155.behavior.js @@ -433,7 +433,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder, }); }); - describe('safeBatchTransferFrom', function () { + describe.only('safeBatchTransferFrom', function () { beforeEach(async function () { await this.token.mint(multiTokenHolder, firstTokenId, firstAmount, '0x', { from: minter, diff --git a/test/token/ERC1155/ERC1155.test.js b/test/token/ERC1155/ERC1155.test.js index 48891deb805..97eb217ad49 100644 --- a/test/token/ERC1155/ERC1155.test.js +++ b/test/token/ERC1155/ERC1155.test.js @@ -57,7 +57,7 @@ contract('ERC1155', function (accounts) { }); }); - describe('_mintBatch', function () { + describe.only('_mintBatch', function () { it('reverts with a zero destination address', async function () { await expectRevert( this.token.mintBatch(ZERO_ADDRESS, tokenBatchIds, mintAmounts, data), @@ -169,7 +169,7 @@ contract('ERC1155', function (accounts) { }); }); - describe('_burnBatch', function () { + describe.only('_burnBatch', function () { it('reverts when burning the zero account\'s tokens', async function () { await expectRevert( this.token.burnBatch(ZERO_ADDRESS, tokenBatchIds, burnAmounts), From 79884e6144f3ef16487a2d1ada1047ee906d217e Mon Sep 17 00:00:00 2001 From: JulissaDantes Date: Tue, 13 Dec 2022 09:43:28 -0400 Subject: [PATCH 05/25] Update mocks --- contracts/mocks/ERC1155PausableMock.sol | 10 ++++++++++ contracts/mocks/ERC1155SupplyMock.sol | 10 ++++++++++ contracts/token/ERC1155/extensions/ERC1155Pausable.sol | 5 ++--- contracts/token/ERC1155/extensions/ERC1155Supply.sol | 5 ++--- 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/contracts/mocks/ERC1155PausableMock.sol b/contracts/mocks/ERC1155PausableMock.sol index 9c11ec55f3b..a3c88ed81b1 100644 --- a/contracts/mocks/ERC1155PausableMock.sol +++ b/contracts/mocks/ERC1155PausableMock.sol @@ -15,4 +15,14 @@ contract ERC1155PausableMock is ERC1155Mock, ERC1155Pausable { function unpause() external { _unpause(); } + + function _safeBatchTransferFrom( + address from, + address to, + uint256[] memory ids, + uint256[] memory amounts, + bytes memory data + ) internal virtual override(ERC1155, ERC1155Pausable) { + super._safeBatchTransferFrom(from, to, ids, amounts, data); + } } diff --git a/contracts/mocks/ERC1155SupplyMock.sol b/contracts/mocks/ERC1155SupplyMock.sol index d7b3ee70bfa..96febecbff2 100644 --- a/contracts/mocks/ERC1155SupplyMock.sol +++ b/contracts/mocks/ERC1155SupplyMock.sol @@ -7,4 +7,14 @@ import "../token/ERC1155/extensions/ERC1155Supply.sol"; contract ERC1155SupplyMock is ERC1155Mock, ERC1155Supply { constructor(string memory uri) ERC1155Mock(uri) {} + + function _safeBatchTransferFrom( + address from, + address to, + uint256[] memory ids, + uint256[] memory amounts, + bytes memory data + ) internal virtual override(ERC1155, ERC1155Supply) { + super._safeBatchTransferFrom(from, to, ids, amounts, data); + } } diff --git a/contracts/token/ERC1155/extensions/ERC1155Pausable.sol b/contracts/token/ERC1155/extensions/ERC1155Pausable.sol index c2565d6a94f..20194ac8153 100644 --- a/contracts/token/ERC1155/extensions/ERC1155Pausable.sol +++ b/contracts/token/ERC1155/extensions/ERC1155Pausable.sol @@ -23,8 +23,7 @@ abstract contract ERC1155Pausable is ERC1155, Pausable { * * - the contract must not be paused. */ - function _safeTransferFrom( - address operator, + function _safeBatchTransferFrom( address from, address to, uint256[] memory ids, @@ -32,6 +31,6 @@ abstract contract ERC1155Pausable is ERC1155, Pausable { bytes memory data ) internal virtual override { require(!paused(), "ERC1155Pausable: token transfer while paused"); - super._safeTransferFrom(operator, from, to, ids, amounts, data); + super._safeBatchTransferFrom(from, to, ids, amounts, data); } } diff --git a/contracts/token/ERC1155/extensions/ERC1155Supply.sol b/contracts/token/ERC1155/extensions/ERC1155Supply.sol index d6d56f1d8bb..f862fe00773 100644 --- a/contracts/token/ERC1155/extensions/ERC1155Supply.sol +++ b/contracts/token/ERC1155/extensions/ERC1155Supply.sol @@ -33,8 +33,7 @@ abstract contract ERC1155Supply is ERC1155 { /** * @dev See {ERC1155-_safeTransferFrom}. */ - function _safeTransferFrom( - address operator, + function _safeBatchTransferFrom( address from, address to, uint256[] memory ids, @@ -58,6 +57,6 @@ abstract contract ERC1155Supply is ERC1155 { } } } - super._safeTransferFrom(operator, from, to, ids, amounts, data); + super._safeBatchTransferFrom(from, to, ids, amounts, data); } } From 96467b7dff8677148b7da701728aebb16146c39c Mon Sep 17 00:00:00 2001 From: JulissaDantes Date: Tue, 13 Dec 2022 15:30:33 -0400 Subject: [PATCH 06/25] Introduce _update and _updateBatch --- contracts/mocks/ERC1155PausableMock.sol | 14 +++- contracts/mocks/ERC1155SupplyMock.sol | 14 +++- contracts/token/ERC1155/ERC1155.sol | 72 +++++++++++++++---- .../ERC1155/extensions/ERC1155Pausable.sol | 24 ++++++- .../ERC1155/extensions/ERC1155Supply.sol | 30 +++++++- test/token/ERC1155/ERC1155.behavior.js | 2 +- test/token/ERC1155/ERC1155.test.js | 10 +-- 7 files changed, 137 insertions(+), 29 deletions(-) diff --git a/contracts/mocks/ERC1155PausableMock.sol b/contracts/mocks/ERC1155PausableMock.sol index a3c88ed81b1..d5297084eeb 100644 --- a/contracts/mocks/ERC1155PausableMock.sol +++ b/contracts/mocks/ERC1155PausableMock.sol @@ -16,13 +16,23 @@ contract ERC1155PausableMock is ERC1155Mock, ERC1155Pausable { _unpause(); } - function _safeBatchTransferFrom( + function _update( + address from, + address to, + uint256 id, + uint256 amount, + bytes memory data + ) internal virtual override(ERC1155, ERC1155Pausable) { + super._update(from, to, id, amount, data); + } + + function _updateBatch( address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual override(ERC1155, ERC1155Pausable) { - super._safeBatchTransferFrom(from, to, ids, amounts, data); + super._updateBatch(from, to, ids, amounts, data); } } diff --git a/contracts/mocks/ERC1155SupplyMock.sol b/contracts/mocks/ERC1155SupplyMock.sol index 96febecbff2..7d81b83cea4 100644 --- a/contracts/mocks/ERC1155SupplyMock.sol +++ b/contracts/mocks/ERC1155SupplyMock.sol @@ -8,13 +8,23 @@ import "../token/ERC1155/extensions/ERC1155Supply.sol"; contract ERC1155SupplyMock is ERC1155Mock, ERC1155Supply { constructor(string memory uri) ERC1155Mock(uri) {} - function _safeBatchTransferFrom( + function _update( + address from, + address to, + uint256 id, + uint256 amount, + bytes memory data + ) internal virtual override(ERC1155, ERC1155Supply) { + super._update(from, to, id, amount, data); + } + + function _updateBatch( address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual override(ERC1155, ERC1155Supply) { - super._safeBatchTransferFrom(from, to, ids, amounts, data); + super._updateBatch(from, to, ids, amounts, data); } } diff --git a/contracts/token/ERC1155/ERC1155.sol b/contracts/token/ERC1155/ERC1155.sol index afc0b39dd78..ec9c283997f 100644 --- a/contracts/token/ERC1155/ERC1155.sol +++ b/contracts/token/ERC1155/ERC1155.sol @@ -146,18 +146,16 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { } /** - * @dev Transfers `amount` tokens of token type `id` from `from` to `to`. + * @dev Transfers `amount` tokens of token type `id` from `from` to `to`. Will mint (or burn) if `from` (or `to`) is the zero address. * * Emits a {TransferSingle} event. * * Requirements: * - * - `to` cannot be the zero address. - * - `from` must have a balance of tokens of type `id` of at least `amount`. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ - function _safeTransferFrom( + function _update( address from, address to, uint256 id, @@ -166,7 +164,7 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { ) internal virtual { address operator = _msgSender(); uint256 fromBalance = _balances[id][from]; - require(from != address(0) || to != address(0), "ERC1155: invalid transfer operation"); + if (to == address(0)) { require(from != address(0), "ERC1155: burn from the zero address"); require(fromBalance >= amount, "ERC1155: burn amount exceeds balance"); @@ -190,7 +188,7 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { } /** - * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}. + * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_update}. * * Emits a {TransferBatch} event. * @@ -199,7 +197,7 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ - function _safeBatchTransferFrom( + function _updateBatch( address from, address to, uint256[] memory ids, @@ -207,7 +205,6 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { bytes memory data ) internal virtual { require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); - require(from != address(0) || to != address(0), "ERC1155: invalid transfer operation"); address operator = _msgSender(); @@ -216,8 +213,9 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { uint256 amount = amounts[i]; uint256 fromBalance = _balances[id][from]; - require(fromBalance >= amount, "ERC1155: insufficient balance for transfer"); + if (from != address(0)) { + require(fromBalance >= amount, "ERC1155: insufficient balance for transfer"); unchecked { _balances[id][from] = fromBalance - amount; } @@ -234,6 +232,50 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { } } + /** + * @dev Transfers `amount` tokens of token type `id` from `from` to `to`. + * + * Emits a {TransferSingle} event. + * + * Requirements: + * + * - `to` cannot be the zero address. + * - `from` must have a balance of tokens of type `id` of at least `amount`. + * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the + * acceptance magic value. + */ + function _safeTransferFrom( + address from, + address to, + uint256 id, + uint256 amount, + bytes memory data + ) internal virtual { + require(to != address(0), "ERC1155: transfer to the zero address"); + _update(from, to, id, amount, data); + } + + /** + * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}. + * + * Emits a {TransferBatch} event. + * + * Requirements: + * + * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the + * acceptance magic value. + */ + function _safeBatchTransferFrom( + address from, + address to, + uint256[] memory ids, + uint256[] memory amounts, + bytes memory data + ) internal virtual { + require(to != address(0), "ERC1155: transfer to the zero address"); + _updateBatch(from, to, ids, amounts, data); + } + /** * @dev Sets a new URI for all token types, by relying on the token type ID * substitution mechanism @@ -274,7 +316,8 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { uint256 amount, bytes memory data ) internal virtual { - _safeTransferFrom(address(0), to, id, amount, data); + require(to != address(0), "ERC1155: mint to the zero address"); + _update(address(0), to, id, amount, data); } /** @@ -294,7 +337,8 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { uint256[] memory amounts, bytes memory data ) internal { - _safeBatchTransferFrom(address(0), to, ids, amounts, data); + require(to != address(0), "ERC1155: mint to the zero address"); + _updateBatch(address(0), to, ids, amounts, data); } /** @@ -312,7 +356,8 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { uint256 id, uint256 amount ) internal { - _safeTransferFrom(from, address(0), id, amount, ""); + require(from != address(0), "ERC1155: burn from the zero address"); + _update(from, address(0), id, amount, ""); } /** @@ -329,7 +374,8 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { uint256[] memory ids, uint256[] memory amounts ) internal { - _safeBatchTransferFrom(from, address(0), ids, amounts, ""); + require(from != address(0), "ERC1155: burn from the zero address"); + _updateBatch(from, address(0), ids, amounts, ""); } /** diff --git a/contracts/token/ERC1155/extensions/ERC1155Pausable.sol b/contracts/token/ERC1155/extensions/ERC1155Pausable.sol index 20194ac8153..a4b6e3b38b3 100644 --- a/contracts/token/ERC1155/extensions/ERC1155Pausable.sol +++ b/contracts/token/ERC1155/extensions/ERC1155Pausable.sol @@ -17,13 +17,31 @@ import "../../../security/Pausable.sol"; */ abstract contract ERC1155Pausable is ERC1155, Pausable { /** - * @dev See {ERC1155-_safeTransferFrom}. + * @dev See {ERC1155-_update}. * * Requirements: * * - the contract must not be paused. */ - function _safeBatchTransferFrom( + function _update( + address from, + address to, + uint256 id, + uint256 amount, + bytes memory data + ) internal virtual override { + require(!paused(), "ERC1155Pausable: token transfer while paused"); + super._update(from, to, id, amount, data); + } + + /** + * @dev See {ERC1155-_updateBatch}. + * + * Requirements: + * + * - the contract must not be paused. + */ + function _updateBatch( address from, address to, uint256[] memory ids, @@ -31,6 +49,6 @@ abstract contract ERC1155Pausable is ERC1155, Pausable { bytes memory data ) internal virtual override { require(!paused(), "ERC1155Pausable: token transfer while paused"); - super._safeBatchTransferFrom(from, to, ids, amounts, data); + super._updateBatch(from, to, ids, amounts, data); } } diff --git a/contracts/token/ERC1155/extensions/ERC1155Supply.sol b/contracts/token/ERC1155/extensions/ERC1155Supply.sol index f862fe00773..5e04a69430c 100644 --- a/contracts/token/ERC1155/extensions/ERC1155Supply.sol +++ b/contracts/token/ERC1155/extensions/ERC1155Supply.sol @@ -31,9 +31,33 @@ abstract contract ERC1155Supply is ERC1155 { } /** - * @dev See {ERC1155-_safeTransferFrom}. + * @dev See {ERC1155-_update}. */ - function _safeBatchTransferFrom( + function _update( + address from, + address to, + uint256 id, + uint256 amount, + bytes memory data + ) internal virtual override { + if (from == address(0)) { + _totalSupply[id] += amount; + } + + if (to == address(0)) { + uint256 supply = _totalSupply[id]; + require(supply >= amount, "ERC1155: burn amount exceeds totalSupply"); + unchecked { + _totalSupply[id] = supply - amount; + } + } + super._update(from, to, id, amount, data); + } + + /** + * @dev See {ERC1155-_updateBatch}. + */ + function _updateBatch( address from, address to, uint256[] memory ids, @@ -57,6 +81,6 @@ abstract contract ERC1155Supply is ERC1155 { } } } - super._safeBatchTransferFrom(from, to, ids, amounts, data); + super._updateBatch(from, to, ids, amounts, data); } } diff --git a/test/token/ERC1155/ERC1155.behavior.js b/test/token/ERC1155/ERC1155.behavior.js index 61d5ea1a408..5714cab26a0 100644 --- a/test/token/ERC1155/ERC1155.behavior.js +++ b/test/token/ERC1155/ERC1155.behavior.js @@ -433,7 +433,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder, }); }); - describe.only('safeBatchTransferFrom', function () { + describe('safeBatchTransferFrom', function () { beforeEach(async function () { await this.token.mint(multiTokenHolder, firstTokenId, firstAmount, '0x', { from: minter, diff --git a/test/token/ERC1155/ERC1155.test.js b/test/token/ERC1155/ERC1155.test.js index 97eb217ad49..94e92c8a951 100644 --- a/test/token/ERC1155/ERC1155.test.js +++ b/test/token/ERC1155/ERC1155.test.js @@ -32,7 +32,7 @@ contract('ERC1155', function (accounts) { it('reverts with a zero destination address', async function () { await expectRevert( this.token.mint(ZERO_ADDRESS, tokenId, mintAmount, data), - 'ERC1155: invalid transfer operation', + 'ERC1155: mint to the zero address', ); }); @@ -57,7 +57,7 @@ contract('ERC1155', function (accounts) { }); }); - describe.only('_mintBatch', function () { + describe('_mintBatch', function () { it('reverts with a zero destination address', async function () { await expectRevert( this.token.mintBatch(ZERO_ADDRESS, tokenBatchIds, mintAmounts, data), @@ -113,7 +113,7 @@ contract('ERC1155', function (accounts) { it('reverts when burning the zero account\'s tokens', async function () { await expectRevert( this.token.burn(ZERO_ADDRESS, tokenId, mintAmount), - 'ERC1155: invalid transfer operation', + 'ERC1155: burn from the zero address', ); }); @@ -169,7 +169,7 @@ contract('ERC1155', function (accounts) { }); }); - describe.only('_burnBatch', function () { + describe('_burnBatch', function () { it('reverts when burning the zero account\'s tokens', async function () { await expectRevert( this.token.burnBatch(ZERO_ADDRESS, tokenBatchIds, burnAmounts), @@ -192,7 +192,7 @@ contract('ERC1155', function (accounts) { it('reverts when burning a non-existent token id', async function () { await expectRevert( this.token.burnBatch(tokenBatchHolder, tokenBatchIds, burnAmounts), - 'ERC1155: burn amount exceeds balance', + 'ERC1155: insufficient balance for transfer', ); }); From 293d0ee7ba543b7cf5ea3f29d78122efe23bb1d1 Mon Sep 17 00:00:00 2001 From: JulissaDantes Date: Tue, 13 Dec 2022 15:45:06 -0400 Subject: [PATCH 07/25] Add changelog entry --- CHANGELOG.md | 1 + test/token/ERC1155/ERC1155.behavior.js | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bf92d9b4395..39b597ec8b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ * Removed presets in favor of [OpenZeppelin Contracts Wizard](https://wizard.openzeppelin.com/). * `TransparentUpgradeableProxy`: Removed `admin` and `implementation` getters, which were only callable by the proxy owner and thus not very useful. ([#3820](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3820)) * `ProxyAdmin`: Removed `getProxyAdmin` and `getProxyImplementation` getters. ([#3820](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3820)) + * `ERC1155`: Deleted `_beforeTokenTransfer` and `_afterTokenTransfer` hooks, and refactor all extensions using those hooks for customization, by using `_update` instead. ([#3876](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3876)) ## Unreleased diff --git a/test/token/ERC1155/ERC1155.behavior.js b/test/token/ERC1155/ERC1155.behavior.js index 5714cab26a0..92dee36b76f 100644 --- a/test/token/ERC1155/ERC1155.behavior.js +++ b/test/token/ERC1155/ERC1155.behavior.js @@ -221,6 +221,20 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder, ); }); + it.only('reverts when transferring to zero address', async function () { + await expectRevert( + this.token.safeTransferFrom( + multiTokenHolder, + ZERO_ADDRESS, + firstTokenId, + firstAmount, + '0x', + { from: multiTokenHolder }, + ), + 'ERC1155: transfer to the zero address', + ); + }); + function transferWasSuccessful ({ operator, from, id, value }) { it('debits transferred balance from sender', async function () { const newBalance = await this.token.balanceOf(from, id); From f84a858f5684696a87bcce0508224fb747bf2fe8 Mon Sep 17 00:00:00 2001 From: JulissaDantes Date: Tue, 13 Dec 2022 15:46:41 -0400 Subject: [PATCH 08/25] Update test --- test/token/ERC1155/ERC1155.behavior.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/token/ERC1155/ERC1155.behavior.js b/test/token/ERC1155/ERC1155.behavior.js index 92dee36b76f..62ba6667721 100644 --- a/test/token/ERC1155/ERC1155.behavior.js +++ b/test/token/ERC1155/ERC1155.behavior.js @@ -221,7 +221,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder, ); }); - it.only('reverts when transferring to zero address', async function () { + it('reverts when transferring to zero address', async function () { await expectRevert( this.token.safeTransferFrom( multiTokenHolder, From 0eb70aca6635aeb67079d3d71c1e15237b19e732 Mon Sep 17 00:00:00 2001 From: JulissaDantes Date: Mon, 19 Dec 2022 10:58:20 -0400 Subject: [PATCH 09/25] update extension --- contracts/token/ERC721/extensions/ERC721Consecutive.sol | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/contracts/token/ERC721/extensions/ERC721Consecutive.sol b/contracts/token/ERC721/extensions/ERC721Consecutive.sol index e6843f1fa12..c71e0d9e067 100644 --- a/contracts/token/ERC721/extensions/ERC721Consecutive.sol +++ b/contracts/token/ERC721/extensions/ERC721Consecutive.sol @@ -90,16 +90,17 @@ abstract contract ERC721Consecutive is IERC2309, ERC721 { require(to != address(0), "ERC721Consecutive: mint to the zero address"); require(batchSize <= _maxBatchSize(), "ERC721Consecutive: batch too large"); - // hook before - _beforeTokenTransfer(address(0), to, first, batchSize); + if (batchSize > 1) { + if (to != address(0)) { + _balances[to] += batchSize; + } + } // push an ownership checkpoint & emit event uint96 last = first + batchSize - 1; _sequentialOwnership.push(last, uint160(to)); emit ConsecutiveTransfer(first, last, address(0), to); - // hook after - _afterTokenTransfer(address(0), to, first, batchSize); } return first; From bd0f915e8db36f18d66ebf3bf0b2cff84a43f024 Mon Sep 17 00:00:00 2001 From: JulissaDantes Date: Mon, 19 Dec 2022 16:25:43 -0400 Subject: [PATCH 10/25] fix post merge error --- .../token/ERC721/extensions/ERC721Consecutive.sol | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/contracts/token/ERC721/extensions/ERC721Consecutive.sol b/contracts/token/ERC721/extensions/ERC721Consecutive.sol index c71e0d9e067..4130e61e6ec 100644 --- a/contracts/token/ERC721/extensions/ERC721Consecutive.sol +++ b/contracts/token/ERC721/extensions/ERC721Consecutive.sol @@ -90,17 +90,16 @@ abstract contract ERC721Consecutive is IERC2309, ERC721 { require(to != address(0), "ERC721Consecutive: mint to the zero address"); require(batchSize <= _maxBatchSize(), "ERC721Consecutive: batch too large"); - if (batchSize > 1) { - if (to != address(0)) { - _balances[to] += batchSize; - } - } + // hook before + _beforeTokenTransfer(address(0), to, first, batchSize); // push an ownership checkpoint & emit event uint96 last = first + batchSize - 1; _sequentialOwnership.push(last, uint160(to)); emit ConsecutiveTransfer(first, last, address(0), to); + // hook after + _afterTokenTransfer(address(0), to, first, batchSize); } return first; @@ -141,4 +140,4 @@ abstract contract ERC721Consecutive is IERC2309, ERC721 { (bool exists, uint96 latestId, ) = _sequentialOwnership.latestCheckpoint(); return exists ? latestId + 1 : 0; } -} +} \ No newline at end of file From 11a8d929a2542772548feffa5f8b6ea1a0822126 Mon Sep 17 00:00:00 2001 From: JulissaDantes Date: Mon, 19 Dec 2022 16:29:22 -0400 Subject: [PATCH 11/25] update changelog --- CHANGELOG.md | 3 +-- contracts/token/ERC721/extensions/ERC721Consecutive.sol | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 619a9eef6cd..e7fae0beb80 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,8 +8,7 @@ * Removed presets in favor of [OpenZeppelin Contracts Wizard](https://wizard.openzeppelin.com/). * `TransparentUpgradeableProxy`: Removed `admin` and `implementation` getters, which were only callable by the proxy owner and thus not very useful. ([#3820](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3820)) * `ProxyAdmin`: Removed `getProxyAdmin` and `getProxyImplementation` getters. ([#3820](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3820)) - * `ERC1155`: Deleted `_beforeTokenTransfer` and `_afterTokenTransfer` hooks, and refactor all extensions using those hooks for customization, by using `_update` instead. ([#3876](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3876)) - * `ERC20`: Deleted `_beforeTokenTransfer` and `_afterTokenTransfer` hooks, added a new internal `_update` function for customizations, and refactored all extensions using those hooks to use `_update` instead. ([#3838](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3838)) + * `ERC20`, `ERC1155`: Deleted `_beforeTokenTransfer` and `_afterTokenTransfer` hooks, added a new internal `_update` function for customizations, and refactored all extensions using those hooks to use `_update` instead. ([#3838](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3838), [#3876](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3876)) ### How to upgrade from 4.x diff --git a/contracts/token/ERC721/extensions/ERC721Consecutive.sol b/contracts/token/ERC721/extensions/ERC721Consecutive.sol index 4130e61e6ec..e6843f1fa12 100644 --- a/contracts/token/ERC721/extensions/ERC721Consecutive.sol +++ b/contracts/token/ERC721/extensions/ERC721Consecutive.sol @@ -140,4 +140,4 @@ abstract contract ERC721Consecutive is IERC2309, ERC721 { (bool exists, uint96 latestId, ) = _sequentialOwnership.latestCheckpoint(); return exists ? latestId + 1 : 0; } -} \ No newline at end of file +} From 7c8b929e8fc90481c8efcd1a74fc4b9bd7d1683f Mon Sep 17 00:00:00 2001 From: JulissaDantes Date: Tue, 20 Dec 2022 10:04:08 -0400 Subject: [PATCH 12/25] Remove updateBatch --- contracts/mocks/ERC1155PausableMock.sol | 12 +-- contracts/mocks/ERC1155SupplyMock.sol | 12 +-- contracts/token/ERC1155/ERC1155.sol | 84 +++++++------------ .../ERC1155/extensions/ERC1155Pausable.sol | 20 +---- .../ERC1155/extensions/ERC1155Supply.sol | 26 +----- 5 files changed, 34 insertions(+), 120 deletions(-) diff --git a/contracts/mocks/ERC1155PausableMock.sol b/contracts/mocks/ERC1155PausableMock.sol index d5297084eeb..8512f3dd07d 100644 --- a/contracts/mocks/ERC1155PausableMock.sol +++ b/contracts/mocks/ERC1155PausableMock.sol @@ -17,22 +17,12 @@ contract ERC1155PausableMock is ERC1155Mock, ERC1155Pausable { } function _update( - address from, - address to, - uint256 id, - uint256 amount, - bytes memory data - ) internal virtual override(ERC1155, ERC1155Pausable) { - super._update(from, to, id, amount, data); - } - - function _updateBatch( address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual override(ERC1155, ERC1155Pausable) { - super._updateBatch(from, to, ids, amounts, data); + super._update(from, to, ids, amounts, data); } } diff --git a/contracts/mocks/ERC1155SupplyMock.sol b/contracts/mocks/ERC1155SupplyMock.sol index 7d81b83cea4..6ea763cf355 100644 --- a/contracts/mocks/ERC1155SupplyMock.sol +++ b/contracts/mocks/ERC1155SupplyMock.sol @@ -9,22 +9,12 @@ contract ERC1155SupplyMock is ERC1155Mock, ERC1155Supply { constructor(string memory uri) ERC1155Mock(uri) {} function _update( - address from, - address to, - uint256 id, - uint256 amount, - bytes memory data - ) internal virtual override(ERC1155, ERC1155Supply) { - super._update(from, to, id, amount, data); - } - - function _updateBatch( address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual override(ERC1155, ERC1155Supply) { - super._updateBatch(from, to, ids, amounts, data); + super._update(from, to, ids, amounts, data); } } diff --git a/contracts/token/ERC1155/ERC1155.sol b/contracts/token/ERC1155/ERC1155.sol index df472e0e4c4..716c2aaa56e 100644 --- a/contracts/token/ERC1155/ERC1155.sol +++ b/contracts/token/ERC1155/ERC1155.sol @@ -148,56 +148,14 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { /** * @dev Transfers `amount` tokens of token type `id` from `from` to `to`. Will mint (or burn) if `from` (or `to`) is the zero address. * - * Emits a {TransferSingle} event. - * - * Requirements: - * - * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the - * acceptance magic value. - */ - function _update( - address from, - address to, - uint256 id, - uint256 amount, - bytes memory data - ) internal virtual { - address operator = _msgSender(); - uint256 fromBalance = _balances[id][from]; - - if (to == address(0)) { - require(from != address(0), "ERC1155: burn from the zero address"); - require(fromBalance >= amount, "ERC1155: burn amount exceeds balance"); - } else if (from == address(0)) { - require(to != address(0), "ERC1155: mint to the zero address"); - } else { - require(fromBalance >= amount, "ERC1155: insufficient balance for transfer"); - } - - if (from != address(0)) { - unchecked { - _balances[id][from] -= amount; - } - } - if (to != address(0)) { - _balances[id][to] += amount; - _doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data); - } - - emit TransferSingle(operator, from, to, id, amount); - } - - /** - * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_update}. - * - * Emits a {TransferBatch} event. + * Emits a {TransferSingle} event if only one transfer is done, and {TransferBatch} event for multiple transfer operations. * * Requirements: * * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ - function _updateBatch( + function _update( address from, address to, uint256[] memory ids, @@ -214,6 +172,12 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { uint256 fromBalance = _balances[id][from]; + if (to == address(0)) { + require(from != address(0), "ERC1155: burn from the zero address"); + } else if (from == address(0)) { + require(to != address(0), "ERC1155: mint to the zero address"); + } + if (from != address(0)) { require(fromBalance >= amount, "ERC1155: insufficient balance for transfer"); unchecked { @@ -225,10 +189,16 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { _balances[id][to] += amount; } } - - emit TransferBatch(operator, from, to, ids, amounts); - if (to != address(0)) { - _doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data); + if (ids.length == 1) { + emit TransferSingle(operator, from, to, ids[0], amounts[0]); + if (to != address(0)) { + _doSafeTransferAcceptanceCheck(operator, from, to, ids[0], amounts[0], data); + } + } else { + emit TransferBatch(operator, from, to, ids, amounts); + if (to != address(0)) { + _doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data); + } } } @@ -252,7 +222,9 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { bytes memory data ) internal virtual { require(to != address(0), "ERC1155: transfer to the zero address"); - _update(from, to, id, amount, data); + uint256[] memory ids = _asSingletonArray(id); + uint256[] memory amounts = _asSingletonArray(amount); + _update(from, to, ids, amounts, data); } /** @@ -273,7 +245,7 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { bytes memory data ) internal virtual { require(to != address(0), "ERC1155: transfer to the zero address"); - _updateBatch(from, to, ids, amounts, data); + _update(from, to, ids, amounts, data); } /** @@ -317,7 +289,9 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { bytes memory data ) internal virtual { require(to != address(0), "ERC1155: mint to the zero address"); - _update(address(0), to, id, amount, data); + uint256[] memory ids = _asSingletonArray(id); + uint256[] memory amounts = _asSingletonArray(amount); + _update(address(0), to, ids, amounts, data); } /** @@ -338,7 +312,7 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { bytes memory data ) internal { require(to != address(0), "ERC1155: mint to the zero address"); - _updateBatch(address(0), to, ids, amounts, data); + _update(address(0), to, ids, amounts, data); } /** @@ -357,7 +331,9 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { uint256 amount ) internal { require(from != address(0), "ERC1155: burn from the zero address"); - _update(from, address(0), id, amount, ""); + uint256[] memory ids = _asSingletonArray(id); + uint256[] memory amounts = _asSingletonArray(amount); + _update(from, address(0), ids, amounts, ""); } /** @@ -375,7 +351,7 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { uint256[] memory amounts ) internal { require(from != address(0), "ERC1155: burn from the zero address"); - _updateBatch(from, address(0), ids, amounts, ""); + _update(from, address(0), ids, amounts, ""); } /** diff --git a/contracts/token/ERC1155/extensions/ERC1155Pausable.sol b/contracts/token/ERC1155/extensions/ERC1155Pausable.sol index a4b6e3b38b3..f37d90e25c5 100644 --- a/contracts/token/ERC1155/extensions/ERC1155Pausable.sol +++ b/contracts/token/ERC1155/extensions/ERC1155Pausable.sol @@ -24,24 +24,6 @@ abstract contract ERC1155Pausable is ERC1155, Pausable { * - the contract must not be paused. */ function _update( - address from, - address to, - uint256 id, - uint256 amount, - bytes memory data - ) internal virtual override { - require(!paused(), "ERC1155Pausable: token transfer while paused"); - super._update(from, to, id, amount, data); - } - - /** - * @dev See {ERC1155-_updateBatch}. - * - * Requirements: - * - * - the contract must not be paused. - */ - function _updateBatch( address from, address to, uint256[] memory ids, @@ -49,6 +31,6 @@ abstract contract ERC1155Pausable is ERC1155, Pausable { bytes memory data ) internal virtual override { require(!paused(), "ERC1155Pausable: token transfer while paused"); - super._updateBatch(from, to, ids, amounts, data); + super._update(from, to, ids, amounts, data); } } diff --git a/contracts/token/ERC1155/extensions/ERC1155Supply.sol b/contracts/token/ERC1155/extensions/ERC1155Supply.sol index 5e04a69430c..77690b59d0a 100644 --- a/contracts/token/ERC1155/extensions/ERC1155Supply.sol +++ b/contracts/token/ERC1155/extensions/ERC1155Supply.sol @@ -34,30 +34,6 @@ abstract contract ERC1155Supply is ERC1155 { * @dev See {ERC1155-_update}. */ function _update( - address from, - address to, - uint256 id, - uint256 amount, - bytes memory data - ) internal virtual override { - if (from == address(0)) { - _totalSupply[id] += amount; - } - - if (to == address(0)) { - uint256 supply = _totalSupply[id]; - require(supply >= amount, "ERC1155: burn amount exceeds totalSupply"); - unchecked { - _totalSupply[id] = supply - amount; - } - } - super._update(from, to, id, amount, data); - } - - /** - * @dev See {ERC1155-_updateBatch}. - */ - function _updateBatch( address from, address to, uint256[] memory ids, @@ -81,6 +57,6 @@ abstract contract ERC1155Supply is ERC1155 { } } } - super._updateBatch(from, to, ids, amounts, data); + super._update(from, to, ids, amounts, data); } } From a9799ae0de78944fc721e824c8145f54134b4e27 Mon Sep 17 00:00:00 2001 From: JulissaDantes Date: Tue, 20 Dec 2022 10:16:41 -0400 Subject: [PATCH 13/25] Update ERC1155 --- contracts/token/ERC1155/ERC1155.sol | 6 +----- test/token/ERC1155/ERC1155.test.js | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/contracts/token/ERC1155/ERC1155.sol b/contracts/token/ERC1155/ERC1155.sol index 716c2aaa56e..89ee8c088a7 100644 --- a/contracts/token/ERC1155/ERC1155.sol +++ b/contracts/token/ERC1155/ERC1155.sol @@ -171,13 +171,9 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { uint256 amount = amounts[i]; uint256 fromBalance = _balances[id][from]; - if (to == address(0)) { - require(from != address(0), "ERC1155: burn from the zero address"); - } else if (from == address(0)) { - require(to != address(0), "ERC1155: mint to the zero address"); + require(fromBalance >= amount, "ERC1155: burn amount exceeds balance"); } - if (from != address(0)) { require(fromBalance >= amount, "ERC1155: insufficient balance for transfer"); unchecked { diff --git a/test/token/ERC1155/ERC1155.test.js b/test/token/ERC1155/ERC1155.test.js index 94e92c8a951..a0a8cf3ff89 100644 --- a/test/token/ERC1155/ERC1155.test.js +++ b/test/token/ERC1155/ERC1155.test.js @@ -192,7 +192,7 @@ contract('ERC1155', function (accounts) { it('reverts when burning a non-existent token id', async function () { await expectRevert( this.token.burnBatch(tokenBatchHolder, tokenBatchIds, burnAmounts), - 'ERC1155: insufficient balance for transfer', + 'ERC1155: burn amount exceeds balance', ); }); From 4e513b64452f4c2a066c36ba8a31dc00de56881d Mon Sep 17 00:00:00 2001 From: JulissaDantes Date: Tue, 27 Dec 2022 09:59:11 -0400 Subject: [PATCH 14/25] Check non zero address as attribute --- contracts/token/ERC1155/ERC1155.sol | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/contracts/token/ERC1155/ERC1155.sol b/contracts/token/ERC1155/ERC1155.sol index 89ee8c088a7..9f56dc542f3 100644 --- a/contracts/token/ERC1155/ERC1155.sol +++ b/contracts/token/ERC1155/ERC1155.sol @@ -216,8 +216,9 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { uint256 id, uint256 amount, bytes memory data - ) internal virtual { + ) internal { require(to != address(0), "ERC1155: transfer to the zero address"); + require(from != address(0), "ERC1155: transfer from the zero address"); uint256[] memory ids = _asSingletonArray(id); uint256[] memory amounts = _asSingletonArray(amount); _update(from, to, ids, amounts, data); @@ -239,8 +240,9 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { uint256[] memory ids, uint256[] memory amounts, bytes memory data - ) internal virtual { + ) internal { require(to != address(0), "ERC1155: transfer to the zero address"); + require(from != address(0), "ERC1155: transfer from the zero address"); _update(from, to, ids, amounts, data); } @@ -283,7 +285,7 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { uint256 id, uint256 amount, bytes memory data - ) internal virtual { + ) internal { require(to != address(0), "ERC1155: mint to the zero address"); uint256[] memory ids = _asSingletonArray(id); uint256[] memory amounts = _asSingletonArray(amount); From 48080eb2ca662da293a18b9da731a6ccb5d36249 Mon Sep 17 00:00:00 2001 From: JulissaDantes Date: Fri, 6 Jan 2023 09:24:42 -0400 Subject: [PATCH 15/25] Update contracts/token/ERC1155/ERC1155.sol Co-authored-by: Hadrien Croubois --- contracts/token/ERC1155/ERC1155.sol | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/contracts/token/ERC1155/ERC1155.sol b/contracts/token/ERC1155/ERC1155.sol index 9f56dc542f3..a8509596d47 100644 --- a/contracts/token/ERC1155/ERC1155.sol +++ b/contracts/token/ERC1155/ERC1155.sol @@ -186,9 +186,11 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { } } if (ids.length == 1) { - emit TransferSingle(operator, from, to, ids[0], amounts[0]); + uint256 id = ids[0]; + uint256 amount = amounts[0]; + emit TransferSingle(operator, from, to, id, amount); if (to != address(0)) { - _doSafeTransferAcceptanceCheck(operator, from, to, ids[0], amounts[0], data); + _doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data); } } else { emit TransferBatch(operator, from, to, ids, amounts); From c1ee9ce354813c0ec76e6f01f1cd7292ddfb99e6 Mon Sep 17 00:00:00 2001 From: JulissaDantes Date: Fri, 6 Jan 2023 09:47:40 -0400 Subject: [PATCH 16/25] Update contracts/token/ERC1155/ERC1155.sol Co-authored-by: Hadrien Croubois --- contracts/token/ERC1155/ERC1155.sol | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/contracts/token/ERC1155/ERC1155.sol b/contracts/token/ERC1155/ERC1155.sol index a8509596d47..fb85aee462c 100644 --- a/contracts/token/ERC1155/ERC1155.sol +++ b/contracts/token/ERC1155/ERC1155.sol @@ -170,11 +170,8 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { uint256 id = ids[i]; uint256 amount = amounts[i]; - uint256 fromBalance = _balances[id][from]; - if (to == address(0)) { - require(fromBalance >= amount, "ERC1155: burn amount exceeds balance"); - } if (from != address(0)) { + uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: insufficient balance for transfer"); unchecked { _balances[id][from] = fromBalance - amount; From 93345da76ae392119018deb17c0cb78fac61802d Mon Sep 17 00:00:00 2001 From: JulissaDantes Date: Fri, 6 Jan 2023 10:25:44 -0400 Subject: [PATCH 17/25] update test error message --- test/token/ERC1155/ERC1155.test.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/token/ERC1155/ERC1155.test.js b/test/token/ERC1155/ERC1155.test.js index a0a8cf3ff89..2f145de5d24 100644 --- a/test/token/ERC1155/ERC1155.test.js +++ b/test/token/ERC1155/ERC1155.test.js @@ -120,7 +120,7 @@ contract('ERC1155', function (accounts) { it('reverts when burning a non-existent token id', async function () { await expectRevert( this.token.burn(tokenHolder, tokenId, mintAmount), - 'ERC1155: burn amount exceeds balance', + 'ERC1155: insufficient balance for transfer', ); }); @@ -135,7 +135,7 @@ contract('ERC1155', function (accounts) { await expectRevert( this.token.burn(tokenHolder, tokenId, mintAmount.addn(1)), - 'ERC1155: burn amount exceeds balance', + 'ERC1155: insufficient balance for transfer', ); }); @@ -192,7 +192,7 @@ contract('ERC1155', function (accounts) { it('reverts when burning a non-existent token id', async function () { await expectRevert( this.token.burnBatch(tokenBatchHolder, tokenBatchIds, burnAmounts), - 'ERC1155: burn amount exceeds balance', + 'ERC1155: insufficient balance for transfer', ); }); From 8b112861fce39db418c07aa392323de759485a41 Mon Sep 17 00:00:00 2001 From: JulissaDantes Date: Fri, 6 Jan 2023 10:33:45 -0400 Subject: [PATCH 18/25] run lint --- .../polygon/CrossChainEnabledPolygonChild.sol | 2 +- contracts/finance/VestingWallet.sol | 6 +- contracts/governance/Governor.sol | 27 ++++--- contracts/governance/TimelockController.sol | 20 ++++- .../GovernorCompatibilityBravo.sol | 17 ++-- .../IGovernorCompatibilityBravo.sol | 8 +- .../extensions/GovernorCountingSimple.sol | 13 ++- .../extensions/GovernorSettings.sol | 6 +- .../extensions/GovernorTimelockControl.sol | 2 +- contracts/governance/utils/IVotes.sol | 9 ++- contracts/governance/utils/Votes.sol | 12 ++- contracts/interfaces/IERC1363.sol | 25 +++++- contracts/interfaces/IERC1363Spender.sol | 6 +- contracts/interfaces/IERC2981.sol | 8 +- contracts/interfaces/IERC4626.sol | 12 ++- contracts/metatx/MinimalForwarder.sol | 9 ++- contracts/mocks/AddressImpl.sol | 6 +- contracts/mocks/CheckpointsMock.sol | 30 ++++++- contracts/mocks/ClonesMock.sol | 6 +- contracts/mocks/ContextMock.sol | 6 +- contracts/mocks/Create2Impl.sol | 6 +- contracts/mocks/DummyImplementation.sol | 6 +- contracts/mocks/ECDSAMock.sol | 13 ++- contracts/mocks/EIP712External.sol | 7 +- contracts/mocks/ERC1155BurnableMock.sol | 7 +- contracts/mocks/ERC1155Mock.sol | 26 +++++- contracts/mocks/ERC1155ReceiverMock.sol | 7 +- contracts/mocks/ERC20CappedMock.sol | 6 +- contracts/mocks/ERC20DecimalsMock.sol | 6 +- contracts/mocks/ERC20Mock.sol | 12 ++- contracts/mocks/ERC3156FlashBorrowerMock.sol | 2 +- contracts/mocks/ERC4626Mock.sol | 32 +++++--- contracts/mocks/ERC721BurnableMock.sol | 6 +- .../mocks/ERC721ConsecutiveEnumerableMock.sol | 10 ++- contracts/mocks/ERC721EnumerableMock.sol | 6 +- contracts/mocks/ERC721Mock.sol | 6 +- contracts/mocks/ERC721PausableMock.sol | 6 +- contracts/mocks/ERC721RoyaltyMock.sol | 6 +- contracts/mocks/ERC721URIStorageMock.sol | 6 +- contracts/mocks/ERC777Mock.sol | 20 ++++- contracts/mocks/ERC777SenderRecipientMock.sol | 13 ++- .../mocks/GovernorCompatibilityBravoMock.sol | 27 ++++--- .../mocks/GovernorPreventLateQuorumMock.sol | 9 ++- .../mocks/GovernorTimelockCompoundMock.sol | 27 ++++--- .../mocks/GovernorTimelockControlMock.sol | 18 +++-- contracts/mocks/MathMock.sol | 7 +- contracts/mocks/MerkleProofWrapper.sol | 12 ++- .../MultipleInheritanceInitializableMocks.sol | 7 +- contracts/mocks/SafeERC20Helper.sol | 18 ++++- contracts/mocks/SafeMathMock.sol | 18 ++++- contracts/mocks/SignatureCheckerMock.sol | 6 +- contracts/mocks/UUPS/UUPSLegacy.sol | 6 +- contracts/mocks/crosschain/bridges.sol | 12 ++- contracts/mocks/wizard/MyGovernor1.sol | 28 ++++--- contracts/mocks/wizard/MyGovernor2.sol | 28 ++++--- contracts/mocks/wizard/MyGovernor3.sol | 37 ++++++--- contracts/proxy/Clones.sol | 9 ++- contracts/proxy/ERC1967/ERC1967Upgrade.sol | 18 ++++- .../TransparentUpgradeableProxy.sol | 6 +- contracts/token/ERC1155/ERC1155.sol | 17 ++-- contracts/token/ERC1155/IERC1155.sol | 16 ++-- .../ERC1155/extensions/ERC1155Burnable.sol | 12 ++- contracts/token/ERC20/ERC20.sol | 30 +++++-- contracts/token/ERC20/IERC20.sol | 6 +- .../token/ERC20/extensions/ERC20Capped.sol | 6 +- .../token/ERC20/extensions/ERC20Pausable.sol | 6 +- .../token/ERC20/extensions/ERC20Snapshot.sol | 6 +- .../token/ERC20/extensions/ERC20Votes.sol | 6 +- contracts/token/ERC20/extensions/ERC4626.sol | 19 ++++- contracts/token/ERC20/utils/SafeERC20.sol | 31 +++++-- contracts/token/ERC20/utils/TokenTimelock.sol | 6 +- contracts/token/ERC721/ERC721.sol | 53 +++++++++--- contracts/token/ERC721/IERC721.sol | 19 ++++- contracts/token/ERC721/utils/ERC721Holder.sol | 7 +- contracts/token/ERC777/ERC777.sol | 51 ++++++++++-- contracts/token/ERC777/IERC777.sol | 13 ++- contracts/token/common/ERC2981.sol | 6 +- contracts/utils/Address.sol | 6 +- contracts/utils/Checkpoints.sol | 80 ++++++++++++++----- contracts/utils/Create2.sol | 12 ++- contracts/utils/cryptography/ECDSA.sol | 26 +++++- contracts/utils/cryptography/MerkleProof.sol | 12 ++- .../utils/cryptography/SignatureChecker.sol | 6 +- .../utils/introspection/ERC165Checker.sol | 9 ++- .../introspection/ERC1820Implementer.sol | 11 ++- .../utils/introspection/IERC1820Registry.sol | 6 +- contracts/utils/math/Math.sol | 41 ++++++---- contracts/utils/math/SafeMath.sol | 18 ++++- contracts/utils/structs/BitMaps.sol | 6 +- contracts/utils/structs/EnumerableMap.sol | 36 +++++++-- contracts/vendor/amb/IAMB.sol | 14 +++- contracts/vendor/arbitrum/IArbSys.sol | 9 ++- contracts/vendor/arbitrum/IBridge.sol | 9 ++- contracts/vendor/arbitrum/IOutbox.sol | 6 +- .../vendor/optimism/ICrossDomainMessenger.sol | 6 +- .../vendor/polygon/IFxMessageProcessor.sol | 6 +- test/utils/math/Math.t.sol | 42 +++++++--- 97 files changed, 1082 insertions(+), 321 deletions(-) diff --git a/contracts/crosschain/polygon/CrossChainEnabledPolygonChild.sol b/contracts/crosschain/polygon/CrossChainEnabledPolygonChild.sol index fa099483499..3918bfe25d8 100644 --- a/contracts/crosschain/polygon/CrossChainEnabledPolygonChild.sol +++ b/contracts/crosschain/polygon/CrossChainEnabledPolygonChild.sol @@ -59,7 +59,7 @@ abstract contract CrossChainEnabledPolygonChild is IFxMessageProcessor, CrossCha * then security could be compromised. */ function processMessageFromRoot( - uint256 /* stateId */, + uint256, /* stateId */ address rootMessageSender, bytes calldata data ) external override nonReentrant { diff --git a/contracts/finance/VestingWallet.sol b/contracts/finance/VestingWallet.sol index fe67eb54ff6..0feac4ac6ab 100644 --- a/contracts/finance/VestingWallet.sol +++ b/contracts/finance/VestingWallet.sol @@ -29,7 +29,11 @@ contract VestingWallet is Context { /** * @dev Set the beneficiary, start timestamp and vesting duration of the vesting wallet. */ - constructor(address beneficiaryAddress, uint64 startTimestamp, uint64 durationSeconds) payable { + constructor( + address beneficiaryAddress, + uint64 startTimestamp, + uint64 durationSeconds + ) payable { require(beneficiaryAddress != address(0), "VestingWallet: beneficiary is zero address"); _beneficiary = beneficiaryAddress; _start = startTimestamp; diff --git a/contracts/governance/Governor.sol b/contracts/governance/Governor.sol index 8235fb5ecb1..84b3128ff0c 100644 --- a/contracts/governance/Governor.sol +++ b/contracts/governance/Governor.sol @@ -314,7 +314,7 @@ abstract contract Governor is Context, ERC165, EIP712, IGovernor, IERC721Receive * @dev Internal execution mechanism. Can be overridden to implement different execution mechanism */ function _execute( - uint256 /* proposalId */, + uint256, /* proposalId */ address[] memory targets, uint256[] memory values, bytes[] memory calldatas, @@ -331,9 +331,9 @@ abstract contract Governor is Context, ERC165, EIP712, IGovernor, IERC721Receive * @dev Hook before execution is triggered. */ function _beforeExecute( - uint256 /* proposalId */, + uint256, /* proposalId */ address[] memory targets, - uint256[] memory /* values */, + uint256[] memory, /* values */ bytes[] memory calldatas, bytes32 /*descriptionHash*/ ) internal virtual { @@ -350,10 +350,10 @@ abstract contract Governor is Context, ERC165, EIP712, IGovernor, IERC721Receive * @dev Hook after execution is triggered. */ function _afterExecute( - uint256 /* proposalId */, - address[] memory /* targets */, - uint256[] memory /* values */, - bytes[] memory /* calldatas */, + uint256, /* proposalId */ + address[] memory, /* targets */ + uint256[] memory, /* values */ + bytes[] memory, /* calldatas */ bytes32 /*descriptionHash*/ ) internal virtual { if (_executor() != address(this)) { @@ -540,7 +540,11 @@ abstract contract Governor is Context, ERC165, EIP712, IGovernor, IERC721Receive * in a governance proposal to recover tokens or Ether that was sent to the governor contract by mistake. * Note that if the executor is simply the governor itself, use of `relay` is redundant. */ - function relay(address target, uint256 value, bytes calldata data) external payable virtual onlyGovernance { + function relay( + address target, + uint256 value, + bytes calldata data + ) external payable virtual onlyGovernance { (bool success, bytes memory returndata) = target.call{value: value}(data); Address.verifyCallResult(success, returndata, "Governor: relay reverted without message"); } @@ -556,7 +560,12 @@ abstract contract Governor is Context, ERC165, EIP712, IGovernor, IERC721Receive /** * @dev See {IERC721Receiver-onERC721Received}. */ - function onERC721Received(address, address, uint256, bytes memory) public virtual override returns (bytes4) { + function onERC721Received( + address, + address, + uint256, + bytes memory + ) public virtual override returns (bytes4) { return this.onERC721Received.selector; } diff --git a/contracts/governance/TimelockController.sol b/contracts/governance/TimelockController.sol index 67e6d206c2d..43eedd23468 100644 --- a/contracts/governance/TimelockController.sol +++ b/contracts/governance/TimelockController.sol @@ -73,7 +73,12 @@ contract TimelockController is AccessControl, IERC721Receiver, IERC1155Receiver * administration through timelocked proposals. Previous versions of this contract would assign * this admin to the deployer automatically and should be renounced as well. */ - constructor(uint256 minDelay, address[] memory proposers, address[] memory executors, address admin) { + constructor( + uint256 minDelay, + address[] memory proposers, + address[] memory executors, + address admin + ) { // self administration _grantRole(DEFAULT_ADMIN_ROLE, address(this)); @@ -331,7 +336,11 @@ contract TimelockController is AccessControl, IERC721Receiver, IERC1155Receiver /** * @dev Execute an operation's call. */ - function _execute(address target, uint256 value, bytes calldata data) internal virtual { + function _execute( + address target, + uint256 value, + bytes calldata data + ) internal virtual { (bool success, ) = target.call{value: value}(data); require(success, "TimelockController: underlying transaction reverted"); } @@ -371,7 +380,12 @@ contract TimelockController is AccessControl, IERC721Receiver, IERC1155Receiver /** * @dev See {IERC721Receiver-onERC721Received}. */ - function onERC721Received(address, address, uint256, bytes memory) public virtual override returns (bytes4) { + function onERC721Received( + address, + address, + uint256, + bytes memory + ) public virtual override returns (bytes4) { return this.onERC721Received.selector; } diff --git a/contracts/governance/compatibility/GovernorCompatibilityBravo.sol b/contracts/governance/compatibility/GovernorCompatibilityBravo.sol index 8d74742c5bb..8d96be7d676 100644 --- a/contracts/governance/compatibility/GovernorCompatibilityBravo.sol +++ b/contracts/governance/compatibility/GovernorCompatibilityBravo.sol @@ -118,10 +118,11 @@ abstract contract GovernorCompatibilityBravo is IGovernorTimelock, IGovernorComp /** * @dev Encodes calldatas with optional function signature. */ - function _encodeCalldata( - string[] memory signatures, - bytes[] memory calldatas - ) private pure returns (bytes[] memory) { + function _encodeCalldata(string[] memory signatures, bytes[] memory calldatas) + private + pure + returns (bytes[] memory) + { bytes[] memory fullcalldatas = new bytes[](calldatas.length); for (uint256 i = 0; i < signatures.length; ++i) { @@ -162,9 +163,7 @@ abstract contract GovernorCompatibilityBravo is IGovernorTimelock, IGovernorComp /** * @dev See {IGovernorCompatibilityBravo-proposals}. */ - function proposals( - uint256 proposalId - ) + function proposals(uint256 proposalId) public view virtual @@ -201,9 +200,7 @@ abstract contract GovernorCompatibilityBravo is IGovernorTimelock, IGovernorComp /** * @dev See {IGovernorCompatibilityBravo-getActions}. */ - function getActions( - uint256 proposalId - ) + function getActions(uint256 proposalId) public view virtual diff --git a/contracts/governance/compatibility/IGovernorCompatibilityBravo.sol b/contracts/governance/compatibility/IGovernorCompatibilityBravo.sol index d1ec0337d00..83e4e1ae9c0 100644 --- a/contracts/governance/compatibility/IGovernorCompatibilityBravo.sol +++ b/contracts/governance/compatibility/IGovernorCompatibilityBravo.sol @@ -50,9 +50,7 @@ abstract contract IGovernorCompatibilityBravo is IGovernor { /** * @dev Part of the Governor Bravo's interface: _"The official record of all proposals ever proposed"_. */ - function proposals( - uint256 - ) + function proposals(uint256) public view virtual @@ -98,9 +96,7 @@ abstract contract IGovernorCompatibilityBravo is IGovernor { /** * @dev Part of the Governor Bravo's interface: _"Gets actions of a proposal"_. */ - function getActions( - uint256 proposalId - ) + function getActions(uint256 proposalId) public view virtual diff --git a/contracts/governance/extensions/GovernorCountingSimple.sol b/contracts/governance/extensions/GovernorCountingSimple.sol index f3eea9d7fa4..5611fc6692c 100644 --- a/contracts/governance/extensions/GovernorCountingSimple.sol +++ b/contracts/governance/extensions/GovernorCountingSimple.sol @@ -47,9 +47,16 @@ abstract contract GovernorCountingSimple is Governor { /** * @dev Accessor to the internal vote counts. */ - function proposalVotes( - uint256 proposalId - ) public view virtual returns (uint256 againstVotes, uint256 forVotes, uint256 abstainVotes) { + function proposalVotes(uint256 proposalId) + public + view + virtual + returns ( + uint256 againstVotes, + uint256 forVotes, + uint256 abstainVotes + ) + { ProposalVote storage proposalVote = _proposalVotes[proposalId]; return (proposalVote.againstVotes, proposalVote.forVotes, proposalVote.abstainVotes); } diff --git a/contracts/governance/extensions/GovernorSettings.sol b/contracts/governance/extensions/GovernorSettings.sol index 527f41cd8a8..a3187c6e16e 100644 --- a/contracts/governance/extensions/GovernorSettings.sol +++ b/contracts/governance/extensions/GovernorSettings.sol @@ -22,7 +22,11 @@ abstract contract GovernorSettings is Governor { /** * @dev Initialize the governance parameters. */ - constructor(uint256 initialVotingDelay, uint256 initialVotingPeriod, uint256 initialProposalThreshold) { + constructor( + uint256 initialVotingDelay, + uint256 initialVotingPeriod, + uint256 initialProposalThreshold + ) { _setVotingDelay(initialVotingDelay); _setVotingPeriod(initialVotingPeriod); _setProposalThreshold(initialProposalThreshold); diff --git a/contracts/governance/extensions/GovernorTimelockControl.sol b/contracts/governance/extensions/GovernorTimelockControl.sol index 6aa2556abf1..aaeaf940926 100644 --- a/contracts/governance/extensions/GovernorTimelockControl.sol +++ b/contracts/governance/extensions/GovernorTimelockControl.sol @@ -110,7 +110,7 @@ abstract contract GovernorTimelockControl is IGovernorTimelock, Governor { * @dev Overridden execute function that run the already queued proposal through the timelock. */ function _execute( - uint256 /* proposalId */, + uint256, /* proposalId */ address[] memory targets, uint256[] memory values, bytes[] memory calldatas, diff --git a/contracts/governance/utils/IVotes.sol b/contracts/governance/utils/IVotes.sol index 0bef3f92079..6317d7752e0 100644 --- a/contracts/governance/utils/IVotes.sol +++ b/contracts/governance/utils/IVotes.sol @@ -50,5 +50,12 @@ interface IVotes { /** * @dev Delegates votes from signer to `delegatee`. */ - function delegateBySig(address delegatee, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s) external; + function delegateBySig( + address delegatee, + uint256 nonce, + uint256 expiry, + uint8 v, + bytes32 r, + bytes32 s + ) external; } diff --git a/contracts/governance/utils/Votes.sol b/contracts/governance/utils/Votes.sol index 492c1afb157..801be3bcd32 100644 --- a/contracts/governance/utils/Votes.sol +++ b/contracts/governance/utils/Votes.sol @@ -134,7 +134,11 @@ abstract contract Votes is IVotes, Context, EIP712, Nonces { * @dev Transfers, mints, or burns voting units. To register a mint, `from` should be zero. To register a burn, `to` * should be zero. Total supply of voting units will be adjusted with mints and burns. */ - function _transferVotingUnits(address from, address to, uint256 amount) internal virtual { + function _transferVotingUnits( + address from, + address to, + uint256 amount + ) internal virtual { if (from == address(0)) { _totalCheckpoints.push(_add, amount); } @@ -147,7 +151,11 @@ abstract contract Votes is IVotes, Context, EIP712, Nonces { /** * @dev Moves delegated votes from one delegate to another. */ - function _moveDelegateVotes(address from, address to, uint256 amount) private { + function _moveDelegateVotes( + address from, + address to, + uint256 amount + ) private { if (from != to && amount > 0) { if (from != address(0)) { (uint256 oldValue, uint256 newValue) = _delegateCheckpoints[from].push(_subtract, amount); diff --git a/contracts/interfaces/IERC1363.sol b/contracts/interfaces/IERC1363.sol index 1a8dc79f438..5fad104c223 100644 --- a/contracts/interfaces/IERC1363.sol +++ b/contracts/interfaces/IERC1363.sol @@ -38,7 +38,11 @@ interface IERC1363 is IERC165, IERC20 { * @param data bytes Additional data with no specified format, sent in call to `to` * @return true unless throwing */ - function transferAndCall(address to, uint256 value, bytes memory data) external returns (bool); + function transferAndCall( + address to, + uint256 value, + bytes memory data + ) external returns (bool); /** * @dev Transfer tokens from one address to another and then call `onTransferReceived` on receiver @@ -47,7 +51,11 @@ interface IERC1363 is IERC165, IERC20 { * @param value uint256 The amount of tokens to be transferred * @return true unless throwing */ - function transferFromAndCall(address from, address to, uint256 value) external returns (bool); + function transferFromAndCall( + address from, + address to, + uint256 value + ) external returns (bool); /** * @dev Transfer tokens from one address to another and then call `onTransferReceived` on receiver @@ -57,7 +65,12 @@ interface IERC1363 is IERC165, IERC20 { * @param data bytes Additional data with no specified format, sent in call to `to` * @return true unless throwing */ - function transferFromAndCall(address from, address to, uint256 value, bytes memory data) external returns (bool); + function transferFromAndCall( + address from, + address to, + uint256 value, + bytes memory data + ) external returns (bool); /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender @@ -74,5 +87,9 @@ interface IERC1363 is IERC165, IERC20 { * @param value uint256 The amount of tokens to be spent * @param data bytes Additional data with no specified format, sent in call to `spender` */ - function approveAndCall(address spender, uint256 value, bytes memory data) external returns (bool); + function approveAndCall( + address spender, + uint256 value, + bytes memory data + ) external returns (bool); } diff --git a/contracts/interfaces/IERC1363Spender.sol b/contracts/interfaces/IERC1363Spender.sol index 28775e1406b..48f6fd56d6d 100644 --- a/contracts/interfaces/IERC1363Spender.sol +++ b/contracts/interfaces/IERC1363Spender.sol @@ -22,5 +22,9 @@ interface IERC1363Spender { * @return `bytes4(keccak256("onApprovalReceived(address,uint256,bytes)"))` * unless throwing */ - function onApprovalReceived(address owner, uint256 value, bytes memory data) external returns (bytes4); + function onApprovalReceived( + address owner, + uint256 value, + bytes memory data + ) external returns (bytes4); } diff --git a/contracts/interfaces/IERC2981.sol b/contracts/interfaces/IERC2981.sol index 1c9448a9147..6b0558169ea 100644 --- a/contracts/interfaces/IERC2981.sol +++ b/contracts/interfaces/IERC2981.sol @@ -18,8 +18,8 @@ interface IERC2981 is IERC165 { * @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of * exchange. The royalty amount is denominated and should be paid in that same unit of exchange. */ - function royaltyInfo( - uint256 tokenId, - uint256 salePrice - ) external view returns (address receiver, uint256 royaltyAmount); + function royaltyInfo(uint256 tokenId, uint256 salePrice) + external + view + returns (address receiver, uint256 royaltyAmount); } diff --git a/contracts/interfaces/IERC4626.sol b/contracts/interfaces/IERC4626.sol index 08e5de7176b..f7c5397a0fa 100644 --- a/contracts/interfaces/IERC4626.sol +++ b/contracts/interfaces/IERC4626.sol @@ -187,7 +187,11 @@ interface IERC4626 is IERC20, IERC20Metadata { * Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed. * Those methods should be performed separately. */ - function withdraw(uint256 assets, address receiver, address owner) external returns (uint256 shares); + function withdraw( + uint256 assets, + address receiver, + address owner + ) external returns (uint256 shares); /** * @dev Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault, @@ -228,5 +232,9 @@ interface IERC4626 is IERC20, IERC20Metadata { * NOTE: some implementations will require pre-requesting to the Vault before a withdrawal may be performed. * Those methods should be performed separately. */ - function redeem(uint256 shares, address receiver, address owner) external returns (uint256 assets); + function redeem( + uint256 shares, + address receiver, + address owner + ) external returns (uint256 assets); } diff --git a/contracts/metatx/MinimalForwarder.sol b/contracts/metatx/MinimalForwarder.sol index 9298ae6751c..bb49c794dbb 100644 --- a/contracts/metatx/MinimalForwarder.sol +++ b/contracts/metatx/MinimalForwarder.sol @@ -44,10 +44,11 @@ contract MinimalForwarder is EIP712 { return _nonces[req.from] == req.nonce && signer == req.from; } - function execute( - ForwardRequest calldata req, - bytes calldata signature - ) public payable returns (bool, bytes memory) { + function execute(ForwardRequest calldata req, bytes calldata signature) + public + payable + returns (bool, bytes memory) + { require(verify(req, signature), "MinimalForwarder: signature does not match request"); _nonces[req.from] = req.nonce + 1; diff --git a/contracts/mocks/AddressImpl.sol b/contracts/mocks/AddressImpl.sol index b06bec37284..702093c7337 100644 --- a/contracts/mocks/AddressImpl.sol +++ b/contracts/mocks/AddressImpl.sol @@ -22,7 +22,11 @@ contract AddressImpl { emit CallReturnValue(abi.decode(returnData, (string))); } - function functionCallWithValue(address target, bytes calldata data, uint256 value) external payable { + function functionCallWithValue( + address target, + bytes calldata data, + uint256 value + ) external payable { bytes memory returnData = Address.functionCallWithValue(target, data, value); emit CallReturnValue(abi.decode(returnData, (string))); } diff --git a/contracts/mocks/CheckpointsMock.sol b/contracts/mocks/CheckpointsMock.sol index 874a1d1f213..f1dadabaf7d 100644 --- a/contracts/mocks/CheckpointsMock.sol +++ b/contracts/mocks/CheckpointsMock.sol @@ -14,7 +14,15 @@ contract CheckpointsMock { return _totalCheckpoints.latest(); } - function latestCheckpoint() public view returns (bool, uint256, uint256) { + function latestCheckpoint() + public + view + returns ( + bool, + uint256, + uint256 + ) + { return _totalCheckpoints.latestCheckpoint(); } @@ -44,7 +52,15 @@ contract Checkpoints224Mock { return _totalCheckpoints.latest(); } - function latestCheckpoint() public view returns (bool, uint32, uint224) { + function latestCheckpoint() + public + view + returns ( + bool, + uint32, + uint224 + ) + { return _totalCheckpoints.latestCheckpoint(); } @@ -74,7 +90,15 @@ contract Checkpoints160Mock { return _totalCheckpoints.latest(); } - function latestCheckpoint() public view returns (bool, uint96, uint160) { + function latestCheckpoint() + public + view + returns ( + bool, + uint96, + uint160 + ) + { return _totalCheckpoints.latestCheckpoint(); } diff --git a/contracts/mocks/ClonesMock.sol b/contracts/mocks/ClonesMock.sol index c65d30cc3b0..3719b0a7835 100644 --- a/contracts/mocks/ClonesMock.sol +++ b/contracts/mocks/ClonesMock.sol @@ -15,7 +15,11 @@ contract ClonesMock { _initAndEmit(implementation.clone(), initdata); } - function cloneDeterministic(address implementation, bytes32 salt, bytes calldata initdata) public payable { + function cloneDeterministic( + address implementation, + bytes32 salt, + bytes calldata initdata + ) public payable { _initAndEmit(implementation.cloneDeterministic(salt), initdata); } diff --git a/contracts/mocks/ContextMock.sol b/contracts/mocks/ContextMock.sol index 7759f350639..f17af38a49a 100644 --- a/contracts/mocks/ContextMock.sol +++ b/contracts/mocks/ContextMock.sol @@ -23,7 +23,11 @@ contract ContextMockCaller { context.msgSender(); } - function callData(ContextMock context, uint256 integerValue, string memory stringValue) public { + function callData( + ContextMock context, + uint256 integerValue, + string memory stringValue + ) public { context.msgData(integerValue, stringValue); } } diff --git a/contracts/mocks/Create2Impl.sol b/contracts/mocks/Create2Impl.sol index 6b2f4b712e5..070ad3671c5 100644 --- a/contracts/mocks/Create2Impl.sol +++ b/contracts/mocks/Create2Impl.sol @@ -6,7 +6,11 @@ import "../utils/Create2.sol"; import "../utils/introspection/ERC1820Implementer.sol"; contract Create2Impl { - function deploy(uint256 value, bytes32 salt, bytes memory code) public { + function deploy( + uint256 value, + bytes32 salt, + bytes memory code + ) public { Create2.deploy(value, salt, code); } diff --git a/contracts/mocks/DummyImplementation.sol b/contracts/mocks/DummyImplementation.sol index ddcca660439..d8651340d1b 100644 --- a/contracts/mocks/DummyImplementation.sol +++ b/contracts/mocks/DummyImplementation.sol @@ -27,7 +27,11 @@ contract DummyImplementation { value = _value; } - function initialize(uint256 _value, string memory _text, uint256[] memory _values) public { + function initialize( + uint256 _value, + string memory _text, + uint256[] memory _values + ) public { value = _value; text = _text; values = _values; diff --git a/contracts/mocks/ECDSAMock.sol b/contracts/mocks/ECDSAMock.sol index cfc37d26ea6..97bd46669a6 100644 --- a/contracts/mocks/ECDSAMock.sol +++ b/contracts/mocks/ECDSAMock.sol @@ -13,12 +13,21 @@ contract ECDSAMock { } // solhint-disable-next-line func-name-mixedcase - function recover_v_r_s(bytes32 hash, uint8 v, bytes32 r, bytes32 s) public pure returns (address) { + function recover_v_r_s( + bytes32 hash, + uint8 v, + bytes32 r, + bytes32 s + ) public pure returns (address) { return hash.recover(v, r, s); } // solhint-disable-next-line func-name-mixedcase - function recover_r_vs(bytes32 hash, bytes32 r, bytes32 vs) public pure returns (address) { + function recover_r_vs( + bytes32 hash, + bytes32 r, + bytes32 vs + ) public pure returns (address) { return hash.recover(r, vs); } diff --git a/contracts/mocks/EIP712External.sol b/contracts/mocks/EIP712External.sol index bc5b1269f7c..93f77d54946 100644 --- a/contracts/mocks/EIP712External.sol +++ b/contracts/mocks/EIP712External.sol @@ -12,7 +12,12 @@ contract EIP712External is EIP712 { return _domainSeparatorV4(); } - function verify(bytes memory signature, address signer, address mailTo, string memory mailContents) external view { + function verify( + bytes memory signature, + address signer, + address mailTo, + string memory mailContents + ) external view { bytes32 digest = _hashTypedDataV4( keccak256(abi.encode(keccak256("Mail(address to,string contents)"), mailTo, keccak256(bytes(mailContents)))) ); diff --git a/contracts/mocks/ERC1155BurnableMock.sol b/contracts/mocks/ERC1155BurnableMock.sol index 3334523cf74..62138f28da6 100644 --- a/contracts/mocks/ERC1155BurnableMock.sol +++ b/contracts/mocks/ERC1155BurnableMock.sol @@ -7,7 +7,12 @@ import "../token/ERC1155/extensions/ERC1155Burnable.sol"; contract ERC1155BurnableMock is ERC1155Burnable { constructor(string memory uri) ERC1155(uri) {} - function mint(address to, uint256 id, uint256 value, bytes memory data) public { + function mint( + address to, + uint256 id, + uint256 value, + bytes memory data + ) public { _mint(to, id, value, data); } } diff --git a/contracts/mocks/ERC1155Mock.sol b/contracts/mocks/ERC1155Mock.sol index 6bfc86ceaf3..0518ac26c17 100644 --- a/contracts/mocks/ERC1155Mock.sol +++ b/contracts/mocks/ERC1155Mock.sol @@ -15,19 +15,37 @@ contract ERC1155Mock is ERC1155 { _setURI(newuri); } - function mint(address to, uint256 id, uint256 value, bytes memory data) public { + function mint( + address to, + uint256 id, + uint256 value, + bytes memory data + ) public { _mint(to, id, value, data); } - function mintBatch(address to, uint256[] memory ids, uint256[] memory values, bytes memory data) public { + function mintBatch( + address to, + uint256[] memory ids, + uint256[] memory values, + bytes memory data + ) public { _mintBatch(to, ids, values, data); } - function burn(address owner, uint256 id, uint256 value) public { + function burn( + address owner, + uint256 id, + uint256 value + ) public { _burn(owner, id, value); } - function burnBatch(address owner, uint256[] memory ids, uint256[] memory values) public { + function burnBatch( + address owner, + uint256[] memory ids, + uint256[] memory values + ) public { _burnBatch(owner, ids, values); } } diff --git a/contracts/mocks/ERC1155ReceiverMock.sol b/contracts/mocks/ERC1155ReceiverMock.sol index b2d505c0a86..6443a56c7ae 100644 --- a/contracts/mocks/ERC1155ReceiverMock.sol +++ b/contracts/mocks/ERC1155ReceiverMock.sol @@ -14,7 +14,12 @@ contract ERC1155ReceiverMock is ERC165, IERC1155Receiver { event Received(address operator, address from, uint256 id, uint256 value, bytes data, uint256 gas); event BatchReceived(address operator, address from, uint256[] ids, uint256[] values, bytes data, uint256 gas); - constructor(bytes4 recRetval, bool recReverts, bytes4 batRetval, bool batReverts) { + constructor( + bytes4 recRetval, + bool recReverts, + bytes4 batRetval, + bool batReverts + ) { _recRetval = recRetval; _recReverts = recReverts; _batRetval = batRetval; diff --git a/contracts/mocks/ERC20CappedMock.sol b/contracts/mocks/ERC20CappedMock.sol index e69aadfdf30..edb36f20531 100644 --- a/contracts/mocks/ERC20CappedMock.sol +++ b/contracts/mocks/ERC20CappedMock.sol @@ -5,7 +5,11 @@ pragma solidity ^0.8.0; import "../token/ERC20/extensions/ERC20Capped.sol"; contract ERC20CappedMock is ERC20Capped { - constructor(string memory name, string memory symbol, uint256 cap) ERC20(name, symbol) ERC20Capped(cap) {} + constructor( + string memory name, + string memory symbol, + uint256 cap + ) ERC20(name, symbol) ERC20Capped(cap) {} function mint(address to, uint256 tokenId) public { _mint(to, tokenId); diff --git a/contracts/mocks/ERC20DecimalsMock.sol b/contracts/mocks/ERC20DecimalsMock.sol index 7677e9dd1d1..3721f6c393b 100644 --- a/contracts/mocks/ERC20DecimalsMock.sol +++ b/contracts/mocks/ERC20DecimalsMock.sol @@ -7,7 +7,11 @@ import "../token/ERC20/ERC20.sol"; contract ERC20DecimalsMock is ERC20 { uint8 private immutable _decimals; - constructor(string memory name_, string memory symbol_, uint8 decimals_) ERC20(name_, symbol_) { + constructor( + string memory name_, + string memory symbol_, + uint8 decimals_ + ) ERC20(name_, symbol_) { _decimals = decimals_; } diff --git a/contracts/mocks/ERC20Mock.sol b/contracts/mocks/ERC20Mock.sol index 16ffad19fe5..fd7f991baf0 100644 --- a/contracts/mocks/ERC20Mock.sol +++ b/contracts/mocks/ERC20Mock.sol @@ -23,11 +23,19 @@ contract ERC20Mock is ERC20 { _burn(account, amount); } - function transferInternal(address from, address to, uint256 value) public { + function transferInternal( + address from, + address to, + uint256 value + ) public { _transfer(from, to, value); } - function approveInternal(address owner, address spender, uint256 value) public { + function approveInternal( + address owner, + address spender, + uint256 value + ) public { _approve(owner, spender, value); } } diff --git a/contracts/mocks/ERC3156FlashBorrowerMock.sol b/contracts/mocks/ERC3156FlashBorrowerMock.sol index 6a4410fcb1d..288a278fb80 100644 --- a/contracts/mocks/ERC3156FlashBorrowerMock.sol +++ b/contracts/mocks/ERC3156FlashBorrowerMock.sol @@ -28,7 +28,7 @@ contract ERC3156FlashBorrowerMock is IERC3156FlashBorrower { } function onFlashLoan( - address /*initiator*/, + address, /*initiator*/ address token, uint256 amount, uint256 fee, diff --git a/contracts/mocks/ERC4626Mock.sol b/contracts/mocks/ERC4626Mock.sol index 9c13346f059..4f80b4bd75b 100644 --- a/contracts/mocks/ERC4626Mock.sol +++ b/contracts/mocks/ERC4626Mock.sol @@ -5,7 +5,11 @@ pragma solidity ^0.8.0; import "../token/ERC20/extensions/ERC4626.sol"; contract ERC4626Mock is ERC4626 { - constructor(IERC20Metadata asset, string memory name, string memory symbol) ERC20(name, symbol) ERC4626(asset) {} + constructor( + IERC20Metadata asset, + string memory name, + string memory symbol + ) ERC20(name, symbol) ERC4626(asset) {} function mockMint(address account, uint256 amount) public { _mint(account, amount); @@ -34,17 +38,23 @@ contract ERC4626DecimalMock is ERC4626Mock { return _decimals; } - function _initialConvertToShares( - uint256 assets, - Math.Rounding rounding - ) internal view virtual override returns (uint256 shares) { - return assets.mulDiv(10 ** decimals(), 10 ** super.decimals(), rounding); + function _initialConvertToShares(uint256 assets, Math.Rounding rounding) + internal + view + virtual + override + returns (uint256 shares) + { + return assets.mulDiv(10**decimals(), 10**super.decimals(), rounding); } - function _initialConvertToAssets( - uint256 shares, - Math.Rounding rounding - ) internal view virtual override returns (uint256 assets) { - return shares.mulDiv(10 ** super.decimals(), 10 ** decimals(), rounding); + function _initialConvertToAssets(uint256 shares, Math.Rounding rounding) + internal + view + virtual + override + returns (uint256 assets) + { + return shares.mulDiv(10**super.decimals(), 10**decimals(), rounding); } } diff --git a/contracts/mocks/ERC721BurnableMock.sol b/contracts/mocks/ERC721BurnableMock.sol index ecf42768182..b30dbf53dfb 100644 --- a/contracts/mocks/ERC721BurnableMock.sol +++ b/contracts/mocks/ERC721BurnableMock.sol @@ -19,7 +19,11 @@ contract ERC721BurnableMock is ERC721Burnable { _safeMint(to, tokenId); } - function safeMint(address to, uint256 tokenId, bytes memory _data) public { + function safeMint( + address to, + uint256 tokenId, + bytes memory _data + ) public { _safeMint(to, tokenId, _data); } } diff --git a/contracts/mocks/ERC721ConsecutiveEnumerableMock.sol b/contracts/mocks/ERC721ConsecutiveEnumerableMock.sol index f4f5c5832be..cde3bd86cff 100644 --- a/contracts/mocks/ERC721ConsecutiveEnumerableMock.sol +++ b/contracts/mocks/ERC721ConsecutiveEnumerableMock.sol @@ -17,9 +17,13 @@ contract ERC721ConsecutiveEnumerableMock is ERC721Consecutive, ERC721Enumerable } } - function supportsInterface( - bytes4 interfaceId - ) public view virtual override(ERC721, ERC721Enumerable) returns (bool) { + function supportsInterface(bytes4 interfaceId) + public + view + virtual + override(ERC721, ERC721Enumerable) + returns (bool) + { return super.supportsInterface(interfaceId); } diff --git a/contracts/mocks/ERC721EnumerableMock.sol b/contracts/mocks/ERC721EnumerableMock.sol index b7ea94ee3f2..a747925e69d 100644 --- a/contracts/mocks/ERC721EnumerableMock.sol +++ b/contracts/mocks/ERC721EnumerableMock.sol @@ -37,7 +37,11 @@ contract ERC721EnumerableMock is ERC721Enumerable { _safeMint(to, tokenId); } - function safeMint(address to, uint256 tokenId, bytes memory _data) public { + function safeMint( + address to, + uint256 tokenId, + bytes memory _data + ) public { _safeMint(to, tokenId, _data); } diff --git a/contracts/mocks/ERC721Mock.sol b/contracts/mocks/ERC721Mock.sol index a3bc839ae7b..74a09233469 100644 --- a/contracts/mocks/ERC721Mock.sol +++ b/contracts/mocks/ERC721Mock.sol @@ -27,7 +27,11 @@ contract ERC721Mock is ERC721 { _safeMint(to, tokenId); } - function safeMint(address to, uint256 tokenId, bytes memory _data) public { + function safeMint( + address to, + uint256 tokenId, + bytes memory _data + ) public { _safeMint(to, tokenId, _data); } diff --git a/contracts/mocks/ERC721PausableMock.sol b/contracts/mocks/ERC721PausableMock.sol index 753842e902b..8d8e818fb17 100644 --- a/contracts/mocks/ERC721PausableMock.sol +++ b/contracts/mocks/ERC721PausableMock.sol @@ -31,7 +31,11 @@ contract ERC721PausableMock is ERC721Pausable { _safeMint(to, tokenId); } - function safeMint(address to, uint256 tokenId, bytes memory _data) public { + function safeMint( + address to, + uint256 tokenId, + bytes memory _data + ) public { _safeMint(to, tokenId, _data); } diff --git a/contracts/mocks/ERC721RoyaltyMock.sol b/contracts/mocks/ERC721RoyaltyMock.sol index 6f19d5248d2..83a9074e2c1 100644 --- a/contracts/mocks/ERC721RoyaltyMock.sol +++ b/contracts/mocks/ERC721RoyaltyMock.sol @@ -7,7 +7,11 @@ import "../token/ERC721/extensions/ERC721Royalty.sol"; contract ERC721RoyaltyMock is ERC721Royalty { constructor(string memory name, string memory symbol) ERC721(name, symbol) {} - function setTokenRoyalty(uint256 tokenId, address recipient, uint96 fraction) public { + function setTokenRoyalty( + uint256 tokenId, + address recipient, + uint96 fraction + ) public { _setTokenRoyalty(tokenId, recipient, fraction); } diff --git a/contracts/mocks/ERC721URIStorageMock.sol b/contracts/mocks/ERC721URIStorageMock.sol index 4bb26b1ada7..60f9f7b7c1a 100644 --- a/contracts/mocks/ERC721URIStorageMock.sol +++ b/contracts/mocks/ERC721URIStorageMock.sol @@ -41,7 +41,11 @@ contract ERC721URIStorageMock is ERC721URIStorage { _safeMint(to, tokenId); } - function safeMint(address to, uint256 tokenId, bytes memory _data) public { + function safeMint( + address to, + uint256 tokenId, + bytes memory _data + ) public { _safeMint(to, tokenId, _data); } diff --git a/contracts/mocks/ERC777Mock.sol b/contracts/mocks/ERC777Mock.sol index 59c00b30756..f8a3b67849d 100644 --- a/contracts/mocks/ERC777Mock.sol +++ b/contracts/mocks/ERC777Mock.sol @@ -18,7 +18,12 @@ contract ERC777Mock is Context, ERC777 { _mint(initialHolder, initialBalance, "", ""); } - function mintInternal(address to, uint256 amount, bytes memory userData, bytes memory operatorData) public { + function mintInternal( + address to, + uint256 amount, + bytes memory userData, + bytes memory operatorData + ) public { _mint(to, amount, userData, operatorData); } @@ -32,11 +37,20 @@ contract ERC777Mock is Context, ERC777 { _mint(to, amount, userData, operatorData, requireReceptionAck); } - function approveInternal(address holder, address spender, uint256 value) public { + function approveInternal( + address holder, + address spender, + uint256 value + ) public { _approve(holder, spender, value); } - function _beforeTokenTransfer(address, address, address, uint256) internal override { + function _beforeTokenTransfer( + address, + address, + address, + uint256 + ) internal override { emit BeforeTokenTransfer(); } } diff --git a/contracts/mocks/ERC777SenderRecipientMock.sol b/contracts/mocks/ERC777SenderRecipientMock.sol index 8e8c749ceda..169912f699b 100644 --- a/contracts/mocks/ERC777SenderRecipientMock.sol +++ b/contracts/mocks/ERC777SenderRecipientMock.sol @@ -141,12 +141,21 @@ contract ERC777SenderRecipientMock is Context, IERC777Sender, IERC777Recipient, _shouldRevertReceive = shouldRevert; } - function send(IERC777 token, address to, uint256 amount, bytes memory data) public { + function send( + IERC777 token, + address to, + uint256 amount, + bytes memory data + ) public { // This is 777's send function, not the Solidity send function token.send(to, amount, data); // solhint-disable-line check-send-result } - function burn(IERC777 token, uint256 amount, bytes memory data) public { + function burn( + IERC777 token, + uint256 amount, + bytes memory data + ) public { token.burn(amount, data); } } diff --git a/contracts/mocks/GovernorCompatibilityBravoMock.sol b/contracts/mocks/GovernorCompatibilityBravoMock.sol index d3b4f707d16..1ef0f94b92e 100644 --- a/contracts/mocks/GovernorCompatibilityBravoMock.sol +++ b/contracts/mocks/GovernorCompatibilityBravoMock.sol @@ -27,9 +27,12 @@ contract GovernorCompatibilityBravoMock is GovernorVotesComp(token_) {} - function supportsInterface( - bytes4 interfaceId - ) public view override(IERC165, Governor, GovernorTimelockCompound) returns (bool) { + function supportsInterface(bytes4 interfaceId) + public + view + override(IERC165, Governor, GovernorTimelockCompound) + returns (bool) + { return super.supportsInterface(interfaceId); } @@ -37,15 +40,21 @@ contract GovernorCompatibilityBravoMock is return 0; } - function state( - uint256 proposalId - ) public view override(IGovernor, Governor, GovernorTimelockCompound) returns (ProposalState) { + function state(uint256 proposalId) + public + view + override(IGovernor, Governor, GovernorTimelockCompound) + returns (ProposalState) + { return super.state(proposalId); } - function proposalEta( - uint256 proposalId - ) public view override(IGovernorTimelock, GovernorTimelockCompound) returns (uint256) { + function proposalEta(uint256 proposalId) + public + view + override(IGovernorTimelock, GovernorTimelockCompound) + returns (uint256) + { return super.proposalEta(proposalId); } diff --git a/contracts/mocks/GovernorPreventLateQuorumMock.sol b/contracts/mocks/GovernorPreventLateQuorumMock.sol index b6b5e761970..d868ab22b62 100644 --- a/contracts/mocks/GovernorPreventLateQuorumMock.sol +++ b/contracts/mocks/GovernorPreventLateQuorumMock.sol @@ -35,9 +35,12 @@ contract GovernorPreventLateQuorumMock is return _quorum; } - function proposalDeadline( - uint256 proposalId - ) public view override(Governor, GovernorPreventLateQuorum) returns (uint256) { + function proposalDeadline(uint256 proposalId) + public + view + override(Governor, GovernorPreventLateQuorum) + returns (uint256) + { return super.proposalDeadline(proposalId); } diff --git a/contracts/mocks/GovernorTimelockCompoundMock.sol b/contracts/mocks/GovernorTimelockCompoundMock.sol index 75a2f3c144c..becc72a06ef 100644 --- a/contracts/mocks/GovernorTimelockCompoundMock.sol +++ b/contracts/mocks/GovernorTimelockCompoundMock.sol @@ -28,15 +28,21 @@ contract GovernorTimelockCompoundMock is GovernorVotesQuorumFraction(quorumNumerator_) {} - function supportsInterface( - bytes4 interfaceId - ) public view override(Governor, GovernorTimelockCompound) returns (bool) { + function supportsInterface(bytes4 interfaceId) + public + view + override(Governor, GovernorTimelockCompound) + returns (bool) + { return super.supportsInterface(interfaceId); } - function quorum( - uint256 blockNumber - ) public view override(IGovernor, GovernorVotesQuorumFraction) returns (uint256) { + function quorum(uint256 blockNumber) + public + view + override(IGovernor, GovernorVotesQuorumFraction) + returns (uint256) + { return super.quorum(blockNumber); } @@ -52,9 +58,12 @@ contract GovernorTimelockCompoundMock is /** * Overriding nightmare */ - function state( - uint256 proposalId - ) public view override(Governor, GovernorTimelockCompound) returns (ProposalState) { + function state(uint256 proposalId) + public + view + override(Governor, GovernorTimelockCompound) + returns (ProposalState) + { return super.state(proposalId); } diff --git a/contracts/mocks/GovernorTimelockControlMock.sol b/contracts/mocks/GovernorTimelockControlMock.sol index 671a1e0ea03..ca412d1ca60 100644 --- a/contracts/mocks/GovernorTimelockControlMock.sol +++ b/contracts/mocks/GovernorTimelockControlMock.sol @@ -28,15 +28,21 @@ contract GovernorTimelockControlMock is GovernorVotesQuorumFraction(quorumNumerator_) {} - function supportsInterface( - bytes4 interfaceId - ) public view override(Governor, GovernorTimelockControl) returns (bool) { + function supportsInterface(bytes4 interfaceId) + public + view + override(Governor, GovernorTimelockControl) + returns (bool) + { return super.supportsInterface(interfaceId); } - function quorum( - uint256 blockNumber - ) public view override(IGovernor, GovernorVotesQuorumFraction) returns (uint256) { + function quorum(uint256 blockNumber) + public + view + override(IGovernor, GovernorVotesQuorumFraction) + returns (uint256) + { return super.quorum(blockNumber); } diff --git a/contracts/mocks/MathMock.sol b/contracts/mocks/MathMock.sol index be935f91dee..c6b1e872318 100644 --- a/contracts/mocks/MathMock.sol +++ b/contracts/mocks/MathMock.sol @@ -21,7 +21,12 @@ contract MathMock { return Math.ceilDiv(a, b); } - function mulDiv(uint256 a, uint256 b, uint256 denominator, Math.Rounding direction) public pure returns (uint256) { + function mulDiv( + uint256 a, + uint256 b, + uint256 denominator, + Math.Rounding direction + ) public pure returns (uint256) { return Math.mulDiv(a, b, denominator, direction); } diff --git a/contracts/mocks/MerkleProofWrapper.sol b/contracts/mocks/MerkleProofWrapper.sol index 60741e41c03..b74459dc890 100644 --- a/contracts/mocks/MerkleProofWrapper.sol +++ b/contracts/mocks/MerkleProofWrapper.sol @@ -5,11 +5,19 @@ pragma solidity ^0.8.0; import "../utils/cryptography/MerkleProof.sol"; contract MerkleProofWrapper { - function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) public pure returns (bool) { + function verify( + bytes32[] memory proof, + bytes32 root, + bytes32 leaf + ) public pure returns (bool) { return MerkleProof.verify(proof, root, leaf); } - function verifyCalldata(bytes32[] calldata proof, bytes32 root, bytes32 leaf) public pure returns (bool) { + function verifyCalldata( + bytes32[] calldata proof, + bytes32 root, + bytes32 leaf + ) public pure returns (bool) { return MerkleProof.verifyCalldata(proof, root, leaf); } diff --git a/contracts/mocks/MultipleInheritanceInitializableMocks.sol b/contracts/mocks/MultipleInheritanceInitializableMocks.sol index b8cf9d9d5d3..f6d6440654f 100644 --- a/contracts/mocks/MultipleInheritanceInitializableMocks.sol +++ b/contracts/mocks/MultipleInheritanceInitializableMocks.sol @@ -108,7 +108,12 @@ contract SampleFather is Initializable, SampleGramps { contract SampleChild is Initializable, SampleMother, SampleFather { uint256 public child; - function initialize(uint256 _mother, string memory _gramps, uint256 _father, uint256 _child) public initializer { + function initialize( + uint256 _mother, + string memory _gramps, + uint256 _father, + uint256 _child + ) public initializer { __SampleChild_init(_mother, _gramps, _father, _child); } diff --git a/contracts/mocks/SafeERC20Helper.sol b/contracts/mocks/SafeERC20Helper.sol index 237e32041c4..98fdc644490 100644 --- a/contracts/mocks/SafeERC20Helper.sol +++ b/contracts/mocks/SafeERC20Helper.sol @@ -19,7 +19,11 @@ contract ERC20ReturnFalseMock is Context { return false; } - function transferFrom(address, address, uint256) public returns (bool) { + function transferFrom( + address, + address, + uint256 + ) public returns (bool) { _dummy = 0; return false; } @@ -47,7 +51,11 @@ contract ERC20ReturnTrueMock is Context { return true; } - function transferFrom(address, address, uint256) public returns (bool) { + function transferFrom( + address, + address, + uint256 + ) public returns (bool) { _dummy = 0; return true; } @@ -77,7 +85,11 @@ contract ERC20NoReturnMock is Context { _dummy = 0; } - function transferFrom(address, address, uint256) public { + function transferFrom( + address, + address, + uint256 + ) public { _dummy = 0; } diff --git a/contracts/mocks/SafeMathMock.sol b/contracts/mocks/SafeMathMock.sol index ef504e3ab90..3d1f4727ee5 100644 --- a/contracts/mocks/SafeMathMock.sol +++ b/contracts/mocks/SafeMathMock.sol @@ -47,15 +47,27 @@ contract SafeMathMock { return SafeMath.mod(a, b); } - function subWithMessage(uint256 a, uint256 b, string memory errorMessage) public pure returns (uint256) { + function subWithMessage( + uint256 a, + uint256 b, + string memory errorMessage + ) public pure returns (uint256) { return SafeMath.sub(a, b, errorMessage); } - function divWithMessage(uint256 a, uint256 b, string memory errorMessage) public pure returns (uint256) { + function divWithMessage( + uint256 a, + uint256 b, + string memory errorMessage + ) public pure returns (uint256) { return SafeMath.div(a, b, errorMessage); } - function modWithMessage(uint256 a, uint256 b, string memory errorMessage) public pure returns (uint256) { + function modWithMessage( + uint256 a, + uint256 b, + string memory errorMessage + ) public pure returns (uint256) { return SafeMath.mod(a, b, errorMessage); } diff --git a/contracts/mocks/SignatureCheckerMock.sol b/contracts/mocks/SignatureCheckerMock.sol index 5671540ec4a..3b399c1aeaa 100644 --- a/contracts/mocks/SignatureCheckerMock.sol +++ b/contracts/mocks/SignatureCheckerMock.sol @@ -7,7 +7,11 @@ import "../utils/cryptography/SignatureChecker.sol"; contract SignatureCheckerMock { using SignatureChecker for address; - function isValidSignatureNow(address signer, bytes32 hash, bytes memory signature) public view returns (bool) { + function isValidSignatureNow( + address signer, + bytes32 hash, + bytes memory signature + ) public view returns (bool) { return signer.isValidSignatureNow(hash, signature); } } diff --git a/contracts/mocks/UUPS/UUPSLegacy.sol b/contracts/mocks/UUPS/UUPSLegacy.sol index 7a3002889bf..e03fa862da3 100644 --- a/contracts/mocks/UUPS/UUPSLegacy.sol +++ b/contracts/mocks/UUPS/UUPSLegacy.sol @@ -17,7 +17,11 @@ contract UUPSUpgradeableLegacyMock is UUPSUpgradeableMock { StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; } - function _upgradeToAndCallSecureLegacyV1(address newImplementation, bytes memory data, bool forceCall) internal { + function _upgradeToAndCallSecureLegacyV1( + address newImplementation, + bytes memory data, + bool forceCall + ) internal { address oldImplementation = _getImplementation(); // Initial upgrade and setup call diff --git a/contracts/mocks/crosschain/bridges.sol b/contracts/mocks/crosschain/bridges.sol index 41baffed805..35c7f4c0625 100644 --- a/contracts/mocks/crosschain/bridges.sol +++ b/contracts/mocks/crosschain/bridges.sol @@ -12,7 +12,11 @@ abstract contract BaseRelayMock { address internal _currentSender; - function relayAs(address target, bytes calldata data, address sender) external virtual { + function relayAs( + address target, + bytes calldata data, + address sender + ) external virtual { address previousSender = _currentSender; _currentSender = sender; @@ -88,7 +92,11 @@ contract BridgeOptimismMock is BaseRelayMock { * Polygon */ contract BridgePolygonChildMock is BaseRelayMock { - function relayAs(address target, bytes calldata data, address sender) external override { + function relayAs( + address target, + bytes calldata data, + address sender + ) external override { IFxMessageProcessor(target).processMessageFromRoot(0, sender, data); } } diff --git a/contracts/mocks/wizard/MyGovernor1.sol b/contracts/mocks/wizard/MyGovernor1.sol index 37ecfd57d8b..a80d8400c5e 100644 --- a/contracts/mocks/wizard/MyGovernor1.sol +++ b/contracts/mocks/wizard/MyGovernor1.sol @@ -14,10 +14,12 @@ contract MyGovernor1 is GovernorVotesQuorumFraction, GovernorCountingSimple { - constructor( - IVotes _token, - TimelockController _timelock - ) Governor("MyGovernor") GovernorVotes(_token) GovernorVotesQuorumFraction(4) GovernorTimelockControl(_timelock) {} + constructor(IVotes _token, TimelockController _timelock) + Governor("MyGovernor") + GovernorVotes(_token) + GovernorVotesQuorumFraction(4) + GovernorTimelockControl(_timelock) + {} function votingDelay() public pure override returns (uint256) { return 1; // 1 block @@ -29,9 +31,12 @@ contract MyGovernor1 is // The following functions are overrides required by Solidity. - function quorum( - uint256 blockNumber - ) public view override(IGovernor, GovernorVotesQuorumFraction) returns (uint256) { + function quorum(uint256 blockNumber) + public + view + override(IGovernor, GovernorVotesQuorumFraction) + returns (uint256) + { return super.quorum(blockNumber); } @@ -71,9 +76,12 @@ contract MyGovernor1 is return super._executor(); } - function supportsInterface( - bytes4 interfaceId - ) public view override(Governor, GovernorTimelockControl) returns (bool) { + function supportsInterface(bytes4 interfaceId) + public + view + override(Governor, GovernorTimelockControl) + returns (bool) + { return super.supportsInterface(interfaceId); } } diff --git a/contracts/mocks/wizard/MyGovernor2.sol b/contracts/mocks/wizard/MyGovernor2.sol index 1472b67d588..34c608c5cc2 100644 --- a/contracts/mocks/wizard/MyGovernor2.sol +++ b/contracts/mocks/wizard/MyGovernor2.sol @@ -16,10 +16,12 @@ contract MyGovernor2 is GovernorVotesQuorumFraction, GovernorCountingSimple { - constructor( - IVotes _token, - TimelockController _timelock - ) Governor("MyGovernor") GovernorVotes(_token) GovernorVotesQuorumFraction(4) GovernorTimelockControl(_timelock) {} + constructor(IVotes _token, TimelockController _timelock) + Governor("MyGovernor") + GovernorVotes(_token) + GovernorVotesQuorumFraction(4) + GovernorTimelockControl(_timelock) + {} function votingDelay() public pure override returns (uint256) { return 1; // 1 block @@ -35,9 +37,12 @@ contract MyGovernor2 is // The following functions are overrides required by Solidity. - function quorum( - uint256 blockNumber - ) public view override(IGovernor, GovernorVotesQuorumFraction) returns (uint256) { + function quorum(uint256 blockNumber) + public + view + override(IGovernor, GovernorVotesQuorumFraction) + returns (uint256) + { return super.quorum(blockNumber); } @@ -77,9 +82,12 @@ contract MyGovernor2 is return super._executor(); } - function supportsInterface( - bytes4 interfaceId - ) public view override(Governor, GovernorTimelockControl) returns (bool) { + function supportsInterface(bytes4 interfaceId) + public + view + override(Governor, GovernorTimelockControl) + returns (bool) + { return super.supportsInterface(interfaceId); } } diff --git a/contracts/mocks/wizard/MyGovernor3.sol b/contracts/mocks/wizard/MyGovernor3.sol index 320342290a5..70e4e87f046 100644 --- a/contracts/mocks/wizard/MyGovernor3.sol +++ b/contracts/mocks/wizard/MyGovernor3.sol @@ -14,10 +14,12 @@ contract MyGovernor is GovernorVotes, GovernorVotesQuorumFraction { - constructor( - IVotes _token, - TimelockController _timelock - ) Governor("MyGovernor") GovernorVotes(_token) GovernorVotesQuorumFraction(4) GovernorTimelockControl(_timelock) {} + constructor(IVotes _token, TimelockController _timelock) + Governor("MyGovernor") + GovernorVotes(_token) + GovernorVotesQuorumFraction(4) + GovernorTimelockControl(_timelock) + {} function votingDelay() public pure override returns (uint256) { return 1; // 1 block @@ -33,15 +35,21 @@ contract MyGovernor is // The following functions are overrides required by Solidity. - function quorum( - uint256 blockNumber - ) public view override(IGovernor, GovernorVotesQuorumFraction) returns (uint256) { + function quorum(uint256 blockNumber) + public + view + override(IGovernor, GovernorVotesQuorumFraction) + returns (uint256) + { return super.quorum(blockNumber); } - function state( - uint256 proposalId - ) public view override(Governor, IGovernor, GovernorTimelockControl) returns (ProposalState) { + function state(uint256 proposalId) + public + view + override(Governor, IGovernor, GovernorTimelockControl) + returns (ProposalState) + { return super.state(proposalId); } @@ -77,9 +85,12 @@ contract MyGovernor is return super._executor(); } - function supportsInterface( - bytes4 interfaceId - ) public view override(Governor, IERC165, GovernorTimelockControl) returns (bool) { + function supportsInterface(bytes4 interfaceId) + public + view + override(Governor, IERC165, GovernorTimelockControl) + returns (bool) + { return super.supportsInterface(interfaceId); } } diff --git a/contracts/proxy/Clones.sol b/contracts/proxy/Clones.sol index 712519892ef..93ea0cec77e 100644 --- a/contracts/proxy/Clones.sol +++ b/contracts/proxy/Clones.sol @@ -79,10 +79,11 @@ library Clones { /** * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}. */ - function predictDeterministicAddress( - address implementation, - bytes32 salt - ) internal view returns (address predicted) { + function predictDeterministicAddress(address implementation, bytes32 salt) + internal + view + returns (address predicted) + { return predictDeterministicAddress(implementation, salt, address(this)); } } diff --git a/contracts/proxy/ERC1967/ERC1967Upgrade.sol b/contracts/proxy/ERC1967/ERC1967Upgrade.sol index 38ea7ea1bf9..07dc048625a 100644 --- a/contracts/proxy/ERC1967/ERC1967Upgrade.sol +++ b/contracts/proxy/ERC1967/ERC1967Upgrade.sol @@ -62,7 +62,11 @@ abstract contract ERC1967Upgrade { * * Emits an {Upgraded} event. */ - function _upgradeToAndCall(address newImplementation, bytes memory data, bool forceCall) internal { + function _upgradeToAndCall( + address newImplementation, + bytes memory data, + bool forceCall + ) internal { _upgradeTo(newImplementation); if (data.length > 0 || forceCall) { Address.functionDelegateCall(newImplementation, data); @@ -74,7 +78,11 @@ abstract contract ERC1967Upgrade { * * Emits an {Upgraded} event. */ - function _upgradeToAndCallUUPS(address newImplementation, bytes memory data, bool forceCall) internal { + function _upgradeToAndCallUUPS( + address newImplementation, + bytes memory data, + bool forceCall + ) internal { // Upgrades from old implementations will perform a rollback test. This test requires the new // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing // this special case will break upgrade paths from old UUPS implementation to new ones. @@ -167,7 +175,11 @@ abstract contract ERC1967Upgrade { * * Emits a {BeaconUpgraded} event. */ - function _upgradeBeaconToAndCall(address newBeacon, bytes memory data, bool forceCall) internal { + function _upgradeBeaconToAndCall( + address newBeacon, + bytes memory data, + bool forceCall + ) internal { _setBeacon(newBeacon); emit BeaconUpgraded(newBeacon); if (data.length > 0 || forceCall) { diff --git a/contracts/proxy/transparent/TransparentUpgradeableProxy.sol b/contracts/proxy/transparent/TransparentUpgradeableProxy.sol index ffc97ff4855..57417296d6e 100644 --- a/contracts/proxy/transparent/TransparentUpgradeableProxy.sol +++ b/contracts/proxy/transparent/TransparentUpgradeableProxy.sol @@ -31,7 +31,11 @@ contract TransparentUpgradeableProxy is ERC1967Proxy { * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}. */ - constructor(address _logic, address admin_, bytes memory _data) payable ERC1967Proxy(_logic, _data) { + constructor( + address _logic, + address admin_, + bytes memory _data + ) payable ERC1967Proxy(_logic, _data) { _changeAdmin(admin_); } diff --git a/contracts/token/ERC1155/ERC1155.sol b/contracts/token/ERC1155/ERC1155.sol index 320746702ad..fb85aee462c 100644 --- a/contracts/token/ERC1155/ERC1155.sol +++ b/contracts/token/ERC1155/ERC1155.sol @@ -79,10 +79,13 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { * * - `accounts` and `ids` must have the same length. */ - function balanceOfBatch( - address[] memory accounts, - uint256[] memory ids - ) public view virtual override returns (uint256[] memory) { + function balanceOfBatch(address[] memory accounts, uint256[] memory ids) + public + view + virtual + override + returns (uint256[] memory) + { require(accounts.length == ids.length, "ERC1155: accounts and ids length mismatch"); uint256[] memory batchBalances = new uint256[](accounts.length); @@ -353,7 +356,11 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { * * Emits an {ApprovalForAll} event. */ - function _setApprovalForAll(address owner, address operator, bool approved) internal virtual { + function _setApprovalForAll( + address owner, + address operator, + bool approved + ) internal virtual { require(owner != operator, "ERC1155: setting approval status for self"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); diff --git a/contracts/token/ERC1155/IERC1155.sol b/contracts/token/ERC1155/IERC1155.sol index eae0b7029f6..05f74dc4f32 100644 --- a/contracts/token/ERC1155/IERC1155.sol +++ b/contracts/token/ERC1155/IERC1155.sol @@ -60,10 +60,10 @@ interface IERC1155 is IERC165 { * * - `accounts` and `ids` must have the same length. */ - function balanceOfBatch( - address[] calldata accounts, - uint256[] calldata ids - ) external view returns (uint256[] memory); + function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids) + external + view + returns (uint256[] memory); /** * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`, @@ -96,7 +96,13 @@ interface IERC1155 is IERC165 { * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ - function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes calldata data) external; + function safeTransferFrom( + address from, + address to, + uint256 id, + uint256 amount, + bytes calldata data + ) external; /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}. diff --git a/contracts/token/ERC1155/extensions/ERC1155Burnable.sol b/contracts/token/ERC1155/extensions/ERC1155Burnable.sol index cc81957a7fe..cfaa2359dbd 100644 --- a/contracts/token/ERC1155/extensions/ERC1155Burnable.sol +++ b/contracts/token/ERC1155/extensions/ERC1155Burnable.sol @@ -12,7 +12,11 @@ import "../ERC1155.sol"; * _Available since v3.1._ */ abstract contract ERC1155Burnable is ERC1155 { - function burn(address account, uint256 id, uint256 value) public virtual { + function burn( + address account, + uint256 id, + uint256 value + ) public virtual { require( account == _msgSender() || isApprovedForAll(account, _msgSender()), "ERC1155: caller is not token owner or approved" @@ -21,7 +25,11 @@ abstract contract ERC1155Burnable is ERC1155 { _burn(account, id, value); } - function burnBatch(address account, uint256[] memory ids, uint256[] memory values) public virtual { + function burnBatch( + address account, + uint256[] memory ids, + uint256[] memory values + ) public virtual { require( account == _msgSender() || isApprovedForAll(account, _msgSender()), "ERC1155: caller is not token owner or approved" diff --git a/contracts/token/ERC20/ERC20.sol b/contracts/token/ERC20/ERC20.sol index f9be8b68965..261a46f2253 100644 --- a/contracts/token/ERC20/ERC20.sol +++ b/contracts/token/ERC20/ERC20.sol @@ -154,7 +154,11 @@ contract ERC20 is Context, IERC20, IERC20Metadata { * - the caller must have allowance for ``from``'s tokens of at least * `amount`. */ - function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) { + function transferFrom( + address from, + address to, + uint256 amount + ) public virtual override returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, amount); _transfer(from, to, amount); @@ -214,7 +218,11 @@ contract ERC20 is Context, IERC20, IERC20Metadata { * * NOTE: This function is not virtual, {_update} should be overridden instead. */ - function _transfer(address from, address to, uint256 amount) internal { + function _transfer( + address from, + address to, + uint256 amount + ) internal { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); _update(from, to, amount); @@ -226,7 +234,11 @@ contract ERC20 is Context, IERC20, IERC20Metadata { * * Emits a {Transfer} event. */ - function _update(address from, address to, uint256 amount) internal virtual { + function _update( + address from, + address to, + uint256 amount + ) internal virtual { if (from == address(0)) { _totalSupply += amount; unchecked { @@ -294,7 +306,11 @@ contract ERC20 is Context, IERC20, IERC20Metadata { * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ - function _approve(address owner, address spender, uint256 amount) internal virtual { + function _approve( + address owner, + address spender, + uint256 amount + ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); @@ -310,7 +326,11 @@ contract ERC20 is Context, IERC20, IERC20Metadata { * * Might emit an {Approval} event. */ - function _spendAllowance(address owner, address spender, uint256 amount) internal virtual { + function _spendAllowance( + address owner, + address spender, + uint256 amount + ) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { require(currentAllowance >= amount, "ERC20: insufficient allowance"); diff --git a/contracts/token/ERC20/IERC20.sol b/contracts/token/ERC20/IERC20.sol index 66c4e4d88fe..b816bfed086 100644 --- a/contracts/token/ERC20/IERC20.sol +++ b/contracts/token/ERC20/IERC20.sol @@ -74,5 +74,9 @@ interface IERC20 { * * Emits a {Transfer} event. */ - function transferFrom(address from, address to, uint256 amount) external returns (bool); + function transferFrom( + address from, + address to, + uint256 amount + ) external returns (bool); } diff --git a/contracts/token/ERC20/extensions/ERC20Capped.sol b/contracts/token/ERC20/extensions/ERC20Capped.sol index d80fb2a4ccd..3be9ff805d7 100644 --- a/contracts/token/ERC20/extensions/ERC20Capped.sol +++ b/contracts/token/ERC20/extensions/ERC20Capped.sol @@ -30,7 +30,11 @@ abstract contract ERC20Capped is ERC20 { /** * @dev See {ERC20-_transfer}. */ - function _update(address from, address to, uint256 amount) internal virtual override { + function _update( + address from, + address to, + uint256 amount + ) internal virtual override { if (from == address(0)) { require(ERC20.totalSupply() + amount <= cap(), "ERC20Capped: cap exceeded"); } diff --git a/contracts/token/ERC20/extensions/ERC20Pausable.sol b/contracts/token/ERC20/extensions/ERC20Pausable.sol index 85dd164d37b..92d764932a9 100644 --- a/contracts/token/ERC20/extensions/ERC20Pausable.sol +++ b/contracts/token/ERC20/extensions/ERC20Pausable.sol @@ -21,7 +21,11 @@ abstract contract ERC20Pausable is ERC20, Pausable { * * - the contract must not be paused. */ - function _update(address from, address to, uint256 amount) internal virtual override { + function _update( + address from, + address to, + uint256 amount + ) internal virtual override { require(!paused(), "ERC20Pausable: token transfer while paused"); super._update(from, to, amount); } diff --git a/contracts/token/ERC20/extensions/ERC20Snapshot.sol b/contracts/token/ERC20/extensions/ERC20Snapshot.sol index 3bc1a74eecc..2c34e226809 100644 --- a/contracts/token/ERC20/extensions/ERC20Snapshot.sol +++ b/contracts/token/ERC20/extensions/ERC20Snapshot.sol @@ -120,7 +120,11 @@ abstract contract ERC20Snapshot is ERC20 { // Update balance and/or total supply snapshots before the values are modified. This is executed // for _mint, _burn, and _transfer operations. - function _update(address from, address to, uint256 amount) internal virtual override { + function _update( + address from, + address to, + uint256 amount + ) internal virtual override { if (from == address(0)) { // mint _updateAccountSnapshot(to); diff --git a/contracts/token/ERC20/extensions/ERC20Votes.sol b/contracts/token/ERC20/extensions/ERC20Votes.sol index 225d08c443e..7f9f36b7603 100644 --- a/contracts/token/ERC20/extensions/ERC20Votes.sol +++ b/contracts/token/ERC20/extensions/ERC20Votes.sol @@ -35,7 +35,11 @@ abstract contract ERC20Votes is ERC20, Votes { * * Emits a {IVotes-DelegateVotesChanged} event. */ - function _update(address from, address to, uint256 amount) internal virtual override { + function _update( + address from, + address to, + uint256 amount + ) internal virtual override { super._update(from, to, amount); if (from == address(0)) { require(totalSupply() <= _maxSupply(), "ERC20Votes: total supply risks overflowing votes"); diff --git a/contracts/token/ERC20/extensions/ERC4626.sol b/contracts/token/ERC20/extensions/ERC4626.sol index 9b26aefebed..3ffcd7bfd5a 100644 --- a/contracts/token/ERC20/extensions/ERC4626.sol +++ b/contracts/token/ERC20/extensions/ERC4626.sol @@ -153,7 +153,11 @@ abstract contract ERC4626 is ERC20, IERC4626 { } /** @dev See {IERC4626-withdraw}. */ - function withdraw(uint256 assets, address receiver, address owner) public virtual override returns (uint256) { + function withdraw( + uint256 assets, + address receiver, + address owner + ) public virtual override returns (uint256) { require(assets <= maxWithdraw(owner), "ERC4626: withdraw more than max"); uint256 shares = previewWithdraw(assets); @@ -163,7 +167,11 @@ abstract contract ERC4626 is ERC20, IERC4626 { } /** @dev See {IERC4626-redeem}. */ - function redeem(uint256 shares, address receiver, address owner) public virtual override returns (uint256) { + function redeem( + uint256 shares, + address receiver, + address owner + ) public virtual override returns (uint256) { require(shares <= maxRedeem(owner), "ERC4626: redeem more than max"); uint256 assets = previewRedeem(shares); @@ -222,7 +230,12 @@ abstract contract ERC4626 is ERC20, IERC4626 { /** * @dev Deposit/mint common workflow. */ - function _deposit(address caller, address receiver, uint256 assets, uint256 shares) internal virtual { + function _deposit( + address caller, + address receiver, + uint256 assets, + uint256 shares + ) internal virtual { // If _asset is ERC777, `transferFrom` can trigger a reenterancy BEFORE the transfer happens through the // `tokensToSend` hook. On the other hand, the `tokenReceived` hook, that is triggered after the transfer, // calls the vault, which is assumed not malicious. diff --git a/contracts/token/ERC20/utils/SafeERC20.sol b/contracts/token/ERC20/utils/SafeERC20.sol index 028711ddf29..bfc381f9b4a 100644 --- a/contracts/token/ERC20/utils/SafeERC20.sol +++ b/contracts/token/ERC20/utils/SafeERC20.sol @@ -19,11 +19,20 @@ import "../../../utils/Address.sol"; library SafeERC20 { using Address for address; - function safeTransfer(IERC20 token, address to, uint256 value) internal { + function safeTransfer( + IERC20 token, + address to, + uint256 value + ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } - function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { + function safeTransferFrom( + IERC20 token, + address from, + address to, + uint256 value + ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } @@ -34,7 +43,11 @@ library SafeERC20 { * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ - function safeApprove(IERC20 token, address spender, uint256 value) internal { + function safeApprove( + IERC20 token, + address spender, + uint256 value + ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' @@ -45,12 +58,20 @@ library SafeERC20 { _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } - function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { + function safeIncreaseAllowance( + IERC20 token, + address spender, + uint256 value + ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } - function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { + function safeDecreaseAllowance( + IERC20 token, + address spender, + uint256 value + ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); diff --git a/contracts/token/ERC20/utils/TokenTimelock.sol b/contracts/token/ERC20/utils/TokenTimelock.sol index ed855b7bcb4..d879a7e7d72 100644 --- a/contracts/token/ERC20/utils/TokenTimelock.sol +++ b/contracts/token/ERC20/utils/TokenTimelock.sol @@ -29,7 +29,11 @@ contract TokenTimelock { * `beneficiary_` when {release} is invoked after `releaseTime_`. The release time is specified as a Unix timestamp * (in seconds). */ - constructor(IERC20 token_, address beneficiary_, uint256 releaseTime_) { + constructor( + IERC20 token_, + address beneficiary_, + uint256 releaseTime_ + ) { require(releaseTime_ > block.timestamp, "TokenTimelock: release time is before current time"); _token = token_; _beneficiary = beneficiary_; diff --git a/contracts/token/ERC721/ERC721.sol b/contracts/token/ERC721/ERC721.sol index 6bf620b4f24..80fc22de04d 100644 --- a/contracts/token/ERC721/ERC721.sol +++ b/contracts/token/ERC721/ERC721.sol @@ -147,7 +147,11 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { /** * @dev See {IERC721-transferFrom}. */ - function transferFrom(address from, address to, uint256 tokenId) public virtual override { + function transferFrom( + address from, + address to, + uint256 tokenId + ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved"); @@ -157,14 +161,23 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { /** * @dev See {IERC721-safeTransferFrom}. */ - function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override { + function safeTransferFrom( + address from, + address to, + uint256 tokenId + ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ - function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public virtual override { + function safeTransferFrom( + address from, + address to, + uint256 tokenId, + bytes memory data + ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved"); _safeTransfer(from, to, tokenId, data); } @@ -187,7 +200,12 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { * * Emits a {Transfer} event. */ - function _safeTransfer(address from, address to, uint256 tokenId, bytes memory data) internal virtual { + function _safeTransfer( + address from, + address to, + uint256 tokenId, + bytes memory data + ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer"); } @@ -241,7 +259,11 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ - function _safeMint(address to, uint256 tokenId, bytes memory data) internal virtual { + function _safeMint( + address to, + uint256 tokenId, + bytes memory data + ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, data), @@ -330,7 +352,11 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { * * Emits a {Transfer} event. */ - function _transfer(address from, address to, uint256 tokenId) internal virtual { + function _transfer( + address from, + address to, + uint256 tokenId + ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner"); require(to != address(0), "ERC721: transfer to the zero address"); @@ -373,7 +399,11 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { * * Emits an {ApprovalForAll} event. */ - function _setApprovalForAll(address owner, address operator, bool approved) internal virtual { + function _setApprovalForAll( + address owner, + address operator, + bool approved + ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); @@ -437,7 +467,7 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { function _beforeTokenTransfer( address from, address to, - uint256 /* firstTokenId */, + uint256, /* firstTokenId */ uint256 batchSize ) internal virtual { if (batchSize > 1) { @@ -464,5 +494,10 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ - function _afterTokenTransfer(address from, address to, uint256 firstTokenId, uint256 batchSize) internal virtual {} + function _afterTokenTransfer( + address from, + address to, + uint256 firstTokenId, + uint256 batchSize + ) internal virtual {} } diff --git a/contracts/token/ERC721/IERC721.sol b/contracts/token/ERC721/IERC721.sol index 646530aa568..22020bab0bf 100644 --- a/contracts/token/ERC721/IERC721.sol +++ b/contracts/token/ERC721/IERC721.sol @@ -51,7 +51,12 @@ interface IERC721 is IERC165 { * * Emits a {Transfer} event. */ - function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external; + function safeTransferFrom( + address from, + address to, + uint256 tokenId, + bytes calldata data + ) external; /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients @@ -67,7 +72,11 @@ interface IERC721 is IERC165 { * * Emits a {Transfer} event. */ - function safeTransferFrom(address from, address to, uint256 tokenId) external; + function safeTransferFrom( + address from, + address to, + uint256 tokenId + ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. @@ -85,7 +94,11 @@ interface IERC721 is IERC165 { * * Emits a {Transfer} event. */ - function transferFrom(address from, address to, uint256 tokenId) external; + function transferFrom( + address from, + address to, + uint256 tokenId + ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. diff --git a/contracts/token/ERC721/utils/ERC721Holder.sol b/contracts/token/ERC721/utils/ERC721Holder.sol index cfa533a47b1..394926d51ed 100644 --- a/contracts/token/ERC721/utils/ERC721Holder.sol +++ b/contracts/token/ERC721/utils/ERC721Holder.sol @@ -17,7 +17,12 @@ contract ERC721Holder is IERC721Receiver { * * Always returns `IERC721Receiver.onERC721Received.selector`. */ - function onERC721Received(address, address, uint256, bytes memory) public virtual override returns (bytes4) { + function onERC721Received( + address, + address, + uint256, + bytes memory + ) public virtual override returns (bytes4) { return this.onERC721Received.selector; } } diff --git a/contracts/token/ERC777/ERC777.sol b/contracts/token/ERC777/ERC777.sol index c1503c4dfc3..7c35bf5a8a9 100644 --- a/contracts/token/ERC777/ERC777.sol +++ b/contracts/token/ERC777/ERC777.sol @@ -57,7 +57,11 @@ contract ERC777 is Context, IERC777, IERC20 { /** * @dev `defaultOperators` may be an empty array. */ - constructor(string memory name_, string memory symbol_, address[] memory defaultOperators_) { + constructor( + string memory name_, + string memory symbol_, + address[] memory defaultOperators_ + ) { _name = name_; _symbol = symbol_; @@ -123,7 +127,11 @@ contract ERC777 is Context, IERC777, IERC20 { * * Also emits a {IERC20-Transfer} event for ERC20 compatibility. */ - function send(address recipient, uint256 amount, bytes memory data) public virtual override { + function send( + address recipient, + uint256 amount, + bytes memory data + ) public virtual override { _send(_msgSender(), recipient, amount, data, "", true); } @@ -264,7 +272,11 @@ contract ERC777 is Context, IERC777, IERC20 { * * Emits {Sent}, {IERC20-Transfer} and {IERC20-Approval} events. */ - function transferFrom(address holder, address recipient, uint256 amount) public virtual override returns (bool) { + function transferFrom( + address holder, + address recipient, + uint256 amount + ) public virtual override returns (bool) { address spender = _msgSender(); _spendAllowance(holder, spender, amount); _send(holder, recipient, amount, "", "", false); @@ -289,7 +301,12 @@ contract ERC777 is Context, IERC777, IERC20 { * - if `account` is a contract, it must implement the {IERC777Recipient} * interface. */ - function _mint(address account, uint256 amount, bytes memory userData, bytes memory operatorData) internal virtual { + function _mint( + address account, + uint256 amount, + bytes memory userData, + bytes memory operatorData + ) internal virtual { _mint(account, amount, userData, operatorData, true); } @@ -370,7 +387,12 @@ contract ERC777 is Context, IERC777, IERC20 { * @param data bytes extra information provided by the token holder * @param operatorData bytes extra information provided by the operator (if any) */ - function _burn(address from, uint256 amount, bytes memory data, bytes memory operatorData) internal virtual { + function _burn( + address from, + uint256 amount, + bytes memory data, + bytes memory operatorData + ) internal virtual { require(from != address(0), "ERC777: burn from the zero address"); address operator = _msgSender(); @@ -417,7 +439,11 @@ contract ERC777 is Context, IERC777, IERC20 { * * Note that accounts cannot have allowance issued by their operators. */ - function _approve(address holder, address spender, uint256 value) internal virtual { + function _approve( + address holder, + address spender, + uint256 value + ) internal virtual { require(holder != address(0), "ERC777: approve from the zero address"); require(spender != address(0), "ERC777: approve to the zero address"); @@ -484,7 +510,11 @@ contract ERC777 is Context, IERC777, IERC20 { * * Might emit an {IERC20-Approval} event. */ - function _spendAllowance(address owner, address spender, uint256 amount) internal virtual { + function _spendAllowance( + address owner, + address spender, + uint256 amount + ) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { require(currentAllowance >= amount, "ERC777: insufficient allowance"); @@ -508,5 +538,10 @@ contract ERC777 is Context, IERC777, IERC20 { * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ - function _beforeTokenTransfer(address operator, address from, address to, uint256 amount) internal virtual {} + function _beforeTokenTransfer( + address operator, + address from, + address to, + uint256 amount + ) internal virtual {} } diff --git a/contracts/token/ERC777/IERC777.sol b/contracts/token/ERC777/IERC777.sol index d3bede62610..2af7771b03e 100644 --- a/contracts/token/ERC777/IERC777.sol +++ b/contracts/token/ERC777/IERC777.sol @@ -83,7 +83,11 @@ interface IERC777 { * - if `recipient` is a contract, it must implement the {IERC777Recipient} * interface. */ - function send(address recipient, uint256 amount, bytes calldata data) external; + function send( + address recipient, + uint256 amount, + bytes calldata data + ) external; /** * @dev Destroys `amount` tokens from the caller's account, reducing the @@ -187,7 +191,12 @@ interface IERC777 { * - `account` must have at least `amount` tokens. * - the caller must be an operator for `account`. */ - function operatorBurn(address account, uint256 amount, bytes calldata data, bytes calldata operatorData) external; + function operatorBurn( + address account, + uint256 amount, + bytes calldata data, + bytes calldata operatorData + ) external; event Sent( address indexed operator, diff --git a/contracts/token/common/ERC2981.sol b/contracts/token/common/ERC2981.sol index 84cb6b8deb4..604dba3046a 100644 --- a/contracts/token/common/ERC2981.sol +++ b/contracts/token/common/ERC2981.sol @@ -91,7 +91,11 @@ abstract contract ERC2981 is IERC2981, ERC165 { * - `receiver` cannot be the zero address. * - `feeNumerator` cannot be greater than the fee denominator. */ - function _setTokenRoyalty(uint256 tokenId, address receiver, uint96 feeNumerator) internal virtual { + function _setTokenRoyalty( + uint256 tokenId, + address receiver, + uint96 feeNumerator + ) internal virtual { require(feeNumerator <= _feeDenominator(), "ERC2981: royalty fee will exceed salePrice"); require(receiver != address(0), "ERC2981: Invalid parameters"); diff --git a/contracts/utils/Address.sol b/contracts/utils/Address.sol index 70d03e3d212..e89512342ae 100644 --- a/contracts/utils/Address.sol +++ b/contracts/utils/Address.sol @@ -111,7 +111,11 @@ library Address { * * _Available since v3.1._ */ - function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { + function functionCallWithValue( + address target, + bytes memory data, + uint256 value + ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } diff --git a/contracts/utils/Checkpoints.sol b/contracts/utils/Checkpoints.sol index 76203edd2ce..f20601c6a81 100644 --- a/contracts/utils/Checkpoints.sol +++ b/contracts/utils/Checkpoints.sol @@ -111,9 +111,15 @@ library Checkpoints { * @dev Returns whether there is a checkpoint in the structure (i.e. it is not empty), and if so the key and value * in the most recent checkpoint. */ - function latestCheckpoint( - History storage self - ) internal view returns (bool exists, uint32 _blockNumber, uint224 _value) { + function latestCheckpoint(History storage self) + internal + view + returns ( + bool exists, + uint32 _blockNumber, + uint224 _value + ) + { uint256 pos = self._checkpoints.length; if (pos == 0) { return (false, 0, 0); @@ -134,7 +140,11 @@ library Checkpoints { * @dev Pushes a (`key`, `value`) pair into an ordered list of checkpoints, either by inserting a new checkpoint, * or by updating the last one. */ - function _insert(Checkpoint[] storage self, uint32 key, uint224 value) private returns (uint224, uint224) { + function _insert( + Checkpoint[] storage self, + uint32 key, + uint224 value + ) private returns (uint224, uint224) { uint256 pos = self.length; if (pos > 0) { @@ -227,7 +237,11 @@ library Checkpoints { * * Returns previous value and new value. */ - function push(Trace224 storage self, uint32 key, uint224 value) internal returns (uint224, uint224) { + function push( + Trace224 storage self, + uint32 key, + uint224 value + ) internal returns (uint224, uint224) { return _insert(self._checkpoints, key, value); } @@ -261,7 +275,15 @@ library Checkpoints { * @dev Returns whether there is a checkpoint in the structure (i.e. it is not empty), and if so the key and value * in the most recent checkpoint. */ - function latestCheckpoint(Trace224 storage self) internal view returns (bool exists, uint32 _key, uint224 _value) { + function latestCheckpoint(Trace224 storage self) + internal + view + returns ( + bool exists, + uint32 _key, + uint224 _value + ) + { uint256 pos = self._checkpoints.length; if (pos == 0) { return (false, 0, 0); @@ -282,7 +304,11 @@ library Checkpoints { * @dev Pushes a (`key`, `value`) pair into an ordered list of checkpoints, either by inserting a new checkpoint, * or by updating the last one. */ - function _insert(Checkpoint224[] storage self, uint32 key, uint224 value) private returns (uint224, uint224) { + function _insert( + Checkpoint224[] storage self, + uint32 key, + uint224 value + ) private returns (uint224, uint224) { uint256 pos = self.length; if (pos > 0) { @@ -354,10 +380,11 @@ library Checkpoints { /** * @dev Access an element of the array without performing bounds check. The position is assumed to be within bounds. */ - function _unsafeAccess( - Checkpoint224[] storage self, - uint256 pos - ) private pure returns (Checkpoint224 storage result) { + function _unsafeAccess(Checkpoint224[] storage self, uint256 pos) + private + pure + returns (Checkpoint224 storage result) + { assembly { mstore(0, self.slot) result.slot := add(keccak256(0, 0x20), pos) @@ -378,7 +405,11 @@ library Checkpoints { * * Returns previous value and new value. */ - function push(Trace160 storage self, uint96 key, uint160 value) internal returns (uint160, uint160) { + function push( + Trace160 storage self, + uint96 key, + uint160 value + ) internal returns (uint160, uint160) { return _insert(self._checkpoints, key, value); } @@ -412,7 +443,15 @@ library Checkpoints { * @dev Returns whether there is a checkpoint in the structure (i.e. it is not empty), and if so the key and value * in the most recent checkpoint. */ - function latestCheckpoint(Trace160 storage self) internal view returns (bool exists, uint96 _key, uint160 _value) { + function latestCheckpoint(Trace160 storage self) + internal + view + returns ( + bool exists, + uint96 _key, + uint160 _value + ) + { uint256 pos = self._checkpoints.length; if (pos == 0) { return (false, 0, 0); @@ -433,7 +472,11 @@ library Checkpoints { * @dev Pushes a (`key`, `value`) pair into an ordered list of checkpoints, either by inserting a new checkpoint, * or by updating the last one. */ - function _insert(Checkpoint160[] storage self, uint96 key, uint160 value) private returns (uint160, uint160) { + function _insert( + Checkpoint160[] storage self, + uint96 key, + uint160 value + ) private returns (uint160, uint160) { uint256 pos = self.length; if (pos > 0) { @@ -505,10 +548,11 @@ library Checkpoints { /** * @dev Access an element of the array without performing bounds check. The position is assumed to be within bounds. */ - function _unsafeAccess( - Checkpoint160[] storage self, - uint256 pos - ) private pure returns (Checkpoint160 storage result) { + function _unsafeAccess(Checkpoint160[] storage self, uint256 pos) + private + pure + returns (Checkpoint160 storage result) + { assembly { mstore(0, self.slot) result.slot := add(keccak256(0, 0x20), pos) diff --git a/contracts/utils/Create2.sol b/contracts/utils/Create2.sol index 2255a4df8b7..8df86d66999 100644 --- a/contracts/utils/Create2.sol +++ b/contracts/utils/Create2.sol @@ -27,7 +27,11 @@ library Create2 { * - the factory must have a balance of at least `amount`. * - if `amount` is non-zero, `bytecode` must have a `payable` constructor. */ - function deploy(uint256 amount, bytes32 salt, bytes memory bytecode) internal returns (address addr) { + function deploy( + uint256 amount, + bytes32 salt, + bytes memory bytecode + ) internal returns (address addr) { require(address(this).balance >= amount, "Create2: insufficient balance"); require(bytecode.length != 0, "Create2: bytecode length is zero"); /// @solidity memory-safe-assembly @@ -49,7 +53,11 @@ library Create2 { * @dev Returns the address where a contract will be stored if deployed via {deploy} from a contract located at * `deployer`. If `deployer` is this contract's address, returns the same value as {computeAddress}. */ - function computeAddress(bytes32 salt, bytes32 bytecodeHash, address deployer) internal pure returns (address addr) { + function computeAddress( + bytes32 salt, + bytes32 bytecodeHash, + address deployer + ) internal pure returns (address addr) { /// @solidity memory-safe-assembly assembly { let ptr := mload(0x40) // Get free memory pointer diff --git a/contracts/utils/cryptography/ECDSA.sol b/contracts/utils/cryptography/ECDSA.sol index 3f996520efd..4b1d66b092d 100644 --- a/contracts/utils/cryptography/ECDSA.sol +++ b/contracts/utils/cryptography/ECDSA.sol @@ -98,7 +98,11 @@ library ECDSA { * * _Available since v4.3._ */ - function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError) { + function tryRecover( + bytes32 hash, + bytes32 r, + bytes32 vs + ) internal pure returns (address, RecoverError) { bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff); uint8 v = uint8((uint256(vs) >> 255) + 27); return tryRecover(hash, v, r, s); @@ -109,7 +113,11 @@ library ECDSA { * * _Available since v4.2._ */ - function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) { + function recover( + bytes32 hash, + bytes32 r, + bytes32 vs + ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, r, vs); _throwError(error); return recovered; @@ -121,7 +129,12 @@ library ECDSA { * * _Available since v4.3._ */ - function tryRecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address, RecoverError) { + function tryRecover( + bytes32 hash, + uint8 v, + bytes32 r, + bytes32 s + ) internal pure returns (address, RecoverError) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most @@ -148,7 +161,12 @@ library ECDSA { * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ - function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) { + function recover( + bytes32 hash, + uint8 v, + bytes32 r, + bytes32 s + ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, v, r, s); _throwError(error); return recovered; diff --git a/contracts/utils/cryptography/MerkleProof.sol b/contracts/utils/cryptography/MerkleProof.sol index 0ce87faf283..47c60eb0118 100644 --- a/contracts/utils/cryptography/MerkleProof.sol +++ b/contracts/utils/cryptography/MerkleProof.sol @@ -24,7 +24,11 @@ library MerkleProof { * sibling hashes on the branch from the leaf to the root of the tree. Each * pair of leaves and each pair of pre-images are assumed to be sorted. */ - function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) internal pure returns (bool) { + function verify( + bytes32[] memory proof, + bytes32 root, + bytes32 leaf + ) internal pure returns (bool) { return processProof(proof, leaf) == root; } @@ -33,7 +37,11 @@ library MerkleProof { * * _Available since v4.7._ */ - function verifyCalldata(bytes32[] calldata proof, bytes32 root, bytes32 leaf) internal pure returns (bool) { + function verifyCalldata( + bytes32[] calldata proof, + bytes32 root, + bytes32 leaf + ) internal pure returns (bool) { return processProofCalldata(proof, leaf) == root; } diff --git a/contracts/utils/cryptography/SignatureChecker.sol b/contracts/utils/cryptography/SignatureChecker.sol index e06778debd7..77fe98282bf 100644 --- a/contracts/utils/cryptography/SignatureChecker.sol +++ b/contracts/utils/cryptography/SignatureChecker.sol @@ -21,7 +21,11 @@ library SignatureChecker { * NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus * change through time. It could return true at block N and false at block N+1 (or the opposite). */ - function isValidSignatureNow(address signer, bytes32 hash, bytes memory signature) internal view returns (bool) { + function isValidSignatureNow( + address signer, + bytes32 hash, + bytes memory signature + ) internal view returns (bool) { (address recovered, ECDSA.RecoverError error) = ECDSA.tryRecover(hash, signature); if (error == ECDSA.RecoverError.NoError && recovered == signer) { return true; diff --git a/contracts/utils/introspection/ERC165Checker.sol b/contracts/utils/introspection/ERC165Checker.sol index 40ffd68f73f..4c5fe2092df 100644 --- a/contracts/utils/introspection/ERC165Checker.sol +++ b/contracts/utils/introspection/ERC165Checker.sol @@ -48,10 +48,11 @@ library ERC165Checker { * * _Available since v3.4._ */ - function getSupportedInterfaces( - address account, - bytes4[] memory interfaceIds - ) internal view returns (bool[] memory) { + function getSupportedInterfaces(address account, bytes4[] memory interfaceIds) + internal + view + returns (bool[] memory) + { // an array of booleans corresponding to interfaceIds and whether they're supported or not bool[] memory interfaceIdsSupported = new bool[](interfaceIds.length); diff --git a/contracts/utils/introspection/ERC1820Implementer.sol b/contracts/utils/introspection/ERC1820Implementer.sol index ac5a884c02a..1b5139658bd 100644 --- a/contracts/utils/introspection/ERC1820Implementer.sol +++ b/contracts/utils/introspection/ERC1820Implementer.sol @@ -21,10 +21,13 @@ contract ERC1820Implementer is IERC1820Implementer { /** * @dev See {IERC1820Implementer-canImplementInterfaceForAddress}. */ - function canImplementInterfaceForAddress( - bytes32 interfaceHash, - address account - ) public view virtual override returns (bytes32) { + function canImplementInterfaceForAddress(bytes32 interfaceHash, address account) + public + view + virtual + override + returns (bytes32) + { return _supportedInterfaces[interfaceHash][account] ? _ERC1820_ACCEPT_MAGIC : bytes32(0x00); } diff --git a/contracts/utils/introspection/IERC1820Registry.sol b/contracts/utils/introspection/IERC1820Registry.sol index a146bc2a68b..42cf46a8ae8 100644 --- a/contracts/utils/introspection/IERC1820Registry.sol +++ b/contracts/utils/introspection/IERC1820Registry.sol @@ -64,7 +64,11 @@ interface IERC1820Registry { * queried for support, unless `implementer` is the caller. See * {IERC1820Implementer-canImplementInterfaceForAddress}. */ - function setInterfaceImplementer(address account, bytes32 _interfaceHash, address implementer) external; + function setInterfaceImplementer( + address account, + bytes32 _interfaceHash, + address implementer + ) external; /** * @dev Returns the implementer of `interfaceHash` for `account`. If no such diff --git a/contracts/utils/math/Math.sol b/contracts/utils/math/Math.sol index f3a83b0ffab..0ed5460e05f 100644 --- a/contracts/utils/math/Math.sol +++ b/contracts/utils/math/Math.sol @@ -52,7 +52,11 @@ library Math { * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ - function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) { + function mulDiv( + uint256 x, + uint256 y, + uint256 denominator + ) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 @@ -133,7 +137,12 @@ library Math { /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ - function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) { + function mulDiv( + uint256 x, + uint256 y, + uint256 denominator, + Rounding rounding + ) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; @@ -249,31 +258,31 @@ library Math { function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { - if (value >= 10 ** 64) { - value /= 10 ** 64; + if (value >= 10**64) { + value /= 10**64; result += 64; } - if (value >= 10 ** 32) { - value /= 10 ** 32; + if (value >= 10**32) { + value /= 10**32; result += 32; } - if (value >= 10 ** 16) { - value /= 10 ** 16; + if (value >= 10**16) { + value /= 10**16; result += 16; } - if (value >= 10 ** 8) { - value /= 10 ** 8; + if (value >= 10**8) { + value /= 10**8; result += 8; } - if (value >= 10 ** 4) { - value /= 10 ** 4; + if (value >= 10**4) { + value /= 10**4; result += 4; } - if (value >= 10 ** 2) { - value /= 10 ** 2; + if (value >= 10**2) { + value /= 10**2; result += 2; } - if (value >= 10 ** 1) { + if (value >= 10**1) { result += 1; } } @@ -287,7 +296,7 @@ library Math { function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); - return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0); + return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0); } } diff --git a/contracts/utils/math/SafeMath.sol b/contracts/utils/math/SafeMath.sol index 2f48fb7360a..550f0e779b1 100644 --- a/contracts/utils/math/SafeMath.sol +++ b/contracts/utils/math/SafeMath.sol @@ -165,7 +165,11 @@ library SafeMath { * * - Subtraction cannot overflow. */ - function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { + function sub( + uint256 a, + uint256 b, + string memory errorMessage + ) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; @@ -184,7 +188,11 @@ library SafeMath { * * - The divisor cannot be zero. */ - function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { + function div( + uint256 a, + uint256 b, + string memory errorMessage + ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; @@ -206,7 +214,11 @@ library SafeMath { * * - The divisor cannot be zero. */ - function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { + function mod( + uint256 a, + uint256 b, + string memory errorMessage + ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; diff --git a/contracts/utils/structs/BitMaps.sol b/contracts/utils/structs/BitMaps.sol index eb67bfab081..a2ddc47098f 100644 --- a/contracts/utils/structs/BitMaps.sol +++ b/contracts/utils/structs/BitMaps.sol @@ -23,7 +23,11 @@ library BitMaps { /** * @dev Sets the bit at `index` to the boolean `value`. */ - function setTo(BitMap storage bitmap, uint256 index, bool value) internal { + function setTo( + BitMap storage bitmap, + uint256 index, + bool value + ) internal { if (value) { set(bitmap, index); } else { diff --git a/contracts/utils/structs/EnumerableMap.sol b/contracts/utils/structs/EnumerableMap.sol index d359671f461..a3fda61d802 100644 --- a/contracts/utils/structs/EnumerableMap.sol +++ b/contracts/utils/structs/EnumerableMap.sol @@ -70,7 +70,11 @@ library EnumerableMap { * Returns true if the key was added to the map, that is if it was not * already present. */ - function set(Bytes32ToBytes32Map storage map, bytes32 key, bytes32 value) internal returns (bool) { + function set( + Bytes32ToBytes32Map storage map, + bytes32 key, + bytes32 value + ) internal returns (bool) { map._values[key] = value; return map._keys.add(key); } @@ -169,7 +173,11 @@ library EnumerableMap { * Returns true if the key was added to the map, that is if it was not * already present. */ - function set(UintToUintMap storage map, uint256 key, uint256 value) internal returns (bool) { + function set( + UintToUintMap storage map, + uint256 key, + uint256 value + ) internal returns (bool) { return set(map._inner, bytes32(key), bytes32(value)); } @@ -236,7 +244,11 @@ library EnumerableMap { * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryGet}. */ - function get(UintToUintMap storage map, uint256 key, string memory errorMessage) internal view returns (uint256) { + function get( + UintToUintMap storage map, + uint256 key, + string memory errorMessage + ) internal view returns (uint256) { return uint256(get(map._inner, bytes32(key), errorMessage)); } @@ -253,7 +265,11 @@ library EnumerableMap { * Returns true if the key was added to the map, that is if it was not * already present. */ - function set(UintToAddressMap storage map, uint256 key, address value) internal returns (bool) { + function set( + UintToAddressMap storage map, + uint256 key, + address value + ) internal returns (bool) { return set(map._inner, bytes32(key), bytes32(uint256(uint160(value)))); } @@ -341,7 +357,11 @@ library EnumerableMap { * Returns true if the key was added to the map, that is if it was not * already present. */ - function set(AddressToUintMap storage map, address key, uint256 value) internal returns (bool) { + function set( + AddressToUintMap storage map, + address key, + uint256 value + ) internal returns (bool) { return set(map._inner, bytes32(uint256(uint160(key))), bytes32(value)); } @@ -429,7 +449,11 @@ library EnumerableMap { * Returns true if the key was added to the map, that is if it was not * already present. */ - function set(Bytes32ToUintMap storage map, bytes32 key, uint256 value) internal returns (bool) { + function set( + Bytes32ToUintMap storage map, + bytes32 key, + uint256 value + ) internal returns (bool) { return set(map._inner, key, bytes32(value)); } diff --git a/contracts/vendor/amb/IAMB.sol b/contracts/vendor/amb/IAMB.sol index 73a2bd24bcb..1a5d7080f8b 100644 --- a/contracts/vendor/amb/IAMB.sol +++ b/contracts/vendor/amb/IAMB.sol @@ -31,9 +31,17 @@ interface IAMB { function failedMessageSender(bytes32 _messageId) external view returns (address); - function requireToPassMessage(address _contract, bytes calldata _data, uint256 _gas) external returns (bytes32); - - function requireToConfirmMessage(address _contract, bytes calldata _data, uint256 _gas) external returns (bytes32); + function requireToPassMessage( + address _contract, + bytes calldata _data, + uint256 _gas + ) external returns (bytes32); + + function requireToConfirmMessage( + address _contract, + bytes calldata _data, + uint256 _gas + ) external returns (bytes32); function sourceChainId() external view returns (uint256); diff --git a/contracts/vendor/arbitrum/IArbSys.sol b/contracts/vendor/arbitrum/IArbSys.sol index 9b79d5c16a2..aac5dd53a9e 100644 --- a/contracts/vendor/arbitrum/IArbSys.sol +++ b/contracts/vendor/arbitrum/IArbSys.sol @@ -92,7 +92,14 @@ interface IArbSys { * @return root root hash of the send history * @return partials hashes of partial subtrees in the send history tree */ - function sendMerkleTreeState() external view returns (uint256 size, bytes32 root, bytes32[] memory partials); + function sendMerkleTreeState() + external + view + returns ( + uint256 size, + bytes32 root, + bytes32[] memory partials + ); /** * @notice creates a send txn from L2 to L1 diff --git a/contracts/vendor/arbitrum/IBridge.sol b/contracts/vendor/arbitrum/IBridge.sol index e71bedce012..7518f5d13cc 100644 --- a/contracts/vendor/arbitrum/IBridge.sol +++ b/contracts/vendor/arbitrum/IBridge.sol @@ -77,7 +77,14 @@ interface IBridge { uint256 afterDelayedMessagesRead, uint256 prevMessageCount, uint256 newMessageCount - ) external returns (uint256 seqMessageIndex, bytes32 beforeAcc, bytes32 delayedAcc, bytes32 acc); + ) + external + returns ( + uint256 seqMessageIndex, + bytes32 beforeAcc, + bytes32 delayedAcc, + bytes32 acc + ); /** * @dev Allows the sequencer inbox to submit a delayed message of the batchPostingReport type diff --git a/contracts/vendor/arbitrum/IOutbox.sol b/contracts/vendor/arbitrum/IOutbox.sol index 22fa58f405a..4f809dbf43e 100644 --- a/contracts/vendor/arbitrum/IOutbox.sol +++ b/contracts/vendor/arbitrum/IOutbox.sol @@ -113,5 +113,9 @@ interface IOutbox { bytes calldata data ) external pure returns (bytes32); - function calculateMerkleRoot(bytes32[] memory proof, uint256 path, bytes32 item) external pure returns (bytes32); + function calculateMerkleRoot( + bytes32[] memory proof, + uint256 path, + bytes32 item + ) external pure returns (bytes32); } diff --git a/contracts/vendor/optimism/ICrossDomainMessenger.sol b/contracts/vendor/optimism/ICrossDomainMessenger.sol index cc01a48ab9a..9cc797701bf 100644 --- a/contracts/vendor/optimism/ICrossDomainMessenger.sol +++ b/contracts/vendor/optimism/ICrossDomainMessenger.sol @@ -30,5 +30,9 @@ interface ICrossDomainMessenger { * @param _message Message to send to the target. * @param _gasLimit Gas limit for the provided message. */ - function sendMessage(address _target, bytes calldata _message, uint32 _gasLimit) external; + function sendMessage( + address _target, + bytes calldata _message, + uint32 _gasLimit + ) external; } diff --git a/contracts/vendor/polygon/IFxMessageProcessor.sol b/contracts/vendor/polygon/IFxMessageProcessor.sol index be73e6f53cd..9f42eb64709 100644 --- a/contracts/vendor/polygon/IFxMessageProcessor.sol +++ b/contracts/vendor/polygon/IFxMessageProcessor.sol @@ -3,5 +3,9 @@ pragma solidity ^0.8.0; interface IFxMessageProcessor { - function processMessageFromRoot(uint256 stateId, address rootMessageSender, bytes calldata data) external; + function processMessageFromRoot( + uint256 stateId, + address rootMessageSender, + bytes calldata data + ) external; } diff --git a/test/utils/math/Math.t.sol b/test/utils/math/Math.t.sol index 5542baf9d94..c1c6f447d3a 100644 --- a/test/utils/math/Math.t.sol +++ b/test/utils/math/Math.t.sol @@ -70,16 +70,16 @@ contract MathTest is Test { assertFalse(rounding == Math.Rounding.Up); assertTrue(_powerOf2Bigger(result + 1, input)); } else { - assertEq(2 ** result, input); + assertEq(2**result, input); } } function _powerOf2Bigger(uint256 value, uint256 ref) private pure returns (bool) { - return value >= 256 || 2 ** value > ref; // 2**256 overflows uint256 + return value >= 256 || 2**value > ref; // 2**256 overflows uint256 } function _powerOf2Smaller(uint256 value, uint256 ref) private pure returns (bool) { - return 2 ** value < ref; + return 2**value < ref; } // LOG10 @@ -97,16 +97,16 @@ contract MathTest is Test { assertFalse(rounding == Math.Rounding.Up); assertTrue(_powerOf10Bigger(result + 1, input)); } else { - assertEq(10 ** result, input); + assertEq(10**result, input); } } function _powerOf10Bigger(uint256 value, uint256 ref) private pure returns (bool) { - return value >= 78 || 10 ** value > ref; // 10**78 overflows uint256 + return value >= 78 || 10**value > ref; // 10**78 overflows uint256 } function _powerOf10Smaller(uint256 value, uint256 ref) private pure returns (bool) { - return 10 ** value < ref; + return 10**value < ref; } // LOG256 @@ -124,20 +124,24 @@ contract MathTest is Test { assertFalse(rounding == Math.Rounding.Up); assertTrue(_powerOf256Bigger(result + 1, input)); } else { - assertEq(256 ** result, input); + assertEq(256**result, input); } } function _powerOf256Bigger(uint256 value, uint256 ref) private pure returns (bool) { - return value >= 32 || 256 ** value > ref; // 256**32 overflows uint256 + return value >= 32 || 256**value > ref; // 256**32 overflows uint256 } function _powerOf256Smaller(uint256 value, uint256 ref) private pure returns (bool) { - return 256 ** value < ref; + return 256**value < ref; } // MULDIV - function testMulDiv(uint256 x, uint256 y, uint256 d) public { + function testMulDiv( + uint256 x, + uint256 y, + uint256 d + ) public { // Full precision for x * y (uint256 xyHi, uint256 xyLo) = _mulHighLow(x, y); @@ -159,7 +163,11 @@ contract MathTest is Test { assertEq(xyLo, qdRemLo); } - function testMulDivDomain(uint256 x, uint256 y, uint256 d) public { + function testMulDivDomain( + uint256 x, + uint256 y, + uint256 d + ) public { (uint256 xyHi, ) = _mulHighLow(x, y); // Violate {testMulDiv} assumption (covers d is 0 and result overflow) @@ -172,7 +180,11 @@ contract MathTest is Test { } // External call - function muldiv(uint256 x, uint256 y, uint256 d) external pure returns (uint256) { + function muldiv( + uint256 x, + uint256 y, + uint256 d + ) external pure returns (uint256) { return Math.mulDiv(x, y, d); } @@ -182,7 +194,11 @@ contract MathTest is Test { return Math.Rounding(r); } - function _mulmod(uint256 x, uint256 y, uint256 z) private pure returns (uint256 r) { + function _mulmod( + uint256 x, + uint256 y, + uint256 z + ) private pure returns (uint256 r) { assembly { r := mulmod(x, y, z) } From d2483513be0d8c1858877b983337d589532b6d24 Mon Sep 17 00:00:00 2001 From: Hadrien Croubois Date: Fri, 6 Jan 2023 16:07:37 +0100 Subject: [PATCH 19/25] fix lint --- .../polygon/CrossChainEnabledPolygonChild.sol | 2 +- contracts/finance/VestingWallet.sol | 6 +- contracts/governance/Governor.sol | 27 +++---- contracts/governance/TimelockController.sol | 20 +---- .../GovernorCompatibilityBravo.sol | 17 ++-- .../IGovernorCompatibilityBravo.sol | 8 +- .../extensions/GovernorCountingSimple.sol | 13 +-- .../extensions/GovernorSettings.sol | 6 +- .../extensions/GovernorTimelockControl.sol | 2 +- contracts/governance/utils/IVotes.sol | 9 +-- contracts/governance/utils/Votes.sol | 12 +-- contracts/interfaces/IERC1363.sol | 25 +----- contracts/interfaces/IERC1363Spender.sol | 6 +- contracts/interfaces/IERC2981.sol | 8 +- contracts/interfaces/IERC4626.sol | 12 +-- contracts/metatx/MinimalForwarder.sol | 9 +-- contracts/mocks/AddressImpl.sol | 6 +- contracts/mocks/CheckpointsMock.sol | 30 +------ contracts/mocks/ClonesMock.sol | 6 +- contracts/mocks/ContextMock.sol | 6 +- contracts/mocks/Create2Impl.sol | 6 +- contracts/mocks/DummyImplementation.sol | 6 +- contracts/mocks/ECDSAMock.sol | 13 +-- contracts/mocks/EIP712External.sol | 7 +- contracts/mocks/ERC1155BurnableMock.sol | 7 +- contracts/mocks/ERC1155Mock.sol | 26 +----- contracts/mocks/ERC1155ReceiverMock.sol | 7 +- contracts/mocks/ERC20CappedMock.sol | 6 +- contracts/mocks/ERC20DecimalsMock.sol | 6 +- contracts/mocks/ERC20Mock.sol | 12 +-- contracts/mocks/ERC3156FlashBorrowerMock.sol | 2 +- contracts/mocks/ERC4626Mock.sol | 32 +++----- contracts/mocks/ERC721BurnableMock.sol | 6 +- .../mocks/ERC721ConsecutiveEnumerableMock.sol | 10 +-- contracts/mocks/ERC721EnumerableMock.sol | 6 +- contracts/mocks/ERC721Mock.sol | 6 +- contracts/mocks/ERC721PausableMock.sol | 6 +- contracts/mocks/ERC721RoyaltyMock.sol | 6 +- contracts/mocks/ERC721URIStorageMock.sol | 6 +- contracts/mocks/ERC777Mock.sol | 20 +---- contracts/mocks/ERC777SenderRecipientMock.sol | 13 +-- .../mocks/GovernorCompatibilityBravoMock.sol | 27 +++---- .../mocks/GovernorPreventLateQuorumMock.sol | 9 +-- .../mocks/GovernorTimelockCompoundMock.sol | 27 +++---- .../mocks/GovernorTimelockControlMock.sol | 18 ++--- contracts/mocks/MathMock.sol | 7 +- contracts/mocks/MerkleProofWrapper.sol | 12 +-- .../MultipleInheritanceInitializableMocks.sol | 7 +- contracts/mocks/SafeERC20Helper.sol | 18 +---- contracts/mocks/SafeMathMock.sol | 18 +---- contracts/mocks/SignatureCheckerMock.sol | 6 +- contracts/mocks/UUPS/UUPSLegacy.sol | 6 +- contracts/mocks/crosschain/bridges.sol | 12 +-- contracts/mocks/wizard/MyGovernor1.sol | 28 +++---- contracts/mocks/wizard/MyGovernor2.sol | 28 +++---- contracts/mocks/wizard/MyGovernor3.sol | 37 +++------ contracts/proxy/Clones.sol | 9 +-- contracts/proxy/ERC1967/ERC1967Upgrade.sol | 18 +---- .../TransparentUpgradeableProxy.sol | 6 +- contracts/token/ERC1155/ERC1155.sol | 51 +++--------- contracts/token/ERC1155/IERC1155.sol | 16 ++-- .../ERC1155/extensions/ERC1155Burnable.sol | 12 +-- contracts/token/ERC20/ERC20.sol | 30 ++----- contracts/token/ERC20/IERC20.sol | 6 +- .../token/ERC20/extensions/ERC20Capped.sol | 6 +- .../token/ERC20/extensions/ERC20Pausable.sol | 6 +- .../token/ERC20/extensions/ERC20Snapshot.sol | 6 +- .../token/ERC20/extensions/ERC20Votes.sol | 6 +- contracts/token/ERC20/extensions/ERC4626.sol | 19 +---- contracts/token/ERC20/utils/SafeERC20.sol | 31 ++----- contracts/token/ERC20/utils/TokenTimelock.sol | 6 +- contracts/token/ERC721/ERC721.sol | 53 +++--------- contracts/token/ERC721/IERC721.sol | 19 +---- contracts/token/ERC721/utils/ERC721Holder.sol | 7 +- contracts/token/ERC777/ERC777.sol | 51 ++---------- contracts/token/ERC777/IERC777.sol | 13 +-- contracts/token/common/ERC2981.sol | 6 +- contracts/utils/Address.sol | 6 +- contracts/utils/Checkpoints.sol | 80 +++++-------------- contracts/utils/Create2.sol | 12 +-- contracts/utils/cryptography/ECDSA.sol | 26 +----- contracts/utils/cryptography/MerkleProof.sol | 12 +-- .../utils/cryptography/SignatureChecker.sol | 6 +- .../utils/introspection/ERC165Checker.sol | 9 +-- .../introspection/ERC1820Implementer.sol | 11 +-- .../utils/introspection/IERC1820Registry.sol | 6 +- contracts/utils/math/Math.sol | 41 ++++------ contracts/utils/math/SafeMath.sol | 18 +---- contracts/utils/structs/BitMaps.sol | 6 +- contracts/utils/structs/EnumerableMap.sol | 36 ++------- contracts/vendor/amb/IAMB.sol | 14 +--- contracts/vendor/arbitrum/IArbSys.sol | 9 +-- contracts/vendor/arbitrum/IBridge.sol | 9 +-- contracts/vendor/arbitrum/IOutbox.sol | 6 +- .../vendor/optimism/ICrossDomainMessenger.sol | 6 +- .../vendor/polygon/IFxMessageProcessor.sol | 6 +- test/utils/math/Math.t.sol | 42 +++------- 97 files changed, 326 insertions(+), 1111 deletions(-) diff --git a/contracts/crosschain/polygon/CrossChainEnabledPolygonChild.sol b/contracts/crosschain/polygon/CrossChainEnabledPolygonChild.sol index 3918bfe25d8..fa099483499 100644 --- a/contracts/crosschain/polygon/CrossChainEnabledPolygonChild.sol +++ b/contracts/crosschain/polygon/CrossChainEnabledPolygonChild.sol @@ -59,7 +59,7 @@ abstract contract CrossChainEnabledPolygonChild is IFxMessageProcessor, CrossCha * then security could be compromised. */ function processMessageFromRoot( - uint256, /* stateId */ + uint256 /* stateId */, address rootMessageSender, bytes calldata data ) external override nonReentrant { diff --git a/contracts/finance/VestingWallet.sol b/contracts/finance/VestingWallet.sol index 0feac4ac6ab..fe67eb54ff6 100644 --- a/contracts/finance/VestingWallet.sol +++ b/contracts/finance/VestingWallet.sol @@ -29,11 +29,7 @@ contract VestingWallet is Context { /** * @dev Set the beneficiary, start timestamp and vesting duration of the vesting wallet. */ - constructor( - address beneficiaryAddress, - uint64 startTimestamp, - uint64 durationSeconds - ) payable { + constructor(address beneficiaryAddress, uint64 startTimestamp, uint64 durationSeconds) payable { require(beneficiaryAddress != address(0), "VestingWallet: beneficiary is zero address"); _beneficiary = beneficiaryAddress; _start = startTimestamp; diff --git a/contracts/governance/Governor.sol b/contracts/governance/Governor.sol index 84b3128ff0c..8235fb5ecb1 100644 --- a/contracts/governance/Governor.sol +++ b/contracts/governance/Governor.sol @@ -314,7 +314,7 @@ abstract contract Governor is Context, ERC165, EIP712, IGovernor, IERC721Receive * @dev Internal execution mechanism. Can be overridden to implement different execution mechanism */ function _execute( - uint256, /* proposalId */ + uint256 /* proposalId */, address[] memory targets, uint256[] memory values, bytes[] memory calldatas, @@ -331,9 +331,9 @@ abstract contract Governor is Context, ERC165, EIP712, IGovernor, IERC721Receive * @dev Hook before execution is triggered. */ function _beforeExecute( - uint256, /* proposalId */ + uint256 /* proposalId */, address[] memory targets, - uint256[] memory, /* values */ + uint256[] memory /* values */, bytes[] memory calldatas, bytes32 /*descriptionHash*/ ) internal virtual { @@ -350,10 +350,10 @@ abstract contract Governor is Context, ERC165, EIP712, IGovernor, IERC721Receive * @dev Hook after execution is triggered. */ function _afterExecute( - uint256, /* proposalId */ - address[] memory, /* targets */ - uint256[] memory, /* values */ - bytes[] memory, /* calldatas */ + uint256 /* proposalId */, + address[] memory /* targets */, + uint256[] memory /* values */, + bytes[] memory /* calldatas */, bytes32 /*descriptionHash*/ ) internal virtual { if (_executor() != address(this)) { @@ -540,11 +540,7 @@ abstract contract Governor is Context, ERC165, EIP712, IGovernor, IERC721Receive * in a governance proposal to recover tokens or Ether that was sent to the governor contract by mistake. * Note that if the executor is simply the governor itself, use of `relay` is redundant. */ - function relay( - address target, - uint256 value, - bytes calldata data - ) external payable virtual onlyGovernance { + function relay(address target, uint256 value, bytes calldata data) external payable virtual onlyGovernance { (bool success, bytes memory returndata) = target.call{value: value}(data); Address.verifyCallResult(success, returndata, "Governor: relay reverted without message"); } @@ -560,12 +556,7 @@ abstract contract Governor is Context, ERC165, EIP712, IGovernor, IERC721Receive /** * @dev See {IERC721Receiver-onERC721Received}. */ - function onERC721Received( - address, - address, - uint256, - bytes memory - ) public virtual override returns (bytes4) { + function onERC721Received(address, address, uint256, bytes memory) public virtual override returns (bytes4) { return this.onERC721Received.selector; } diff --git a/contracts/governance/TimelockController.sol b/contracts/governance/TimelockController.sol index 43eedd23468..67e6d206c2d 100644 --- a/contracts/governance/TimelockController.sol +++ b/contracts/governance/TimelockController.sol @@ -73,12 +73,7 @@ contract TimelockController is AccessControl, IERC721Receiver, IERC1155Receiver * administration through timelocked proposals. Previous versions of this contract would assign * this admin to the deployer automatically and should be renounced as well. */ - constructor( - uint256 minDelay, - address[] memory proposers, - address[] memory executors, - address admin - ) { + constructor(uint256 minDelay, address[] memory proposers, address[] memory executors, address admin) { // self administration _grantRole(DEFAULT_ADMIN_ROLE, address(this)); @@ -336,11 +331,7 @@ contract TimelockController is AccessControl, IERC721Receiver, IERC1155Receiver /** * @dev Execute an operation's call. */ - function _execute( - address target, - uint256 value, - bytes calldata data - ) internal virtual { + function _execute(address target, uint256 value, bytes calldata data) internal virtual { (bool success, ) = target.call{value: value}(data); require(success, "TimelockController: underlying transaction reverted"); } @@ -380,12 +371,7 @@ contract TimelockController is AccessControl, IERC721Receiver, IERC1155Receiver /** * @dev See {IERC721Receiver-onERC721Received}. */ - function onERC721Received( - address, - address, - uint256, - bytes memory - ) public virtual override returns (bytes4) { + function onERC721Received(address, address, uint256, bytes memory) public virtual override returns (bytes4) { return this.onERC721Received.selector; } diff --git a/contracts/governance/compatibility/GovernorCompatibilityBravo.sol b/contracts/governance/compatibility/GovernorCompatibilityBravo.sol index 8d96be7d676..8d74742c5bb 100644 --- a/contracts/governance/compatibility/GovernorCompatibilityBravo.sol +++ b/contracts/governance/compatibility/GovernorCompatibilityBravo.sol @@ -118,11 +118,10 @@ abstract contract GovernorCompatibilityBravo is IGovernorTimelock, IGovernorComp /** * @dev Encodes calldatas with optional function signature. */ - function _encodeCalldata(string[] memory signatures, bytes[] memory calldatas) - private - pure - returns (bytes[] memory) - { + function _encodeCalldata( + string[] memory signatures, + bytes[] memory calldatas + ) private pure returns (bytes[] memory) { bytes[] memory fullcalldatas = new bytes[](calldatas.length); for (uint256 i = 0; i < signatures.length; ++i) { @@ -163,7 +162,9 @@ abstract contract GovernorCompatibilityBravo is IGovernorTimelock, IGovernorComp /** * @dev See {IGovernorCompatibilityBravo-proposals}. */ - function proposals(uint256 proposalId) + function proposals( + uint256 proposalId + ) public view virtual @@ -200,7 +201,9 @@ abstract contract GovernorCompatibilityBravo is IGovernorTimelock, IGovernorComp /** * @dev See {IGovernorCompatibilityBravo-getActions}. */ - function getActions(uint256 proposalId) + function getActions( + uint256 proposalId + ) public view virtual diff --git a/contracts/governance/compatibility/IGovernorCompatibilityBravo.sol b/contracts/governance/compatibility/IGovernorCompatibilityBravo.sol index 83e4e1ae9c0..d1ec0337d00 100644 --- a/contracts/governance/compatibility/IGovernorCompatibilityBravo.sol +++ b/contracts/governance/compatibility/IGovernorCompatibilityBravo.sol @@ -50,7 +50,9 @@ abstract contract IGovernorCompatibilityBravo is IGovernor { /** * @dev Part of the Governor Bravo's interface: _"The official record of all proposals ever proposed"_. */ - function proposals(uint256) + function proposals( + uint256 + ) public view virtual @@ -96,7 +98,9 @@ abstract contract IGovernorCompatibilityBravo is IGovernor { /** * @dev Part of the Governor Bravo's interface: _"Gets actions of a proposal"_. */ - function getActions(uint256 proposalId) + function getActions( + uint256 proposalId + ) public view virtual diff --git a/contracts/governance/extensions/GovernorCountingSimple.sol b/contracts/governance/extensions/GovernorCountingSimple.sol index 5611fc6692c..f3eea9d7fa4 100644 --- a/contracts/governance/extensions/GovernorCountingSimple.sol +++ b/contracts/governance/extensions/GovernorCountingSimple.sol @@ -47,16 +47,9 @@ abstract contract GovernorCountingSimple is Governor { /** * @dev Accessor to the internal vote counts. */ - function proposalVotes(uint256 proposalId) - public - view - virtual - returns ( - uint256 againstVotes, - uint256 forVotes, - uint256 abstainVotes - ) - { + function proposalVotes( + uint256 proposalId + ) public view virtual returns (uint256 againstVotes, uint256 forVotes, uint256 abstainVotes) { ProposalVote storage proposalVote = _proposalVotes[proposalId]; return (proposalVote.againstVotes, proposalVote.forVotes, proposalVote.abstainVotes); } diff --git a/contracts/governance/extensions/GovernorSettings.sol b/contracts/governance/extensions/GovernorSettings.sol index a3187c6e16e..527f41cd8a8 100644 --- a/contracts/governance/extensions/GovernorSettings.sol +++ b/contracts/governance/extensions/GovernorSettings.sol @@ -22,11 +22,7 @@ abstract contract GovernorSettings is Governor { /** * @dev Initialize the governance parameters. */ - constructor( - uint256 initialVotingDelay, - uint256 initialVotingPeriod, - uint256 initialProposalThreshold - ) { + constructor(uint256 initialVotingDelay, uint256 initialVotingPeriod, uint256 initialProposalThreshold) { _setVotingDelay(initialVotingDelay); _setVotingPeriod(initialVotingPeriod); _setProposalThreshold(initialProposalThreshold); diff --git a/contracts/governance/extensions/GovernorTimelockControl.sol b/contracts/governance/extensions/GovernorTimelockControl.sol index aaeaf940926..6aa2556abf1 100644 --- a/contracts/governance/extensions/GovernorTimelockControl.sol +++ b/contracts/governance/extensions/GovernorTimelockControl.sol @@ -110,7 +110,7 @@ abstract contract GovernorTimelockControl is IGovernorTimelock, Governor { * @dev Overridden execute function that run the already queued proposal through the timelock. */ function _execute( - uint256, /* proposalId */ + uint256 /* proposalId */, address[] memory targets, uint256[] memory values, bytes[] memory calldatas, diff --git a/contracts/governance/utils/IVotes.sol b/contracts/governance/utils/IVotes.sol index 6317d7752e0..0bef3f92079 100644 --- a/contracts/governance/utils/IVotes.sol +++ b/contracts/governance/utils/IVotes.sol @@ -50,12 +50,5 @@ interface IVotes { /** * @dev Delegates votes from signer to `delegatee`. */ - function delegateBySig( - address delegatee, - uint256 nonce, - uint256 expiry, - uint8 v, - bytes32 r, - bytes32 s - ) external; + function delegateBySig(address delegatee, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s) external; } diff --git a/contracts/governance/utils/Votes.sol b/contracts/governance/utils/Votes.sol index 801be3bcd32..492c1afb157 100644 --- a/contracts/governance/utils/Votes.sol +++ b/contracts/governance/utils/Votes.sol @@ -134,11 +134,7 @@ abstract contract Votes is IVotes, Context, EIP712, Nonces { * @dev Transfers, mints, or burns voting units. To register a mint, `from` should be zero. To register a burn, `to` * should be zero. Total supply of voting units will be adjusted with mints and burns. */ - function _transferVotingUnits( - address from, - address to, - uint256 amount - ) internal virtual { + function _transferVotingUnits(address from, address to, uint256 amount) internal virtual { if (from == address(0)) { _totalCheckpoints.push(_add, amount); } @@ -151,11 +147,7 @@ abstract contract Votes is IVotes, Context, EIP712, Nonces { /** * @dev Moves delegated votes from one delegate to another. */ - function _moveDelegateVotes( - address from, - address to, - uint256 amount - ) private { + function _moveDelegateVotes(address from, address to, uint256 amount) private { if (from != to && amount > 0) { if (from != address(0)) { (uint256 oldValue, uint256 newValue) = _delegateCheckpoints[from].push(_subtract, amount); diff --git a/contracts/interfaces/IERC1363.sol b/contracts/interfaces/IERC1363.sol index 5fad104c223..1a8dc79f438 100644 --- a/contracts/interfaces/IERC1363.sol +++ b/contracts/interfaces/IERC1363.sol @@ -38,11 +38,7 @@ interface IERC1363 is IERC165, IERC20 { * @param data bytes Additional data with no specified format, sent in call to `to` * @return true unless throwing */ - function transferAndCall( - address to, - uint256 value, - bytes memory data - ) external returns (bool); + function transferAndCall(address to, uint256 value, bytes memory data) external returns (bool); /** * @dev Transfer tokens from one address to another and then call `onTransferReceived` on receiver @@ -51,11 +47,7 @@ interface IERC1363 is IERC165, IERC20 { * @param value uint256 The amount of tokens to be transferred * @return true unless throwing */ - function transferFromAndCall( - address from, - address to, - uint256 value - ) external returns (bool); + function transferFromAndCall(address from, address to, uint256 value) external returns (bool); /** * @dev Transfer tokens from one address to another and then call `onTransferReceived` on receiver @@ -65,12 +57,7 @@ interface IERC1363 is IERC165, IERC20 { * @param data bytes Additional data with no specified format, sent in call to `to` * @return true unless throwing */ - function transferFromAndCall( - address from, - address to, - uint256 value, - bytes memory data - ) external returns (bool); + function transferFromAndCall(address from, address to, uint256 value, bytes memory data) external returns (bool); /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender @@ -87,9 +74,5 @@ interface IERC1363 is IERC165, IERC20 { * @param value uint256 The amount of tokens to be spent * @param data bytes Additional data with no specified format, sent in call to `spender` */ - function approveAndCall( - address spender, - uint256 value, - bytes memory data - ) external returns (bool); + function approveAndCall(address spender, uint256 value, bytes memory data) external returns (bool); } diff --git a/contracts/interfaces/IERC1363Spender.sol b/contracts/interfaces/IERC1363Spender.sol index 48f6fd56d6d..28775e1406b 100644 --- a/contracts/interfaces/IERC1363Spender.sol +++ b/contracts/interfaces/IERC1363Spender.sol @@ -22,9 +22,5 @@ interface IERC1363Spender { * @return `bytes4(keccak256("onApprovalReceived(address,uint256,bytes)"))` * unless throwing */ - function onApprovalReceived( - address owner, - uint256 value, - bytes memory data - ) external returns (bytes4); + function onApprovalReceived(address owner, uint256 value, bytes memory data) external returns (bytes4); } diff --git a/contracts/interfaces/IERC2981.sol b/contracts/interfaces/IERC2981.sol index 6b0558169ea..1c9448a9147 100644 --- a/contracts/interfaces/IERC2981.sol +++ b/contracts/interfaces/IERC2981.sol @@ -18,8 +18,8 @@ interface IERC2981 is IERC165 { * @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of * exchange. The royalty amount is denominated and should be paid in that same unit of exchange. */ - function royaltyInfo(uint256 tokenId, uint256 salePrice) - external - view - returns (address receiver, uint256 royaltyAmount); + function royaltyInfo( + uint256 tokenId, + uint256 salePrice + ) external view returns (address receiver, uint256 royaltyAmount); } diff --git a/contracts/interfaces/IERC4626.sol b/contracts/interfaces/IERC4626.sol index f7c5397a0fa..08e5de7176b 100644 --- a/contracts/interfaces/IERC4626.sol +++ b/contracts/interfaces/IERC4626.sol @@ -187,11 +187,7 @@ interface IERC4626 is IERC20, IERC20Metadata { * Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed. * Those methods should be performed separately. */ - function withdraw( - uint256 assets, - address receiver, - address owner - ) external returns (uint256 shares); + function withdraw(uint256 assets, address receiver, address owner) external returns (uint256 shares); /** * @dev Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault, @@ -232,9 +228,5 @@ interface IERC4626 is IERC20, IERC20Metadata { * NOTE: some implementations will require pre-requesting to the Vault before a withdrawal may be performed. * Those methods should be performed separately. */ - function redeem( - uint256 shares, - address receiver, - address owner - ) external returns (uint256 assets); + function redeem(uint256 shares, address receiver, address owner) external returns (uint256 assets); } diff --git a/contracts/metatx/MinimalForwarder.sol b/contracts/metatx/MinimalForwarder.sol index bb49c794dbb..9298ae6751c 100644 --- a/contracts/metatx/MinimalForwarder.sol +++ b/contracts/metatx/MinimalForwarder.sol @@ -44,11 +44,10 @@ contract MinimalForwarder is EIP712 { return _nonces[req.from] == req.nonce && signer == req.from; } - function execute(ForwardRequest calldata req, bytes calldata signature) - public - payable - returns (bool, bytes memory) - { + function execute( + ForwardRequest calldata req, + bytes calldata signature + ) public payable returns (bool, bytes memory) { require(verify(req, signature), "MinimalForwarder: signature does not match request"); _nonces[req.from] = req.nonce + 1; diff --git a/contracts/mocks/AddressImpl.sol b/contracts/mocks/AddressImpl.sol index 702093c7337..b06bec37284 100644 --- a/contracts/mocks/AddressImpl.sol +++ b/contracts/mocks/AddressImpl.sol @@ -22,11 +22,7 @@ contract AddressImpl { emit CallReturnValue(abi.decode(returnData, (string))); } - function functionCallWithValue( - address target, - bytes calldata data, - uint256 value - ) external payable { + function functionCallWithValue(address target, bytes calldata data, uint256 value) external payable { bytes memory returnData = Address.functionCallWithValue(target, data, value); emit CallReturnValue(abi.decode(returnData, (string))); } diff --git a/contracts/mocks/CheckpointsMock.sol b/contracts/mocks/CheckpointsMock.sol index f1dadabaf7d..874a1d1f213 100644 --- a/contracts/mocks/CheckpointsMock.sol +++ b/contracts/mocks/CheckpointsMock.sol @@ -14,15 +14,7 @@ contract CheckpointsMock { return _totalCheckpoints.latest(); } - function latestCheckpoint() - public - view - returns ( - bool, - uint256, - uint256 - ) - { + function latestCheckpoint() public view returns (bool, uint256, uint256) { return _totalCheckpoints.latestCheckpoint(); } @@ -52,15 +44,7 @@ contract Checkpoints224Mock { return _totalCheckpoints.latest(); } - function latestCheckpoint() - public - view - returns ( - bool, - uint32, - uint224 - ) - { + function latestCheckpoint() public view returns (bool, uint32, uint224) { return _totalCheckpoints.latestCheckpoint(); } @@ -90,15 +74,7 @@ contract Checkpoints160Mock { return _totalCheckpoints.latest(); } - function latestCheckpoint() - public - view - returns ( - bool, - uint96, - uint160 - ) - { + function latestCheckpoint() public view returns (bool, uint96, uint160) { return _totalCheckpoints.latestCheckpoint(); } diff --git a/contracts/mocks/ClonesMock.sol b/contracts/mocks/ClonesMock.sol index 3719b0a7835..c65d30cc3b0 100644 --- a/contracts/mocks/ClonesMock.sol +++ b/contracts/mocks/ClonesMock.sol @@ -15,11 +15,7 @@ contract ClonesMock { _initAndEmit(implementation.clone(), initdata); } - function cloneDeterministic( - address implementation, - bytes32 salt, - bytes calldata initdata - ) public payable { + function cloneDeterministic(address implementation, bytes32 salt, bytes calldata initdata) public payable { _initAndEmit(implementation.cloneDeterministic(salt), initdata); } diff --git a/contracts/mocks/ContextMock.sol b/contracts/mocks/ContextMock.sol index f17af38a49a..7759f350639 100644 --- a/contracts/mocks/ContextMock.sol +++ b/contracts/mocks/ContextMock.sol @@ -23,11 +23,7 @@ contract ContextMockCaller { context.msgSender(); } - function callData( - ContextMock context, - uint256 integerValue, - string memory stringValue - ) public { + function callData(ContextMock context, uint256 integerValue, string memory stringValue) public { context.msgData(integerValue, stringValue); } } diff --git a/contracts/mocks/Create2Impl.sol b/contracts/mocks/Create2Impl.sol index 070ad3671c5..6b2f4b712e5 100644 --- a/contracts/mocks/Create2Impl.sol +++ b/contracts/mocks/Create2Impl.sol @@ -6,11 +6,7 @@ import "../utils/Create2.sol"; import "../utils/introspection/ERC1820Implementer.sol"; contract Create2Impl { - function deploy( - uint256 value, - bytes32 salt, - bytes memory code - ) public { + function deploy(uint256 value, bytes32 salt, bytes memory code) public { Create2.deploy(value, salt, code); } diff --git a/contracts/mocks/DummyImplementation.sol b/contracts/mocks/DummyImplementation.sol index d8651340d1b..ddcca660439 100644 --- a/contracts/mocks/DummyImplementation.sol +++ b/contracts/mocks/DummyImplementation.sol @@ -27,11 +27,7 @@ contract DummyImplementation { value = _value; } - function initialize( - uint256 _value, - string memory _text, - uint256[] memory _values - ) public { + function initialize(uint256 _value, string memory _text, uint256[] memory _values) public { value = _value; text = _text; values = _values; diff --git a/contracts/mocks/ECDSAMock.sol b/contracts/mocks/ECDSAMock.sol index 97bd46669a6..cfc37d26ea6 100644 --- a/contracts/mocks/ECDSAMock.sol +++ b/contracts/mocks/ECDSAMock.sol @@ -13,21 +13,12 @@ contract ECDSAMock { } // solhint-disable-next-line func-name-mixedcase - function recover_v_r_s( - bytes32 hash, - uint8 v, - bytes32 r, - bytes32 s - ) public pure returns (address) { + function recover_v_r_s(bytes32 hash, uint8 v, bytes32 r, bytes32 s) public pure returns (address) { return hash.recover(v, r, s); } // solhint-disable-next-line func-name-mixedcase - function recover_r_vs( - bytes32 hash, - bytes32 r, - bytes32 vs - ) public pure returns (address) { + function recover_r_vs(bytes32 hash, bytes32 r, bytes32 vs) public pure returns (address) { return hash.recover(r, vs); } diff --git a/contracts/mocks/EIP712External.sol b/contracts/mocks/EIP712External.sol index 93f77d54946..bc5b1269f7c 100644 --- a/contracts/mocks/EIP712External.sol +++ b/contracts/mocks/EIP712External.sol @@ -12,12 +12,7 @@ contract EIP712External is EIP712 { return _domainSeparatorV4(); } - function verify( - bytes memory signature, - address signer, - address mailTo, - string memory mailContents - ) external view { + function verify(bytes memory signature, address signer, address mailTo, string memory mailContents) external view { bytes32 digest = _hashTypedDataV4( keccak256(abi.encode(keccak256("Mail(address to,string contents)"), mailTo, keccak256(bytes(mailContents)))) ); diff --git a/contracts/mocks/ERC1155BurnableMock.sol b/contracts/mocks/ERC1155BurnableMock.sol index 62138f28da6..3334523cf74 100644 --- a/contracts/mocks/ERC1155BurnableMock.sol +++ b/contracts/mocks/ERC1155BurnableMock.sol @@ -7,12 +7,7 @@ import "../token/ERC1155/extensions/ERC1155Burnable.sol"; contract ERC1155BurnableMock is ERC1155Burnable { constructor(string memory uri) ERC1155(uri) {} - function mint( - address to, - uint256 id, - uint256 value, - bytes memory data - ) public { + function mint(address to, uint256 id, uint256 value, bytes memory data) public { _mint(to, id, value, data); } } diff --git a/contracts/mocks/ERC1155Mock.sol b/contracts/mocks/ERC1155Mock.sol index 0518ac26c17..6bfc86ceaf3 100644 --- a/contracts/mocks/ERC1155Mock.sol +++ b/contracts/mocks/ERC1155Mock.sol @@ -15,37 +15,19 @@ contract ERC1155Mock is ERC1155 { _setURI(newuri); } - function mint( - address to, - uint256 id, - uint256 value, - bytes memory data - ) public { + function mint(address to, uint256 id, uint256 value, bytes memory data) public { _mint(to, id, value, data); } - function mintBatch( - address to, - uint256[] memory ids, - uint256[] memory values, - bytes memory data - ) public { + function mintBatch(address to, uint256[] memory ids, uint256[] memory values, bytes memory data) public { _mintBatch(to, ids, values, data); } - function burn( - address owner, - uint256 id, - uint256 value - ) public { + function burn(address owner, uint256 id, uint256 value) public { _burn(owner, id, value); } - function burnBatch( - address owner, - uint256[] memory ids, - uint256[] memory values - ) public { + function burnBatch(address owner, uint256[] memory ids, uint256[] memory values) public { _burnBatch(owner, ids, values); } } diff --git a/contracts/mocks/ERC1155ReceiverMock.sol b/contracts/mocks/ERC1155ReceiverMock.sol index 6443a56c7ae..b2d505c0a86 100644 --- a/contracts/mocks/ERC1155ReceiverMock.sol +++ b/contracts/mocks/ERC1155ReceiverMock.sol @@ -14,12 +14,7 @@ contract ERC1155ReceiverMock is ERC165, IERC1155Receiver { event Received(address operator, address from, uint256 id, uint256 value, bytes data, uint256 gas); event BatchReceived(address operator, address from, uint256[] ids, uint256[] values, bytes data, uint256 gas); - constructor( - bytes4 recRetval, - bool recReverts, - bytes4 batRetval, - bool batReverts - ) { + constructor(bytes4 recRetval, bool recReverts, bytes4 batRetval, bool batReverts) { _recRetval = recRetval; _recReverts = recReverts; _batRetval = batRetval; diff --git a/contracts/mocks/ERC20CappedMock.sol b/contracts/mocks/ERC20CappedMock.sol index edb36f20531..e69aadfdf30 100644 --- a/contracts/mocks/ERC20CappedMock.sol +++ b/contracts/mocks/ERC20CappedMock.sol @@ -5,11 +5,7 @@ pragma solidity ^0.8.0; import "../token/ERC20/extensions/ERC20Capped.sol"; contract ERC20CappedMock is ERC20Capped { - constructor( - string memory name, - string memory symbol, - uint256 cap - ) ERC20(name, symbol) ERC20Capped(cap) {} + constructor(string memory name, string memory symbol, uint256 cap) ERC20(name, symbol) ERC20Capped(cap) {} function mint(address to, uint256 tokenId) public { _mint(to, tokenId); diff --git a/contracts/mocks/ERC20DecimalsMock.sol b/contracts/mocks/ERC20DecimalsMock.sol index 3721f6c393b..7677e9dd1d1 100644 --- a/contracts/mocks/ERC20DecimalsMock.sol +++ b/contracts/mocks/ERC20DecimalsMock.sol @@ -7,11 +7,7 @@ import "../token/ERC20/ERC20.sol"; contract ERC20DecimalsMock is ERC20 { uint8 private immutable _decimals; - constructor( - string memory name_, - string memory symbol_, - uint8 decimals_ - ) ERC20(name_, symbol_) { + constructor(string memory name_, string memory symbol_, uint8 decimals_) ERC20(name_, symbol_) { _decimals = decimals_; } diff --git a/contracts/mocks/ERC20Mock.sol b/contracts/mocks/ERC20Mock.sol index fd7f991baf0..16ffad19fe5 100644 --- a/contracts/mocks/ERC20Mock.sol +++ b/contracts/mocks/ERC20Mock.sol @@ -23,19 +23,11 @@ contract ERC20Mock is ERC20 { _burn(account, amount); } - function transferInternal( - address from, - address to, - uint256 value - ) public { + function transferInternal(address from, address to, uint256 value) public { _transfer(from, to, value); } - function approveInternal( - address owner, - address spender, - uint256 value - ) public { + function approveInternal(address owner, address spender, uint256 value) public { _approve(owner, spender, value); } } diff --git a/contracts/mocks/ERC3156FlashBorrowerMock.sol b/contracts/mocks/ERC3156FlashBorrowerMock.sol index 288a278fb80..6a4410fcb1d 100644 --- a/contracts/mocks/ERC3156FlashBorrowerMock.sol +++ b/contracts/mocks/ERC3156FlashBorrowerMock.sol @@ -28,7 +28,7 @@ contract ERC3156FlashBorrowerMock is IERC3156FlashBorrower { } function onFlashLoan( - address, /*initiator*/ + address /*initiator*/, address token, uint256 amount, uint256 fee, diff --git a/contracts/mocks/ERC4626Mock.sol b/contracts/mocks/ERC4626Mock.sol index 4f80b4bd75b..9c13346f059 100644 --- a/contracts/mocks/ERC4626Mock.sol +++ b/contracts/mocks/ERC4626Mock.sol @@ -5,11 +5,7 @@ pragma solidity ^0.8.0; import "../token/ERC20/extensions/ERC4626.sol"; contract ERC4626Mock is ERC4626 { - constructor( - IERC20Metadata asset, - string memory name, - string memory symbol - ) ERC20(name, symbol) ERC4626(asset) {} + constructor(IERC20Metadata asset, string memory name, string memory symbol) ERC20(name, symbol) ERC4626(asset) {} function mockMint(address account, uint256 amount) public { _mint(account, amount); @@ -38,23 +34,17 @@ contract ERC4626DecimalMock is ERC4626Mock { return _decimals; } - function _initialConvertToShares(uint256 assets, Math.Rounding rounding) - internal - view - virtual - override - returns (uint256 shares) - { - return assets.mulDiv(10**decimals(), 10**super.decimals(), rounding); + function _initialConvertToShares( + uint256 assets, + Math.Rounding rounding + ) internal view virtual override returns (uint256 shares) { + return assets.mulDiv(10 ** decimals(), 10 ** super.decimals(), rounding); } - function _initialConvertToAssets(uint256 shares, Math.Rounding rounding) - internal - view - virtual - override - returns (uint256 assets) - { - return shares.mulDiv(10**super.decimals(), 10**decimals(), rounding); + function _initialConvertToAssets( + uint256 shares, + Math.Rounding rounding + ) internal view virtual override returns (uint256 assets) { + return shares.mulDiv(10 ** super.decimals(), 10 ** decimals(), rounding); } } diff --git a/contracts/mocks/ERC721BurnableMock.sol b/contracts/mocks/ERC721BurnableMock.sol index b30dbf53dfb..ecf42768182 100644 --- a/contracts/mocks/ERC721BurnableMock.sol +++ b/contracts/mocks/ERC721BurnableMock.sol @@ -19,11 +19,7 @@ contract ERC721BurnableMock is ERC721Burnable { _safeMint(to, tokenId); } - function safeMint( - address to, - uint256 tokenId, - bytes memory _data - ) public { + function safeMint(address to, uint256 tokenId, bytes memory _data) public { _safeMint(to, tokenId, _data); } } diff --git a/contracts/mocks/ERC721ConsecutiveEnumerableMock.sol b/contracts/mocks/ERC721ConsecutiveEnumerableMock.sol index cde3bd86cff..f4f5c5832be 100644 --- a/contracts/mocks/ERC721ConsecutiveEnumerableMock.sol +++ b/contracts/mocks/ERC721ConsecutiveEnumerableMock.sol @@ -17,13 +17,9 @@ contract ERC721ConsecutiveEnumerableMock is ERC721Consecutive, ERC721Enumerable } } - function supportsInterface(bytes4 interfaceId) - public - view - virtual - override(ERC721, ERC721Enumerable) - returns (bool) - { + function supportsInterface( + bytes4 interfaceId + ) public view virtual override(ERC721, ERC721Enumerable) returns (bool) { return super.supportsInterface(interfaceId); } diff --git a/contracts/mocks/ERC721EnumerableMock.sol b/contracts/mocks/ERC721EnumerableMock.sol index a747925e69d..b7ea94ee3f2 100644 --- a/contracts/mocks/ERC721EnumerableMock.sol +++ b/contracts/mocks/ERC721EnumerableMock.sol @@ -37,11 +37,7 @@ contract ERC721EnumerableMock is ERC721Enumerable { _safeMint(to, tokenId); } - function safeMint( - address to, - uint256 tokenId, - bytes memory _data - ) public { + function safeMint(address to, uint256 tokenId, bytes memory _data) public { _safeMint(to, tokenId, _data); } diff --git a/contracts/mocks/ERC721Mock.sol b/contracts/mocks/ERC721Mock.sol index 74a09233469..a3bc839ae7b 100644 --- a/contracts/mocks/ERC721Mock.sol +++ b/contracts/mocks/ERC721Mock.sol @@ -27,11 +27,7 @@ contract ERC721Mock is ERC721 { _safeMint(to, tokenId); } - function safeMint( - address to, - uint256 tokenId, - bytes memory _data - ) public { + function safeMint(address to, uint256 tokenId, bytes memory _data) public { _safeMint(to, tokenId, _data); } diff --git a/contracts/mocks/ERC721PausableMock.sol b/contracts/mocks/ERC721PausableMock.sol index 8d8e818fb17..753842e902b 100644 --- a/contracts/mocks/ERC721PausableMock.sol +++ b/contracts/mocks/ERC721PausableMock.sol @@ -31,11 +31,7 @@ contract ERC721PausableMock is ERC721Pausable { _safeMint(to, tokenId); } - function safeMint( - address to, - uint256 tokenId, - bytes memory _data - ) public { + function safeMint(address to, uint256 tokenId, bytes memory _data) public { _safeMint(to, tokenId, _data); } diff --git a/contracts/mocks/ERC721RoyaltyMock.sol b/contracts/mocks/ERC721RoyaltyMock.sol index 83a9074e2c1..6f19d5248d2 100644 --- a/contracts/mocks/ERC721RoyaltyMock.sol +++ b/contracts/mocks/ERC721RoyaltyMock.sol @@ -7,11 +7,7 @@ import "../token/ERC721/extensions/ERC721Royalty.sol"; contract ERC721RoyaltyMock is ERC721Royalty { constructor(string memory name, string memory symbol) ERC721(name, symbol) {} - function setTokenRoyalty( - uint256 tokenId, - address recipient, - uint96 fraction - ) public { + function setTokenRoyalty(uint256 tokenId, address recipient, uint96 fraction) public { _setTokenRoyalty(tokenId, recipient, fraction); } diff --git a/contracts/mocks/ERC721URIStorageMock.sol b/contracts/mocks/ERC721URIStorageMock.sol index 60f9f7b7c1a..4bb26b1ada7 100644 --- a/contracts/mocks/ERC721URIStorageMock.sol +++ b/contracts/mocks/ERC721URIStorageMock.sol @@ -41,11 +41,7 @@ contract ERC721URIStorageMock is ERC721URIStorage { _safeMint(to, tokenId); } - function safeMint( - address to, - uint256 tokenId, - bytes memory _data - ) public { + function safeMint(address to, uint256 tokenId, bytes memory _data) public { _safeMint(to, tokenId, _data); } diff --git a/contracts/mocks/ERC777Mock.sol b/contracts/mocks/ERC777Mock.sol index f8a3b67849d..59c00b30756 100644 --- a/contracts/mocks/ERC777Mock.sol +++ b/contracts/mocks/ERC777Mock.sol @@ -18,12 +18,7 @@ contract ERC777Mock is Context, ERC777 { _mint(initialHolder, initialBalance, "", ""); } - function mintInternal( - address to, - uint256 amount, - bytes memory userData, - bytes memory operatorData - ) public { + function mintInternal(address to, uint256 amount, bytes memory userData, bytes memory operatorData) public { _mint(to, amount, userData, operatorData); } @@ -37,20 +32,11 @@ contract ERC777Mock is Context, ERC777 { _mint(to, amount, userData, operatorData, requireReceptionAck); } - function approveInternal( - address holder, - address spender, - uint256 value - ) public { + function approveInternal(address holder, address spender, uint256 value) public { _approve(holder, spender, value); } - function _beforeTokenTransfer( - address, - address, - address, - uint256 - ) internal override { + function _beforeTokenTransfer(address, address, address, uint256) internal override { emit BeforeTokenTransfer(); } } diff --git a/contracts/mocks/ERC777SenderRecipientMock.sol b/contracts/mocks/ERC777SenderRecipientMock.sol index 169912f699b..8e8c749ceda 100644 --- a/contracts/mocks/ERC777SenderRecipientMock.sol +++ b/contracts/mocks/ERC777SenderRecipientMock.sol @@ -141,21 +141,12 @@ contract ERC777SenderRecipientMock is Context, IERC777Sender, IERC777Recipient, _shouldRevertReceive = shouldRevert; } - function send( - IERC777 token, - address to, - uint256 amount, - bytes memory data - ) public { + function send(IERC777 token, address to, uint256 amount, bytes memory data) public { // This is 777's send function, not the Solidity send function token.send(to, amount, data); // solhint-disable-line check-send-result } - function burn( - IERC777 token, - uint256 amount, - bytes memory data - ) public { + function burn(IERC777 token, uint256 amount, bytes memory data) public { token.burn(amount, data); } } diff --git a/contracts/mocks/GovernorCompatibilityBravoMock.sol b/contracts/mocks/GovernorCompatibilityBravoMock.sol index 1ef0f94b92e..d3b4f707d16 100644 --- a/contracts/mocks/GovernorCompatibilityBravoMock.sol +++ b/contracts/mocks/GovernorCompatibilityBravoMock.sol @@ -27,12 +27,9 @@ contract GovernorCompatibilityBravoMock is GovernorVotesComp(token_) {} - function supportsInterface(bytes4 interfaceId) - public - view - override(IERC165, Governor, GovernorTimelockCompound) - returns (bool) - { + function supportsInterface( + bytes4 interfaceId + ) public view override(IERC165, Governor, GovernorTimelockCompound) returns (bool) { return super.supportsInterface(interfaceId); } @@ -40,21 +37,15 @@ contract GovernorCompatibilityBravoMock is return 0; } - function state(uint256 proposalId) - public - view - override(IGovernor, Governor, GovernorTimelockCompound) - returns (ProposalState) - { + function state( + uint256 proposalId + ) public view override(IGovernor, Governor, GovernorTimelockCompound) returns (ProposalState) { return super.state(proposalId); } - function proposalEta(uint256 proposalId) - public - view - override(IGovernorTimelock, GovernorTimelockCompound) - returns (uint256) - { + function proposalEta( + uint256 proposalId + ) public view override(IGovernorTimelock, GovernorTimelockCompound) returns (uint256) { return super.proposalEta(proposalId); } diff --git a/contracts/mocks/GovernorPreventLateQuorumMock.sol b/contracts/mocks/GovernorPreventLateQuorumMock.sol index d868ab22b62..b6b5e761970 100644 --- a/contracts/mocks/GovernorPreventLateQuorumMock.sol +++ b/contracts/mocks/GovernorPreventLateQuorumMock.sol @@ -35,12 +35,9 @@ contract GovernorPreventLateQuorumMock is return _quorum; } - function proposalDeadline(uint256 proposalId) - public - view - override(Governor, GovernorPreventLateQuorum) - returns (uint256) - { + function proposalDeadline( + uint256 proposalId + ) public view override(Governor, GovernorPreventLateQuorum) returns (uint256) { return super.proposalDeadline(proposalId); } diff --git a/contracts/mocks/GovernorTimelockCompoundMock.sol b/contracts/mocks/GovernorTimelockCompoundMock.sol index becc72a06ef..75a2f3c144c 100644 --- a/contracts/mocks/GovernorTimelockCompoundMock.sol +++ b/contracts/mocks/GovernorTimelockCompoundMock.sol @@ -28,21 +28,15 @@ contract GovernorTimelockCompoundMock is GovernorVotesQuorumFraction(quorumNumerator_) {} - function supportsInterface(bytes4 interfaceId) - public - view - override(Governor, GovernorTimelockCompound) - returns (bool) - { + function supportsInterface( + bytes4 interfaceId + ) public view override(Governor, GovernorTimelockCompound) returns (bool) { return super.supportsInterface(interfaceId); } - function quorum(uint256 blockNumber) - public - view - override(IGovernor, GovernorVotesQuorumFraction) - returns (uint256) - { + function quorum( + uint256 blockNumber + ) public view override(IGovernor, GovernorVotesQuorumFraction) returns (uint256) { return super.quorum(blockNumber); } @@ -58,12 +52,9 @@ contract GovernorTimelockCompoundMock is /** * Overriding nightmare */ - function state(uint256 proposalId) - public - view - override(Governor, GovernorTimelockCompound) - returns (ProposalState) - { + function state( + uint256 proposalId + ) public view override(Governor, GovernorTimelockCompound) returns (ProposalState) { return super.state(proposalId); } diff --git a/contracts/mocks/GovernorTimelockControlMock.sol b/contracts/mocks/GovernorTimelockControlMock.sol index ca412d1ca60..671a1e0ea03 100644 --- a/contracts/mocks/GovernorTimelockControlMock.sol +++ b/contracts/mocks/GovernorTimelockControlMock.sol @@ -28,21 +28,15 @@ contract GovernorTimelockControlMock is GovernorVotesQuorumFraction(quorumNumerator_) {} - function supportsInterface(bytes4 interfaceId) - public - view - override(Governor, GovernorTimelockControl) - returns (bool) - { + function supportsInterface( + bytes4 interfaceId + ) public view override(Governor, GovernorTimelockControl) returns (bool) { return super.supportsInterface(interfaceId); } - function quorum(uint256 blockNumber) - public - view - override(IGovernor, GovernorVotesQuorumFraction) - returns (uint256) - { + function quorum( + uint256 blockNumber + ) public view override(IGovernor, GovernorVotesQuorumFraction) returns (uint256) { return super.quorum(blockNumber); } diff --git a/contracts/mocks/MathMock.sol b/contracts/mocks/MathMock.sol index c6b1e872318..be935f91dee 100644 --- a/contracts/mocks/MathMock.sol +++ b/contracts/mocks/MathMock.sol @@ -21,12 +21,7 @@ contract MathMock { return Math.ceilDiv(a, b); } - function mulDiv( - uint256 a, - uint256 b, - uint256 denominator, - Math.Rounding direction - ) public pure returns (uint256) { + function mulDiv(uint256 a, uint256 b, uint256 denominator, Math.Rounding direction) public pure returns (uint256) { return Math.mulDiv(a, b, denominator, direction); } diff --git a/contracts/mocks/MerkleProofWrapper.sol b/contracts/mocks/MerkleProofWrapper.sol index b74459dc890..60741e41c03 100644 --- a/contracts/mocks/MerkleProofWrapper.sol +++ b/contracts/mocks/MerkleProofWrapper.sol @@ -5,19 +5,11 @@ pragma solidity ^0.8.0; import "../utils/cryptography/MerkleProof.sol"; contract MerkleProofWrapper { - function verify( - bytes32[] memory proof, - bytes32 root, - bytes32 leaf - ) public pure returns (bool) { + function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) public pure returns (bool) { return MerkleProof.verify(proof, root, leaf); } - function verifyCalldata( - bytes32[] calldata proof, - bytes32 root, - bytes32 leaf - ) public pure returns (bool) { + function verifyCalldata(bytes32[] calldata proof, bytes32 root, bytes32 leaf) public pure returns (bool) { return MerkleProof.verifyCalldata(proof, root, leaf); } diff --git a/contracts/mocks/MultipleInheritanceInitializableMocks.sol b/contracts/mocks/MultipleInheritanceInitializableMocks.sol index f6d6440654f..b8cf9d9d5d3 100644 --- a/contracts/mocks/MultipleInheritanceInitializableMocks.sol +++ b/contracts/mocks/MultipleInheritanceInitializableMocks.sol @@ -108,12 +108,7 @@ contract SampleFather is Initializable, SampleGramps { contract SampleChild is Initializable, SampleMother, SampleFather { uint256 public child; - function initialize( - uint256 _mother, - string memory _gramps, - uint256 _father, - uint256 _child - ) public initializer { + function initialize(uint256 _mother, string memory _gramps, uint256 _father, uint256 _child) public initializer { __SampleChild_init(_mother, _gramps, _father, _child); } diff --git a/contracts/mocks/SafeERC20Helper.sol b/contracts/mocks/SafeERC20Helper.sol index 98fdc644490..237e32041c4 100644 --- a/contracts/mocks/SafeERC20Helper.sol +++ b/contracts/mocks/SafeERC20Helper.sol @@ -19,11 +19,7 @@ contract ERC20ReturnFalseMock is Context { return false; } - function transferFrom( - address, - address, - uint256 - ) public returns (bool) { + function transferFrom(address, address, uint256) public returns (bool) { _dummy = 0; return false; } @@ -51,11 +47,7 @@ contract ERC20ReturnTrueMock is Context { return true; } - function transferFrom( - address, - address, - uint256 - ) public returns (bool) { + function transferFrom(address, address, uint256) public returns (bool) { _dummy = 0; return true; } @@ -85,11 +77,7 @@ contract ERC20NoReturnMock is Context { _dummy = 0; } - function transferFrom( - address, - address, - uint256 - ) public { + function transferFrom(address, address, uint256) public { _dummy = 0; } diff --git a/contracts/mocks/SafeMathMock.sol b/contracts/mocks/SafeMathMock.sol index 3d1f4727ee5..ef504e3ab90 100644 --- a/contracts/mocks/SafeMathMock.sol +++ b/contracts/mocks/SafeMathMock.sol @@ -47,27 +47,15 @@ contract SafeMathMock { return SafeMath.mod(a, b); } - function subWithMessage( - uint256 a, - uint256 b, - string memory errorMessage - ) public pure returns (uint256) { + function subWithMessage(uint256 a, uint256 b, string memory errorMessage) public pure returns (uint256) { return SafeMath.sub(a, b, errorMessage); } - function divWithMessage( - uint256 a, - uint256 b, - string memory errorMessage - ) public pure returns (uint256) { + function divWithMessage(uint256 a, uint256 b, string memory errorMessage) public pure returns (uint256) { return SafeMath.div(a, b, errorMessage); } - function modWithMessage( - uint256 a, - uint256 b, - string memory errorMessage - ) public pure returns (uint256) { + function modWithMessage(uint256 a, uint256 b, string memory errorMessage) public pure returns (uint256) { return SafeMath.mod(a, b, errorMessage); } diff --git a/contracts/mocks/SignatureCheckerMock.sol b/contracts/mocks/SignatureCheckerMock.sol index 3b399c1aeaa..5671540ec4a 100644 --- a/contracts/mocks/SignatureCheckerMock.sol +++ b/contracts/mocks/SignatureCheckerMock.sol @@ -7,11 +7,7 @@ import "../utils/cryptography/SignatureChecker.sol"; contract SignatureCheckerMock { using SignatureChecker for address; - function isValidSignatureNow( - address signer, - bytes32 hash, - bytes memory signature - ) public view returns (bool) { + function isValidSignatureNow(address signer, bytes32 hash, bytes memory signature) public view returns (bool) { return signer.isValidSignatureNow(hash, signature); } } diff --git a/contracts/mocks/UUPS/UUPSLegacy.sol b/contracts/mocks/UUPS/UUPSLegacy.sol index e03fa862da3..7a3002889bf 100644 --- a/contracts/mocks/UUPS/UUPSLegacy.sol +++ b/contracts/mocks/UUPS/UUPSLegacy.sol @@ -17,11 +17,7 @@ contract UUPSUpgradeableLegacyMock is UUPSUpgradeableMock { StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; } - function _upgradeToAndCallSecureLegacyV1( - address newImplementation, - bytes memory data, - bool forceCall - ) internal { + function _upgradeToAndCallSecureLegacyV1(address newImplementation, bytes memory data, bool forceCall) internal { address oldImplementation = _getImplementation(); // Initial upgrade and setup call diff --git a/contracts/mocks/crosschain/bridges.sol b/contracts/mocks/crosschain/bridges.sol index 35c7f4c0625..41baffed805 100644 --- a/contracts/mocks/crosschain/bridges.sol +++ b/contracts/mocks/crosschain/bridges.sol @@ -12,11 +12,7 @@ abstract contract BaseRelayMock { address internal _currentSender; - function relayAs( - address target, - bytes calldata data, - address sender - ) external virtual { + function relayAs(address target, bytes calldata data, address sender) external virtual { address previousSender = _currentSender; _currentSender = sender; @@ -92,11 +88,7 @@ contract BridgeOptimismMock is BaseRelayMock { * Polygon */ contract BridgePolygonChildMock is BaseRelayMock { - function relayAs( - address target, - bytes calldata data, - address sender - ) external override { + function relayAs(address target, bytes calldata data, address sender) external override { IFxMessageProcessor(target).processMessageFromRoot(0, sender, data); } } diff --git a/contracts/mocks/wizard/MyGovernor1.sol b/contracts/mocks/wizard/MyGovernor1.sol index a80d8400c5e..37ecfd57d8b 100644 --- a/contracts/mocks/wizard/MyGovernor1.sol +++ b/contracts/mocks/wizard/MyGovernor1.sol @@ -14,12 +14,10 @@ contract MyGovernor1 is GovernorVotesQuorumFraction, GovernorCountingSimple { - constructor(IVotes _token, TimelockController _timelock) - Governor("MyGovernor") - GovernorVotes(_token) - GovernorVotesQuorumFraction(4) - GovernorTimelockControl(_timelock) - {} + constructor( + IVotes _token, + TimelockController _timelock + ) Governor("MyGovernor") GovernorVotes(_token) GovernorVotesQuorumFraction(4) GovernorTimelockControl(_timelock) {} function votingDelay() public pure override returns (uint256) { return 1; // 1 block @@ -31,12 +29,9 @@ contract MyGovernor1 is // The following functions are overrides required by Solidity. - function quorum(uint256 blockNumber) - public - view - override(IGovernor, GovernorVotesQuorumFraction) - returns (uint256) - { + function quorum( + uint256 blockNumber + ) public view override(IGovernor, GovernorVotesQuorumFraction) returns (uint256) { return super.quorum(blockNumber); } @@ -76,12 +71,9 @@ contract MyGovernor1 is return super._executor(); } - function supportsInterface(bytes4 interfaceId) - public - view - override(Governor, GovernorTimelockControl) - returns (bool) - { + function supportsInterface( + bytes4 interfaceId + ) public view override(Governor, GovernorTimelockControl) returns (bool) { return super.supportsInterface(interfaceId); } } diff --git a/contracts/mocks/wizard/MyGovernor2.sol b/contracts/mocks/wizard/MyGovernor2.sol index 34c608c5cc2..1472b67d588 100644 --- a/contracts/mocks/wizard/MyGovernor2.sol +++ b/contracts/mocks/wizard/MyGovernor2.sol @@ -16,12 +16,10 @@ contract MyGovernor2 is GovernorVotesQuorumFraction, GovernorCountingSimple { - constructor(IVotes _token, TimelockController _timelock) - Governor("MyGovernor") - GovernorVotes(_token) - GovernorVotesQuorumFraction(4) - GovernorTimelockControl(_timelock) - {} + constructor( + IVotes _token, + TimelockController _timelock + ) Governor("MyGovernor") GovernorVotes(_token) GovernorVotesQuorumFraction(4) GovernorTimelockControl(_timelock) {} function votingDelay() public pure override returns (uint256) { return 1; // 1 block @@ -37,12 +35,9 @@ contract MyGovernor2 is // The following functions are overrides required by Solidity. - function quorum(uint256 blockNumber) - public - view - override(IGovernor, GovernorVotesQuorumFraction) - returns (uint256) - { + function quorum( + uint256 blockNumber + ) public view override(IGovernor, GovernorVotesQuorumFraction) returns (uint256) { return super.quorum(blockNumber); } @@ -82,12 +77,9 @@ contract MyGovernor2 is return super._executor(); } - function supportsInterface(bytes4 interfaceId) - public - view - override(Governor, GovernorTimelockControl) - returns (bool) - { + function supportsInterface( + bytes4 interfaceId + ) public view override(Governor, GovernorTimelockControl) returns (bool) { return super.supportsInterface(interfaceId); } } diff --git a/contracts/mocks/wizard/MyGovernor3.sol b/contracts/mocks/wizard/MyGovernor3.sol index 70e4e87f046..320342290a5 100644 --- a/contracts/mocks/wizard/MyGovernor3.sol +++ b/contracts/mocks/wizard/MyGovernor3.sol @@ -14,12 +14,10 @@ contract MyGovernor is GovernorVotes, GovernorVotesQuorumFraction { - constructor(IVotes _token, TimelockController _timelock) - Governor("MyGovernor") - GovernorVotes(_token) - GovernorVotesQuorumFraction(4) - GovernorTimelockControl(_timelock) - {} + constructor( + IVotes _token, + TimelockController _timelock + ) Governor("MyGovernor") GovernorVotes(_token) GovernorVotesQuorumFraction(4) GovernorTimelockControl(_timelock) {} function votingDelay() public pure override returns (uint256) { return 1; // 1 block @@ -35,21 +33,15 @@ contract MyGovernor is // The following functions are overrides required by Solidity. - function quorum(uint256 blockNumber) - public - view - override(IGovernor, GovernorVotesQuorumFraction) - returns (uint256) - { + function quorum( + uint256 blockNumber + ) public view override(IGovernor, GovernorVotesQuorumFraction) returns (uint256) { return super.quorum(blockNumber); } - function state(uint256 proposalId) - public - view - override(Governor, IGovernor, GovernorTimelockControl) - returns (ProposalState) - { + function state( + uint256 proposalId + ) public view override(Governor, IGovernor, GovernorTimelockControl) returns (ProposalState) { return super.state(proposalId); } @@ -85,12 +77,9 @@ contract MyGovernor is return super._executor(); } - function supportsInterface(bytes4 interfaceId) - public - view - override(Governor, IERC165, GovernorTimelockControl) - returns (bool) - { + function supportsInterface( + bytes4 interfaceId + ) public view override(Governor, IERC165, GovernorTimelockControl) returns (bool) { return super.supportsInterface(interfaceId); } } diff --git a/contracts/proxy/Clones.sol b/contracts/proxy/Clones.sol index 93ea0cec77e..712519892ef 100644 --- a/contracts/proxy/Clones.sol +++ b/contracts/proxy/Clones.sol @@ -79,11 +79,10 @@ library Clones { /** * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}. */ - function predictDeterministicAddress(address implementation, bytes32 salt) - internal - view - returns (address predicted) - { + function predictDeterministicAddress( + address implementation, + bytes32 salt + ) internal view returns (address predicted) { return predictDeterministicAddress(implementation, salt, address(this)); } } diff --git a/contracts/proxy/ERC1967/ERC1967Upgrade.sol b/contracts/proxy/ERC1967/ERC1967Upgrade.sol index 07dc048625a..38ea7ea1bf9 100644 --- a/contracts/proxy/ERC1967/ERC1967Upgrade.sol +++ b/contracts/proxy/ERC1967/ERC1967Upgrade.sol @@ -62,11 +62,7 @@ abstract contract ERC1967Upgrade { * * Emits an {Upgraded} event. */ - function _upgradeToAndCall( - address newImplementation, - bytes memory data, - bool forceCall - ) internal { + function _upgradeToAndCall(address newImplementation, bytes memory data, bool forceCall) internal { _upgradeTo(newImplementation); if (data.length > 0 || forceCall) { Address.functionDelegateCall(newImplementation, data); @@ -78,11 +74,7 @@ abstract contract ERC1967Upgrade { * * Emits an {Upgraded} event. */ - function _upgradeToAndCallUUPS( - address newImplementation, - bytes memory data, - bool forceCall - ) internal { + function _upgradeToAndCallUUPS(address newImplementation, bytes memory data, bool forceCall) internal { // Upgrades from old implementations will perform a rollback test. This test requires the new // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing // this special case will break upgrade paths from old UUPS implementation to new ones. @@ -175,11 +167,7 @@ abstract contract ERC1967Upgrade { * * Emits a {BeaconUpgraded} event. */ - function _upgradeBeaconToAndCall( - address newBeacon, - bytes memory data, - bool forceCall - ) internal { + function _upgradeBeaconToAndCall(address newBeacon, bytes memory data, bool forceCall) internal { _setBeacon(newBeacon); emit BeaconUpgraded(newBeacon); if (data.length > 0 || forceCall) { diff --git a/contracts/proxy/transparent/TransparentUpgradeableProxy.sol b/contracts/proxy/transparent/TransparentUpgradeableProxy.sol index 57417296d6e..ffc97ff4855 100644 --- a/contracts/proxy/transparent/TransparentUpgradeableProxy.sol +++ b/contracts/proxy/transparent/TransparentUpgradeableProxy.sol @@ -31,11 +31,7 @@ contract TransparentUpgradeableProxy is ERC1967Proxy { * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}. */ - constructor( - address _logic, - address admin_, - bytes memory _data - ) payable ERC1967Proxy(_logic, _data) { + constructor(address _logic, address admin_, bytes memory _data) payable ERC1967Proxy(_logic, _data) { _changeAdmin(admin_); } diff --git a/contracts/token/ERC1155/ERC1155.sol b/contracts/token/ERC1155/ERC1155.sol index fb85aee462c..2c430696b91 100644 --- a/contracts/token/ERC1155/ERC1155.sol +++ b/contracts/token/ERC1155/ERC1155.sol @@ -79,13 +79,10 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { * * - `accounts` and `ids` must have the same length. */ - function balanceOfBatch(address[] memory accounts, uint256[] memory ids) - public - view - virtual - override - returns (uint256[] memory) - { + function balanceOfBatch( + address[] memory accounts, + uint256[] memory ids + ) public view virtual override returns (uint256[] memory) { require(accounts.length == ids.length, "ERC1155: accounts and ids length mismatch"); uint256[] memory batchBalances = new uint256[](accounts.length); @@ -209,13 +206,7 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ - function _safeTransferFrom( - address from, - address to, - uint256 id, - uint256 amount, - bytes memory data - ) internal { + function _safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes memory data) internal { require(to != address(0), "ERC1155: transfer to the zero address"); require(from != address(0), "ERC1155: transfer from the zero address"); uint256[] memory ids = _asSingletonArray(id); @@ -279,12 +270,7 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ - function _mint( - address to, - uint256 id, - uint256 amount, - bytes memory data - ) internal { + function _mint(address to, uint256 id, uint256 amount, bytes memory data) internal { require(to != address(0), "ERC1155: mint to the zero address"); uint256[] memory ids = _asSingletonArray(id); uint256[] memory amounts = _asSingletonArray(amount); @@ -302,12 +288,7 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ - function _mintBatch( - address to, - uint256[] memory ids, - uint256[] memory amounts, - bytes memory data - ) internal { + function _mintBatch(address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data) internal { require(to != address(0), "ERC1155: mint to the zero address"); _update(address(0), to, ids, amounts, data); } @@ -322,11 +303,7 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { * - `from` cannot be the zero address. * - `from` must have at least `amount` tokens of token type `id`. */ - function _burn( - address from, - uint256 id, - uint256 amount - ) internal { + function _burn(address from, uint256 id, uint256 amount) internal { require(from != address(0), "ERC1155: burn from the zero address"); uint256[] memory ids = _asSingletonArray(id); uint256[] memory amounts = _asSingletonArray(amount); @@ -342,11 +319,7 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { * * - `ids` and `amounts` must have the same length. */ - function _burnBatch( - address from, - uint256[] memory ids, - uint256[] memory amounts - ) internal { + function _burnBatch(address from, uint256[] memory ids, uint256[] memory amounts) internal { require(from != address(0), "ERC1155: burn from the zero address"); _update(from, address(0), ids, amounts, ""); } @@ -356,11 +329,7 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { * * Emits an {ApprovalForAll} event. */ - function _setApprovalForAll( - address owner, - address operator, - bool approved - ) internal virtual { + function _setApprovalForAll(address owner, address operator, bool approved) internal virtual { require(owner != operator, "ERC1155: setting approval status for self"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); diff --git a/contracts/token/ERC1155/IERC1155.sol b/contracts/token/ERC1155/IERC1155.sol index 05f74dc4f32..eae0b7029f6 100644 --- a/contracts/token/ERC1155/IERC1155.sol +++ b/contracts/token/ERC1155/IERC1155.sol @@ -60,10 +60,10 @@ interface IERC1155 is IERC165 { * * - `accounts` and `ids` must have the same length. */ - function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids) - external - view - returns (uint256[] memory); + function balanceOfBatch( + address[] calldata accounts, + uint256[] calldata ids + ) external view returns (uint256[] memory); /** * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`, @@ -96,13 +96,7 @@ interface IERC1155 is IERC165 { * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ - function safeTransferFrom( - address from, - address to, - uint256 id, - uint256 amount, - bytes calldata data - ) external; + function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes calldata data) external; /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}. diff --git a/contracts/token/ERC1155/extensions/ERC1155Burnable.sol b/contracts/token/ERC1155/extensions/ERC1155Burnable.sol index cfaa2359dbd..cc81957a7fe 100644 --- a/contracts/token/ERC1155/extensions/ERC1155Burnable.sol +++ b/contracts/token/ERC1155/extensions/ERC1155Burnable.sol @@ -12,11 +12,7 @@ import "../ERC1155.sol"; * _Available since v3.1._ */ abstract contract ERC1155Burnable is ERC1155 { - function burn( - address account, - uint256 id, - uint256 value - ) public virtual { + function burn(address account, uint256 id, uint256 value) public virtual { require( account == _msgSender() || isApprovedForAll(account, _msgSender()), "ERC1155: caller is not token owner or approved" @@ -25,11 +21,7 @@ abstract contract ERC1155Burnable is ERC1155 { _burn(account, id, value); } - function burnBatch( - address account, - uint256[] memory ids, - uint256[] memory values - ) public virtual { + function burnBatch(address account, uint256[] memory ids, uint256[] memory values) public virtual { require( account == _msgSender() || isApprovedForAll(account, _msgSender()), "ERC1155: caller is not token owner or approved" diff --git a/contracts/token/ERC20/ERC20.sol b/contracts/token/ERC20/ERC20.sol index 261a46f2253..f9be8b68965 100644 --- a/contracts/token/ERC20/ERC20.sol +++ b/contracts/token/ERC20/ERC20.sol @@ -154,11 +154,7 @@ contract ERC20 is Context, IERC20, IERC20Metadata { * - the caller must have allowance for ``from``'s tokens of at least * `amount`. */ - function transferFrom( - address from, - address to, - uint256 amount - ) public virtual override returns (bool) { + function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, amount); _transfer(from, to, amount); @@ -218,11 +214,7 @@ contract ERC20 is Context, IERC20, IERC20Metadata { * * NOTE: This function is not virtual, {_update} should be overridden instead. */ - function _transfer( - address from, - address to, - uint256 amount - ) internal { + function _transfer(address from, address to, uint256 amount) internal { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); _update(from, to, amount); @@ -234,11 +226,7 @@ contract ERC20 is Context, IERC20, IERC20Metadata { * * Emits a {Transfer} event. */ - function _update( - address from, - address to, - uint256 amount - ) internal virtual { + function _update(address from, address to, uint256 amount) internal virtual { if (from == address(0)) { _totalSupply += amount; unchecked { @@ -306,11 +294,7 @@ contract ERC20 is Context, IERC20, IERC20Metadata { * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ - function _approve( - address owner, - address spender, - uint256 amount - ) internal virtual { + function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); @@ -326,11 +310,7 @@ contract ERC20 is Context, IERC20, IERC20Metadata { * * Might emit an {Approval} event. */ - function _spendAllowance( - address owner, - address spender, - uint256 amount - ) internal virtual { + function _spendAllowance(address owner, address spender, uint256 amount) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { require(currentAllowance >= amount, "ERC20: insufficient allowance"); diff --git a/contracts/token/ERC20/IERC20.sol b/contracts/token/ERC20/IERC20.sol index b816bfed086..66c4e4d88fe 100644 --- a/contracts/token/ERC20/IERC20.sol +++ b/contracts/token/ERC20/IERC20.sol @@ -74,9 +74,5 @@ interface IERC20 { * * Emits a {Transfer} event. */ - function transferFrom( - address from, - address to, - uint256 amount - ) external returns (bool); + function transferFrom(address from, address to, uint256 amount) external returns (bool); } diff --git a/contracts/token/ERC20/extensions/ERC20Capped.sol b/contracts/token/ERC20/extensions/ERC20Capped.sol index 3be9ff805d7..d80fb2a4ccd 100644 --- a/contracts/token/ERC20/extensions/ERC20Capped.sol +++ b/contracts/token/ERC20/extensions/ERC20Capped.sol @@ -30,11 +30,7 @@ abstract contract ERC20Capped is ERC20 { /** * @dev See {ERC20-_transfer}. */ - function _update( - address from, - address to, - uint256 amount - ) internal virtual override { + function _update(address from, address to, uint256 amount) internal virtual override { if (from == address(0)) { require(ERC20.totalSupply() + amount <= cap(), "ERC20Capped: cap exceeded"); } diff --git a/contracts/token/ERC20/extensions/ERC20Pausable.sol b/contracts/token/ERC20/extensions/ERC20Pausable.sol index 92d764932a9..85dd164d37b 100644 --- a/contracts/token/ERC20/extensions/ERC20Pausable.sol +++ b/contracts/token/ERC20/extensions/ERC20Pausable.sol @@ -21,11 +21,7 @@ abstract contract ERC20Pausable is ERC20, Pausable { * * - the contract must not be paused. */ - function _update( - address from, - address to, - uint256 amount - ) internal virtual override { + function _update(address from, address to, uint256 amount) internal virtual override { require(!paused(), "ERC20Pausable: token transfer while paused"); super._update(from, to, amount); } diff --git a/contracts/token/ERC20/extensions/ERC20Snapshot.sol b/contracts/token/ERC20/extensions/ERC20Snapshot.sol index 2c34e226809..3bc1a74eecc 100644 --- a/contracts/token/ERC20/extensions/ERC20Snapshot.sol +++ b/contracts/token/ERC20/extensions/ERC20Snapshot.sol @@ -120,11 +120,7 @@ abstract contract ERC20Snapshot is ERC20 { // Update balance and/or total supply snapshots before the values are modified. This is executed // for _mint, _burn, and _transfer operations. - function _update( - address from, - address to, - uint256 amount - ) internal virtual override { + function _update(address from, address to, uint256 amount) internal virtual override { if (from == address(0)) { // mint _updateAccountSnapshot(to); diff --git a/contracts/token/ERC20/extensions/ERC20Votes.sol b/contracts/token/ERC20/extensions/ERC20Votes.sol index 7f9f36b7603..225d08c443e 100644 --- a/contracts/token/ERC20/extensions/ERC20Votes.sol +++ b/contracts/token/ERC20/extensions/ERC20Votes.sol @@ -35,11 +35,7 @@ abstract contract ERC20Votes is ERC20, Votes { * * Emits a {IVotes-DelegateVotesChanged} event. */ - function _update( - address from, - address to, - uint256 amount - ) internal virtual override { + function _update(address from, address to, uint256 amount) internal virtual override { super._update(from, to, amount); if (from == address(0)) { require(totalSupply() <= _maxSupply(), "ERC20Votes: total supply risks overflowing votes"); diff --git a/contracts/token/ERC20/extensions/ERC4626.sol b/contracts/token/ERC20/extensions/ERC4626.sol index 3ffcd7bfd5a..9b26aefebed 100644 --- a/contracts/token/ERC20/extensions/ERC4626.sol +++ b/contracts/token/ERC20/extensions/ERC4626.sol @@ -153,11 +153,7 @@ abstract contract ERC4626 is ERC20, IERC4626 { } /** @dev See {IERC4626-withdraw}. */ - function withdraw( - uint256 assets, - address receiver, - address owner - ) public virtual override returns (uint256) { + function withdraw(uint256 assets, address receiver, address owner) public virtual override returns (uint256) { require(assets <= maxWithdraw(owner), "ERC4626: withdraw more than max"); uint256 shares = previewWithdraw(assets); @@ -167,11 +163,7 @@ abstract contract ERC4626 is ERC20, IERC4626 { } /** @dev See {IERC4626-redeem}. */ - function redeem( - uint256 shares, - address receiver, - address owner - ) public virtual override returns (uint256) { + function redeem(uint256 shares, address receiver, address owner) public virtual override returns (uint256) { require(shares <= maxRedeem(owner), "ERC4626: redeem more than max"); uint256 assets = previewRedeem(shares); @@ -230,12 +222,7 @@ abstract contract ERC4626 is ERC20, IERC4626 { /** * @dev Deposit/mint common workflow. */ - function _deposit( - address caller, - address receiver, - uint256 assets, - uint256 shares - ) internal virtual { + function _deposit(address caller, address receiver, uint256 assets, uint256 shares) internal virtual { // If _asset is ERC777, `transferFrom` can trigger a reenterancy BEFORE the transfer happens through the // `tokensToSend` hook. On the other hand, the `tokenReceived` hook, that is triggered after the transfer, // calls the vault, which is assumed not malicious. diff --git a/contracts/token/ERC20/utils/SafeERC20.sol b/contracts/token/ERC20/utils/SafeERC20.sol index bfc381f9b4a..028711ddf29 100644 --- a/contracts/token/ERC20/utils/SafeERC20.sol +++ b/contracts/token/ERC20/utils/SafeERC20.sol @@ -19,20 +19,11 @@ import "../../../utils/Address.sol"; library SafeERC20 { using Address for address; - function safeTransfer( - IERC20 token, - address to, - uint256 value - ) internal { + function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } - function safeTransferFrom( - IERC20 token, - address from, - address to, - uint256 value - ) internal { + function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } @@ -43,11 +34,7 @@ library SafeERC20 { * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ - function safeApprove( - IERC20 token, - address spender, - uint256 value - ) internal { + function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' @@ -58,20 +45,12 @@ library SafeERC20 { _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } - function safeIncreaseAllowance( - IERC20 token, - address spender, - uint256 value - ) internal { + function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } - function safeDecreaseAllowance( - IERC20 token, - address spender, - uint256 value - ) internal { + function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); diff --git a/contracts/token/ERC20/utils/TokenTimelock.sol b/contracts/token/ERC20/utils/TokenTimelock.sol index d879a7e7d72..ed855b7bcb4 100644 --- a/contracts/token/ERC20/utils/TokenTimelock.sol +++ b/contracts/token/ERC20/utils/TokenTimelock.sol @@ -29,11 +29,7 @@ contract TokenTimelock { * `beneficiary_` when {release} is invoked after `releaseTime_`. The release time is specified as a Unix timestamp * (in seconds). */ - constructor( - IERC20 token_, - address beneficiary_, - uint256 releaseTime_ - ) { + constructor(IERC20 token_, address beneficiary_, uint256 releaseTime_) { require(releaseTime_ > block.timestamp, "TokenTimelock: release time is before current time"); _token = token_; _beneficiary = beneficiary_; diff --git a/contracts/token/ERC721/ERC721.sol b/contracts/token/ERC721/ERC721.sol index 80fc22de04d..6bf620b4f24 100644 --- a/contracts/token/ERC721/ERC721.sol +++ b/contracts/token/ERC721/ERC721.sol @@ -147,11 +147,7 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { /** * @dev See {IERC721-transferFrom}. */ - function transferFrom( - address from, - address to, - uint256 tokenId - ) public virtual override { + function transferFrom(address from, address to, uint256 tokenId) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved"); @@ -161,23 +157,14 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { /** * @dev See {IERC721-safeTransferFrom}. */ - function safeTransferFrom( - address from, - address to, - uint256 tokenId - ) public virtual override { + function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ - function safeTransferFrom( - address from, - address to, - uint256 tokenId, - bytes memory data - ) public virtual override { + function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved"); _safeTransfer(from, to, tokenId, data); } @@ -200,12 +187,7 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { * * Emits a {Transfer} event. */ - function _safeTransfer( - address from, - address to, - uint256 tokenId, - bytes memory data - ) internal virtual { + function _safeTransfer(address from, address to, uint256 tokenId, bytes memory data) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer"); } @@ -259,11 +241,7 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ - function _safeMint( - address to, - uint256 tokenId, - bytes memory data - ) internal virtual { + function _safeMint(address to, uint256 tokenId, bytes memory data) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, data), @@ -352,11 +330,7 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { * * Emits a {Transfer} event. */ - function _transfer( - address from, - address to, - uint256 tokenId - ) internal virtual { + function _transfer(address from, address to, uint256 tokenId) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner"); require(to != address(0), "ERC721: transfer to the zero address"); @@ -399,11 +373,7 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { * * Emits an {ApprovalForAll} event. */ - function _setApprovalForAll( - address owner, - address operator, - bool approved - ) internal virtual { + function _setApprovalForAll(address owner, address operator, bool approved) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); @@ -467,7 +437,7 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { function _beforeTokenTransfer( address from, address to, - uint256, /* firstTokenId */ + uint256 /* firstTokenId */, uint256 batchSize ) internal virtual { if (batchSize > 1) { @@ -494,10 +464,5 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ - function _afterTokenTransfer( - address from, - address to, - uint256 firstTokenId, - uint256 batchSize - ) internal virtual {} + function _afterTokenTransfer(address from, address to, uint256 firstTokenId, uint256 batchSize) internal virtual {} } diff --git a/contracts/token/ERC721/IERC721.sol b/contracts/token/ERC721/IERC721.sol index 22020bab0bf..646530aa568 100644 --- a/contracts/token/ERC721/IERC721.sol +++ b/contracts/token/ERC721/IERC721.sol @@ -51,12 +51,7 @@ interface IERC721 is IERC165 { * * Emits a {Transfer} event. */ - function safeTransferFrom( - address from, - address to, - uint256 tokenId, - bytes calldata data - ) external; + function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external; /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients @@ -72,11 +67,7 @@ interface IERC721 is IERC165 { * * Emits a {Transfer} event. */ - function safeTransferFrom( - address from, - address to, - uint256 tokenId - ) external; + function safeTransferFrom(address from, address to, uint256 tokenId) external; /** * @dev Transfers `tokenId` token from `from` to `to`. @@ -94,11 +85,7 @@ interface IERC721 is IERC165 { * * Emits a {Transfer} event. */ - function transferFrom( - address from, - address to, - uint256 tokenId - ) external; + function transferFrom(address from, address to, uint256 tokenId) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. diff --git a/contracts/token/ERC721/utils/ERC721Holder.sol b/contracts/token/ERC721/utils/ERC721Holder.sol index 394926d51ed..cfa533a47b1 100644 --- a/contracts/token/ERC721/utils/ERC721Holder.sol +++ b/contracts/token/ERC721/utils/ERC721Holder.sol @@ -17,12 +17,7 @@ contract ERC721Holder is IERC721Receiver { * * Always returns `IERC721Receiver.onERC721Received.selector`. */ - function onERC721Received( - address, - address, - uint256, - bytes memory - ) public virtual override returns (bytes4) { + function onERC721Received(address, address, uint256, bytes memory) public virtual override returns (bytes4) { return this.onERC721Received.selector; } } diff --git a/contracts/token/ERC777/ERC777.sol b/contracts/token/ERC777/ERC777.sol index 7c35bf5a8a9..c1503c4dfc3 100644 --- a/contracts/token/ERC777/ERC777.sol +++ b/contracts/token/ERC777/ERC777.sol @@ -57,11 +57,7 @@ contract ERC777 is Context, IERC777, IERC20 { /** * @dev `defaultOperators` may be an empty array. */ - constructor( - string memory name_, - string memory symbol_, - address[] memory defaultOperators_ - ) { + constructor(string memory name_, string memory symbol_, address[] memory defaultOperators_) { _name = name_; _symbol = symbol_; @@ -127,11 +123,7 @@ contract ERC777 is Context, IERC777, IERC20 { * * Also emits a {IERC20-Transfer} event for ERC20 compatibility. */ - function send( - address recipient, - uint256 amount, - bytes memory data - ) public virtual override { + function send(address recipient, uint256 amount, bytes memory data) public virtual override { _send(_msgSender(), recipient, amount, data, "", true); } @@ -272,11 +264,7 @@ contract ERC777 is Context, IERC777, IERC20 { * * Emits {Sent}, {IERC20-Transfer} and {IERC20-Approval} events. */ - function transferFrom( - address holder, - address recipient, - uint256 amount - ) public virtual override returns (bool) { + function transferFrom(address holder, address recipient, uint256 amount) public virtual override returns (bool) { address spender = _msgSender(); _spendAllowance(holder, spender, amount); _send(holder, recipient, amount, "", "", false); @@ -301,12 +289,7 @@ contract ERC777 is Context, IERC777, IERC20 { * - if `account` is a contract, it must implement the {IERC777Recipient} * interface. */ - function _mint( - address account, - uint256 amount, - bytes memory userData, - bytes memory operatorData - ) internal virtual { + function _mint(address account, uint256 amount, bytes memory userData, bytes memory operatorData) internal virtual { _mint(account, amount, userData, operatorData, true); } @@ -387,12 +370,7 @@ contract ERC777 is Context, IERC777, IERC20 { * @param data bytes extra information provided by the token holder * @param operatorData bytes extra information provided by the operator (if any) */ - function _burn( - address from, - uint256 amount, - bytes memory data, - bytes memory operatorData - ) internal virtual { + function _burn(address from, uint256 amount, bytes memory data, bytes memory operatorData) internal virtual { require(from != address(0), "ERC777: burn from the zero address"); address operator = _msgSender(); @@ -439,11 +417,7 @@ contract ERC777 is Context, IERC777, IERC20 { * * Note that accounts cannot have allowance issued by their operators. */ - function _approve( - address holder, - address spender, - uint256 value - ) internal virtual { + function _approve(address holder, address spender, uint256 value) internal virtual { require(holder != address(0), "ERC777: approve from the zero address"); require(spender != address(0), "ERC777: approve to the zero address"); @@ -510,11 +484,7 @@ contract ERC777 is Context, IERC777, IERC20 { * * Might emit an {IERC20-Approval} event. */ - function _spendAllowance( - address owner, - address spender, - uint256 amount - ) internal virtual { + function _spendAllowance(address owner, address spender, uint256 amount) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { require(currentAllowance >= amount, "ERC777: insufficient allowance"); @@ -538,10 +508,5 @@ contract ERC777 is Context, IERC777, IERC20 { * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ - function _beforeTokenTransfer( - address operator, - address from, - address to, - uint256 amount - ) internal virtual {} + function _beforeTokenTransfer(address operator, address from, address to, uint256 amount) internal virtual {} } diff --git a/contracts/token/ERC777/IERC777.sol b/contracts/token/ERC777/IERC777.sol index 2af7771b03e..d3bede62610 100644 --- a/contracts/token/ERC777/IERC777.sol +++ b/contracts/token/ERC777/IERC777.sol @@ -83,11 +83,7 @@ interface IERC777 { * - if `recipient` is a contract, it must implement the {IERC777Recipient} * interface. */ - function send( - address recipient, - uint256 amount, - bytes calldata data - ) external; + function send(address recipient, uint256 amount, bytes calldata data) external; /** * @dev Destroys `amount` tokens from the caller's account, reducing the @@ -191,12 +187,7 @@ interface IERC777 { * - `account` must have at least `amount` tokens. * - the caller must be an operator for `account`. */ - function operatorBurn( - address account, - uint256 amount, - bytes calldata data, - bytes calldata operatorData - ) external; + function operatorBurn(address account, uint256 amount, bytes calldata data, bytes calldata operatorData) external; event Sent( address indexed operator, diff --git a/contracts/token/common/ERC2981.sol b/contracts/token/common/ERC2981.sol index 604dba3046a..84cb6b8deb4 100644 --- a/contracts/token/common/ERC2981.sol +++ b/contracts/token/common/ERC2981.sol @@ -91,11 +91,7 @@ abstract contract ERC2981 is IERC2981, ERC165 { * - `receiver` cannot be the zero address. * - `feeNumerator` cannot be greater than the fee denominator. */ - function _setTokenRoyalty( - uint256 tokenId, - address receiver, - uint96 feeNumerator - ) internal virtual { + function _setTokenRoyalty(uint256 tokenId, address receiver, uint96 feeNumerator) internal virtual { require(feeNumerator <= _feeDenominator(), "ERC2981: royalty fee will exceed salePrice"); require(receiver != address(0), "ERC2981: Invalid parameters"); diff --git a/contracts/utils/Address.sol b/contracts/utils/Address.sol index e89512342ae..70d03e3d212 100644 --- a/contracts/utils/Address.sol +++ b/contracts/utils/Address.sol @@ -111,11 +111,7 @@ library Address { * * _Available since v3.1._ */ - function functionCallWithValue( - address target, - bytes memory data, - uint256 value - ) internal returns (bytes memory) { + function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } diff --git a/contracts/utils/Checkpoints.sol b/contracts/utils/Checkpoints.sol index f20601c6a81..76203edd2ce 100644 --- a/contracts/utils/Checkpoints.sol +++ b/contracts/utils/Checkpoints.sol @@ -111,15 +111,9 @@ library Checkpoints { * @dev Returns whether there is a checkpoint in the structure (i.e. it is not empty), and if so the key and value * in the most recent checkpoint. */ - function latestCheckpoint(History storage self) - internal - view - returns ( - bool exists, - uint32 _blockNumber, - uint224 _value - ) - { + function latestCheckpoint( + History storage self + ) internal view returns (bool exists, uint32 _blockNumber, uint224 _value) { uint256 pos = self._checkpoints.length; if (pos == 0) { return (false, 0, 0); @@ -140,11 +134,7 @@ library Checkpoints { * @dev Pushes a (`key`, `value`) pair into an ordered list of checkpoints, either by inserting a new checkpoint, * or by updating the last one. */ - function _insert( - Checkpoint[] storage self, - uint32 key, - uint224 value - ) private returns (uint224, uint224) { + function _insert(Checkpoint[] storage self, uint32 key, uint224 value) private returns (uint224, uint224) { uint256 pos = self.length; if (pos > 0) { @@ -237,11 +227,7 @@ library Checkpoints { * * Returns previous value and new value. */ - function push( - Trace224 storage self, - uint32 key, - uint224 value - ) internal returns (uint224, uint224) { + function push(Trace224 storage self, uint32 key, uint224 value) internal returns (uint224, uint224) { return _insert(self._checkpoints, key, value); } @@ -275,15 +261,7 @@ library Checkpoints { * @dev Returns whether there is a checkpoint in the structure (i.e. it is not empty), and if so the key and value * in the most recent checkpoint. */ - function latestCheckpoint(Trace224 storage self) - internal - view - returns ( - bool exists, - uint32 _key, - uint224 _value - ) - { + function latestCheckpoint(Trace224 storage self) internal view returns (bool exists, uint32 _key, uint224 _value) { uint256 pos = self._checkpoints.length; if (pos == 0) { return (false, 0, 0); @@ -304,11 +282,7 @@ library Checkpoints { * @dev Pushes a (`key`, `value`) pair into an ordered list of checkpoints, either by inserting a new checkpoint, * or by updating the last one. */ - function _insert( - Checkpoint224[] storage self, - uint32 key, - uint224 value - ) private returns (uint224, uint224) { + function _insert(Checkpoint224[] storage self, uint32 key, uint224 value) private returns (uint224, uint224) { uint256 pos = self.length; if (pos > 0) { @@ -380,11 +354,10 @@ library Checkpoints { /** * @dev Access an element of the array without performing bounds check. The position is assumed to be within bounds. */ - function _unsafeAccess(Checkpoint224[] storage self, uint256 pos) - private - pure - returns (Checkpoint224 storage result) - { + function _unsafeAccess( + Checkpoint224[] storage self, + uint256 pos + ) private pure returns (Checkpoint224 storage result) { assembly { mstore(0, self.slot) result.slot := add(keccak256(0, 0x20), pos) @@ -405,11 +378,7 @@ library Checkpoints { * * Returns previous value and new value. */ - function push( - Trace160 storage self, - uint96 key, - uint160 value - ) internal returns (uint160, uint160) { + function push(Trace160 storage self, uint96 key, uint160 value) internal returns (uint160, uint160) { return _insert(self._checkpoints, key, value); } @@ -443,15 +412,7 @@ library Checkpoints { * @dev Returns whether there is a checkpoint in the structure (i.e. it is not empty), and if so the key and value * in the most recent checkpoint. */ - function latestCheckpoint(Trace160 storage self) - internal - view - returns ( - bool exists, - uint96 _key, - uint160 _value - ) - { + function latestCheckpoint(Trace160 storage self) internal view returns (bool exists, uint96 _key, uint160 _value) { uint256 pos = self._checkpoints.length; if (pos == 0) { return (false, 0, 0); @@ -472,11 +433,7 @@ library Checkpoints { * @dev Pushes a (`key`, `value`) pair into an ordered list of checkpoints, either by inserting a new checkpoint, * or by updating the last one. */ - function _insert( - Checkpoint160[] storage self, - uint96 key, - uint160 value - ) private returns (uint160, uint160) { + function _insert(Checkpoint160[] storage self, uint96 key, uint160 value) private returns (uint160, uint160) { uint256 pos = self.length; if (pos > 0) { @@ -548,11 +505,10 @@ library Checkpoints { /** * @dev Access an element of the array without performing bounds check. The position is assumed to be within bounds. */ - function _unsafeAccess(Checkpoint160[] storage self, uint256 pos) - private - pure - returns (Checkpoint160 storage result) - { + function _unsafeAccess( + Checkpoint160[] storage self, + uint256 pos + ) private pure returns (Checkpoint160 storage result) { assembly { mstore(0, self.slot) result.slot := add(keccak256(0, 0x20), pos) diff --git a/contracts/utils/Create2.sol b/contracts/utils/Create2.sol index 8df86d66999..2255a4df8b7 100644 --- a/contracts/utils/Create2.sol +++ b/contracts/utils/Create2.sol @@ -27,11 +27,7 @@ library Create2 { * - the factory must have a balance of at least `amount`. * - if `amount` is non-zero, `bytecode` must have a `payable` constructor. */ - function deploy( - uint256 amount, - bytes32 salt, - bytes memory bytecode - ) internal returns (address addr) { + function deploy(uint256 amount, bytes32 salt, bytes memory bytecode) internal returns (address addr) { require(address(this).balance >= amount, "Create2: insufficient balance"); require(bytecode.length != 0, "Create2: bytecode length is zero"); /// @solidity memory-safe-assembly @@ -53,11 +49,7 @@ library Create2 { * @dev Returns the address where a contract will be stored if deployed via {deploy} from a contract located at * `deployer`. If `deployer` is this contract's address, returns the same value as {computeAddress}. */ - function computeAddress( - bytes32 salt, - bytes32 bytecodeHash, - address deployer - ) internal pure returns (address addr) { + function computeAddress(bytes32 salt, bytes32 bytecodeHash, address deployer) internal pure returns (address addr) { /// @solidity memory-safe-assembly assembly { let ptr := mload(0x40) // Get free memory pointer diff --git a/contracts/utils/cryptography/ECDSA.sol b/contracts/utils/cryptography/ECDSA.sol index 4b1d66b092d..3f996520efd 100644 --- a/contracts/utils/cryptography/ECDSA.sol +++ b/contracts/utils/cryptography/ECDSA.sol @@ -98,11 +98,7 @@ library ECDSA { * * _Available since v4.3._ */ - function tryRecover( - bytes32 hash, - bytes32 r, - bytes32 vs - ) internal pure returns (address, RecoverError) { + function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError) { bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff); uint8 v = uint8((uint256(vs) >> 255) + 27); return tryRecover(hash, v, r, s); @@ -113,11 +109,7 @@ library ECDSA { * * _Available since v4.2._ */ - function recover( - bytes32 hash, - bytes32 r, - bytes32 vs - ) internal pure returns (address) { + function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, r, vs); _throwError(error); return recovered; @@ -129,12 +121,7 @@ library ECDSA { * * _Available since v4.3._ */ - function tryRecover( - bytes32 hash, - uint8 v, - bytes32 r, - bytes32 s - ) internal pure returns (address, RecoverError) { + function tryRecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address, RecoverError) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most @@ -161,12 +148,7 @@ library ECDSA { * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ - function recover( - bytes32 hash, - uint8 v, - bytes32 r, - bytes32 s - ) internal pure returns (address) { + function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, v, r, s); _throwError(error); return recovered; diff --git a/contracts/utils/cryptography/MerkleProof.sol b/contracts/utils/cryptography/MerkleProof.sol index 47c60eb0118..0ce87faf283 100644 --- a/contracts/utils/cryptography/MerkleProof.sol +++ b/contracts/utils/cryptography/MerkleProof.sol @@ -24,11 +24,7 @@ library MerkleProof { * sibling hashes on the branch from the leaf to the root of the tree. Each * pair of leaves and each pair of pre-images are assumed to be sorted. */ - function verify( - bytes32[] memory proof, - bytes32 root, - bytes32 leaf - ) internal pure returns (bool) { + function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) internal pure returns (bool) { return processProof(proof, leaf) == root; } @@ -37,11 +33,7 @@ library MerkleProof { * * _Available since v4.7._ */ - function verifyCalldata( - bytes32[] calldata proof, - bytes32 root, - bytes32 leaf - ) internal pure returns (bool) { + function verifyCalldata(bytes32[] calldata proof, bytes32 root, bytes32 leaf) internal pure returns (bool) { return processProofCalldata(proof, leaf) == root; } diff --git a/contracts/utils/cryptography/SignatureChecker.sol b/contracts/utils/cryptography/SignatureChecker.sol index 77fe98282bf..e06778debd7 100644 --- a/contracts/utils/cryptography/SignatureChecker.sol +++ b/contracts/utils/cryptography/SignatureChecker.sol @@ -21,11 +21,7 @@ library SignatureChecker { * NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus * change through time. It could return true at block N and false at block N+1 (or the opposite). */ - function isValidSignatureNow( - address signer, - bytes32 hash, - bytes memory signature - ) internal view returns (bool) { + function isValidSignatureNow(address signer, bytes32 hash, bytes memory signature) internal view returns (bool) { (address recovered, ECDSA.RecoverError error) = ECDSA.tryRecover(hash, signature); if (error == ECDSA.RecoverError.NoError && recovered == signer) { return true; diff --git a/contracts/utils/introspection/ERC165Checker.sol b/contracts/utils/introspection/ERC165Checker.sol index 4c5fe2092df..40ffd68f73f 100644 --- a/contracts/utils/introspection/ERC165Checker.sol +++ b/contracts/utils/introspection/ERC165Checker.sol @@ -48,11 +48,10 @@ library ERC165Checker { * * _Available since v3.4._ */ - function getSupportedInterfaces(address account, bytes4[] memory interfaceIds) - internal - view - returns (bool[] memory) - { + function getSupportedInterfaces( + address account, + bytes4[] memory interfaceIds + ) internal view returns (bool[] memory) { // an array of booleans corresponding to interfaceIds and whether they're supported or not bool[] memory interfaceIdsSupported = new bool[](interfaceIds.length); diff --git a/contracts/utils/introspection/ERC1820Implementer.sol b/contracts/utils/introspection/ERC1820Implementer.sol index 1b5139658bd..ac5a884c02a 100644 --- a/contracts/utils/introspection/ERC1820Implementer.sol +++ b/contracts/utils/introspection/ERC1820Implementer.sol @@ -21,13 +21,10 @@ contract ERC1820Implementer is IERC1820Implementer { /** * @dev See {IERC1820Implementer-canImplementInterfaceForAddress}. */ - function canImplementInterfaceForAddress(bytes32 interfaceHash, address account) - public - view - virtual - override - returns (bytes32) - { + function canImplementInterfaceForAddress( + bytes32 interfaceHash, + address account + ) public view virtual override returns (bytes32) { return _supportedInterfaces[interfaceHash][account] ? _ERC1820_ACCEPT_MAGIC : bytes32(0x00); } diff --git a/contracts/utils/introspection/IERC1820Registry.sol b/contracts/utils/introspection/IERC1820Registry.sol index 42cf46a8ae8..a146bc2a68b 100644 --- a/contracts/utils/introspection/IERC1820Registry.sol +++ b/contracts/utils/introspection/IERC1820Registry.sol @@ -64,11 +64,7 @@ interface IERC1820Registry { * queried for support, unless `implementer` is the caller. See * {IERC1820Implementer-canImplementInterfaceForAddress}. */ - function setInterfaceImplementer( - address account, - bytes32 _interfaceHash, - address implementer - ) external; + function setInterfaceImplementer(address account, bytes32 _interfaceHash, address implementer) external; /** * @dev Returns the implementer of `interfaceHash` for `account`. If no such diff --git a/contracts/utils/math/Math.sol b/contracts/utils/math/Math.sol index 0ed5460e05f..f3a83b0ffab 100644 --- a/contracts/utils/math/Math.sol +++ b/contracts/utils/math/Math.sol @@ -52,11 +52,7 @@ library Math { * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ - function mulDiv( - uint256 x, - uint256 y, - uint256 denominator - ) internal pure returns (uint256 result) { + function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 @@ -137,12 +133,7 @@ library Math { /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ - function mulDiv( - uint256 x, - uint256 y, - uint256 denominator, - Rounding rounding - ) internal pure returns (uint256) { + function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; @@ -258,31 +249,31 @@ library Math { function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { - if (value >= 10**64) { - value /= 10**64; + if (value >= 10 ** 64) { + value /= 10 ** 64; result += 64; } - if (value >= 10**32) { - value /= 10**32; + if (value >= 10 ** 32) { + value /= 10 ** 32; result += 32; } - if (value >= 10**16) { - value /= 10**16; + if (value >= 10 ** 16) { + value /= 10 ** 16; result += 16; } - if (value >= 10**8) { - value /= 10**8; + if (value >= 10 ** 8) { + value /= 10 ** 8; result += 8; } - if (value >= 10**4) { - value /= 10**4; + if (value >= 10 ** 4) { + value /= 10 ** 4; result += 4; } - if (value >= 10**2) { - value /= 10**2; + if (value >= 10 ** 2) { + value /= 10 ** 2; result += 2; } - if (value >= 10**1) { + if (value >= 10 ** 1) { result += 1; } } @@ -296,7 +287,7 @@ library Math { function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); - return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0); + return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0); } } diff --git a/contracts/utils/math/SafeMath.sol b/contracts/utils/math/SafeMath.sol index 550f0e779b1..2f48fb7360a 100644 --- a/contracts/utils/math/SafeMath.sol +++ b/contracts/utils/math/SafeMath.sol @@ -165,11 +165,7 @@ library SafeMath { * * - Subtraction cannot overflow. */ - function sub( - uint256 a, - uint256 b, - string memory errorMessage - ) internal pure returns (uint256) { + function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; @@ -188,11 +184,7 @@ library SafeMath { * * - The divisor cannot be zero. */ - function div( - uint256 a, - uint256 b, - string memory errorMessage - ) internal pure returns (uint256) { + function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; @@ -214,11 +206,7 @@ library SafeMath { * * - The divisor cannot be zero. */ - function mod( - uint256 a, - uint256 b, - string memory errorMessage - ) internal pure returns (uint256) { + function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; diff --git a/contracts/utils/structs/BitMaps.sol b/contracts/utils/structs/BitMaps.sol index a2ddc47098f..eb67bfab081 100644 --- a/contracts/utils/structs/BitMaps.sol +++ b/contracts/utils/structs/BitMaps.sol @@ -23,11 +23,7 @@ library BitMaps { /** * @dev Sets the bit at `index` to the boolean `value`. */ - function setTo( - BitMap storage bitmap, - uint256 index, - bool value - ) internal { + function setTo(BitMap storage bitmap, uint256 index, bool value) internal { if (value) { set(bitmap, index); } else { diff --git a/contracts/utils/structs/EnumerableMap.sol b/contracts/utils/structs/EnumerableMap.sol index a3fda61d802..d359671f461 100644 --- a/contracts/utils/structs/EnumerableMap.sol +++ b/contracts/utils/structs/EnumerableMap.sol @@ -70,11 +70,7 @@ library EnumerableMap { * Returns true if the key was added to the map, that is if it was not * already present. */ - function set( - Bytes32ToBytes32Map storage map, - bytes32 key, - bytes32 value - ) internal returns (bool) { + function set(Bytes32ToBytes32Map storage map, bytes32 key, bytes32 value) internal returns (bool) { map._values[key] = value; return map._keys.add(key); } @@ -173,11 +169,7 @@ library EnumerableMap { * Returns true if the key was added to the map, that is if it was not * already present. */ - function set( - UintToUintMap storage map, - uint256 key, - uint256 value - ) internal returns (bool) { + function set(UintToUintMap storage map, uint256 key, uint256 value) internal returns (bool) { return set(map._inner, bytes32(key), bytes32(value)); } @@ -244,11 +236,7 @@ library EnumerableMap { * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryGet}. */ - function get( - UintToUintMap storage map, - uint256 key, - string memory errorMessage - ) internal view returns (uint256) { + function get(UintToUintMap storage map, uint256 key, string memory errorMessage) internal view returns (uint256) { return uint256(get(map._inner, bytes32(key), errorMessage)); } @@ -265,11 +253,7 @@ library EnumerableMap { * Returns true if the key was added to the map, that is if it was not * already present. */ - function set( - UintToAddressMap storage map, - uint256 key, - address value - ) internal returns (bool) { + function set(UintToAddressMap storage map, uint256 key, address value) internal returns (bool) { return set(map._inner, bytes32(key), bytes32(uint256(uint160(value)))); } @@ -357,11 +341,7 @@ library EnumerableMap { * Returns true if the key was added to the map, that is if it was not * already present. */ - function set( - AddressToUintMap storage map, - address key, - uint256 value - ) internal returns (bool) { + function set(AddressToUintMap storage map, address key, uint256 value) internal returns (bool) { return set(map._inner, bytes32(uint256(uint160(key))), bytes32(value)); } @@ -449,11 +429,7 @@ library EnumerableMap { * Returns true if the key was added to the map, that is if it was not * already present. */ - function set( - Bytes32ToUintMap storage map, - bytes32 key, - uint256 value - ) internal returns (bool) { + function set(Bytes32ToUintMap storage map, bytes32 key, uint256 value) internal returns (bool) { return set(map._inner, key, bytes32(value)); } diff --git a/contracts/vendor/amb/IAMB.sol b/contracts/vendor/amb/IAMB.sol index 1a5d7080f8b..73a2bd24bcb 100644 --- a/contracts/vendor/amb/IAMB.sol +++ b/contracts/vendor/amb/IAMB.sol @@ -31,17 +31,9 @@ interface IAMB { function failedMessageSender(bytes32 _messageId) external view returns (address); - function requireToPassMessage( - address _contract, - bytes calldata _data, - uint256 _gas - ) external returns (bytes32); - - function requireToConfirmMessage( - address _contract, - bytes calldata _data, - uint256 _gas - ) external returns (bytes32); + function requireToPassMessage(address _contract, bytes calldata _data, uint256 _gas) external returns (bytes32); + + function requireToConfirmMessage(address _contract, bytes calldata _data, uint256 _gas) external returns (bytes32); function sourceChainId() external view returns (uint256); diff --git a/contracts/vendor/arbitrum/IArbSys.sol b/contracts/vendor/arbitrum/IArbSys.sol index aac5dd53a9e..9b79d5c16a2 100644 --- a/contracts/vendor/arbitrum/IArbSys.sol +++ b/contracts/vendor/arbitrum/IArbSys.sol @@ -92,14 +92,7 @@ interface IArbSys { * @return root root hash of the send history * @return partials hashes of partial subtrees in the send history tree */ - function sendMerkleTreeState() - external - view - returns ( - uint256 size, - bytes32 root, - bytes32[] memory partials - ); + function sendMerkleTreeState() external view returns (uint256 size, bytes32 root, bytes32[] memory partials); /** * @notice creates a send txn from L2 to L1 diff --git a/contracts/vendor/arbitrum/IBridge.sol b/contracts/vendor/arbitrum/IBridge.sol index 7518f5d13cc..e71bedce012 100644 --- a/contracts/vendor/arbitrum/IBridge.sol +++ b/contracts/vendor/arbitrum/IBridge.sol @@ -77,14 +77,7 @@ interface IBridge { uint256 afterDelayedMessagesRead, uint256 prevMessageCount, uint256 newMessageCount - ) - external - returns ( - uint256 seqMessageIndex, - bytes32 beforeAcc, - bytes32 delayedAcc, - bytes32 acc - ); + ) external returns (uint256 seqMessageIndex, bytes32 beforeAcc, bytes32 delayedAcc, bytes32 acc); /** * @dev Allows the sequencer inbox to submit a delayed message of the batchPostingReport type diff --git a/contracts/vendor/arbitrum/IOutbox.sol b/contracts/vendor/arbitrum/IOutbox.sol index 4f809dbf43e..22fa58f405a 100644 --- a/contracts/vendor/arbitrum/IOutbox.sol +++ b/contracts/vendor/arbitrum/IOutbox.sol @@ -113,9 +113,5 @@ interface IOutbox { bytes calldata data ) external pure returns (bytes32); - function calculateMerkleRoot( - bytes32[] memory proof, - uint256 path, - bytes32 item - ) external pure returns (bytes32); + function calculateMerkleRoot(bytes32[] memory proof, uint256 path, bytes32 item) external pure returns (bytes32); } diff --git a/contracts/vendor/optimism/ICrossDomainMessenger.sol b/contracts/vendor/optimism/ICrossDomainMessenger.sol index 9cc797701bf..cc01a48ab9a 100644 --- a/contracts/vendor/optimism/ICrossDomainMessenger.sol +++ b/contracts/vendor/optimism/ICrossDomainMessenger.sol @@ -30,9 +30,5 @@ interface ICrossDomainMessenger { * @param _message Message to send to the target. * @param _gasLimit Gas limit for the provided message. */ - function sendMessage( - address _target, - bytes calldata _message, - uint32 _gasLimit - ) external; + function sendMessage(address _target, bytes calldata _message, uint32 _gasLimit) external; } diff --git a/contracts/vendor/polygon/IFxMessageProcessor.sol b/contracts/vendor/polygon/IFxMessageProcessor.sol index 9f42eb64709..be73e6f53cd 100644 --- a/contracts/vendor/polygon/IFxMessageProcessor.sol +++ b/contracts/vendor/polygon/IFxMessageProcessor.sol @@ -3,9 +3,5 @@ pragma solidity ^0.8.0; interface IFxMessageProcessor { - function processMessageFromRoot( - uint256 stateId, - address rootMessageSender, - bytes calldata data - ) external; + function processMessageFromRoot(uint256 stateId, address rootMessageSender, bytes calldata data) external; } diff --git a/test/utils/math/Math.t.sol b/test/utils/math/Math.t.sol index c1c6f447d3a..5542baf9d94 100644 --- a/test/utils/math/Math.t.sol +++ b/test/utils/math/Math.t.sol @@ -70,16 +70,16 @@ contract MathTest is Test { assertFalse(rounding == Math.Rounding.Up); assertTrue(_powerOf2Bigger(result + 1, input)); } else { - assertEq(2**result, input); + assertEq(2 ** result, input); } } function _powerOf2Bigger(uint256 value, uint256 ref) private pure returns (bool) { - return value >= 256 || 2**value > ref; // 2**256 overflows uint256 + return value >= 256 || 2 ** value > ref; // 2**256 overflows uint256 } function _powerOf2Smaller(uint256 value, uint256 ref) private pure returns (bool) { - return 2**value < ref; + return 2 ** value < ref; } // LOG10 @@ -97,16 +97,16 @@ contract MathTest is Test { assertFalse(rounding == Math.Rounding.Up); assertTrue(_powerOf10Bigger(result + 1, input)); } else { - assertEq(10**result, input); + assertEq(10 ** result, input); } } function _powerOf10Bigger(uint256 value, uint256 ref) private pure returns (bool) { - return value >= 78 || 10**value > ref; // 10**78 overflows uint256 + return value >= 78 || 10 ** value > ref; // 10**78 overflows uint256 } function _powerOf10Smaller(uint256 value, uint256 ref) private pure returns (bool) { - return 10**value < ref; + return 10 ** value < ref; } // LOG256 @@ -124,24 +124,20 @@ contract MathTest is Test { assertFalse(rounding == Math.Rounding.Up); assertTrue(_powerOf256Bigger(result + 1, input)); } else { - assertEq(256**result, input); + assertEq(256 ** result, input); } } function _powerOf256Bigger(uint256 value, uint256 ref) private pure returns (bool) { - return value >= 32 || 256**value > ref; // 256**32 overflows uint256 + return value >= 32 || 256 ** value > ref; // 256**32 overflows uint256 } function _powerOf256Smaller(uint256 value, uint256 ref) private pure returns (bool) { - return 256**value < ref; + return 256 ** value < ref; } // MULDIV - function testMulDiv( - uint256 x, - uint256 y, - uint256 d - ) public { + function testMulDiv(uint256 x, uint256 y, uint256 d) public { // Full precision for x * y (uint256 xyHi, uint256 xyLo) = _mulHighLow(x, y); @@ -163,11 +159,7 @@ contract MathTest is Test { assertEq(xyLo, qdRemLo); } - function testMulDivDomain( - uint256 x, - uint256 y, - uint256 d - ) public { + function testMulDivDomain(uint256 x, uint256 y, uint256 d) public { (uint256 xyHi, ) = _mulHighLow(x, y); // Violate {testMulDiv} assumption (covers d is 0 and result overflow) @@ -180,11 +172,7 @@ contract MathTest is Test { } // External call - function muldiv( - uint256 x, - uint256 y, - uint256 d - ) external pure returns (uint256) { + function muldiv(uint256 x, uint256 y, uint256 d) external pure returns (uint256) { return Math.mulDiv(x, y, d); } @@ -194,11 +182,7 @@ contract MathTest is Test { return Math.Rounding(r); } - function _mulmod( - uint256 x, - uint256 y, - uint256 z - ) private pure returns (uint256 r) { + function _mulmod(uint256 x, uint256 y, uint256 z) private pure returns (uint256 r) { assembly { r := mulmod(x, y, z) } From 826e2edbe3bb8d8eb5d48d4b6ae6c4d8e82ee41c Mon Sep 17 00:00:00 2001 From: JulissaDantes Date: Mon, 9 Jan 2023 09:43:54 -0400 Subject: [PATCH 20/25] Update contracts/mocks/ERC1155PausableMock.sol Co-authored-by: Hadrien Croubois --- contracts/mocks/ERC1155PausableMock.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/mocks/ERC1155PausableMock.sol b/contracts/mocks/ERC1155PausableMock.sol index 8512f3dd07d..501ed3d1f6f 100644 --- a/contracts/mocks/ERC1155PausableMock.sol +++ b/contracts/mocks/ERC1155PausableMock.sol @@ -22,7 +22,7 @@ contract ERC1155PausableMock is ERC1155Mock, ERC1155Pausable { uint256[] memory ids, uint256[] memory amounts, bytes memory data - ) internal virtual override(ERC1155, ERC1155Pausable) { + ) internal override(ERC1155, ERC1155Pausable) { super._update(from, to, ids, amounts, data); } } From 0061bb75f39b1f3ec4817f3e1be6f71303e55f7e Mon Sep 17 00:00:00 2001 From: JulissaDantes Date: Mon, 9 Jan 2023 09:44:03 -0400 Subject: [PATCH 21/25] Update contracts/mocks/ERC1155SupplyMock.sol Co-authored-by: Hadrien Croubois --- contracts/mocks/ERC1155SupplyMock.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/mocks/ERC1155SupplyMock.sol b/contracts/mocks/ERC1155SupplyMock.sol index 6ea763cf355..a7421f0455c 100644 --- a/contracts/mocks/ERC1155SupplyMock.sol +++ b/contracts/mocks/ERC1155SupplyMock.sol @@ -14,7 +14,7 @@ contract ERC1155SupplyMock is ERC1155Mock, ERC1155Supply { uint256[] memory ids, uint256[] memory amounts, bytes memory data - ) internal virtual override(ERC1155, ERC1155Supply) { + ) internal override(ERC1155, ERC1155Supply) { super._update(from, to, ids, amounts, data); } } From 4b040e221e8f0a60dab336f534ca25128a48fe8a Mon Sep 17 00:00:00 2001 From: JulissaDantes Date: Mon, 9 Jan 2023 09:45:27 -0400 Subject: [PATCH 22/25] Update package-lock.json Co-authored-by: Hadrien Croubois --- package-lock.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index e8bf9303a6a..8d8a2ca1628 100644 --- a/package-lock.json +++ b/package-lock.json @@ -26458,4 +26458,4 @@ "dev": true } } -} \ No newline at end of file +} From c338f9c5acfc311c4024892e8b180088b5c22f64 Mon Sep 17 00:00:00 2001 From: JulissaDantes Date: Mon, 9 Jan 2023 09:45:37 -0400 Subject: [PATCH 23/25] Update contracts/token/ERC1155/ERC1155.sol Co-authored-by: Francisco --- contracts/token/ERC1155/ERC1155.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/token/ERC1155/ERC1155.sol b/contracts/token/ERC1155/ERC1155.sol index 2c430696b91..c5bf37a7c18 100644 --- a/contracts/token/ERC1155/ERC1155.sol +++ b/contracts/token/ERC1155/ERC1155.sol @@ -145,7 +145,7 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { /** * @dev Transfers `amount` tokens of token type `id` from `from` to `to`. Will mint (or burn) if `from` (or `to`) is the zero address. * - * Emits a {TransferSingle} event if only one transfer is done, and {TransferBatch} event for multiple transfer operations. + * Emits a {TransferSingle} event if the arrays contain one element, and {TransferBatch} otherwise. * * Requirements: * From 943993c4fa40af02ae195c1f0cdf2c496e20778e Mon Sep 17 00:00:00 2001 From: JulissaDantes Date: Mon, 9 Jan 2023 09:45:47 -0400 Subject: [PATCH 24/25] Update contracts/token/ERC1155/ERC1155.sol Co-authored-by: Francisco --- contracts/token/ERC1155/ERC1155.sol | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contracts/token/ERC1155/ERC1155.sol b/contracts/token/ERC1155/ERC1155.sol index c5bf37a7c18..8c43fcbcf35 100644 --- a/contracts/token/ERC1155/ERC1155.sol +++ b/contracts/token/ERC1155/ERC1155.sol @@ -149,8 +149,8 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { * * Requirements: * - * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the - * acceptance magic value. + * - If `to` refers to a smart contract, it must implement either {IERC1155Receiver-onERC1155Received} + * or {IERC1155Receiver-onERC1155BatchReceived} and return the acceptance magic value. */ function _update( address from, From 276a20fa71714a4c16ab2ab7d95b526a7c9776e1 Mon Sep 17 00:00:00 2001 From: JulissaDantes Date: Mon, 9 Jan 2023 09:45:58 -0400 Subject: [PATCH 25/25] Update contracts/token/ERC1155/ERC1155.sol Co-authored-by: Francisco --- contracts/token/ERC1155/ERC1155.sol | 1 + 1 file changed, 1 insertion(+) diff --git a/contracts/token/ERC1155/ERC1155.sol b/contracts/token/ERC1155/ERC1155.sol index 8c43fcbcf35..e491a23100b 100644 --- a/contracts/token/ERC1155/ERC1155.sol +++ b/contracts/token/ERC1155/ERC1155.sol @@ -179,6 +179,7 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { _balances[id][to] += amount; } } + if (ids.length == 1) { uint256 id = ids[0]; uint256 amount = amounts[0];