diff --git a/.changeset/three-parents-argue.md b/.changeset/three-parents-argue.md new file mode 100644 index 00000000000..95517262fb9 --- /dev/null +++ b/.changeset/three-parents-argue.md @@ -0,0 +1,5 @@ +--- +'openzeppelin-solidity': patch +--- + +Add `_reentrancyGuardStorageSlot()` to `ReentrancyGuardTransient` as a `pure virtual` function to allow slot overrides for diamond-compatible modular usage. Related to #5681. diff --git a/contracts/utils/ReentrancyGuardTransient.sol b/contracts/utils/ReentrancyGuardTransient.sol index a1318c86f3c..9863b333f16 100644 --- a/contracts/utils/ReentrancyGuardTransient.sol +++ b/contracts/utils/ReentrancyGuardTransient.sol @@ -44,11 +44,11 @@ abstract contract ReentrancyGuardTransient { } // Any calls to nonReentrant after this point will fail - REENTRANCY_GUARD_STORAGE.asBoolean().tstore(true); + _reentrancyGuardStorageSlot().asBoolean().tstore(true); } function _nonReentrantAfter() private { - REENTRANCY_GUARD_STORAGE.asBoolean().tstore(false); + _reentrancyGuardStorageSlot().asBoolean().tstore(false); } /** @@ -56,6 +56,10 @@ abstract contract ReentrancyGuardTransient { * `nonReentrant` function in the call stack. */ function _reentrancyGuardEntered() internal view returns (bool) { - return REENTRANCY_GUARD_STORAGE.asBoolean().tload(); + return _reentrancyGuardStorageSlot().asBoolean().tload(); + } + + function _reentrancyGuardStorageSlot() internal pure virtual returns (bytes32) { + return REENTRANCY_GUARD_STORAGE; } }