From 4d76ccfb5fb9335fe0197f53759c04eac67b7f0f Mon Sep 17 00:00:00 2001 From: Thibault Martinez Date: Sun, 29 Oct 2023 18:35:25 +0100 Subject: [PATCH] Reorder and fixes --- .../02_get_account_outputs.rs | 2 +- .../node_api/indexer/query_parameters.rs | 198 +++++++++--------- sdk/src/types/block/output/account.rs | 5 - sdk/src/types/block/output/mod.rs | 14 +- .../addresses/output_ids/account_foundry.rs | 2 +- 5 files changed, 107 insertions(+), 114 deletions(-) diff --git a/sdk/examples/client/node_api_indexer/02_get_account_outputs.rs b/sdk/examples/client/node_api_indexer/02_get_account_outputs.rs index d708ee22e3..a66e1beb2c 100644 --- a/sdk/examples/client/node_api_indexer/02_get_account_outputs.rs +++ b/sdk/examples/client/node_api_indexer/02_get_account_outputs.rs @@ -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:#?}"); diff --git a/sdk/src/client/node_api/indexer/query_parameters.rs b/sdk/src/client/node_api/indexer/query_parameters.rs index fd58423a11..1c159f1a5a 100644 --- a/sdk/src/client/node_api/indexer/query_parameters.rs +++ b/sdk/src/client/node_api/indexer/query_parameters.rs @@ -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, - /// Returns outputs that were created before a certain slot index. - created_before: Option, - /// Starts the search from the cursor (createdSlotIndex+outputId.pageSize). - cursor: Option, /// Filters outputs based on the presence of a native token. has_native_token: Option, /// Filters outputs based on the presence of a specific native token. native_token: Option, + /// Returns outputs that are unlockable by the bech32 address. + unlockable_by_address: Option, /// 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, - /// Returns outputs that are unlockable by the bech32 address. - unlockable_by_address: Option, + /// Starts the search from the cursor (createdSlotIndex+outputId.pageSize). + cursor: Option, + /// Returns outputs that were created before a certain slot index. + created_before: Option, + /// Returns outputs that were created after a certain slot index. + created_after: Option, } impl_query_parameters_methods!(OutputQueryParameters); @@ -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, - /// Returns outputs that were created before a certain slot index. - created_before: Option, - /// Starts the search from the cursor (createdSlotIndex+outputId.pageSize). - cursor: Option, /// Filters outputs based on the presence of a native token. has_native_token: Option, /// Filters outputs based on the presence of a specific native token. native_token: Option, - /// 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, /// Returns outputs that are unlockable by the bech32 address. unlockable_by_address: Option, /// Bech32-encoded address that should be searched for. address: Option, + /// Filters outputs based on the presence of storage deposit return unlock condition. + has_storage_deposit_return: Option, + /// Filters outputs based on the presence of a specific return address in the storage deposit return unlock + /// condition. + storage_deposit_return_address: Option, + /// Filters outputs based on the presence of expiration unlock condition. + has_expiration: Option, /// Filters outputs based on the presence of a specific Bech32-encoded return address in the expiration unlock /// condition. expiration_return_address: Option, - /// Returns outputs that expire after a certain slot index. - expires_after: Option, /// Returns outputs that expire before a certain slot index. expires_before: Option, - /// Filters outputs based on the presence of expiration unlock condition. - has_expiration: Option, - /// Filters outputs based on the presence of storage deposit return unlock condition. - has_storage_deposit_return: Option, + /// Returns outputs that expire after a certain slot index. + expires_after: Option, /// Filters outputs based on the presence of timelock unlock condition. has_timelock: Option, + /// Returns outputs that are timelocked before a certain slot index. + timelocked_before: Option, + /// Returns outputs that are timelocked after a certain slot index. + timelocked_after: Option, /// Filters outputs based on the presence of validated Sender (bech32 encoded). sender: Option, - /// Filters outputs based on the presence of a specific return address in the storage deposit return unlock - /// condition. - storage_deposit_return_address: Option, /// Filters outputs based on matching Tag Block. tag: Option, - /// Returns outputs that are timelocked after a certain slot index. - timelocked_after: Option, - /// Returns outputs that are timelocked before a certain slot index. - timelocked_before: Option, + /// 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, + /// Starts the search from the cursor (createdSlotIndex+outputId.pageSize). + cursor: Option, + /// Returns outputs that were created before a certain slot index. + created_before: Option, + /// Returns outputs that were created after a certain slot index. + created_after: Option, } impl_query_parameters_methods!(BasicOutputQueryParameters); @@ -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, - /// Returns outputs that were created before a certain slot index. - created_before: Option, - /// Starts the search from the cursor (createdSlotIndex+outputId.pageSize). - cursor: Option, + /// Bech32-encoded address that should be searched for. + address: Option, + /// Filters outputs based on bech32-encoded issuer address. + issuer: Option, + /// Filters outputs based on the presence of validated Sender (bech32 encoded). + sender: Option, /// 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, - /// Returns outputs that are unlockable by the bech32 address. - unlockable_by_address: Option, - /// Filters outputs based on the presence of validated Sender (bech32 encoded). - sender: Option, - /// Filters outputs based on bech32-encoded issuer address. - issuer: Option, - /// Bech32-encoded address that should be searched for. - address: Option, + /// Starts the search from the cursor (createdSlotIndex+outputId.pageSize). + cursor: Option, + /// Returns outputs that were created before a certain slot index. + created_before: Option, + /// Returns outputs that were created after a certain slot index. + created_after: Option, } impl_query_parameters_methods!(AccountOutputQueryParameters); @@ -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, - /// Returns outputs that were created before a certain slot index. - created_before: Option, - /// Starts the search from the cursor (createdSlotIndex+outputId.pageSize). - cursor: Option, - /// 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, /// Returns outputs that are unlockable by the bech32 address. unlockable_by_address: Option, - /// Filters outputs based on the presence of validated Sender (bech32 encoded). - sender: Option, - /// Filters outputs based on bech32-encoded issuer address. - issuer: Option, - /// Filters outputs based on bech32-encoded governor (governance controller) address. - governor: Option, /// Filters outputs based on bech32-encoded state controller address. state_controller: Option, + /// Filters outputs based on bech32-encoded governor (governance controller) address. + governor: Option, + /// Filters outputs based on bech32-encoded issuer address. + issuer: Option, + /// Filters outputs based on the presence of validated Sender (bech32 encoded). + sender: Option, + /// 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, + /// Starts the search from the cursor (createdSlotIndex+outputId.pageSize). + cursor: Option, + /// Returns outputs that were created before a certain slot index. + created_before: Option, + /// Returns outputs that were created after a certain slot index. + created_after: Option, } impl_query_parameters_methods!(AnchorOutputQueryParameters); @@ -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, - /// Returns outputs that were created before a certain slot index. - created_before: Option, - /// Starts the search from the cursor (createdSlotIndex+outputId.pageSize). - cursor: Option, - /// 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, /// Bech32-encoded address that should be searched for. address: Option, /// Filter foundry outputs based on bech32-encoded address of the validator. validator: Option, + /// 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, + /// Starts the search from the cursor (createdSlotIndex+outputId.pageSize). + cursor: Option, + /// Returns outputs that were created before a certain slot index. + created_before: Option, + /// Returns outputs that were created after a certain slot index. + created_after: Option, } impl_query_parameters_methods!(DelegationOutputQueryParameters); @@ -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, - /// Returns outputs that were created before a certain slot index. - created_before: Option, - /// Starts the search from the cursor (createdSlotIndex+outputId.pageSize). - cursor: Option, /// Filters outputs based on the presence of a native token. has_native_token: Option, /// Filters outputs based on the presence of a specific native token. native_token: Option, + /// Filter foundry outputs based on bech32-encoded address of the controlling account. + account_address: Option, /// 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, - /// Filter foundry outputs based on bech32-encoded address of the controlling account. - account_address: Option, + /// Starts the search from the cursor (createdSlotIndex+outputId.pageSize). + cursor: Option, + /// Returns outputs that were created before a certain slot index. + created_before: Option, + /// Returns outputs that were created after a certain slot index. + created_after: Option, } impl_query_parameters_methods!(FoundryOutputQueryParameters); @@ -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, - /// Returns outputs that were created before a certain slot index. - created_before: Option, - /// Starts the search from the cursor (createdSlotIndex+outputId.pageSize). - cursor: Option, - /// 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, /// Returns outputs that are unlockable by the bech32 address. unlockable_by_address: Option, /// Bech32-encoded address that should be searched for. address: Option, + /// Filters outputs based on the presence of storage deposit return unlock condition. + has_storage_deposit_return: Option, + /// Filters outputs based on the presence of a specific return address in the storage deposit return unlock + /// condition. + storage_deposit_return_address: Option, + /// Filters outputs based on the presence of expiration unlock condition. + has_expiration: Option, /// Filters outputs based on the presence of a specific Bech32-encoded return address in the expiration unlock /// condition. expiration_return_address: Option, - /// Returns outputs that expire after a certain slot index. - expires_after: Option, /// Returns outputs that expire before a certain slot index. expires_before: Option, - /// Filters outputs based on the presence of expiration unlock condition. - has_expiration: Option, - /// Filters outputs based on the presence of storage deposit return unlock condition. - has_storage_deposit_return: Option, + /// Returns outputs that expire after a certain slot index. + expires_after: Option, /// Filters outputs based on the presence of timelock unlock condition. has_timelock: Option, - /// Filters outputs based on the presence of validated Sender (bech32 encoded). - sender: Option, + /// Returns outputs that are timelocked before a certain slot index. + timelocked_before: Option, + /// Returns outputs that are timelocked after a certain slot index. + timelocked_after: Option, /// Filters outputs based on bech32-encoded issuer address. issuer: Option, - /// Filters outputs based on the presence of a specific return address in the storage deposit return unlock - /// condition. - storage_deposit_return_address: Option, + /// Filters outputs based on the presence of validated Sender (bech32 encoded). + sender: Option, /// Filters outputs based on matching Tag Block. tag: Option, - /// Returns outputs that are timelocked after a certain slot index. - timelocked_after: Option, - /// Returns outputs that are timelocked before a certain slot index. - timelocked_before: Option, + /// 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, + /// Starts the search from the cursor (createdSlotIndex+outputId.pageSize). + cursor: Option, + /// Returns outputs that were created before a certain slot index. + created_before: Option, + /// Returns outputs that were created after a certain slot index. + created_after: Option, } impl_query_parameters_methods!(NftOutputQueryParameters); diff --git a/sdk/src/types/block/output/account.rs b/sdk/src/types/block/output/account.rs index 14ae4a60f3..411e8c0fb6 100644 --- a/sdk/src/types/block/output/account.rs +++ b/sdk/src/types/block/output/account.rs @@ -5,7 +5,6 @@ use alloc::{collections::BTreeSet, vec::Vec}; use hashbrown::HashMap; use packable::{ - bounded::BoundedU16, error::{UnpackError, UnpackErrorExt}, packer::Packer, unpacker::Unpacker, @@ -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 { @@ -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`]. diff --git a/sdk/src/types/block/output/mod.rs b/sdk/src/types/block/output/mod.rs index 3448884b33..840819c7a2 100644 --- a/sdk/src/types/block/output/mod.rs +++ b/sdk/src/types/block/output/mod.rs @@ -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}, @@ -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}; diff --git a/sdk/src/wallet/account/operations/syncing/addresses/output_ids/account_foundry.rs b/sdk/src/wallet/account/operations/syncing/addresses/output_ids/account_foundry.rs index 795ee91c95..497d9ff025 100644 --- a/sdk/src/wallet/account/operations/syncing/addresses/output_ids/account_foundry.rs +++ b/sdk/src/wallet/account/operations/syncing/addresses/output_ids/account_foundry.rs @@ -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;