Skip to content

Commit

Permalink
Update doc, solidity version to 0.8.22 in config files, OpenZeppelin …
Browse files Browse the repository at this point in the history
…to 5.02, update function balanceInfo in ERC20BaseModule
  • Loading branch information
rya-sge committed Mar 19, 2024
1 parent 5d183e2 commit 2abaa06
Show file tree
Hide file tree
Showing 116 changed files with 1,702 additions and 1,146 deletions.
24 changes: 23 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,31 @@

Please follow <https://changelog.md/> conventions.

## 2.4.0-rc.1 - 20240319

The modifications between the version v2.3.0 and this version are not audited !!!

## 2.4.0-rc.0 - 20230925
**snapshotModule**

- Create an interface `ICMTATSnapshot` with the main public functions for the SnapshotModule to make easier the calls to a contract including a snapshotModule, useful e.g. for debt payment.
- Replace `getSnapshotInfoBatch` by `SnapshotInfo`. This function gets a user's balance specified in parameter and the total supply.
- Add a new function `SnapshotInfoBatch` to get several user's balances and the total supply.

**ERC20BaseModule**
Add a function `balanceInfo` to get the balance for a list of addresses and the total supply
Useful to perform transfer restriction based on the user's balance (e.g vesting rule or partial lock).

**ValidationModule**
Create an internal function ` _validateTransferByModule` which performs check with others module (PauseModule & EnforcementModule)

**Other**

