@openzeppelin/confidential-contracts 0.2.0-rc.2 → 0.3.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.
- package/build/contracts/Checkpoints.json +2 -2
- package/build/contracts/CheckpointsConfidential.json +3 -9
- package/build/contracts/{ConfidentialFungibleToken.json → ERC7984.json} +28 -33
- package/build/contracts/{ConfidentialFungibleTokenERC20Wrapper.json → ERC7984ERC20Wrapper.json} +34 -39
- package/build/contracts/ERC7984Freezable.json +666 -0
- package/build/contracts/ERC7984ObserverAccess.json +676 -0
- package/build/contracts/ERC7984Omnibus.json +994 -0
- package/build/contracts/ERC7984Restricted.json +677 -0
- package/build/contracts/ERC7984Rwa.json +1370 -0
- package/build/contracts/{ConfidentialFungibleTokenUtils.json → ERC7984Utils.json} +4 -4
- package/build/contracts/{ConfidentialFungibleTokenVotes.json → ERC7984Votes.json} +99 -81
- package/build/contracts/{TFHESafeMath.json → FHESafeMath.json} +4 -4
- package/build/contracts/HandleAccessManager.json +34 -0
- package/build/contracts/{IConfidentialFungibleToken.json → IERC7984.json} +15 -15
- package/build/contracts/{IConfidentialFungibleTokenReceiver.json → IERC7984Receiver.json} +2 -2
- package/build/contracts/IERC7984Rwa.json +797 -0
- package/build/contracts/VestingWalletCliffConfidential.json +3 -3
- package/build/contracts/VestingWalletConfidential.json +3 -3
- package/build/contracts/VestingWalletConfidentialFactory.json +18 -153
- package/build/contracts/VotesConfidential.json +23 -0
- package/finance/ERC7821WithExecutor.sol +2 -2
- package/finance/VestingWalletCliffConfidential.sol +15 -4
- package/finance/VestingWalletConfidential.sol +32 -20
- package/finance/VestingWalletConfidentialFactory.sol +34 -123
- package/governance/utils/VotesConfidential.sol +18 -4
- package/interfaces/{IConfidentialFungibleToken.sol → IERC7984.sol} +6 -6
- package/interfaces/{IConfidentialFungibleTokenReceiver.sol → IERC7984Receiver.sol} +3 -3
- package/interfaces/IERC7984Rwa.sol +64 -0
- package/package.json +4 -4
- package/token/{ConfidentialFungibleToken.sol → ERC7984/ERC7984.sol} +73 -84
- package/token/{extensions/ConfidentialFungibleTokenERC20Wrapper.sol → ERC7984/extensions/ERC7984ERC20Wrapper.sol} +36 -27
- package/token/ERC7984/extensions/ERC7984Freezable.sol +66 -0
- package/token/ERC7984/extensions/ERC7984ObserverAccess.sol +63 -0
- package/token/ERC7984/extensions/ERC7984Omnibus.sol +209 -0
- package/token/ERC7984/extensions/ERC7984Restricted.sol +118 -0
- package/token/ERC7984/extensions/ERC7984Rwa.sol +236 -0
- package/token/ERC7984/extensions/ERC7984Votes.sol +31 -0
- package/token/{utils/ConfidentialFungibleTokenUtils.sol → ERC7984/utils/ERC7984Utils.sol} +12 -12
- package/utils/FHESafeMath.sol +72 -0
- package/utils/HandleAccessManager.sol +29 -0
- package/utils/structs/CheckpointsConfidential.sol +1 -6
- package/utils/structs/temporary-Checkpoints.sol +2 -2
- package/token/extensions/ConfidentialFungibleTokenVotes.sol +0 -29
- package/utils/TFHESafeMath.sol +0 -37
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// OpenZeppelin Confidential Contracts (last updated v0.3.0-rc.0) (utils/FHESafeMath.sol)
|
|
3
|
+
pragma solidity ^0.8.24;
|
|
4
|
+
|
|
5
|
+
import {FHE, ebool, euint64} from "@fhevm/solidity/lib/FHE.sol";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @dev Library providing safe arithmetic operations for encrypted values
|
|
9
|
+
* to handle potential overflows in FHE operations.
|
|
10
|
+
*/
|
|
11
|
+
library FHESafeMath {
|
|
12
|
+
/**
|
|
13
|
+
* @dev Try to increase the encrypted value `oldValue` by `delta`. If the operation is successful,
|
|
14
|
+
* `success` will be true and `updated` will be the new value. Otherwise, `success` will be false
|
|
15
|
+
* and `updated` will be the original value.
|
|
16
|
+
*/
|
|
17
|
+
function tryIncrease(euint64 oldValue, euint64 delta) internal returns (ebool success, euint64 updated) {
|
|
18
|
+
if (!FHE.isInitialized(oldValue)) {
|
|
19
|
+
return (FHE.asEbool(true), delta);
|
|
20
|
+
}
|
|
21
|
+
euint64 newValue = FHE.add(oldValue, delta);
|
|
22
|
+
success = FHE.ge(newValue, oldValue);
|
|
23
|
+
updated = FHE.select(success, newValue, oldValue);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @dev Try to decrease the encrypted value `oldValue` by `delta`. If the operation is successful,
|
|
28
|
+
* `success` will be true and `updated` will be the new value. Otherwise, `success` will be false
|
|
29
|
+
* and `updated` will be the original value.
|
|
30
|
+
*/
|
|
31
|
+
function tryDecrease(euint64 oldValue, euint64 delta) internal returns (ebool success, euint64 updated) {
|
|
32
|
+
if (!FHE.isInitialized(oldValue)) {
|
|
33
|
+
if (!FHE.isInitialized(delta)) {
|
|
34
|
+
return (FHE.asEbool(true), oldValue);
|
|
35
|
+
}
|
|
36
|
+
return (FHE.eq(oldValue, delta), oldValue);
|
|
37
|
+
}
|
|
38
|
+
success = FHE.ge(oldValue, delta);
|
|
39
|
+
updated = FHE.select(success, FHE.sub(oldValue, delta), oldValue);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @dev Try to add `a` and `b`. If the operation is successful, `success` will be true and `res`
|
|
44
|
+
* will be the sum of `a` and `b`. Otherwise, `success` will be false, and `res` will be 0.
|
|
45
|
+
*/
|
|
46
|
+
function tryAdd(euint64 a, euint64 b) internal returns (ebool success, euint64 res) {
|
|
47
|
+
if (!FHE.isInitialized(a)) {
|
|
48
|
+
return (FHE.asEbool(true), b);
|
|
49
|
+
}
|
|
50
|
+
if (!FHE.isInitialized(b)) {
|
|
51
|
+
return (FHE.asEbool(true), a);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
euint64 sum = FHE.add(a, b);
|
|
55
|
+
success = FHE.ge(sum, a);
|
|
56
|
+
res = FHE.select(success, sum, FHE.asEuint64(0));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* @dev Try to subtract `b` from `a`. If the operation is successful, `success` will be true and `res`
|
|
61
|
+
* will be `a - b`. Otherwise, `success` will be false, and `res` will be 0.
|
|
62
|
+
*/
|
|
63
|
+
function trySub(euint64 a, euint64 b) internal returns (ebool success, euint64 res) {
|
|
64
|
+
if (!FHE.isInitialized(b)) {
|
|
65
|
+
return (FHE.asEbool(true), a);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
euint64 difference = FHE.sub(a, b);
|
|
69
|
+
success = FHE.le(difference, a);
|
|
70
|
+
res = FHE.select(success, difference, FHE.asEuint64(0));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// OpenZeppelin Confidential Contracts (last updated v0.2.0) (utils/HandleAccessManager.sol)
|
|
3
|
+
pragma solidity ^0.8.24;
|
|
4
|
+
|
|
5
|
+
import {Impl} from "@fhevm/solidity/lib/Impl.sol";
|
|
6
|
+
|
|
7
|
+
abstract contract HandleAccessManager {
|
|
8
|
+
/**
|
|
9
|
+
* @dev Get handle access for the given handle `handle`. Access will be given to the
|
|
10
|
+
* account `account` with the given persistence flag.
|
|
11
|
+
*
|
|
12
|
+
* NOTE: This function call is gated by `msg.sender` and validated by the
|
|
13
|
+
* {_validateHandleAllowance} function.
|
|
14
|
+
*/
|
|
15
|
+
function getHandleAllowance(bytes32 handle, address account, bool persistent) public virtual {
|
|
16
|
+
_validateHandleAllowance(handle);
|
|
17
|
+
if (persistent) {
|
|
18
|
+
Impl.allow(handle, account);
|
|
19
|
+
} else {
|
|
20
|
+
Impl.allowTransient(handle, account);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @dev Unimplemented function that must revert if the message sender is not allowed to call
|
|
26
|
+
* {getHandleAllowance} for the given handle.
|
|
27
|
+
*/
|
|
28
|
+
function _validateHandleAllowance(bytes32 handle) internal view virtual;
|
|
29
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
-
// OpenZeppelin Confidential Contracts (last updated v0.2.0
|
|
2
|
+
// OpenZeppelin Confidential Contracts (last updated v0.2.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;
|
|
@@ -18,11 +18,6 @@ import {Checkpoints} from "./temporary-Checkpoints.sol";
|
|
|
18
18
|
library CheckpointsConfidential {
|
|
19
19
|
using Checkpoints for Checkpoints.Trace256;
|
|
20
20
|
|
|
21
|
-
/**
|
|
22
|
-
* @dev A value was attempted to be inserted on a past checkpoint.
|
|
23
|
-
*/
|
|
24
|
-
error CheckpointUnorderedInsertion();
|
|
25
|
-
|
|
26
21
|
struct TraceEuint32 {
|
|
27
22
|
Checkpoints.Trace256 _inner;
|
|
28
23
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
-
// OpenZeppelin Confidential Contracts (last updated v0.
|
|
3
|
-
// OpenZeppelin Contracts (last updated v5.
|
|
2
|
+
// OpenZeppelin Confidential Contracts (last updated v0.3.0-rc.0) (utils/structs/temporary-Checkpoints.sol)
|
|
3
|
+
// OpenZeppelin Contracts (last updated v5.4.0) (utils/structs/Checkpoints.sol)
|
|
4
4
|
// This file was procedurally generated from scripts/generate/templates/Checkpoints.js.
|
|
5
5
|
// WARNING: This file is temporary and will be deleted once the latest version of the file is released in v5.5.0 of @openzeppelin/contracts.
|
|
6
6
|
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
// OpenZeppelin Confidential Contracts (last updated v0.2.0-rc.2) (token/extensions/ConfidentialFungibleTokenVotes.sol)
|
|
3
|
-
pragma solidity ^0.8.27;
|
|
4
|
-
|
|
5
|
-
import {euint64} from "@fhevm/solidity/lib/FHE.sol";
|
|
6
|
-
import {VotesConfidential} from "./../../governance/utils/VotesConfidential.sol";
|
|
7
|
-
import {ConfidentialFungibleToken} from "./../ConfidentialFungibleToken.sol";
|
|
8
|
-
|
|
9
|
-
abstract contract ConfidentialFungibleTokenVotes is ConfidentialFungibleToken, VotesConfidential {
|
|
10
|
-
function confidentialTotalSupply()
|
|
11
|
-
public
|
|
12
|
-
view
|
|
13
|
-
virtual
|
|
14
|
-
override(VotesConfidential, ConfidentialFungibleToken)
|
|
15
|
-
returns (euint64)
|
|
16
|
-
{
|
|
17
|
-
return super.confidentialTotalSupply();
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function _update(address from, address to, euint64 amount) internal virtual override returns (euint64 transferred) {
|
|
21
|
-
transferred = super._update(from, to, amount);
|
|
22
|
-
|
|
23
|
-
_transferVotingUnits(from, to, transferred);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function _getVotingUnits(address account) internal view virtual override returns (euint64) {
|
|
27
|
-
return confidentialBalanceOf(account);
|
|
28
|
-
}
|
|
29
|
-
}
|
package/utils/TFHESafeMath.sol
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
// OpenZeppelin Confidential Contracts (last updated v0.2.0-rc.2) (utils/TFHESafeMath.sol)
|
|
3
|
-
pragma solidity ^0.8.24;
|
|
4
|
-
|
|
5
|
-
import {FHE, ebool, euint64} from "@fhevm/solidity/lib/FHE.sol";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @dev Library providing safe arithmetic operations for encrypted values
|
|
9
|
-
* to handle potential overflows in FHE operations.
|
|
10
|
-
*/
|
|
11
|
-
library TFHESafeMath {
|
|
12
|
-
/**
|
|
13
|
-
* @dev Try to increase the encrypted value `oldValue` by `delta`. If the operation is successful,
|
|
14
|
-
* `success` will be true and `updated` will be the new value. Otherwise, `success` will be false
|
|
15
|
-
* and `updated` will be the original value.
|
|
16
|
-
*/
|
|
17
|
-
function tryIncrease(euint64 oldValue, euint64 delta) internal returns (ebool success, euint64 updated) {
|
|
18
|
-
if (!FHE.isInitialized(oldValue)) {
|
|
19
|
-
success = FHE.asEbool(true);
|
|
20
|
-
updated = delta;
|
|
21
|
-
} else {
|
|
22
|
-
euint64 newValue = FHE.add(oldValue, delta);
|
|
23
|
-
success = FHE.ge(newValue, oldValue);
|
|
24
|
-
updated = FHE.select(success, newValue, oldValue);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* @dev Try to decrease the encrypted value `oldValue` by `delta`. If the operation is successful,
|
|
30
|
-
* `success` will be true and `updated` will be the new value. Otherwise, `success` will be false
|
|
31
|
-
* and `updated` will be the original value.
|
|
32
|
-
*/
|
|
33
|
-
function tryDecrease(euint64 oldValue, euint64 delta) internal returns (ebool success, euint64 updated) {
|
|
34
|
-
success = FHE.ge(oldValue, delta);
|
|
35
|
-
updated = FHE.select(success, FHE.sub(oldValue, delta), oldValue);
|
|
36
|
-
}
|
|
37
|
-
}
|