pragma solidity >=0.8.0; import "@openzeppelin/contracts/access/Ownable.sol"; contract Colnago is Ownable { mapping(string => string) bikes; mapping(string => mapping(uint256 => string)) updates; mapping(string => uint256) updatesCountForBike; function createAsset(string memory assetId, string memory data) public onlyOwner returns (string memory) { require( bytes(bikes[assetId]).length == 0, "Duplicated ID." ); bikes[assetId] = data; return assetId; } function updateAsset(string memory assetId, uint256 updateId, string memory data) public onlyOwner returns (string memory) { require( bytes(updates[assetId][updateId]).length == 0, "Asset/Update exists" ); updates[assetId][updateId] = data; updatesCountForBike[assetId] = updateId; return updates[assetId][updateId]; } function getAsset(string memory assetId) public view returns (string memory) { require( bytes(bikes[assetId]).length != 0, "Bike not found." ); return bikes[assetId]; } function getUpdateAsset(string memory assetId, uint256 updateId) public view returns (string memory) { require( bytes(updates[assetId][updateId]).length != 0, "Asset/Update not found." ); return updates[assetId][updateId]; } function getUpdatesCount(string memory assetId) public view returns (uint256) { return updatesCountForBike[assetId]; } }
0.4.18