From 9da5f21ff594e4b060faf390acf505b1f3b7c1e6 Mon Sep 17 00:00:00 2001 From: Thibault Martinez Date: Mon, 20 Nov 2023 11:43:20 +0100 Subject: [PATCH 1/3] TMP --- .../syncing/addresses/output_ids/mod.rs | 1 + sdk/src/wallet/operations/syncing/mod.rs | 16 ++++++++++++---- sdk/src/wallet/operations/syncing/options.rs | 9 +++++++++ 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/sdk/src/wallet/operations/syncing/addresses/output_ids/mod.rs b/sdk/src/wallet/operations/syncing/addresses/output_ids/mod.rs index 0ce8368503..c9ddc7b6cb 100644 --- a/sdk/src/wallet/operations/syncing/addresses/output_ids/mod.rs +++ b/sdk/src/wallet/operations/syncing/addresses/output_ids/mod.rs @@ -47,6 +47,7 @@ where if (address.is_ed25519() && sync_options.wallet.all_outputs()) || (address.is_nft() && sync_options.nft.all_outputs()) || (address.is_account() && sync_options.account.all_outputs()) + || (address.is_implicit_account_creation() && sync_options.sync_implicit_accounts) { return Ok(self .client() diff --git a/sdk/src/wallet/operations/syncing/mod.rs b/sdk/src/wallet/operations/syncing/mod.rs index abbbbb4d4e..4a3e1e569b 100644 --- a/sdk/src/wallet/operations/syncing/mod.rs +++ b/sdk/src/wallet/operations/syncing/mod.rs @@ -107,7 +107,15 @@ where key_index: 0, }; - let address_to_sync = vec![wallet_address_with_unspent_outputs]; + let address_to_sync = vec![ + wallet_address_with_unspent_outputs, + AddressWithUnspentOutputs { + address: self.implicit_account_creation_address().await?, + output_ids: vec![], + internal: false, + key_index: 0, + }, + ]; let (addresses_with_unspent_outputs, spent_or_not_synced_output_ids, outputs_data): ( Vec, @@ -124,11 +132,11 @@ where // Add the output response to the output ids, the output response is optional, because an output could be // pruned and then we can't get the metadata - let mut spent_or_unsynced_output_metadata_map: HashMap> = + let mut spent_or_unsynced_output_metadata: HashMap> = spent_or_not_synced_output_ids.into_iter().map(|o| (o, None)).collect(); for output_metadata_response in spent_or_unsynced_output_metadata_responses { let output_id = output_metadata_response.output_id(); - spent_or_unsynced_output_metadata_map.insert(*output_id, Some(output_metadata_response)); + spent_or_unsynced_output_metadata.insert(*output_id, Some(output_metadata_response)); } if options.sync_incoming_transactions { @@ -156,7 +164,7 @@ where } // Updates wallet with balances, output ids, outputs - self.update_after_sync(outputs_data, spent_or_unsynced_output_metadata_map) + self.update_after_sync(outputs_data, spent_or_unsynced_output_metadata) .await } diff --git a/sdk/src/wallet/operations/syncing/options.rs b/sdk/src/wallet/operations/syncing/options.rs index 38e733c1e1..efedf25bda 100644 --- a/sdk/src/wallet/operations/syncing/options.rs +++ b/sdk/src/wallet/operations/syncing/options.rs @@ -8,6 +8,7 @@ const DEFAULT_SYNC_INCOMING_TRANSACTIONS: bool = false; const DEFAULT_SYNC_ONLY_MOST_BASIC_OUTPUTS: bool = false; const DEFAULT_SYNC_PENDING_TRANSACTIONS: bool = true; const DEFAULT_SYNC_NATIVE_TOKEN_FOUNDRIES: bool = false; +const DEFAULT_SYNC_IMPLICIT_ACCOUNTS: bool = false; /// The synchronization options #[derive(Debug, Clone, Eq, PartialEq, Hash, Serialize, Deserialize)] @@ -41,6 +42,9 @@ pub struct SyncOptions { /// Sync native token foundries, so their metadata can be returned in the balance. #[serde(default = "default_sync_native_token_foundries")] pub sync_native_token_foundries: bool, + /// + #[serde(default = "default_sync_implicit_accounts")] + pub sync_implicit_accounts: bool, } fn default_force_syncing() -> bool { @@ -63,6 +67,10 @@ fn default_sync_native_token_foundries() -> bool { DEFAULT_SYNC_NATIVE_TOKEN_FOUNDRIES } +fn default_sync_implicit_accounts() -> bool { + DEFAULT_SYNC_IMPLICIT_ACCOUNTS +} + impl Default for SyncOptions { fn default() -> Self { Self { @@ -74,6 +82,7 @@ impl Default for SyncOptions { sync_only_most_basic_outputs: default_sync_only_most_basic_outputs(), sync_native_token_foundries: default_sync_native_token_foundries(), force_syncing: default_force_syncing(), + sync_implicit_accounts: default_sync_implicit_accounts(), } } } From 872763aba8fdc264aa30719f853894e3e56a4e46 Mon Sep 17 00:00:00 2001 From: Thibault Martinez Date: Mon, 20 Nov 2023 13:05:15 +0100 Subject: [PATCH 2/3] Add sync option to CLI --- cli/src/wallet_cli/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/cli/src/wallet_cli/mod.rs b/cli/src/wallet_cli/mod.rs index dba658b975..8e30b03144 100644 --- a/cli/src/wallet_cli/mod.rs +++ b/cli/src/wallet_cli/mod.rs @@ -788,6 +788,7 @@ pub async fn sync_command(wallet: &Wallet) -> Result<(), Error> { let balance = wallet .sync(Some(SyncOptions { sync_native_token_foundries: true, + sync_implicit_accounts: true, ..Default::default() })) .await?; From 79c5efc9ab765ff7360ffeeb73c99be1aa1d4d22 Mon Sep 17 00:00:00 2001 From: Thibault Martinez Date: Mon, 20 Nov 2023 13:44:46 +0100 Subject: [PATCH 3/3] Doc --- sdk/src/wallet/operations/syncing/options.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/src/wallet/operations/syncing/options.rs b/sdk/src/wallet/operations/syncing/options.rs index efedf25bda..fe6d9c5489 100644 --- a/sdk/src/wallet/operations/syncing/options.rs +++ b/sdk/src/wallet/operations/syncing/options.rs @@ -42,7 +42,7 @@ pub struct SyncOptions { /// Sync native token foundries, so their metadata can be returned in the balance. #[serde(default = "default_sync_native_token_foundries")] pub sync_native_token_foundries: bool, - /// + /// Sync implicit accounts. #[serde(default = "default_sync_implicit_accounts")] pub sync_implicit_accounts: bool, }