-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(contracts): add new forwarder contracts
- Loading branch information
1 parent
f9748f2
commit 6de87a9
Showing
6 changed files
with
132 additions
and
88 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
pragma solidity 0.8.20; | ||
import './ForwarderV4.sol'; | ||
import './CloneFactory.sol'; | ||
|
||
/** | ||
* @title ForwarderFactoryV4 | ||
* @notice This contract will deploy new forwarder contracts using the create2 opcode | ||
*/ | ||
contract ForwarderFactoryV4 is CloneFactory { | ||
address public implementationAddress; | ||
|
||
/** | ||
* @notice Event triggered when a new forwarder is deployed | ||
* @param newForwarderAddress Address of the newly deployed forwarder | ||
* @param parentAddress Address to which the funds should be forwarded | ||
* @param feeAddress Address which is allowed to call methods on forwarder contract alongwith the parentAddress | ||
* @param shouldAutoFlushERC721 Whether to automatically flush ERC721 tokens or not | ||
* @param shouldAutoFlushERC1155 Whether to automatically flush ERC1155 tokens or not | ||
*/ | ||
event ForwarderCreated( | ||
address newForwarderAddress, | ||
address parentAddress, | ||
address feeAddress, | ||
bool shouldAutoFlushERC721, | ||
bool shouldAutoFlushERC1155 | ||
); | ||
|
||
constructor(address _implementationAddress) { | ||
implementationAddress = _implementationAddress; | ||
} | ||
|
||
/** | ||
* @notice Creates a new forwarder contract | ||
* @param parent Address to which the funds should be forwarded | ||
* @param feeAddress Address which is allowed to call methods on forwarder contract alongwith the parentAddress | ||
* @param salt Salt to be used while deploying the contract | ||
*/ | ||
function createForwarder( | ||
address parent, | ||
address feeAddress, | ||
bytes32 salt | ||
) external { | ||
this.createForwarder(parent, feeAddress, salt, true, true); | ||
} | ||
|
||
/** | ||
* @notice Creates a new forwarder contract | ||
* @param parent Address to which the funds should be forwarded | ||
* @param feeAddress Address which is allowed to call methods on forwarder contract alongwith the parentAddress | ||
* @param salt Salt to be used while deploying the contract | ||
* @param shouldAutoFlushERC721 Whether to automatically flush ERC721 tokens or not | ||
* @param shouldAutoFlushERC1155 Whether to automatically flush ERC1155 tokens or not | ||
*/ | ||
function createForwarder( | ||
address parent, | ||
address feeAddress, | ||
bytes32 salt, | ||
bool shouldAutoFlushERC721, | ||
bool shouldAutoFlushERC1155 | ||
) external { | ||
/// include the parent in the salt so any contract deployed directly relies on the parent address | ||
bytes32 finalSalt = keccak256(abi.encodePacked(parent, salt)); | ||
|
||
address payable clone = createClone(implementationAddress, finalSalt); | ||
ForwarderV4(clone).init( | ||
parent, | ||
feeAddress, | ||
shouldAutoFlushERC721, | ||
shouldAutoFlushERC1155 | ||
); | ||
emit ForwarderCreated( | ||
clone, | ||
parent, | ||
feeAddress, | ||
shouldAutoFlushERC721, | ||
shouldAutoFlushERC1155 | ||
); | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
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