- Upgrade OpenZeppelin to the version [v5.0.2](https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/releases/tag/v5.0.2)
- Upgrade Solidity to the version [0.8.22](https://soliditylang.org/blog/2023/10/25/solidity-0.8.22-release-announcement/) in the truffle and hardhat config files.

## 2.4.0-rc.0 - 20240129

The modifications between the version v2.3.0 and this version are not audited !!!

**New architecture for the RuleEngine** [#250](https://github.com/CMTA/CMTAT/pull/250)

Expand Down
15 changes: 9 additions & 6 deletions contracts/interfaces/ICMTATSnapshot.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ pragma solidity ^0.8.0;
* @notice interface to represent a CMTAT with snapshot
*/
interface ICMTATSnapshot {
/**
* @notice Return snapshotBalanceOf and snapshotTotalSupply to avoid multiple calls
* @return ownerBalance , totalSupply - see snapshotBalanceOf and snapshotTotalSupply
*/
function snapshotInfo(uint256 time, address owner) external view returns (uint256 ownerBalance, uint256 totalSupply);
/**
* @notice Return the number of tokens owned by the given owner at the time when the snapshot with the given time was created.
* @return value stored in the snapshot, or the actual balance if no snapshot
Expand All @@ -22,6 +17,14 @@ interface ICMTATSnapshot {
* @return value stored in the snapshot, or the actual totalSupply if no snapshot
*/
function snapshotTotalSupply(uint256 time) external view returns (uint256);

/**
* @notice Return snapshotBalanceOf and snapshotTotalSupply to avoid multiple calls
* @return ownerBalance , totalSupply - see snapshotBalanceOf and snapshotTotalSupply
*/
function snapshotInfo(uint256 time, address owner) external view returns (uint256 ownerBalance, uint256 totalSupply);
/**
* @notice Return snapshotBalanceOf for each address in the array and the total supply
* @return ownerBalances array with the balance of each address, the total supply
*/
function snapshotInfoBatch(uint256 time, address[] calldata addresses) external view returns (uint256[] memory ownerBalances, uint256 totalSupply);
}
3 changes: 1 addition & 2 deletions contracts/modules/internal/ERC20SnapshotModuleInternal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import "./base/SnapshotModuleBase.sol";
abstract contract ERC20SnapshotModuleInternal is SnapshotModuleBase, ERC20Upgradeable {
using Arrays for uint256[];


/**
* @dev
* list of scheduled snapshot (time)
Expand All @@ -45,7 +44,7 @@ abstract contract ERC20SnapshotModuleInternal is SnapshotModuleBase, ERC20Upgrad
}

/**
* @notice Return snapshotBalanceOf for each address in an array and the total supply
* @notice Return snapshotBalanceOf for each address in the array and the total supply
* @return ownerBalances array with the balance of each address, the total supply
*/
function snapshotInfoBatch(uint256 time, address[] calldata addresses) public view returns (uint256[] memory ownerBalances, uint256 totalSupply) {
Expand Down
18 changes: 6 additions & 12 deletions contracts/modules/internal/base/SnapshotModuleBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,11 @@ abstract contract SnapshotModuleBase is Initializable {
indexLowerBound -
1;
nextScheduledSnapshot = new uint256[](arraySize);
for (uint256 i; i < arraySize; ) {
// No need of unchecked block since Soliditiy 0.8.22
for (uint256 i; i < arraySize; ++i) {
nextScheduledSnapshot[i] = _scheduledSnapshots[
indexLowerBound + 1 + i
];
unchecked {
++i;
}
}
}
}
Expand Down Expand Up @@ -257,11 +255,9 @@ abstract contract SnapshotModuleBase is Initializable {
if (!isFound) {
revert Errors.CMTAT_SnapshotModule_SnapshotNotFound();
}
for (uint256 i = index; i + 1 < _scheduledSnapshots.length; ) {
// No need of unchecked block since Soliditiy 0.8.22
for (uint256 i = index; i + 1 < _scheduledSnapshots.length; ++i ) {
_scheduledSnapshots[i] = _scheduledSnapshots[i + 1];
unchecked {
++i;
}
}
_scheduledSnapshots.pop();
}
Expand Down Expand Up @@ -392,17 +388,15 @@ abstract contract SnapshotModuleBase is Initializable {
// mostRecent is initialized in the loop
uint256 mostRecent;
index = currentArraySize;
for (uint256 i = _currentSnapshotIndex; i < currentArraySize; ) {
// No need of unchecked block since Soliditiy 0.8.22
for (uint256 i = _currentSnapshotIndex; i < currentArraySize; ++i ) {
if (_scheduledSnapshots[i] <= block.timestamp) {
mostRecent = _scheduledSnapshots[i];
index = i;
} else {
// All snapshot are planned in the futur
break;
}
unchecked {
++i;
}
}
return (mostRecent, index);
}
Expand Down
19 changes: 9 additions & 10 deletions contracts/modules/wrapper/core/ERC20BaseModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,11 @@ abstract contract ERC20BaseModule is ERC20Upgradeable {
if (bool(tos.length != values.length)) {
revert Errors.CMTAT_ERC20BaseModule_TosValueslengthMismatch();
}

for (uint256 i = 0; i < tos.length; ) {
// No need of unchecked block since Soliditiy 0.8.22
for (uint256 i = 0; i < tos.length; ++i) {
// We call directly the internal function transfer
// The reason is that the public function adds only the owner address recovery
ERC20Upgradeable._transfer(_msgSender(), tos[i], values[i]);
unchecked {
++i;
}
}
// not really useful
// Here only to keep the same behaviour as transfer
Expand Down Expand Up @@ -102,13 +99,15 @@ abstract contract ERC20BaseModule is ERC20Upgradeable {
}

/**
* @param from address
* @param to address
* @param addresses list of address to know their balance
* @return balances ,totalSupply array with balance for each address, totalSupply
* @dev useful for the snapshot rule
*/
function balanceInfo(address from, address to) public view returns(uint256 fromBalance, uint256 toBalance, uint256 totalSupply) {
fromBalance = ERC20Upgradeable.balanceOf(from);
toBalance = ERC20Upgradeable.balanceOf(to);
function balanceInfo(address[] calldata addresses) public view returns(uint256[] memory balances , uint256 totalSupply) {
balances = new uint256[](addresses.length);
for(uint256 i = 0; i < addresses.length; ++i){
balances[i] = ERC20Upgradeable.balanceOf(addresses[i]);
}
totalSupply = ERC20Upgradeable.totalSupply();
}

Expand Down
7 changes: 2 additions & 5 deletions contracts/modules/wrapper/core/ERC20BurnModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,10 @@ abstract contract ERC20BurnModule is ERC20Upgradeable, ICCIPBurnFromERC20, Autho
if (bool(accounts.length != values.length)) {
revert Errors.CMTAT_BurnModule_AccountsValueslengthMismatch();
}

for (uint256 i = 0; i < accounts.length; ) {
// No need of unchecked block since Soliditiy 0.8.22
for (uint256 i = 0; i < accounts.length; ++i ) {
_burn(accounts[i], values[i]);
emit Burn(accounts[i], values[i], reason);
unchecked {
++i;
}
}
}

Expand Down
7 changes: 2 additions & 5 deletions contracts/modules/wrapper/core/ERC20MintModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,10 @@ abstract contract ERC20MintModule is ERC20Upgradeable, ICCIPMintERC20, Authoriza
if (bool(accounts.length != values.length)) {
revert Errors.CMTAT_MintModule_AccountsValueslengthMismatch();
}

for (uint256 i = 0; i < accounts.length; ) {
// No need of unchecked block since Soliditiy 0.8.22
for (uint256 i = 0; i < accounts.length; ++i ) {
_mint(accounts[i], values[i]);
emit Mint(accounts[i], values[i]);
unchecked {
++i;
}
}
}

Expand Down
6 changes: 3 additions & 3 deletions doc/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ are the latest ones that we tested:
- npm 10.2.5
- Hardhat-web3 2.0.0
- *Truffle 5.9.3 [depreciated]*
- Solidity 0.8.21 (via solc-js)
- Solidity 0.8.22 (via solc-js)
- Node 20.5.0
- Web3.js 1.9.0
- OpenZeppelin
- OpenZeppelin Contracts Upgradeable (submodule) [v5.0.1](https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/releases/tag/v5.0.1)
- OpenZeppelin Contracts (Node.js module) [v5.0.1](https://github.com/OpenZeppelin/openzeppelin-contracts/releases/tag/v5.0.1)
- OpenZeppelin Contracts Upgradeable (submodule) [v5.0.2](https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/releases/tag/v5.0.2)
- OpenZeppelin Contracts (Node.js module) [v5.0.2](https://github.com/OpenZeppelin/openzeppelin-contracts/releases/tag/v5.0.2)
- Reason n°1: libraries and interfaces are no longer available inside the upgradeable version since the version v5.0.0.
- Reason n°2: It is not installed as a github submodule because it will create conflicts with the imports inside OpenZeppelin which use the Node.js version.

Expand Down
2 changes: 1 addition & 1 deletion doc/general/test/coverage/contracts/CMTAT_PROXY.sol.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Mon Jan 29 2024 10:44:14 GMT+0100 (Central European Standard Time)
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Tue Mar 19 2024 16:20:33 GMT+0100 (Central European Standard Time)
</div>
</div>
<script src="../prettify.js"></script>
Expand Down
4 changes: 2 additions & 2 deletions doc/general/test/coverage/contracts/CMTAT_STANDALONE.sol.html
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ <h1>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">188×</span>
<span class="cline-any cline-yes">189×</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
Expand Down Expand Up @@ -208,7 +208,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Mon Jan 29 2024 10:44:14 GMT+0100 (Central European Standard Time)
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Tue Mar 19 2024 16:20:33 GMT+0100 (Central European Standard Time)
</div>
</div>
<script src="../prettify.js"></script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Mon Jan 29 2024 10:44:14 GMT+0100 (Central European Standard Time)
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Tue Mar 19 2024 16:20:33 GMT+0100 (Central European Standard Time)
</div>
</div>
<script src="../../prettify.js"></script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Mon Jan 29 2024 10:44:14 GMT+0100 (Central European Standard Time)
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Tue Mar 19 2024 16:20:33 GMT+0100 (Central European Standard Time)
</div>
</div>
<script src="../../prettify.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion doc/general/test/coverage/contracts/deployment/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Mon Jan 29 2024 10:44:14 GMT+0100 (Central European Standard Time)
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Tue Mar 19 2024 16:20:33 GMT+0100 (Central European Standard Time)
</div>
</div>
<script src="../../prettify.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion doc/general/test/coverage/contracts/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Mon Jan 29 2024 10:44:14 GMT+0100 (Central European Standard Time)
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Tue Mar 19 2024 16:20:33 GMT+0100 (Central European Standard Time)
</div>
</div>
<script src="../prettify.js"></script>
Expand Down
21 changes: 18 additions & 3 deletions doc/general/test/coverage/contracts/interfaces/ICCIPToken.sol.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,17 @@ <h1>
17
18
19
20</td><td class="line-coverage quiet"><span class="cline-any cline-neutral">&nbsp;</span>
20
21
22
23
24
25</td><td class="line-coverage quiet"><span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
Expand All @@ -85,6 +95,9 @@ <h1>
&nbsp;
pragma solidity ^0.8.0;
&nbsp;
/**
* @notice CCIP Pool with mint
*/
interface ICCIPMintERC20 {
/// @notice Mints new tokens for a given address.
/// @param account The address to mint the new tokens to.
Expand All @@ -93,20 +106,22 @@ <h1>
function mint(address account, uint256 value) external;
}
&nbsp;
/**
* @notice CCIP Pool with burnFrom
*/
interface ICCIPBurnFromERC20 {
/// @notice Burns tokens from a given address..
/// @param account The address to burn tokens from.
/// @param value The number of tokens to be burned.
/// @dev this function decreases the total supply.
function burnFrom(address account, uint256 value) external;
&nbsp;
}</pre></td></tr>
</table></pre>
<div class='push'></div><!-- for sticky footer -->
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Mon Jan 29 2024 10:44:14 GMT+0100 (Central European Standard Time)
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Tue Mar 19 2024 16:20:33 GMT+0100 (Central European Standard Time)
</div>
</div>
<script src="../../prettify.js"></script>
Expand Down
Loading

0 comments on commit 2abaa06

Please sign in to comment.