Skip to content

Commit

Permalink
remove functions
Browse files Browse the repository at this point in the history
  • Loading branch information
FelixFan1992 committed Jan 17, 2024
1 parent 3ed3c61 commit 12e6360
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 207 deletions.
100 changes: 0 additions & 100 deletions contracts/src/v0.8/automation/v2_1/KeeperRegistryLogicA2_1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -325,106 +325,6 @@ contract KeeperRegistryLogicA2_1 is KeeperRegistryBase2_1, Chainable {
emit FundsAdded(id, msg.sender, amount);
}

/**
* @notice migrates upkeeps from one registry to another
* @param ids the upkeepIDs to migrate
* @param destination the destination registry address
* @dev a transcoder must be set in order to enable migration
* @dev migration permissions must be set on *both* sending and receiving registries
* @dev only an upkeep admin can migrate their upkeeps
*/
function migrateUpkeeps(uint256[] calldata ids, address destination) external {
if (
s_peerRegistryMigrationPermission[destination] != MigrationPermission.OUTGOING &&
s_peerRegistryMigrationPermission[destination] != MigrationPermission.BIDIRECTIONAL
) revert MigrationNotPermitted();
if (s_storage.transcoder == ZERO_ADDRESS) revert TranscoderNotSet();
if (ids.length == 0) revert ArrayHasNoEntries();
uint256 id;
Upkeep memory upkeep;
uint256 totalBalanceRemaining;
address[] memory admins = new address[](ids.length);
Upkeep[] memory upkeeps = new Upkeep[](ids.length);
bytes[] memory checkDatas = new bytes[](ids.length);
bytes[] memory triggerConfigs = new bytes[](ids.length);
bytes[] memory offchainConfigs = new bytes[](ids.length);
for (uint256 idx = 0; idx < ids.length; idx++) {
id = ids[idx];
upkeep = s_upkeep[id];
_requireAdminAndNotCancelled(id);
upkeep.forwarder.updateRegistry(destination);
upkeeps[idx] = upkeep;
admins[idx] = s_upkeepAdmin[id];
checkDatas[idx] = s_checkData[id];
triggerConfigs[idx] = s_upkeepTriggerConfig[id];
offchainConfigs[idx] = s_upkeepOffchainConfig[id];
totalBalanceRemaining = totalBalanceRemaining + upkeep.balance;
delete s_upkeep[id];
delete s_checkData[id];
delete s_upkeepTriggerConfig[id];
delete s_upkeepOffchainConfig[id];
// nullify existing proposed admin change if an upkeep is being migrated
delete s_proposedAdmin[id];
s_upkeepIDs.remove(id);
emit UpkeepMigrated(id, upkeep.balance, destination);
}
s_expectedLinkBalance = s_expectedLinkBalance - totalBalanceRemaining;
bytes memory encodedUpkeeps = abi.encode(
ids,
upkeeps,
new address[](ids.length),
admins,
checkDatas,
triggerConfigs,
offchainConfigs
);
MigratableKeeperRegistryInterfaceV2(destination).receiveUpkeeps(
UpkeepTranscoderInterfaceV2(s_storage.transcoder).transcodeUpkeeps(
UPKEEP_VERSION_BASE,
MigratableKeeperRegistryInterfaceV2(destination).upkeepVersion(),
encodedUpkeeps
)
);
i_link.transfer(destination, totalBalanceRemaining);
}

/**
* @notice received upkeeps migrated from another registry
* @param encodedUpkeeps the raw upkeep data to import
* @dev this function is never called directly, it is only called by another registry's migrate function
*/
function receiveUpkeeps(bytes calldata encodedUpkeeps) external {
if (
s_peerRegistryMigrationPermission[msg.sender] != MigrationPermission.INCOMING &&
s_peerRegistryMigrationPermission[msg.sender] != MigrationPermission.BIDIRECTIONAL
) revert MigrationNotPermitted();
(
uint256[] memory ids,
Upkeep[] memory upkeeps,
address[] memory targets,
address[] memory upkeepAdmins,
bytes[] memory checkDatas,
bytes[] memory triggerConfigs,
bytes[] memory offchainConfigs
) = abi.decode(encodedUpkeeps, (uint256[], Upkeep[], address[], address[], bytes[], bytes[], bytes[]));
for (uint256 idx = 0; idx < ids.length; idx++) {
if (address(upkeeps[idx].forwarder) == ZERO_ADDRESS) {
upkeeps[idx].forwarder = IAutomationForwarder(
address(new AutomationForwarder(targets[idx], address(this), i_automationForwarderLogic))
);
}
_createUpkeep(
ids[idx],
upkeeps[idx],
upkeepAdmins[idx],
checkDatas[idx],
triggerConfigs[idx],
offchainConfigs[idx]
);
emit UpkeepReceived(ids[idx], upkeeps[idx].balance, msg.sender);
}
}

