Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nft support #95

Merged
merged 8 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/asynch/account/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ where
None,
classic_address,
None,
Some(ledger_index),
Some(ledger_index.into()),
None,
None,
None,
Expand Down
9 changes: 9 additions & 0 deletions src/models/flag_collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,15 @@ where
}
}

impl<T> FlagCollection<T>
where
T: IntoEnumIterator + Serialize,
{
pub fn len(&self) -> usize {
self.0.len()
}
}

fn flag_to_u32<T>(flag: &T) -> XRPLModelResult<u32>
where
T: Serialize,
Expand Down
22 changes: 11 additions & 11 deletions src/models/requests/account_channels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use serde_with::skip_serializing_none;

use crate::models::{requests::RequestMethod, Model};

use super::{CommonFields, Request};
use super::{CommonFields, LedgerIndex, LookupByLedgerRequest, Marker, Request};

/// This request returns information about an account's Payment
/// Channels. This includes only channels where the specified
Expand Down Expand Up @@ -42,11 +42,9 @@ pub struct AccountChannels<'a> {
/// account's Address. The request returns channels where
/// this account is the channel's owner/source.
pub account: Cow<'a, str>,
/// A 20-byte hex string for the ledger version to use.
pub ledger_hash: Option<Cow<'a, str>>,
/// The ledger index of the ledger to use, or a shortcut
/// string to choose a ledger automatically.
pub ledger_index: Option<Cow<'a, str>>,
/// The unique identifier of a ledger.
#[serde(flatten)]
pub ledger_lookup: Option<LookupByLedgerRequest<'a>>,
/// Limit the number of transactions to retrieve. Cannot
/// be less than 10 or more than 400. The default is 200.
pub limit: Option<u16>,
Expand All @@ -56,7 +54,7 @@ pub struct AccountChannels<'a> {
pub destination_account: Option<Cow<'a, str>>,
/// Value from a previous paginated response.
/// Resume retrieving data where that response left off.
pub marker: Option<u32>,
pub marker: Option<Marker<'a>>,
}

