Browse Source

Merge branch 'master' into next-v5.0

Francisco Giordano 2 years ago
parent
commit
9cbe8b340c
76 changed files with 160 additions and 16123 deletions
  1. 1 0
      .github/workflows/checks.yml
  2. 14 2
      CHANGELOG.md
  3. 1 1
      contracts/access/AccessControl.sol
  4. 1 1
      contracts/access/Ownable2Step.sol
  5. 2 0
      contracts/access/README.adoc
  6. 1 1
      contracts/crosschain/arbitrum/CrossChainEnabledArbitrumL2.sol
  7. 1 1
      contracts/crosschain/arbitrum/LibArbitrumL1.sol
  8. 1 1
      contracts/crosschain/arbitrum/LibArbitrumL2.sol
  9. 1 1
      contracts/finance/PaymentSplitter.sol
  10. 1 1
      contracts/finance/VestingWallet.sol
  11. 1 1
      contracts/governance/Governor.sol
  12. 1 1
      contracts/governance/IGovernor.sol
  13. 1 1
      contracts/governance/TimelockController.sol
  14. 1 1
      contracts/governance/compatibility/GovernorCompatibilityBravo.sol
  15. 1 1
      contracts/governance/extensions/GovernorCountingSimple.sol
  16. 1 1
      contracts/governance/extensions/GovernorVotesQuorumFraction.sol
  17. 1 1
      contracts/governance/utils/Votes.sol
  18. 1 0
      contracts/interfaces/IERC2309.sol
  19. 1 1
      contracts/interfaces/IERC4626.sol
  20. 1 1
      contracts/metatx/MinimalForwarder.sol
  21. 1 1
      contracts/package.json
  22. 1 1
      contracts/proxy/Clones.sol
  23. 3 3
      contracts/proxy/utils/Initializable.sol
  24. 1 1
      contracts/proxy/utils/UUPSUpgradeable.sol
  25. 1 1
      contracts/security/PullPayment.sol
  26. 1 1
      contracts/security/ReentrancyGuard.sol
  27. 1 1
      contracts/token/ERC1155/ERC1155.sol
  28. 1 1
      contracts/token/ERC1155/extensions/ERC1155Burnable.sol
  29. 1 1
      contracts/token/ERC20/ERC20.sol
  30. 1 1
      contracts/token/ERC20/extensions/ERC20FlashMint.sol
  31. 15 4
      contracts/token/ERC20/extensions/ERC4626.sol
  32. 1 0
      contracts/token/ERC20/extensions/draft-ERC20Permit.sol
  33. 1 1
      contracts/token/ERC20/utils/SafeERC20.sol
  34. 1 1
      contracts/token/ERC721/ERC721.sol
  35. 1 1
      contracts/token/ERC721/IERC721.sol
  36. 1 1
      contracts/token/ERC721/extensions/ERC721Burnable.sol
  37. 1 0
      contracts/token/ERC721/extensions/ERC721Consecutive.sol
  38. 1 1
      contracts/token/ERC721/extensions/ERC721Enumerable.sol
  39. 1 1
      contracts/token/ERC721/extensions/ERC721Pausable.sol
  40. 1 1
      contracts/token/ERC721/extensions/ERC721Royalty.sol
  41. 1 0
      contracts/token/ERC721/extensions/ERC721Votes.sol
  42. 1 0
      contracts/token/ERC721/extensions/draft-ERC721Votes.sol
  43. 1 1
      contracts/token/ERC777/ERC777.sol
  44. 1 1
      contracts/token/ERC777/IERC777.sol
  45. 1 1
      contracts/utils/Address.sol
  46. 1 1
      contracts/utils/Arrays.sol
  47. 18 8
      contracts/utils/Checkpoints.sol
  48. 1 1
      contracts/utils/Create2.sol
  49. 1 1
      contracts/utils/Strings.sol
  50. 1 1
      contracts/utils/cryptography/ECDSA.sol
  51. 1 0
      contracts/utils/cryptography/EIP712.sol
  52. 9 5
      contracts/utils/cryptography/MerkleProof.sol
  53. 1 1
      contracts/utils/cryptography/SignatureChecker.sol
  54. 1 0
      contracts/utils/cryptography/draft-EIP712.sol
  55. 1 1
      contracts/utils/introspection/ERC165Checker.sol
  56. 1 1
      contracts/utils/introspection/IERC1820Registry.sol
  57. 2 2
      contracts/utils/math/Math.sol
  58. 1 1
      contracts/utils/math/SafeCast.sol
  59. 1 1
      contracts/utils/math/SignedMath.sol
  60. 1 1
      contracts/utils/structs/BitMaps.sol
  61. 1 1
      contracts/utils/structs/EnumerableMap.sol
  62. 1 1
      contracts/utils/structs/EnumerableSet.sol
  63. 1 0
      contracts/vendor/arbitrum/IArbSys.sol
  64. 1 0
      contracts/vendor/arbitrum/IBridge.sol
  65. 1 0
      contracts/vendor/arbitrum/IDelayedMessageProvider.sol
  66. 1 0
      contracts/vendor/arbitrum/IInbox.sol
  67. 1 0
      contracts/vendor/arbitrum/IOutbox.sol
  68. 2 16040
      package-lock.json
  69. 1 1
      package.json
  70. 7 3
      scripts/generate/templates/Checkpoints.js
  71. 1 1
      test/token/ERC1155/extensions/ERC1155URIStorage.test.js
  72. 1 1
      test/token/ERC20/extensions/ERC20Votes.test.js
  73. 1 1
      test/token/ERC20/extensions/ERC20VotesComp.test.js
  74. 19 0
      test/token/ERC20/extensions/ERC4626.t.sol
  75. 4 4
      test/token/ERC20/extensions/draft-ERC20Permit.test.js
  76. 1 1
      test/utils/Checkpoints.test.js

