"metadata": "{\"compiler\":{\"version\":\"0.6.6+commit.6c089d02\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sla\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"sloValue\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"enum SLORegistry.SLOType\",\"name\":\"sloType\",\"type\":\"uint8\"}],\"name\":\"SLORegistered\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_value\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_slaAddress\",\"type\":\"address\"}],\"name\":\"isRespected\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_sloValue\",\"type\":\"uint256\"},{\"internalType\":\"enum SLORegistry.SLOType\",\"name\":\"_sloType\",\"type\":\"uint8\"},{\"internalType\":\"address\",\"name\":\"_slaAddress\",\"type\":\"address\"}],\"name\":\"registerSLO\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"registeredSLO\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"sloValue\",\"type\":\"uint256\"},{\"internalType\":\"enum SLORegistry.SLOType\",\"name\":\"sloType\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"setSLARegistry\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"SLORegistry is a contract for handling creation of service level objectives and querying those service level objectives\",\"methods\":{\"isRespected(uint256,address)\":{\"details\":\"external view function to check a value against the SLO\",\"params\":{\"_value\":\"The SLI value to check against the SL\"},\"returns\":{\"_0\":\"boolean with the SLO honored state\"}},\"registerSLO(uint256,uint8,address)\":{\"details\":\"public function for creating service level objectives\",\"params\":{\"_slaAddress\":\"3. -\",\"_sloType\":\"2. -\",\"_sloValue\":\"1. -\"}}},\"title\":\"SLORegistry\"},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"@stacktical/dsla-contracts/contracts/SLORegistry.sol\":\"SLORegistry\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@stacktical/dsla-contracts/contracts/SLORegistry.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity 0.6.6;\\npragma experimental ABIEncoderV2;\\n\\n/**\\n * @title SLORegistry\\n * @dev SLORegistry is a contract for handling creation of service level\\n * objectives and querying those service level objectives\\n */\\ncontract SLORegistry {\\n enum SLOType {\\n EqualTo,\\n NotEqualTo,\\n SmallerThan,\\n SmallerOrEqualTo,\\n GreaterThan,\\n GreaterOrEqualTo\\n }\\n\\n struct SLO {\\n uint256 sloValue;\\n SLOType sloType;\\n }\\n /**\\n * @dev SLO Registered event\\n * @param sla 1. -\\n * @param sloValue 2. -\\n * @param sloType 3. -\\n */\\n event SLORegistered(address indexed sla, uint256 sloValue, SLOType sloType);\\n\\n address private slaRegistry;\\n mapping(address => SLO) public registeredSLO;\\n\\n modifier onlySLARegistry {\\n require(\\n msg.sender == slaRegistry,\\n 'Should only be called using the SLARegistry contract'\\n );\\n _;\\n }\\n\\n function setSLARegistry() public {\\n // Only able to trigger this function once\\n require(\\n address(slaRegistry) == address(0),\\n 'SLARegistry address has already been set'\\n );\\n slaRegistry = msg.sender;\\n }\\n\\n /**\\n * @dev public function for creating service level objectives\\n * @param _sloValue 1. -\\n * @param _sloType 2. -\\n * @param _slaAddress 3. -\\n */\\n function registerSLO(\\n uint256 _sloValue,\\n SLOType _sloType,\\n address _slaAddress\\n ) public onlySLARegistry {\\n registeredSLO[_slaAddress] = SLO({\\n sloValue: _sloValue,\\n sloType: _sloType\\n });\\n emit SLORegistered(_slaAddress, _sloValue, _sloType);\\n }\\n\\n /**\\n * @dev external view function to check a value against the SLO\\n * @param _value The SLI value to check against the SL\\n * @return boolean with the SLO honored state\\n */\\n function isRespected(uint256 _value, address _slaAddress)\\n public\\n view\\n returns (bool)\\n {\\n SLO memory slo = registeredSLO[_slaAddress];\\n SLOType sloType = slo.sloType;\\n uint256 sloValue = slo.sloValue;\\n\\n if (sloType == SLOType.EqualTo) {\\n return _value == sloValue;\\n }\\n\\n if (sloType == SLOType.NotEqualTo) {\\n return _value != sloValue;\\n }\\n\\n if (sloType == SLOType.SmallerThan) {\\n return _value < sloValue;\\n }\\n\\n if (sloType == SLOType.SmallerOrEqualTo) {\\n return _value <= sloValue;\\n }\\n\\n if (sloType == SLOType.GreaterThan) {\\n return _value > sloValue;\\n }\\n\\n if (sloType == SLOType.GreaterOrEqualTo) {\\n return _value >= sloValue;\\n }\\n revert(\\\"isRespected wasn't executed properly\\\");\\n }\\n}\\n\",\"keccak256\":\"0x15c7b1bb4b97a177cf56078bfcdace06a35e82cc68682e8f9f2414df99886cb1\"}},\"version\":1}",
0 commit comments