Skip to content

Commit a5516c9

Browse files
authored
Merge pull request #37 from CMTA/dev
Rule Engine 2.0.0
2 parents ddaaaae + d9777ce commit a5516c9

File tree

270 files changed

+17085
-3772
lines changed

Some content is hidden

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

270 files changed

+17085
-3772
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
Please follow [https://changelog.md/](https://changelog.md/) conventions.
44

5+
## v2.0.0
6+
7+
- Implement the new architecture for the RuleEngine, with ValidationRule and OperationRule
8+
- Add the rule ConditionalTransfer as an Operation rule
9+
- Add the rule Blacklist as a Validation rule
10+
- Whitelist and blacklist rules share a part of their code.
11+
- Upgrade the library CMTAT to the version [v2.4.0](https://github.com/CMTA/CMTAT/releases/tag/v2.4.0)
12+
- Fix a minor bug when rules are deleted with clearRules
13+
514
## v1.0.3 - 20231122
615

716
- Upgrade the library CMTAT to the version [v2.3.1](https://github.com/CMTA/CMTAT/releases/tag/v2.3.1)

README.md

Lines changed: 42 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,40 @@
33
# RuleEngine
44

55
This repository includes the RuleEngine contract for the [CMTAT](https://github.com/CMTA/CMTAT) token.
6-
- The CMTAT version used is the version [v2.3.1](https://github.com/CMTA/CMTAT/releases/tag/v2.3.1)
7-
- The OpenZeppelin version used is the version [v5.0.0](https://github.com/OpenZeppelin/openzeppelin-contracts/releases/tag/v5.0.0)
6+
- The CMTAT version used is the version [v2.4.0](https://github.com/CMTA/CMTAT/releases/tag/v2.4.0)
7+
- The OpenZeppelin version used is the version [v5.0.2](https://github.com/OpenZeppelin/openzeppelin-contracts/releases/tag/v5.0.2)
88

99
The CMTAT contracts and the OpenZeppelin library are included as a submodule of the present repository.
1010

11+
## How to include it
12+
13+
While it has been designed for the CMTAT, the ruleEngine can be used with others contracts to apply restriction on transfer.
14+
15+
For that, the only thing to do is to import in your contract the interface `IRuleEngine` which declares the function `operateOnTransfer`
16+
17+
This interface can be found in [CMTAT/contracts/interfaces/engine/IRuleEngine.sol](https://github.com/CMTA/CMTAT/blob/23a1e59f913d079d0c09d32fafbd95ab2d426093/contracts/interfaces/engine/IRuleEngine.sol)
18+
19+
Before each transfer, your contract must call the function `operateOnTransfer` which is the entrypoint for the RuleEngine.
20+
21+
## Schema
22+
23+
![Engine-RuleEngine.drawio](./doc/schema/Engine-RuleEngine.drawio.png)
24+
25+
26+
27+
## Available Rules
28+
29+
The following rules are available:
30+
31+
| Rule | Type | Description | Doc |
32+
| ------------------------------------------------------------ | -------------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
33+
| [RuleWhitelist](src/rules/validation/RuleWhitelist.sol) | RuleValidation | This rule can be used to restrict transfers from/to only addresses inside a whitelist. | [RuleWhitelist.md](./doc/technical/RuleWhitelist.md)<br />[surya-report](./doc/surya/surya_report/surya_report_RuleWhitelist.sol.md) |
34+
| [RuleBlacklist](src/rules/validation/RuleBlacklist.sol) | RuleValidation | This rule can be used to forbid transfer from/to addresses in the blacklist | [RuleBlacklist.md](./doc/technical/RuleBlacklist.md)<br />[surya-report](./doc/surya/surya_report/surya_report_RuleBlacklist.sol.md) |
35+
| [RuleSanctionList](src/rules/validation/RuleSanctionList.sol) | RuleValidation | The purpose of this contract is to use the oracle contract from Chainalysis to forbid transfer from/to an address included in a sanctions designation (US, EU, or UN). | [RuleSanctionList.md](./doc/technical/RuleSanctionList.md)<br />[surya-report](./doc/surya/surya_report/surya_report_RuleSanctionList.sol.md) |
36+
| [RuleConditionalTransfer](src/rules/operation/RuleConditionalTransfer.sol) | RuleOperation | This page describes a Conditional Transfer implementation. This rule requires that transfers have to be approved before being executed by the token holders. | [RuleConditionalTransfer.md](./doc/technical/RuleConditionalTransfer.md)<br />[surya-report](./doc/surya/surya_report/surya_report_RuleConditionalTransfer.sol.md) |
37+
38+
39+
1140
## Audit
1241

1342
The contracts have been audited by [ABDKConsulting](https://www.abdk.consulting/), a globally recognized firm specialized in smart contracts' security.
@@ -30,21 +59,22 @@ You will find the report performed with [Slither](https://github.com/crytic/slit
3059

3160
| Version | File |
3261
| ------- | ------------------------------------------------------------ |
33-
| v1.0.2 | [v1.0.2-slither-report.md](./doc/audits/tools/v1.0.2-slither-report.md) |
34-
| v1.0.3 | [v1.0.3-slither-report.md](./doc/audits/tools/v1.0.3-slither-report.md) |
62+
| latest | [slither-report.md](./doc/security/audits/tools/slither-report.md) |
63+
| v1.0.2 | [v1.0.2-slither-report.md](./doc/security/audits/archive/v1.0.2-slither-report.md) |
64+
| v1.0.3 | [v1.0.3-slither-report.md](./doc/security/audits/archive/v1.0.3-slither-report.md) |
65+
66+
3567

3668
## Documentation
3769

3870
Here a summary of the main documentation
3971

40-
| Document | Link/Files |
41-
| ----------------------------------- | ------------------------------------------------------ |
42-
| Solidity API Documentation (docgen) | [doc/solidityAPI](./doc/solidityAPI) |
43-
| Technical documentation | [doc/technical](./doc/technical) |
44-
| Toolchain | [doc/TOOLCHAIN.md](./doc/TOOLCHAIN.md) |
45-
| Functionalities | [doc/functionalities.pdf](./doc/functionalities.pdf) |
46-
| Surya report | [doc/surya](./doc/surya) |
47-
| Test (v1.0.2) | [doc/test/v1.0.2/test.pdf](./doc/test/v1.0.2/test.pdf) |
72+
| Document | Link/Files |
73+
| ----------------------- | ---------------------------------------------------- |
74+
| Technical documentation | [doc/technical/general](./doc/technical/general.md) |
75+
| Toolchain | [doc/TOOLCHAIN.md](./doc/TOOLCHAIN.md) |
76+
| Functionalities | [doc/functionalities.pdf](./doc/functionalities.pdf) |
77+
| Surya report | [doc/surya](./doc/surya/) |
4878

4979

5080

@@ -150,21 +180,3 @@ Only RuleEngine with a Whitelist contract
150180
```bash
151181
forge script script/RuleEngineScript.s.sol:RuleEngineScript --rpc-url=$RPC_URL --broadcast --verify -vvv
152182
```
153-
154-
### Local
155-
156-
> This documentation has been written for the version v1.0.2
157-
158-
With Foundry, you [can create a local testnet](https://book.getfoundry.sh/reference/anvil/) node for deploying and testing smart contracts, based on the [Anvil](https://anvil.works/) framework.
159-
160-
On Linux, using the default RPC URL, and Anvil's test private key, run:
161-
162-
Example - Deploy the CMTAT, standalone version
163-
164-
``` bash
165-
export RPC_URL=http://127.0.0.1:8545
166-
export PRIVATE_KEY=<Local Private Key>
167-
forge create CMTAT_BASE --rpc-url=$RPC_URL --private-key=$PRIVATE_KEY --constructor-args 0x0000000000000000000000000000000000000000,ADMIN,"CMTA Token","CMTAT","CMTAT_ISIN","https://cmta.ch",0x0000000000000000000000000000000000000000,"CMTAT_info",5
168-
```
169-
170-
See also the command's [documentation](https://book.getfoundry.sh/reference/forge/deploy-command).

doc/accessControl/.$access-control.drawio.bkp

Lines changed: 0 additions & 1 deletion
This file was deleted.
Binary file not shown.

doc/accessControl/access-control.drawio

Lines changed: 0 additions & 1 deletion
This file was deleted.

doc/codelist.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@
44
55
Here the list of codes used by the different rules
66

7-
| Contract | Constant name | Value |
8-
| ---------------- | --------------------------------- | ----- |
9-
| All | NO_ERROR | 0 |
10-
| RuleWhitelist | CODE_ADDRESS_FROM_NOT_WHITELISTED | 21 |
11-
| RuleWhitelist | CODE_ADDRESS_TO_NOT_WHITELISTED | 22 |
12-
| RuleSanctionList | CODE_ADDRESS_FROM_IS_SANCTIONED | 31 |
13-
| RuleSanctionList | CODE_ADDRESS_TO_IS_SANCTIONED | 32 |
7+
| Contract | Constant name | Value |
8+
| ----------------------- | ---------------------------------- | ----- |
9+
| All | TRANSFER_OK (from CMTAT) | 0 |
10+
| RuleWhitelist | CODE_ADDRESS_FROM_NOT_WHITELISTED | 21 |
11+
| RuleWhitelist | CODE_ADDRESS_TO_NOT_WHITELISTED | 22 |
12+
| RuleSanctionList | CODE_ADDRESS_FROM_IS_SANCTIONED | 31 |
13+
| RuleSanctionList | CODE_ADDRESS_TO_IS_SANCTIONED | 32 |
14+
| RuleBlacklist | CODE_ADDRESS_FROM_IS_BLACKLISTED | 41 |
15+
| RuleBlacklist | CODE_ADDRESS_TO_IS_BLACKLISTED | 42 |
16+
| RuleConditionalTransfer | CODE_TRANSFER_REQUEST_NOT_APPROVED | 51 |
1417

1518

1619

20+
Warning: the CMTAT already uses the code 0-4 and the code 5-9 should be left free to allow further additions in the CMTAT

doc/functionalities.odt

523 Bytes
Binary file not shown.
204 KB
Loading

0 commit comments

Comments
 (0)