ConditionalEscrow.sol 802 B

123456789101112131415161718192021222324
  1. // SPDX-License-Identifier: MIT
  2. pragma solidity ^0.7.0;
  3. import "./Escrow.sol";
  4. /**
  5. * @title ConditionalEscrow
  6. * @dev Base abstract escrow to only allow withdrawal if a condition is met.
  7. * @dev Intended usage: See {Escrow}. Same usage guidelines apply here.
  8. */
  9. abstract contract ConditionalEscrow is Escrow {
  10. /**
  11. * @dev Returns whether an address is allowed to withdraw their funds. To be
  12. * implemented by derived contracts.
  13. * @param payee The destination address of the funds.
  14. */
  15. function withdrawalAllowed(address payee) public view virtual returns (bool);
  16. function withdraw(address payable payee) public virtual override {
  17. require(withdrawalAllowed(payee), "ConditionalEscrow: payee is not allowed to withdraw");
  18. super.withdraw(payee);
  19. }
  20. }