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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
use crate::Abi;
use crate::{bytecode::Bytecode, DeploymentInformation};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use web3::types::Address;
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(default = "Contract::empty")]
pub struct Contract {
#[serde(rename = "contractName")]
pub name: String,
pub abi: Abi,
pub bytecode: Bytecode,
pub networks: HashMap<String, Network>,
pub devdoc: Documentation,
pub userdoc: Documentation,
}
impl Contract {
pub fn empty() -> Self {
Contract::with_name(String::default())
}
pub fn with_name(name: impl Into<String>) -> Self {
Contract {
name: name.into(),
abi: Abi {
constructor: None,
functions: HashMap::new(),
events: HashMap::new(),
fallback: false,
receive: false,
},
bytecode: Default::default(),
networks: HashMap::new(),
devdoc: Default::default(),
userdoc: Default::default(),
}
}
}
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Network {
pub address: Address,
#[serde(rename = "transactionHash")]
pub deployment_information: Option<DeploymentInformation>,
}
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
pub struct Documentation {
pub details: Option<String>,
pub methods: HashMap<String, DocEntry>,
}
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
pub struct DocEntry {
pub details: Option<String>,
}