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
//! For balance related functions.
use *;
/// Return its current balance for a specific entry credit address.
/// # Example
/// ```
/// use factom::*;
///
/// #[tokio::main]
/// async fn main() {
/// let client = Factom::testnet_node();
/// let ec_address = "EC2MJzCcHqYJyujnPzjitEaHhtEPVBhmEWUKkv4SVaaKeYcq3fqK";
/// let response = balance::multiple_ec_balances(&client, vec![ec_address])
/// .await
/// .expect("Fetching query");
/// dbg!(&response);
/// assert!(response.success());
/// }
/// ```
pub async
/// This call returns the number of Factoshis (Factoids *10^-8) that are
/// currently available at the address specified.
///
/// # Example
/// ```
/// use factom::*;
///
/// #[tokio::main]
///async fn main() {
/// let client = Factom::testnet_node();
/// let fct_address = "FA2jK2HcLnRdS94dEcU27rF3meoJfpUcZPSinpb7AwQvPRY6RL1Q";
/// let response = balance::factoid_balance(&client, fct_address)
/// .await
/// .expect("Fetching query");
/// assert!(response.result.balance > 0);
/// }
/// ```
pub async
/// The multiple-ec-balances API is used to query the acknowledged and saved
/// balances for a list of entry credit addresses.
///
/// * currentheight is the current height that factomd was loading.
/// * lastsavedheight is the height last saved to the database.
///
/// * In balances it returns "ack", "saved" and "err".
/// * ack is the balance after processing any in-flight transactions known to
/// the Factom node responding to the API call
/// * saved is the last saved to the database
/// * err is just used to display any error that might have happened during the
/// request. If it is empty that means there was no error.
///
/// * If the syntax of the parameters is off e.g. missing a quote, a comma, or a
/// square bracket, it will return: `{“jsonrpc”:“2.0”,“id”:null,“error”:
/// {“code”:-32600,“message”:“Invalid Request”}}`
///
/// * If the parameters are labeled incorrectly the call will return:
/// `{“code”:-32602,“message”:“Invalid params”,“data”:“ERROR! Invalid params passed
/// in, expected addresses”}`
///
/// * If factomd is not loaded up all the way to the last saved block it will
/// return: `{“currentheight”:0,“lastsavedheight”:0,“balances”:[{“ack”:0,“saved”:0,
/// “err”:“Not fully booted”}]}`
///
/// * If the list of addresses contains an incorrectly formatted address the call
/// will return: `{“currentheight”:0,“lastsavedheight”:0,“balances”:[{“ack”:0,
/// “saved”:0,“err”:“Error decoding address”}]}`
///
/// * If an address in the list is valid but has never been part of a transaction
/// the call will return: `“balances”:[{“ack”:0,“saved”:0,“err”:“Address has not
/// had a transaction”}]`
/// # Example
/// ```
/// use factom::*;
///
/// #[tokio::main]
/// async fn main() {
/// let client = Factom::testnet_node();
/// let ec_address = "EC2MJzCcHqYJyujnPzjitEaHhtEPVBhmEWUKkv4SVaaKeYcq3fqK";
/// let response = balance::multiple_ec_balances(&client, vec![ec_address])
/// .await
/// .expect("Fetching query");
/// assert!(response.success());
/// }
/// ```
pub async
/// The multiple-fct-balances API is used to query the acknowledged and saved
/// balances in factoshis (a factoshi is 10^8 factoids) not factoids(FCT) for a
/// list of FCT addresses.
///
/// * currentheight is the current height that factomd was loading.
/// * lastsavedheight is the height last saved to the database.
///
/// * In balances it returns "ack", "saved" and "err".
/// * ack is the balance after processing any in-flight transactions known to
/// the Factom node responding to the API call
/// * saved is the last saved to the database
/// * err is just used to display any error that might have happened during the
/// request. If it is "" that means there was no error.
///
/// * If the syntax of the parameters is off e.g. missing a quote, a comma, or a
/// square bracket, it will return: `{”jsonrpc”:“2.0”,“id”:null,“error”:
/// {“code”:-32600,“message”:“Invalid Request”}}`
///
/// * If the parameters are labeled incorrectly the call will return: `
/// {“code”:-32602,“message”:“Invalid params”,“data”:“ERROR! Invalid params passed in, expected 'addresses’”}`
///
/// * If factomd is not loaded up all the way to the last saved block it will
/// return: `{“currentheight”:0,“lastsavedheight”:0,“balances”:
/// [{“ack”:0,“saved”:0,“err”:“Not fully booted”}]}`
///
/// * If the list of addresses contains an incorrectly formatted address the call
/// will return: `{“currentheight”:0,“lastsavedheight”:0,
/// “balances”:[{“ack”:0,“saved”:0,“err”:“Error decoding address”}]}`
///
/// * If an address in the list is valid but has never been part of a transaction
/// it will return: `“balances”:[{“ack”:0,“saved”:0,“err”:“Address has not had a
/// transaction”}]`
/// # Example
/// ```
/// use factom::*;
///
/// #[tokio::main]
/// async fn main() {
/// let client = Factom::testnet_node();
/// let fct_address = "FA2jK2HcLnRdS94dEcU27rF3meoJfpUcZPSinpb7AwQvPRY6RL1Q";
/// let response = balance::multiple_fct_balances(&client, vec![fct_address])
/// .await
/// .expect("Fetching query");
/// assert!(response.success());
/// }
/// ```
pub async
/// entry-credit-balance and factoid-balance functions
/// Struct for deserialising multiple-fct-balances and multiple-ec-balances