@openzeppelin/confidential-contracts 0.3.1 → 0.4.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/README.md +36 -7
  2. package/build/contracts/BatcherConfidential.json +544 -0
  3. package/build/contracts/CheckpointsConfidential.json +2 -2
  4. package/build/contracts/ERC7984.json +16 -0
  5. package/build/contracts/ERC7984ERC20Wrapper.json +93 -9
  6. package/build/contracts/ERC7984Freezable.json +16 -0
  7. package/build/contracts/ERC7984ObserverAccess.json +16 -0
  8. package/build/contracts/ERC7984Omnibus.json +16 -0
  9. package/build/contracts/ERC7984Restricted.json +35 -19
  10. package/build/contracts/ERC7984Rwa.json +35 -19
  11. package/build/contracts/ERC7984Utils.json +2 -2
  12. package/build/contracts/ERC7984Votes.json +32 -0
  13. package/build/contracts/FHESafeMath.json +2 -2
  14. package/build/contracts/HandleAccessManager.json +16 -0
  15. package/build/contracts/IERC7984ERC20Wrapper.json +659 -0
  16. package/build/contracts/IERC7984Rwa.json +19 -19
  17. package/build/contracts/VestingWalletConfidentialFactory.json +16 -0
  18. package/build/contracts/VotesConfidential.json +16 -0
  19. package/finance/BatcherConfidential.sol +450 -0
  20. package/finance/VestingWalletConfidential.sol +3 -3
  21. package/governance/utils/VotesConfidential.sol +5 -4
  22. package/interfaces/IERC7984ERC20Wrapper.sol +62 -0
  23. package/interfaces/IERC7984Receiver.sol +4 -2
  24. package/interfaces/IERC7984Rwa.sol +2 -2
  25. package/package.json +4 -4
  26. package/token/ERC7984/extensions/ERC7984ERC20Wrapper.sol +81 -55
  27. package/token/ERC7984/extensions/ERC7984Freezable.sol +4 -5
  28. package/token/ERC7984/extensions/ERC7984ObserverAccess.sol +3 -3
  29. package/token/ERC7984/extensions/ERC7984Restricted.sol +8 -8
  30. package/token/ERC7984/extensions/ERC7984Rwa.sol +5 -7
  31. package/token/ERC7984/extensions/ERC7984Votes.sol +2 -2
  32. package/utils/FHESafeMath.sol +2 -2
  33. package/utils/HandleAccessManager.sol +8 -7
  34. package/utils/structs/CheckpointsConfidential.sol +2 -2
  35. package/build/contracts/Checkpoints.json +0 -16
  36. package/utils/structs/temporary-Checkpoints.sol +0 -835
@@ -1,5 +1,5 @@
1
1
  // SPDX-License-Identifier: MIT
2
- // OpenZeppelin Confidential Contracts (last updated v0.3.1) (token/ERC7984/extensions/ERC7984ERC20Wrapper.sol)
2
+ // OpenZeppelin Confidential Contracts (last updated v0.4.0-rc.0) (token/ERC7984/extensions/ERC7984ERC20Wrapper.sol)
3
3
 
4
4
  pragma solidity ^0.8.27;
5
5
 
@@ -8,7 +8,10 @@ import {IERC1363Receiver} from "@openzeppelin/contracts/interfaces/IERC1363Recei
8
8
  import {IERC20} from "@openzeppelin/contracts/interfaces/IERC20.sol";
9
9
  import {IERC20Metadata} from "@openzeppelin/contracts/interfaces/IERC20Metadata.sol";
10
10
  import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
11
+ import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
11
12
  import {SafeCast} from "@openzeppelin/contracts/utils/math/SafeCast.sol";
13
+ import {IERC7984} from "../../../interfaces/IERC7984.sol";
14
+ import {IERC7984ERC20Wrapper} from "../../../interfaces/IERC7984ERC20Wrapper.sol";
12
15
  import {ERC7984} from "./../ERC7984.sol";
13
16
 
