Skip to content

Commit

Permalink
Merge pull request #221 from CMTA/remove-kill
Browse files Browse the repository at this point in the history
Remove the function kill
  • Loading branch information
rya-sge authored Sep 4, 2023
2 parents 41edba6 + 2565334 commit 4b11c22
Show file tree
Hide file tree
Showing 18 changed files with 418 additions and 514 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ node_modules
build
coverage
coverage.json
bin/*
#exception
!doc/general/test/coverage
/.openzeppelin
Expand Down
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,12 +2,15 @@

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.
*
* @dev Put in pause or deactivate the contract
* The issuer must be able to “pause” the smart contract,
* to prevent execution of transactions on the distributed ledger until the issuer puts an end to the pause.
*
* Useful for scenarios such as preventing trades until the end of an evaluation
* period, or having an emergency switch for freezing all token transfers in the
Expand All @@ -16,6 +19,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, uint48 initialDelayToAcceptAdminRole) internal onlyInitializing {
/* OpenZeppelin */
Expand All @@ -39,30 +44,58 @@ abstract contract PauseModule is PausableUpgradeable, AuthorizationModule {
}

/**
* @dev Pauses all token transfers.
*
* See {ERC20Pausable} and {Pausable-_pause}.
* @notice Pauses all token transfers.
* @dev See {ERC20Pausable} and {Pausable-_pause}.
*
* Requirements:
*
* - the caller must have the `PAUSER_ROLE`.
*
*/
function pause() public onlyRole(PAUSER_ROLE) {
_pause();
}

/**
* @dev Unpauses all token transfers.
*
* See {ERC20Pausable} and {Pausable-_unpause}.
* @notice Unpauses all token transfers.
* @dev See {ERC20Pausable} and {Pausable-_unpause}.
*
* Requirements:
*
* - the caller must have the `PAUSER_ROLE`.
*/
function unpause() public onlyRole(PAUSER_ROLE) {
if(isDeactivated){
revert Errors.CMTAT_PauseModule_ContractIsDeactivated();
}
_unpause();
}

/**
* @notice deactivate the contract
* Warning: the operation is irreversible, be careful
* @dev
* Emits a {Deactivated} event indicating that the contract has been deactivated.
* Requirements:
*
* - the caller must have the `DEFAULT_ADMIN_ROLE`.
*/
/// @custom:oz-upgrades-unsafe-allow selfdestruct
function deactivateContract()
public
onlyRole(DEFAULT_ADMIN_ROLE)
{
isDeactivated = true;
_pause();
emit Deactivated(_msgSender());
}

/**
* @notice Returns true if the contract is deactivated, and false otherwise.
*/
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

0 comments on commit 4b11c22

Please sign in to comment.