I'm trying to implement the Pauseable functionality to my upgradeable contract to use with Defender.
I must do something wrong because Defender is not picking up the Pausable feature and shows;
Defender Admin could not determine whether this contract is pauseable. For a contract to be detected as pauseable by Defender, the provided ABI needs to specify a
pause()
function.You can still add this contract to Defender Admin and run admin operations on it.
The doc mention using a Pausable() argument in the constructor. But what happens when we are using the initializer instead?
This is what I'm trying;
// contracts/MyContract.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
// Imports from the OpenZeppelin Contracts library
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/utils/math/SafeMathUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
contract MyContract is Initializable, PausableUpgradeable {
using SafeMathUpgradeable for uint;
uint256 private value;
address private admin;
/// @notice Events
event ValueChanged(uint256 newValue);
/// @notice initialize.
/// @dev Upgradable Contract constructor
function initialize(address _admin) public initializer {
admin = _admin;
}
/// @notice store.
/// @dev update the trading fees
/// @param newValue uint
function store(uint256 newValue) public whenNotPaused{
value = newValue;
emit ValueChanged(newValue);
}
/// @notice retreive.
/// @dev return value
function retrieve() public view returns (uint256) {
return value;
}
/// @notice pause
/// @dev pause the contract
function pause() public whenNotPaused{
_pause();
}
}
Anyone know what I am missing?