14
17
  /**
@@ -19,17 +22,14 @@ import {ERC7984} from "./../ERC7984.sol";
19
22
  * WARNING: Minting assumes the full amount of the underlying token transfer has been received, hence some non-standard
20
23
  * tokens such as fee-on-transfer or other deflationary-type tokens are not supported by this wrapper.
21
24
  */
22
- abstract contract ERC7984ERC20Wrapper is ERC7984, IERC1363Receiver {
25
+ abstract contract ERC7984ERC20Wrapper is ERC7984, IERC7984ERC20Wrapper, IERC1363Receiver {
23
26
  IERC20 private immutable _underlying;
24
27
  uint8 private immutable _decimals;
25
28
  uint256 private immutable _rate;
26
29
 
27
- mapping(euint64 unwrapAmount => address recipient) private _unwrapRequests;
30
+ mapping(bytes32 unwrapRequestId => address recipient) private _unwrapRequests;
28
31
 
29
- event UnwrapRequested(address indexed receiver, euint64 amount);
30
- event UnwrapFinalized(address indexed receiver, euint64 encryptedAmount, uint64 cleartextAmount);
31
-
32
- error InvalidUnwrapRequest(euint64 amount);
32
+ error InvalidUnwrapRequest(bytes32 unwrapRequestId);
33
33
  error ERC7984TotalSupplyOverflow();
34
34
 
35
35
  constructor(IERC20 underlying_) {
@@ -49,7 +49,7 @@ abstract contract ERC7984ERC20Wrapper is ERC7984, IERC1363Receiver {
49
49
  /**
50
50
  * @dev `ERC1363` callback function which wraps tokens to the address specified in `data` or
51
51
  * the address `from` (if no address is specified in `data`). This function refunds any excess tokens
52
- * sent beyond the nearest multiple of {rate} to `from`. See {wrap} from more details on wrapping tokens.
52
+ * sent beyond the nearest multiple of {rate} to `from`. See {wrap} for more details on wrapping tokens.
53
53
  */
54
54
  function onTransferReceived(
55
55
  address /*operator*/,
@@ -58,7 +58,7 @@ abstract contract ERC7984ERC20Wrapper is ERC7984, IERC1363Receiver {
58
58
  bytes calldata data
59
59
  ) public virtual returns (bytes4) {
60
60
  // check caller is the token contract
61
- require(address(underlying()) == msg.sender, ERC7984UnauthorizedCaller(msg.sender));
61
+ require(underlying() == msg.sender, ERC7984UnauthorizedCaller(msg.sender));
62
62
 
63
63
  // mint confidential token
64
64
  address to = data.length < 20 ? from : address(bytes20(data));
@@ -66,88 +66,100 @@ abstract contract ERC7984ERC20Wrapper is ERC7984, IERC1363Receiver {
66
66
 
67
67
  // transfer excess back to the sender
68
68
  uint256 excess = amount % rate();
69
- if (excess > 0) SafeERC20.safeTransfer(underlying(), from, excess);
69
+ if (excess > 0) SafeERC20.safeTransfer(IERC20(underlying()), from, excess);
70
70
 
71
71
  // return magic value
72
72
  return IERC1363Receiver.onTransferReceived.selector;
73
73
  }
74
74
 
75
75
  /**
76
- * @dev Wraps amount `amount` of the underlying token into a confidential token and sends it to
77
- * `to`. Tokens are exchanged at a fixed rate specified by {rate} such that `amount / rate()` confidential
78
- * tokens are sent. Amount transferred in is rounded down to the nearest multiple of {rate}.
76
+ * @dev See {IERC7984ERC20Wrapper-wrap}. Tokens are exchanged at a fixed rate specified by {rate} such that
77
+ * `amount / rate()` confidential tokens are sent. The amount transferred in is rounded down to the nearest
78
+ * multiple of {rate}.
79
+ *
80
+ * Returns the amount of wrapped token sent.
79
81
  */
80
- function wrap(address to, uint256 amount) public virtual {
82
+ function wrap(address to, uint256 amount) public virtual override returns (euint64) {
81
83
  // take ownership of the tokens
82
- SafeERC20.safeTransferFrom(underlying(), msg.sender, address(this), amount - (amount % rate()));
84
+ SafeERC20.safeTransferFrom(IERC20(underlying()), msg.sender, address(this), amount - (amount % rate()));
83
85
 
84
86
  // mint confidential token
85
- _mint(to, FHE.asEuint64(SafeCast.toUint64(amount / rate())));
87
+ euint64 wrappedAmountSent = _mint(to, FHE.asEuint64(SafeCast.toUint64(amount / rate())));
88
+ FHE.allowTransient(wrappedAmountSent, msg.sender);
89
+
90
+ return wrappedAmountSent;
86
91
  }
87
92
 
88
- /**
89
- * @dev Unwraps tokens from `from` and sends the underlying tokens to `to`. The caller must be `from`
90
- * or be an approved operator for `from`. `amount * rate()` underlying tokens are sent to `to`.
91
- *
92
- * NOTE: The unwrap request created by this function must be finalized by calling {finalizeUnwrap}.
93
- * NOTE: The caller *must* already be approved by ACL for the given `amount`.
94
- */
95
- function unwrap(address from, address to, euint64 amount) public virtual {
93
+ /// @dev Unwrap without passing an input proof. See {unwrap-address-address-bytes32-bytes} for more details.
94
+ function unwrap(address from, address to, euint64 amount) public virtual returns (bytes32) {
96
95
  require(FHE.isAllowed(amount, msg.sender), ERC7984UnauthorizedUseOfEncryptedAmount(amount, msg.sender));
97
- _unwrap(from, to, amount);
96
+ return _unwrap(from, to, amount);
98
97
  }
99
98
 
100
99
  /**
101
- * @dev Variant of {unwrap} that passes an `inputProof` which approves the caller for the `encryptedAmount`
102
- * in the ACL.
100
+ * @dev See {IERC7984ERC20Wrapper-unwrap}. `amount * rate()` underlying tokens are sent to `to`.
101
+ *
102
+ * NOTE: The unwrap request created by this function must be finalized by calling {finalizeUnwrap}.
103
103
  */
104
104
  function unwrap(
105
105
  address from,
106
106
  address to,
107
107
  externalEuint64 encryptedAmount,
108
108
  bytes calldata inputProof
109
- ) public virtual {
110
- _unwrap(from, to, FHE.fromExternal(encryptedAmount, inputProof));
109
+ ) public virtual returns (bytes32) {
110
+ return _unwrap(from, to, FHE.fromExternal(encryptedAmount, inputProof));
111
111
  }
112
112
 
113
- /// @dev Fills an unwrap request for a given cipher-text `burntAmount` with the `cleartextAmount` and `decryptionProof`.
113
+ /// @inheritdoc IERC7984ERC20Wrapper
114
114
  function finalizeUnwrap(
115
- euint64 burntAmount,
116
- uint64 burntAmountCleartext,
115
+ bytes32 unwrapRequestId,
116
+ uint64 unwrapAmountCleartext,
117
117
  bytes calldata decryptionProof
118
118
  ) public virtual {
119
- address to = _unwrapRequests[burntAmount];
120
- require(to != address(0), InvalidUnwrapRequest(burntAmount));
121
- delete _unwrapRequests[burntAmount];
119
+ address to = unwrapRequester(unwrapRequestId);
120
+ require(to != address(0), InvalidUnwrapRequest(unwrapRequestId));
121
+
122
+ euint64 unwrapAmount_ = unwrapAmount(unwrapRequestId);
123
+ delete _unwrapRequests[unwrapRequestId];
122
124
 
123
125
  bytes32[] memory handles = new bytes32[](1);
124
- handles[0] = euint64.unwrap(burntAmount);
126
+ handles[0] = euint64.unwrap(unwrapAmount_);
125
127
 
126
- bytes memory cleartexts = abi.encode(burntAmountCleartext);
128
+ bytes memory cleartexts = abi.encode(unwrapAmountCleartext);
127
129
 
128
130
  FHE.checkSignatures(handles, cleartexts, decryptionProof);
129
131
 
130
- SafeERC20.safeTransfer(underlying(), to, burntAmountCleartext * rate());
132
+ SafeERC20.safeTransfer(IERC20(underlying()), to, unwrapAmountCleartext * rate());
131
133
 
132
- emit UnwrapFinalized(to, burntAmount, burntAmountCleartext);
134
+ emit UnwrapFinalized(to, unwrapRequestId, unwrapAmount_, unwrapAmountCleartext);
133
135
  }
134
136
 
135
137
  /// @inheritdoc ERC7984
136
- function decimals() public view virtual override returns (uint8) {
138
+ function decimals() public view virtual override(IERC7984, ERC7984) returns (uint8) {
137
139
  return _decimals;
138
140
  }
139
141
 
140
- /**
141
- * @dev Returns the rate at which the underlying token is converted to the wrapped token.
142
- * For example, if the `rate` is 1000, then 1000 units of the underlying token equal 1 unit of the wrapped token.
143
- */
142
+ /// @inheritdoc IERC7984ERC20Wrapper
144
143
  function rate() public view virtual returns (uint256) {
145
144
  return _rate;
146
145
  }
147
146
 
148
- /// @dev Returns the address of the underlying ERC-20 token that is being wrapped.
149
- function underlying() public view returns (IERC20) {
150
- return _underlying;
147
+ /// @inheritdoc IERC7984ERC20Wrapper
148
+ function underlying() public view virtual override returns (address) {
149
+ return address(_underlying);
150
+ }
151
+
152
+ /// @inheritdoc IERC7984ERC20Wrapper
153
+ function unwrapAmount(bytes32 unwrapRequestId) public view virtual returns (euint64) {
154
+ return euint64.wrap(unwrapRequestId);
155
+ }
156
+
157
+ /// @inheritdoc IERC165
158
+ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC7984) returns (bool) {
159
+ return
160
+ interfaceId == type(IERC7984ERC20Wrapper).interfaceId ||
161
+ interfaceId == type(IERC1363Receiver).interfaceId ||
162
+ super.supportsInterface(interfaceId);
151
163
  }
152
164
 
153
165
  /**
@@ -159,7 +171,7 @@ abstract contract ERC7984ERC20Wrapper is ERC7984, IERC1363Receiver {
159
171
  * on {finalizeUnwrap}.
160
172
  */
161
173
  function inferredTotalSupply() public view virtual returns (uint256) {
162
- return underlying().balanceOf(address(this)) / rate();
174
+ return IERC20(underlying()).balanceOf(address(this)) / rate();
163
175
  }
164
176
 
165
177
  /// @dev Returns the maximum total supply of wrapped tokens supported by the encrypted datatype.
@@ -167,6 +179,14 @@ abstract contract ERC7984ERC20Wrapper is ERC7984, IERC1363Receiver {
167
179
  return type(uint64).max;
168
180
  }
169
181
 
182
+ /**
183
+ * @dev Get the address that has a pending unwrap request for the given `unwrapAmount`. Returns `address(0)` if no pending
184
+ * unwrap request for the amount `unwrapAmount` exists.
185
+ */
186
+ function unwrapRequester(bytes32 unwrapRequestId) public view virtual returns (address) {
187
+ return _unwrapRequests[unwrapRequestId];
188
+ }
189
+
170
190
  /**
171
191
  * @dev This function must revert if the new {confidentialTotalSupply} is invalid (overflow occurred).
172
192
  *
@@ -188,19 +208,25 @@ abstract contract ERC7984ERC20Wrapper is ERC7984, IERC1363Receiver {
188
208
  return super._update(from, to, amount);
189
209
  }
190
210
 
191
- /// @dev Internal logic for handling the creation of unwrap requests.
192
- function _unwrap(address from, address to, euint64 amount) internal virtual {
211
+ /// @dev Internal logic for handling the creation of unwrap requests. Returns the unwrap request id.
212
+ function _unwrap(address from, address to, euint64 amount) internal virtual returns (bytes32) {
193
213
  require(to != address(0), ERC7984InvalidReceiver(to));
194
214
  require(from == msg.sender || isOperator(from, msg.sender), ERC7984UnauthorizedSpender(from, msg.sender));
195
215
 
196
216
  // try to burn, see how much we actually got
197
- euint64 burntAmount = _burn(from, amount);
198
- FHE.makePubliclyDecryptable(burntAmount);
217
+ euint64 unwrapAmount_ = _burn(from, amount);
218
+ FHE.makePubliclyDecryptable(unwrapAmount_);
219
+
220
+ assert(unwrapRequester(euint64.unwrap(unwrapAmount_)) == address(0));
199
221
 
200
- assert(_unwrapRequests[burntAmount] == address(0));
201
- _unwrapRequests[burntAmount] = to;
222
+ // WARNING: Directly using the cipher-text as the unwrap request id assumes that
223
+ // cipher-texts are unique--this holds here but is not always true. Be cautious when assuming
224
+ // cipher-text uniqueness.
225
+ bytes32 unwrapRequestId = euint64.unwrap(unwrapAmount_);
226
+ _unwrapRequests[unwrapRequestId] = to;
202
227
 
203
- emit UnwrapRequested(to, burntAmount);
228
+ emit UnwrapRequested(to, unwrapRequestId, unwrapAmount_);
229
+ return unwrapRequestId;
204
230
  }
205
231
 
206
232
  /**
@@ -1,5 +1,5 @@
1
1
  // SPDX-License-Identifier: MIT
2
- // OpenZeppelin Confidential Contracts (last updated v0.3.0) (token/ERC7984/extensions/ERC7984Freezable.sol)
2
+ // OpenZeppelin Confidential Contracts (last updated v0.4.0-rc.0) (token/ERC7984/extensions/ERC7984Freezable.sol)
3
3
 
4
4
  pragma solidity ^0.8.27;
5
5
 
@@ -9,11 +9,10 @@ import {ERC7984} from "../ERC7984.sol";
9
9
 
10
10
  /**
11
11
  * @dev Extension of {ERC7984} that implements a confidential
12
- * freezing mechanism that can be managed by an authorized account with
13
- * {setConfidentialFrozen} functions.
12
+ * freezing mechanism that can be managed by calling the internal function
13
+ * {_setConfidentialFrozen} by an inheriting contract.
14
14
  *
15
- * The freezing mechanism provides the guarantee to the contract owner
16
- * (e.g. a DAO or a well-configured multisig) that a specific confidential
15
+ * The freezing mechanism provides the guarantee that a specific confidential
17
16
  * amount of tokens held by an account won't be transferable until those
18
17
  * tokens are unfrozen.
19
18
  *
@@ -1,5 +1,5 @@
1
1
  // SPDX-License-Identifier: MIT
2
- // OpenZeppelin Confidential Contracts (last updated v0.3.0) (token/ERC7984/extensions/ERC7984ObserverAccess.sol)
2
+ // OpenZeppelin Confidential Contracts (last updated v0.4.0-rc.0) (token/ERC7984/extensions/ERC7984ObserverAccess.sol)
3
3
 
4
4
  pragma solidity ^0.8.27;
5
5
 
@@ -7,8 +7,8 @@ import {FHE, euint64} from "@fhevm/solidity/lib/FHE.sol";
7
7
  import {ERC7984} from "../ERC7984.sol";
8
8
 
9
9
  /**
10
- * @dev Extension of {ERC7984} that allows each account to add a observer who is given
11
- * permanent ACL access to its transfer and balance amounts. A observer can be added or removed at any point in time.
10
+ * @dev Extension of {ERC7984} that allows each account to add an observer who is given
11
+ * permanent ACL access to its transfer and balance amounts. An observer can be added or removed at any point in time.
12
12
  */
13
13
  abstract contract ERC7984ObserverAccess is ERC7984 {
14
14
  mapping(address account => address) private _observers;
@@ -1,5 +1,5 @@
1
1
  // SPDX-License-Identifier: MIT
2
- // OpenZeppelin Confidential Contracts (last updated v0.3.0) (token/ERC7984/extensions/ERC7984Restricted.sol)
2
+ // OpenZeppelin Confidential Contracts (last updated v0.4.0-rc.0) (token/ERC7984/extensions/ERC7984Restricted.sol)
3
3
 
4
4
  pragma solidity ^0.8.27;
5
5
 
@@ -7,11 +7,11 @@ import {ERC7984, euint64} from "../ERC7984.sol";
7
7
 
8
8
  /**
9
9
  * @dev Extension of {ERC7984} that implements user account transfer restrictions through the
10
- * {isUserAllowed} function. Inspired by
10
+ * {canTransact} function. Inspired by
11
11
  * https://github.com/OpenZeppelin/openzeppelin-community-contracts/blob/master/contracts/token/ERC20/extensions/ERC20Restricted.sol.
12
12
  *
13
- * By default, each account has no explicit restriction. The {isUserAllowed} function acts as
14
- * a blocklist. Developers can override {isUserAllowed} to check that `restriction == ALLOWED`
13
+ * By default, each account has no explicit restriction. The {canTransact} function acts as
14
+ * a blocklist. Developers can override {canTransact} to check that `restriction == ALLOWED`
15
15
  * to implement an allowlist.
16
16
  */
17
17
  abstract contract ERC7984Restricted is ERC7984 {
@@ -39,7 +39,7 @@ abstract contract ERC7984Restricted is ERC7984 {
39
39
  *
40
40
  * Default implementation only disallows explicitly BLOCKED accounts (i.e. a blocklist).
41
41
  */
42
- function isUserAllowed(address account) public view virtual returns (bool) {
42
+ function canTransact(address account) public view virtual returns (bool) {
43
43
  return getRestriction(account) != Restriction.BLOCKED; // i.e. DEFAULT && ALLOWED
44
44
  }
45
45
 
@@ -48,8 +48,8 @@ abstract contract ERC7984Restricted is ERC7984 {
48
48
  *
49
49
  * Requirements:
50
50
  *
51
- * * `from` must be allowed to transfer tokens (see {isUserAllowed}).
52
- * * `to` must be allowed to receive tokens (see {isUserAllowed}).
51
+ * * `from` must be allowed to transfer tokens (see {canTransact}).
52
+ * * `to` must be allowed to receive tokens (see {canTransact}).
53
53
  *
54
54
  * The default restriction behavior can be changed (for a pass-through for instance) by overriding
55
55
  * {_checkSenderRestriction} and/or {_checkRecipientRestriction}.
@@ -85,7 +85,7 @@ abstract contract ERC7984Restricted is ERC7984 {
85
85
 
86
86
  /// @dev Checks if a user account is restricted. Reverts with {UserRestricted} if so.
87
87
  function _checkRestriction(address account) internal view virtual {
88
- require(isUserAllowed(account), UserRestricted(account));
88
+ require(canTransact(account), UserRestricted(account));
89
89
  }
90
90
 
91
91
  /**
@@ -1,5 +1,5 @@
1
1
  // SPDX-License-Identifier: MIT
2
- // OpenZeppelin Confidential Contracts (last updated v0.3.0) (token/ERC7984/extensions/ERC7984Rwa.sol)
2
+ // OpenZeppelin Confidential Contracts (last updated v0.4.0-rc.0) (token/ERC7984/extensions/ERC7984Rwa.sol)
3
3
 
4
4
  pragma solidity ^0.8.27;
5
5
 
@@ -204,10 +204,8 @@ abstract contract ERC7984Rwa is IERC7984Rwa, ERC7984Freezable, ERC7984Restricted
204
204
  }
205
205
 
206
206
  /// @inheritdoc ERC7984Restricted
207
- function isUserAllowed(
208
- address account
209
- ) public view virtual override(IERC7984Rwa, ERC7984Restricted) returns (bool) {
210
- return super.isUserAllowed(account);
207
+ function canTransact(address account) public view virtual override(IERC7984Rwa, ERC7984Restricted) returns (bool) {
208
+ return super.canTransact(account);
211
209
  }
212
210
 
213
211
  /// @dev Internal function which updates confidential balances while performing frozen and restriction compliance checks.
@@ -242,7 +240,7 @@ abstract contract ERC7984Rwa is IERC7984Rwa, ERC7984Freezable, ERC7984Restricted
242
240
  /// @dev Private function which checks if the called function is a {forceConfidentialTransferFrom}.
243
241
  function _isForceTransfer() private pure returns (bool) {
244
242
  return
245
- msg.sig == 0x6c9c3c85 || // bytes4(keccak256("forceConfidentialTransferFrom(address,address,bytes32)"))
246
- msg.sig == 0x44fd6e40; // bytes4(keccak256("forceConfidentialTransferFrom(address,address,bytes32,bytes)"))
243
+ msg.sig == 0x6c9c3c85 || // bytes4(keccak256("forceConfidentialTransferFrom(address,address,bytes32,bytes)"))
244
+ msg.sig == 0x44fd6e40; // bytes4(keccak256("forceConfidentialTransferFrom(address,address,bytes32)"))
247
245
  }
248
246
  }
@@ -1,5 +1,5 @@
1
1
  // SPDX-License-Identifier: MIT
2
- // OpenZeppelin Confidential Contracts (last updated v0.3.0) (token/ERC7984/extensions/ERC7984Votes.sol)
2
+ // OpenZeppelin Confidential Contracts (last updated v0.4.0-rc.0) (token/ERC7984/extensions/ERC7984Votes.sol)
3
3
  pragma solidity ^0.8.27;
4
4
 
5
5
  import {euint64} from "@fhevm/solidity/lib/FHE.sol";
@@ -10,7 +10,7 @@ import {ERC7984} from "./../ERC7984.sol";
10
10
  * @dev Extension of {ERC7984} supporting confidential votes tracking and delegation.
11
11
  *
12
12
  * The amount of confidential voting units an account has is equal to the balance of
13
- * that account. Voing power is taken into account when an account delegates votes to itself or to another
13
+ * that account. Voting power is taken into account when an account delegates votes to itself or to another
14
14
  * account.
15
15
  */
16
16
  abstract contract ERC7984Votes is ERC7984, VotesConfidential {
@@ -1,5 +1,5 @@
1
1
  // SPDX-License-Identifier: MIT
2
- // OpenZeppelin Confidential Contracts (last updated v0.3.0) (utils/FHESafeMath.sol)
2
+ // OpenZeppelin Confidential Contracts (last updated v0.4.0-rc.0) (utils/FHESafeMath.sol)
3
3
  pragma solidity ^0.8.24;
4
4
 
5
5
  import {FHE, ebool, euint64} from "@fhevm/solidity/lib/FHE.sol";
@@ -9,7 +9,7 @@ import {FHE, ebool, euint64} from "@fhevm/solidity/lib/FHE.sol";
9
9
  * to handle potential overflows in FHE operations.
10
10
  *
11
11
  * NOTE: An uninitialized `euint64` value (equivalent to euint64.wrap(bytes32(0))) is evaluated as 0.
12
- * This library will may return an uninitialized value if all inputs are uninitialized.
12
+ * This library may return an uninitialized value if all inputs are uninitialized.
13
13
  */
14
14
  library FHESafeMath {
15
15
  /**
@@ -1,19 +1,20 @@
1
1
  // SPDX-License-Identifier: MIT
2
- // OpenZeppelin Confidential Contracts (last updated v0.2.0) (utils/HandleAccessManager.sol)
3
- pragma solidity ^0.8.24;
2
+ // OpenZeppelin Confidential Contracts (last updated v0.4.0-rc.0) (utils/HandleAccessManager.sol)
3
+ pragma solidity ^0.8.26;
4
4
 
5
5
  import {Impl} from "@fhevm/solidity/lib/Impl.sol";
6
6
 
7
7
  abstract contract HandleAccessManager {
8
+ error HandleAccessManagerNotAllowed(bytes32 handle, address account);
9
+
8
10
  /**
9
11
  * @dev Get handle access for the given handle `handle`. Access will be given to the
10
12
  * account `account` with the given persistence flag.
11
13
  *
12
- * NOTE: This function call is gated by `msg.sender` and validated by the
13
- * {_validateHandleAllowance} function.
14
+ * NOTE: This function call is validated by {_validateHandleAllowance}.
14
15
  */
15
16
  function getHandleAllowance(bytes32 handle, address account, bool persistent) public virtual {
16
- _validateHandleAllowance(handle);
17
+ require(_validateHandleAllowance(handle), HandleAccessManagerNotAllowed(handle, account));
17
18
  if (persistent) {
18
19
  Impl.allow(handle, account);
19
20
  } else {
@@ -22,8 +23,8 @@ abstract contract HandleAccessManager {
22
23
  }
23
24
 
24
25
  /**
25
- * @dev Unimplemented function that must revert if the message sender is not allowed to call
26
+ * @dev Unimplemented function that must return true if the message sender is allowed to call
26
27
  * {getHandleAllowance} for the given handle.
27
28
  */
28
- function _validateHandleAllowance(bytes32 handle) internal view virtual;
29
+ function _validateHandleAllowance(bytes32 handle) internal view virtual returns (bool);
29
30
  }
@@ -1,12 +1,12 @@
1
1
  // SPDX-License-Identifier: MIT
2
- // OpenZeppelin Confidential Contracts (last updated v0.2.0) (utils/structs/CheckpointsConfidential.sol)
2
+ // OpenZeppelin Confidential Contracts (last updated v0.4.0-rc.0) (utils/structs/CheckpointsConfidential.sol)
3
3
  // This file was procedurally generated from scripts/generate/templates/CheckpointsConfidential.js.
4
4
 
5
5
  pragma solidity ^0.8.24;
6
6
 
7
7
  import {euint32, euint64} from "@fhevm/solidity/lib/FHE.sol";
8
8
  import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";
9
- import {Checkpoints} from "./temporary-Checkpoints.sol";
9
+ import {Checkpoints} from "@openzeppelin/contracts/utils/structs/Checkpoints.sol";
10
10
 
11
11
  /**
12
12
  * @dev This library defines the `Trace*` struct, for checkpointing values as they change at different points in
@@ -1,16 +0,0 @@
1
- {
2
- "_format": "hh-sol-artifact-1",
3
- "contractName": "Checkpoints",
4
- "sourceName": "contracts/utils/structs/temporary-Checkpoints.sol",
5
- "abi": [
6
- {
7
- "inputs": [],
8
- "name": "CheckpointUnorderedInsertion",
9
- "type": "error"
10
- }
11
- ],
12
- "bytecode": "0x60556032600b8282823980515f1a607314602657634e487b7160e01b5f525f60045260245ffd5b305f52607381538281f3fe730000000000000000000000000000000000000000301460806040525f5ffdfea26469706673582212207ac2b5a91bbe8d5c2edc50cd6b8ca65dda1c06dc3baad1b46f94f6cc976f083064736f6c634300081d0033",
13
- "deployedBytecode": "0x730000000000000000000000000000000000000000301460806040525f5ffdfea26469706673582212207ac2b5a91bbe8d5c2edc50cd6b8ca65dda1c06dc3baad1b46f94f6cc976f083064736f6c634300081d0033",
14
- "linkReferences": {},
15
- "deployedLinkReferences": {}
16
- }