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
#[macro_use]
extern crate serde_derive;
#[cfg(test)]
#[macro_use]
extern crate serde_json;
extern crate serde;
extern crate base64;
#[cfg(test)]
mod tests;
mod types;
pub use types::*;
mod interop;
mod client;
pub use client::*;
mod crypto;
pub use crypto::*;
mod contracts;
pub use contracts::*;
#[derive(Debug, Deserialize)]
pub struct TonError {
source: String,
code: u32,
message: String,
}
impl TonError {
fn sdk(code: u32, message: &str) -> Self {
Self {
source: "sdk".to_string(),
code,
message: message.to_string(),
}
}
pub fn invalid_params(method_name: &str) -> Self {
Self::sdk(1, &format!("Can not serialize params for {}", method_name))
}
pub fn invalid_response_result(method_name: &str, result_json: &String) -> Self {
Self::sdk(2, &format!("Can not deserialize result for {}\nresult JSON: {}", method_name, result_json))
}
pub fn invalid_response_error(method_name: &str, error_json: &String) -> Self {
Self::sdk(3, &format!("Can not deserialize error for {}\nerror JSON: {}", method_name, error_json))
}
}
pub type TonResult<R> = Result<R, TonError>;