Skip to content

Commit 85ea37d

Browse files
committed
chore: release version 1.0.2
### Fixed - Fixed all Clippy warnings for better code quality - Fixed uninlined format arguments throughout the codebase - Fixed collapsible if statements for cleaner code - Fixed redundant closures - Replaced map_or with is_some_and for better readability - Fixed module inception in tests.rs - Changed len() > 0 to \!is_empty() for idiomatic Rust ### Changed - Improved code formatting and style consistency - Enhanced error messages with inline format strings
1 parent 7041726 commit 85ea37d

File tree

7 files changed

+349
-331
lines changed

7 files changed

+349
-331
lines changed

CHANGELOG.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,27 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [1.0.2] - 2025-01-06
11+
12+
### Fixed
13+
- Fixed all Clippy warnings for better code quality
14+
- Fixed uninlined format arguments throughout the codebase
15+
- Fixed collapsible if statements for cleaner code
16+
- Fixed redundant closures
17+
- Replaced `map_or` with `is_some_and` for better readability
18+
- Fixed module inception in tests.rs
19+
- Changed `len() > 0` to `!is_empty()` for idiomatic Rust
20+
21+
### Changed
22+
- Improved code formatting and style consistency
23+
- Enhanced error messages with inline format strings
24+
25+
## [1.0.1] - 2025-01-06
26+
27+
### Added
28+
- Prepared for crates.io publishing
29+
- Added comprehensive README documentation
30+
1031
## [1.0.0] - 2025-01-06
1132

1233
### Added
@@ -25,5 +46,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2546
- Multiple output format options
2647
- Human-readable function and event signatures
2748

28-
[Unreleased]: https://github.com/yourusername/abi2human-rs/compare/v1.0.0...HEAD
49+
[Unreleased]: https://github.com/yourusername/abi2human-rs/compare/v1.0.2...HEAD
50+
[1.0.2]: https://github.com/yourusername/abi2human-rs/compare/v1.0.1...v1.0.2
51+
[1.0.1]: https://github.com/yourusername/abi2human-rs/compare/v1.0.0...v1.0.1
2952
[1.0.0]: https://github.com/yourusername/abi2human-rs/releases/tag/v1.0.0

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "abi2human"
3-
version = "1.0.0"
3+
version = "1.0.2"
44
edition = "2021"
55
authors = ["Your Name <your.email@example.com>"]
66
description = "Zero-dependency CLI tool to convert Ethereum ABI JSON to human-readable format"

