Skip to content

Commit 4f52f46

Browse files
committed
Improve documentation, add missing fields
1 parent c5b97bb commit 4f52f46

File tree

3 files changed

+66
-8
lines changed

3 files changed

+66
-8
lines changed

xrpl_api/src/api/random.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
//! The random command provides a random number to be used as a source of
2+
//! entropy for random number generation by clients.
3+
//!
4+
//! - https://xrpl.org/random.html
5+
16
use crate::Request;
27
use serde::{Deserialize, Serialize};
38

4-
/// The random command provides a random number to be used as a source of
5-
/// entropy for random number generation by clients.
6-
///
7-
/// - https://xrpl.org/random.html
89
#[derive(Default, Clone, Serialize)]
910
pub struct RandomRequest {}
1011

xrpl_api/src/api/submit.rs

+25-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,31 @@
1+
//! The submit method applies a transaction and sends it to the network to be
2+
//! confirmed and included in future ledgers.
3+
//!
4+
//! This command has two modes:
5+
//!
6+
//! Submit-only mode takes a signed, serialized transaction as a binary blob,
7+
//! and submits it to the network as-is. Since signed transaction objects are
8+
//! immutable, no part of the transaction can be modified or automatically
9+
//! filled in after submission.
10+
//!
11+
//! Sign-and-submit mode takes a JSON-formatted Transaction object, completes
12+
//! and signs the transaction in the same manner as the sign method, and then
13+
//! submits the signed transaction. We recommend only using this mode for
14+
//! testing and development.
15+
//!
16+
//! To send a transaction as robustly as possible, you should construct and
17+
//! sign it in advance, persist it somewhere that you can access even after a
18+
//! power outage, then submit it as a tx_blob. After submission, monitor the
19+
//! network with the tx method command to see if the transaction was
20+
//! successfully applied; if a restart or other problem occurs, you can safely
21+
//! re-submit the tx_blob transaction: it won't be applied twice since it has
22+
//! the same sequence number as the old transaction.
23+
//!
24+
//! - https://xrpl.org/submit.html
25+
126
use crate::Request;
227
use serde::Serialize;
328

4-
/// - https://xrpl.org/submit.html
529
#[derive(Default, Clone, Serialize)]
630
pub struct SubmitRequest {
731
/// Hex representation of the signed transaction to submit. This can be a

xrpl_api/src/api/subscribe.rs

+36-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
//! The subscribe method requests periodic notifications from the server when
2+
//! certain events happen.
3+
//!
4+
//! - https://xrpl.org/subscribe.html
5+
16
use crate::Request;
27
use serde::{Deserialize, Serialize};
38

4-
/// https://xrpl.org/subscribe.html
59
#[derive(Default, Clone, Serialize)]
610
pub struct SubscribeRequest {
711
#[serde(skip_serializing_if = "Option::is_none")]
@@ -46,14 +50,43 @@ impl SubscribeRequest {
4650
}
4751
}
4852

53+
#[derive(Debug, Deserialize)]
54+
pub struct SubscribeResponse {}
55+
56+
// Streaming Events
57+
4958
#[derive(Debug, Serialize, Deserialize)]
5059
pub struct LedgerClosedEvent {
5160
#[serde(rename = "type")]
5261
pub event_type: String,
5362
pub fee_base: u32,
5463
pub fee_ref: u32,
64+
pub ledger_hash: String,
65+
pub ledger_index: u64,
66+
pub ledger_time: i64,
67+
pub reserve_base: u32,
68+
pub reserve_inc: u32,
5569
pub txn_count: u32,
70+
pub validated_ledgers: String,
5671
}
5772

58-
#[derive(Debug, Deserialize)]
59-
pub struct SubscribeResponse {}
73+
#[derive(Debug, Serialize, Deserialize)]
74+
pub struct ValidationReceivedEvent {
75+
#[serde(rename = "type")]
76+
pub event_type: String,
77+
pub base_fee: u32,
78+
pub cookie: Option<String>,
79+
pub flags: u32,
80+
pub ledger_hash: String,
81+
pub ledger_index: String,
82+
pub signature: String,
83+
// #TODO add missing fields
84+
}
85+
86+
#[derive(Debug, Serialize, Deserialize)]
87+
pub struct TransactionEvent {
88+
#[serde(rename = "type")]
89+
pub event_type: String,
90+
pub engine_result: String,
91+
// #TODO add missing fields
92+
}

0 commit comments

Comments
 (0)