Skip to content

Commit

Permalink
Merge pull request #237 from CMTA/remove-init
Browse files Browse the repository at this point in the history
remove init functions in wrapper modules
  • Loading branch information
rya-sge authored Nov 10, 2023
2 parents 94954fb + 1121188 commit e93acaa
Show file tree
Hide file tree
Showing 10 changed files with 4 additions and 210 deletions.
29 changes: 0 additions & 29 deletions contracts/modules/wrapper/controllers/ValidationModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,35 +24,6 @@ abstract contract ValidationModule is
string constant TEXT_TRANSFER_OK = "No restriction";
string constant TEXT_UNKNOWN_CODE = "Unknown code";

function __ValidationModule_init(
IEIP1404Wrapper ruleEngine_,
address admin,
uint48 initialDelayToAcceptAdminRole
) internal onlyInitializing {
/* OpenZeppelin */
__Context_init_unchained();
// AccessControlUpgradeable inherits from ERC165Upgradeable
__ERC165_init_unchained();
__AccessControl_init_unchained();
__AccessControlDefaultAdminRules_init_unchained(initialDelayToAcceptAdminRole, admin);

__Pausable_init_unchained();

/* CMTAT modules */
// Internal
__Validation_init_unchained(ruleEngine_);

// Security
__AuthorizationModule_init_unchained();

// Wrapper
__PauseModule_init_unchained();
__EnforcementModule_init_unchained();

// own function
__ValidationModule_init_unchained();
}

function __ValidationModule_init_unchained() internal onlyInitializing {
// no variable to initialize
}
Expand Down
23 changes: 1 addition & 22 deletions contracts/modules/wrapper/core/BaseModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,35 +29,14 @@ abstract contract BaseModule is AuthorizationModule {
uint256 public flag;



/* Initializers */
/**
* @dev Sets the values for {name} and {symbol}.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
function __Base_init(
string memory tokenId_,
string memory terms_,
string memory information_,
uint256 flag_,
address admin,
uint48 initialDelayToAcceptAdminRole
) internal onlyInitializing {
/* OpenZeppelin */
__Context_init_unchained();
// AccessControlUpgradeable inherits from ERC165Upgradeable
__ERC165_init_unchained();
// AuthorizationModule inherits from AccessControlUpgradeable
__AccessControl_init_unchained();
__AccessControlDefaultAdminRules_init_unchained(initialDelayToAcceptAdminRole, admin);
/* CMTAT modules */
// Security
__AuthorizationModule_init_unchained();
// own function
__Base_init_unchained(tokenId_, terms_, information_, flag_);
}

