From 81c47b8ecf2fffaa8d1d9e69ed8cd2d2b8dbde81 Mon Sep 17 00:00:00 2001 From: Shunkichi Sato <49983831+s8sato@users.noreply.github.com> Date: Wed, 8 Jan 2025 18:01:59 +0900 Subject: [PATCH] fix: revise NonZeros Signed-off-by: Shunkichi Sato <49983831+s8sato@users.noreply.github.com> --- crates/iroha_cli/src/main.rs | 4 ++-- .../iroha_executor/src/default/isi/multisig/transaction.rs | 5 +---- crates/iroha_executor_data_model/src/isi.rs | 4 ++-- docs/source/references/schema.json | 4 ++-- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/crates/iroha_cli/src/main.rs b/crates/iroha_cli/src/main.rs index 52ef99b42bd..71301216e5a 100644 --- a/crates/iroha_cli/src/main.rs +++ b/crates/iroha_cli/src/main.rs @@ -1581,7 +1581,7 @@ mod multisig { proposal_status.instructions = proposal_value.instructions; proposal_status.proposed_at = { let proposed_at = Duration::from_secs( - Duration::from_millis(proposal_value.proposed_at_ms.into()).as_secs(), + Duration::from_millis(proposal_value.proposed_at_ms).as_secs(), ); SystemTime::UNIX_EPOCH .checked_add(proposed_at) @@ -1592,7 +1592,7 @@ mod multisig { let now = SystemTime::now() .duration_since(SystemTime::UNIX_EPOCH) .unwrap(); - let expires_at = Duration::from_millis(proposal_value.expires_at_ms.into()); + let expires_at = Duration::from_millis(proposal_value.expires_at_ms); Duration::from_secs(expires_at.saturating_sub(now).as_secs()).into() }; } diff --git a/crates/iroha_executor/src/default/isi/multisig/transaction.rs b/crates/iroha_executor/src/default/isi/multisig/transaction.rs index 47236cb89bb..17b23d9aeb0 100644 --- a/crates/iroha_executor/src/default/isi/multisig/transaction.rs +++ b/crates/iroha_executor/src/default/isi/multisig/transaction.rs @@ -1,7 +1,6 @@ //! Validation and execution logic of instructions for multisig transactions use alloc::{collections::btree_set::BTreeSet, vec}; -use core::num::NonZeroU64; use iroha_smart_contract::data_model::query::error::QueryExecutionFail; @@ -189,15 +188,13 @@ fn proposal_value( .map_err(metadata_conversion_error) } -fn now_ms(executor: &V) -> NonZeroU64 { +fn now_ms(executor: &V) -> u64 { executor .context() .curr_block .creation_time() .as_millis() .try_into() - .ok() - .and_then(NonZeroU64::new) .dbg_expect("shouldn't overflow within 584942417 years") } diff --git a/crates/iroha_executor_data_model/src/isi.rs b/crates/iroha_executor_data_model/src/isi.rs index 1b48b2b500f..c0b9a736780 100644 --- a/crates/iroha_executor_data_model/src/isi.rs +++ b/crates/iroha_executor_data_model/src/isi.rs @@ -132,9 +132,9 @@ pub mod multisig { /// Proposal contents pub instructions: Vec, /// Time in milliseconds at which the proposal was made - pub proposed_at_ms: NonZeroU64, + pub proposed_at_ms: u64, /// Time in milliseconds at which the proposal will expire - pub expires_at_ms: NonZeroU64, + pub expires_at_ms: u64, /// List of approvers of the proposal so far pub approvals: BTreeSet, /// In case this proposal is some relaying approval, indicates if it has executed or not diff --git a/docs/source/references/schema.json b/docs/source/references/schema.json index a0e9b8e56ad..99c2137b5fe 100644 --- a/docs/source/references/schema.json +++ b/docs/source/references/schema.json @@ -3041,11 +3041,11 @@ }, { "name": "proposed_at_ms", - "type": "NonZero" + "type": "u64" }, { "name": "expires_at_ms", - "type": "NonZero" + "type": "u64" }, { "name": "approvals",