Skip to content

Commit

Permalink
fix: fix deprecated functions
Browse files Browse the repository at this point in the history
  • Loading branch information
jjyr authored and Flouse committed Nov 1, 2023
1 parent c1664d0 commit e86bd11
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions web3/crates/indexer/src/indexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -625,8 +625,14 @@ impl Web3Indexer {
};

let epoch_time_as_millis: u64 = l2_block.raw().timestamp().unpack();
let timestamp =
NaiveDateTime::from_timestamp((epoch_time_as_millis / MILLIS_PER_SEC) as i64, 0);
let timestamp = {
let timestamp = NaiveDateTime::from_timestamp_opt(
(epoch_time_as_millis / MILLIS_PER_SEC) as i64,
0,
)
.ok_or_else(|| anyhow!("fail to parse epoch time"))?;
DateTime::from_naive_utc_and_offset(timestamp, Utc)
};
let size = l2_block.raw().as_slice().len();
let web3_block = Web3Block {
number: block_number,
Expand All @@ -636,7 +642,7 @@ impl Web3Indexer {
gas_used,
miner: miner_address,
size,
timestamp: DateTime::<Utc>::from_utc(timestamp, Utc),
timestamp,
};
Ok(web3_block)
}
Expand Down

0 comments on commit e86bd11

Please sign in to comment.