Skip to content

Commit

Permalink
Merge pull request #42 from CMTA/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
rya-sge authored Jun 11, 2024
2 parents a5516c9 + ec029bd commit 061f26c
Show file tree
Hide file tree
Showing 177 changed files with 7,939 additions and 5,132 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ node_modules/
broadcast/
lib/
out/
docOut/
cache/
.~lock.test.odt#
nethereum-gen.settings
Expand All @@ -12,4 +13,4 @@ artifacts/
cache_hardhat/
#drawio
*.bkp
*.dtmp
*.dtmp
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

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

## v2.0.1

- Add a new rule WhitelistWrapper

This rule can be used to restrict transfers from/to only addresses inside a group of whitelist rules managed by different operators.

## v2.0.0

- Implement the new architecture for the RuleEngine, with ValidationRule and OperationRule
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ The following rules are available:
| Rule | Type | Description | Doc |
| ------------------------------------------------------------ | -------------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
| [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) |
| [RuleWhitelistWrapper](src/rules/validation/RuleWhitelistWrapper.sol) | RuleValidation | This rule can be used to restrict transfers from/to only addresses inside a group of whitelist rules managed by different operators. | [RuleWhitelistWrapper.md](./doc/technical/RuleWhitelistWrapper.md)<br />[surya-report](./doc/surya/surya_report/surya_report_RuleWhitelistWrapper.sol.md) |
| [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) |
| [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) |
| [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) |
Expand Down
1 change: 1 addition & 0 deletions doc/schema/rule/ruleWhitelistWrapper.drawio
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<mxfile host="Electron" modified="2024-06-10T15:08:23.006Z" agent="5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/20.6.2 Chrome/106.0.5249.199 Electron/21.3.3 Safari/537.36" etag="ZhdH9EA9LXOtab_TQP2a" version="20.6.2" type="device"><diagram id="zM64sRnQbgzkaFHiXnTb" name="RuleWhitelistWrapper">7VrLcpswFP0als3whizj2Eln2k4zzSJJdwrIoKmMPEJ+5esrjMBIsmPsxpgk3STcowfo3MO90sWGcz1Z3lIwTX+QGGLDNuOl4QwN2w4vTf63AFYl4PthCSQUxSVkbYB79AIFKMYlMxTDXOrICMEMTWUwIlkGIyZhgFKykLuNCZbvOgUJ1ID7CGAdfUAxS0vUdhx/0/AVoiStbu17btkyAVVvsZQ8BTFZNCBnZDjXlBBWXk2W1xAX5FXElONudrTWT0ZhxtoMYDcvz7d+bOY2+j0fWZgFafrFLmeZAzwTK/41w3CUJSiD4rHZqiIjX6AJBrzBGSxSxOD9FERF04K7nmMpm2BuWfxyTDImnGmF3NafVTz+HFIGlw1IPPstJBPI6Ip3qaQkaBRCcipaFw23mAJLGx6pQSCkkNRTb8jiF4KvA7hzNO4eClYwytkDZ2QKad4vCl23dxy6uznkMOVa5P+sftEYWjKN4dlZ9DQWFzqLdr9Z7IEY/TY0Zv2m0XfPTmOg0ahRBrP4qsjO3IowyHMUyURRMstiWNzE5BZcIvYoWorrpwK/8IQ1XDa6DVeVkfGlPDaNxqjC3AxbW9W41i7KyYxGcH9qZYAmkO1PIzCWdiK6wxsO9bb4s8IoxIChubx/2eZjcYc7gjK20ZPjy3pyPUUm5brFqOZ2Q5nIVYTpqnoridEmWkuuXvbxKgy7UaF9nAzt7nTotNSh2ysdBmp6cI/UYaAI2r7sVoeX/6PhISr0+qVCRwliqnhaq1A5vriqnE+swuptOq0MrQ8iQr9XIvQ9ZYvnHCtCU57ICzsWoV5teCMRmlIsDF4Phm+np36lTH/X8f5QnWgTdZwyLb2yYgQDRrlh8xnNMcA5NIKhLh7uiO/gGWJZMwCjJCsExR0MKQeK4xWKAL4SDRMUx8UcAwpz9AKe1/MVUpkWS1wv2hsY3rCVeF6Xvnqwq0uX4q5Gszi47cBnXlhB6Mn++Tf5VF3IeJzD0zhUL/Oc48WvE5AlJ6CguwzktcxA/ToUhrayhz52M66msq4PhZZeKXv3kaV6tz5nZNFrdmeNLM1gUu+IO4ks/oeILK66JT12z+JZHUeWLVXP9x5Zqnfrc0aWwwqIGVl/AIhBnq5DiSW7s8DvAOOuzNaIbToczRklf+oPy/buWFSXd56a0WdfKOp5JOpXqScM9hyO20aiSyWkeepx/dSRaEvFMRj8/MYhQgu+uWLp+h2O9U/8n2MX3rYOZPdKoY63J8W1/jSj1IFc/60Uys3ND1rK7pufBTmjvw==</diagram></mxfile>
Binary file added doc/schema/rule/ruleWhitelistWrapper.drawio.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/surya/surya_graph/surya_graph_IRuleEngineValidation.sol.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/surya/surya_graph/surya_graph_RuleAddressList.sol.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

