1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#![allow(missing_docs)]
use serde::{Deserialize, Serialize};
pub type RawAbi = Vec<Item>;
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Item {
#[serde(default)]
pub inputs: Vec<Component>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub state_mutability: Option<String>,
#[serde(rename = "type")]
pub type_field: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(default)]
pub outputs: Vec<Component>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Component {
#[serde(
rename = "internalType",
default,
skip_serializing_if = "Option::is_none"
)]
pub internal_type: Option<String>,
pub name: String,
#[serde(rename = "type")]
pub type_field: String,
#[serde(default)]
pub components: Vec<Component>,
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn can_parse_raw_abi() {
const VERIFIER_ABI: &str = include_str!("../../tests/solidity-contracts/verifier_abi.json");
let _ = serde_json::from_str::<RawAbi>(VERIFIER_ABI).unwrap();
}
}