Skip to content

Move Timestamp to cosmwasm-core #2114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 15, 2024
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
2 changes: 2 additions & 0 deletions packages/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ mod errors;
mod forward_ref;
mod hex_binary;
mod math;
mod timestamp;

#[doc(hidden)]
pub mod __internal;
Expand All @@ -38,6 +39,7 @@ pub use crate::math::{
Int512, Int64, Isqrt, SignedDecimal, SignedDecimal256, SignedDecimal256RangeExceeded,
SignedDecimalRangeExceeded, Uint128, Uint256, Uint512, Uint64,
};
pub use crate::timestamp::Timestamp;

/// Exposed for testing only
/// Both unit tests and integration tests are compiled to native code, so everything in here does not need to compile to Wasm.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use core::fmt;
use cosmwasm_core::Uint64;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

use crate::Uint64;

/// A point in time in nanosecond precision.
///
/// This type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.
Expand All @@ -21,9 +21,8 @@ use serde::{Deserialize, Serialize};
/// assert_eq!(ts.seconds(), 3);
/// assert_eq!(ts.subsec_nanos(), 202);
/// ```
#[derive(
Serialize, Deserialize, Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, JsonSchema,
)]
#[derive(Serialize, Deserialize, Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord)]
#[cfg_attr(feature = "std", derive(schemars::JsonSchema))]
pub struct Timestamp(Uint64);

impl Timestamp {
Expand Down
3 changes: 1 addition & 2 deletions packages/std/src/ibc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
// The rest of the IBC related functionality is defined here

use core::cmp::{Ord, Ordering, PartialOrd};
use cosmwasm_core::Addr;
use cosmwasm_core::{Addr, Timestamp};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

use crate::coin::Coin;
use crate::prelude::*;
use crate::results::{Attribute, CosmosMsg, Empty, Event, SubMsg};
use crate::timestamp::Timestamp;
use crate::StdResult;
use crate::{to_json_binary, Binary};

Expand Down
6 changes: 2 additions & 4 deletions packages/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ mod sections;
mod serde;
mod stdack;
mod storage;
mod timestamp;
mod traits;
mod types;

Expand Down Expand Up @@ -78,7 +77,6 @@ pub use crate::serde::{
};
pub use crate::stdack::StdAck;
pub use crate::storage::MemoryStorage;
pub use crate::timestamp::Timestamp;
pub use crate::traits::{Api, Querier, QuerierResult, QuerierWrapper, Storage};
pub use crate::types::{BlockInfo, ContractInfo, Env, MessageInfo, TransactionInfo};

Expand Down Expand Up @@ -117,8 +115,8 @@ pub use cosmwasm_core::{
Decimal256RangeExceeded, DecimalRangeExceeded, DivideByZeroError, DivisionError, Fraction,
HexBinary, Instantiate2AddressError, Int128, Int256, Int512, Int64, Isqrt, OverflowError,
OverflowOperation, RecoverPubkeyError, SignedDecimal, SignedDecimal256,
SignedDecimal256RangeExceeded, SignedDecimalRangeExceeded, SystemError, Uint128, Uint256,
Uint512, Uint64, VerificationError,
SignedDecimal256RangeExceeded, SignedDecimalRangeExceeded, SystemError, Timestamp, Uint128,
Uint256, Uint512, Uint64, VerificationError,
};

#[cfg(not(target_arch = "wasm32"))]
Expand Down
3 changes: 1 addition & 2 deletions packages/std/src/testing/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use bech32::{encode, Bech32, Hrp};
use core::marker::PhantomData;
#[cfg(feature = "cosmwasm_1_3")]
use core::ops::Bound;
use cosmwasm_core::{Addr, CanonicalAddr};
use cosmwasm_core::{Addr, CanonicalAddr, Timestamp};
use rand_core::OsRng;
use serde::de::DeserializeOwned;
#[cfg(feature = "stargate")]
Expand Down Expand Up @@ -36,7 +36,6 @@ use crate::query::{
use crate::query::{DelegatorWithdrawAddressResponse, DistributionQuery};
use crate::results::{ContractResult, Empty, SystemResult};
use crate::storage::MemoryStorage;
use crate::timestamp::Timestamp;
use crate::traits::{Api, Querier, QuerierResult};
use crate::types::{BlockInfo, ContractInfo, Env, MessageInfo, TransactionInfo};
use crate::{from_json, to_json_binary, Binary, Uint128};
Expand Down
3 changes: 1 addition & 2 deletions packages/std/src/types.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use cosmwasm_core::Addr;
use cosmwasm_core::{Addr, Timestamp};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

use crate::coin::Coin;
use crate::prelude::*;
use crate::timestamp::Timestamp;

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
pub struct Env {
Expand Down