-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathmod.rs
More file actions
166 lines (155 loc) · 4.69 KB
/
mod.rs
File metadata and controls
166 lines (155 loc) · 4.69 KB
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
pub mod account_root;
pub mod amendments;
pub mod amm;
pub mod bridge;
pub mod check;
pub mod deposit_preauth;
pub mod directory_node;
pub mod escrow;
pub mod fee_settings;
pub mod ledger_hashes;
pub mod negative_unl;
pub mod nftoken_offer;
pub mod nftoken_page;
pub mod offer;
pub mod pay_channel;
pub mod permissioned_domain;
pub mod ripple_state;
pub mod signer_list;
pub mod ticket;
pub mod xchain_owned_claim_id;
pub mod xchain_owned_create_account_claim_id;
use account_root::AccountRoot;
use amendments::Amendments;
use amm::AMM;
use bridge::Bridge;
use check::Check;
use deposit_preauth::DepositPreauth;
use derive_new::new;
use directory_node::DirectoryNode;
use escrow::Escrow;
use fee_settings::FeeSettings;
use ledger_hashes::LedgerHashes;
use negative_unl::NegativeUNL;
use nftoken_offer::NFTokenOffer;
use nftoken_page::NFTokenPage;
use offer::Offer;
use pay_channel::PayChannel;
use permissioned_domain::PermissionedDomain;
use ripple_state::RippleState;
use signer_list::SignerList;
use strum::IntoEnumIterator;
use alloc::borrow::Cow;
use serde::{Deserialize, Serialize};
use serde_with::skip_serializing_none;
use strum_macros::Display;
use ticket::Ticket;
use xchain_owned_claim_id::XChainOwnedClaimID;
use xchain_owned_create_account_claim_id::XChainOwnedCreateAccountClaimID;
use crate::_serde::lgr_obj_flags;
use crate::models::{Amount, FlagCollection};
#[derive(Debug, Clone, Serialize, Deserialize, Display, PartialEq, Eq)]
pub enum LedgerEntryType {
AccountRoot = 0x0061,
Amendments = 0x0066,
AMM = 0x0079,
Bridge = 0x0069,
Check = 0x0043,
DepositPreauth = 0x0070,
DirectoryNode = 0x0064,
Escrow = 0x0075,
FeeSettings = 0x0073,
LedgerHashes = 0x0068,
NegativeUNL = 0x004E,
NFTokenOffer = 0x0037,
NFTokenPage = 0x0050,
Offer = 0x006F,
PayChannel = 0x0078,
PermissionedDomain = 0x0082,
RippleState = 0x0072,
SignerList = 0x0053,
Ticket = 0x0054,
XChainOwnedClaimID = 0x0071,
XChainOwnedCreateAccountClaimID = 0x0074,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub enum LedgerEntry<'a> {
AccountRoot(AccountRoot<'a>),
Amendments(Amendments<'a>),
AMM(AMM<'a>),
Bridge(Bridge<'a>),
Check(Check<'a>),
DepositPreauth(DepositPreauth<'a>),
DirectoryNode(DirectoryNode<'a>),
Escrow(Escrow<'a>),
FeeSettings(FeeSettings<'a>),
LedgerHashes(LedgerHashes<'a>),
NegativeUNL(NegativeUNL<'a>),
NFTokenOffer(NFTokenOffer<'a>),
NFTokenPage(NFTokenPage<'a>),
Offer(Offer<'a>),
PayChannel(PayChannel<'a>),
PermissionedDomain(PermissionedDomain<'a>),
RippleState(RippleState<'a>),
SignerList(SignerList<'a>),
Ticket(Ticket<'a>),
XChainOwnedClaimID(XChainOwnedClaimID<'a>),
XChainOwnedCreateAccountClaimID(XChainOwnedCreateAccountClaimID<'a>),
}
#[skip_serializing_none]
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "PascalCase")]
pub struct XChainClaimProofSig<'a> {
pub amount: Amount<'a>,
pub attestation_reward_account: Cow<'a, str>,
pub attestation_signer_account: Cow<'a, str>,
pub destination: Cow<'a, str>,
pub public_key: Cow<'a, str>,
pub was_locking_chain_send: u8,
}
/// The base fields for all ledger object models.
///
/// See Ledger Object Common Fields:
/// `<https://xrpl.org/ledger-entry-common-fields.html>`
#[skip_serializing_none]
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Clone, new)]
#[serde(rename_all = "PascalCase")]
pub struct CommonFields<'a, F>
where
F: IntoEnumIterator + Serialize + core::fmt::Debug,
{
/// A bit-map of boolean flags enabled for this account.
#[serde(with = "lgr_obj_flags")]
pub flags: FlagCollection<F>,
/// The type of the ledger object.
pub ledger_entry_type: LedgerEntryType,
/// The object ID of a single object to retrieve from the ledger, as a
/// 64-character (256-bit) hexadecimal string.
#[serde(rename = "index")]
pub index: Option<Cow<'a, str>>,
/// The object ID in transaction metadata of a single object to retrieve from the ledger, as a
/// 64-character (256-bit) hexadecimal string.
pub ledger_index: Option<Cow<'a, str>>,
}
impl<'a, T> LedgerObject<T> for CommonFields<'a, T>
where
T: IntoEnumIterator + Serialize + PartialEq + core::fmt::Debug,
{
fn has_flag(&self, flag: &T) -> bool {
self.flags.0.contains(flag)
}
fn get_ledger_entry_type(&self) -> LedgerEntryType {
self.ledger_entry_type.clone()
}
}
/// Standard functions for ledger objects.
pub trait LedgerObject<T>
where
T: IntoEnumIterator + Serialize,
{
fn has_flag(&self, flag: &T) -> bool {
let _txn_flag = flag;
false
}
fn get_ledger_entry_type(&self) -> LedgerEntryType;
}