I have a contract that looks like this
pragma solidity >=0.7.0 <0.9.0;
contract SomeContract {
uint256 public id;
address public creator;
enum Status {ACTIVE, INACTIVE}
Status contractStatus;
modifier checkStatus {
require(contractStatus == Status.ACTIVE);
_;
}
modifier onlyCreator {
require(msg.sender == creator);
_;
}
constructor() {
contractStatus = Status.ACTIVE;
creator = msg.sender;
}
function doSomething() external checkStatus {
// do something here
}
function changeStatus(bool _isActive) external onlyCreator {
if (_isActive) {
contractStatus = Status.ACTIVE;
} else {
contractStatus = Status.INACTIVE;
}
}}
}
This contract works fine. The problem is after I deactivate the contract, people still can access public state variables like id
and creator
because solidity automatically creates a getter for each of these variables. Is there any faster way besides making it internal and creating my own getter and adding a modifier to it?