Skip to content

Commit

Permalink
Reorder and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
thibault-martinez committed Oct 29, 2023
1 parent f92e864 commit 4d76ccf
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 114 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async fn main() -> Result<()> {

// Get output IDs of account outputs that can be controlled by this address.
let output_ids_response = client
.account_output_ids(AccountOutputQueryParameters::new().unlockable_by_address(address))
.account_output_ids(AccountOutputQueryParameters::new().address(address))
.await?;

println!("Account output IDs: {output_ids_response:#?}");
Expand Down
198 changes: 98 additions & 100 deletions sdk/src/client/node_api/indexer/query_parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,21 @@ macro_rules! impl_query_parameters_methods {
#[setters(strip_option)]
#[serde(rename_all = "camelCase")]
pub struct OutputQueryParameters {
/// Returns outputs that were created after a certain slot index.
created_after: Option<SlotIndex>,
/// Returns outputs that were created before a certain slot index.
created_before: Option<SlotIndex>,
/// Starts the search from the cursor (createdSlotIndex+outputId.pageSize).
cursor: Option<String>,
/// Filters outputs based on the presence of a native token.
has_native_token: Option<bool>,
/// Filters outputs based on the presence of a specific native token.
native_token: Option<TokenId>,
/// Returns outputs that are unlockable by the bech32 address.
unlockable_by_address: Option<Bech32Address>,
/// The maximum amount of items returned in one call. If there are more items, a cursor to the next page is
/// returned too. The parameter is ignored when pageSize is defined via the cursor parameter.
page_size: Option<usize>,
/// Returns outputs that are unlockable by the bech32 address.
unlockable_by_address: Option<Bech32Address>,
/// Starts the search from the cursor (createdSlotIndex+outputId.pageSize).
cursor: Option<String>,
/// Returns outputs that were created before a certain slot index.
created_before: Option<SlotIndex>,
/// Returns outputs that were created after a certain slot index.
created_after: Option<SlotIndex>,
}

impl_query_parameters_methods!(OutputQueryParameters);
Expand All @@ -87,47 +87,47 @@ impl_query_parameters_methods!(OutputQueryParameters);
#[setters(strip_option)]
#[serde(rename_all = "camelCase")]
pub struct BasicOutputQueryParameters {
/// Returns outputs that were created after a certain slot index.
created_after: Option<SlotIndex>,
/// Returns outputs that were created before a certain slot index.
created_before: Option<SlotIndex>,
/// Starts the search from the cursor (createdSlotIndex+outputId.pageSize).
cursor: Option<String>,
/// Filters outputs based on the presence of a native token.
has_native_token: Option<bool>,
/// Filters outputs based on the presence of a specific native token.
native_token: Option<TokenId>,
/// The maximum amount of items returned in one call. If there are more items, a cursor to the next page is
/// returned too. The parameter is ignored when pageSize is defined via the cursor parameter.
page_size: Option<usize>,
/// Returns outputs that are unlockable by the bech32 address.
unlockable_by_address: Option<Bech32Address>,
/// Bech32-encoded address that should be searched for.
address: Option<Bech32Address>,
/// Filters outputs based on the presence of storage deposit return unlock condition.
has_storage_deposit_return: Option<bool>,
/// Filters outputs based on the presence of a specific return address in the storage deposit return unlock
/// condition.
storage_deposit_return_address: Option<Bech32Address>,
/// Filters outputs based on the presence of expiration unlock condition.
has_expiration: Option<bool>,
/// Filters outputs based on the presence of a specific Bech32-encoded return address in the expiration unlock
/// condition.
expiration_return_address: Option<Bech32Address>,
/// Returns outputs that expire after a certain slot index.
expires_after: Option<SlotIndex>,
/// Returns outputs that expire before a certain slot index.
expires_before: Option<SlotIndex>,
/// Filters outputs based on the presence of expiration unlock condition.
has_expiration: Option<bool>,
/// Filters outputs based on the presence of storage deposit return unlock condition.
has_storage_deposit_return: Option<bool>,
/// Returns outputs that expire after a certain slot index.
expires_after: Option<SlotIndex>,
/// Filters outputs based on the presence of timelock unlock condition.
has_timelock: Option<bool>,
/// Returns outputs that are timelocked before a certain slot index.
timelocked_before: Option<SlotIndex>,
/// Returns outputs that are timelocked after a certain slot index.
timelocked_after: Option<SlotIndex>,
/// Filters outputs based on the presence of validated Sender (bech32 encoded).
sender: Option<Bech32Address>,
/// Filters outputs based on the presence of a specific return address in the storage deposit return unlock
/// condition.
storage_deposit_return_address: Option<Bech32Address>,
/// Filters outputs based on matching Tag Block.
tag: Option<String>,
/// Returns outputs that are timelocked after a certain slot index.
timelocked_after: Option<SlotIndex>,
/// Returns outputs that are timelocked before a certain slot index.
timelocked_before: Option<SlotIndex>,
/// The maximum amount of items returned in one call. If there are more items, a cursor to the next page is
/// returned too. The parameter is ignored when pageSize is defined via the cursor parameter.
page_size: Option<usize>,
/// Starts the search from the cursor (createdSlotIndex+outputId.pageSize).
cursor: Option<String>,
/// Returns outputs that were created before a certain slot index.
created_before: Option<SlotIndex>,
/// Returns outputs that were created after a certain slot index.
created_after: Option<SlotIndex>,
}

impl_query_parameters_methods!(BasicOutputQueryParameters);
Expand All @@ -149,23 +149,21 @@ impl BasicOutputQueryParameters {
#[setters(strip_option)]
#[serde(rename_all = "camelCase")]
pub struct AccountOutputQueryParameters {
/// Returns outputs that were created after a certain slot index.
created_after: Option<SlotIndex>,
/// Returns outputs that were created before a certain slot index.
created_before: Option<SlotIndex>,
/// Starts the search from the cursor (createdSlotIndex+outputId.pageSize).
cursor: Option<String>,
/// Bech32-encoded address that should be searched for.
address: Option<Bech32Address>,
/// Filters outputs based on bech32-encoded issuer address.
issuer: Option<Bech32Address>,
/// Filters outputs based on the presence of validated Sender (bech32 encoded).
sender: Option<Bech32Address>,
/// The maximum amount of items returned in one call. If there are more items, a cursor to the next page is
/// returned too. The parameter is ignored when pageSize is defined via the cursor parameter.
page_size: Option<usize>,
/// Returns outputs that are unlockable by the bech32 address.
unlockable_by_address: Option<Bech32Address>,
/// Filters outputs based on the presence of validated Sender (bech32 encoded).
sender: Option<Bech32Address>,
/// Filters outputs based on bech32-encoded issuer address.
issuer: Option<Bech32Address>,
/// Bech32-encoded address that should be searched for.
address: Option<Bech32Address>,
/// Starts the search from the cursor (createdSlotIndex+outputId.pageSize).
cursor: Option<String>,
/// Returns outputs that were created before a certain slot index.
created_before: Option<SlotIndex>,
/// Returns outputs that were created after a certain slot index.
created_after: Option<SlotIndex>,
}

impl_query_parameters_methods!(AccountOutputQueryParameters);
Expand All @@ -175,25 +173,25 @@ impl_query_parameters_methods!(AccountOutputQueryParameters);
#[setters(strip_option)]
#[serde(rename_all = "camelCase")]
pub struct AnchorOutputQueryParameters {
/// Returns outputs that were created after a certain slot index.
created_after: Option<SlotIndex>,
/// Returns outputs that were created before a certain slot index.
created_before: Option<SlotIndex>,
/// Starts the search from the cursor (createdSlotIndex+outputId.pageSize).
cursor: Option<String>,
/// The maximum amount of items returned in one call. If there are more items, a cursor to the next page is
/// returned too. The parameter is ignored when pageSize is defined via the cursor parameter.
page_size: Option<usize>,
/// Returns outputs that are unlockable by the bech32 address.
unlockable_by_address: Option<Bech32Address>,
/// Filters outputs based on the presence of validated Sender (bech32 encoded).
sender: Option<Bech32Address>,
/// Filters outputs based on bech32-encoded issuer address.
issuer: Option<Bech32Address>,
/// Filters outputs based on bech32-encoded governor (governance controller) address.
governor: Option<Bech32Address>,
/// Filters outputs based on bech32-encoded state controller address.
state_controller: Option<Bech32Address>,
/// Filters outputs based on bech32-encoded governor (governance controller) address.
governor: Option<Bech32Address>,
/// Filters outputs based on bech32-encoded issuer address.
issuer: Option<Bech32Address>,
/// Filters outputs based on the presence of validated Sender (bech32 encoded).
sender: Option<Bech32Address>,
/// The maximum amount of items returned in one call. If there are more items, a cursor to the next page is
/// returned too. The parameter is ignored when pageSize is defined via the cursor parameter.
page_size: Option<usize>,
/// Starts the search from the cursor (createdSlotIndex+outputId.pageSize).
cursor: Option<String>,
/// Returns outputs that were created before a certain slot index.
created_before: Option<SlotIndex>,
/// Returns outputs that were created after a certain slot index.
created_after: Option<SlotIndex>,
}

impl_query_parameters_methods!(AnchorOutputQueryParameters);
Expand All @@ -203,19 +201,19 @@ impl_query_parameters_methods!(AnchorOutputQueryParameters);
#[setters(strip_option)]
#[serde(rename_all = "camelCase")]
pub struct DelegationOutputQueryParameters {
/// Returns outputs that were created after a certain slot index.
created_after: Option<SlotIndex>,
/// Returns outputs that were created before a certain slot index.
created_before: Option<SlotIndex>,
/// Starts the search from the cursor (createdSlotIndex+outputId.pageSize).
cursor: Option<String>,
/// The maximum amount of items returned in one call. If there are more items, a cursor to the next page is
/// returned too. The parameter is ignored when pageSize is defined via the cursor parameter.
page_size: Option<usize>,
/// Bech32-encoded address that should be searched for.
address: Option<Bech32Address>,
/// Filter foundry outputs based on bech32-encoded address of the validator.
validator: Option<Bech32Address>,
/// The maximum amount of items returned in one call. If there are more items, a cursor to the next page is
/// returned too. The parameter is ignored when pageSize is defined via the cursor parameter.
page_size: Option<usize>,
/// Starts the search from the cursor (createdSlotIndex+outputId.pageSize).
cursor: Option<String>,
/// Returns outputs that were created before a certain slot index.
created_before: Option<SlotIndex>,
/// Returns outputs that were created after a certain slot index.
created_after: Option<SlotIndex>,
}

impl_query_parameters_methods!(DelegationOutputQueryParameters);
Expand All @@ -225,21 +223,21 @@ impl_query_parameters_methods!(DelegationOutputQueryParameters);
#[setters(strip_option)]
#[serde(rename_all = "camelCase")]
pub struct FoundryOutputQueryParameters {
/// Returns outputs that were created after a certain slot index.
created_after: Option<SlotIndex>,
/// Returns outputs that were created before a certain slot index.
created_before: Option<SlotIndex>,
/// Starts the search from the cursor (createdSlotIndex+outputId.pageSize).
cursor: Option<String>,
/// Filters outputs based on the presence of a native token.
has_native_token: Option<bool>,
/// Filters outputs based on the presence of a specific native token.
native_token: Option<TokenId>,
/// Filter foundry outputs based on bech32-encoded address of the controlling account.
account_address: Option<Bech32Address>,
/// The maximum amount of items returned in one call. If there are more items, a cursor to the next page is
/// returned too. The parameter is ignored when pageSize is defined via the cursor parameter.
page_size: Option<usize>,
/// Filter foundry outputs based on bech32-encoded address of the controlling account.
account_address: Option<Bech32Address>,
/// Starts the search from the cursor (createdSlotIndex+outputId.pageSize).
cursor: Option<String>,
/// Returns outputs that were created before a certain slot index.
created_before: Option<SlotIndex>,
/// Returns outputs that were created after a certain slot index.
created_after: Option<SlotIndex>,
}

impl_query_parameters_methods!(FoundryOutputQueryParameters);
Expand All @@ -249,45 +247,45 @@ impl_query_parameters_methods!(FoundryOutputQueryParameters);
#[setters(strip_option)]
#[serde(rename_all = "camelCase")]
pub struct NftOutputQueryParameters {
/// Returns outputs that were created after a certain slot index.
created_after: Option<SlotIndex>,
/// Returns outputs that were created before a certain slot index.
created_before: Option<SlotIndex>,
/// Starts the search from the cursor (createdSlotIndex+outputId.pageSize).
cursor: Option<String>,
/// The maximum amount of items returned in one call. If there are more items, a cursor to the next page is
/// returned too. The parameter is ignored when pageSize is defined via the cursor parameter.
page_size: Option<usize>,
/// Returns outputs that are unlockable by the bech32 address.
unlockable_by_address: Option<Bech32Address>,
/// Bech32-encoded address that should be searched for.
address: Option<Bech32Address>,
/// Filters outputs based on the presence of storage deposit return unlock condition.
has_storage_deposit_return: Option<bool>,
/// Filters outputs based on the presence of a specific return address in the storage deposit return unlock
/// condition.
storage_deposit_return_address: Option<Bech32Address>,
/// Filters outputs based on the presence of expiration unlock condition.
has_expiration: Option<bool>,
/// Filters outputs based on the presence of a specific Bech32-encoded return address in the expiration unlock
/// condition.
expiration_return_address: Option<Bech32Address>,
/// Returns outputs that expire after a certain slot index.
expires_after: Option<SlotIndex>,
/// Returns outputs that expire before a certain slot index.
expires_before: Option<SlotIndex>,
/// Filters outputs based on the presence of expiration unlock condition.
has_expiration: Option<bool>,
/// Filters outputs based on the presence of storage deposit return unlock condition.
has_storage_deposit_return: Option<bool>,
/// Returns outputs that expire after a certain slot index.
expires_after: Option<SlotIndex>,
/// Filters outputs based on the presence of timelock unlock condition.
has_timelock: Option<bool>,
/// Filters outputs based on the presence of validated Sender (bech32 encoded).
sender: Option<Bech32Address>,
/// Returns outputs that are timelocked before a certain slot index.
timelocked_before: Option<SlotIndex>,
/// Returns outputs that are timelocked after a certain slot index.
timelocked_after: Option<SlotIndex>,
/// Filters outputs based on bech32-encoded issuer address.
issuer: Option<Bech32Address>,
/// Filters outputs based on the presence of a specific return address in the storage deposit return unlock
/// condition.
storage_deposit_return_address: Option<Bech32Address>,
/// Filters outputs based on the presence of validated Sender (bech32 encoded).
sender: Option<Bech32Address>,
/// Filters outputs based on matching Tag Block.
tag: Option<String>,
/// Returns outputs that are timelocked after a certain slot index.
timelocked_after: Option<SlotIndex>,
/// Returns outputs that are timelocked before a certain slot index.
timelocked_before: Option<SlotIndex>,
/// The maximum amount of items returned in one call. If there are more items, a cursor to the next page is
/// returned too. The parameter is ignored when pageSize is defined via the cursor parameter.
page_size: Option<usize>,
/// Starts the search from the cursor (createdSlotIndex+outputId.pageSize).
cursor: Option<String>,
/// Returns outputs that were created before a certain slot index.
created_before: Option<SlotIndex>,
/// Returns outputs that were created after a certain slot index.
created_after: Option<SlotIndex>,
}

impl_query_parameters_methods!(NftOutputQueryParameters);
Expand Down
5 changes: 0 additions & 5 deletions sdk/src/types/block/output/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use alloc::{collections::BTreeSet, vec::Vec};

use hashbrown::HashMap;
use packable::{
bounded::BoundedU16,
error::{UnpackError, UnpackErrorExt},
packer::Packer,
unpacker::Unpacker,
Expand Down Expand Up @@ -307,8 +306,6 @@ impl From<&AccountOutput> for AccountOutputBuilder {
}
}

pub(crate) type StateMetadataLength = BoundedU16<0, { AccountOutput::STATE_METADATA_LENGTH_MAX }>;

/// Describes an account in the ledger that can be controlled by the state and governance controllers.
#[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct AccountOutput {
Expand All @@ -331,8 +328,6 @@ pub struct AccountOutput {
impl AccountOutput {
/// The [`Output`](crate::types::block::output::Output) kind of an [`AccountOutput`].
pub const KIND: u8 = 1;
/// Maximum possible length in bytes of the state metadata.
pub const STATE_METADATA_LENGTH_MAX: u16 = 8192;
/// The set of allowed [`UnlockCondition`]s for an [`AccountOutput`].
pub const ALLOWED_UNLOCK_CONDITIONS: UnlockConditionFlags = UnlockConditionFlags::ADDRESS;
/// The set of allowed [`Feature`]s for an [`AccountOutput`].
Expand Down
14 changes: 7 additions & 7 deletions sdk/src/types/block/output/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,6 @@ use packable::{
Packable, PackableExt,
};

pub(crate) use self::{
account::StateMetadataLength,
feature::{MetadataFeatureLength, TagFeatureLength},
native_token::NativeTokenCount,
output_id::OutputIndex,
unlock_condition::AddressUnlockCondition,
};
pub use self::{
account::{AccountId, AccountOutput, AccountOutputBuilder},
anchor::{AnchorId, AnchorOutput, AnchorTransition},
Expand All @@ -58,6 +51,13 @@ pub use self::{
token_scheme::{SimpleTokenScheme, TokenScheme},
unlock_condition::{UnlockCondition, UnlockConditions},
};
pub(crate) use self::{
anchor::StateMetadataLength,
feature::{MetadataFeatureLength, TagFeatureLength},
native_token::NativeTokenCount,
output_id::OutputIndex,
unlock_condition::AddressUnlockCondition,
};
use super::protocol::ProtocolParameters;
use crate::types::block::{address::Address, semantic::SemanticValidationContext, slot::SlotIndex, Error};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ where

let mut output_ids = self
.client()
.account_output_ids(AccountOutputQueryParameters::new().unlockable_by_address(bech32_address))
.account_output_ids(AccountOutputQueryParameters::new().address(bech32_address))
.await?
.items;

Expand Down

0 comments on commit 4d76ccf

Please sign in to comment.