Skip to content

Commit 9a35496

Browse files
authored
Merge pull request #46 from CMTA/engine-improvement
V2.0.3
2 parents c8bcda2 + b7dbab7 commit 9a35496

171 files changed

Lines changed: 4688 additions & 4541 deletions

File tree

Some content is hidden

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

CHANGELOG.md

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

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

5+
6+
7+
## v2.0.3
8+
9+
- Small optimization in WhitelistWrapper; add a break in a loop
10+
- Set Solidity version to 0.8.26 in config file
11+
512
## v2.0.2 - 20240617
613

714
- Create abstract contract ruleWhitelistCommon to contain code shared between ruleWhitelist & ruleWhitelistWrapper

CONTRIBUTING.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Contributing Guidelines
2+
3+
There are many ways to contribute to RuleEngine Contracts.
4+
5+
## Opening an issue
6+
7+
You can [open an issue] to suggest a feature, a difficulty you have or report a minor bug. For serious bugs in an audited version please do not open an issue, instead refer to our [security policy] for appropriate steps. See [SECURITY.md](./SECURITY.MD) in CMTAT project.
8+
9+
Before opening an issue, be sure to search through the existing open and closed issues, and consider posting a comment in one of those instead.
10+
11+
When requesting a new feature, include as many details as you can, especially around the use cases that motivate it.
12+
13+
## Submitting a pull request
14+
15+
If you would like to contribute code or documentation you may do so by forking the repository and submitting a pull request.
16+
17+
Run linter and tests to make sure your pull request is good before submitting it.
18+
19+
20+
21+
## Reference
22+
23+
Based on the version made by [OpenZeppelin](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/CONTRIBUTING.md)

README.md

Lines changed: 75 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,16 @@
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.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)
86

