Skip to content

Commit

Permalink
add validations
Browse files Browse the repository at this point in the history
  • Loading branch information
andresaiello committed Nov 6, 2024
1 parent 188c136 commit 98dd76c
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ contract InstantRewardsFactory is Ownable2Step {
bool public allowPublicCreation = false;

error AccessDenied();
error InvalidSignerAddress();
error EmptyName();
error StartTimeInPast();
error EndTimeBeforeStart();

event InstantRewardsCreated(address indexed instantRewards, address indexed owner);

constructor(address owner) Ownable() {
Expand All @@ -24,6 +29,11 @@ contract InstantRewardsFactory is Ownable2Step {
uint256 end,
string memory name
) external returns (address) {
if (signerAddress == address(0)) revert InvalidSignerAddress();
if (bytes(name).length == 0) revert EmptyName();
if (start < block.timestamp) revert StartTimeInPast();
if (end <= start) revert EndTimeBeforeStart();

bool isOwner = owner() == msg.sender;
if (!allowPublicCreation && !isOwner) revert AccessDenied();

Expand Down

0 comments on commit 98dd76c

Please sign in to comment.