Skip to content

Commit

Permalink
Add missing stateMutability field to AbiFunctionEntry (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
xJonathanLEI committed Jan 9, 2022
1 parent 2dfab64 commit 6af00e8
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions starknet-core/src/types/contract_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ pub struct Constructor {
}

#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Function {
pub name: String,
pub inputs: Vec<Input>,
pub outputs: Vec<Output>,
pub state_mutability: Option<String>,
}

#[derive(Debug, Serialize, Deserialize)]
Expand Down Expand Up @@ -86,10 +88,18 @@ mod tests {
if let AbiEntry::Function(f) = &abi[1] {
assert_eq!(f.name, "execute");
assert_eq!(f.inputs.len(), 5);
assert_eq!(f.state_mutability, None);
} else {
panic!("Did not deserialize AbiEntry::Function properly");
}

if let AbiEntry::Function(f) = &abi[9] {
assert_eq!(f.name, "is_valid_signature");
assert_eq!(f.inputs.len(), 3);
assert_eq!(f.state_mutability, Some(String::from("view")));
} else {
panic!("Did not deserialize AbiEntry::Function properly");
}
// TODO: use abi[9] to test "stateMutability" param
}

#[test]
Expand All @@ -115,9 +125,9 @@ mod tests {
}

if let AbiEntry::Function(f) = &abi[5] {
// TODO: stateMutability
assert_eq!(f.name, "g");
assert_eq!(f.outputs.len(), 1);
assert_eq!(f.state_mutability, Some(String::from("view")));
} else {
panic!("Did not deserialize AbiEntry::Function properly");
}
Expand Down

0 comments on commit 6af00e8

Please sign in to comment.