1mod api_logs;
2mod api_smart_contract_result;
3mod api_transaction_result;
4mod arg_create_transaction;
5mod events;
6mod get_transaction_response;
7mod log_data;
8mod multiple_transactions;
9mod simulate_gas;
10mod transaction_process_status;
11mod transaction_request;
12mod transaction_response_data;
13mod transaction_status;
14mod tx_cost;
15
16pub use api_logs::ApiLogs;
17pub use api_smart_contract_result::ApiSmartContractResult;
18pub use api_transaction_result::ApiTransactionResult;
19pub use arg_create_transaction::ArgCreateTransaction;
20pub use events::Events;
21pub use get_transaction_response::{GetTransactionResponse, GetTransactionResponseData};
22pub use log_data::LogData;
23pub use multiple_transactions::{MultipleTransactionsResponseData, ResponseMultipleTransactions};
24pub use simulate_gas::{SimulateGasTransactionData, SimulateGasTransactionResponse};
25pub use transaction_process_status::{ProcessStatusResponse, TransactionProcessStatus};
26pub use transaction_request::Transaction;
27pub use transaction_response_data::{ResponseTransaction, TransactionResponseData};
28pub use transaction_status::{ResponseTxStatus, TransactionStatus};
29pub use tx_cost::{ResponseTxCost, TxCostResponseData};
30
31#[deprecated(
32 since = "0.16.0",
33 note = "Renamed to ApiTransactionResult, matching the original Go implementation."
34)]
35pub type TransactionOnNetwork = ApiTransactionResult;
36
37#[deprecated(
38 since = "0.16.0",
39 note = "Renamed to GetTransactionResponse, matching the original Go implementation."
40)]
41pub type TransactionInfo = GetTransactionResponse;
42
43#[deprecated(
44 since = "0.16.0",
45 note = "Renamed to GetTransactionResponseData, matching the original Go implementation."
46)]
47pub type TransactionInfoData = GetTransactionResponseData;
48
49#[deprecated(
50 since = "0.16.0",
51 note = "Renamed to ResponseTransaction, matching the original Go implementation."
52)]
53pub type SendTransactionResponse = ResponseTransaction;
54
55#[deprecated(
56 since = "0.16.0",
57 note = "Renamed to TransactionResponseData, matching the original Go implementation."
58)]
59pub type SendTransactionData = TransactionResponseData;
60
61#[deprecated(
62 since = "0.16.0",
63 note = "Renamed to ResponseMultipleTransactions, matching the original Go implementation."
64)]
65pub type SendTransactionsResponse = ResponseMultipleTransactions;
66
67#[deprecated(
68 since = "0.16.0",
69 note = "Renamed to MultipleTransactionsResponseData, matching the original Go implementation."
70)]
71pub type SendTransactionsResponseData = MultipleTransactionsResponseData;
72
73#[deprecated(
74 since = "0.16.0",
75 note = "Renamed to ResponseTxCost, matching the original Go implementation."
76)]
77pub type TxCostResponse = ResponseTxCost;
78
79#[deprecated(
80 since = "0.16.0",
81 note = "Renamed to ResponseTxStatus, matching the original Go implementation."
82)]
83pub type TransactionStatusData = ResponseTxStatus;
84
85#[deprecated(
86 since = "0.16.0",
87 note = "Renamed to ProcessStatusResponse, matching the original Go implementation."
88)]
89pub type TransactionProcessStatusData = ProcessStatusResponse;
90
91#[cfg(test)]
92mod test {
93 use super::*;
94
95 #[test]
96 fn parse_event_log_null_data() {
97 let data = r#"
98{
99 "address": "erd1qqqqqqqqqqqqqpgq0628nau8zydgwu96fn8ksqklzhrggkcfq33sm4vmwv",
100 "identifier": "completedTxEvent",
101 "topics": [],
102 "data": null,
103 "additionalData": null
104}
105 "#;
106
107 let event_log = serde_json::from_str::<Events>(data).unwrap();
108 assert!(event_log.topics.is_empty());
109 assert_eq!(event_log.data, LogData::Empty);
110 }
111
112 #[test]
113 fn parse_event_log_no_topics() {
114 let data = r#"
115{
116 "address": "erd1qqqqqqqqqqqqqpgq0628nau8zydgwu96fn8ksqklzhrggkcfq33sm4vmwv",
117 "identifier": "completedTxEvent",
118 "data": null,
119 "additionalData": null
120}
121 "#;
122
123 let event_log = serde_json::from_str::<Events>(data).unwrap();
124 assert!(event_log.topics.is_empty());
125 }
126
127 #[test]
128 fn parse_event_log_null_additional_data() {
129 let data = r#"
130{
131 "address": "erd1qqqqqqqqqqqqqpgq0628nau8zydgwu96fn8ksqklzhrggkcfq33sm4vmwv",
132 "identifier": "completedTxEvent",
133 "topics": [],
134 "data": "data-string",
135 "additionalData": null
136}
137 "#;
138
139 let event_log = serde_json::from_str::<Events>(data).unwrap();
140 assert_eq!(event_log.data, LogData::String("data-string".to_owned()));
141 }
142
143 #[test]
144 fn parse_event_log_with_array_data() {
145 let data = r#"
146{
147 "address": "erd1qqqqqqqqqqqqqpgq0628nau8zydgwu96fn8ksqklzhrggkcfq33sm4vmwv",
148 "identifier": "completedTxEvent",
149 "topics": [],
150 "data": [
151 "data1",
152 "data2"
153 ],
154 "additionalData": null
155}
156 "#;
157
158 let event_log = serde_json::from_str::<Events>(data).unwrap();
159 assert_eq!(
160 event_log.data,
161 LogData::Vec(vec!["data1".to_owned(), "data2".to_owned()])
162 );
163 }
164
165 #[test]
166 fn parse_transaction_info_no_signature() {
167 let data = r#"
168{
169 "data": {
170 "transaction": {
171 "type": "unsigned",
172 "processingTypeOnSource": "SCInvoking",
173 "processingTypeOnDestination": "SCInvoking",
174 "hash": "34cd9c6d0f68c0975971352ed4dcaacc1acd9a2dbd8f5840a2866d09b1d72298",
175 "nonce": 0,
176 "round": 5616535,
177 "epoch": 2314,
178 "value": "0",
179 "receiver": "erd1qqqqqqqqqqqqqpgq0mhy244pyr9pzdhahvvyze4rw3xl29q4kklszyzq72",
180 "sender": "erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqzllls8a5w6u",
181 "gasPrice": 1000000000,
182 "gasLimit": 25411165,
183 "gasUsed": 1197500,
184 "data": "",
185 "previousTransactionHash": "6c105dc2bb6ca8b89cfcac910a46310812b51312a281837096fc94dd771bb652",
186 "originalTransactionHash": "100d1edd0434938ec39e6cb5059601b4618a1ca25b91c38e5be9e75444b3c4f5",
187 "originalSender": "erd1wavgcxq9tfyrw49k3s3h34085mayu82wqvpd4h6akyh8559pkklsknwhwh",
188 "sourceShard": 4294967295,
189 "destinationShard": 1,
190 "blockNonce": 5547876,
191 "blockHash": "0d7caaf8f2bf46e913f91867527d44cd1c77453c9aee50d91a10739bd272d00c",
192 "notarizedAtSourceInMetaNonce": 5551265,
193 "NotarizedAtSourceInMetaHash": "4c87bc5161925a3902e43a7f9f186e63f21f827ef1129ad0e609a0d45dca016a",
194 "notarizedAtDestinationInMetaNonce": 5551269,
195 "notarizedAtDestinationInMetaHash": "83bfa8463558ee6d2c90b34ee03782619b699fea667acfb98924227bacbba93d",
196 "miniblockType": "SmartContractResultBlock",
197 "miniblockHash": "c12693db88e3b69b68d5279fd8939ec75b7f0d8e529e7fd950c83b5716a436bd",
198 "hyperblockNonce": 5551269,
199 "hyperblockHash": "83bfa8463558ee6d2c90b34ee03782619b699fea667acfb98924227bacbba93d",
200 "timestamp": 1727699210,
201 "logs": {
202 "address": "erd1qqqqqqqqqqqqqpgq0mhy244pyr9pzdhahvvyze4rw3xl29q4kklszyzq72",
203 "events": [
204 {
205 "address": "erd1qqqqqqqqqqqqqpgq0mhy244pyr9pzdhahvvyze4rw3xl29q4kklszyzq72",
206 "identifier": "transferValueOnly",
207 "topics": [
208 "I4byb8EAAA==",
209 "AAAAAAAAAAAFAMMiO8pDAH5z5hUCqfc+N03C7UI6tb8="
210 ],
211 "data": "RXhlY3V0ZU9uRGVzdENvbnRleHQ=",
212 "additionalData": [
213 "RXhlY3V0ZU9uRGVzdENvbnRleHQ=",
214 "ZGVwbG95SW50ZXJjaGFpblRva2Vu",
215 "GeLN3wLxaJKDPbaxdmqkIh0pFNi1l8WJeqy9TofeG40=",
216 "YXZhbGFuY2hlLWZ1amk=",
217 "SVRTVGVzdFRva2Vu",
218 "SVRTVFQ=",
219 "Bg==",
220 "d1iMGAVaSDdUtowjeNXnpvpOHU4DAtrfXbEuelChtb8="
221 ]
222 }
223 ]
224 },
225 "status": "success",
226 "operation": "transfer",
227 "fee": "0",
228 "callType": "asynchronousCallBack",
229 "options": 0
230 }
231 },
232 "error": "",
233 "code": "successful"
234}
235 "#;
236
237 let transaction = serde_json::from_str::<GetTransactionResponse>(data).unwrap();
238 assert_eq!(
239 transaction.data.unwrap().transaction.hash.unwrap(),
240 "34cd9c6d0f68c0975971352ed4dcaacc1acd9a2dbd8f5840a2866d09b1d72298"
241 );
242 }
243}