| File Name | SHA-1 Hash |
|-------------|--------------|
| ./interfaces/IRuleEngineValidation.sol | 79955886291ed983850b8b82060b7c2b0b90e4f7 |
| ./interfaces/IRuleEngineValidation.sol | 11118806381880ade78b3dbba1cea694c9a8014e |


### Contracts Description Table
Expand All @@ -16,12 +16,14 @@
|| **Function Name** | **Visibility** | **Mutability** | **Modifiers** |
||||||
| **IRuleEngineValidation** | Interface | |||
|| detectTransferRestrictionValidation | External ❗️ | |NO❗️ |
|| validateTransferValidation | External ❗️ | |NO❗️ |
||||||
| **IRuleEngineValidationCommon** | Interface | |||
|| setRulesValidation | External ❗️ | 🛑 |NO❗️ |
|| rulesCountValidation | External ❗️ | |NO❗️ |
|| ruleValidation | External ❗️ | |NO❗️ |
|| rulesValidation | External ❗️ | |NO❗️ |
|| detectTransferRestrictionValidation | External ❗️ | |NO❗️ |
|| validateTransferValidation | External ❗️ | |NO❗️ |


### Legend
Expand Down
3 changes: 2 additions & 1 deletion doc/surya/surya_report/surya_report_RuleAddressList.sol.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

| File Name | SHA-1 Hash |
|-------------|--------------|
| ./rules/validation/abstract/RuleAddressList/RuleAddressList.sol | daf3fa53f0f864274951e68bb9c8e6b44eba5fa0 |
| ./rules/validation/abstract/RuleAddressList/RuleAddressList.sol | 5cbdfeb513dd3181dd8654b57e32bd0f4b49f981 |


### Contracts Description Table
Expand All @@ -23,6 +23,7 @@
|| removeAddressFromTheList | Public ❗️ | 🛑 | onlyRole |
|| numberListedAddress | Public ❗️ | |NO❗️ |
|| addressIsListed | Public ❗️ | |NO❗️ |
|| addressIsListedBatch | Public ❗️ | |NO❗️ |
|| _msgSender | Internal 🔒 | | |
|| _msgData | Internal 🔒 | | |
|| _contextSuffixLength | Internal 🔒 | | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

| File Name | SHA-1 Hash |
|-------------|--------------|
| ./rules/validation/abstract/RuleAddressList/RuleAddressListInvariantStorage.sol | f9927d2adb13a39b3f83b0c810f3fa559272c341 |
| ./rules/validation/abstract/RuleAddressList/invariantStorage/RuleAddressListInvariantStorage.sol | f9927d2adb13a39b3f83b0c810f3fa559272c341 |


### Contracts Description Table
Expand Down
2 changes: 1 addition & 1 deletion doc/surya/surya_report/surya_report_RuleBlacklist.sol.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

| File Name | SHA-1 Hash |
|-------------|--------------|
| ./rules/validation/RuleBlacklist.sol | 831a76a89cf2f6148bdd911e6e1ec5be4e1c1a27 |
| ./rules/validation/RuleBlacklist.sol | 9bf4aefed66c48ac2b68bad9c56b9f3e01e8da24 |


### Contracts Description Table
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

| File Name | SHA-1 Hash |
|-------------|--------------|
| ./rules/validation/abstract/RuleAddressList/RuleBlacklistInvariantStorage.sol | ff8b14ed50b470a70389498956f621cd828816ed |
| ./rules/validation/abstract/RuleAddressList/invariantStorage/RuleBlacklistInvariantStorage.sol | cf47d03ede24ba35080106f8d4380bb651e92c39 |


### Contracts Description Table
Expand Down
2 changes: 1 addition & 1 deletion doc/surya/surya_report/surya_report_RuleEngine.sol.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

| File Name | SHA-1 Hash |
|-------------|--------------|
| ./RuleEngine.sol | 0fc418971885c84c32fab8ba76462a7ae5c77b77 |
| ./RuleEngine.sol | 9ac4a4a50634a369d5b88418fc8d1af7a3b1df77 |


### Contracts Description Table
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

| File Name | SHA-1 Hash |
|-------------|--------------|
| ./modules/RuleEngineInvariantStorage.sol | c733563e242d5ffa42e9e5c8140a4cbbd6267f93 |
| ./modules/RuleEngineInvariantStorage.sol | 824864b8a40f1f4ff47cc91e3226d6cd92b9ed3c |


