Skip to content

Commit

Permalink
Improve comments
Browse files Browse the repository at this point in the history
  • Loading branch information
rya-sge committed Aug 12, 2024
1 parent 4f45a2a commit 1b6bcc6
Show file tree
Hide file tree
Showing 18 changed files with 79 additions and 796 deletions.
23 changes: 15 additions & 8 deletions contracts/deployment/CMTAT_BEACON_FACTORY.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ contract CMTAT_BEACON_FACTORY is AccessControl, CMTATFactoryRoot {
beacon = new UpgradeableBeacon(implementation_, beaconOwner);
}

/*//////////////////////////////////////////////////////////////
PUBLIC/EXTERNAL FUNCTIONS
//////////////////////////////////////////////////////////////*/
/**
* @notice deploy CMTAT with a beacon proxy
*
Expand Down Expand Up @@ -63,6 +66,18 @@ contract CMTAT_BEACON_FACTORY is AccessControl, CMTATFactoryRoot {
return Create2.computeAddress(deploymentSalt, keccak256(bytecode), address(this) );
}

/**
* @notice get the implementation address from the beacon
* @return implementation address
*/
function implementation() public view returns (address) {
return beacon.implementation();
}

/*//////////////////////////////////////////////////////////////
INTERNAL FUNCTIONS
//////////////////////////////////////////////////////////////*/

/**
* @notice Deploy CMTAT and push the created CMTAT in the list
*/
Expand Down Expand Up @@ -92,12 +107,4 @@ contract CMTAT_BEACON_FACTORY is AccessControl, CMTATFactoryRoot {
);
bytecode = abi.encodePacked(type(BeaconProxy).creationCode, abi.encode(address(beacon), _implementation));
}

/**
* @notice get the implementation address from the beacon
* @return implementation address
*/
function implementation() public view returns (address) {
return beacon.implementation();
}
}
14 changes: 12 additions & 2 deletions contracts/deployment/CMTAT_TP_FACTORY.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@ import "./libraries/CMTATFactoryBase.sol";
* @notice Factory to deploy CMTAT with a transparent proxy
*
*/
contract CMTAT_TP_FACTORY is CMTATFactoryInvariant, CMTATFactoryBase {
contract CMTAT_TP_FACTORY is CMTATFactoryBase {

constructor(address logic_, address factoryAdmin, bool useCustomSalt_) CMTATFactoryBase(logic_, factoryAdmin,useCustomSalt_){}
/**

/*//////////////////////////////////////////////////////////////
PUBLIC/EXTERNAL FUNCTIONS
//////////////////////////////////////////////////////////////*/
/**
* @notice deploy a transparent proxy with a proxy admin contract
*/
function deployCMTAT(
Expand Down Expand Up @@ -49,6 +53,12 @@ contract CMTAT_TP_FACTORY is CMTATFactoryInvariant, CMTATFactoryBase {
return Create2.computeAddress(deploymentSalt, keccak256(bytecode), address(this) );
}


/*//////////////////////////////////////////////////////////////
INTERNAL FUNCTIONS
//////////////////////////////////////////////////////////////*/


/**
* @notice Deploy CMTAT and push the created CMTAT in the list
*/
Expand Down
5 changes: 4 additions & 1 deletion contracts/deployment/CMTAT_UUPS_FACTORY.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@ import "./libraries/CMTATFactoryBase.sol";
* @notice Factory to deploy CMTAT with a UUPS proxy
*
*/
contract CMTAT_UUPS_FACTORY is CMTATFactoryInvariant, CMTATFactoryBase {
contract CMTAT_UUPS_FACTORY is CMTATFactoryBase {
/**
* @param logic_ contract implementation
* @param factoryAdmin admin
*/
constructor(address logic_, address factoryAdmin, bool useCustomSalt_) CMTATFactoryBase(logic_, factoryAdmin,useCustomSalt_){}


/*//////////////////////////////////////////////////////////////
PUBLIC/EXTERNAL FUNCTIONS
//////////////////////////////////////////////////////////////*/
/**
* @notice deploy a transparent proxy with a proxy admin contract
*/
Expand Down
3 changes: 2 additions & 1 deletion contracts/deployment/libraries/CMTATFactoryBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import "./CMTATFactoryRoot.sol";
*
*/
abstract contract CMTATFactoryBase is CMTATFactoryRoot {
// Public
/* ============ State Variables ============ */
address public immutable logic;
/* ============ Constructor ============ */
/**
* @param logic_ contract implementation
* @param factoryAdmin admin
Expand Down
8 changes: 5 additions & 3 deletions contracts/deployment/libraries/CMTATFactoryInvariant.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,20 @@ pragma solidity ^0.8.20;
import "../../interfaces/ICMTATConstructor.sol";

/**
* @notice Factory to deploy CMTAT with a transparent proxy
* @notice List of Invariant (struct, constant, events)
*
*/
abstract contract CMTATFactoryInvariant {
/// @dev Role to deploy CMTAT
bytes32 public constant CMTAT_DEPLOYER_ROLE = keccak256("CMTAT_DEPLOYER_ROLE");
/* ============ Structs ============ */
struct CMTAT_ARGUMENT{
address CMTATAdmin;
ICMTATConstructor.ERC20Attributes ERC20Attributes;
ICMTATConstructor.BaseModuleAttributes baseModuleAttributes;
ICMTATConstructor.Engine engines;
}
/* ============ State Variables ============ */
/// @dev Role to deploy CMTAT
bytes32 public constant CMTAT_DEPLOYER_ROLE = keccak256("CMTAT_DEPLOYER_ROLE");
/* ============ Events ============ */
event CMTAT(address indexed CMTAT, uint256 id);
}
12 changes: 12 additions & 0 deletions contracts/deployment/libraries/CMTATFactoryRoot.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@ import "./CMTATFactoryInvariant.sol";
*
*/
abstract contract CMTATFactoryRoot is AccessControl, CMTATFactoryInvariant {
/* ============ State Variables ============ */
// Public
address[] public cmtatsList;
bool public useCustomSalt;
uint256 public cmtatCounterId;
/// mapping
mapping(uint256 => address) internal cmtats;
mapping(bytes32 => bool) internal customSaltUsed;

/* ============ Constructor ============ */
/**
* @param factoryAdmin admin
*/
Expand All @@ -33,13 +36,22 @@ abstract contract CMTATFactoryRoot is AccessControl, CMTATFactoryInvariant {
_grantRole(CMTAT_DEPLOYER_ROLE, factoryAdmin);
}


/*//////////////////////////////////////////////////////////////
PUBLIC/EXTERNAL FUNCTIONS
//////////////////////////////////////////////////////////////*/

/**
* @notice get CMTAT proxy address
*
*/
function CMTATProxyAddress(uint256 cmtatCounterId_) external view returns (address) {
return cmtats[cmtatCounterId_];
}

/*//////////////////////////////////////////////////////////////
INTERNAL FUNCTIONS
//////////////////////////////////////////////////////////////*/

/**
* @param deploymentSalt salt for deployment
Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/ICMTATSnapshot.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
pragma solidity ^0.8.20;

/**
* @notice interface to represent a CMTAT with snapshot
* @notice minimum interface to represent a CMTAT with snapshot
*/
interface ICMTATSnapshot {
/**
Expand Down
3 changes: 3 additions & 0 deletions contracts/interfaces/engine/IAuthorizationEngine.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

pragma solidity ^0.8.20;

/*
* @dev minimum interface to define an AuthorizationEngine
*/
interface IAuthorizationEngine {
/**
* @dev Returns true if the operation is authorized, and false otherwise.
Expand Down
5 changes: 4 additions & 1 deletion contracts/interfaces/engine/IDebtEngine.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
// SPDX-License-Identifier: MPL-2.0

pragma solidity ^0.8.20;
import "../IDebtGlobal.sol";
import "./IDebtGlobal.sol";

/*
* @dev minimum interface to define a DebtEngine
*/
interface IDebtEngine is IDebtGlobal {
/**
* @dev Returns debt information
Expand Down
File renamed without changes.
3 changes: 3 additions & 0 deletions contracts/interfaces/engine/IRuleEngine.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ pragma solidity ^0.8.20;

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

/*
* @dev minimum interface to define a RuleEngine
*/
interface IRuleEngine is IERC1404Wrapper {
/**
* @dev Returns true if the operation is a success, and false otherwise.
Expand Down
3 changes: 3 additions & 0 deletions contracts/libraries/Errors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

pragma solidity ^0.8.20;

/*
* @dev CMTAT custom errors
*/
library Errors {
// CMTAT
error CMTAT_InvalidTransfer(address from, address to, uint256 amount);
Expand Down
3 changes: 3 additions & 0 deletions contracts/libraries/FactoryErrors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

pragma solidity ^0.8.20;

/*
* @dev Factory contract custom errors
*/
library FactoryErrors {
error CMTAT_Factory_AddressZeroNotAllowedForFactoryAdmin();
error CMTAT_Factory_AddressZeroNotAllowedForBeaconOwner();
Expand Down
3 changes: 3 additions & 0 deletions contracts/mocks/DebtEngineMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ interface IDebtEngineMock is IDebtEngine {
function setCreditEvents(CreditEvents calldata creditEvents) external;
}

/*
* @title a DebtEngine mock for testing, not suitable for production
*/
contract DebtEngineMock is IDebtEngineMock {
DebtBase private _debt;
CreditEvents private _creditEvents;
Expand Down
8 changes: 5 additions & 3 deletions contracts/mocks/DocumentEngineMock.sol
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@

// SPDX-License-Identifier: MPL-2.0
pragma solidity ^0.8.20;
interface IERC1643Whole {
import "../interfaces/engine/draft-IERC1643.sol";
interface IERC1643Whole is IERC1643{

// Document Management
function getDocument(bytes32 _name) external view returns (string memory, bytes32, uint256);
function setDocument(bytes32 _name, string memory _uri, bytes32 _documentHash) external;
function removeDocument(bytes32 _name) external;
function getAllDocuments() external view returns (bytes32[] memory);

// Document Events
event DocumentRemoved(bytes32 indexed _name, string _uri, bytes32 _documentHash);
event DocumentUpdated(bytes32 indexed _name, string _uri, bytes32 _documentHash);

}
/*
* @title a DocumentEngine mock for testing, not suitable for production
*/
contract DocumentEngineMock is IERC1643Whole {
struct Document {
string uri;
Expand Down
3 changes: 3 additions & 0 deletions contracts/mocks/MinimalForwarderMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ pragma solidity ^0.8.20;

import "@openzeppelin/contracts-upgradeable/metatx/ERC2771ForwarderUpgradeable.sol";

/*
* @title a MinimalForwarderMock for testing, not suitable for production
*/
contract MinimalForwarderMock is ERC2771ForwarderUpgradeable {
function initialize(string memory name) public initializer {
__EIP712_init_unchained(name, "1");
Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/RuleEngine/RuleEngineMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import "./interfaces/IRuleEngineMock.sol";
import "./RuleMock.sol";

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

0 comments on commit 1b6bcc6

Please sign in to comment.