src/abi.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl fmt::Display for AbiItem {
6060
.join(", ")
6161
})
6262
.unwrap_or_default();
63-
write!(f, "constructor({})", params)
63+
write!(f, "constructor({params})")
6464
}
6565
"event" => {
6666
let params = self
@@ -116,7 +116,7 @@ impl fmt::Display for AbiItem {
116116
let output_params = outputs
117117
.iter()
118118
.map(|o| {
119-
let has_name = o.name.as_ref().map_or(false, |n| !n.is_empty());
119+
let has_name = o.name.as_ref().is_some_and(|n| !n.is_empty());
120120
if has_name {
121121
format!("{} {}", o.r#type, o.name.as_ref().unwrap())
122122
} else {
@@ -125,7 +125,7 @@ impl fmt::Display for AbiItem {
125125
})
126126
.collect::<Vec<_>>()
127127
.join(", ");
128-
format!(" returns ({})", output_params)
128+
format!(" returns ({output_params})")
129129
} else {
130130
String::new()
131131
}
@@ -134,7 +134,7 @@ impl fmt::Display for AbiItem {
134134
};
135135

136136
let vis = if visibility != "nonpayable" {
137-
format!(" {}", visibility)
137+
format!(" {visibility}")
138138
} else {
139139
String::new()
140140
};
@@ -154,7 +154,7 @@ impl fmt::Display for AbiItem {
154154
} else {
155155
""
156156
};
157-
write!(f, "fallback() external{}", payable)
157+
write!(f, "fallback() external{payable}")
158158
}
159159
"receive" => {
160160
write!(f, "receive() external payable")

src/file_ops.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub fn convert_file(
3939
input_path: input_path.to_path_buf(),
4040
output_path: output_path.map(|p| p.to_path_buf()),
4141
success: false,
42-
error: Some(format!("Failed to read file: {}", e)),
42+
error: Some(format!("Failed to read file: {e}")),
4343
item_count: None,
4444
};
4545
}
@@ -52,7 +52,7 @@ pub fn convert_file(
5252
input_path: input_path.to_path_buf(),
5353
output_path: output_path.map(|p| p.to_path_buf()),
5454
success: false,
55-
error: Some(format!("Failed to parse ABI: {}", e)),
55+
error: Some(format!("Failed to parse ABI: {e}")),
5656
item_count: None,
5757
};
5858
}
@@ -91,7 +91,7 @@ pub fn convert_file(
9191
input_path: input_path.to_path_buf(),
9292
output_path: Some(final_output_path),
9393
success: false,
94-
error: Some(format!("Failed to create directory: {}", e)),
94+
error: Some(format!("Failed to create directory: {e}")),
9595
item_count: Some(human_readable.len()),
9696
};
9797
}
@@ -110,7 +110,7 @@ pub fn convert_file(
110110
input_path: input_path.to_path_buf(),
111111
output_path: Some(final_output_path),
112112
success: false,
113-
error: Some(format!("Failed to write file: {}", e)),
113+
error: Some(format!("Failed to write file: {e}")),
114114
item_count: Some(human_readable.len()),
115115
},
116116
}
@@ -130,7 +130,7 @@ pub fn convert_directory(
130130
input_path: input_dir.to_path_buf(),
131131
output_path: None,
132132
success: false,
133-
error: Some(format!("Failed to read directory: {}", e)),
133+
error: Some(format!("Failed to read directory: {e}")),
134134
item_count: None,
135135
});
136136
return results;
@@ -198,10 +198,8 @@ fn matches_pattern(filename: &str, pattern: &str) -> bool {
198198
let mut filename_pos = 0;
199199

200200
for (i, part) in pattern_parts.iter().enumerate() {
201-
if part.is_empty() {
202-
if i == 0 || i == pattern_parts.len() - 1 {
203-
continue;
204-
}
201+
if part.is_empty() && (i == 0 || i == pattern_parts.len() - 1) {
202+
continue;
205203
}
206204

207205
if let Some(pos) = filename[filename_pos..].find(part) {

src/json_parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ impl JsonParser {
339339
self.advance();
340340
Ok(())
341341
} else {
342-
Err(format!("Expected '{}'", expected))
342+
Err(format!("Expected '{expected}'"))
343343
}
344344
}
345345
}

src/main.rs

Lines changed: 53 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ use std::env;
1010
use std::path::Path;
1111
use std::process;
1212

13-
const VERSION: &str = "1.0.0";
13+
const VERSION: &str = "1.0.2";
1414

1515
fn print_help() {
1616
println!(
1717
r#"
18-
abi2human v{} - Convert Ethereum ABI to human-readable format
18+
abi2human v{VERSION} - Convert Ethereum ABI to human-readable format
1919
Optimized for AI agents to efficiently consume smart contract interfaces
2020
2121
USAGE:
@@ -51,8 +51,7 @@ EXAMPLES:
5151
5252
FOR AI AGENTS:
5353
This tool helps you read Ethereum ABIs efficiently without consuming excessive tokens.
54-
"#,
55-
VERSION
54+
"#
5655
);
5756
}
5857

@@ -126,7 +125,7 @@ impl CliArgs {
126125
i += 1;
127126
}
128127

129-
if positionals.len() > 0 {
128+
if !positionals.is_empty() {
130129
cli_args.input = Some(positionals[0].clone());
131130
}
132131
if positionals.len() > 1 {
@@ -146,21 +145,21 @@ fn main() {
146145
}
147146

148147
if args.version {
149-
println!("abi2human v{}", VERSION);
148+
println!("abi2human v{VERSION}");
150149
process::exit(0);
151150
}
152151

153152
let log = |msg: &str| {
154153
if !args.quiet {
155-
eprintln!("{}", msg);
154+
eprintln!("{msg}");
156155
}
157156
};
158157

159158
if let Some(input) = args.input {
160159
let input_path = Path::new(&input);
161160

162161
if !input_path.exists() {
163-
eprintln!("Error: Input path '{}' does not exist", input);
162+
eprintln!("Error: Input path '{input}' does not exist");
164163
process::exit(1);
165164
}
166165

@@ -204,67 +203,65 @@ fn main() {
204203
}
205204
process::exit(1);
206205
}
207-
} else {
208-
if args.stdout {
209-
let content = match std::fs::read_to_string(input_path) {
210-
Ok(c) => c,
211-
Err(e) => {
212-
eprintln!("Error reading file: {}", e);
213-
process::exit(1);
214-
}
215-
};
216-
217-
let abi_items = match Converter::parse_abi_content(&content) {
218-
Ok(items) => items,
219-
Err(e) => {
220-
eprintln!("Error parsing ABI: {}", e);
221-
process::exit(1);
222-
}
223-
};
206+
} else if args.stdout {
207+
let content = match std::fs::read_to_string(input_path) {
208+
Ok(c) => c,
209+
Err(e) => {
210+
eprintln!("Error reading file: {e}");
211+
process::exit(1);
212+
}
213+
};
224214

225-
if abi_items.is_empty() {
226-
eprintln!("Error: No valid ABI found in file");
215+
let abi_items = match Converter::parse_abi_content(&content) {
216+
Ok(items) => items,
217+
Err(e) => {
218+
eprintln!("Error parsing ABI: {e}");
227219
process::exit(1);
228220
}
221+
};
229222

230-
let human_readable = Converter::convert_to_human_readable(&abi_items);
223+
if abi_items.is_empty() {
224+
eprintln!("Error: No valid ABI found in file");
225+
process::exit(1);
226+
}
231227

232-
if args.raw {
233-
for item in human_readable {
234-
println!("{}", item);
235-
}
236-
} else {
237-
let formatted = Converter::format_as_json_array(&human_readable, args.pretty);
238-
print!("{}", formatted);
239-
if args.pretty {
240-
println!();
241-
}
228+
let human_readable = Converter::convert_to_human_readable(&abi_items);
229+
230+
if args.raw {
231+
for item in human_readable {
232+
println!("{item}");
242233
}
243234
} else {
244-
let output_path = args.output.as_ref().map(|s| Path::new(s));
245-
let result = convert_file(input_path, output_path, &options);
246-
247-
if result.success {
248-
if let Some(output) = result.output_path {
249-
log(&format!(
250-
"✅ Converted {} → {} ({} items)",
251-
result.input_path.display(),
252-
output.display(),
253-
result.item_count.unwrap_or(0)
254-
));
255-
}
256-
} else {
257-
if let Some(error) = result.error {
258-
eprintln!("❌ Error: {}", error);
259-
}
260-
process::exit(1);
235+
let formatted = Converter::format_as_json_array(&human_readable, args.pretty);
236+
print!("{formatted}");
237+
if args.pretty {
238+
println!();
261239
}
262240
}
241+
} else {
242+
let output_path = args.output.as_ref().map(Path::new);
243+
let result = convert_file(input_path, output_path, &options);
244+
245+
if result.success {
246+
if let Some(output) = result.output_path {
247+
log(&format!(
248+
"✅ Converted {} → {} ({} items)",
249+
result.input_path.display(),
250+
output.display(),
251+
result.item_count.unwrap_or(0)
252+
));
253+
}
254+
} else {
255+
if let Some(error) = result.error {
256+
eprintln!("❌ Error: {error}");
257+
}
258+
process::exit(1);
259+
}
263260
}
264261
} else {
265262
let options = ConvertOptions::default();
266263
if let Err(e) = convert_stdin_to_stdout(&options) {
267-
eprintln!("Error: {}", e);
264+
eprintln!("Error: {e}");
268265
process::exit(1);
269266
}
270267
}

0 commit comments

Comments
 (0)