Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(rs): add derives to builder pattern #50

Merged
merged 2 commits into from
Aug 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading