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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
// Copyright 2019-2026 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT
use super::*;
use ::cid::Cid;
use fvm_ipld_encoding::RawBytes;
use jsonrpsee::core::Serialize;
use pastey::paste;
use schemars::JsonSchema;
use serde::Deserialize;
use std::fmt::Debug;
#[derive(Serialize, Deserialize, JsonSchema, Debug, Clone, PartialEq)]
#[serde(rename_all = "PascalCase")]
pub struct InitConstructorParamsLotusJson {
pub network_name: String,
}
#[derive(Serialize, Deserialize, JsonSchema, Debug, Clone, PartialEq)]
#[serde(rename_all = "PascalCase")]
pub struct InitExecParamsLotusJson {
#[schemars(with = "LotusJson<Cid>")]
#[serde(with = "crate::lotus_json")]
#[serde(rename = "CodeCID")]
pub code_cid: Cid,
#[schemars(with = "LotusJson<RawBytes>")]
#[serde(with = "crate::lotus_json")]
pub constructor_params: RawBytes,
}
#[derive(Serialize, Deserialize, JsonSchema, Debug, Clone, PartialEq)]
#[serde(rename_all = "PascalCase")]
pub struct InitExec4ParamsLotusJson {
#[schemars(with = "LotusJson<Cid>")]
#[serde(with = "crate::lotus_json")]
#[serde(rename = "CodeCID")]
pub code_cid: Cid,
#[schemars(with = "LotusJson<RawBytes>")]
#[serde(with = "crate::lotus_json")]
pub constructor_params: RawBytes,
#[schemars(with = "LotusJson<RawBytes>")]
#[serde(with = "crate::lotus_json")]
pub sub_address: RawBytes,
}
macro_rules! impl_lotus_json_for_init_constructor_params {
($($version:literal),+) => {
$(
paste! {
mod [<impl_lotus_json_for_init_constructor_params_ $version>] {
use super::*;
type T = fil_actor_init_state::[<v $version>]::ConstructorParams;
#[test]
fn snapshots() {
crate::lotus_json::assert_all_snapshots::<T>();
}
impl HasLotusJson for T {
type LotusJson = InitConstructorParamsLotusJson;
#[cfg(test)]
fn snapshots() -> Vec<(serde_json::Value, Self)> {
vec![
(
json!({
"NetworkName": "calibnet",
}),
Self {
network_name: "calibnet".to_string(),
},
),
]
}
fn into_lotus_json(self) -> Self::LotusJson {
Self::LotusJson {
network_name: self.network_name,
}
}
fn from_lotus_json(json: Self::LotusJson) -> Self {
Self {
network_name: json.network_name,
}
}
}
}
}
)+
}
}
macro_rules! impl_lotus_json_for_init_exec_params {
($($version:literal),+) => {
$(
paste! {
mod [<impl_lotus_json_for_init_exec_params_ $version>] {
use super::*;
type T = fil_actor_init_state::[<v $version>]::ExecParams;
#[test]
fn snapshots() {
crate::lotus_json::assert_all_snapshots::<T>();
}
impl HasLotusJson for T {
type LotusJson = InitExecParamsLotusJson;
#[cfg(test)]
fn snapshots() -> Vec<(serde_json::Value, Self)> {
vec![
(
json!({
"CodeCID": {
"/": "baeaaaaa"
},
"ConstructorParams": "ESIzRFU=",
}),
Self {
code_cid: Cid::default(),
constructor_params: RawBytes::new(hex::decode("1122334455").unwrap()),
},
),
]
}
fn into_lotus_json(self) -> Self::LotusJson {
Self::LotusJson {
code_cid: self.code_cid,
constructor_params: self.constructor_params,
}
}
fn from_lotus_json(json: Self::LotusJson) -> Self {
Self {
code_cid: json.code_cid,
constructor_params: json.constructor_params,
}
}
}
}
}
)+
};
}
macro_rules! impl_lotus_json_for_init_exec4_params {
($($version:literal),+) => {
$(
paste! {
mod [<impl_lotus_json_for_init_exec4_params_ $version>] {
use super::*;
type T = fil_actor_init_state::[<v $version>]::Exec4Params;
#[test]
fn snapshots() {
crate::lotus_json::assert_all_snapshots::<T>();
}
impl HasLotusJson for T {
type LotusJson = InitExec4ParamsLotusJson;
#[cfg(test)]
fn snapshots() -> Vec<(serde_json::Value, Self)> {
vec![
(
json!({
"CodeCID": {
"/": "baeaaaaa"
},
"ConstructorParams": "ESIzRFU=",
"SubAddress": "ESIzRFU=",
}),
Self {
code_cid: Cid::default(),
constructor_params: RawBytes::new(hex::decode("1122334455").unwrap()),
subaddress: RawBytes::new(hex::decode("1122334455").unwrap()),
},
),
]
}
fn into_lotus_json(self) -> Self::LotusJson {
Self::LotusJson {
code_cid: self.code_cid,
constructor_params: self.constructor_params,
sub_address: self.subaddress,
}
}
fn from_lotus_json(json: Self::LotusJson) -> Self {
Self {
code_cid: json.code_cid,
constructor_params: json.constructor_params,
subaddress: json.sub_address,
}
}
}
}
}
)+
};
}
impl_lotus_json_for_init_constructor_params!(8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18);
impl_lotus_json_for_init_exec_params!(8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18);
impl_lotus_json_for_init_exec4_params!(10, 11, 12, 13, 14, 15, 16, 17, 18);