How regolith-labs/steel works
Project Type and Purpose
• Steel is a developer-oriented framework written in Rust.
• Its purpose is to facilitate building safe and maintainable smart contracts on the Solana blockchain.
• The project includes a CLI tool that scaffolds new project templates and a core library that provides helper functions, macros, and standard patterns for Solana development.
File Structure
• Top-Level Components:
• Root-level files (Cargo.toml, Cargo.lock, README.md) denote a workspace.
• The “cli” directory is dedicated to the command-line tool used to initialize, build, and clean projects.
• The “lib” directory holds the core library providing functionalities for account management, CPIs (Cross-Program Invocations), error handling, logging, etc.
• The “lib” folder is organized into modules such as account, spl (Solana Program Library utilities), and utils, showing a modular approach for handling different aspects of smart contract development.
README for Architectural Insights
• The README elaborates on the recommended project structure (splitting code into “api” and “program”), which serves as a guideline for users building their own smart contracts with Steel.
• It provides examples for key macros (account!, instruction!, error!, event!) and emphasizes separation of concerns – a hint toward modularity.
• The instructions and examples illustrate how the framework ties together CLI operations with smart contract implementation through a structured division of components.
a. Main Components to Represent:
– CLI Component:
▪ Represents the Steel command-line interface.
▪ Contains modules like new_project, build_project, clean_project, and the templating system.
– Library (Core) Component:
▪ Contains modules for account management (account validation, deserialization, lamports handling), error logging, macros, and specialized Solana integrations (SPL helpers).
– Generated/Target Project Template:
▪ Outlines the recommended file structure for a Solana smart contract project with separate “api” and “program” sections.
– External Dependencies:
▪ Solana blockchain and its toolchain.
▪ External libraries such as SPL tokens.
b. Relationships and Interactions:
– The CLI component’s commands trigger the creation of new projects by pulling template files (from cli/src/template) that have a clear separation between the API and program portions.
– The generated project uses the Steel library (lib) for core functionalities during compilation and runtime on the Solana blockchain.
– The CLI acts as an orchestrator for build, test, and deployment tasks that link back to both the generated project structure and the library’s functionalities.
c. Architectural Patterns:
– Modular Design: Clear separation between CLI (tooling) and Lib (core functionality) with a generated project template following an MVC-like separation or layered architecture (interface/API vs. implementation/program).
– Template-based Scaffold: The use of predefined templates in the CLI to enforce a well-structured project layout.
d. Relevant Technologies and Frameworks:
– Rust as the programming language.
– Cargo for package and dependency management (with workspace setup).
– Solana SDK and Solana’s toolchain.
– SPL (Solana Program Library) for token-related functions.
Instructing the Principal Software Engineer
– Use clear labels for each component (e.g., “Steel CLI”, “Steel Core Library”, “Project Template: API”, “Project Template: Program”, “Solana Blockchain”, “SPL Integration”).
▪ From the CLI to the Project Template to indicate the generation of new projects.
▪ From the Project Template to the Core Library, showing dependency injection or usage.
▪ Between the Core Library and external services (Solana and SPL) to denote runtime interactions.
▪ Rectangles for major modules (CLI, Library, Project Template).
▪ Rounded rectangles for external dependencies and subsystems.