-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
de5fd16
commit 68853f4
Showing
7 changed files
with
129 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
pragma solidity ^0.8.19; | ||
|
||
interface IPaymentsFactoryFunctions { | ||
/** | ||
* Creates a Payments proxy contract | ||
* @param proxyOwner The owner of the Payments proxy | ||
* @param paymentsOwner The owner of the Payments implementation | ||
* @param paymentsSigner The signer of the Payments implementation | ||
* @return proxyAddr The address of the Payments proxy | ||
*/ | ||
function deploy(address proxyOwner, address paymentsOwner, address paymentsSigner) | ||
external | ||
returns (address proxyAddr); | ||
|
||
/** | ||
* Computes the address of a proxy instance. | ||
* @param proxyOwner The owner of the Payments proxy | ||
* @param paymentsOwner The owner of the Payments implementation | ||
* @param paymentsSigner The signer of the Payments implementation | ||
* @return proxyAddr The address of the Payments proxy | ||
*/ | ||
function determineAddress(address proxyOwner, address paymentsOwner, address paymentsSigner) | ||
external | ||
returns (address proxyAddr); | ||
} | ||
|
||
interface IPaymentsFactorySignals { | ||
/** | ||
* Event emitted when a new Payments proxy contract is deployed. | ||
* @param proxyAddr The address of the deployed proxy. | ||
*/ | ||
event PaymentsDeployed(address proxyAddr); | ||
} | ||
|
||
interface IPaymentsFactory is IPaymentsFactoryFunctions, IPaymentsFactorySignals {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
pragma solidity ^0.8.19; | ||
|
||
import {Payments} from "@0xsequence/contracts-library/payments/Payments.sol"; | ||
import { | ||
IPaymentsFactory, IPaymentsFactoryFunctions | ||
} from "@0xsequence/contracts-library/payments/IPaymentsFactory.sol"; | ||
import {SequenceProxyFactory} from "@0xsequence/contracts-library/proxies/SequenceProxyFactory.sol"; | ||
|
||
/** | ||
* Deployer of Payments proxies. | ||
*/ | ||
contract PaymentsFactory is IPaymentsFactory, SequenceProxyFactory { | ||
/** | ||
* Creates an Payments Factory. | ||
* @param factoryOwner The owner of the Payments Factory | ||
*/ | ||
constructor(address factoryOwner) { | ||
Payments impl = new Payments(); | ||
SequenceProxyFactory._initialize(address(impl), factoryOwner); | ||
} | ||
|
||
/// @inheritdoc IPaymentsFactoryFunctions | ||
function deploy(address proxyOwner, address paymentsOwner, address paymentsSigner) | ||
external | ||
returns (address proxyAddr) | ||
{ | ||
bytes32 salt = keccak256(abi.encode(paymentsOwner, paymentsSigner)); | ||
proxyAddr = _createProxy(salt, proxyOwner, ""); | ||
Payments(proxyAddr).initialize(paymentsOwner, paymentsSigner); | ||
emit PaymentsDeployed(proxyAddr); | ||
return proxyAddr; | ||
} | ||
|
||
/// @inheritdoc IPaymentsFactoryFunctions | ||
function determineAddress(address proxyOwner, address paymentsOwner, address paymentsSigner) | ||
external | ||
view | ||
returns (address proxyAddr) | ||
{ | ||
bytes32 salt = keccak256(abi.encode(paymentsOwner, paymentsSigner)); | ||
return _computeProxyAddress(salt, proxyOwner, ""); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters