Skip to content

Commit addf18c

Browse files
committed
docs: update EIP712 upgradeable comment in patch file
Fix misleading comment in EIP712Upgradeable by updating the comment in the transpilation patch file. The previous comment incorrectly referred to immutable values that don't exist in the upgradeable version. The patch file has also been cleaned of trailing whitespace.
1 parent 48bd286 commit addf18c

File tree

2 files changed

+44
-37
lines changed

2 files changed

+44
-37
lines changed

.changeset/smart-teams-raise.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

scripts/upgradeable/upgradeable.patch

Lines changed: 42 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
22
deleted file mode 100644
3-
index 35ad097ff..000000000
3+
index 35ad097f..00000000
44
--- a/.github/ISSUE_TEMPLATE/bug_report.md
55
+++ /dev/null
66
@@ -1,21 +0,0 @@
@@ -26,7 +26,7 @@ index 35ad097ff..000000000
2626
-
2727
-<!-- We will be able to better help if you provide a minimal example that triggers the bug. -->
2828
diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml
29-
index 4018cef29..d343a53d8 100644
29+
index 4018cef2..d343a53d 100644
3030
--- a/.github/ISSUE_TEMPLATE/config.yml
3131
+++ b/.github/ISSUE_TEMPLATE/config.yml
3232
@@ -1,4 +1,8 @@
@@ -40,7 +40,7 @@ index 4018cef29..d343a53d8 100644
4040
about: Ask in the OpenZeppelin Forum
4141
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
4242
deleted file mode 100644
43-
index ff596b0c3..000000000
43+
index ff596b0c..00000000
4444
--- a/.github/ISSUE_TEMPLATE/feature_request.md
4545
+++ /dev/null
4646
@@ -1,14 +0,0 @@
@@ -59,48 +59,48 @@ index ff596b0c3..000000000
5959
-<!-- Make sure that you have reviewed the OpenZeppelin Contracts Contributor Guidelines. -->
6060
-<!-- https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/CONTRIBUTING.md -->
6161
diff --git a/README.md b/README.md
62-
index 60d0a430a..0e4f91a6d 100644
62+
index 60d0a430..0e4f91a6 100644
6363
--- a/README.md
6464
+++ b/README.md
6565
@@ -19,6 +19,9 @@
6666
> [!IMPORTANT]
6767
> OpenZeppelin Contracts uses semantic versioning to communicate backwards compatibility of its API and storage layout. For upgradeable contracts, the storage layout of different major versions should be assumed incompatible, for example, it is unsafe to upgrade from 4.9.3 to 5.0.0. Learn more at [Backwards Compatibility](https://docs.openzeppelin.com/contracts/backwards-compatibility).
68-
68+
6969
++> [!NOTE]
7070
++> You are looking at the upgradeable variant of OpenZeppelin Contracts. Be sure to review the documentation on [Using OpenZeppelin Contracts with Upgrades](https://docs.openzeppelin.com/contracts/upgradeable).
7171
++
7272
## Overview
73-
73+
7474
### Installation
7575
@@ -26,7 +29,7 @@
7676
#### Hardhat (npm)
77-
77+
7878
```
7979
-$ npm install @openzeppelin/contracts
8080
+$ npm install @openzeppelin/contracts-upgradeable
8181
```
82-
82+
8383
#### Foundry (git)
8484
@@ -38,10 +41,10 @@ $ npm install @openzeppelin/contracts
8585
> Foundry installs the latest version initially, but subsequent `forge update` commands will use the `master` branch.
86-
86+
8787
```
8888
-$ forge install OpenZeppelin/openzeppelin-contracts
8989
+$ forge install OpenZeppelin/openzeppelin-contracts-upgradeable
9090
```
91-
91+
9292
-Add `@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/` in `remappings.txt.`
9393
+Add `@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/` in `remappings.txt.`
94-
94+
9595
### Usage
96-
96+
9797
@@ -50,10 +53,11 @@ Once installed, you can use the contracts in the library by importing them:
9898
```solidity
9999
pragma solidity ^0.8.20;
100-
100+
101101
-import {ERC721} from "@openzeppelin/contracts/token/ERC721/ERC721.sol";
102102
+import {ERC721Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol";
103-
103+
104104
-contract MyCollectible is ERC721 {
105105
- constructor() ERC721("MyCollectible", "MCO") {
106106
+contract MyCollectible is ERC721Upgradeable {
@@ -110,15 +110,15 @@ index 60d0a430a..0e4f91a6d 100644
110110
}
111111
```
112112
diff --git a/contracts/package.json b/contracts/package.json
113-
index 3682eadeb..4f870d094 100644
113+
index 70ae73bc..ef659873 100644
114114
--- a/contracts/package.json
115115
+++ b/contracts/package.json
116116
@@ -1,5 +1,5 @@
117117
{
118118
- "name": "@openzeppelin/contracts",
119119
+ "name": "@openzeppelin/contracts-upgradeable",
120120
"description": "Secure Smart Contract library for Solidity",
121-
"version": "5.2.0",
121+
"version": "5.3.0",
122122
"files": [
123123
@@ -13,7 +13,7 @@
124124
},
@@ -140,30 +140,35 @@ index 3682eadeb..4f870d094 100644
140140
+ }
141141
}
142142
diff --git a/contracts/utils/cryptography/EIP712.sol b/contracts/utils/cryptography/EIP712.sol
143-
index bcb67c87a..7195c3bbd 100644
143+
index c39954e3..fe681f87 100644
144144
--- a/contracts/utils/cryptography/EIP712.sol
145145
+++ b/contracts/utils/cryptography/EIP712.sol
146146
@@ -4,7 +4,6 @@
147147
pragma solidity ^0.8.20;
148-
148+
149149
import {MessageHashUtils} from "./MessageHashUtils.sol";
150150
-import {ShortStrings, ShortString} from "../ShortStrings.sol";
151151
import {IERC5267} from "../../interfaces/IERC5267.sol";
152-
152+
153153
/**
154-
@@ -28,30 +27,18 @@ import {IERC5267} from "../../interfaces/IERC5267.sol";
155-
* NOTE: In the upgradeable version of this contract, the cached values will correspond to the address, and the domain
156-
* separator of the implementation contract. This will cause the {_domainSeparatorV4} function to always rebuild the
157-
* separator from the immutable values, which is cheaper than accessing a cached version in cold storage.
154+
@@ -25,33 +24,20 @@ import {IERC5267} from "../../interfaces/IERC5267.sol";
155+
* NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method
156+
* https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].
157+
*
158+
- * NOTE: In the upgradeable version of this contract, the cached values will correspond to the address, and the domain
159+
- * separator of the implementation contract. This will cause the {_domainSeparatorV4} function to always rebuild the
160+
- * separator from the immutable values, which is cheaper than accessing a cached version in cold storage.
158161
- *
159162
- * @custom:oz-upgrades-unsafe-allow state-variable-immutable
163+
+ * NOTE: The upgradeable version of this contract does not use an immutable cache and recomputes the domain separator
164+
+ * each time {_domainSeparatorV4} is called. That is cheaper than accessing a cached version in cold storage.
160165
*/
161166
abstract contract EIP712 is IERC5267 {
162167
- using ShortStrings for *;
163168
-
164169
bytes32 private constant TYPE_HASH =
165170
keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");
166-
171+
167172
- // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to
168173
- // invalidate the cached domain separator if the chain id changes.
169174
- bytes32 private immutable _cachedDomainSeparator;
@@ -174,7 +179,7 @@ index bcb67c87a..7195c3bbd 100644
174179
bytes32 private immutable _hashedName;
175180
+ /// @custom:oz-renamed-from _HASHED_VERSION
176181
bytes32 private immutable _hashedVersion;
177-
182+
178183
- ShortString private immutable _name;
179184
- ShortString private immutable _version;
180185
- // slither-disable-next-line constable-states
@@ -183,10 +188,10 @@ index bcb67c87a..7195c3bbd 100644
183188
- string private _versionFallback;
184189
+ string private _name;
185190
+ string private _version;
186-
191+
187192
/**
188193
* @dev Initializes the domain separator and parameter caches.
189-
@@ -66,29 +53,23 @@ abstract contract EIP712 is IERC5267 {
194+
@@ -66,29 +52,23 @@ abstract contract EIP712 is IERC5267 {
190195
* contract upgrade].
191196
*/
192197
constructor(string memory name, string memory version) {
@@ -205,7 +210,7 @@ index bcb67c87a..7195c3bbd 100644
205210
+ _hashedName = 0;
206211
+ _hashedVersion = 0;
207212
}
208-
213+
209214
/**
210215
* @dev Returns the domain separator for the current chain.
211216
*/
@@ -217,14 +222,14 @@ index bcb67c87a..7195c3bbd 100644
217222
- }
218223
+ return _buildDomainSeparator();
219224
}
220-
225+
221226
function _buildDomainSeparator() private view returns (bytes32) {
222227
- return keccak256(abi.encode(TYPE_HASH, _hashedName, _hashedVersion, block.chainid, address(this)));
223228
+ return keccak256(abi.encode(TYPE_HASH, _EIP712NameHash(), _EIP712VersionHash(), block.chainid, address(this)));
224229
}
225-
230+
226231
/**
227-
@@ -127,6 +108,10 @@ abstract contract EIP712 is IERC5267 {
232+
@@ -125,6 +105,10 @@ abstract contract EIP712 is IERC5267 {
228233
uint256[] memory extensions
229234
)
230235
{
@@ -235,7 +240,7 @@ index bcb67c87a..7195c3bbd 100644
235240
return (
236241
hex"0f", // 01111
237242
_EIP712Name(),
238-
@@ -141,22 +126,62 @@ abstract contract EIP712 is IERC5267 {
243+
@@ -139,22 +123,62 @@ abstract contract EIP712 is IERC5267 {
239244
/**
240245
* @dev The name parameter for the EIP712 domain.
241246
*
@@ -250,7 +255,7 @@ index bcb67c87a..7195c3bbd 100644
250255
+ function _EIP712Name() internal view virtual returns (string memory) {
251256
+ return _name;
252257
}
253-
258+
254259
/**
255260
* @dev The version parameter for the EIP712 domain.
256261
*
@@ -309,7 +314,7 @@ index bcb67c87a..7195c3bbd 100644
309314
}
310315
}
311316
diff --git a/package.json b/package.json
312-
index f9e7d9205..c35020d51 100644
317+
index eeeaf0bc..65581c54 100644
313318
--- a/package.json
314319
+++ b/package.json
315320
@@ -34,7 +34,7 @@
@@ -322,15 +327,15 @@ index f9e7d9205..c35020d51 100644
322327
"keywords": [
323328
"solidity",
324329
diff --git a/remappings.txt b/remappings.txt
325-
index 304d1386a..a1cd63bee 100644
330+
index 304d1386..a1cd63be 100644
326331
--- a/remappings.txt
327332
+++ b/remappings.txt
328333
@@ -1 +1,2 @@
329334
-@openzeppelin/contracts/=contracts/
330335
+@openzeppelin/contracts-upgradeable/=contracts/
331336
+@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/
332337
diff --git a/test/utils/cryptography/EIP712.test.js b/test/utils/cryptography/EIP712.test.js
333-
index 2b6e7fa97..268e0d29d 100644
338+
index 2b6e7fa9..268e0d29 100644
334339
--- a/test/utils/cryptography/EIP712.test.js
335340
+++ b/test/utils/cryptography/EIP712.test.js
336341
@@ -47,27 +47,6 @@ describe('EIP712', function () {
@@ -359,5 +364,5 @@ index 2b6e7fa97..268e0d29d 100644
359364
- });
360365
- }
361366
});
362-
367+
363368
it('hash digest', async function () {

0 commit comments

Comments
 (0)