Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions packages/rs-dpp/src/state_repository.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Option<u32>>;

// Get latest platform block height
async fn fetch_latest_platform_block_height(&self) -> AnyResult<u64>;
}
18 changes: 18 additions & 0 deletions packages/wasm-dpp/src/state_repository.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@ extern "C" {
this: &ExternalStateRepositoryLike,
) -> Result<JsValue, JsValue>;

#[wasm_bindgen(catch, structural, method, js_name=fetchLatestPlatformBlockHeight)]
pub async fn fetch_latest_platform_block_height(
this: &ExternalStateRepositoryLike,
) -> Result<JsValue, JsValue>;

#[wasm_bindgen(catch, structural, method, js_name=fetchTransaction)]
pub async fn fetch_transaction(
this: &ExternalStateRepositoryLike,
Expand Down Expand Up @@ -529,6 +534,19 @@ impl StateRepositoryLike for ExternalStateRepositoryLikeWrapper {
Ok(Some(height as u32))
}

async fn fetch_latest_platform_block_height(&self) -> Result<u64> {
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,
Expand Down