Expand description
§sol2seq
A library for generating sequence diagrams from Solidity smart contracts.
This crate can be used as:
- A library in your Rust projects
- A command-line tool for generating diagrams
§Library Usage
use anyhow::Result;
use sol2seq::{generate_diagram_from_file, Config};
fn main() -> Result<()> {
// Create a configuration
let config = Config {
light_colors: false,
output_file: Some("diagram.md".into()),
};
// Generate diagram from AST file
generate_diagram_from_file("path/to/ast.json", config)?;
println!("Diagram generated successfully!");
Ok(())
}
§CLI Usage
# Generate a diagram from an AST JSON file
sol2seq path/to/ast.json output.md
# Use lighter colors
sol2seq --light-colors path/to/ast.json output.md
Structs§
- Config
- Configuration for diagram generation
- Contract
Info - Represents contract information
- Contract
Relationship - Relationship between contracts
- Diagram
Data - Container for all extracted contract information
- Interaction
- Represents a diagram interaction between participants
- Parameter
- Represents a function parameter or return value
- State
Variable - Represents a contract’s state variable
Enums§
- Interaction
Type - Represents a sequence diagram interaction
Functions§
- generate_
diagram_ from_ file - Generate a sequence diagram from an AST JSON file
- generate_
diagram_ from_ sources - Generate a sequence diagram from Solidity source files
- generate_
sequence_ diagram - Generate a Mermaid sequence diagram from AST JSON