Skip to content

Commit 9aaabd4

Browse files
KyrylRaritkulovaArvolear
authored
Migrated to OZ v5 (#6)
* Migrated to OZ v5 * integrated with new versions of solarity and openzeppelin * updated package-lock * switched to custom errors * cleaned up * refactored error naming * renamed claimTopicKey to contextKey, claimTopic to handleTopic * fixed typos * fixed inits in example * returned accidentally missing part * updated examples folder * Added erc721 (#7) * created transaction context for both nft and token * added NFT F initial version * updated naming * updated dependencies * fixed typo * updated readme * added example of NFTF contract * review fixes * handle topic -> handler topic * updated package-lock files * fixed typos * created IAssetF interface for Context and common errors * added onlyInitializing to init functions * updated minimal solidity version to ^0.8.21 * added storage buckets to the modules * updated the architecture diagram * updated version to 0.3.0 * added tokenURI to NFTF * updated diagram to capture ERC20 and ERC721 * updated dependency * fixed diagram * few fixes * moved TokenF and NFTF contracts from core folder * updated diagram * calldata -> memory in public functions * TransferLimitsModule -> ERC20TransferLimitsModule * EquityNFT -> LandNFT * added ERC721TransferLimitsModule * added LandERC721TransferLimitsModule to examples * added INFTF to supported interfaces * updated scripts * added AbstractAssetF contract * order consistency fix * fixed ERC721TransferLimitsModule formula * cleaned up ERC721TransferLimitsModule test * review fix * updated diagram * fix --------- Co-authored-by: aritkulova <[email protected]> Co-authored-by: Artem Chystiakov <[email protected]>
1 parent 705de68 commit 9aaabd4

File tree

76 files changed

+8672
-22414
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+8672
-22414
lines changed

.env.example

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1 @@
1-
# Deployer private key
2-
PRIVATE_KEY=YOUR PRIVATE KEY
3-
4-
# RPC Endpoints
5-
INFURA_KEY=INFURA PROJECT ID
6-
7-
# Additional keys
8-
ETHERSCAN_KEY=ETHERSCAN API KEY
9-
BSCSCAN_KEY=BSCSCAN API KEY
10-
POLYGONSCAN_KEY=POLYGONSCAN API KEY
11-
AVALANCHE_KEY=AVALANCHE API KEY
121
COINMARKETCAP_KEY=COINMARKETCAP API KEY

.solhint.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
"func-visibility": "off",
1010
"max-states-count": "off",
1111
"not-rely-on-time": "off",
12-
"compiler-version": "off"
12+
"compiler-version": "off",
13+
"func-name-mixedcase": "off",
14+
"no-inline-assembly": "off"
1315
}
1416
}

README.md

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,29 @@
55

66
Bring Real World Assets (RWA) on-chain via flexible tokenization framework - TokenF.
77

8-
!["TokenF Architecture"](https://github.com/dl-tokenf/core-contracts/assets/47551140/9e912d07-bc4d-407d-bf25-859e0da40f32)
8+
TokenF and NFTF architecture:
9+
10+
!["AssetF Architecture"](https://github.com/user-attachments/assets/5594c199-db9b-4aa3-b16a-5b464621311c)
11+
12+
Built with [Solarity](https://github.com/dl-solarity), [OpenZeppelin](https://github.com/OpenZeppelin/openzeppelin-contracts), and aspiration to perfection.
913

10-
Built with [Solarity](https://github.com/dl-solarity), [Openzeppelin](https://github.com/OpenZeppelin/openzeppelin-contracts), and aspiration to perfection.
1114

1215
## Application
1316

14-
TokenF is an on-chain framework that enables development, management, and deployment of permissioned ERC-20-compatible assets on EVM networks. TokenF enables custom rules to be configured for RWA tokens, providing flexible KYC/AML and regulatory compliance checks for the users to abide during interaction with the smart contracts.
17+
TokenF is an on-chain framework that enables development, management, and deployment of permissioned ERC-20-compatible and ERC-721-compatible assets on EVM networks. TokenF enables custom rules to be configured for RWA tokens, providing flexible KYC/AML and regulatory compliance checks for the users to abide during interaction with the smart contracts.
1518

16-
TokenF is built with certain levels of abstraction in mind:
19+
TokenF is built with certain levels of abstraction in mind:
1720

1821
- ERC-2535 Diamond beating heart that allows extensibility and upgradeability.
1922
- Support of custom compliance modules to be plugged in the TokenF core.
2023
- Rich configuration of check/hooks/behavior with imagination being the only limit.
2124

22-
| **What TokenF Is ✅** | **What TokenF Is Not ❌** |
23-
| :-----------------------------------------: | :------------------------------: |
24-
| On-chain tokenization framework | Fullstack tokenization framework |
25-
| Smart contracts to configure RWA behavior | RWA launchpad/RWA consulting set |
26-
| Reimagined and enhanced ERC-3643 alternative | Yet another ERC-3643 copy |
25+
| **What TokenF Is ✅** | **What TokenF Is Not ❌** |
26+
| :-----------------------------------------: | :---------------------------------: |
27+
| On-chain tokenization framework | Fullstack tokenization framework |
28+
| Smart contracts to configure RWA behavior | RWA launchpad/RWA consulting set |
29+
| Built from scratch ERC-3643 alternative | Yet another ERC-3643 copy |
30+
| Support of both ERC-20 and ERC-721 standards | Currently does not support ERC-1155 |
2731

2832
> [!NOTE]
2933
> TokenF is at the early stage of development, many breaking changes are foreseen.
@@ -41,13 +45,20 @@ npm install @tokenf/contracts
4145
You will then be able to start using TokenF:
4246

4347
```solidity
44-
pragma solidity ^0.8.20;
48+
pragma solidity ^0.8.21;
4549
46-
import {TokenF} from "@tokenf/contracts/core/TokenF.sol";
50+
import {TokenF} from "@tokenf/contracts/TokenF.sol";
51+
import {NFTF} from "@tokenf/contracts/NFTF.sol";
4752
4853
contract EquityToken is TokenF {
4954
. . .
5055
}
56+
57+
// or
58+
59+
contract LandNft is NFTF {
60+
. . .
61+
}
5162
```
5263

5364
> [!TIP]

contracts/AbstractAssetF.sol

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.21;
3+
4+
import {Diamond} from "@solarity/solidity-lib/diamond/Diamond.sol";
5+
6+
import {IAssetF} from "./interfaces/IAssetF.sol";
7+
import {IKYCCompliance} from "./interfaces/core/IKYCCompliance.sol";
8+
import {IRegulatoryCompliance} from "./interfaces/core/IRegulatoryCompliance.sol";
9+
10+
import {AgentAccessControl} from "./core/AgentAccessControl.sol";
11+
import {RegulatoryComplianceStorage} from "./storages/core/RegulatoryComplianceStorage.sol";
12+
import {KYCComplianceStorage} from "./storages/core/KYCComplianceStorage.sol";
13+
14+
abstract contract AbstractAssetF is IAssetF, Diamond, AgentAccessControl {
15+
bytes4 public constant RECOVERY_SELECTOR = this.recovery.selector;
16+
17+
function __AbstractAssetF_init(
18+
address regulatoryCompliance_,
19+
address kycCompliance_,
20+
bytes memory initRegulatory_,
21+
bytes memory initKYC_
22+
) internal virtual onlyInitializing {
23+
bytes4[] memory rComplianceSelectors_ = new bytes4[](6);
24+
rComplianceSelectors_[0] = IRegulatoryCompliance.addRegulatoryModules.selector;
25+
rComplianceSelectors_[1] = IRegulatoryCompliance.removeRegulatoryModules.selector;
26+
rComplianceSelectors_[2] = IRegulatoryCompliance.transferred.selector;
27+
rComplianceSelectors_[3] = IRegulatoryCompliance.canTransfer.selector;
28+
rComplianceSelectors_[4] = RegulatoryComplianceStorage.getRegulatoryModules.selector;
29+
rComplianceSelectors_[5] = RegulatoryComplianceStorage.getRegulatoryModulesCount.selector;
30+
31+
bytes4[] memory kycComplianceSelectors_ = new bytes4[](5);
32+
kycComplianceSelectors_[0] = IKYCCompliance.addKYCModules.selector;
33+
kycComplianceSelectors_[1] = IKYCCompliance.removeKYCModules.selector;
34+
kycComplianceSelectors_[2] = IKYCCompliance.isKYCed.selector;
35+
kycComplianceSelectors_[3] = KYCComplianceStorage.getKYCModules.selector;
36+
kycComplianceSelectors_[4] = KYCComplianceStorage.getKYCModulesCount.selector;
37+
38+
Facet[] memory facets_ = new Facet[](2);
39+
facets_[0] = Facet(regulatoryCompliance_, FacetAction.Add, rComplianceSelectors_);
40+
facets_[1] = Facet(kycCompliance_, FacetAction.Add, kycComplianceSelectors_);
41+
42+
_diamondCut(facets_, address(0), "");
43+
_diamondCut(new Facet[](0), regulatoryCompliance_, initRegulatory_);
44+
_diamondCut(new Facet[](0), kycCompliance_, initKYC_);
45+
}
46+
47+
/// @inheritdoc IAssetF
48+
function diamondCut(
49+
Facet[] memory modules_
50+
) public virtual override onlyRole(_diamondCutRole()) {
51+
diamondCut(modules_, address(0), "");
52+
}
53+
54+
/// @inheritdoc IAssetF
55+
function diamondCut(
56+
Facet[] memory modules_,
57+
address initModule_,
58+
bytes memory initData_
59+
) public virtual override onlyRole(_diamondCutRole()) {
60+
_diamondCut(modules_, initModule_, initData_);
61+
}
62+
63+
function _mintRole() internal view virtual returns (bytes32) {
64+
return AGENT_ROLE;
65+
}
66+
67+
function _burnRole() internal view virtual returns (bytes32) {
68+
return AGENT_ROLE;
69+
}
70+
71+
function _forcedTransferRole() internal view virtual returns (bytes32) {
72+
return AGENT_ROLE;
73+
}
74+
75+
function _recoveryRole() internal view virtual returns (bytes32) {
76+
return AGENT_ROLE;
77+
}
78+
79+
function _diamondCutRole() internal view virtual returns (bytes32) {
80+
return AGENT_ROLE;
81+
}
82+
}

0 commit comments

Comments
 (0)