// "SPDX-License-Identifier: Apache-2.0" pragma solidity ^0.6.11; pragma experimental ABIEncoderV2; import "../Base/SharedTypes.sol"; import "../Base/AssetRegistry/BaseRegistry.sol"; import "./CECEncoder.sol"; import "./ICECRegistry.sol"; /** * @title CECRegistry * @notice Registry for ACTUS Protocol assets */ contract CECRegistry is BaseRegistry, ICECRegistry { using CECEncoder for Asset; constructor() public BaseRegistry() {} /** * @notice * @param assetId id of the asset * @param terms asset specific terms (CECTerms) * @param state initial state of the asset * @param schedule schedule of the asset * @param ownership ownership of the asset * @param engine ACTUS Engine of the asset * @param actor account which is allowed to update the asset state * @param admin account which as admin rights (optional) */ function registerAsset( bytes32 assetId, CECTerms calldata terms, State calldata state, bytes32[] calldata schedule, AssetOwnership calldata ownership, address engine, address actor, address admin ) external override onlyApprovedActors { setAsset(assetId, state, schedule, ownership, engine, actor, admin); assets[assetId].encodeAndSetCECTerms(terms); } /** * @notice Returns the terms of an asset. * @param assetId id of the asset * @return terms of the asset */ function getTerms(bytes32 assetId) external view override returns (CECTerms memory) { return assets[assetId].decodeAndGetCECTerms(); } /** * @notice Set the terms of the asset * @dev Can only be set by authorized account. * @param assetId id of the asset * @param terms new terms */ function setTerms(bytes32 assetId, CECTerms calldata terms) external override isAuthorized (assetId) { assets[assetId].encodeAndSetCECTerms(terms); emit UpdatedTerms(assetId); } function getEnumValueForTermsAttribute(bytes32 assetId, bytes32 attribute) public view override(ITermsRegistry, TermsRegistry) returns (uint8) { return assets[assetId].decodeAndGetEnumValueForCECAttribute(attribute); } function getAddressValueForTermsAttribute(bytes32 assetId, bytes32 attribute) public view override(ITermsRegistry, TermsRegistry) returns (address) { return assets[assetId].decodeAndGetAddressValueForForCECAttribute(attribute); } function getBytes32ValueForTermsAttribute(bytes32 assetId, bytes32 attribute) public view override(ITermsRegistry, TermsRegistry) returns (bytes32) { return assets[assetId].decodeAndGetBytes32ValueForForCECAttribute(attribute); } function getUIntValueForTermsAttribute(bytes32 assetId, bytes32 attribute) public view override(ITermsRegistry, TermsRegistry) returns (uint256) { return assets[assetId].decodeAndGetUIntValueForForCECAttribute(attribute); } function getIntValueForTermsAttribute(bytes32 assetId, bytes32 attribute) public view override(ITermsRegistry, TermsRegistry) returns (int256) { return assets[assetId].decodeAndGetIntValueForForCECAttribute(attribute); } function getPeriodValueForTermsAttribute(bytes32 assetId, bytes32 attribute) public view override(ITermsRegistry, TermsRegistry) returns (IP memory) { return assets[assetId].decodeAndGetPeriodValueForForCECAttribute(attribute); } function getCycleValueForTermsAttribute(bytes32 assetId, bytes32 attribute) public view override(ITermsRegistry, TermsRegistry) returns (IPS memory) { return assets[assetId].decodeAndGetCycleValueForForCECAttribute(attribute); } function getContractReferenceValueForTermsAttribute(bytes32 assetId, bytes32 attribute) public view override(ITermsRegistry, TermsRegistry) returns (ContractReference memory) { return assets[assetId].decodeAndGetContractReferenceValueForCECAttribute(attribute); } function getNextCyclicEvent(bytes32 /* assetId */) internal view override(TermsRegistry) returns (bytes32) { return bytes32(0); } }