structs.sol
Overview
This file defines several Solidity data structures (structs) used for organizing and managing key pieces of data within the system. These structs provide a compact and efficient way to group related variables, enabling consistent handling of message metadata and token-related information. The file does not contain executable logic or contract definitions but serves as a foundational module for representing structured data in other parts of the application.
Structs
MessageInfo
Represents metadata about a specific message, primarily identified by a hash and an expiration timestamp.
Properties:
messageHash(uint256): A unique identifier for the message, typically a cryptographic hash.expireAt(uint32): A Unix timestamp indicating when the message expires or becomes invalid.
Usage Example:
MessageInfo memory msgInfo = MessageInfo({ messageHash: someHashValue, expireAt: block.timestamp + 3600 // expires in 1 hour });Purpose:
Useful for tracking the validity period of messages, ensuring that expired messages can be identified and handled accordingly.
EccToken
Encapsulates information about a token, including identification, precision, supply, and description.
Properties:
key(uint32): A unique key or identifier for the token.name(string): The token's name or symbol.decimals(uint64): Number of decimal places the token supports, defining its smallest unit.baseMinted(uint64): The initial minted supply or base quantity of tokens.description(string): A textual description providing details about the token.
Usage Example:
EccToken memory token = EccToken({ key: 1, name: "GOSHToken", decimals: 18, baseMinted: 1000000, description: "Main utility token for GOSH platform" });Purpose:
This struct standardizes token metadata, facilitating token management, display, and integration in the system.
EccData
Combines an EccToken instance with a timestamp, likely to represent a snapshot or event related to the token.
Properties:
data(EccToken): The token data as defined in theEccTokenstruct.time(uint32): A timestamp indicating when this data snapshot was recorded or applicable.
Usage Example:
EccData memory eccDataInstance = EccData({ data: token, time: uint32(block.timestamp) });Purpose:
This struct is designed to associate token data with a specific point in time, potentially for historical tracking, auditing, or event logging.
Implementation Details
The use of fixed-size integer types (e.g.,
uint32,uint64) optimizes storage and gas costs compared to general-purposeuint256.Strings are used for names and descriptions to provide flexibility in representing human-readable token metadata.
The
EccDatastruct encapsulates theEccTokenstruct, demonstrating nested struct usage for complex data representation.The
expireAtfield inMessageInfoenables time-based validation logic outside this file, such as message expiration checks.
Interactions with Other Parts of the System
These structs are intended to be imported and used by smart contracts or libraries that handle messaging, token management, and time-based data tracking.
MessageInfolikely interacts with messaging or event handling contracts to track message validity.EccTokenandEccDataare probably used in token-related contracts for minting, transfers, or metadata queries.The
timeproperty inEccDatacan be used by analytics or auditing modules to track changes or snapshots of token states over time.
Structure Diagram
classDiagram
class MessageInfo {
+uint256 messageHash
+uint32 expireAt
}
class EccToken {
+uint32 key
+string name
+uint64 decimals
+uint64 baseMinted
+string description
}
class EccData {
+EccToken data
+uint32 time
}
EccData --> EccToken : contains