From 9595252c8c2bb93cdf84ab5748e9eba3e54cf1fd Mon Sep 17 00:00:00 2001 From: hal3e Date: Tue, 29 Aug 2023 17:00:15 +0200 Subject: [PATCH] chore: replace deprecated `chrono` functions (#1111) --- Cargo.toml | 2 +- packages/fuels-core/Cargo.toml | 4 ++-- packages/fuels-core/src/types/wrappers/block.rs | 2 +- .../fuels-core/src/types/wrappers/transaction_response.rs | 2 +- packages/fuels/tests/providers.rs | 5 ++++- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9bfd08e275..9dc070a9c0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,7 +41,7 @@ Inflector = "0.11.4" async-trait = { version = "0.1.73", default-features = false } bech32 = "0.9.1" bytes = { version = "1.4.0", default-features = false } -chrono = "0.4.26" +chrono = "0.4.27" elliptic-curve = { version = "0.13.5", default-features = false } eth-keystore = "0.5.0" fuel-abi-types = "0.3.0" diff --git a/packages/fuels-core/Cargo.toml b/packages/fuels-core/Cargo.toml index cce1aaedbd..2e831ac706 100644 --- a/packages/fuels-core/Cargo.toml +++ b/packages/fuels-core/Cargo.toml @@ -10,8 +10,8 @@ rust-version = { workspace = true } description = "Fuel Rust SDK core." [dependencies] -bech32 = "0.9.0" -chrono = "0.4.2" +bech32 = { workspace = true } +chrono = { workspace = true } fuel-abi-types = { workspace = true } fuel-asm = { workspace = true } fuel-core = { workspace = true, default-features = false, optional = true } diff --git a/packages/fuels-core/src/types/wrappers/block.rs b/packages/fuels-core/src/types/wrappers/block.rs index c9a4e65fb7..080e0e1d68 100644 --- a/packages/fuels-core/src/types/wrappers/block.rs +++ b/packages/fuels-core/src/types/wrappers/block.rs @@ -23,7 +23,7 @@ pub struct Header { impl From for Header { fn from(client_header: ClientHeader) -> Self { let naive = NaiveDateTime::from_timestamp_opt(client_header.time.to_unix(), 0); - let time = naive.map(|time| DateTime::::from_utc(time, Utc)); + let time = naive.map(|time| DateTime::::from_naive_utc_and_offset(time, Utc)); Self { id: client_header.id, diff --git a/packages/fuels-core/src/types/wrappers/transaction_response.rs b/packages/fuels-core/src/types/wrappers/transaction_response.rs index 9b3a6e592b..6d8f64d914 100644 --- a/packages/fuels-core/src/types/wrappers/transaction_response.rs +++ b/packages/fuels-core/src/types/wrappers/transaction_response.rs @@ -45,7 +45,7 @@ impl From for TransactionResponse { ClientTransactionStatus::Success { time, .. } | ClientTransactionStatus::Failure { time, .. } => { let native = NaiveDateTime::from_timestamp_opt(time.to_unix(), 0); - native.map(|time| DateTime::::from_utc(time, Utc)) + native.map(|time| DateTime::::from_naive_utc_and_offset(time, Utc)) } }; diff --git a/packages/fuels/tests/providers.rs b/packages/fuels/tests/providers.rs index 448cc6ff1d..c45a99156f 100644 --- a/packages/fuels/tests/providers.rs +++ b/packages/fuels/tests/providers.rs @@ -749,7 +749,10 @@ fn given_a_message(address: Bech32Address, message_amount: u64) -> Message { fn convert_to_datetime(timestamp: u64) -> DateTime { let unix = Tai64(timestamp).to_unix(); - DateTime::from_local(NaiveDateTime::from_timestamp_opt(unix, 0).unwrap(), Utc) + NaiveDateTime::from_timestamp_opt(unix, 0) + .unwrap() + .and_local_timezone(Utc) + .unwrap() } /// This test is here in addition to `can_set_custom_block_time` because even though this test