Skip to content

Commit

Permalink
Merge pull request #261 from CMTA/update-lib
Browse files Browse the repository at this point in the history
Update lib
  • Loading branch information
rya-sge authored Jan 18, 2024
2 parents 0823631 + f5c2401 commit 6cb947d
Show file tree
Hide file tree
Showing 18 changed files with 4,734 additions and 8,385 deletions.
2 changes: 1 addition & 1 deletion contracts/CMTAT_STANDALONE.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ contract CMTAT_STANDALONE is CMTAT_BASE {
uint8 decimalsIrrevocable,
string memory tokenId_,
string memory terms_,
IRuleEngineCMTAT ruleEngine_,
IRuleEngine ruleEngine_,
string memory information_,
uint256 flag_
) MetaTxModule(forwarderIrrevocable) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

pragma solidity ^0.8.0;

import "./draft-IERC1404Wrapper.sol";
import "../draft-IERC1404/draft-IERC1404Wrapper.sol";

interface IRuleEngineCMTAT is IERC1404Wrapper {
interface IRuleEngine is IERC1404Wrapper {
/**
* @dev Returns true if the operation is a success, and false otherwise.
*/
Expand Down
40 changes: 40 additions & 0 deletions contracts/mocks/AuthorizationEngineMock.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//SPDX-License-Identifier: MPL-2.0

pragma solidity ^0.8.20;

import "../interfaces/engine/IAuthorizationEngine.sol";

/*
@title a mock for testing, not suitable for production
*/
contract AuthorizationEngineMock is IAuthorizationEngine {
address nextAdmin;

constructor() {

}

/*
* @dev
* Warning: if you want to use this mock, you have to restrict the access to this function through an an access control
*/
function authorizeAdminChange(address newAdmin) external {
nextAdmin = newAdmin;
}

/*
* @dev
* Warning: if you want to use this mock, you have to restrict the access to this function through an an access control
*/
function operateOnAuthorization(
bytes32 role, address account
) external returns (bool isValid){
if(role == 0x0 && account == nextAdmin && account != address(0x0)){
// Reset to 0
nextAdmin = address(0x0);
return true;
}else{
return false;
}
}
}
18 changes: 9 additions & 9 deletions contracts/mocks/RuleEngine/RuleEngineMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@
pragma solidity ^0.8.20;

import "./interfaces/IRule.sol";
import "./interfaces/IRuleEngine.sol";
import "./interfaces/IRuleEngineMock.sol";
import "./RuleMock.sol";
import "./CodeList.sol";

/*
@title a mock for testing, not suitable for production
*/
contract RuleEngineMock is IRuleEngine {
contract RuleEngineMock is IRuleEngineMock {
IRule[] internal _rules;

constructor() {
_rules.push(new RuleMock());
}

/*
@dev
Warning: if you want to use this mock, you have to restrict the access to this function through an an access control
* @dev
* Warning: if you want to use this mock, you have to restrict the access to this function through an an access control
*/
function setRules(IRule[] calldata rules_) external override {
_rules = rules_;
Expand Down Expand Up @@ -68,18 +68,18 @@ contract RuleEngineMock is IRuleEngine {
}

/*
@dev
Warning: if you want to use this mock, you have to restrict the access to this function through an an access control
* @dev
* Warning: if you want to use this mock, you have to restrict the access to this function through an an access control
*/
function operateOnTransfer( address _from,
address _to,
uint256 _amount) public override returns (bool){
uint256 _amount) view public override returns (bool){
return validateTransfer(_from, _to, _amount);
}

/**
@dev
For all the rules, each restriction code has to be unique.
* @dev
* For all the rules, each restriction code has to be unique.
*/
function messageForTransferRestriction(
uint8 _restrictionCode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
pragma solidity ^0.8.0;

import "./IRule.sol";
import "../../../interfaces/draft-IERC1404/IRuleEngineCMTAT.sol";
import "../../../interfaces/engine/IRuleEngine.sol";

interface IRuleEngine is IRuleEngineCMTAT {
interface IRuleEngineMock is IRuleEngine {
/**
* @dev define the rules, the precedent rules will be overwritten
*/
Expand Down
4 changes: 2 additions & 2 deletions contracts/modules/CMTAT_BASE.sol
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ abstract contract CMTAT_BASE is
uint8 decimalsIrrevocable,
string memory tokenId_,
string memory terms_,
IRuleEngineCMTAT ruleEngine_,
IRuleEngine ruleEngine_,
string memory information_,
uint256 flag_
) public initializer {
Expand Down Expand Up @@ -91,7 +91,7 @@ abstract contract CMTAT_BASE is
uint8 decimalsIrrevocable,
string memory tokenId_,
string memory terms_,
IRuleEngineCMTAT ruleEngine_,
IRuleEngine ruleEngine_,
string memory information_,
uint256 flag_
) internal onlyInitializing {
Expand Down
8 changes: 4 additions & 4 deletions contracts/modules/internal/ValidationModuleInternal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pragma solidity ^0.8.20;
import "../../../openzeppelin-contracts-upgradeable/contracts/utils/ContextUpgradeable.sol";
import "../../../openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol";
import "../../interfaces/draft-IERC1404/draft-IERC1404Wrapper.sol";
import "../../interfaces/draft-IERC1404/IRuleEngineCMTAT.sol";
import "../../interfaces/engine/IRuleEngine.sol";
/**
* @dev Validation module.
*
Expand All @@ -18,12 +18,12 @@ abstract contract ValidationModuleInternal is
/**
* @dev Emitted when a rule engine is set.
*/
event RuleEngine(IRuleEngineCMTAT indexed newRuleEngine);
event RuleEngine(IRuleEngine indexed newRuleEngine);

IRuleEngineCMTAT public ruleEngine;
IRuleEngine public ruleEngine;

function __Validation_init_unchained(
IRuleEngineCMTAT ruleEngine_
IRuleEngine ruleEngine_
) internal onlyInitializing {
if (address(ruleEngine_) != address(0)) {
ruleEngine = ruleEngine_;
Expand Down
2 changes: 1 addition & 1 deletion contracts/modules/security/AuthorizationModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import "../../../openzeppelin-contracts-upgradeable/contracts/access/AccessContr
import "../../../openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol";

import "../../libraries/Errors.sol";
import "../../interfaces/IAuthorizationEngine.sol";
import "../../interfaces/engine/IAuthorizationEngine.sol";
abstract contract AuthorizationModule is AccessControlUpgradeable {
IAuthorizationEngine private authorizationEngine;
/**
Expand Down
2 changes: 1 addition & 1 deletion contracts/modules/wrapper/controllers/ValidationModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ abstract contract ValidationModule is
@param ruleEngine_ the call will be reverted if the new value of ruleEngine is the same as the current one
*/
function setRuleEngine(
IRuleEngineCMTAT ruleEngine_
IRuleEngine ruleEngine_
) external onlyRole(DEFAULT_ADMIN_ROLE) {
if (ruleEngine == ruleEngine_)
revert Errors.CMTAT_ValidationModule_SameValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ contract CMTATSnapshotStandaloneTest is CMTAT_BASE_SnapshotTest {
uint8 decimalsIrrevocable,
string memory tokenId_,
string memory terms_,
IRuleEngineCMTAT ruleEngine_,
IRuleEngine ruleEngine_,
string memory information_,
uint256 flag_
) MetaTxModule(forwarderIrrevocable) {
Expand Down
4 changes: 2 additions & 2 deletions contracts/test/CMTATSnapshot/CMTAT_BASE_SnapshotTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ abstract contract CMTAT_BASE_SnapshotTest is
uint8 decimalsIrrevocable,
string memory tokenId_,
string memory terms_,
IRuleEngineCMTAT ruleEngine_,
IRuleEngine ruleEngine_,
string memory information_,
uint256 flag_
) public initializer {
Expand Down Expand Up @@ -82,7 +82,7 @@ abstract contract CMTAT_BASE_SnapshotTest is
uint8 decimalsIrrevocable,
string memory tokenId_,
string memory terms_,
IRuleEngineCMTAT ruleEngine_,
IRuleEngine ruleEngine_,
string memory information_,
uint256 flag_
) internal onlyInitializing {
Expand Down
8 changes: 4 additions & 4 deletions doc/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ The instructions below have been tested on Ubuntu 20.04.5 LTS.
The toolchain includes the following components, where the versions
are the latest ones that we tested:

- npm 8.19.2
- npm 10.2.5
- Hardhat-web3 2.0.0
- *Truffle 5.9.3 [depreciated]*
- Solidity 0.8.17 (via solc-js)
- Node 16.17.0
- Solidity 0.8.20 (via solc-js)
- Node 20.5.0
- Web3.js 1.9.0
- OpenZeppelin
- OpenZeppelin Contracts Upgradeable (submodule) [v5.0.0](https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/releases/tag/v5.0.0)
Expand All @@ -30,7 +30,7 @@ Clone the git repository, with the option `--recurse-submodules` to fetch the su

- Node.js version

We recommend to install the [Node Version Manager `nvm`](https://github.com/nvm-sh/nvm) to manage multiple versions of Node.js on your machine. You can then, for example, install the version 16.17.0 of Node.js with the following command: `nvm install 16.17.0`
We recommend to install the [Node Version Manager `nvm`](https://github.com/nvm-sh/nvm) to manage multiple versions of Node.js on your machine. You can then, for example, install the version 20.5.0 of Node.js with the following command: `nvm install 20.5.0`

The file [.nvmrc](../.nvmrc) at the root of the project set the Node.js version. `nvm use`will automatically use this version if no version is supplied on the command line.

Expand Down
Loading

0 comments on commit 6cb947d

Please sign in to comment.