-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #186 from corpus-io/feature/cloneContinuousFundrai…
…sing Feature/clone continuous fundraising
- Loading branch information
Showing
12 changed files
with
751 additions
and
218 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity 0.8.17; | ||
|
||
import "./ContinuousFundraising.sol"; | ||
import "./CloneFactory.sol"; | ||
import "@openzeppelin/contracts/proxy/Clones.sol"; | ||
|
||
contract ContinuousFundraisingCloneFactory is CloneFactory { | ||
constructor(address _implementation) CloneFactory(_implementation) {} | ||
|
||
function createContinuousFundraisingClone( | ||
bytes32 _rawSalt, | ||
address _trustedForwarder, | ||
address _owner, | ||
address _currencyReceiver, | ||
uint256 _minAmountPerBuyer, | ||
uint256 _maxAmountPerBuyer, | ||
uint256 _tokenPrice, | ||
uint256 _maxAmountOfTokenToBeSold, | ||
IERC20 _currency, | ||
Token _token | ||
) external returns (address) { | ||
bytes32 salt = keccak256( | ||
abi.encodePacked( | ||
_rawSalt, | ||
_trustedForwarder, | ||
_owner, | ||
_currencyReceiver, | ||
_minAmountPerBuyer, | ||
_maxAmountPerBuyer, | ||
_tokenPrice, | ||
_maxAmountOfTokenToBeSold, | ||
_currency, | ||
_token | ||
) | ||
); | ||
address clone = Clones.cloneDeterministic(implementation, salt); | ||
ContinuousFundraising continuousFundraising = ContinuousFundraising(clone); | ||
require( | ||
continuousFundraising.isTrustedForwarder(_trustedForwarder), | ||
"ContinuousFundraisingCloneFactory: Unexpected trustedForwarder" | ||
); | ||
continuousFundraising.initialize( | ||
_owner, | ||
_currencyReceiver, | ||
_minAmountPerBuyer, | ||
_maxAmountPerBuyer, | ||
_tokenPrice, | ||
_maxAmountOfTokenToBeSold, | ||
_currency, | ||
_token | ||
); | ||
emit NewClone(clone); | ||
return clone; | ||
} | ||
|
||
function predictCloneAddress( | ||
bytes32 _rawSalt, | ||
address _trustedForwarder, | ||
address _owner, | ||
address _currencyReceiver, | ||
uint256 _minAmountPerBuyer, | ||
uint256 _maxAmountPerBuyer, | ||
uint256 _tokenPrice, | ||
uint256 _maxAmountOfTokenToBeSold, | ||
IERC20 _currency, | ||
Token _token | ||
) external view returns (address) { | ||
bytes32 salt = keccak256( | ||
abi.encodePacked( | ||
_rawSalt, | ||
_trustedForwarder, | ||
_owner, | ||
_currencyReceiver, | ||
_minAmountPerBuyer, | ||
_maxAmountPerBuyer, | ||
_tokenPrice, | ||
_maxAmountOfTokenToBeSold, | ||
_currency, | ||
_token | ||
) | ||
); | ||
return Clones.predictDeterministicAddress(implementation, salt); | ||
} | ||
} |
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
Oops, something went wrong.