function __Base_init_unchained(
string memory tokenId_,
string memory terms_,
Expand Down
18 changes: 3 additions & 15 deletions contracts/modules/wrapper/core/ERC20BaseModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,13 @@ abstract contract ERC20BaseModule is ERC20Upgradeable {
uint8 private _decimals;

/* Initializers */

/**
* @dev Sets the values for {name}, {symbol} and decimals.
* @dev Sets the values for decimals.
*
* These values are immutable: they can only be set once during
* this value is immutable: it can only be set once during
* construction/initialization.
*/
function __ERC20Module_init(
string memory name_,
string memory symbol_,
uint8 decimals_
) internal onlyInitializing {
/* OpenZeppelin */
__Context_init_unchained();
__ERC20_init(name_, symbol_);

/* own function */
__ERC20Module_init_unchained(decimals_);
}

function __ERC20Module_init_unchained(
uint8 decimals_
) internal onlyInitializing {
Expand Down
22 changes: 0 additions & 22 deletions contracts/modules/wrapper/core/ERC20BurnModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,6 @@ abstract contract ERC20BurnModule is ERC20Upgradeable, AuthorizationModule {
*/
event Burn(address indexed owner, uint256 value, string reason);

function __ERC20BurnModule_init(
string memory name_,
string memory symbol_,
address admin,
uint48 initialDelayToAcceptAdminRole
) internal onlyInitializing {
/* OpenZeppelin */
__Context_init_unchained();
__ERC20_init_unchained(name_, symbol_);
// AccessControlUpgradeable inherits from ERC165Upgradeable
__ERC165_init_unchained();
// AuthorizationModule inherits from AccessControlUpgradeable
__AccessControl_init_unchained();
__AccessControlDefaultAdminRules_init_unchained( initialDelayToAcceptAdminRole, admin);
/* CMTAT modules */
// Security
__AuthorizationModule_init_unchained();

// own function
__ERC20BurnModule_init_unchained();
}

function __ERC20BurnModule_init_unchained() internal onlyInitializing {
// no variable to initialize
}
Expand Down
22 changes: 0 additions & 22 deletions contracts/modules/wrapper/core/ERC20MintModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,6 @@ abstract contract ERC20MintModule is ERC20Upgradeable, AuthorizationModule {
*/
event Mint(address indexed account, uint256 value);

function __ERC20MintModule_init(
string memory name_,
string memory symbol_,
address admin,
uint48 initialDelayToAcceptAdminRole
) internal onlyInitializing {
/* OpenZeppelin */
__Context_init_unchained();
__ERC20_init_unchained(name_, symbol_);
// AccessControlUpgradeable inherits from ERC165Upgradeable
__ERC165_init_unchained();
// AuthorizationModule inherits from AccessControlUpgradeable
__AccessControl_init_unchained();
__AccessControlDefaultAdminRules_init_unchained(initialDelayToAcceptAdminRole, admin);
/* CMTAT modules */
// Security
__AuthorizationModule_init_unchained();

// own function
__ERC20MintModule_init_unchained();
}

function __ERC20MintModule_init_unchained() internal onlyInitializing {
// no variable to initialize
}
Expand Down
19 changes: 0 additions & 19 deletions contracts/modules/wrapper/core/EnforcementModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,6 @@ abstract contract EnforcementModule is
string internal constant TEXT_TRANSFER_REJECTED_TO_FROZEN =
"The address TO is frozen";

function __EnforcementModule_init(address admin, uint48 initialDelayToAcceptAdminRole) internal onlyInitializing {
/* OpenZeppelin */
__Context_init_unchained();
// AccessControlUpgradeable inherits from ERC165Upgradeable
__ERC165_init_unchained();
// AuthorizationModule inherits from AccessControlUpgradeable
__AccessControl_init_unchained();
__AccessControlDefaultAdminRules_init_unchained(initialDelayToAcceptAdminRole, admin);
/* CMTAT modules */
// Internal
__Enforcement_init_unchained();

// Security
__AuthorizationModule_init_unchained();

// own function
__EnforcementModule_init_unchained();
}

function __EnforcementModule_init_unchained() internal onlyInitializing {
// no variable to initialize
}
Expand Down
17 changes: 0 additions & 17 deletions contracts/modules/wrapper/core/PauseModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,6 @@ abstract contract PauseModule is PausableUpgradeable, AuthorizationModule {
bool private isDeactivated;
event Deactivated(address account);

function __PauseModule_init(address admin, uint48 initialDelayToAcceptAdminRole) internal onlyInitializing {
/* OpenZeppelin */
__Context_init_unchained();
__Pausable_init_unchained();
// AccessControlUpgradeable inherits from ERC165Upgradeable
__ERC165_init_unchained();
// AuthorizationModule inherits from AccessControlUpgradeable
__AccessControl_init_unchained();
__AccessControlDefaultAdminRules_init_unchained(initialDelayToAcceptAdminRole, admin);
/* CMTAT modules */
// Security
__AuthorizationModule_init_unchained();

// own function
__PauseModule_init_unchained();
}

function __PauseModule_init_unchained() internal onlyInitializing {
// no variable to initialize
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,6 @@ abstract contract CreditEventsModule is
event FlagRedeemed(bool indexed newFlagRedeemed);
event Rating(string indexed newRatingIndexed, string newRating);

function __CreditEvents_init(
address admin,
uint48 initialDelayToAcceptAdminRole) internal onlyInitializing {
/* OpenZeppelin */
__Context_init_unchained();

// AccessControlUpgradeable inherits from ERC165Upgradeable
__ERC165_init_unchained();
// AuthorizationModule inherits from AccessControlUpgradeable
__AccessControl_init_unchained();
__AccessControlDefaultAdminRules_init_unchained(initialDelayToAcceptAdminRole, admin);
/* CMTAT modules */
// Security
__AuthorizationModule_init_unchained();

// own function
__CreditEvents_init_unchained();
}

function __CreditEvents_init_unchained() internal onlyInitializing {
// no variable to initialize
}
Expand Down
19 changes: 0 additions & 19 deletions contracts/modules/wrapper/extensions/DebtModule/DebtBaseModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -55,25 +55,6 @@ abstract contract DebtBaseModule is
string newCouponFrequency
);

function __DebtBaseModule_init(
address admin,
uint48 initialDelayToAcceptAdminRole) internal onlyInitializing {
/* OpenZeppelin */
__Context_init_unchained();

// AccessControlUpgradeable inherits from ERC165Upgradeable
__ERC165_init_unchained();
// AuthorizationModule inherits from AccessControlUpgradeable
__AccessControl_init_unchained();
__AccessControlDefaultAdminRules_init_unchained(initialDelayToAcceptAdminRole, admin);
/* CMTAT modules */
// Security
__AuthorizationModule_init_unchained();

// own function
__DebtBaseModule_init_unchained();
}

function __DebtBaseModule_init_unchained() internal onlyInitializing {
// no variable to initialize
}
Expand Down
26 changes: 0 additions & 26 deletions contracts/modules/wrapper/extensions/ERC20SnapshotModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,6 @@ abstract contract ERC20SnapshotModule is
ERC20SnapshotModuleInternal,
AuthorizationModule
{
function __ERC20SnasphotModule_init(
string memory name_,
string memory symbol_,
address admin,
uint48 initialDelayToAcceptAdminRole
) internal onlyInitializing {
/* OpenZeppelin */
__Context_init_unchained();
// SnapshotModuelInternal inherits from ERC20
__ERC20_init_unchained(name_, symbol_);
// AccessControlUpgradeable inherits from ERC165Upgradeable
__ERC165_init_unchained();
// AuthorizationModule inherits from AccessControlUpgradeable
__AccessControl_init_unchained();
__AccessControlDefaultAdminRules_init_unchained(initialDelayToAcceptAdminRole, admin);
/* CMTAT modules */
// Internal
__ERC20Snapshot_init_unchained();

// Security
__AuthorizationModule_init_unchained();

// own function
__ERC20SnasphotModule_init_unchained();
}

function __ERC20SnasphotModule_init_unchained() internal onlyInitializing {
// no variable to initialize
}
Expand Down

0 comments on commit e93acaa

Please sign in to comment.