Skip to content

Commit

Permalink
feat(payment-escrow): improve escrow
Browse files Browse the repository at this point in the history
  • Loading branch information
thongxuan committed Mar 29, 2024
1 parent 9fa798f commit 4577451
Show file tree
Hide file tree
Showing 6 changed files with 204 additions and 289 deletions.
117 changes: 0 additions & 117 deletions contracts/payment/escrow/ILemonadeEscrow.sol

This file was deleted.

9 changes: 0 additions & 9 deletions contracts/payment/escrow/ILemonadeEscrowFactory.sol

This file was deleted.

66 changes: 66 additions & 0 deletions contracts/payment/escrow/LemonadeEscrowFactory.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";

import "./LemonadeEscrowV1.sol";

contract LemonadeEscrowFactory is OwnableUpgradeable {
address public registry;
uint256 public feeAmount;

event EscrowCreated(address escrow, uint256 fee);

error CannotPayFee();
error NotOwner();

function initialize(
address _registry,
uint256 _feeAmount
) public initializer {
__Ownable_init();

registry = _registry;
feeAmount = _feeAmount;
}

function createEscrow(
address owner,
address[] memory delegates,
address[] memory payees,
uint256[] memory shares,
uint16 hostRefundPercent,
RefundPolicy[] memory refundPolicies
) external payable {
if (feeAmount > 0) {
PaymentConfigRegistry registry_ = PaymentConfigRegistry(registry);

(bool success, ) = payable(registry_.feeVault()).call{
value: feeAmount
}("");

if (!success) revert CannotPayFee();
}

LemonadeEscrowV1 escrow = new LemonadeEscrowV1(
registry,
owner,
delegates,
payees,
shares,
hostRefundPercent,
refundPolicies
);

emit EscrowCreated(address(escrow), feeAmount);
}

function setFeeAmount(uint256 _feeAmount) public onlyOwner {
feeAmount = _feeAmount;
}

function _checkOwner() internal view virtual override {
if (owner() != _msgSender()) revert NotOwner();
}
}
72 changes: 0 additions & 72 deletions contracts/payment/escrow/LemonadeEscrowFactoryV1.sol

This file was deleted.

Loading

0 comments on commit 4577451

Please sign in to comment.