Skip to content

Commit

Permalink
improve registerAutoDepositJob, add assignKeeperToAutoDepositJob
Browse files Browse the repository at this point in the history
  • Loading branch information
defi-dev committed May 30, 2024
1 parent e7671b3 commit b05ce53
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
17 changes: 16 additions & 1 deletion contracts/VRFAgentManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ contract VRFAgentManager is Ownable {
uint16 maxBaseFeeGwei_,
uint16 rewardPct_,
uint32 fixedReward_,
uint256 jobMinCvp_
uint256 jobMinCvp_,
bool activateJob
) external payable onlyOwner returns(bytes32 jobKey, uint256 jobId) {
IPPAgentV2JobOwner.RegisterJobParams memory params = IPPAgentV2JobOwner.RegisterJobParams({
jobAddress: address(this),
Expand All @@ -71,6 +72,10 @@ contract VRFAgentManager is Ownable {
});
(jobKey, jobId) = agent.registerJob{value: msg.value}(params, getAutoDepositResolverStruct(), new bytes(0));
autoDepositJobKey = jobKey;
if (activateJob) {
agent.setJobConfig(autoDepositJobKey, true, false, true, false);
_assignKeeperToAutoDepositJob();
}
}

function processVrfJobDeposit() external {
Expand Down Expand Up @@ -197,6 +202,16 @@ contract VRFAgentManager is Ownable {
agent.setAgentParams(minKeeperCvp_, timeoutSeconds_, feePpm_);
}

function _assignKeeperToAutoDepositJob() internal {
bytes32[] memory assignJobKeys = new bytes32[](1);
assignJobKeys[0] = autoDepositJobKey;
agent.assignKeeper(assignJobKeys);
}

function assignKeeperToAutoDepositJob() external onlyOwner {
_assignKeeperToAutoDepositJob();
}

function ownerSlash(uint256 keeperId_, address to_, uint256 currentAmount_, uint256 pendingAmount_) external onlyOwner {
agent.ownerSlash(keeperId_, to_, currentAmount_, pendingAmount_);
}
Expand Down
2 changes: 1 addition & 1 deletion test/randao/VRFTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ contract VRFTest is AbstractTestHelper {
(
bytes32 autoDepositJobKey,
uint256 autoDepositJobId
) = agentManager.registerAutoDepositJob{value: 1e16}(100, 35, 10, 0);
) = agentManager.registerAutoDepositJob{value: 1e16}(100, 35, 10, 0, false);

assertNotEq(agentManager.autoDepositJobKey(), bytes32(0));
assertEq(agentManager.autoDepositJobKey(), autoDepositJobKey);
Expand Down

0 comments on commit b05ce53

Please sign in to comment.