Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the function kill #221

Merged
merged 6 commits into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions contracts/libraries/Errors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ library Errors {
error CMTAT_SnapshotModule_NoSnapshotScheduled();
error CMTAT_SnapshotModule_SnapshotNotFound();

// OnlyDelegateCallModule
error CMTAT_OnlyDelegateCallModule_DirectCallToImplementation();

// ERC20BaseModule
error CMTAT_ERC20BaseModule_WrongAllowance(
address spender,
Expand Down Expand Up @@ -61,4 +58,7 @@ library Errors {

// AuthorizationModule
error CMTAT_AuthorizationModule_AddressZeroNotAllowed();

// PauseModule
error CMTAT_PauseModule_ContractIsDeactivated();
}
2 changes: 1 addition & 1 deletion contracts/modules/CMTAT_BASE.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ SnapshotModule:
Add this import in case you add the SnapshotModule
import "./wrapper/optional/SnapshotModule.sol";
*/
import "./wrapper/mandatory/PauseModule.sol";
import "./wrapper/optional/ValidationModule.sol";
import "./wrapper/optional/MetaTxModule.sol";
import "./wrapper/optional/DebtModule/DebtBaseModule.sol";
import "./wrapper/optional/DebtModule/CreditEventsModule.sol";
import "./security/AuthorizationModule.sol";
import "./security/PauseModule.sol";
import "../interfaces/IEIP1404/IEIP1404Wrapper.sol";

import "../libraries/Errors.sol";
Expand Down
28 changes: 0 additions & 28 deletions contracts/modules/security/OnlyDelegateCallModule.sol

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

pragma solidity ^0.8.20;

import "../../../../openzeppelin-contracts-upgradeable/contracts/security/PausableUpgradeable.sol";
import "../../../../openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol";
import "../../security/AuthorizationModule.sol";
import "../../../openzeppelin-contracts-upgradeable/contracts/security/PausableUpgradeable.sol";
import "../../../openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol";
import "./AuthorizationModule.sol";

/**
* @dev ERC20 token with pausable token transfers, minting and burning.
Expand All @@ -16,6 +16,8 @@ import "../../security/AuthorizationModule.sol";
abstract contract PauseModule is PausableUpgradeable, AuthorizationModule {
string internal constant TEXT_TRANSFER_REJECTED_PAUSED =
"All transfers paused";
bool private isDeactivated;
event Deactivated(address account);

function __PauseModule_init(address admin) internal onlyInitializing {
/* OpenZeppelin */
Expand Down Expand Up @@ -61,8 +63,29 @@ abstract contract PauseModule is PausableUpgradeable, AuthorizationModule {
* - the caller must have the `PAUSER_ROLE`.
*/
function unpause() public onlyRole(PAUSER_ROLE) {
if(isDeactivated){
revert Errors.CMTAT_PauseModule_ContractIsDeactivated();
}
_unpause();
}

/**
@notice p
Warning: the operation is irreversible, be careful
*/
/// @custom:oz-upgrades-unsafe-allow selfdestruct
function deactivateContract()
public
onlyRole(DEFAULT_ADMIN_ROLE)
{
isDeactivated = true;
_pause();
emit Deactivated(_msgSender());
}

function deactivated() view public returns (bool){
return isDeactivated;
}

uint256[50] private __gap;
}
18 changes: 2 additions & 16 deletions contracts/modules/wrapper/mandatory/BaseModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ pragma solidity ^0.8.20;
// required OZ imports here
import "../../../../openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol";
import "../../security/AuthorizationModule.sol";
import "../../security/OnlyDelegateCallModule.sol";

import "../../../libraries/Errors.sol";

abstract contract BaseModule is AuthorizationModule, OnlyDelegateCallModule {
abstract contract BaseModule is AuthorizationModule {
// to initialize inside the implementation constructor when deployed with a Proxy
bool internal deployedWithProxy;
/* Events */
Expand All @@ -27,6 +25,7 @@ abstract contract BaseModule is AuthorizationModule, OnlyDelegateCallModule {
string public information;
uint256 public flag;


/* Initializers */
/**
* @dev Sets the values for {name} and {symbol}.
Expand Down Expand Up @@ -110,18 +109,5 @@ abstract contract BaseModule is AuthorizationModule, OnlyDelegateCallModule {
emit Flag(flag_);
}

/**
@notice destroys the contract and send the remaining ethers in the contract to the sender
Warning: the operation is irreversible, be careful
*/
/// @custom:oz-upgrades-unsafe-allow selfdestruct
function kill()
public
onlyRole(DEFAULT_ADMIN_ROLE)
onlyDelegateCall(deployedWithProxy)
{
selfdestruct(payable(_msgSender()));
}

uint256[50] private __gap;
}
2 changes: 1 addition & 1 deletion contracts/modules/wrapper/optional/ValidationModule.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/proxy/utils/Initializable.sol";
import "../../security/AuthorizationModule.sol";
import "../../internal/ValidationModuleInternal.sol";
import "../mandatory/PauseModule.sol";
import "../../security/PauseModule.sol";
import "../mandatory/EnforcementModule.sol";

import "../../../libraries/Errors.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/test/CMTATSnapshot/CMTAT_BASE_SnapshotTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ SnapshotModule:
Add this import in case you add the SnapshotModule
*/
import "../../modules/wrapper/optional/SnapshotModule.sol";
import "../../modules/wrapper/mandatory/PauseModule.sol";
import "../../modules/wrapper/optional/ValidationModule.sol";
import "../../modules/wrapper/optional/MetaTxModule.sol";
import "../../modules/wrapper/optional/DebtModule/DebtBaseModule.sol";
import "../../modules/wrapper/optional/DebtModule/CreditEventsModule.sol";
import "../../modules/security/AuthorizationModule.sol";
import "../../modules/security/PauseModule.sol";
import "../../interfaces/IEIP1404/IEIP1404Wrapper.sol";

import "../../libraries/Errors.sol";
Expand Down
109 changes: 0 additions & 109 deletions contracts/test/killTest/BaseModuleTest.sol

This file was deleted.

Loading