+ 1 - 0
.github/workflows/checks.yml

@@ -77,6 +77,7 @@ jobs:
       - uses: actions/checkout@v3
       - name: Set up environment
         uses: ./.github/actions/setup
+      - run: rm foundry.toml # https://github.com/foundry-rs/foundry/issues/3827
       - uses: crytic/slither-action@v0.2.0
 
   codespell:

+ 14 - 2
CHANGELOG.md

@@ -38,12 +38,13 @@ For example, a contract using `ERC20`'s `_beforeTokenTransfer` hook would have t
  * `ReentrancyGuard`: Add a `_reentrancyGuardEntered` function to expose the guard status. ([#3714](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3714))
  * `ERC20Votes`: optimize by using unchecked arithmetic. ([#3748](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3748))
  * `Initializable`: optimize `_disableInitializers` by using `!=` instead of `<`. ([#3787](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3787))
+ * `Math`: optimize `log256` rounding check. ([#3745](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3745))
 
 ### Deprecations
 
  * `ERC20Permit`: Added the file `IERC20Permit.sol` and `ERC20Permit.sol` and deprecated `draft-IERC20Permit.sol` and `draft-ERC20Permit.sol` since [EIP-2612](https://eips.ethereum.org/EIPS/eip-2612) is no longer a Draft. Developers are encouraged to update their imports. ([#3793](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3793))
 
-## Unreleased
+## 4.8.0 (2022-11-08)
 
  * `TimelockController`: Added a new `admin` constructor parameter that is assigned the admin role instead of the deployer account. ([#3722](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3722))
  * `Initializable`: add internal functions `_getInitializedVersion` and `_isInitializing` ([#3598](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3598))
@@ -78,7 +79,6 @@ For example, a contract using `ERC20`'s `_beforeTokenTransfer` hook would have t
  * `Math` and `SignedMath`: optimize function `max` by using `>` instead of `>=`. ([#3679](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3679))
  * `Math`: Add `log2`, `log10` and `log256`. ([#3670](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3670))
  * Arbitrum: Update the vendored arbitrum contracts to match the nitro upgrade. ([#3692](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3692))
- * `Math`: optimize `log256` rounding check. ([#3745](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3745))
 
 ### Breaking changes
 
@@ -119,6 +119,18 @@ ERC-721 integrators that interpret contract state from events should make sure t
 
 With the new `ERC721Consecutive` extension, the internal workings of `ERC721` are slightly changed. Custom extensions to ERC721 should be reviewed to ensure they remain correct. The internal functions that should be considered are `_ownerOf` (new), `_beforeTokenTransfer`, and `_afterTokenTransfer`.
 
+### ERC-4626 Upgrade Note
+
+Existing `ERC4626` contracts that are upgraded to 4.8 must initialize a new variable that holds the vault token decimals. The recommended way to do this is to use a [reinitializer]:
+
+[reinitializer]: https://docs.openzeppelin.com/contracts/4.x/api/proxy#Initializable-reinitializer-uint8-
+
+```solidity
+function migrateToV48() public reinitializer(2) {
+    __ERC4626_init(IERC20Upgradeable(asset()));
+}
+```
+
 ## 4.7.3
 
 ### Breaking changes

+ 1 - 1
contracts/access/AccessControl.sol

@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: MIT
-// OpenZeppelin Contracts (last updated v4.7.0) (access/AccessControl.sol)
+// OpenZeppelin Contracts (last updated v4.8.0) (access/AccessControl.sol)
 
 pragma solidity ^0.8.0;
 

+ 1 - 1
contracts/access/Ownable2Step.sol

@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: MIT
-// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)
+// OpenZeppelin Contracts (last updated v4.8.0) (access/Ownable2Step.sol)
 
 pragma solidity ^0.8.0;
 

+ 2 - 0
contracts/access/README.adoc

@@ -12,6 +12,8 @@ This directory provides ways to restrict who can access the functions of a contr
 
 {{Ownable}}
 
+{{Ownable2Step}}
+
 {{IAccessControl}}
 
 {{AccessControl}}

+ 1 - 1
contracts/crosschain/arbitrum/CrossChainEnabledArbitrumL2.sol

@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: MIT
-// OpenZeppelin Contracts (last updated v4.7.0) (crosschain/arbitrum/CrossChainEnabledArbitrumL2.sol)
+// OpenZeppelin Contracts (last updated v4.8.0) (crosschain/arbitrum/CrossChainEnabledArbitrumL2.sol)
 
 pragma solidity ^0.8.4;
 

+ 1 - 1
contracts/crosschain/arbitrum/LibArbitrumL1.sol

@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: MIT
-// OpenZeppelin Contracts (last updated v4.7.0) (crosschain/arbitrum/LibArbitrumL1.sol)
+// OpenZeppelin Contracts (last updated v4.8.0) (crosschain/arbitrum/LibArbitrumL1.sol)
 
 pragma solidity ^0.8.4;
 

+ 1 - 1
contracts/crosschain/arbitrum/LibArbitrumL2.sol

@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: MIT
-// OpenZeppelin Contracts (last updated v4.7.0) (crosschain/arbitrum/LibArbitrumL2.sol)
+// OpenZeppelin Contracts (last updated v4.8.0) (crosschain/arbitrum/LibArbitrumL2.sol)
 
 pragma solidity ^0.8.4;
 

+ 1 - 1
contracts/finance/PaymentSplitter.sol

@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: MIT
-// OpenZeppelin Contracts (last updated v4.7.0) (finance/PaymentSplitter.sol)
+// OpenZeppelin Contracts (last updated v4.8.0) (finance/PaymentSplitter.sol)
 
 pragma solidity ^0.8.0;
 

+ 1 - 1
contracts/finance/VestingWallet.sol

@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: MIT
-// OpenZeppelin Contracts (last updated v4.7.0) (finance/VestingWallet.sol)
+// OpenZeppelin Contracts (last updated v4.8.0) (finance/VestingWallet.sol)
 pragma solidity ^0.8.0;
 
 import "../token/ERC20/utils/SafeERC20.sol";

+ 1 - 1
contracts/governance/Governor.sol

@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: MIT
-// OpenZeppelin Contracts (last updated v4.7.0) (governance/Governor.sol)
+// OpenZeppelin Contracts (last updated v4.8.0) (governance/Governor.sol)
 
 pragma solidity ^0.8.0;
 

+ 1 - 1
contracts/governance/IGovernor.sol

@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: MIT
-// OpenZeppelin Contracts (last updated v4.7.0) (governance/IGovernor.sol)
+// OpenZeppelin Contracts (last updated v4.8.0) (governance/IGovernor.sol)
 
 pragma solidity ^0.8.0;
 

+ 1 - 1
contracts/governance/TimelockController.sol

@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: MIT
-// OpenZeppelin Contracts (last updated v4.7.0) (governance/TimelockController.sol)
+// OpenZeppelin Contracts (last updated v4.8.0) (governance/TimelockController.sol)
 
 pragma solidity ^0.8.0;
 

+ 1 - 1
contracts/governance/compatibility/GovernorCompatibilityBravo.sol

@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: MIT
-// OpenZeppelin Contracts (last updated v4.6.0) (governance/compatibility/GovernorCompatibilityBravo.sol)
+// OpenZeppelin Contracts (last updated v4.8.0) (governance/compatibility/GovernorCompatibilityBravo.sol)
 
 pragma solidity ^0.8.0;
 

+ 1 - 1
contracts/governance/extensions/GovernorCountingSimple.sol

@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: MIT
-// OpenZeppelin Contracts (last updated v4.6.0) (governance/extensions/GovernorCountingSimple.sol)
+// OpenZeppelin Contracts (last updated v4.8.0) (governance/extensions/GovernorCountingSimple.sol)
 
 pragma solidity ^0.8.0;
 

+ 1 - 1
contracts/governance/extensions/GovernorVotesQuorumFraction.sol

@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: MIT
-// OpenZeppelin Contracts (last updated v4.5.0) (governance/extensions/GovernorVotesQuorumFraction.sol)
+// OpenZeppelin Contracts (last updated v4.8.0) (governance/extensions/GovernorVotesQuorumFraction.sol)
 
 pragma solidity ^0.8.0;
 

+ 1 - 1
contracts/governance/utils/Votes.sol

@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: MIT
-// OpenZeppelin Contracts (last updated v4.6.0) (governance/utils/Votes.sol)
+// OpenZeppelin Contracts (last updated v4.8.0) (governance/utils/Votes.sol)
 pragma solidity ^0.8.0;
 
 import "../../utils/Context.sol";

+ 1 - 0
contracts/interfaces/IERC2309.sol

@@ -1,4 +1,5 @@
 // SPDX-License-Identifier: MIT
+// OpenZeppelin Contracts (last updated v4.8.0) (interfaces/IERC2309.sol)
 
 pragma solidity ^0.8.0;
 

+ 1 - 1
contracts/interfaces/IERC4626.sol

@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: MIT
-// OpenZeppelin Contracts (last updated v4.7.0) (interfaces/IERC4626.sol)
+// OpenZeppelin Contracts (last updated v4.8.0) (interfaces/IERC4626.sol)
 
 pragma solidity ^0.8.0;
 

+ 1 - 1
contracts/metatx/MinimalForwarder.sol

@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: MIT
-// OpenZeppelin Contracts (last updated v4.7.0) (metatx/MinimalForwarder.sol)
+// OpenZeppelin Contracts (last updated v4.8.0) (metatx/MinimalForwarder.sol)
 
 pragma solidity ^0.8.0;
 

+ 1 - 1
contracts/package.json

@@ -1,7 +1,7 @@
 {
   "name": "@openzeppelin/contracts",
   "description": "Secure Smart Contract library for Solidity",
-  "version": "4.7.0",
+  "version": "4.8.0",
   "files": [
     "**/*.sol",
     "/build/contracts/*.json",

+ 1 - 1
contracts/proxy/Clones.sol

@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: MIT
-// OpenZeppelin Contracts (last updated v4.7.0) (proxy/Clones.sol)
+// OpenZeppelin Contracts (last updated v4.8.0) (proxy/Clones.sol)
 
 pragma solidity ^0.8.0;
 

+ 3 - 3
contracts/proxy/utils/Initializable.sol

@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: MIT
-// OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol)
+// OpenZeppelin Contracts (last updated v4.8.0) (proxy/utils/Initializable.sol)
 
 pragma solidity ^0.8.2;
 
@@ -150,14 +150,14 @@ abstract contract Initializable {
     }
 
     /**
-     * @dev Internal function that returns the initialized version. Returns `_initialized`
+     * @dev Returns the highest version that has been initialized. See {reinitializer}.
      */
     function _getInitializedVersion() internal view returns (uint8) {
         return _initialized;
     }
 
     /**
-     * @dev Internal function that returns the initialized version. Returns `_initializing`
+     * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
      */
     function _isInitializing() internal view returns (bool) {
         return _initializing;

+ 1 - 1
contracts/proxy/utils/UUPSUpgradeable.sol

@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: MIT
-// OpenZeppelin Contracts (last updated v4.5.0) (proxy/utils/UUPSUpgradeable.sol)
+// OpenZeppelin Contracts (last updated v4.8.0) (proxy/utils/UUPSUpgradeable.sol)
 
 pragma solidity ^0.8.0;
 

+ 1 - 1
contracts/security/PullPayment.sol

@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: MIT
-// OpenZeppelin Contracts (last updated v4.7.0) (security/PullPayment.sol)
+// OpenZeppelin Contracts (last updated v4.8.0) (security/PullPayment.sol)
 
 pragma solidity ^0.8.0;
 

+ 1 - 1
contracts/security/ReentrancyGuard.sol

@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: MIT
-// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)
+// OpenZeppelin Contracts (last updated v4.8.0) (security/ReentrancyGuard.sol)
 
 pragma solidity ^0.8.0;
 

+ 1 - 1
contracts/token/ERC1155/ERC1155.sol

@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: MIT
-// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/ERC1155.sol)
+// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC1155/ERC1155.sol)
 
 pragma solidity ^0.8.0;
 

+ 1 - 1
contracts/token/ERC1155/extensions/ERC1155Burnable.sol

@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: MIT
-// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/extensions/ERC1155Burnable.sol)
+// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC1155/extensions/ERC1155Burnable.sol)
 
 pragma solidity ^0.8.0;
 

+ 1 - 1
contracts/token/ERC20/ERC20.sol

@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: MIT
-// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/ERC20.sol)
+// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/ERC20.sol)
 
 pragma solidity ^0.8.0;
 

+ 1 - 1
contracts/token/ERC20/extensions/ERC20FlashMint.sol

@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: MIT
-// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/extensions/ERC20FlashMint.sol)
+// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/extensions/ERC20FlashMint.sol)
 
 pragma solidity ^0.8.0;
 

+ 15 - 4
contracts/token/ERC20/extensions/ERC4626.sol

@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: MIT
-// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/extensions/ERC4626.sol)
+// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/extensions/ERC4626.sol)
 
 pragma solidity ^0.8.0;
 
@@ -17,8 +17,12 @@ import "../../../utils/math/Math.sol";
  * the ERC20 standard. Any additional extensions included along it would affect the "shares" token represented by this
  * contract and not the "assets" token which is an independent contract.
  *
- * CAUTION: Deposits and withdrawals may incur unexpected slippage. Users should verify that the amount received of
- * shares or assets is as expected. EOAs should operate through a wrapper that performs these checks such as
+ * CAUTION: When the vault is empty or nearly empty, deposits are at high risk of being stolen through frontrunning with
+ * a "donation" to the vault that inflates the price of a share. This is variously known as a donation or inflation
+ * attack and is essentially a problem of slippage. Vault deployers can protect against this attack by making an initial
+ * deposit of a non-trivial amount of the asset, such that price manipulation becomes infeasible. Withdrawals may
+ * similarly be affected by slippage. Users can protect against this attack as well unexpected slippage in general by
+ * verifying the amount received is as expected, using a wrapper that performs these checks such as
  * https://github.com/fei-protocol/ERC4626#erc4626router-and-base[ERC4626Router].
  *
  * _Available since v4.7._
@@ -134,7 +138,11 @@ abstract contract ERC4626 is ERC20, IERC4626 {
         return shares;
     }
 
-    /** @dev See {IERC4626-mint}. */
+    /** @dev See {IERC4626-mint}.
+     *
+     * As opposed to {deposit}, minting is allowed even if the vault is in a state where the price of a share is zero.
+     * In this case, the shares will be minted without requiring any assets to be deposited.
+     */
     function mint(uint256 shares, address receiver) public virtual override returns (uint256) {
         require(shares <= maxMint(receiver), "ERC4626: mint more than max");
 
@@ -267,6 +275,9 @@ abstract contract ERC4626 is ERC20, IERC4626 {
         emit Withdraw(caller, receiver, owner, assets, shares);
     }
 
+    /**
+     * @dev Checks if vault is "healthy" in the sense of having assets backing the circulating shares.
+     */
     function _isVaultHealthy() private view returns (bool) {
         return totalAssets() > 0 || totalSupply() == 0;
     }

+ 1 - 0
contracts/token/ERC20/extensions/draft-ERC20Permit.sol

@@ -1,4 +1,5 @@
 // SPDX-License-Identifier: MIT
+// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/extensions/draft-ERC20Permit.sol)
 
 pragma solidity ^0.8.0;
 

+ 1 - 1
contracts/token/ERC20/utils/SafeERC20.sol

@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: MIT
-// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)
+// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)
 
 pragma solidity ^0.8.0;
 

+ 1 - 1
contracts/token/ERC721/ERC721.sol

@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: MIT
-// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/ERC721.sol)
+// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/ERC721.sol)
 
 pragma solidity ^0.8.0;
 

+ 1 - 1
contracts/token/ERC721/IERC721.sol

@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: MIT
-// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol)
+// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol)
 
 pragma solidity ^0.8.0;
 

+ 1 - 1
contracts/token/ERC721/extensions/ERC721Burnable.sol

@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: MIT
-// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/extensions/ERC721Burnable.sol)
+// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/extensions/ERC721Burnable.sol)
 
 pragma solidity ^0.8.0;
 

+ 1 - 0
contracts/token/ERC721/extensions/ERC721Consecutive.sol

@@ -1,4 +1,5 @@
 // SPDX-License-Identifier: MIT
+// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/extensions/ERC721Consecutive.sol)
 
 pragma solidity ^0.8.0;
 

+ 1 - 1
contracts/token/ERC721/extensions/ERC721Enumerable.sol

@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: MIT
-// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/ERC721Enumerable.sol)
+// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/extensions/ERC721Enumerable.sol)
 
 pragma solidity ^0.8.0;
 

+ 1 - 1
contracts/token/ERC721/extensions/ERC721Pausable.sol

@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: MIT
-// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/ERC721Pausable.sol)
+// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/extensions/ERC721Pausable.sol)
 
 pragma solidity ^0.8.0;
 

+ 1 - 1
contracts/token/ERC721/extensions/ERC721Royalty.sol

@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: MIT
-// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/ERC721Royalty.sol)
+// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/extensions/ERC721Royalty.sol)
 
 pragma solidity ^0.8.0;
 

+ 1 - 0
contracts/token/ERC721/extensions/ERC721Votes.sol

@@ -1,4 +1,5 @@
 // SPDX-License-Identifier: MIT
+// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/extensions/ERC721Votes.sol)
 
 pragma solidity ^0.8.0;
 

+ 1 - 0
contracts/token/ERC721/extensions/draft-ERC721Votes.sol

@@ -1,4 +1,5 @@
 // SPDX-License-Identifier: MIT
+// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/extensions/draft-ERC721Votes.sol)
 
 pragma solidity ^0.8.0;
 

+ 1 - 1
contracts/token/ERC777/ERC777.sol

@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: MIT
-// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC777/ERC777.sol)
+// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC777/ERC777.sol)
 
 pragma solidity ^0.8.0;
 

+ 1 - 1
contracts/token/ERC777/IERC777.sol

@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: MIT
-// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC777/IERC777.sol)
+// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC777/IERC777.sol)
 
 pragma solidity ^0.8.0;
 

+ 1 - 1
contracts/utils/Address.sol

@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: MIT
-// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)
+// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)
 
 pragma solidity ^0.8.1;
 

+ 1 - 1
contracts/utils/Arrays.sol

@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: MIT
-// OpenZeppelin Contracts v4.4.1 (utils/Arrays.sol)
+// OpenZeppelin Contracts (last updated v4.8.0) (utils/Arrays.sol)
 
 pragma solidity ^0.8.0;
 

+ 18 - 8
contracts/utils/Checkpoints.sol

@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: MIT
-// OpenZeppelin Contracts (last updated v4.5.0) (utils/Checkpoints.sol)
+// OpenZeppelin Contracts (last updated v4.8.0) (utils/Checkpoints.sol)
 // This file was procedurally generated from scripts/generate/templates/Checkpoints.js.
 
 pragma solidity ^0.8.0;
@@ -28,7 +28,8 @@ library Checkpoints {
 
     /**
      * @dev Returns the value at a given block number. If a checkpoint is not available at that block, the closest one
-     * before it is returned, or zero otherwise.
+     * before it is returned, or zero otherwise. Because the number returned corresponds to that at the end of the
+     * block, the requested block number must be in the past, excluding the current block.
      */
     function getAtBlock(History storage self, uint256 blockNumber) internal view returns (uint256) {
         require(blockNumber < block.number, "Checkpoints: block not yet mined");
@@ -150,8 +151,8 @@ library Checkpoints {
             // Copying to memory is important here.
             Checkpoint memory last = _unsafeAccess(self, pos - 1);
 
-            // Checkpoints keys must be increasing.
-            require(last._blockNumber <= key, "Checkpoint: invalid key");
+            // Checkpoint keys must be non-decreasing.
+            require(last._blockNumber <= key, "Checkpoint: decreasing keys");
 
             // Update or push new checkpoint
             if (last._blockNumber == key) {
@@ -212,6 +213,9 @@ library Checkpoints {
         return high;
     }
 
+    /**
+     * @dev Access an element of the array without performing bounds check. The position is assumed to be within bounds.
+     */
     function _unsafeAccess(Checkpoint[] storage self, uint256 pos) private pure returns (Checkpoint storage result) {
         assembly {
             mstore(0, self.slot)
@@ -311,8 +315,8 @@ library Checkpoints {
             // Copying to memory is important here.
             Checkpoint224 memory last = _unsafeAccess(self, pos - 1);
 
-            // Checkpoints keys must be increasing.
-            require(last._key <= key, "Checkpoint: invalid key");
+            // Checkpoint keys must be non-decreasing.
+            require(last._key <= key, "Checkpoint: decreasing keys");
 
             // Update or push new checkpoint
             if (last._key == key) {
@@ -373,6 +377,9 @@ library Checkpoints {
         return high;
     }
 
+    /**
+     * @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
@@ -476,8 +483,8 @@ library Checkpoints {
             // Copying to memory is important here.
             Checkpoint160 memory last = _unsafeAccess(self, pos - 1);
 
-            // Checkpoints keys must be increasing.
-            require(last._key <= key, "Checkpoint: invalid key");
+            // Checkpoint keys must be non-decreasing.
+            require(last._key <= key, "Checkpoint: decreasing keys");
 
             // Update or push new checkpoint
             if (last._key == key) {
@@ -538,6 +545,9 @@ library Checkpoints {
         return high;
     }
 
+    /**
+     * @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

+ 1 - 1
contracts/utils/Create2.sol

@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: MIT
-// OpenZeppelin Contracts (last updated v4.7.0) (utils/Create2.sol)
+// OpenZeppelin Contracts (last updated v4.8.0) (utils/Create2.sol)
 
 pragma solidity ^0.8.0;
 

+ 1 - 1
contracts/utils/Strings.sol

@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: MIT
-// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)
+// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)
 
 pragma solidity ^0.8.0;
 

+ 1 - 1
contracts/utils/cryptography/ECDSA.sol

@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: MIT
-// OpenZeppelin Contracts (last updated v4.7.0) (utils/cryptography/ECDSA.sol)
+// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/ECDSA.sol)
 
 pragma solidity ^0.8.0;
 

+ 1 - 0
contracts/utils/cryptography/EIP712.sol

@@ -1,4 +1,5 @@
 // SPDX-License-Identifier: MIT
+// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/EIP712.sol)
 
 pragma solidity ^0.8.0;
 

+ 9 - 5
contracts/utils/cryptography/MerkleProof.sol

@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: MIT
-// OpenZeppelin Contracts (last updated v4.7.0) (utils/cryptography/MerkleProof.sol)
+// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/MerkleProof.sol)
 
 pragma solidity ^0.8.0;
 
@@ -124,7 +124,7 @@ library MerkleProof {
         bool[] memory proofFlags,
         bytes32[] memory leaves
     ) internal pure returns (bytes32 merkleRoot) {
-        // This function rebuild the root hash by traversing the tree up from the leaves. The root is rebuilt by
+        // This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by
         // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
         // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
         // the merkle tree.
@@ -147,7 +147,9 @@ library MerkleProof {
         //   `proof` array.
         for (uint256 i = 0; i < totalHashes; i++) {
             bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
-            bytes32 b = proofFlags[i] ? leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++] : proof[proofPos++];
+            bytes32 b = proofFlags[i]
+                ? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])
+                : proof[proofPos++];
             hashes[i] = _hashPair(a, b);
         }
 
@@ -172,7 +174,7 @@ library MerkleProof {
         bool[] calldata proofFlags,
         bytes32[] memory leaves
     ) internal pure returns (bytes32 merkleRoot) {
-        // This function rebuild the root hash by traversing the tree up from the leaves. The root is rebuilt by
+        // This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by
         // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
         // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
         // the merkle tree.
@@ -195,7 +197,9 @@ library MerkleProof {
         //   `proof` array.
         for (uint256 i = 0; i < totalHashes; i++) {
             bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
-            bytes32 b = proofFlags[i] ? leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++] : proof[proofPos++];
+            bytes32 b = proofFlags[i]
+                ? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])
+                : proof[proofPos++];
             hashes[i] = _hashPair(a, b);
         }
 

+ 1 - 1
contracts/utils/cryptography/SignatureChecker.sol

@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: MIT
-// OpenZeppelin Contracts (last updated v4.5.0) (utils/cryptography/SignatureChecker.sol)
+// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/SignatureChecker.sol)
 
 pragma solidity ^0.8.0;
 

+ 1 - 0
contracts/utils/cryptography/draft-EIP712.sol

@@ -1,4 +1,5 @@
 // SPDX-License-Identifier: MIT
+// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/draft-EIP712.sol)
 
 pragma solidity ^0.8.0;
 

+ 1 - 1
contracts/utils/introspection/ERC165Checker.sol

@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: MIT
-// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165Checker.sol)
+// OpenZeppelin Contracts (last updated v4.8.0) (utils/introspection/ERC165Checker.sol)
 
 pragma solidity ^0.8.0;
 

+ 1 - 1
contracts/utils/introspection/IERC1820Registry.sol

@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: MIT
-// OpenZeppelin Contracts (last updated v4.6.0) (utils/introspection/IERC1820Registry.sol)
+// OpenZeppelin Contracts (last updated v4.8.0) (utils/introspection/IERC1820Registry.sol)
 
 pragma solidity ^0.8.0;
 

+ 2 - 2
contracts/utils/math/Math.sol

@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: MIT
-// OpenZeppelin Contracts (last updated v4.7.0) (utils/math/Math.sol)
+// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)
 
 pragma solidity ^0.8.0;
 
@@ -75,7 +75,7 @@ library Math {
             }
 
             // Make sure the result is less than 2^256. Also prevents denominator == 0.
-            require(denominator > prod1);
+            require(denominator > prod1, "Math: mulDiv overflow");
 
             ///////////////////////////////////////////////
             // 512 by 256 division.

+ 1 - 1
contracts/utils/math/SafeCast.sol

@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: MIT
-// OpenZeppelin Contracts (last updated v4.7.0) (utils/math/SafeCast.sol)
+// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol)
 // This file was procedurally generated from scripts/generate/templates/SafeCast.js.
 
 pragma solidity ^0.8.0;

+ 1 - 1
contracts/utils/math/SignedMath.sol

@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: MIT
-// OpenZeppelin Contracts (last updated v4.5.0) (utils/math/SignedMath.sol)
+// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)
 
 pragma solidity ^0.8.0;
 

+ 1 - 1
contracts/utils/structs/BitMaps.sol

@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: MIT
-// OpenZeppelin Contracts v4.4.1 (utils/structs/BitMaps.sol)
+// OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/BitMaps.sol)
 pragma solidity ^0.8.0;
 
 /**

+ 1 - 1
contracts/utils/structs/EnumerableMap.sol

@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: MIT
-// OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableMap.sol)
+// OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/EnumerableMap.sol)
 // This file was procedurally generated from scripts/generate/templates/EnumerableMap.js.
 
 pragma solidity ^0.8.0;

+ 1 - 1
contracts/utils/structs/EnumerableSet.sol

@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: MIT
-// OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol)
+// OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/EnumerableSet.sol)
 // This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.
 
 pragma solidity ^0.8.0;

+ 1 - 0
contracts/vendor/arbitrum/IArbSys.sol

@@ -1,6 +1,7 @@
 // Copyright 2021-2022, Offchain Labs, Inc.
 // For license information, see https://github.com/OffchainLabs/nitro/blob/master/LICENSE
 // SPDX-License-Identifier: BUSL-1.1
+// OpenZeppelin Contracts (last updated v4.8.0) (vendor/arbitrum/IArbSys.sol)
 
 pragma solidity >=0.4.21 <0.9.0;
 

+ 1 - 0
contracts/vendor/arbitrum/IBridge.sol

@@ -1,6 +1,7 @@
 // Copyright 2021-2022, Offchain Labs, Inc.
 // For license information, see https://github.com/nitro/blob/master/LICENSE
 // SPDX-License-Identifier: BUSL-1.1
+// OpenZeppelin Contracts (last updated v4.8.0) (vendor/arbitrum/IBridge.sol)
 
 // solhint-disable-next-line compiler-version
 pragma solidity >=0.6.9 <0.9.0;

+ 1 - 0
contracts/vendor/arbitrum/IDelayedMessageProvider.sol

@@ -1,6 +1,7 @@
 // Copyright 2021-2022, Offchain Labs, Inc.
 // For license information, see https://github.com/nitro/blob/master/LICENSE
 // SPDX-License-Identifier: BUSL-1.1
+// OpenZeppelin Contracts (last updated v4.8.0) (vendor/arbitrum/IDelayedMessageProvider.sol)
 
 // solhint-disable-next-line compiler-version
 pragma solidity >=0.6.9 <0.9.0;

+ 1 - 0
contracts/vendor/arbitrum/IInbox.sol

@@ -1,6 +1,7 @@
 // Copyright 2021-2022, Offchain Labs, Inc.
 // For license information, see https://github.com/nitro/blob/master/LICENSE
 // SPDX-License-Identifier: BUSL-1.1
+// OpenZeppelin Contracts (last updated v4.8.0) (vendor/arbitrum/IInbox.sol)
 
 // solhint-disable-next-line compiler-version
 pragma solidity >=0.6.9 <0.9.0;

+ 1 - 0
contracts/vendor/arbitrum/IOutbox.sol

@@ -1,6 +1,7 @@
 // Copyright 2021-2022, Offchain Labs, Inc.
 // For license information, see https://github.com/nitro/blob/master/LICENSE
 // SPDX-License-Identifier: BUSL-1.1
+// OpenZeppelin Contracts (last updated v4.8.0) (vendor/arbitrum/IOutbox.sol)
 
 // solhint-disable-next-line compiler-version
 pragma solidity >=0.6.9 <0.9.0;

File diff suppressed because it is too large
+ 2 - 16040
package-lock.json


+ 1 - 1
package.json

@@ -1,7 +1,7 @@
 {
   "name": "openzeppelin-solidity",
   "description": "Secure Smart Contract library for Solidity",
-  "version": "4.7.0",
+  "version": "4.8.0",
   "files": [
     "/contracts/**/*.sol",
     "/build/contracts/*.json",

+ 7 - 3
scripts/generate/templates/Checkpoints.js

@@ -67,7 +67,8 @@ function upperLookup(${opts.historyTypeName} storage self, ${opts.keyTypeName} k
 const legacyOperations = opts => `\
 /**
  * @dev Returns the value at a given block number. If a checkpoint is not available at that block, the closest one
- * before it is returned, or zero otherwise.
+ * before it is returned, or zero otherwise. Because the number returned corresponds to that at the end of the
+ * block, the requested block number must be in the past, excluding the current block.
  */
 function getAtBlock(${opts.historyTypeName} storage self, uint256 blockNumber) internal view returns (uint256) {
     require(blockNumber < block.number, "Checkpoints: block not yet mined");
@@ -191,8 +192,8 @@ function _insert(
         // Copying to memory is important here.
         ${opts.checkpointTypeName} memory last = _unsafeAccess(self, pos - 1);
 
-        // Checkpoints keys must be increasing.
-        require(last.${opts.keyFieldName} <= key, "Checkpoint: invalid key");
+        // Checkpoint keys must be non-decreasing.
+        require(last.${opts.keyFieldName} <= key, "Checkpoint: decreasing keys");
 
         // Update or push new checkpoint
         if (last.${opts.keyFieldName} == key) {
@@ -253,6 +254,9 @@ function _lowerBinaryLookup(
     return high;
 }
 
+/**
+ * @dev Access an element of the array without performing bounds check. The position is assumed to be within bounds.
+ */
 function _unsafeAccess(${opts.checkpointTypeName}[] storage self, uint256 pos)
     private
     pure

+ 1 - 1
test/token/ERC1155/extensions/ERC1155URIStorage.test.js

@@ -17,7 +17,7 @@ contract(['ERC1155URIStorage'], function (accounts) {
   describe('with base uri set', function () {
     beforeEach(async function () {
       this.token = await ERC1155URIStorageMock.new(erc1155Uri);
-      this.token.setBaseURI(baseUri);
+      await this.token.setBaseURI(baseUri);
 
       await this.token.mint(holder, tokenId, amount, '0x');
     });

+ 1 - 1
test/token/ERC20/extensions/ERC20Votes.test.js

@@ -21,7 +21,7 @@ const Delegation = [
 ];
 
 contract('ERC20Votes', function (accounts) {
-  const [ holder, recipient, holderDelegatee, recipientDelegatee, other1, other2 ] = accounts;
+  const [ holder, recipient, holderDelegatee, other1, other2 ] = accounts;
 
   const name = 'My Token';
   const symbol = 'MTKN';

+ 1 - 1
test/token/ERC20/extensions/ERC20VotesComp.test.js

@@ -21,7 +21,7 @@ const Delegation = [
 ];
 
 contract('ERC20VotesComp', function (accounts) {
-  const [ holder, recipient, holderDelegatee, recipientDelegatee, other1, other2 ] = accounts;
+  const [ holder, recipient, holderDelegatee, other1, other2 ] = accounts;
 
   const name = 'My Token';
   const symbol = 'MTKN';

+ 19 - 0
test/token/ERC20/extensions/ERC4626.t.sol

@@ -3,6 +3,7 @@ pragma solidity ^0.8.0;
 
 import "erc4626-tests/ERC4626.test.sol";
 
+import {SafeCast} from "../../../../contracts/utils/math/SafeCast.sol";
 import {ERC20Mock} from "../../../../contracts/mocks/ERC20Mock.sol";
 import {ERC4626Mock, IERC20Metadata} from "../../../../contracts/mocks/ERC4626Mock.sol";
 
@@ -14,4 +15,22 @@ contract ERC4626StdTest is ERC4626Test {
         _vaultMayBeEmpty = false;
         _unlimitedAmount = true;
     }
+
+    // solhint-disable-next-line func-name-mixedcase
+    function test_RT_mint_withdraw(ERC4626Test.Init memory init, uint256 shares) public override {
+        // There is an edge case where we currently behave different than the property tests,
+        // when all assets are lost to negative yield.
+
+        // Sum all initially deposited assets.
+        int256 initAssets = 0;
+        for (uint256 i = 0; i < init.share.length; i++) {
+            vm.assume(init.share[i] <= uint256(type(int256).max - initAssets));
+            initAssets += SafeCast.toInt256(init.share[i]);
+        }
+
+        // Reject tests where the yield loses all assets from the vault.
+        vm.assume(init.yield > -initAssets);
+
+        super.test_RT_mint_withdraw(init, shares);
+    }
 }

+ 4 - 4
test/token/ERC20/extensions/draft-ERC20Permit.test.js

@@ -1,8 +1,8 @@
 /* eslint-disable */
 
-const { BN, constants, expectEvent, expectRevert, time } = require('@openzeppelin/test-helpers');
+const { BN, constants, expectRevert, time } = require('@openzeppelin/test-helpers');
 const { expect } = require('chai');
-const { MAX_UINT256, ZERO_ADDRESS, ZERO_BYTES32 } = constants;
+const { MAX_UINT256 } = constants;
 
 const { fromRpcSig } = require('ethereumjs-util');
 const ethSigUtil = require('eth-sig-util');
@@ -13,7 +13,7 @@ const ERC20PermitMock = artifacts.require('ERC20PermitMock');
 const { EIP712Domain, Permit, domainSeparator } = require('../../../helpers/eip712');
 
 contract('ERC20Permit', function (accounts) {
-  const [ initialHolder, spender, recipient, other ] = accounts;
+  const [ initialHolder, spender ] = accounts;
 
   const name = 'My Token';
   const symbol = 'MTKN';
@@ -62,7 +62,7 @@ contract('ERC20Permit', function (accounts) {
       const signature = ethSigUtil.signTypedMessage(wallet.getPrivateKey(), { data });
       const { v, r, s } = fromRpcSig(signature);
 
-      const receipt = await this.token.permit(owner, spender, value, maxDeadline, v, r, s);
+      await this.token.permit(owner, spender, value, maxDeadline, v, r, s);
 
       expect(await this.token.nonces(owner)).to.be.bignumber.equal('1');
       expect(await this.token.allowance(owner, spender)).to.be.bignumber.equal(value);

+ 1 - 1
test/utils/Checkpoints.test.js

@@ -151,7 +151,7 @@ contract('Checkpoints', function (accounts) {
         });
 
         it('cannot push values in the past', async function () {
-          await expectRevert(this.contract.push(last(this.checkpoints).key - 1, '0'), 'Checkpoint: invalid key');
+          await expectRevert(this.contract.push(last(this.checkpoints).key - 1, '0'), 'Checkpoint: decreasing keys');
         });
 
         it('can update last value', async function () {

Some files were not shown because too many files changed in this diff