diff --git a/packages/rs-dpp/src/data_trigger/feature_flags_data_triggers/mod.rs b/packages/rs-dpp/src/data_trigger/feature_flags_data_triggers/mod.rs index 528128186bf..584c6c56a2c 100644 --- a/packages/rs-dpp/src/data_trigger/feature_flags_data_triggers/mod.rs +++ b/packages/rs-dpp/src/data_trigger/feature_flags_data_triggers/mod.rs @@ -40,15 +40,14 @@ where ) })?; - let core_chain_locked_height = context + let block_height = context .state_repository - .fetch_latest_platform_core_chain_locked_height() - .await? - .unwrap_or_default() as i64; + .fetch_latest_platform_block_height() + .await? as i64; let enable_at_height = data.get_i64(PROPERTY_ENABLE_AT_HEIGHT)?; - if enable_at_height < core_chain_locked_height { + if enable_at_height < block_height { let err = create_error( context, dt_create, diff --git a/packages/rs-dpp/src/state_repository.rs b/packages/rs-dpp/src/state_repository.rs index 0b83742e51b..2f9be60f0f6 100644 --- a/packages/rs-dpp/src/state_repository.rs +++ b/packages/rs-dpp/src/state_repository.rs @@ -213,4 +213,7 @@ pub trait StateRepositoryLike: Sync { // Get latest (in a queue) withdrawal transaction index async fn fetch_latest_platform_core_chain_locked_height(&self) -> AnyResult>; + + // Get latest platform block height + async fn fetch_latest_platform_block_height(&self) -> AnyResult; } diff --git a/packages/wasm-dpp/src/state_repository.rs b/packages/wasm-dpp/src/state_repository.rs index de70f6ed1e1..385e4a842d3 100644 --- a/packages/wasm-dpp/src/state_repository.rs +++ b/packages/wasm-dpp/src/state_repository.rs @@ -141,6 +141,11 @@ extern "C" { this: &ExternalStateRepositoryLike, ) -> Result; + #[wasm_bindgen(catch, structural, method, js_name=fetchLatestPlatformBlockHeight)] + pub async fn fetch_latest_platform_block_height( + this: &ExternalStateRepositoryLike, + ) -> Result; + #[wasm_bindgen(catch, structural, method, js_name=fetchTransaction)] pub async fn fetch_transaction( this: &ExternalStateRepositoryLike, @@ -529,6 +534,19 @@ impl StateRepositoryLike for ExternalStateRepositoryLikeWrapper { Ok(Some(height as u32)) } + async fn fetch_latest_platform_block_height(&self) -> Result { + let height = self + .0 + .fetch_latest_platform_block_height() + .await + .map_err(from_js_error)?; + + let height = height + .as_f64() + .ok_or_else(|| anyhow!("Value is not a number"))?; + Ok(height as u64) + } + async fn verify_instant_lock( &self, instant_lock: &InstantLock,