impl<'a> Model for AccountChannels<'a> {}
Expand All @@ -67,18 +65,20 @@ impl<'a> AccountChannels<'a> {
account: Cow<'a, str>,
destination_account: Option<Cow<'a, str>>,
ledger_hash: Option<Cow<'a, str>>,
ledger_index: Option<Cow<'a, str>>,
ledger_index: Option<LedgerIndex<'a>>,
limit: Option<u16>,
marker: Option<u32>,
marker: Option<Marker<'a>>,
) -> Self {
Self {
common_fields: CommonFields {
command: RequestMethod::AccountChannels,
id,
},
account,
ledger_hash,
ledger_index,
ledger_lookup: Some(LookupByLedgerRequest {
ledger_hash,
ledger_index,
}),
limit,
destination_account,
marker,
Expand Down
18 changes: 9 additions & 9 deletions src/models/requests/account_currencies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use serde_with::skip_serializing_none;

use crate::models::{default_false, requests::RequestMethod, Model};

use super::{CommonFields, Request};
use super::{CommonFields, LedgerIndex, LookupByLedgerRequest, Request};

/// This request retrieves a list of currencies that an account
/// can send or receive, based on its trust lines. This is not
Expand All @@ -22,11 +22,9 @@ pub struct AccountCurrencies<'a> {
/// A unique identifier for the account, most commonly
/// the account's Address.
pub account: Cow<'a, str>,
/// A 20-byte hex string for the ledger version to use.
pub ledger_hash: Option<Cow<'a, str>>,
/// The ledger index of the ledger to use, or a shortcut
/// string to choose a ledger automatically.
pub ledger_index: Option<Cow<'a, str>>,
/// The unique identifier of a ledger.
#[serde(flatten)]
pub ledger_lookup: Option<LookupByLedgerRequest<'a>>,
/// If true, then the account field only accepts a public
/// key or XRP Ledger address. Otherwise, account can be
/// a secret or passphrase (not recommended).
Expand All @@ -52,7 +50,7 @@ impl<'a> AccountCurrencies<'a> {
id: Option<Cow<'a, str>>,
account: Cow<'a, str>,
ledger_hash: Option<Cow<'a, str>>,
ledger_index: Option<Cow<'a, str>>,
ledger_index: Option<LedgerIndex<'a>>,
strict: Option<bool>,
) -> Self {
Self {
Expand All @@ -61,8 +59,10 @@ impl<'a> AccountCurrencies<'a> {
id,
},
account,
ledger_hash,
ledger_index,
ledger_lookup: Some(LookupByLedgerRequest {
ledger_hash,
ledger_index,
}),
strict,
}
}
Expand Down
18 changes: 9 additions & 9 deletions src/models/requests/account_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use serde_with::skip_serializing_none;

use crate::models::{requests::RequestMethod, Model};

use super::{CommonFields, Request};
use super::{CommonFields, LedgerIndex, LookupByLedgerRequest, Request};

/// This request retrieves information about an account, its
/// activity, and its XRP balance. All information retrieved
Expand All @@ -21,11 +21,9 @@ pub struct AccountInfo<'a> {
/// A unique identifier for the account, most commonly the
/// account's Address.
pub account: Cow<'a, str>,
/// A 20-byte hex string for the ledger version to use.
pub ledger_hash: Option<Cow<'a, str>>,
/// The ledger index of the ledger to use, or a shortcut
/// string to choose a ledger automatically.
pub ledger_index: Option<Cow<'a, str>>,
/// The unique identifier of a ledger.
#[serde(flatten)]
pub ledger_lookup: Option<LookupByLedgerRequest<'a>>,
/// If true, then the account field only accepts a public
/// key or XRP Ledger address. Otherwise, account can be
/// a secret or passphrase (not recommended).
Expand Down Expand Up @@ -59,7 +57,7 @@ impl<'a> AccountInfo<'a> {
id: Option<Cow<'a, str>>,
account: Cow<'a, str>,
ledger_hash: Option<Cow<'a, str>>,
ledger_index: Option<Cow<'a, str>>,
ledger_index: Option<LedgerIndex<'a>>,
strict: Option<bool>,
queue: Option<bool>,
signer_lists: Option<bool>,
Expand All @@ -70,8 +68,10 @@ impl<'a> AccountInfo<'a> {
id,
},
account,
ledger_hash,
ledger_index,
ledger_lookup: Some(LookupByLedgerRequest {
ledger_hash,
ledger_index,
}),
strict,
queue,
signer_lists,
Expand Down
18 changes: 9 additions & 9 deletions src/models/requests/account_lines.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use serde_with::skip_serializing_none;

use crate::models::{requests::RequestMethod, Model};

use super::{CommonFields, Request};
use super::{CommonFields, LedgerIndex, LookupByLedgerRequest, Request};

/// This request returns information about an account's trust
/// lines, including balances in all non-XRP currencies and
Expand All @@ -22,11 +22,9 @@ pub struct AccountLines<'a> {
/// A unique identifier for the account, most commonly the
/// account's Address.
pub account: Cow<'a, str>,
/// A 20-byte hex string for the ledger version to use.
pub ledger_hash: Option<Cow<'a, str>>,
/// The ledger index of the ledger to use, or a shortcut
/// string to choose a ledger automatically.
pub ledger_index: Option<Cow<'a, str>>,
/// The unique identifier of a ledger.
#[serde(flatten)]
pub ledger_lookup: Option<LookupByLedgerRequest<'a>>,
/// Limit the number of trust lines to retrieve. The server
/// is not required to honor this value. Must be within the
/// inclusive range 10 to 400.
Expand All @@ -53,7 +51,7 @@ impl<'a> AccountLines<'a> {
id: Option<Cow<'a, str>>,
account: Cow<'a, str>,
ledger_hash: Option<Cow<'a, str>>,
ledger_index: Option<Cow<'a, str>>,
ledger_index: Option<LedgerIndex<'a>>,
limit: Option<u16>,
peer: Option<Cow<'a, str>>,
) -> Self {
Expand All @@ -63,8 +61,10 @@ impl<'a> AccountLines<'a> {
id,
},
account,
ledger_hash,
ledger_index,
ledger_lookup: Some(LookupByLedgerRequest {
ledger_hash,
ledger_index,
}),
limit,
peer,
}
Expand Down
6 changes: 3 additions & 3 deletions src/models/requests/account_nfts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use serde_with::skip_serializing_none;

use crate::models::{requests::RequestMethod, Model};

use super::{CommonFields, Request};
use super::{CommonFields, Marker, Request};

/// This method retrieves all of the NFTs currently owned
/// by the specified account.
Expand All @@ -24,7 +24,7 @@ pub struct AccountNfts<'a> {
pub limit: Option<u32>,
/// Value from a previous paginated response. Resume
/// retrieving data where that response left off.
pub marker: Option<u32>,
pub marker: Option<Marker<'a>>,
}

impl<'a> Model for AccountNfts<'a> {}
Expand All @@ -44,7 +44,7 @@ impl<'a> AccountNfts<'a> {
id: Option<Cow<'a, str>>,
account: Cow<'a, str>,
limit: Option<u32>,
marker: Option<u32>,
marker: Option<Marker<'a>>,
) -> Self {
Self {
common_fields: CommonFields {
Expand Down
22 changes: 11 additions & 11 deletions src/models/requests/account_objects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use strum_macros::Display;

use crate::models::{requests::RequestMethod, Model};

use super::{CommonFields, Request};
use super::{CommonFields, LedgerIndex, LookupByLedgerRequest, Marker, Request};

/// Represents the object types that an AccountObjects
/// Request can ask for.
Expand Down Expand Up @@ -39,11 +39,9 @@ pub struct AccountObjects<'a> {
/// A unique identifier for the account, most commonly the
/// account's address.
pub account: Cow<'a, str>,
/// A 20-byte hex string for the ledger version to use.
pub ledger_hash: Option<Cow<'a, str>>,
/// The ledger index of the ledger to use, or a shortcut
/// string to choose a ledger automatically.
pub ledger_index: Option<Cow<'a, str>>,
/// The unique identifier of a ledger.
#[serde(flatten)]
pub ledger_lookup: Option<LookupByLedgerRequest<'a>>,
/// If included, filter results to include only this type
/// of ledger object. The valid types are: check, deposit_preauth,
/// escrow, offer, payment_channel, signer_list, ticket,
Expand All @@ -58,7 +56,7 @@ pub struct AccountObjects<'a> {
pub limit: Option<u16>,
/// Value from a previous paginated response. Resume retrieving
/// data where that response left off.
pub marker: Option<u32>,
pub marker: Option<Marker<'a>>,
}

impl<'a> Model for AccountObjects<'a> {}
Expand All @@ -78,20 +76,22 @@ impl<'a> AccountObjects<'a> {
id: Option<Cow<'a, str>>,
account: Cow<'a, str>,
ledger_hash: Option<Cow<'a, str>>,
ledger_index: Option<Cow<'a, str>>,
ledger_index: Option<LedgerIndex<'a>>,
r#type: Option<AccountObjectType>,
deletion_blockers_only: Option<bool>,
limit: Option<u16>,
marker: Option<u32>,
marker: Option<Marker<'a>>,
) -> Self {
Self {
common_fields: CommonFields {
command: RequestMethod::AccountObjects,
id,
},
account,
ledger_hash,
ledger_index,
ledger_lookup: Some(LookupByLedgerRequest {
ledger_hash,
ledger_index,
}),
r#type,
deletion_blockers_only,
limit,
Expand Down
22 changes: 11 additions & 11 deletions src/models/requests/account_offers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use serde_with::skip_serializing_none;

use crate::models::{requests::RequestMethod, Model};

use super::{CommonFields, Request};
use super::{CommonFields, LedgerIndex, LookupByLedgerRequest, Marker, Request};

/// This request retrieves a list of offers made by a given account
/// that are outstanding as of a particular ledger version.
Expand All @@ -20,11 +20,9 @@ pub struct AccountOffers<'a> {
/// A unique identifier for the account, most commonly the
/// account's Address.
pub account: Cow<'a, str>,
/// A 20-byte hex string identifying the ledger version to use.
pub ledger_hash: Option<Cow<'a, str>>,
/// The ledger index of the ledger to use, or "current",
/// "closed", or "validated" to select a ledger dynamically.
pub ledger_index: Option<Cow<'a, str>>,
/// The unique identifier of a ledger.
#[serde(flatten)]
pub ledger_lookup: Option<LookupByLedgerRequest<'a>>,
/// Limit the number of transactions to retrieve. The server is
/// not required to honor this value. Must be within the inclusive
/// range 10 to 400.
Expand All @@ -35,7 +33,7 @@ pub struct AccountOffers<'a> {
pub strict: Option<bool>,
/// Value from a previous paginated response. Resume retrieving
/// data where that response left off.
pub marker: Option<u32>,
pub marker: Option<Marker<'a>>,
}

impl<'a> Model for AccountOffers<'a> {}
Expand All @@ -55,19 +53,21 @@ impl<'a> AccountOffers<'a> {
id: Option<Cow<'a, str>>,
account: Cow<'a, str>,
ledger_hash: Option<Cow<'a, str>>,
ledger_index: Option<Cow<'a, str>>,
ledger_index: Option<LedgerIndex<'a>>,
limit: Option<u16>,
strict: Option<bool>,
marker: Option<u32>,
marker: Option<Marker<'a>>,
) -> Self {
Self {
common_fields: CommonFields {
command: RequestMethod::AccountOffers,
id,
},
account,
ledger_hash,
ledger_index,
ledger_lookup: Some(LookupByLedgerRequest {
ledger_hash,
ledger_index,
}),
limit,
strict,
marker,
Expand Down
Loading
Loading