Merge branch 'solc-0.7' into solc-0.8

This commit is contained in:
Hadrien Croubois
2021-01-27 11:16:05 +01:00
77 changed files with 2301 additions and 1859 deletions

View File

@ -2,7 +2,9 @@
pragma solidity ^0.8.0;
import "../GSN/Context.sol";
import "../utils/Context.sol";
import "../math/SafeMath.sol";
import "../utils/Address.sol";
/**
* @title PaymentSplitter
@ -109,7 +111,7 @@ contract PaymentSplitter is Context {
_released[account] = _released[account] + payment;
_totalReleased = _totalReleased + payment;
account.transfer(payment);
Address.sendValue(account, payment);
emit PaymentReleased(account, payment);
}

View File

@ -34,7 +34,7 @@ contract Escrow is Ownable {
* @dev Stores the sent amount as credit to be withdrawn.
* @param payee The destination address of the funds.
*/
function deposit(address payee) public virtual payable onlyOwner {
function deposit(address payee) public payable virtual onlyOwner {
uint256 amount = msg.value;
_deposits[payee] = _deposits[payee] + amount;

View File

@ -15,6 +15,8 @@ import "./ConditionalEscrow.sol";
* with `RefundEscrow` will be made through the owner contract.
*/
contract RefundEscrow is ConditionalEscrow {
using Address for address payable;
enum State { Active, Refunding, Closed }
event RefundsClosed();
@ -36,14 +38,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 +54,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 +62,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 +72,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 +81,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.transfer(address(this).balance);
require(state() == State.Closed, "RefundEscrow: beneficiary can only withdraw while closed");
beneficiary().sendValue(address(this).balance);
}
/**
@ -88,6 +90,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;
}
}