/**
* @notice sets the upkeep trigger config
* @param id the upkeepID to change the trigger for
Expand Down
107 changes: 0 additions & 107 deletions contracts/src/v0.8/automation/v2_1/KeeperRegistryLogicB2_1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,57 +27,6 @@ contract KeeperRegistryLogicB2_1 is KeeperRegistryBase2_1 {
// | UPKEEP MANAGEMENT |
// ================================================================

/**
* @notice transfers the address of an admin for an upkeep
*/
function transferUpkeepAdmin(uint256 id, address proposed) external {
_requireAdminAndNotCancelled(id);
if (proposed == msg.sender) revert ValueNotChanged();

if (s_proposedAdmin[id] != proposed) {
s_proposedAdmin[id] = proposed;
emit UpkeepAdminTransferRequested(id, msg.sender, proposed);
}
}

/**
* @notice accepts the transfer of an upkeep admin
*/
function acceptUpkeepAdmin(uint256 id) external {
Upkeep memory upkeep = s_upkeep[id];
if (upkeep.maxValidBlocknumber != UINT32_MAX) revert UpkeepCancelled();
if (s_proposedAdmin[id] != msg.sender) revert OnlyCallableByProposedAdmin();
address past = s_upkeepAdmin[id];
s_upkeepAdmin[id] = msg.sender;
s_proposedAdmin[id] = ZERO_ADDRESS;

emit UpkeepAdminTransferred(id, past, msg.sender);
}

/**
* @notice pauses an upkeep - an upkeep will be neither checked nor performed while paused
*/
function pauseUpkeep(uint256 id) external {
_requireAdminAndNotCancelled(id);
Upkeep memory upkeep = s_upkeep[id];
if (upkeep.paused) revert OnlyUnpausedUpkeep();
s_upkeep[id].paused = true;
s_upkeepIDs.remove(id);
emit UpkeepPaused(id);
}

/**
* @notice unpauses an upkeep
*/
function unpauseUpkeep(uint256 id) external {
_requireAdminAndNotCancelled(id);
Upkeep memory upkeep = s_upkeep[id];
if (!upkeep.paused) revert OnlyPausedUpkeep();
s_upkeep[id].paused = false;
s_upkeepIDs.add(id);
emit UpkeepUnpaused(id);
}

/**
* @notice updates the checkData for an upkeep
*/
Expand Down Expand Up @@ -128,31 +77,6 @@ contract KeeperRegistryLogicB2_1 is KeeperRegistryBase2_1 {
// | NODE MANAGEMENT |
// ================================================================

/**
* @notice transfers the address of payee for a transmitter
*/
function transferPayeeship(address transmitter, address proposed) external {
if (s_transmitterPayees[transmitter] != msg.sender) revert OnlyCallableByPayee();
if (proposed == msg.sender) revert ValueNotChanged();

if (s_proposedPayee[transmitter] != proposed) {
s_proposedPayee[transmitter] = proposed;
emit PayeeshipTransferRequested(transmitter, msg.sender, proposed);
}
}

/**
* @notice accepts the transfer of the payee
*/
function acceptPayeeship(address transmitter) external {
if (s_proposedPayee[transmitter] != msg.sender) revert OnlyCallableByProposedPayee();
address past = s_transmitterPayees[transmitter];
s_transmitterPayees[transmitter] = msg.sender;
s_proposedPayee[transmitter] = ZERO_ADDRESS;

emit PayeeshipTransferred(transmitter, past, msg.sender);
}

/**
* @notice withdraws LINK received as payment for work performed
*/
Expand Down Expand Up @@ -219,30 +143,6 @@ contract KeeperRegistryLogicB2_1 is KeeperRegistryBase2_1 {
emit PayeesUpdated(s_transmittersList, payees);
}

/**
* @notice sets the migration permission for a peer registry
* @dev this must be done before upkeeps can be migrated to/from another registry
*/
function setPeerRegistryMigrationPermission(address peer, MigrationPermission permission) external onlyOwner {
s_peerRegistryMigrationPermission[peer] = permission;
}

/**
* @notice pauses the entire registry
*/
function pause() external onlyOwner {
s_hotVars.paused = true;
emit Paused(msg.sender);
}

/**
* @notice unpauses the entire registry
*/
function unpause() external onlyOwner {
s_hotVars.paused = false;
emit Unpaused(msg.sender);
}

/**
* @notice sets a generic bytes field used to indicate the privilege that this admin address had
* @param admin the address to set privilege for
Expand Down Expand Up @@ -451,13 +351,6 @@ contract KeeperRegistryLogicB2_1 is KeeperRegistryBase2_1 {
return s_upkeep[id].balance;
}

/**
* @notice retrieves the migration permission for a peer registry
*/
function getPeerRegistryMigrationPermission(address peer) external view returns (MigrationPermission) {
return s_peerRegistryMigrationPermission[peer];
}

/**
* @notice returns the upkeep privilege config
*/
Expand Down

0 comments on commit 12e6360

Please sign in to comment.