Skip to content

Instantly share code, notes, and snippets.

@Turupawn
Created October 31, 2021 00:46
Show Gist options
  • Save Turupawn/22222abc76954475a74e19166ee809c9 to your computer and use it in GitHub Desktop.
Save Turupawn/22222abc76954475a74e19166ee809c9 to your computer and use it in GitHub Desktop.
// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";
import "@chainlink/contracts/src/v0.8/interfaces/KeeperCompatibleInterface.sol";
contract MunonFactory {
uint256 public hackathon_count;
function createHackathon(
string memory _name,
string memory image_hash,
uint256 _entry_fee,
string[] memory metrics
) public{}
function enableHackathonReview(uint256 hackathon_id)
public {}
function finishHackathon(uint256 hackathon_id)
public {}
}
contract MunonAutomater is KeeperCompatibleInterface {
uint public counter = 0;
uint public immutable interval = 60;
uint public lastTimeStamp = block.timestamp;
MunonFactory munon_factory = MunonFactory(0x49f524BB56cB060A0Ae669fBF256156add74FE66);
mapping(uint => uint) public hackathon_reivew_time;
mapping(uint => uint) public hackathon_finish_time;
function createHackathon(
string memory name,
string memory image_hash,
uint entry_fee,
string[] memory metrics,
uint review_time,
uint finish_time
) public
{
munon_factory.createHackathon(
name,
image_hash,
entry_fee,
metrics);
uint hackathon_id = munon_factory.hackathon_count();
hackathon_reivew_time[hackathon_id] = review_time;
hackathon_finish_time[hackathon_id] = finish_time;
}
function checkUpkeep(bytes calldata checkData) public view override returns (bool upkeepNeeded, bytes memory performData) {
uint hackathon_id = uint256(bytes32(checkData));
upkeepNeeded = (block.timestamp > hackathon_reivew_time[hackathon_id]) || (block.timestamp > hackathon_finish_time[hackathon_id]);
performData = checkData;
}
function performUpkeep(bytes calldata performData) external override {
uint hackathon_id = uint256(bytes32(performData));
if(block.timestamp > hackathon_reivew_time[hackathon_id])
{
munon_factory.enableHackathonReview(hackathon_id);
}
if(block.timestamp > hackathon_finish_time[hackathon_id])
{
munon_factory.finishHackathon(hackathon_id);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment