-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSimplePaymentSplitterFactory.sol
30 lines (22 loc) · 1.07 KB
/
SimplePaymentSplitterFactory.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;
import { SimplePaymentSplitter } from "./SimplePaymentSplitter.sol";
import { ProxySingleton } from "../proxy/ProxySingleton.sol";
/** Simple factory. Deploy factory once, then easily deploy new */
contract SimplePaymentSplitterFactory {
address public immutable implementation;
event SimplePaymentSplitterCreated(address indexed splitter);
constructor() {
address[] memory payees = new address[](1);
payees[0] = msg.sender;
uint256[] memory shares = new uint256[](1);
shares[0] = 1;
implementation = address(new SimplePaymentSplitter(payees, shares));
}
function create(address[] calldata payees, uint256[] calldata shares) external payable returns (SimplePaymentSplitter splitter) {
splitter = SimplePaymentSplitter(payable(new ProxySingleton(implementation, "")));
splitter.initialize(payees, shares);
if (msg.value > 0) splitter.addPayment{value: msg.value}(msg.sender);
emit SimplePaymentSplitterCreated(address(splitter));
}
}