-
Notifications
You must be signed in to change notification settings - Fork 32
Add ERC7984Rwa extension
#160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
56 commits
Select commit
Hold shift + click to select a range
61729c2
Init `ERC7984Rwa` extension.
james-toussaint 639e5a2
Fix typos
james-toussaint 85546dd
Add agent role
james-toussaint 0029ad7
Update spelling
james-toussaint b2174ea
Add pausable & roles tests
james-toussaint ce8286c
Add mint/burn/force/transfer tests
james-toussaint 6cb98a5
Remove tmp freezable
james-toussaint 46d6800
Merge remote-tracking branch 'origin/master' into feature/confidentia…
james-toussaint d2562aa
Name ERC7984Rwa
james-toussaint f58c1f3
Name confidential
james-toussaint 76b21ae
Move RWA test
james-toussaint 127aff5
Test with & without proof
james-toussaint 84af687
Rwa mock uses freezable
james-toussaint b0d5ffa
Check transferred amounts in tests
james-toussaint 6fb7f97
Bypass hardhat fhevm behaviour
james-toussaint 0cb0208
Add support interface test
james-toussaint 90ebfa0
Add should not force transfer if anyone
james-toussaint c5d07fe
Move some modifiers to mock
james-toussaint e484066
Update doc
james-toussaint 4ec0bd1
Merge remote-tracking branch 'origin/master' into feature/confidentia…
james-toussaint 64c6c9b
Swap items in doc
james-toussaint 1ad9ccd
Add suggestions
james-toussaint 628d143
Remove lint annotation
james-toussaint 0b1d87c
Update test name
james-toussaint b6b6827
Add restriction to ERC7984Rwa
james-toussaint 3185336
Move gates
james-toussaint b4f8c03
Remove ExpectedPause error
james-toussaint 28973a2
Rename block functions
james-toussaint 0facae5
Rename fixture
james-toussaint 2d0ef0e
Force transfer with all update effects
james-toussaint 5451777
Update set frozen doc
james-toussaint 3065002
Refactor event checks in freezable tests
james-toussaint 35b0771
Merge remote-tracking branch 'origin' into feature/confidential-rwa
james-toussaint 4f04222
Use agent for operations
james-toussaint 57eee95
Natively bypass freezable and restricted extensions on force transfer
james-toussaint e94961e
Expose single rwa interface
james-toussaint ea6214c
Fix force transfer receiver blocked test
james-toussaint a32468f
Remove freezer check since internal parent
james-toussaint c27150c
Add pre check and post hook on transfers
james-toussaint 7710529
Add access control tests
james-toussaint f884a5e
Remove dup test
james-toussaint ed2b6fe
Improve pre update wording in freezable
james-toussaint 1de3990
Rename to preTransferCheck
james-toussaint 7c0172d
Remove restricted interface
james-toussaint f43ceaa
Check acl & order functions
james-toussaint b3af5e9
Remove pre and post
james-toussaint 299d0fe
More explicit wording
james-toussaint 3da562e
Remove freezer from mock and fix typo
james-toussaint ac8b822
Update RWA (#214)
arr00 0eecd53
update tests
arr00 10a664c
review feedback
arr00 0cb3508
up
arr00 9d1fe1b
Nit
james-toussaint 341060e
inherit interface and inline selector calc
arr00 f773fd8
Lint import order
james-toussaint 09c2789
Precompute force transfer signatures
james-toussaint File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| 'openzeppelin-confidential-contracts': minor | ||
| --- | ||
|
|
||
| `ERC7984Rwa`: An extension of `ERC7984`, that supports confidential Real World Assets (RWAs). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| pragma solidity ^0.8.24; | ||
|
|
||
| import {externalEuint64, euint64} from "@fhevm/solidity/lib/FHE.sol"; | ||
| import {IERC165} from "@openzeppelin/contracts/interfaces/IERC165.sol"; | ||
| import {IERC7984} from "./IERC7984.sol"; | ||
|
|
||
| /// @dev Interface for confidential RWA contracts. | ||
| interface IERC7984Rwa is IERC7984, IERC165 { | ||
| /// @dev Returns true if the contract is paused, false otherwise. | ||
| function paused() external view returns (bool); | ||
| /// @dev Returns whether an account is allowed to interact with the token. | ||
| function isUserAllowed(address account) external view returns (bool); | ||
| /// @dev Returns the confidential frozen balance of an account. | ||
| function confidentialFrozen(address account) external view returns (euint64); | ||
| /// @dev Returns the confidential available (unfrozen) balance of an account. Up to {IERC7984-confidentialBalanceOf}. | ||
| function confidentialAvailable(address account) external returns (euint64); | ||
| /// @dev Pauses contract. | ||
| function pause() external; | ||
| /// @dev Unpauses contract. | ||
| function unpause() external; | ||
| /// @dev Blocks a user account. | ||
| function blockUser(address account) external; | ||
| /// @dev Unblocks a user account. | ||
| function unblockUser(address account) external; | ||
| /// @dev Sets confidential amount of token for an account as frozen with proof. | ||
| function setConfidentialFrozen( | ||
| address account, | ||
| externalEuint64 encryptedAmount, | ||
| bytes calldata inputProof | ||
| ) external; | ||
| /// @dev Sets confidential amount of token for an account as frozen. | ||
| function setConfidentialFrozen(address account, euint64 encryptedAmount) external; | ||
| /// @dev Mints confidential amount of tokens to account with proof. | ||
| function confidentialMint( | ||
| address to, | ||
| externalEuint64 encryptedAmount, | ||
| bytes calldata inputProof | ||
| ) external returns (euint64); | ||
| /// @dev Mints confidential amount of tokens to account. | ||
| function confidentialMint(address to, euint64 encryptedAmount) external returns (euint64); | ||
| /// @dev Burns confidential amount of tokens from account with proof. | ||
| function confidentialBurn( | ||
| address account, | ||
| externalEuint64 encryptedAmount, | ||
| bytes calldata inputProof | ||
| ) external returns (euint64); | ||
| /// @dev Burns confidential amount of tokens from account. | ||
| function confidentialBurn(address account, euint64 encryptedAmount) external returns (euint64); | ||
| /// @dev Forces transfer of confidential amount of tokens from account to account with proof by skipping compliance checks. | ||
| function forceConfidentialTransferFrom( | ||
| address from, | ||
| address to, | ||
| externalEuint64 encryptedAmount, | ||
| bytes calldata inputProof | ||
| ) external returns (euint64); | ||
| /// @dev Forces transfer of confidential amount of tokens from account to account by skipping compliance checks. | ||
| function forceConfidentialTransferFrom( | ||
| address from, | ||
| address to, | ||
| euint64 encryptedAmount | ||
| ) external returns (euint64); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| // SPDX-License-Identifier: MIT | ||
|
|
||
| pragma solidity ^0.8.24; | ||
|
|
||
| import {FHE, euint64} from "@fhevm/solidity/lib/FHE.sol"; | ||
| import {ERC7984Rwa} from "./../../token/ERC7984/extensions/ERC7984Rwa.sol"; | ||
| import {HandleAccessManager} from "./../../utils/HandleAccessManager.sol"; | ||
| import {ERC7984Mock} from "./ERC7984Mock.sol"; | ||
|
|
||
| // solhint-disable func-name-mixedcase | ||
| contract ERC7984RwaMock is ERC7984Rwa, ERC7984Mock, HandleAccessManager { | ||
| constructor( | ||
| string memory name, | ||
| string memory symbol, | ||
| string memory tokenUri, | ||
| address admin | ||
| ) ERC7984Rwa(admin) ERC7984Mock(name, symbol, tokenUri) {} | ||
|
|
||
| function _update( | ||
| address from, | ||
| address to, | ||
| euint64 amount | ||
| ) internal virtual override(ERC7984Mock, ERC7984Rwa) returns (euint64) { | ||
| return super._update(from, to, amount); | ||
| } | ||
|
|
||
| function _validateHandleAllowance(bytes32 handle) internal view override onlyAgent {} | ||
|
|
||
| // solhint-disable-next-line func-name-mixedcase | ||
| function $_setConfidentialFrozen(address account, uint64 amount) public virtual { | ||
| _setConfidentialFrozen(account, FHE.asEuint64(amount)); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.