Skip to content

Commit

Permalink
fix(rs): add derives to builder pattern (#50)
Browse files Browse the repository at this point in the history
* fix(rs): add derives to builder pattern

* fix: add autogenerated message
  • Loading branch information
glihm authored Aug 14, 2024
1 parent 77807b5 commit 6c90910
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion crates/rs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ impl ContractBindings {
///
/// * `file` - The path to the file to write the bindings to.
pub fn write_to_file(&self, file: &str) -> io::Result<()> {
fs::write(file, self.to_string())
let content = format!(
"// ****\n// Auto-generated by cainome do not edit.\n// ****\n\n{}",
self
);
fs::write(file, content)
}
}

Expand Down Expand Up @@ -109,6 +113,16 @@ impl Abigen {
self
}

/// Sets the derives to be added to the generated types.
///
/// # Arguments
///
/// * `derives` - Derives to be added to the generated types.
pub fn with_derives(mut self, derives: Vec<String>) -> Self {
self.derives = derives;
self
}

/// Generates the contract bindings.
pub fn generate(&self) -> Result<ContractBindings> {
let file_content = std::fs::read_to_string(&self.abi_source)?;
Expand Down

0 comments on commit 6c90910

Please sign in to comment.