Skip to content

Commit

Permalink
update the schedule job function because of the chainlink function re…
Browse files Browse the repository at this point in the history
…strictions
  • Loading branch information
yashgo0018 committed Dec 18, 2023
1 parent 8b5d9e3 commit a5611a4
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions contracts/FundManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ contract FundManager is Ownable, FunctionsClient {
uint256 totalBatchesFulfilled;
bool fulfilled;
bytes32 scheduleOptimizationRequestId;
bool scheduleInitiated;
bool scheduled;
string jobId;
bool completed;
Expand Down Expand Up @@ -213,6 +214,7 @@ contract FundManager is Ownable, FunctionsClient {
totalBatchesFulfilled: 0,
fulfilled: false,
scheduleOptimizationRequestId: bytes32(""),
scheduleInitiated: false,
scheduled: false,
jobId: "",
completed: false
Expand Down Expand Up @@ -313,10 +315,13 @@ contract FundManager is Ownable, FunctionsClient {
);
}

function _scheduleOptimization(uint256 refreshRequestId) internal {
function scheduleOptimization(uint256 refreshRequestId) public {
RefreshRequest storage refreshRequest = refreshRequests[
refreshRequestId
];
if (!refreshRequest.fulfilled) revert("Not fulfilled");
if (refreshRequest.scheduleInitiated) revert("Already initiated");
refreshRequest.scheduleInitiated = true;
uint256 totalBatches = refreshRequest.totalBatches;
string[] memory args = new string[](totalBatches + 1);
args[0] = Strings.toString(totalBatches);
Expand Down Expand Up @@ -428,10 +433,7 @@ contract FundManager is Ownable, FunctionsClient {
refreshRequest.totalBatches
) {
refreshRequest.fulfilled = true;
// initiate schedule optimization
_scheduleOptimization(refreshRequest.id);
}

return;
}

Expand Down

0 comments on commit a5611a4

Please sign in to comment.