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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
use Vec;
use crate;
use crateruntime;
use crateLogLevel;
/// With this method, another contract can be called, Please refer to the corresponding simple_call.
///
/// addr: Called contract address
///
/// input: Parameters required to call the target contract method
///
/// # Example
/// ```no_run
/// # use fvm_std::advance::call_contract;
/// # use fvm_std::types::Address;
/// let addr = Address::repeat_byte(1u8);
/// let res = call_contract(&addr, addr.as_bytes());
/// ```
/// With this method, another contract can be called.
///
/// cns: Called contract cns name
///
/// input: Parameters required to call the target contract method
///
/// # Example
/// ```no_run
/// # use fvm_std::advance::cns_call_contract;
/// # use fvm_std::types::Address;
/// let cns_name = "hello".as_bytes();
/// let input = "world".as_bytes();
/// let res = cns_call_contract(cns_name, input);
/// ```
///Save key-value as a key-value pair
///
/// 对于一般的的属性存储:
/// `fieldName + key => Gson(value)`
/// ---prefix--|--key---|----value--
/// 对于Map, List等的存储:
/// `fieldName + @ + Gson(key) => value`
/// ---prefix------|---key----|----value--
///
/// # Example
///
///```no_run
/// use fvm_std::advance::storage_write;
/// let key = "key";
/// let prefix = "map";
/// let value = "value";
/// storage_write(key.as_bytes(), value.as_bytes());
/// ```
///
///Read key-value pairs according to key.
///
/// # Example
///
///```no_run
/// # use fvm_std::advance::storage_read;
/// let key = "key";
/// let res: Option<Vec<u8>> = storage_read(key.as_bytes());
/// ```
///
///Delte key-value from ledger
///
/// 对于一般的的属性存储:
/// `fieldName + key => Gson(value)`
/// ---prefix--|--key---|----value--
/// 对于Map, List等的存储:
/// `fieldName + @ + Gson(key) => value`
/// ---prefix------|---key----|----value--
///
/// # Example
///
///```no_run
/// # use fvm_std::advance::storage_delete;
/// let key = "key";
/// let prefix = "map";
/// let value = "value";
/// storage_delete(key.as_bytes());
/// ```
///
/// Get timestamp in current block
/// # Example
///
/// ```no_run
/// # use fvm_std::advance::block_time;
/// let res = block_time();
/// ```
///
/// Get current block height
/// # Example
///
/// ```no_run
/// use fvm_std::advance::block_height;
/// let res = block_height();
/// ```
///
/// Get the address of current executing contract
/// # Example
///
/// ```no_run
/// use fvm_std::advance::self_address;
/// let res = self_address();
/// ```
///
///return Caller's contract address
/// # Example
///
///```no_run
/// use fvm_std::advance::caller_address;
/// let res = caller_address();
/// ```
///
///return the origin Caller's contract address, it is same with `caller_address`
/// in normal call, but in cross call, the `origin_address` return the origin
/// caller address.
/// # Example
///
///```no_run
/// use fvm_std::advance::origin_address;
/// let res = origin_address();
/// ```
///
///return current tx hash
/// # Example
///
///```no_run
/// use fvm_std::advance::tx_hash;
/// let res = tx_hash();
/// ```
///
/// Calculate the hash value
/// # Example
///
/// ```no_run
/// use fvm_std::advance::sha256;
/// let res = sha256("test");
/// ```
///
/// Get input data from transaction or caller contract
/// # Example
///
/// ```no_run
/// use fvm_std::advance::input;
/// let input = input();
/// ```
///
/// return the result of execution and exit contract execution
/// # Example
///
/// ```no_run
/// use fvm_std::advance::{input, ret};
/// let input = input();
/// ret(input.as_slice());
/// ```
///
// /// used for event, or use it with correct format
// pub fn event(data: &[u8]) {
// runtime::event(data)
// }
// /// output debugging information
// pub fn log(class_name: &[u8], data: &[u8], level: LogLevel) {
// runtime::log(class_name, data, level)
// }
/// When the function is executed, all writes to the chain will be cancelled, and the error message will be returned.
///
/// # Example
///
/// ```no_run
/// use fvm_std::advance::revert;
/// revert("panic");
/// ```
///
!