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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
use std::fmt::Display;
use fvm_ipld_encoding::tuple::*;
use fvm_ipld_encoding::{serde_bytes, Cbor, RawBytes};
use fvm_ipld_hamt::BytesKey;
use fvm_shared::address::Address;
use fvm_shared::bigint::bigint_ser;
use fvm_shared::clock::ChainEpoch;
use fvm_shared::econ::TokenAmount;
use fvm_shared::error::ExitCode;
use fvm_shared::MethodNum;
use integer_encoding::VarInt;
use serde::{Deserialize, Serialize};
pub const SIGNERS_MAX: usize = 256;
#[derive(Debug, Clone, Copy, Default, Serialize, Deserialize, Hash, Eq, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct TxnID(pub i64);
impl TxnID {
pub fn key(self) -> BytesKey {
self.0.encode_var_vec().into()
}
}
impl Display for TxnID {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "{}", self.0)
}
}
#[derive(Clone, PartialEq, Debug, Serialize_tuple, Deserialize_tuple)]
pub struct Transaction {
pub to: Address,
#[serde(with = "bigint_ser")]
pub value: TokenAmount,
pub method: MethodNum,
pub params: RawBytes,
pub approved: Vec<Address>,
}
#[derive(Serialize_tuple, Debug)]
pub struct ProposalHashData<'a> {
pub requester: Option<&'a Address>,
pub to: &'a Address,
#[serde(with = "bigint_ser")]
pub value: &'a TokenAmount,
pub method: &'a MethodNum,
pub params: &'a RawBytes,
}
#[derive(Serialize_tuple, Deserialize_tuple)]
pub struct ConstructorParams {
pub signers: Vec<Address>,
pub num_approvals_threshold: u64,
pub unlock_duration: ChainEpoch,
pub start_epoch: ChainEpoch,
}
#[derive(Serialize_tuple, Deserialize_tuple)]
pub struct ProposeParams {
pub to: Address,
#[serde(with = "bigint_ser")]
pub value: TokenAmount,
pub method: MethodNum,
pub params: RawBytes,
}
#[derive(Serialize_tuple, Deserialize_tuple)]
pub struct ProposeReturn {
pub txn_id: TxnID,
pub applied: bool,
pub code: ExitCode,
pub ret: RawBytes,
}
impl Cbor for ProposeParams {}
impl Cbor for ProposeReturn {}
#[derive(Clone, PartialEq, Debug, Serialize_tuple, Deserialize_tuple)]
pub struct TxnIDParams {
pub id: TxnID,
#[serde(with = "serde_bytes")]
pub proposal_hash: Vec<u8>,
}
#[derive(Serialize_tuple, Deserialize_tuple)]
pub struct ApproveReturn {
pub applied: bool,
pub code: ExitCode,
pub ret: RawBytes,
}
impl Cbor for TxnIDParams {}
impl Cbor for ApproveReturn {}
#[derive(Serialize_tuple, Deserialize_tuple)]
pub struct AddSignerParams {
pub signer: Address,
pub increase: bool,
}
#[derive(Serialize_tuple, Deserialize_tuple)]
pub struct RemoveSignerParams {
pub signer: Address,
pub decrease: bool,
}
impl Cbor for RemoveSignerParams {}
#[derive(Serialize_tuple, Deserialize_tuple)]
pub struct SwapSignerParams {
pub from: Address,
pub to: Address,
}
impl Cbor for SwapSignerParams {}
#[derive(Serialize_tuple, Deserialize_tuple)]
pub struct ChangeNumApprovalsThresholdParams {
pub new_threshold: u64,
}
#[derive(Serialize_tuple, Deserialize_tuple)]
pub struct LockBalanceParams {
pub start_epoch: ChainEpoch,
pub unlock_duration: ChainEpoch,
#[serde(with = "bigint_ser")]
pub amount: TokenAmount,
}