BoostryJP / ibet-SmartContract

Tokens and DEX contracts available in the ibet DeFi network 🔗
https://ibet.jp/ibet-for-fin
Apache License 2.0
18 stars 3 forks source link

[FEATURE] New Feature: Log storage contract with frozen past logs #375

Closed YoshihitoAso closed 2 years ago

YoshihitoAso commented 2 years ago

Is your feature request related to a problem? Please describe.

We would like to add a contract with the following specifications.

Describe the solution you'd like

freezeLogContract

Specifications

pragma solidity ^0.8.0;

contract FreezeLog {

    event Recorded(address indexed recorder, uint256 index, uint256 _freezingGraceBlockCount);
    event Updated(address indexed recorder, uint256 index);

    struct Log {
        address recorder;  // Recorder
        string  log;  // Log text
        uint256 createdBlockNumber;  // Created block number
        uint256 freezingGraceBlockCount;  // Freezing grace block count
    }

    /// Recorder -> Index
    mapping (address => uint256) public last_log_index;
    /// Recorder > Index -> Log
    mapping (address => mapping (uint256 => Log)) public logs;

    // [CONSTRUCTOR]
    constructor () {}

    /// @notice Get last index
    /// @param _recorder Recorder
    /// @return _index Last index
    function lastLogIndex(address _recorder)
        public
        view
        returns (uint256 _index)
    {
        return _index;
    }

    /// @notice Record new logs
    /// @param _log Log text
    /// @param _freezingGraceBlockCount Freezing grace block count
    function recordLog(
        string memory _log,
        uint256 _freezingGraceBlockCount
    )
        public
    {

    }

    /// @notice Update recorded logs
    /// @param _index Index
    /// @param _log Log to be updated
    function updateLog(
        uint256 _index,
        string memory _log
    )
        public
    {

    }

    /// @notice Get log
    /// @param _recorder Recorder
    /// @param _index Index
    function getLog(
        address _recorder,
        uint256 _index
    )
        public
        view
        returns (
            uint256 _createdBlockNumber,
            uint256 _freezingGraceBlockCount,
            string memory _log
        )
    {
        return (_createdBlockNumber, _freezingGraceBlockCount, _log);
    }

}