Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
explorer: introducing contract metadata store
This commit introduces a **Contract Metadata Store**, serving as a data layer API for managing contract metadata and associated source code files. The storage utilizes a Sled database and organizes data into separate trees, including primary metadata storage for contract details and a tree for contract source code, organized by file paths prefixed with a `ContractId`. The implementation follows an overlay pattern for write operations, enabling unified management of metadata and source code by delegating tasks such as adding, updating, and deleting records to the `ContractMetadataStoreOverlay`. Furthermore, this commit adds the `ContractMetaData` struct, which is used to store additional information for contracts that is not available on-chain. This data is indexed by `ContractId`. The struct encapsulates basic metadata fields, such as the name and description of a contract, and provides methods for creating new metadata instances. In addition, the `ContractSourceFile` struct was added, which represents a source file containing its file path and its contents. Finally, we added test coverage to validate functionality across various scenarios, such as metadata insertion and retrieval, source code insertion, and fetching source paths and contents. Introduced Core Structures and Methods: ContractMetadataStore: - Created the `ContractMetadataStore` struct to manage contract metadata and source code storage, providing an API for fetching and inserting associated data, all backed by a Sled database. ContractMetadataStoreOverlay: - Developed the `ContractMetadataStoreOverlay` to facilitate write operations, including adding metadata and source code, as well as deleting existing source code. ContractMetaData: - Introduced the `ContractMetaData` struct, which represents contract metadata, containing additional contract information that is not stored on-chain. ContractSourceFile: - Introduced the `ContractSourceFile` struct to encapsulate contract source code, containing its file path and its content. Added Test Functions: - `test_add_contract_source`: Verifies the correctness of storing contract source code. - `test_get_contract_source`: Validates the retrieval of a contract source code from the store. - `test_add_metadata`: Tests the addition of contract metadata to the store. Added Load Test Data Functions: - `load_source_code`:Loads the source code test data. Running Tests: cargo test contract_meta_store::tests
- Loading branch information