I want to take a look at this old OpenZeppellin whitelist contract.:
pragma solidity ^0.5.0;
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v2.1.1/contracts/crowdsale/Crowdsale.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v2.1.1/contracts/access/roles/WhitelistedRole.sol";
/**
* @title WhitelistCrowdsale
* @dev Crowdsale in which only whitelisted users can contribute.
*/
contract WhitelistCrowdsale is WhitelistedRole, Crowdsale {
/**
* @dev Extend parent behavior requiring beneficiary to be whitelisted. Note that no
* restriction is imposed on the account sending the transaction.
* @param _beneficiary Token beneficiary
* @param _weiAmount Amount of wei contributed
*/
function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal view {
require(isWhitelisted(_beneficiary));
super._preValidatePurchase(_beneficiary, _weiAmount);
}
}
When I try to compile I get the following error:
TypeError: Overriding function changes state mutability from "pure" to "view".
Refers to the _preValidatePurchase function
change to view and I get the next:
WhitelistCrowdsale.sol:18:17: TypeError: Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
How can I get out of this absurd loop?
Is it possible that it has to be inherited in a contract that overrides the functions?