From e75932b732306bc9927e287af7854ac3bd61452e Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Thu, 21 May 2026 14:29:28 +0200 Subject: [PATCH] feat(platform-wallet): expose sync_watermark() on PlatformAddressWallet MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds an async accessor for the unified provider's last_known_recent_block watermark, so callers driving sync_balances() directly (e.g. PA-007/PA-007b e2e tests) can observe progress without waiting for the periodic PlatformAddressSyncManager event. Returns Option with None for both "provider not initialised" and "watermark == 0" — the existing apply_sync_state convention. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../src/wallet/platform_addresses/provider.rs | 10 ++++++++++ .../src/wallet/platform_addresses/wallet.rs | 15 +++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/packages/rs-platform-wallet/src/wallet/platform_addresses/provider.rs b/packages/rs-platform-wallet/src/wallet/platform_addresses/provider.rs index 3dc9a67565..59a2853c9b 100644 --- a/packages/rs-platform-wallet/src/wallet/platform_addresses/provider.rs +++ b/packages/rs-platform-wallet/src/wallet/platform_addresses/provider.rs @@ -430,6 +430,16 @@ impl PlatformPaymentAddressProvider { self.last_known_recent_block = result.last_known_recent_block; } + /// Current `last_known_recent_block` watermark. + /// + /// Crate-visible mirror of the field used by the `AddressProvider` + /// trait implementation, so wallet-level helpers (notably + /// [`super::wallet::PlatformAddressWallet::sync_watermark`]) can + /// read the value without going through the trait. + pub(crate) fn last_known_recent_block(&self) -> u64 { + self.last_known_recent_block + } + /// Restore incremental-sync watermark from persisted state. pub(crate) fn set_stored_sync_state( &mut self, diff --git a/packages/rs-platform-wallet/src/wallet/platform_addresses/wallet.rs b/packages/rs-platform-wallet/src/wallet/platform_addresses/wallet.rs index aec6d5b4f9..812aa027bd 100644 --- a/packages/rs-platform-wallet/src/wallet/platform_addresses/wallet.rs +++ b/packages/rs-platform-wallet/src/wallet/platform_addresses/wallet.rs @@ -287,6 +287,21 @@ impl PlatformAddressWallet { .unwrap_or_default() } + /// Current incremental-sync watermark (`last_known_recent_block`) + /// from the unified platform-address provider. + /// + /// Returns `None` when the provider hasn't been initialised yet or + /// when no incremental sync has produced a watermark. A zero-valued + /// watermark is reported as `None` to match the "no stored watermark" + /// convention used by [`Self::apply_sync_state`]. Intended for + /// progress checks where the precise "uninitialised vs. zero" + /// distinction is not material. + pub async fn sync_watermark(&self) -> Option { + let guard = self.provider.read().await; + let raw = guard.as_ref().map(|p| p.last_known_recent_block())?; + (raw > 0).then_some(raw) + } + /// Get total platform credits across all addresses. /// /// Returns the sum of all cached balances.