9-
The CMTAT contracts and the OpenZeppelin library are included as a submodule of the present repository.
7+
The RuleEngine is an external contract used to apply transfer restrictions to another contract, initially the CMTAT. Acting as a controller, it can call different contract rules and apply these rules on each transfer.
8+
9+
## Dependencies
10+
11+
The toolchain includes the following components, where the versions are the latest ones that we tested:
12+
13+
- Foundry
14+
- Solidity 0.8.26 (via solc-js)
15+
- OpenZeppelin Contracts (submodule) [v5.0.2](https://github.com/OpenZeppelin/openzeppelin-contracts/releases/tag/v5.0.2)
1016

1117
## How to include it
1218

@@ -22,7 +28,21 @@ Before each transfer, your contract must call the function `operateOnTransfer` w
2228

2329
![Engine-RuleEngine.drawio](./doc/schema/Engine-RuleEngine.drawio.png)
2430

31+
### UML
32+
33+
#### Global
34+
35+
> npm run-script uml
36+
37+
![uml](./doc/schema/classDiagram.svg)
38+
39+
40+
41+
#### RuleEngine
42+
43+
> npm run-script uml:ruleEngine
2544
45+
![uml](./doc/schema/RuleEngine.svg)
2646

2747
## Available Rules
2848

@@ -38,11 +58,41 @@ The following rules are available:
3858

3959

4060

61+
62+
63+
## Functionality
64+
65+
### Upgradeable
66+
67+
The Rule Engine and the other rules are not upgradeable. The reason is the following:
68+
If we need a new on, we just issue a new one, and set inside the CMTAT token (or the RuleEngine for the rules) to use the new.
69+
70+
### Urgency mechanism
71+
72+
- Pause
73+
74+
There are no functionalities to put in pause the contracts.
75+
76+
* Kill / Deactivate the contracts
77+
78+
There are no functionalities to kill/deactivate the contracts.
79+
80+
81+
### Gasless support (ERC-2771)
82+
83+
> The gasless integration was not part of the audit performed by ABDK on the version [1.0.1](https://github.com/CMTA/RuleEngine/releases/tag/1.0.1)
84+
85+
The RuleEngine contracts and the other rules support client-side gasless transactions using the [Gas Station Network](https://docs.opengsn.org/#the-problem) (GSN) pattern, the main open standard for transfering fee payment to another account than that of the transaction issuer. The contract uses the OpenZeppelin contract `ERC2771Context`, which allows a contract to get the original client with `_msgSender()` instead of the fee payer given by `msg.sender` .
86+
87+
At deployment, the parameter `forwarder` inside the contract constructor has to be set with the defined address of the forwarder. Please note that the forwarder can not be changed after deployment.
88+
89+
Please see the OpenGSN [documentation](https://docs.opengsn.org/contracts/#receiving-a-relayed-call) for more details on what is done to support GSN in the contract.
90+
4191
## Audit
4292

4393
The contracts have been audited by [ABDKConsulting](https://www.abdk.consulting/), a globally recognized firm specialized in smart contracts' security.
4494

45-
#### First Audit - March 2022
95+
### First Audit - March 2022
4696

4797
Fixed version : [v1.0.2](https://github.com/CMTA/RuleEngine/releases/tag/v1.0.2)
4898

@@ -72,24 +122,24 @@ Here a summary of the main documentation
72122

73123
| Document | Link/Files |
74124
| ----------------------- | ---------------------------------------------------- |
75-
| Technical documentation | [doc/technical/general](./doc/technical/general.md) |
125+
| Technical documentation | [doc/technical/](./doc/technical/) |
76126
| Toolchain | [doc/TOOLCHAIN.md](./doc/TOOLCHAIN.md) |
77127
| Functionalities | [doc/functionalities.pdf](./doc/functionalities.pdf) |
78128
| Surya report | [doc/surya](./doc/surya/) |
79129

80-
130+
See also [Taurus - Token Transfer Management: How to Apply Restrictions with CMTAT and ERC-1404](https://www.taurushq.com/blog/token-transfer-management-how-to-apply-restrictions-with-cmtat-and-erc-1404/)
81131

82132
## Usage
83133

84134
*Explain how it works.*
85135

86136

87-
## Toolchain installation
137+
### Toolchain installation
88138
The contracts are developed and tested with [Foundry](https://book.getfoundry.sh), a smart contract development toolchain.
89139

90140
To install the Foundry suite, please refer to the official instructions in the [Foundry book](https://book.getfoundry.sh/getting-started/installation).
91141

92-
## Initialization
142+
### Initialization
93143

94144
You must first initialize the submodules, with
95145

@@ -109,7 +159,7 @@ See also the command's [documentation](https://book.getfoundry.sh/reference/forg
109159

110160

111161

112-
## Compilation
162+
### Compilation
113163

114164
The official documentation is available in the Foundry [website](https://book.getfoundry.sh/reference/forge/build-commands)
115165
```
@@ -119,19 +169,25 @@ The official documentation is available in the Foundry [website](https://book.ge
119169
forge build --contracts src/RuleWhiteList.sol
120170
```
121171

122-
## Testing
172+
### Testing
123173
You can run the tests with
124174

125-
```
175+
```bash
126176
forge test
127177
```
128178

129179
To run a specific test, use
130180

131-
```
181+
```bash
132182
forge test --match-contract <contract name> --match-test <function name>
133183
```
134184

185+
Generate gas report
186+
187+
```bash
188+
forge test --gas-report
189+
```
190+
135191
See also the test framework's [official documentation](https://book.getfoundry.sh/forge/tests), and that of the [test commands](https://book.getfoundry.sh/reference/forge/test-commands).
136192

137193
### Coverage
@@ -153,9 +209,9 @@ forge coverage --report lcov && genhtml lcov.info --branch-coverage --output-dir
153209

154210
See [Solidity Coverage in VS Code with Foundry](https://mirror.xyz/devanon.eth/RrDvKPnlD-pmpuW7hQeR5wWdVjklrpOgPCOA-PJkWFU) & [Foundry forge coverage](https://www.rareskills.io/post/foundry-forge-coverage)
155211

156-
## Deployment
212+
### Deployment
157213
The official documentation is available in the Foundry [website](https://book.getfoundry.sh/reference/forge/deploy-commands)
158-
### Script
214+
#### Script
159215

160216
> This documentation has been written for the version v1.0.2
161217
@@ -174,10 +230,14 @@ CMTAT with RuleEngine
174230
```bash
175231
forge script script/CMTATWithRuleEngineScript.s.sol:CMTATWithRuleEngineScript --rpc-url=$RPC_URL --broadcast --verify -vvv
176232
```
177-
Value of YOUR_RPC_URL with a local instance of anvil : [http://127.0.0.1:8545](http://127.0.0.1:8545)
233+
Value of YOUR_RPC_URL with a local instance of anvil : [127.0.0.1:8545](http://127.0.0.1:8545)
178234

179235
Only RuleEngine with a Whitelist contract
180236

181237
```bash
182238
forge script script/RuleEngineScript.s.sol:RuleEngineScript --rpc-url=$RPC_URL --broadcast --verify -vvv
183239
```
240+
241+
## Intellectual property
242+
243+
The code is copyright (c) Capital Market and Technology Association, 2018-2024, and is released under [Mozilla Public License 2.0](https://github.com/CMTA/CMTAT/blob/master/LICENSE.md).

0 commit comments

Comments
 (0)