### Contracts Description Table
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

| File Name | SHA-1 Hash |
|-------------|--------------|
| ./modules/RuleEngineOperation.sol | a511cf11774bebce822a8b277f0d33a71d6df492 |
| ./modules/RuleEngineOperation.sol | 428f410167252dbe376f484fccaa796cb1309851 |


### Contracts Description Table
Expand Down
14 changes: 2 additions & 12 deletions doc/surya/surya_report/surya_report_RuleEngineValidation.sol.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

| File Name | SHA-1 Hash |
|-------------|--------------|
| ./modules/RuleEngineValidation.sol | 389f8e6a721d981e7704f67c608138af0b3bed97 |
| ./modules/RuleEngineValidation.sol | 6b65517a26ad9ef8bfc88dad98a35bd8b29fcca4 |


### Contracts Description Table
Expand All @@ -15,17 +15,7 @@
|:----------:|:-------------------:|:----------------:|:----------------:|:---------------:|
|| **Function Name** | **Visibility** | **Mutability** | **Modifiers** |
||||||
| **RuleEngineValidation** | Implementation | AccessControl, RuleInternal, IRuleEngineValidation, IERC1404EnumCode |||
|| setRulesValidation | Public ❗️ | 🛑 | onlyRole |
|| clearRulesValidation | Public ❗️ | 🛑 | onlyRole |
|| _clearRulesValidation | Internal 🔒 | 🛑 | |
|| addRuleValidation | Public ❗️ | 🛑 | onlyRole |
|| removeRuleValidation | Public ❗️ | 🛑 | onlyRole |
|| _removeRuleValidation | Internal 🔒 | 🛑 | |
|| rulesCountValidation | External ❗️ | |NO❗️ |
|| getRuleIndexValidation | External ❗️ | |NO❗️ |
|| ruleValidation | External ❗️ | |NO❗️ |
|| rulesValidation | External ❗️ | |NO❗️ |
| **RuleEngineValidation** | Implementation | AccessControl, RuleInternal, RuleEngineValidationCommon, IRuleEngineValidation, IERC1404EnumCode |||
|| detectTransferRestrictionValidation | Public ❗️ | |NO❗️ |
|| validateTransferValidation | Public ❗️ | |NO❗️ |

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
## Sūrya's Description Report

### Files Description Table


| File Name | SHA-1 Hash |
|-------------|--------------|
| ./modules/RuleEngineValidationCommon.sol | 9c992d27ccef264c7cb0c3137f384541590f9bfd |


### Contracts Description Table


| Contract | Type | Bases | | |
|:----------:|:-------------------:|:----------------:|:----------------:|:---------------:|
|| **Function Name** | **Visibility** | **Mutability** | **Modifiers** |
||||||
| **RuleEngineValidationCommon** | Implementation | AccessControl, RuleInternal, IRuleEngineValidationCommon |||
|| setRulesValidation | Public ❗️ | 🛑 | onlyRole |
|| clearRulesValidation | Public ❗️ | 🛑 | onlyRole |
|| _clearRulesValidation | Internal 🔒 | 🛑 | |
|| addRuleValidation | Public ❗️ | 🛑 | onlyRole |
|| removeRuleValidation | Public ❗️ | 🛑 | onlyRole |
|| _removeRuleValidation | Internal 🔒 | 🛑 | |
|| rulesCountValidation | External ❗️ | |NO❗️ |
|| getRuleIndexValidation | External ❗️ | |NO❗️ |
|| ruleValidation | External ❗️ | |NO❗️ |
|| rulesValidation | External ❗️ | |NO❗️ |


### Legend

| Symbol | Meaning |
|:--------:|-----------|
| 🛑 | Function can modify state |
| 💵 | Function is payable |
2 changes: 1 addition & 1 deletion doc/surya/surya_report/surya_report_RuleWhitelist.sol.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

| File Name | SHA-1 Hash |
|-------------|--------------|
| ./rules/validation/RuleWhitelist.sol | 721bc822979b9948547c0d499ccb831ee6083775 |
| ./rules/validation/RuleWhitelist.sol | 95fbe2f3831b9a71b1b332868ca5594f4b3d4332 |


### Contracts Description Table
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

| File Name | SHA-1 Hash |
|-------------|--------------|
| ./rules/validation/abstract/RuleAddressList/RuleWhitelistInvariantStorage.sol | 539fc229948771c41225df414fbe1eb050fd75f9 |
| ./rules/validation/abstract/RuleAddressList/invariantStorage/RuleWhitelistInvariantStorage.sol | fd28dfca118991fc5956bb5638de59a5a082ccbf |


