编译器
0.8.15+commit.e14f2714
文件 1 的 4:GenericManager.sol
pragma solidity ^0.8.15;
import "./interfaces/IErrorsRegistries.sol";
abstract contract GenericManager is IErrorsRegistries {
event OwnerUpdated(address indexed owner);
event Pause(address indexed owner);
event Unpause(address indexed owner);
address public owner;
bool public paused;
function changeOwner(address newOwner) external virtual {
if (msg.sender != owner) {
revert OwnerOnly(msg.sender, owner);
}
if (newOwner == address(0)) {
revert ZeroAddress();
}
owner = newOwner;
emit OwnerUpdated(newOwner);
}
function pause() external virtual {
if (msg.sender != owner) {
revert OwnerOnly(msg.sender, owner);
}
paused = true;
emit Pause(msg.sender);
}
function unpause() external virtual {
if (msg.sender != owner) {
revert OwnerOnly(msg.sender, owner);
}
paused = false;
emit Unpause(msg.sender);
}
}
文件 2 的 4:IErrorsRegistries.sol
pragma solidity ^0.8.15;
interface IErrorsRegistries {
error ManagerOnly(address sender, address manager);
error OwnerOnly(address sender, address owner);
error HashExists();
error ZeroAddress();
error WrongAgentId(uint256 agentId);
error WrongArrayLength(uint256 numValues1, uint256 numValues2);
error AgentNotFound(uint256 agentId);
error ComponentNotFound(uint256 componentId);
error WrongThreshold(uint256 currentThreshold, uint256 minThreshold, uint256 maxThreshold);
error AgentInstanceRegistered(address operator);
error WrongOperator(uint256 serviceId);
error OperatorHasNoInstances(address operator, uint256 serviceId);
error AgentNotInService(uint256 agentId, uint256 serviceId);
error Paused();
error ZeroValue();
error Overflow(uint256 provided, uint256 max);
error ServiceMustBeInactive(uint256 serviceId);
error AgentInstancesSlotsFilled(uint256 serviceId);
error WrongServiceState(uint256 state, uint256 serviceId);
error OnlyOwnServiceMultisig(address provided, address expected, uint256 serviceId);
error UnauthorizedMultisig(address multisig);
error IncorrectRegistrationDepositValue(uint256 sent, uint256 expected, uint256 serviceId);
error IncorrectAgentBondingValue(uint256 sent, uint256 expected, uint256 serviceId);
error TransferFailed(address token, address from, address to, uint256 value);
error ReentrancyGuard();
}
文件 3 的 4:IRegistry.sol
pragma solidity ^0.8.15;
interface IRegistry {
enum UnitType {
Component,
Agent
}
function create(
address unitOwner,
bytes32 unitHash,
uint32[] memory dependencies
) external returns (uint256);
function updateHash(address owner, uint256 unitId, bytes32 unitHash) external returns (bool success);
function getLocalSubComponents(uint256 unitId) external view returns (uint32[] memory subComponentIds, uint256 numSubComponents);
function calculateSubComponents(uint32[] memory unitIds) external view returns (uint32[] memory subComponentIds);
function getUpdatedHashes(uint256 unitId) external view returns (uint256 numHashes, bytes32[] memory unitHashes);
function totalSupply() external view returns (uint256);
}
文件 4 的 4:RegistriesManager.sol
pragma solidity ^0.8.15;
import "./GenericManager.sol";
import "./interfaces/IRegistry.sol";
contract RegistriesManager is GenericManager {
address public immutable componentRegistry;
address public immutable agentRegistry;
constructor(address _componentRegistry, address _agentRegistry) {
componentRegistry = _componentRegistry;
agentRegistry = _agentRegistry;
owner = msg.sender;
}
function create(
IRegistry.UnitType unitType,
address unitOwner,
bytes32 unitHash,
uint32[] memory dependencies
) external returns (uint256 unitId)
{
if (paused) {
revert Paused();
}
if (unitType == IRegistry.UnitType.Component) {
unitId = IRegistry(componentRegistry).create(unitOwner, unitHash, dependencies);
} else {
unitId = IRegistry(agentRegistry).create(unitOwner, unitHash, dependencies);
}
}
function updateHash(IRegistry.UnitType unitType, uint256 unitId, bytes32 unitHash) external returns (bool success) {
if (unitType == IRegistry.UnitType.Component) {
success = IRegistry(componentRegistry).updateHash(msg.sender, unitId, unitHash);
} else {
success = IRegistry(agentRegistry).updateHash(msg.sender, unitId, unitHash);
}
}
}
{
"compilationTarget": {
"contracts/RegistriesManager.sol": "RegistriesManager"
},
"evmVersion": "london",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs",
"useLiteralContent": true
},
"optimizer": {
"enabled": true,
"runs": 750
},
"remappings": []
}
[{"inputs":[{"internalType":"address","name":"_componentRegistry","type":"address"},{"internalType":"address","name":"_agentRegistry","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"operator","type":"address"}],"name":"AgentInstanceRegistered","type":"error"},{"inputs":[{"internalType":"uint256","name":"serviceId","type":"uint256"}],"name":"AgentInstancesSlotsFilled","type":"error"},{"inputs":[{"internalType":"uint256","name":"agentId","type":"uint256"}],"name":"AgentNotFound","type":"error"},{"inputs":[{"internalType":"uint256","name":"agentId","type":"uint256"},{"internalType":"uint256","name":"serviceId","type":"uint256"}],"name":"AgentNotInService","type":"error"},{"inputs":[{"internalType":"uint256","name":"componentId","type":"uint256"}],"name":"ComponentNotFound","type":"error"},{"inputs":[],"name":"HashExists","type":"error"},{"inputs":[{"internalType":"uint256","name":"sent","type":"uint256"},{"internalType":"uint256","name":"expected","type":"uint256"},{"internalType":"uint256","name":"serviceId","type":"uint256"}],"name":"IncorrectAgentBondingValue","type":"error"},{"inputs":[{"internalType":"uint256","name":"sent","type":"uint256"},{"internalType":"uint256","name":"expected","type":"uint256"},{"internalType":"uint256","name":"serviceId","type":"uint256"}],"name":"IncorrectRegistrationDepositValue","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"manager","type":"address"}],"name":"ManagerOnly","type":"error"},{"inputs":[{"internalType":"address","name":"provided","type":"address"},{"internalType":"address","name":"expected","type":"address"},{"internalType":"uint256","name":"serviceId","type":"uint256"}],"name":"OnlyOwnServiceMultisig","type":"error"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"uint256","name":"serviceId","type":"uint256"}],"name":"OperatorHasNoInstances","type":"error"},{"inputs":[{"internalType":"uint256","name":"provided","type":"uint256"},{"internalType":"uint256","name":"max","type":"uint256"}],"name":"Overflow","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"owner","type":"address"}],"name":"OwnerOnly","type":"error"},{"inputs":[],"name":"Paused","type":"error"},{"inputs":[],"name":"ReentrancyGuard","type":"error"},{"inputs":[{"internalType":"uint256","name":"serviceId","type":"uint256"}],"name":"ServiceMustBeInactive","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"TransferFailed","type":"error"},{"inputs":[{"internalType":"address","name":"multisig","type":"address"}],"name":"UnauthorizedMultisig","type":"error"},{"inputs":[{"internalType":"uint256","name":"agentId","type":"uint256"}],"name":"WrongAgentId","type":"error"},{"inputs":[{"internalType":"uint256","name":"numValues1","type":"uint256"},{"internalType":"uint256","name":"numValues2","type":"uint256"}],"name":"WrongArrayLength","type":"error"},{"inputs":[{"internalType":"uint256","name":"serviceId","type":"uint256"}],"name":"WrongOperator","type":"error"},{"inputs":[{"internalType":"uint256","name":"state","type":"uint256"},{"internalType":"uint256","name":"serviceId","type":"uint256"}],"name":"WrongServiceState","type":"error"},{"inputs":[{"internalType":"uint256","name":"currentThreshold","type":"uint256"},{"internalType":"uint256","name":"minThreshold","type":"uint256"},{"internalType":"uint256","name":"maxThreshold","type":"uint256"}],"name":"WrongThreshold","type":"error"},{"inputs":[],"name":"ZeroAddress","type":"error"},{"inputs":[],"name":"ZeroValue","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"}],"name":"OwnerUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"}],"name":"Pause","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"}],"name":"Unpause","type":"event"},{"inputs":[],"name":"agentRegistry","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"changeOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"componentRegistry","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"enum IRegistry.UnitType","name":"unitType","type":"uint8"},{"internalType":"address","name":"unitOwner","type":"address"},{"internalType":"bytes32","name":"unitHash","type":"bytes32"},{"internalType":"uint32[]","name":"dependencies","type":"uint32[]"}],"name":"create","outputs":[{"internalType":"uint256","name":"unitId","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"enum IRegistry.UnitType","name":"unitType","type":"uint8"},{"internalType":"uint256","name":"unitId","type":"uint256"},{"internalType":"bytes32","name":"unitHash","type":"bytes32"}],"name":"updateHash","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"stateMutability":"nonpayable","type":"function"}]