Skip to content

feat: upgrade info types #246

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 5 commits into from
Jun 12, 2025
Merged
Show file tree
Hide file tree
Changes from 4 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
1 change: 1 addition & 0 deletions src/did/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub mod http;
pub mod rpc;
#[cfg(test)]
mod test_utils;
pub mod upgrade_info;
pub mod utils;

pub use block::Block;
Expand Down
30 changes: 30 additions & 0 deletions src/did/src/upgrade_info.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
use std::borrow::Cow;

use candid::{CandidType, Decode, Encode};
use ic_stable_structures::{Bound, Storable};
use serde::Deserialize;

use crate::build::BuildData;

/// Historical information about the canister
#[derive(CandidType, Deserialize, Clone, Debug)]
pub struct UpgradeInfo {
/// The build data of the canister
pub build_data: BuildData,
/// The timestamp of the deployment
pub deploy_ts: u64,
/// The last block number
pub last_block_number: u64,
}

impl Storable for UpgradeInfo {
const BOUND: Bound = Bound::Unbounded;

fn to_bytes(&self) -> std::borrow::Cow<[u8]> {
Cow::from(Encode!(&self).expect("Failed to encode UpgradeInfo"))
}

fn from_bytes(bytes: Cow<[u8]>) -> Self {
Decode!(&bytes, UpgradeInfo).expect("Failed to decode UpgradeInfo")
}
}
8 changes: 8 additions & 0 deletions src/evm-canister-client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use did::send_raw_transaction::SendRawTransactionRequest;
use did::state::BasicAccount;
use did::transaction::StorableExecutionResult;
use did::unsafe_blocks::ValidateUnsafeBlockArgs;
use did::upgrade_info::UpgradeInfo;
use did::{
Block, BlockConfirmationData, BlockConfirmationResult, BlockConfirmationStrategy, BlockNumber,
BlockchainBlockInfo, BlockchainStorageLimits, Bytes, EstimateGasRequest, EvmStats, FeeHistory,
Expand Down Expand Up @@ -926,4 +927,11 @@ impl<C: CanisterClient> EvmCanisterClient<C> {
pub async fn get_blockchain_block_info(&self) -> CanisterClientResult<BlockchainBlockInfo> {
self.client.query("get_blockchain_block_info", ()).await
}

/// Returns the upgrade info for the canister of the last `count` entries
pub async fn get_upgrade_info(&self, count: u64) -> CanisterClientResult<UpgradeInfo> {
self.client
.query("get_upgrade_info_paginated", (count,))
.await
}
}