Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrating #7

Open
wants to merge 28 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
0647251
On-chainVoting
FurkanSezal Oct 24, 2022
eb9e262
uptaded erc20
FurkanSezal Oct 26, 2022
9c4aed1
Add tests
FurkanSezal Oct 28, 2022
64bd7d7
add tests v1.1
FurkanSezal Oct 28, 2022
c6f35b2
add test v1.1
FurkanSezal Oct 28, 2022
7b0be87
Add tests v1.2
FurkanSezal Oct 28, 2022
15038d9
Add submit
FurkanSezal Oct 31, 2022
6220217
Funding contract
FurkanSezal Nov 4, 2022
db68871
Funding Contract
FurkanSezal Nov 4, 2022
a7a4d7f
Fixed submit_and_propose and testing
FurkanSezal Nov 5, 2022
ea4432c
add more test
FurkanSezal Nov 6, 2022
a658f31
Add more testing before chainlink keepers
FurkanSezal Nov 6, 2022
74473f4
fix test
FurkanSezal Nov 7, 2022
15bd11e
Add chainlink automation without testing.
FurkanSezal Nov 8, 2022
b38e711
Add chainlink automation without testing V2.
FurkanSezal Nov 8, 2022
9aa568a
Add chainlink automation without testing V3.
FurkanSezal Nov 8, 2022
0a4c984
Add chainlink automation without testing V3.
FurkanSezal Nov 8, 2022
eb6206b
Add chainlink automation without testing V4.
FurkanSezal Nov 8, 2022
5ee5a40
Add chainlink automation Fix big bug. Add tests V1
FurkanSezal Nov 10, 2022
b400b6d
Add chainlink automation Fix big bug. Add tests V2
FurkanSezal Nov 10, 2022
1e4c63e
Add chainlink automation Fix big bug. Add tests V3
FurkanSezal Nov 10, 2022
b2981e4
Add chainlink automation Fix big bug. Add tests V4
FurkanSezal Nov 10, 2022
35bdfab
Fix bugs update code v1.
FurkanSezal Nov 13, 2022
82cfbdb
Fix bugs update code v2
FurkanSezal Nov 13, 2022
54c2dcb
deployed mumbai testnet
FurkanSezal Nov 17, 2022
505a2f9
deployed mumbai testnet v2
FurkanSezal Nov 17, 2022
fd54f69
deployed mumbai testnet v2
FurkanSezal Nov 18, 2022
327bbd8
deployed mumbai testnet v3
FurkanSezal Nov 18, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add chainlink automation without testing V2.
This will break old test for now.
  • Loading branch information
FurkanSezal committed Nov 8, 2022
commit b38e71141a9a40432a6bce9c84a5e6d08afe6dce
37 changes: 37 additions & 0 deletions contracts/FundProject.sol
Original file line number Diff line number Diff line change
@@ -9,6 +9,15 @@ contract FundProject is Ownable, AutomationCompatibleInterface {
error FundProject__UpkeepNeeded();
error FundProject__TransferFailed(uint256 _projectId);
error FundProject__NotEnoughPayment();
error FundProject__withdrawFund();
error FundProject__WithdrawTransferFailed();

enum ProjectFundingStatus {
ONPROGRESS,
SUCCESS,
FAILED,
CANCELED
}

uint256 public projectId = 1;

@@ -28,6 +37,7 @@ contract FundProject is Ownable, AutomationCompatibleInterface {
mapping(uint256 => uint256) public projectFundingGoalAmount;
mapping(uint256 => bool) public _isApporovedByDao;
mapping(uint256 => address) public projectOwnerAddress;
mapping(uint256 => ProjectFundingStatus) public _ProjectFundingStatus;

event projectSuccessfullyFunded(uint256 indexed _projectId);

@@ -60,6 +70,7 @@ contract FundProject is Ownable, AutomationCompatibleInterface {
) external onlyOwner {
// only dao can call this function (after deployement we will transfer ownership to dao)
projectToTime[projectId][_time] = block.timestamp;
_ProjectFundingStatus[projectId] = ProjectFundingStatus.ONPROGRESS;
time[projectId] = _time;
projectFundingGoalAmount[projectId] = _fundingGoalAmount;
hashToProjectId[_ipfsHash] = projectId;
@@ -74,6 +85,7 @@ contract FundProject is Ownable, AutomationCompatibleInterface {
// only dao can call this function (after deployement we will transfer ownership to dao)
_isApporovedByDao[_projecID] = false;
_isFunding[projectId] = false;
_ProjectFundingStatus[projectId] = ProjectFundingStatus.CANCELED;
}

function checkUpkeep(
@@ -103,6 +115,7 @@ contract FundProject is Ownable, AutomationCompatibleInterface {
_isApporovedByDao[projectId] = false;

if (projectFunds[projectId] > projectFundingGoalAmount[projectId]) {
_ProjectFundingStatus[projectId] = ProjectFundingStatus.SUCCESS;
uint256 fundsToSent = (projectFunds[projectId] * daoPercentage) /
100;
(bool success, ) = (projectOwnerAddress[projectId]).call{
@@ -113,6 +126,8 @@ contract FundProject is Ownable, AutomationCompatibleInterface {
}

emit projectSuccessfullyFunded(projectId);
} else {
_ProjectFundingStatus[projectId] = ProjectFundingStatus.FAILED;
}
}

@@ -123,6 +138,20 @@ contract FundProject is Ownable, AutomationCompatibleInterface {
projectOwners = payable(msg.sender);
}

function withdrawFund(uint256 _projectID) public {
if (_ProjectFundingStatus[_projectID] == ProjectFundingStatus.FAILED) {
uint256 fundToSent = funders[_projectID][msg.sender];
(bool success, ) = (payable(msg.sender)).call{value: fundToSent}(
""
);
if (!success) {
revert FundProject__WithdrawTransferFailed();
}
} else {
revert FundProject__withdrawFund();
}
}

function _isApporoveFundingByDao(uint256 _projecID)
external
view
@@ -166,4 +195,12 @@ contract FundProject is Ownable, AutomationCompatibleInterface {
function is_funding(uint256 _projectID) public view returns (bool) {
return _isFunding[_projectID];
}

function _getProjectStatus(uint256 _projectID)
public
view
returns (ProjectFundingStatus)
{
return _ProjectFundingStatus[_projectID];
}
}