Releases: OpenZeppelin/openzeppelin-contracts
v4.8.1
v4.8.0
Note
Don't miss the section on Breaking changes at the end.
TimelockController: Added a newadminconstructor parameter that is assigned the admin role instead of the deployer account. (#3722)Initializable: add internal functions_getInitializedVersionand_isInitializing(#3598)ERC165Checker: addsupportsERC165InterfaceUncheckedfor consulting individual interfaces without the full ERC165 protocol. (#3339)Address: optimizefunctionCallby callingfunctionCallWithValuedirectly. (#3468)Address: optimizefunctionCallfunctions by checking contract size only if there is no returned data. (#3469)Governor: make therelayfunction payable, and add support for EOA payments. (#3730)GovernorCompatibilityBravo: remove unusedusingstatements. (#3506)ERC20: optimize_transfer,_mintand_burnby usinguncheckedarithmetic when possible. (#3513)ERC20Votes,ERC721Votes: optimizegetPastVotesfor looking up recent checkpoints. (#3673)ERC20FlashMint: add an internal_flashFeefunction for overriding. (#3551)ERC4626: use the samedecimals()as the underlying asset by default (if available). (#3639)ERC4626: add internal_initialConvertToSharesand_initialConvertToAssetsfunctions to customize empty vaults behavior. (#3639)ERC721: optimize transfers by making approval clearing implicit instead of emitting an event. (#3481)ERC721: optimize burn by making approval clearing implicit instead of emitting an event. (#3538)ERC721: Fix balance accounting when a custom_beforeTokenTransferhook results in a transfer of the token under consideration. (#3611)ERC721: use unchecked arithmetic for balance updates. (#3524)ERC721Consecutive: Implementation of EIP-2309 that allows batch minting of ERC721 tokens during construction. (#3311)ReentrancyGuard: Reduce code size impact of the modifier by using internal functions. (#3515)SafeCast: optimize downcasting of signed integers. (#3565)ECDSA: Remove redundant check on thevvalue. (#3591)VestingWallet: addreleasablegetters. (#3580)VestingWallet: remove unused libraryMath.sol. (#3605)VestingWallet: make constructor payable. (#3665)Create2: optimize address computation by using assembly instead ofabi.encodePacked. (#3600)Clones: optimized the assembly to use only the scratch space during deployments, and optimizedpredictDeterministicAddressto use fewer operations. (#3640)Checkpoints: Use procedural generation to support multiple key/value lengths. (#3589)Checkpoints: Add new lookup mechanisms. (#3589)Arrays: AddunsafeAccessfunctions that allow reading and writing to an element in a storage array bypassing Solidity's "out-of-bounds" check. (#3589)Strings: optimizetoString. (#3573)Ownable2Step: extension ofOwnablethat makes the ownership transfers a two step process. (#3620)MathandSignedMath: optimize functionmaxby using>instead of>=. (#3679)Math: Addlog2,log10andlog256. (#3670)- Arbitrum: Update the vendored arbitrum contracts to match the nitro upgrade. (#3692)
Breaking changes
ERC721: In order to add support for batch minting viaERC721Consecutiveit was necessary to make a minor breaking change in the internal interface ofERC721. Namely, the hooks_beforeTokenTransferand_afterTokenTransferhave one additional argument that may need to be added to overrides:
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId,
+ uint256 batchSize
) internal virtual override-
ERC4626: Conversion from shares to assets (and vice-versa) in an empty vault used to consider the possible mismatch between the underlying asset's and the vault's decimals. This initial conversion rate is now set to 1-to-1 irrespective of decimals, which are meant for usability purposes only. The vault now uses the assets decimals by default, so off-chain the numbers should appear the same. Developers overriding the vault decimals to a value that does not match the underlying asset may want to override the_initialConvertToSharesand_initialConvertToAssetsto replicate the previous behavior. -
TimelockController: During deployment, the TimelockController used to grant theTIMELOCK_ADMIN_ROLEto the deployer and to the timelock itself. The deployer was then expected to renounce this role once configuration of the timelock is over. Failing to renounce that role allows the deployer to change the timelock permissions (but not to bypass the delay for any time-locked actions). The role is no longer given to the deployer by default. A new parameteradmincan be set to a non-zero address to grant the admin role during construction (to the deployer or any other address). Just like previously, this admin role should be renounced after configuration. If this param is givenaddress(0), the role is not allocated and doesn't need to be revoked. In any case, the timelock itself continues to have this role.
Deprecations
EIP712: Added the fileEIP712.soland deprecateddraft-EIP712.solsince the EIP is no longer a Draft. Developers are encouraged to update their imports. (#3621)
-import "@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol";
+import "@openzeppelin/contracts/utils/cryptography/EIP712.sol";ERC721Votes: Added the fileERC721Votes.soland deprecateddraft-ERC721Votes.solsince it no longer depends on a Draft EIP (EIP-712). Developers are encouraged to update their imports. (#3699)
-import "@openzeppelin/contracts/token/ERC721/extensions/draft-ERC721Votes.sol";
+import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Votes.sol";ERC-721 Compatibility Note
ERC-721 integrators that interpret contract state from events should make sure that they implement the clearing of approval that is implicit in every transfer according to the EIP. Previous versions of OpenZeppelin Contracts emitted an explicit Approval event even though it was not required by the specification, and this is no longer the case.
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.
v4.8.0-rc.1
This prerelease is now available for open review! Try it out, look at the code, and share your feedback.
In addition to all the changes in 4.8.0-rc.0, this new release candidate improves the timelock configuration process and updates part of the documentation.
- ⌛ TimelockController: Add a new admin constructor parameter that is assigned the admin role instead of the deployer account.
- 📖 Some documentation improvements.
Breaking changes
TimelockController: During deployment, the TimelockController used to grant the TIMELOCK_ADMIN_ROLE to the deployer and to the timelock itself. The deployer was then expected to renounce this role once configuration of the timelock is over. Failing to renounce that role allows the deployer to change the timelock permissions (but not to bypass the delay for any time-locked actions). The role is no longer given to the deployer by default. A new parameter admin can be set to a non-zero address to grant the admin role during construction (to the deployer or any other address). Just like previously, this admin role should be renounced after configuration. If this param is given address(0), the role is not allocated and doesn't need to be revoked. In any case, the timelock itself continues to have this role.
See the changelog for all the release details.
v4.8.0-rc.0
This prerelease is now available for open review! Try it out, look at the code, and share your feedback.
To reward issues found we have a bug bounty going up to $25,000 with an additional reward for any findings introduced in this release candidate.
- ⛽ ERC721Consecutive: Efficient batch minting of NFTs (EIP-2309)
- ⛽ Optimizations in ERC20Votes, ERC721Votes: Best case cost reduced to 50%!
- 🆕 Ownable2Step: An extension of Ownable with 2-step transferOwnership
- 🆕 Math.log2/log10: Integer logarithm
- 💯 ERC4626 decimals changes: Remove decimals from on-chain calculations
- ⛽ Many small optimizations
See the changelog for all the release details.
v4.7.3
Breaking changes
ECDSA:recover(bytes32,bytes)andtryRecover(bytes32,bytes)no longer accept compact signatures to prevent malleability. Compact signature support remains available usingrecover(bytes32,bytes32,bytes32)andtryRecover(bytes32,bytes32,bytes32).
v4.7.2
GovernorVotesQuorumFraction. For more information visit the security advisories (1, 2, 3).
GovernorVotesQuorumFraction: Fixed quorum updates so they do not affect past proposals that failed due to lack of quorum. (#3561)ERC165Checker: Added protection against large returndata. (#3587)LibArbitrumL2,CrossChainEnabledArbitrumL2: Fixed detection of cross-chain calls for EOAs. Previously, calls from EOAs would be classified as cross-chain calls. (#3578)
v4.7.1
v4.7.0
TimelockController: Migrate_callto_executeand allow inheritance and overriding similar toGovernor. (#3317)CrossChainEnabledPolygonChild: replace therequirestatement with the custom errorNotCrossChainCall. (#3380)ERC20FlashMint: Add customizable flash fee receiver. (#3327)ERC4626: add an extension ofERC20that implements the ERC4626 Tokenized Vault Standard. (#3171)SafeERC20: addsafePermitas mitigation against phantom permit functions. (#3280)Math: add amulDivfunction that can round the result either up or down. (#3171)Math: Add asqrtfunction to compute square roots of integers, rounding either up or down. (#3242)Strings: add a new overloaded functiontoHexStringthat converts anaddresswith fixed length of 20 bytes to its not checksummed ASCIIstringhexadecimal representation. (#3403)EnumerableMap: add newUintToUintMapmap type. (#3338)EnumerableMap: add newBytes32ToUintMapmap type. (#3416)SafeCast: add support for many more types, using procedural code generation. (#3245)MerkleProof: addmultiProofVerifyto prove multiple values are part of a Merkle tree. (#3276)MerkleProof: add calldata versions of the functions to avoid copying input arrays to memory and save gas. (#3200)ERC721,ERC1155: simplified revert reasons. (#3254, (#3438))ERC721: removed redundant require statement. (#3434)PaymentSplitter: addreleasablegetters. (#3350)Initializable: refactored implementation of modifiers for easier understanding. (#3450)Proxies: remove runtime check of ERC1967 storage slots. (#3455)
Breaking changes
Initializable: functions decorated with the modifierreinitializer(1)may no longer invoke each other.
v4.7.0-rc.0
This prerelease is now available for open review! Let us know your feedback and if you find any security issues.
We have a bug bounty with rewards of up to USD $25,000 and a special POAP for submitting a valid issue.
See the announcement for more details.
v4.6.0
crosschain: Add a new set of contracts for cross-chain applications.CrossChainEnabledis a base contract with instantiations for several chains and bridges, andAccessControlCrossChainis an extension of access control that allows cross-chain operation. (#3183)AccessControl: add a virtual_checkRole(bytes32)function that can be overridden to alter theonlyRolemodifier behavior. (#3137)EnumerableMap: add newAddressToUintMapmap type. (#3150)EnumerableMap: add newBytes32ToBytes32Mapmap type. (#3192)ERC20FlashMint: support infinite allowance when paying back a flash loan. (#3226)ERC20Wrapper: thedecimals()function now tries to fetch the value from the underlying token instance. If that calls revert, then the default value is used. (#3259)draft-ERC20Permit: replaceimmutablewithconstantfor_PERMIT_TYPEHASHsince thekeccak256of string literals is treated specially and the hash is evaluated at compile time. (#3196)ERC1155: Add a_afterTokenTransferhook for improved extensibility. (#3166)ERC1155URIStorage: add a new extension that implements a_setURIbehavior similar to ERC721's_setTokenURI. (#3210)DoubleEndedQueue: a new data structure that supports efficient push and pop to both front and back, useful for FIFO and LIFO queues. (#3153)Governor: improved security ofonlyGovernancemodifier when using an external executor contract (e.g. a timelock) that can operate without necessarily going through the governance protocol. (#3147)Governor: Add a way to parameterize votes. This can be used to implement voting systems such as fractionalized voting, ERC721 based voting, or any number of other systems. Theparamsargument added to_countVotemethod, and included in the newly added_getVotesmethod, can be used by counting and voting modules respectively for such purposes. (#3043)Governor: rewording of revert reason for consistency. (#3275)Governor: fix an inconsistency in data locations that could lead to invalid bytecode being produced. (#3295)Governor: ImplementIERC721ReceiverandIERC1155Receiverto improve token custody by governors. (#3230)TimelockController: ImplementIERC721ReceiverandIERC1155Receiverto improve token custody by timelocks. (#3230)TimelockController: Add a separate canceller role for the ability to cancel. (#3165)Initializable: add a reinitializer modifier that enables the initialization of new modules, added to already initialized contracts through upgradeability. (#3232)Initializable: add an Initialized event that tracks initialized version numbers. (#3294)ERC2981: makeroyaltiInfopublic to allow super call in overrides. (#3305)
Upgradeability notice
TimelockController: (Action needed) The upgrade from <4.6 to >=4.6 introduces a newCANCELLER_ROLEthat requires set up to be assignable. After the upgrade, only addresses with this role will have the ability to cancel. Proposers will no longer be able to cancel. Assigning cancellers can be done by an admin (including the timelock itself) once the role admin is set up. To do this, we recommend upgrading to theTimelockControllerWith46MigrationUpgradeablecontract and then calling themigrateTo46function.
Breaking changes
Governor: Adds internal virtual_getVotesmethod that must be implemented; this is a breaking change for existing concrete extensions toGovernor. To fix this on an existing voting module extension, renamegetVotesto_getVotesand add abytes memoryargument. (#3043)Governor: Addsparamsparameter to internal virtual_countVotemethod; this is a breaking change for existing concrete extensions toGovernor. To fix this on an existing counting module extension, add abytes memoryargument to_countVote. (#3043)Governor: Does not emitVoteCastevent when params data is non-empty; instead emitsVoteCastWithParamsevent. To fix this on an integration that consumes theVoteCastevent, also fetch/monitorVoteCastWithParamsevents. (#3043)Votes: The internal virtual function_getVotingUnitswas madeview(which was accidentally missing). Any overrides should now be updated so they areviewas well.