fix(abigen): support functions with different casing (#972)

This commit is contained in:
Matthias Seitz 2022-02-27 16:40:57 +01:00 committed by GitHub
parent 133c32d64a
commit 10fcf60791
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions

View File

@ -342,7 +342,7 @@ impl Context {
let mut all_functions = HashMap::new(); let mut all_functions = HashMap::new();
for function in self.abi.functions() { for function in self.abi.functions() {
all_functions all_functions
.entry(function.name.to_lowercase()) .entry(util::safe_snake_case_ident(&function.name))
.or_insert_with(Vec::new) .or_insert_with(Vec::new)
.push(function); .push(function);
} }

View File

@ -427,6 +427,23 @@ fn can_generate_nested_types() {
assert_eq!(call, decoded_call); assert_eq!(call, decoded_call);
} }
#[test]
fn can_handle_different_calls() {
abigen!(
Test,
r#"[
function fooBar()
function FOO_BAR()
]"#,
);
let (client, _mock) = Provider::mocked();
let contract = Test::new(Address::default(), Arc::new(client));
let _ = contract.fooBar();
let _ = contract.FOO_BAR();
}
#[test] #[test]
fn can_handle_case_sensitive_calls() { fn can_handle_case_sensitive_calls() {
abigen!( abigen!(