Releases: OpenZeppelin/openzeppelin-contracts-upgradeable
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.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.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.
v4.5.2
v4.5.1
v4.5.0
ERC2981: add implementation of the royalty standard, and the respective extensions forERC721andERC1155. (#3012)GovernorTimelockControl: improve thestate()function to have it reflect cases where a proposal has been canceled directly on the timelock. (#2977)- Preset contracts are now deprecated in favor of Contracts Wizard. (#2986)
Governor: add a relay function to help recover assets sent to a governor that is not its own executor (e.g. when using a timelock). (#2926)GovernorPreventLateQuorum: add new module to ensure a minimum voting duration is available after the quorum is reached. (#2973)ERC721: improved revert reason when transferring from wrong owner. (#2975)Votes: Added a base contract for vote tracking with delegation. (#2944)ERC721Votes: Added an extension of ERC721 enabled with vote tracking and delegation. (#2944)ERC2771Context: use immutable storage to store the forwarder address, no longer an issue since Solidity >=0.8.8 allows reading immutable variables in the constructor. (#2917)Base64: add a library to parse bytes into base64 strings usingencode(bytes memory)function, and provide examples to show how to use to build URL-safetokenURIs. (#2884)ERC20: reduce allowance before triggering transfer. (#3056)ERC20: do not update allowance ontransferFromwhen allowance istype(uint256).max. (#3085)ERC20: add a_spendAllowanceinternal function. (#3170)ERC20Burnable: do not update allowance onburnFromwhen allowance istype(uint256).max. (#3170)ERC777: do not update allowance ontransferFromwhen allowance istype(uint256).max. (#3085)ERC777: add a_spendAllowanceinternal function. (#3170)SignedMath: a new signed version of the Math library withmax,min, andaverage. (#2686)SignedMath: add aabs(int256)method that returns the unsigned absolute value of a signed value. (#2984)ERC1967Upgrade: Refactor the secure upgrade to useERC1822instead of the previous rollback mechanism. This reduces code complexity and attack surface with similar security guarantees. (#3021)UUPSUpgradeable: AddERC1822compliance to support the updated secure upgrade mechanism. (#3021)- Some more functions have been made virtual to customize them via overrides. In many cases this will not imply that other functions in the contract will automatically adapt to the overridden definitions. People who wish to override should consult the source code to understand the impact and if they need to override any additional functions to achieve the desired behavior.
Breaking changes
ERC1967Upgrade: The function_upgradeToAndCallSecurewas renamed to_upgradeToAndCallUUPS, along with the change in security mechanism described above.Address: The Solidity pragma is increased from^0.8.0to^0.8.1. This is required by theaccount.code.lengthsyntax that replaces inline assembly. This may require users to bump their compiler version from0.8.0to0.8.1or later. Note that other parts of the code already include stricter requirements.
v4.4.2
GovernorCompatibilityBravo: Fix error in the encoding of calldata for proposals submitted through the compatibility interface with explicit signatures. (#3100)