Skip to content

Commit

Permalink
May 25, 2023, 5:17 AM
Browse files Browse the repository at this point in the history
  • Loading branch information
xthet committed May 25, 2023
1 parent 1ed679d commit 74b967a
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 70 deletions.
74 changes: 38 additions & 36 deletions contracts/Campaign.sol
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ contract Campaign is KeeperCompatibleInterface, ReentrancyGuard{
currentBalance = 0;
}

function timeBox(address _upkeepCreatorAddress, address _linkTokenAddress, address _campaignAddress) external isCreator {
UpkeepIDConsumer newUpkeepCreator = UpkeepIDConsumer(_upkeepCreatorAddress);
LinkTokenInterface token = LinkTokenInterface(_linkTokenAddress);
if(token.balanceOf(_upkeepCreatorAddress) == 0){revert("no funds");}
rId = newUpkeepCreator.registerAndPredictID(s_title, "0x", _campaignAddress, 500000, i_creator, "0x", "0x", 2000000000000000000);
}
// function timeBox(address _upkeepCreatorAddress, address _linkTokenAddress, address _campaignAddress) external isCreator {
// // UpkeepIDConsumer newUpkeepCreator = UpkeepIDConsumer(_upkeepCreatorAddress);
// // LinkTokenInterface token = LinkTokenInterface(_linkTokenAddress);
// // if(token.balanceOf(_upkeepCreatorAddress) == 0){revert("no funds");}
// // rId = newUpkeepCreator.registerAndPredictID(s_title, "0x", _campaignAddress, 500000, i_creator, "0x", "0x", 2000000000000000000);
// }

function donate(address _donator, bool _rewardable) public payable nonReentrant{
if(msg.sender != i_crf){revert();}
Expand Down Expand Up @@ -185,14 +185,16 @@ contract Campaign is KeeperCompatibleInterface, ReentrancyGuard{

function makeReward(
uint256 _price, string memory _title,
string memory _description, string memory _rpic,
string[] memory _perks,
uint256 _deadline, uint256 _quantity, bool _infinite,
string[] memory _shipsTo
string memory _detsLink
// string memory _description, string memory _rpic,
// string[] memory _perks,
// uint256 _deadline, uint256 _quantity, bool _infinite,
// string[] memory _shipsTo
) external isCreator {
if(rewards[_price] != address(0)){revert();}
rKeys.push(_price);
Reward newReward = new Reward(address(this), i_creator, _price, _title, _description, _rpic, _perks, _deadline, _quantity, _infinite, _shipsTo);
Reward newReward = new Reward(address(this), i_creator, _price, _title, _detsLink);
// _description, _rpic, _perks, _deadline, _quantity, _infinite, _shipsTo);
rewards[_price] = address(newReward);
}

Expand All @@ -207,35 +209,35 @@ contract Campaign is KeeperCompatibleInterface, ReentrancyGuard{
s_campaignURI = _campaignURI;
}

function updateDur(uint256 _addedDur) external isCreator {
duration = (((duration + _addedDur)) > i_maxDur) ? i_maxDur : (duration + _addedDur);
deadline = i_initTimeStamp + duration;
}
// function updateDur(uint256 _addedDur) external isCreator {
// duration = (((duration + _addedDur)) > i_maxDur) ? i_maxDur : (duration + _addedDur);
// deadline = i_initTimeStamp + duration;
// }

// getter functions
function getRewardKeys() external view returns(uint256[] memory){
return rKeys;
}

function getReward(uint256 _priceID) external view returns(Reward.RewardObject memory) {
Reward reward = Reward(rewards[_priceID]);
return reward.getRewardDetails();
}

function getCampaignDetails() external view returns(CampaignObject memory) {
return CampaignObject(
i_creator,
s_title,
s_description,
s_category,
s_tags,
goalAmount,
duration,
currentBalance,
c_state,
s_imageURI,
s_campaignURI,
deadline
);
}
// function getReward(uint256 _priceID) external view returns(Reward.RewardObject memory) {
// Reward reward = Reward(rewards[_priceID]);
// return reward.getRewardDetails();
// }

// function getCampaignDetails() external view returns(CampaignObject memory) {
// return CampaignObject(
// i_creator,
// s_title,
// s_description,
// s_category,
// s_tags,
// goalAmount,
// duration,
// currentBalance,
// c_state,
// s_imageURI,
// s_campaignURI,
// deadline
// );
// }
}
14 changes: 9 additions & 5 deletions contracts/CrowdFunder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,14 @@ contract CrowdFunder {
}

function publishCampaign(address _campaignAddress, address _upkeepCreator, address _linkToken) external {
(bool success, ) = _campaignAddress.delegatecall(abi.encodeWithSignature("timeBox(address,address,address)", _upkeepCreator, _linkToken, _campaignAddress));
if(success){
campaignCounter = campaignCounter + 1;
emit CampaignPublished(_campaignAddress, msg.sender);
}else{revert();}
UpkeepIDConsumer newUpkeepCreator = UpkeepIDConsumer(_upkeepCreator);
LinkTokenInterface token = LinkTokenInterface(_linkToken);
if(token.balanceOf(_upkeepCreator) == 0){revert("no funds");}
newUpkeepCreator.registerAndPredictID(Campaign(_campaignAddress).s_title(), "0x", _campaignAddress, 500000, Campaign(_campaignAddress).i_creator(), "0x", "0x", 2000000000000000000);
// (bool success, ) = _campaignAddress.delegatecall(abi.encodeWithSignature("timeBox(address,address,address)", _upkeepCreator, _linkToken, _campaignAddress));
// if(success){
// campaignCounter = campaignCounter + 1;
// emit CampaignPublished(_campaignAddress, msg.sender);
// }else{revert();}
}
}
59 changes: 30 additions & 29 deletions contracts/Reward.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,27 @@ contract Reward {
address _creator,
uint256 _price,
string memory _title,
string memory _description,
string memory _rpic,
string[] memory _perks,
uint256 _deadline,
uint256 _quantity,
bool _infinite,
string[] memory _shipsTo
string memory _detsLink
// string memory _description,
// string memory _rpic,
// string[] memory _perks,
// uint256 _deadline,
// uint256 _quantity,
// bool _infinite,
// string[] memory _shipsTo
) {
i_price = _price;
i_campaignAddress = _campaignAddress;
i_creator = _creator;

title = _title;
description = _description;
rpic = _rpic;
perks = _perks;
delDate = _deadline;
quantity = _quantity;
infinite = _infinite;
shipsTo = _shipsTo;
// description = _description;
// rpic = _rpic;
// perks = _perks;
// delDate = _deadline;
// quantity = _quantity;
// infinite = _infinite;
// shipsTo = _shipsTo;
}

function updateSurveyLink(string memory _surveylink) external {
Expand Down Expand Up @@ -102,19 +103,19 @@ contract Reward {
surveyResponses[msg.sender] = _response;
}

function getRewardDetails() external view returns(RewardObject memory){
return RewardObject(
i_price,
title,
description,
rpic,
perks,
delDate,
quantity,
infinite,
shipsTo,
donators,
surveyLink
);
}
// function getRewardDetails() external view returns(RewardObject memory){
// return RewardObject(
// i_price,
// title,
// description,
// rpic,
// perks,
// delDate,
// quantity,
// infinite,
// shipsTo,
// donators,
// surveyLink
// );
// }
}

0 comments on commit 74b967a

Please sign in to comment.