Make view and pure functions virtual (#2473)

Co-authored-by: Francisco Giordano <frangio.1@gmail.com>
This commit is contained in:
Hadrien Croubois
2021-01-26 17:23:23 +01:00
committed by GitHub
parent 0931062a3f
commit 18c7efe800
24 changed files with 122 additions and 112 deletions

View File

@ -36,14 +36,14 @@ contract RefundEscrow is ConditionalEscrow {
/**
* @return The current state of the escrow.
*/
function state() public view returns (State) {
function state() public view virtual returns (State) {
return _state;
}
/**
* @return The beneficiary of the escrow.
*/
function beneficiary() public view returns (address) {
function beneficiary() public view virtual returns (address payable) {
return _beneficiary;
}
@ -52,7 +52,7 @@ contract RefundEscrow is ConditionalEscrow {
* @param refundee The address funds will be sent to if a refund occurs.
*/
function deposit(address refundee) public payable virtual override {
require(_state == State.Active, "RefundEscrow: can only deposit while active");
require(state() == State.Active, "RefundEscrow: can only deposit while active");
super.deposit(refundee);
}
@ -60,8 +60,8 @@ contract RefundEscrow is ConditionalEscrow {
* @dev Allows for the beneficiary to withdraw their funds, rejecting
* further deposits.
*/
function close() public onlyOwner virtual {
require(_state == State.Active, "RefundEscrow: can only close while active");
function close() public virtual onlyOwner {
require(state() == State.Active, "RefundEscrow: can only close while active");
_state = State.Closed;
emit RefundsClosed();
}
@ -70,7 +70,7 @@ contract RefundEscrow is ConditionalEscrow {
* @dev Allows for refunds to take place, rejecting further deposits.
*/
function enableRefunds() public onlyOwner virtual {
require(_state == State.Active, "RefundEscrow: can only enable refunds while active");
require(state() == State.Active, "RefundEscrow: can only enable refunds while active");
_state = State.Refunding;
emit RefundsEnabled();
}
@ -79,8 +79,8 @@ contract RefundEscrow is ConditionalEscrow {
* @dev Withdraws the beneficiary's funds.
*/
function beneficiaryWithdraw() public virtual {
require(_state == State.Closed, "RefundEscrow: beneficiary can only withdraw while closed");
_beneficiary.sendValue(address(this).balance);
require(state() == State.Closed, "RefundEscrow: beneficiary can only withdraw while closed");
beneficiary().sendValue(address(this).balance);
}
/**
@ -88,6 +88,6 @@ contract RefundEscrow is ConditionalEscrow {
* 'payee' argument, but we ignore it here since the condition is global, not per-payee.
*/
function withdrawalAllowed(address) public view override returns (bool) {
return _state == State.Refunding;
return state() == State.Refunding;
}
}