From dc8b5dfb5ceaa3ea757652ddaebbd7b9abdc74c5 Mon Sep 17 00:00:00 2001 From: Thibault Martinez Date: Wed, 28 Feb 2024 14:08:16 +0100 Subject: [PATCH 01/11] Remove remaining mentions of milestones --- sdk/src/client/constants.rs | 2 +- sdk/src/types/block/error.rs | 10 ++-------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/sdk/src/client/constants.rs b/sdk/src/client/constants.rs index b4d9b0252f..ba82f47aa8 100644 --- a/sdk/src/client/constants.rs +++ b/sdk/src/client/constants.rs @@ -16,7 +16,7 @@ pub(crate) const DEFAULT_QUORUM_THRESHOLD: usize = 66; pub(crate) const DEFAULT_USER_AGENT: &str = concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION")); #[cfg(not(target_family = "wasm"))] pub(crate) const MAX_PARALLEL_API_REQUESTS: usize = 100; -/// Max allowed difference between the local time and latest milestone time, 5 minutes in seconds +/// Max allowed difference between local time and tangle time, 5 minutes in seconds pub(crate) const FIVE_MINUTES_IN_NANOSECONDS: u64 = 300_000_000_000; /// Delay for caching a node info response in WASM runtime #[cfg(target_family = "wasm")] diff --git a/sdk/src/types/block/error.rs b/sdk/src/types/block/error.rs index 785a4fc480..bbd6bce1e8 100644 --- a/sdk/src/types/block/error.rs +++ b/sdk/src/types/block/error.rs @@ -236,10 +236,7 @@ impl fmt::Display for Error { } Self::DuplicateUtxo(utxo) => write!(f, "duplicate UTXO {utxo:?} in inputs"), Self::ExpirationUnlockConditionZero => { - write!( - f, - "expiration unlock condition with milestone index and timestamp set to 0", - ) + write!(f, "expiration unlock condition with slot index set to 0",) } Self::FeaturesNotUniqueSorted => write!(f, "features are not unique and/or sorted"), Self::InputUnlockCountMismatch { @@ -433,10 +430,7 @@ impl fmt::Display for Error { write!(f, "storage deposit return overflow",) } Self::TimelockUnlockConditionZero => { - write!( - f, - "timelock unlock condition with milestone index and timestamp set to 0", - ) + write!(f, "timelock unlock condition with slot index set to 0",) } Self::UnallowedFeature { index, kind } => { write!(f, "unallowed feature at index {index} with kind {kind}") From bd02cfa7359ac5ed0e248cae501bc118fe262855 Mon Sep 17 00:00:00 2001 From: Thibault Martinez Date: Mon, 4 Mar 2024 13:12:29 +0100 Subject: [PATCH 02/11] force_syncing --- bindings/nodejs/lib/types/wallet/wallet.ts | 6 +++--- bindings/python/iota_sdk/wallet/sync_options.py | 7 +++---- sdk/src/wallet/operations/syncing/options.rs | 6 +++--- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/bindings/nodejs/lib/types/wallet/wallet.ts b/bindings/nodejs/lib/types/wallet/wallet.ts index 88e53d3b6e..a53f9fa5e0 100644 --- a/bindings/nodejs/lib/types/wallet/wallet.ts +++ b/bindings/nodejs/lib/types/wallet/wallet.ts @@ -99,9 +99,9 @@ export interface NativeTokenBalance { /** Sync options for a wallet */ export interface SyncOptions { /** - * Usually syncing is skipped if it's called in between 200ms, because there can only be new changes every - * milestone and calling it twice "at the same time" will not return new data - * When this to true, we will sync anyways, even if it's called 0ms after the las sync finished. Default: false. + * Syncing is usually skipped if it's called repeatedly in a short amount of time as there can only be new changes every + * slot and calling it twice "at the same time" will not return new data. + * When this to true, we sync anyways, even if it's called 0ms after the last sync finished. Default: false. */ forceSyncing?: boolean; /// Try to sync transactions from incoming outputs with their inputs. Some data may not be obtained if it has been diff --git a/bindings/python/iota_sdk/wallet/sync_options.py b/bindings/python/iota_sdk/wallet/sync_options.py index 7a2b702c1b..f32f5acf9a 100644 --- a/bindings/python/iota_sdk/wallet/sync_options.py +++ b/bindings/python/iota_sdk/wallet/sync_options.py @@ -69,10 +69,9 @@ class SyncOptions: **Attributes** force_syncing : - Usually syncing is skipped if it's called in between 200ms, because there can only be new - changes every milestone and calling it twice "at the same time" will not return new data. - When this is set to true, we will sync anyways, even if it's called 0ms after the last sync - finished. + Syncing is usually skipped if it's called repeatedly in a short amount of time as there can only be new changes every + slot and calling it twice "at the same time" will not return new data. + When this to true, we sync anyways, even if it's called 0ms after the last sync finished. sync_incoming_transactions : Try to sync transactions from incoming outputs with their inputs. Some data may not be obtained if it has been pruned. diff --git a/sdk/src/wallet/operations/syncing/options.rs b/sdk/src/wallet/operations/syncing/options.rs index f5a1d09816..f2626acf09 100644 --- a/sdk/src/wallet/operations/syncing/options.rs +++ b/sdk/src/wallet/operations/syncing/options.rs @@ -14,9 +14,9 @@ const DEFAULT_SYNC_IMPLICIT_ACCOUNTS: bool = false; #[derive(Debug, Clone, Eq, PartialEq, Hash, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct SyncOptions { - /// Usually syncing is skipped if it's called in between 200ms, because there can only be new changes every - /// milestone and calling it twice "at the same time" will not return new data - /// When this to true, we will sync anyways, even if it's called 0ms after the las sync finished. + /// Syncing is usually skipped if it's called repeatedly in a short amount of time as there can only be new changes + /// every slot and calling it twice "at the same time" will not return new data. + /// When this to true, we sync anyways, even if it's called 0ms after the last sync finished. #[serde(default)] pub force_syncing: bool, /// Try to sync transactions from incoming outputs with their inputs. Some data may not be obtained if it has been From 764955097858cd41716ecac55d0cba94f9711627 Mon Sep 17 00:00:00 2001 From: Thibault Martinez Date: Mon, 4 Mar 2024 14:09:28 +0100 Subject: [PATCH 03/11] filter options --- bindings/nodejs/lib/types/wallet/wallet.ts | 10 ++++----- .../python/iota_sdk/types/filter_options.py | 6 ++--- sdk/src/wallet/core/mod.rs | 22 +++++++++---------- sdk/src/wallet/mod.rs | 9 ++++---- 4 files changed, 24 insertions(+), 23 deletions(-) diff --git a/bindings/nodejs/lib/types/wallet/wallet.ts b/bindings/nodejs/lib/types/wallet/wallet.ts index a53f9fa5e0..4c296c4073 100644 --- a/bindings/nodejs/lib/types/wallet/wallet.ts +++ b/bindings/nodejs/lib/types/wallet/wallet.ts @@ -11,7 +11,7 @@ import { import { DecayedMana, HexEncodedString, u256, u64 } from '../utils'; import { ClientOptions } from '../client'; import { Bip44, SecretManagerType } from '../secret_manager/secret-manager'; -import { Bech32Address } from '../block'; +import { Bech32Address, SlotIndex } from '../block'; /** Options for the Wallet builder. */ export interface WalletOptions { @@ -163,10 +163,10 @@ export interface NftSyncOptions { /** Options to filter outputs */ export interface FilterOptions { - /** Filter all outputs where the booked milestone index is below the specified timestamp */ - lowerBoundBookedTimestamp?: number; - /** Filter all outputs where the booked milestone index is above the specified timestamp */ - upperBoundBookedTimestamp?: number; + /** Filter all outputs where the included slot is below the specified slot */ + includedBelowSlot?: SlotIndex; + /** Filter all outputs where the included slot is above the specified slot */ + includedAboveSlot?: SlotIndex; /** Filter all outputs for the provided types (Basic = 3, Account = 4, Foundry = 5, NFT = 6) */ outputTypes?: number[]; /** Return all account outputs matching these IDs. */ diff --git a/bindings/python/iota_sdk/types/filter_options.py b/bindings/python/iota_sdk/types/filter_options.py index ae6ec2cf48..42f726cc1b 100644 --- a/bindings/python/iota_sdk/types/filter_options.py +++ b/bindings/python/iota_sdk/types/filter_options.py @@ -4,7 +4,7 @@ from __future__ import annotations from typing import List, Optional from dataclasses import dataclass -from iota_sdk.types.common import json +from iota_sdk.types.common import json, SlotIndex @json @@ -13,8 +13,8 @@ class FilterOptions: """Options to filter outputs. """ - lowerBoundBookedTimestamp: Optional[int] = None - upperBoundBookedTimestamp: Optional[int] = None + includedBelowSlot: Optional[SlotIndex] = None + includedAboveSlot: Optional[SlotIndex] = None outputTypes: Optional[List[int]] = None accountIds: Optional[List[str]] = None foundryIds: Optional[List[str]] = None diff --git a/sdk/src/wallet/core/mod.rs b/sdk/src/wallet/core/mod.rs index 47f90677ea..8beb7d0cf3 100644 --- a/sdk/src/wallet/core/mod.rs +++ b/sdk/src/wallet/core/mod.rs @@ -187,17 +187,17 @@ impl WalletLedger { _ => {} } - // TODO filter based on slot index - // if let Some(lower_bound_booked_timestamp) = filter.lower_bound_booked_timestamp { - // if output.metadata.milestone_timestamp_booked() < lower_bound_booked_timestamp { - // continue; - // } - // } - // if let Some(upper_bound_booked_timestamp) = filter.upper_bound_booked_timestamp { - // if output.metadata.milestone_timestamp_booked() > upper_bound_booked_timestamp { - // continue; - // } - // } + if let Some(included_below_slot) = filter.included_below_slot { + if output.metadata.included().slot() < included_below_slot { + return false; + } + } + + if let Some(included_above_slot) = filter.included_above_slot { + if output.metadata.included().slot() > included_above_slot { + return false; + } + } if let Some(output_types) = &filter.output_types { if !output_types.contains(&output.output.kind()) { diff --git a/sdk/src/wallet/mod.rs b/sdk/src/wallet/mod.rs index 23a51a0506..32a22acca4 100644 --- a/sdk/src/wallet/mod.rs +++ b/sdk/src/wallet/mod.rs @@ -79,6 +79,7 @@ use crate::{ block::{ output::{AccountId, AnchorId, DelegationId, FoundryId, NftId, OutputWithMetadata}, payload::signed_transaction::{SignedTransactionPayload, TransactionId}, + slot::SlotIndex, }, }, wallet::types::InclusionState, @@ -91,10 +92,10 @@ pub type Result = std::result::Result; #[derive(Debug, Default, Clone, Serialize, Deserialize, Eq, PartialEq)] #[serde(rename_all = "camelCase")] pub struct FilterOptions { - /// Filter all outputs where the booked milestone index is below the specified timestamp - pub lower_bound_booked_timestamp: Option, - /// Filter all outputs where the booked milestone index is above the specified timestamp - pub upper_bound_booked_timestamp: Option, + /// Filter all outputs where the included slot is below the specified slot. + pub included_below_slot: Option, + /// Filter all outputs where the included slot is above the specified slot. + pub included_above_slot: Option, /// Filter all outputs for the provided types (Basic = 3, Account = 4, Foundry = 5, NFT = 6). pub output_types: Option>, /// Return all account outputs matching these IDs. From 4934c38accee61ce0fa42093390ef046ab5bff15 Mon Sep 17 00:00:00 2001 From: Thibault Martinez Date: Mon, 4 Mar 2024 14:30:16 +0100 Subject: [PATCH 04/11] Remove TransactionWithMetadata::timestamp --- bindings/nodejs/lib/types/wallet/transaction.ts | 2 -- .../python/iota_sdk/types/transaction_with_metadata.py | 2 -- sdk/src/wallet/mod.rs | 6 ------ sdk/src/wallet/operations/transaction/mod.rs | 1 - sdk/src/wallet/types/mod.rs | 9 --------- 5 files changed, 20 deletions(-) diff --git a/bindings/nodejs/lib/types/wallet/transaction.ts b/bindings/nodejs/lib/types/wallet/transaction.ts index 60eb35692e..5aa0c75fc7 100644 --- a/bindings/nodejs/lib/types/wallet/transaction.ts +++ b/bindings/nodejs/lib/types/wallet/transaction.ts @@ -31,8 +31,6 @@ export class TransactionWithMetadata { blockId?: BlockId; /** The inclusion state of the transaction */ inclusionState!: InclusionState; - /** The creation time */ - timestamp!: string; /** The transaction id */ transactionId!: TransactionId; /** The network id in which the transaction was sent */ diff --git a/bindings/python/iota_sdk/types/transaction_with_metadata.py b/bindings/python/iota_sdk/types/transaction_with_metadata.py index 625ed55c80..acc429638e 100644 --- a/bindings/python/iota_sdk/types/transaction_with_metadata.py +++ b/bindings/python/iota_sdk/types/transaction_with_metadata.py @@ -39,7 +39,6 @@ class TransactionWithMetadata: Attributes: payload: The transaction payload. inclusion_state: The inclusion state of the transaction. - timestamp: The timestamp of the transaction. transaction_id: The ID of the corresponding transaction. network_id: The ID of the network this transaction was issued in. incoming: Indicates whether the transaction was created by the wallet or whether it was sent by someone else and is incoming. @@ -49,7 +48,6 @@ class TransactionWithMetadata: """ payload: SignedTransactionPayload inclusion_state: InclusionState - timestamp: int transaction_id: TransactionId network_id: int incoming: bool diff --git a/sdk/src/wallet/mod.rs b/sdk/src/wallet/mod.rs index 32a22acca4..dad7bfdbc9 100644 --- a/sdk/src/wallet/mod.rs +++ b/sdk/src/wallet/mod.rs @@ -119,12 +119,6 @@ pub(crate) fn build_transaction_from_payload_and_inputs( payload: tx_payload.clone(), block_id: inputs.first().map(|i| *i.metadata.block_id()), inclusion_state: InclusionState::Confirmed, - timestamp: 0, - // TODO use slot index since milestone_timestamp_spent is gone - // inputs - // .first() - // .and_then(|i| i.metadata.milestone_timestamp_spent.map(|t| t as u128 * 1000)) - // .unwrap_or_else(|| crate::utils::unix_timestamp_now().as_millis()), transaction_id: tx_id, network_id: tx_payload.transaction().network_id(), incoming: true, diff --git a/sdk/src/wallet/operations/transaction/mod.rs b/sdk/src/wallet/operations/transaction/mod.rs index c3a84671a5..82a4a30edf 100644 --- a/sdk/src/wallet/operations/transaction/mod.rs +++ b/sdk/src/wallet/operations/transaction/mod.rs @@ -176,7 +176,6 @@ where payload: signed_transaction_data.payload, block_id, network_id, - timestamp: crate::client::unix_timestamp_now().as_millis(), inclusion_state: InclusionState::Pending, incoming: false, note: options.and_then(|o| o.note), diff --git a/sdk/src/wallet/types/mod.rs b/sdk/src/wallet/types/mod.rs index 1f68f33df9..7792f2dce9 100644 --- a/sdk/src/wallet/types/mod.rs +++ b/sdk/src/wallet/types/mod.rs @@ -96,8 +96,6 @@ pub struct TransactionWithMetadata { pub payload: SignedTransactionPayload, pub block_id: Option, pub inclusion_state: InclusionState, - // Transaction creation time - pub timestamp: u128, pub transaction_id: TransactionId, // network id to ignore outputs when set_client_options is used to switch to another network pub network_id: u64, @@ -121,8 +119,6 @@ pub struct TransactionWithMetadataDto { pub block_id: Option, /// Inclusion state of the transaction pub inclusion_state: InclusionState, - /// Timestamp - pub timestamp: String, pub transaction_id: TransactionId, /// Network id to ignore outputs when set_client_options is used to switch to another network pub network_id: String, @@ -139,7 +135,6 @@ impl From<&TransactionWithMetadata> for TransactionWithMetadataDto { payload: SignedTransactionPayloadDto::from(&value.payload), block_id: value.block_id, inclusion_state: value.inclusion_state, - timestamp: value.timestamp.to_string(), transaction_id: value.transaction_id, network_id: value.network_id.to_string(), incoming: value.incoming, @@ -160,10 +155,6 @@ impl TryFromDto for TransactionWithMetadata { payload: SignedTransactionPayload::try_from_dto_with_params_inner(dto.payload, params)?, block_id: dto.block_id, inclusion_state: dto.inclusion_state, - timestamp: dto - .timestamp - .parse::() - .map_err(|e| PayloadError::InvalidTimestamp(e.to_string()))?, transaction_id: dto.transaction_id, network_id: dto .network_id From 1bbbb9a91bed55e3d0ff7251e4cc5300ae59fe38 Mon Sep 17 00:00:00 2001 From: Thibault Martinez Date: Wed, 6 Mar 2024 11:36:02 +0100 Subject: [PATCH 05/11] Remove outdated code --- .../client/block/01_block_confirmation_time.rs | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/sdk/examples/client/block/01_block_confirmation_time.rs b/sdk/examples/client/block/01_block_confirmation_time.rs index e11bb9f84b..5921127c2f 100644 --- a/sdk/examples/client/block/01_block_confirmation_time.rs +++ b/sdk/examples/client/block/01_block_confirmation_time.rs @@ -60,19 +60,5 @@ async fn main() -> Result<(), Box> { block_id ); - // TODO uncomment when we have a new confirmation logic - // Get the block metadata. - // let metadata = client.get_block_metadata(&block_id).await?; - - // if let Some(ms_index) = metadata.referenced_by_milestone_index { - // let ms = client.get_milestone_by_index(ms_index).await?; - // println!( - // "Block {block_id} got confirmed by milestone {ms_index} at timestamp {}.", - // ms.essence().timestamp() - // ); - // } else { - // println!("Block {block_id} is not confirmed.") - // } - Ok(()) } From a4253c51fc57ab86576f197243861a78c704311f Mon Sep 17 00:00:00 2001 From: Thibault Martinez Date: Wed, 6 Mar 2024 11:42:43 +0100 Subject: [PATCH 06/11] fix --- sdk/src/wallet/core/mod.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/sdk/src/wallet/core/mod.rs b/sdk/src/wallet/core/mod.rs index 2cc58453eb..1730153849 100644 --- a/sdk/src/wallet/core/mod.rs +++ b/sdk/src/wallet/core/mod.rs @@ -621,7 +621,6 @@ mod test { payload: tx_payload, block_id: None, network_id: 0, - timestamp: 0, inclusion_state: InclusionState::Pending, incoming: false, note: None, From dd31242d5599252e4fc4e39c9add5b9e2b70efd2 Mon Sep 17 00:00:00 2001 From: Thibault Martinez Date: Wed, 6 Mar 2024 12:35:53 +0100 Subject: [PATCH 07/11] fix cli --- cli/src/wallet_cli/mod.rs | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/cli/src/wallet_cli/mod.rs b/cli/src/wallet_cli/mod.rs index 18ba7fac9b..e65ec747d2 100644 --- a/cli/src/wallet_cli/mod.rs +++ b/cli/src/wallet_cli/mod.rs @@ -35,7 +35,7 @@ use rustyline::{error::ReadlineError, history::MemHistory, Config, Editor}; use self::completer::WalletCommandHelper; use crate::{ - helper::{bytes_from_hex_or_file, get_password, to_utc_date_time}, + helper::{bytes_from_hex_or_file, get_password}, println_log_error, println_log_info, }; @@ -1143,7 +1143,12 @@ pub async fn transaction_command(wallet: &Wallet, selector: TransactionSelector) TransactionSelector::Id(id) => wallet_ledger.get_transaction(&id), TransactionSelector::Index(index) => { let mut transactions = wallet_ledger.transactions().values().collect::>(); - transactions.sort_unstable_by(|a, b| b.timestamp.cmp(&a.timestamp)); + transactions.sort_unstable_by(|a, b| { + b.payload + .transaction() + .creation_slot() + .cmp(&a.payload.transaction().creation_slot()) + }); transactions.into_iter().nth(index) } }; @@ -1161,7 +1166,12 @@ pub async fn transaction_command(wallet: &Wallet, selector: TransactionSelector) pub async fn transactions_command(wallet: &Wallet, show_details: bool) -> Result<(), Error> { let wallet_ledger = wallet.ledger().await; let mut transactions = wallet_ledger.transactions().values().collect::>(); - transactions.sort_unstable_by(|a, b| b.timestamp.cmp(&a.timestamp)); + transactions.sort_unstable_by(|a, b| { + b.payload + .transaction() + .creation_slot() + .cmp(&a.payload.transaction().creation_slot()) + }); if transactions.is_empty() { println_log_info!("No transactions found"); @@ -1170,10 +1180,12 @@ pub async fn transactions_command(wallet: &Wallet, show_details: bool) -> Result if show_details { println_log_info!("{:#?}", tx); } else { - let transaction_time = to_utc_date_time(tx.timestamp)?; - let formatted_time = transaction_time.format("%Y-%m-%d %H:%M:%S UTC").to_string(); - - println_log_info!("{:<5}{}\t{}", i, tx.transaction_id, formatted_time); + println_log_info!( + "{:<5}{}\t{}", + i, + tx.transaction_id, + tx.payload.transaction().creation_slot() + ); } } } From 11b219fd537b3df28ebb900692961b1698176c9e Mon Sep 17 00:00:00 2001 From: Thibault Martinez Date: Wed, 6 Mar 2024 17:20:32 +0100 Subject: [PATCH 08/11] CLI formatted creation_time --- cli/src/wallet_cli/mod.rs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/cli/src/wallet_cli/mod.rs b/cli/src/wallet_cli/mod.rs index e65ec747d2..33beec6fb5 100644 --- a/cli/src/wallet_cli/mod.rs +++ b/cli/src/wallet_cli/mod.rs @@ -35,7 +35,7 @@ use rustyline::{error::ReadlineError, history::MemHistory, Config, Editor}; use self::completer::WalletCommandHelper; use crate::{ - helper::{bytes_from_hex_or_file, get_password}, + helper::{bytes_from_hex_or_file, get_password, to_utc_date_time}, println_log_error, println_log_info, }; @@ -1180,12 +1180,16 @@ pub async fn transactions_command(wallet: &Wallet, show_details: bool) -> Result if show_details { println_log_info!("{:#?}", tx); } else { - println_log_info!( - "{:<5}{}\t{}", - i, - tx.transaction_id, - tx.payload.transaction().creation_slot() - ); + let protocol_parameters = wallet.client().get_protocol_parameters().await?; + let creation_slot = tx.payload.transaction().creation_slot(); + let creation_time = to_utc_date_time(creation_slot.to_timestamp( + protocol_parameters.genesis_unix_timestamp(), + protocol_parameters.slot_duration_in_seconds(), + ) as u128)? + .format("%Y-%m-%d %H:%M:%S UTC") + .to_string(); + + println_log_info!("{:<5}{}\t{}\t{}", i, tx.transaction_id, creation_slot, creation_time); } } } From 55aa738ae44003f30c74727458d31e209b4dc864 Mon Sep 17 00:00:00 2001 From: Thibault Martinez Date: Mon, 11 Mar 2024 11:04:36 +0100 Subject: [PATCH 09/11] Add duration to example --- .../block/01_block_confirmation_time.rs | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/sdk/examples/client/block/01_block_confirmation_time.rs b/sdk/examples/client/block/01_block_confirmation_time.rs index 5921127c2f..4748953ffb 100644 --- a/sdk/examples/client/block/01_block_confirmation_time.rs +++ b/sdk/examples/client/block/01_block_confirmation_time.rs @@ -8,6 +8,8 @@ //! cargo run --release --example block_confirmation_time //! ``` +use std::time::Instant; + use crypto::keys::bip44::Bip44; use iota_sdk::{ client::{ @@ -45,20 +47,32 @@ async fn main() -> Result<(), Box> { println!("{block:#?}"); + let mut block_state = BlockState::Pending; + let start = Instant::now(); + // Wait for the block to get included for _ in 0..30 { tokio::time::sleep(std::time::Duration::from_secs(1)).await; let metadata = client.get_block_metadata(&block_id).await?; - if let BlockState::Confirmed | BlockState::Finalized = metadata.block_state { + block_state = metadata.block_state; + + if let BlockState::Confirmed | BlockState::Finalized = block_state { break; } } - println!( - "Block with no payload included: {}/block/{}", - std::env::var("EXPLORER_URL").unwrap(), - block_id - ); + if let BlockState::Confirmed | BlockState::Finalized = block_state { + let duration = start.elapsed(); + + println!( + "Block with no payload included after {} seconds: {}/block/{}", + duration.as_secs(), + std::env::var("EXPLORER_URL").unwrap(), + block_id + ); + } else { + println!("Block with no payload was not included"); + } Ok(()) } From 9d87c8081ec72ea25f09ba9e99b2ac9b156287c6 Mon Sep 17 00:00:00 2001 From: Thibault Martinez Date: Mon, 11 Mar 2024 11:16:00 +0100 Subject: [PATCH 10/11] Reverse conditions --- sdk/src/wallet/core/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/src/wallet/core/mod.rs b/sdk/src/wallet/core/mod.rs index f446a585aa..716a37c6cf 100644 --- a/sdk/src/wallet/core/mod.rs +++ b/sdk/src/wallet/core/mod.rs @@ -188,13 +188,13 @@ impl WalletLedger { } if let Some(included_below_slot) = filter.included_below_slot { - if output.metadata.included().slot() < included_below_slot { + if output.metadata.included().slot() > included_below_slot { return false; } } if let Some(included_above_slot) = filter.included_above_slot { - if output.metadata.included().slot() > included_above_slot { + if output.metadata.included().slot() < included_above_slot { return false; } } From 5bd77d919ec472e47c433bfd4e189c7f7acd694f Mon Sep 17 00:00:00 2001 From: Thibault Martinez Date: Thu, 28 Mar 2024 11:16:56 +0100 Subject: [PATCH 11/11] Happy Thoralf noises --- bindings/nodejs/lib/types/wallet/wallet.ts | 4 ++-- sdk/src/wallet/mod.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bindings/nodejs/lib/types/wallet/wallet.ts b/bindings/nodejs/lib/types/wallet/wallet.ts index 4c296c4073..5edc9d066d 100644 --- a/bindings/nodejs/lib/types/wallet/wallet.ts +++ b/bindings/nodejs/lib/types/wallet/wallet.ts @@ -163,9 +163,9 @@ export interface NftSyncOptions { /** Options to filter outputs */ export interface FilterOptions { - /** Filter all outputs where the included slot is below the specified slot */ + /** Include all outputs where the included slot is below the specified slot */ includedBelowSlot?: SlotIndex; - /** Filter all outputs where the included slot is above the specified slot */ + /** Include all outputs where the included slot is above the specified slot */ includedAboveSlot?: SlotIndex; /** Filter all outputs for the provided types (Basic = 3, Account = 4, Foundry = 5, NFT = 6) */ outputTypes?: number[]; diff --git a/sdk/src/wallet/mod.rs b/sdk/src/wallet/mod.rs index fd66a34e00..8b704305ab 100644 --- a/sdk/src/wallet/mod.rs +++ b/sdk/src/wallet/mod.rs @@ -88,9 +88,9 @@ use crate::{ #[derive(Debug, Default, Clone, Serialize, Deserialize, Eq, PartialEq)] #[serde(rename_all = "camelCase")] pub struct FilterOptions { - /// Filter all outputs where the included slot is below the specified slot. + /// Include all outputs where the included slot is below the specified slot. pub included_below_slot: Option, - /// Filter all outputs where the included slot is above the specified slot. + /// Include all outputs where the included slot is above the specified slot. pub included_above_slot: Option, /// Filter all outputs for the provided types (Basic = 3, Account = 4, Foundry = 5, NFT = 6). pub output_types: Option>,