pint_abi_types/
lib.rs

1use serde::{Deserialize, Serialize};
2
3/// A contract that consists of a set of predicates and a set of storage variables
4#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
5pub struct ContractABI {
6    pub predicates: Vec<PredicateABI>,
7    pub storage: Vec<StorageVarABI>,
8}
9
10/// A predicate in a contract that has a name and a list of parameters
11#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
12pub struct PredicateABI {
13    pub name: String,
14    pub params: Vec<ParamABI>,
15}
16
17/// A predicate parameter
18#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
19pub struct ParamABI {
20    pub name: String,
21    pub ty: TypeABI,
22}
23
24/// A storage variable
25#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
26pub struct StorageVarABI {
27    pub name: String,
28    pub ty: TypeABI,
29}
30
31#[derive(Debug, Clone, Eq, PartialEq, PartialOrd, Ord, Serialize, Deserialize)]
32pub struct TupleField {
33    pub name: Option<String>,
34    pub ty: TypeABI,
35}
36
37#[derive(Debug, Clone, Eq, PartialEq, PartialOrd, Ord, Serialize, Deserialize)]
38pub struct UnionVariant {
39    pub name: String,
40    pub ty: Option<TypeABI>,
41}
42
43#[derive(Debug, Clone, Eq, PartialEq, PartialOrd, Ord, Serialize, Deserialize)]
44pub enum TypeABI {
45    Bool,
46    Int,
47    Real,
48    String,
49    B256,
50    Optional(Box<Self>),
51    Tuple(Vec<TupleField>),
52    Array {
53        ty: Box<Self>,
54        size: i64,
55    },
56    Union {
57        name: String,
58        variants: Vec<UnionVariant>,
59    },
60    Map {
61        ty_from: Box<Self>,
62        ty_to: Box<Self>,
63    },
64}