-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- move storage to new registry - leave event in RegCoord - trim bytecode from error strings
- Loading branch information
Showing
18 changed files
with
190 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
pragma solidity ^0.8.12; | ||
|
||
import {IRegistryCoordinator} from "./interfaces/IRegistryCoordinator.sol"; | ||
import {ISocketRegistry} from "./interfaces/ISocketRegistry.sol"; | ||
|
||
/** | ||
* @title A `Registry` that keeps track of operator sockets. | ||
* @author Layr Labs, Inc. | ||
*/ | ||
contract SocketRegistry is ISocketRegistry { | ||
|
||
/// @notice The address of the RegistryCoordinator | ||
address public immutable registryCoordinator; | ||
|
||
/// @notice A mapping from operator IDs to their sockets | ||
mapping(bytes32 => string) public operatorIdToSocket; | ||
|
||
/// @notice A modifier that only allows the RegistryCoordinator to call a function | ||
modifier onlyRegistryCoordinator() { | ||
require(msg.sender == address(registryCoordinator), "SocketRegistry.onlyRegistryCoordinator: caller is not the RegistryCoordinator"); | ||
_; | ||
} | ||
|
||
/// @notice A modifier that only allows the owner of the RegistryCoordinator to call a function | ||
modifier onlyCoordinatorOwner() { | ||
require(msg.sender == IRegistryCoordinator(registryCoordinator).owner(), "SocketRegistry.onlyCoordinatorOwner: caller is not the owner of the registryCoordinator"); | ||
_; | ||
} | ||
|
||
constructor(IRegistryCoordinator _registryCoordinator) { | ||
registryCoordinator = address(_registryCoordinator); | ||
} | ||
|
||
/// @notice sets the socket for an operator only callable by the RegistryCoordinator | ||
function setOperatorSocket(bytes32 _operatorId, string memory _socket) external onlyRegistryCoordinator { | ||
operatorIdToSocket[_operatorId] = _socket; | ||
} | ||
|
||
/// @notice migrates the sockets for a list of operators only callable by the owner of the RegistryCoordinator | ||
function migrateOperatorSockets(bytes32[] memory _operatorIds, string[] memory _sockets) external onlyCoordinatorOwner { | ||
for (uint256 i = 0; i < _operatorIds.length; i++) { | ||
operatorIdToSocket[_operatorIds[i]] = _sockets[i]; | ||
} | ||
} | ||
|
||
/// @notice gets the stored socket for an operator | ||
function getOperatorSocket(bytes32 _operatorId) external view returns (string memory) { | ||
return operatorIdToSocket[_operatorId]; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
interface ISocketRegistry { | ||
/// @notice sets the socket for an operator only callable by the RegistryCoordinator | ||
function setOperatorSocket(bytes32 _operatorId, string memory _socket) external; | ||
|
||
/// @notice gets the stored socket for an operator | ||
function getOperatorSocket(bytes32 _operatorId) external view returns (string memory); | ||
} |
Oops, something went wrong.