### Contracts Description Table
Expand Down
33 changes: 33 additions & 0 deletions doc/surya/surya_report/surya_report_RuleWhitelistWrapper.sol.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
## Sūrya's Description Report

### Files Description Table


| File Name | SHA-1 Hash |
|-------------|--------------|
| ./rules/validation/RuleWhitelistWrapper.sol | bf329dec00b1249add78824aa85a9dcdd49a8342 |


### Contracts Description Table


| Contract | Type | Bases | | |
|:----------:|:-------------------:|:----------------:|:----------------:|:---------------:|
|| **Function Name** | **Visibility** | **Mutability** | **Modifiers** |
||||||
| **RuleWhitelistWrapper** | Implementation | RuleEngineValidationCommon, MetaTxModuleStandalone, RuleValidateTransfer, RuleWhitelistInvariantStorage |||
|| <Constructor> | Public ❗️ | 🛑 | MetaTxModuleStandalone |
|| detectTransferRestriction | Public ❗️ | |NO❗️ |
|| canReturnTransferRestrictionCode | External ❗️ | |NO❗️ |
|| messageForTransferRestriction | External ❗️ | |NO❗️ |
|| _msgSender | Internal 🔒 | | |
|| _msgData | Internal 🔒 | | |
|| _contextSuffixLength | Internal 🔒 | | |


### Legend

| Symbol | Meaning |
|:--------:|-----------|
| 🛑 | Function can modify state |
| 💵 | Function is payable |
2 changes: 2 additions & 0 deletions doc/technical/RuleBlacklist.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ A part of the code is shared with Rule Whitelist

![surya_graph_Blacklist](../surya/surya_graph/surya_graph_RuleBlacklist.sol.png)

### Inheritance

![surya_inheritance_RuleWhitelistWrapper.sol](../surya/surya_inheritance/surya_inheritance_RuleBlacklist.sol.png)

## Access Control

Expand Down
2 changes: 2 additions & 0 deletions doc/technical/RuleConditionalTransfer.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ To perform the transfer, the token holder has to `approve` the rule to spend tok

![surya_graph_Blacklist](../surya/surya_graph/surya_graph_RuleConditionalTransfer.sol.png)

### Inheritance

![surya_inheritance_RuleWhitelistWrapper.sol](../surya/surya_inheritance/surya_inheritance_RuleConditionalTransfer.sol.png)

### Workflow

Expand Down
4 changes: 4 additions & 0 deletions doc/technical/RuleSanctionList.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ The documentation and the contracts addresses are available here: [Chainalysis o

![surya_graph_Whitelist](../surya/surya_graph/surya_graph_RuleSanctionList.sol.png)

### Inheritance

![surya_inheritance_RuleWhitelistWrapper.sol](../surya/surya_inheritance/surya_inheritance_RuleSanctionList.sol.png)

## Access Control

### Admin
Expand Down
4 changes: 3 additions & 1 deletion doc/technical/RuleWhitelist.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ This rule can be used to restrict transfers from/to only addresses inside a whit

![surya_graph_Whitelist](../surya/surya_graph/surya_graph_RuleWhitelist.sol.png)

### Inheritance

![surya_inheritance_RuleWhitelistWrapper.sol](../surya/surya_inheritance/surya_inheritance_RuleWhitelist.sol.png)

## Access Control

Expand All @@ -21,7 +23,7 @@ The default admin is the address put in argument(`admin`) inside the constructor
### Schema

Here a schema of the Access Control.
![alt text](../accessControl/access-control-RuleWhitelist.png)
![alt text](../security/accessControl/access-control-RuleWhitelist.png)



Expand Down
32 changes: 32 additions & 0 deletions doc/technical/RuleWhitelistWrapper.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Rule Whitelist Wrapper

[TOC]

This rule allows to have several different whitelist rules, managed by different operators.

The rule will call each whitelist rule to know if during a transfer the address `from`or the address `to`is in the whitelist.
If this is the case, the rule return 0 (transfer valid) or an error otherwise.

## Schema

### Architecture

![ruleWhitelistWrapper.drawio](../schema/rule/ruleWhitelistWrapper.drawio.png)

### Graph

![surya_graph_Whitelist](../surya/surya_graph/surya_graph_RuleWhitelistWrapper.sol.png)

### Inheritance

![surya_inheritance_RuleWhitelistWrapper.sol](../surya/surya_inheritance/surya_inheritance_RuleWhitelistWrapper.sol.png)

## Details

### Architecture

This rule inherits from `RuleEngineValidationCommon`. Thus the whitelist rules are managed with the same architecture and code than for the ruleEngine. For example, rules are added with the functions `setRulesValidation` or `addRuleValidation`.

### Admin

The default admin is the address put in argument(`admin`) inside the constructor. It is set in the constructor when the contract is deployed.
Loading

0 comments on commit 061f26c

Please sign in to comment.