Skip to content

Commit 9130516

Browse files
frangioernestognw
authored andcommitted
Move security directory contents to utils (#4551)
1 parent a93b213 commit 9130516

File tree

13 files changed

+25
-34
lines changed

13 files changed

+25
-34
lines changed

.changeset/smooth-cougars-jump.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'openzeppelin-solidity': major
3+
---
4+
5+
`ReentrancyGuard`, `Pausable`: Moved to `utils` directory.

certora/harnesses/PausableHarness.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity ^0.8.20;
33

4-
import {Pausable} from "../patched/security/Pausable.sol";
4+
import {Pausable} from "../patched/utils/Pausable.sol";
55

66
contract PausableHarness is Pausable {
77
function pause() external {

contracts/mocks/PausableMock.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
pragma solidity ^0.8.20;
44

5-
import {Pausable} from "../security/Pausable.sol";
5+
import {Pausable} from "../utils/Pausable.sol";
66

77
contract PausableMock is Pausable {
88
bool public drasticMeasureTaken;

contracts/mocks/ReentrancyMock.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
pragma solidity ^0.8.20;
44

5-
import {ReentrancyGuard} from "../security/ReentrancyGuard.sol";
5+
import {ReentrancyGuard} from "../utils/ReentrancyGuard.sol";
66
import {ReentrancyAttack} from "./ReentrancyAttack.sol";
77

88
contract ReentrancyMock is ReentrancyGuard {

contracts/security/README.adoc

-17
This file was deleted.

contracts/token/ERC1155/extensions/ERC1155Pausable.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
pragma solidity ^0.8.20;
55

66
import {ERC1155} from "../ERC1155.sol";
7-
import {Pausable} from "../../../security/Pausable.sol";
7+
import {Pausable} from "../../../utils/Pausable.sol";
88

99
/**
1010
* @dev ERC1155 token with pausable token transfers, minting and burning.

contracts/token/ERC20/extensions/ERC20Pausable.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
pragma solidity ^0.8.20;
55

66
import {ERC20} from "../ERC20.sol";
7-
import {Pausable} from "../../../security/Pausable.sol";
7+
import {Pausable} from "../../../utils/Pausable.sol";
88

99
/**
1010
* @dev ERC20 token with pausable token transfers, minting and burning.

contracts/token/ERC721/extensions/ERC721Pausable.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
pragma solidity ^0.8.20;
55

66
import {ERC721} from "../ERC721.sol";
7-
import {Pausable} from "../../../security/Pausable.sol";
7+
import {Pausable} from "../../../utils/Pausable.sol";
88

99
/**
1010
* @dev ERC721 token with pausable token transfers, minting and burning.
File renamed without changes.

contracts/utils/README.adoc

+14-11
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,20 @@ NOTE: This document is better viewed at https://docs.openzeppelin.com/contracts/
55

66
Miscellaneous contracts and libraries containing utility functions you can use to improve security, work with new data types, or safely use low-level primitives.
77

8-
The {Address}, {Arrays}, {Base64} and {Strings} libraries provide more operations related to these native data types, while {SafeCast} adds ways to safely convert between the different signed and unsigned numeric types.
9-
{Multicall} provides a function to batch together multiple calls in a single external call.
10-
11-
For new data types:
12-
13-
* {EnumerableMap}: like Solidity's https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`] type, but with key-value _enumeration_: this will let you know how many entries a mapping has, and iterate over them (which is not possible with `mapping`).
14-
* {EnumerableSet}: like {EnumerableMap}, but for https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets]. Can be used to store privileged accounts, issued IDs, etc.
8+
* {ReentrancyGuard}: A modifier that can prevent reentrancy during certain functions.
9+
* {Pausable}: A common emergency response mechanism that can pause functionality while a remediation is pending.
10+
* {SafeCast}: Checked downcasting functions to avoid silent truncation.
11+
* {Math}, {SignedMath}: Implementation of various arithmetic functions.
12+
* {Multicall}: Simple way to batch together multiple calls in a single external call.
13+
* {Create2}: Wrapper around the https://blog.openzeppelin.com/getting-the-most-out-of-create2/[`CREATE2` EVM opcode] for safe use without having to deal with low-level assembly.
14+
* {EnumerableMap}: A type like Solidity's https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`], but with key-value _enumeration_: this will let you know how many entries a mapping has, and iterate over them (which is not possible with `mapping`).
15+
* {EnumerableSet}: Like {EnumerableMap}, but for https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets]. Can be used to store privileged accounts, issued IDs, etc.
1516

1617
[NOTE]
1718
====
1819
Because Solidity does not support generic types, {EnumerableMap} and {EnumerableSet} are specialized to a limited number of key-value types.
19-
20-
As of v3.0, {EnumerableMap} supports `uint256 -> address` (`UintToAddressMap`), and {EnumerableSet} supports `address` and `uint256` (`AddressSet` and `UintSet`).
2120
====
2221

23-
Finally, {Create2} contains all necessary utilities to safely use the https://blog.openzeppelin.com/getting-the-most-out-of-create2/[`CREATE2` EVM opcode], without having to deal with low-level assembly.
24-
2522
== Math
2623

2724
{{Math}}
@@ -42,6 +39,12 @@ Finally, {Create2} contains all necessary utilities to safely use the https://bl
4239

4340
{{EIP712}}
4441

42+
== Security
43+
44+
{{ReentrancyGuard}}
45+
46+
{{Pausable}}
47+
4548
== Introspection
4649

4750
This set of interfaces and contracts deal with https://en.wikipedia.org/wiki/Type_introspection[type introspection] of contracts, that is, examining which functions can be called on them. This is usually referred to as a contract's _interface_.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)