From 5a2ec5b387699a7dcbee31a030190d8d3023d341 Mon Sep 17 00:00:00 2001 From: Frank Bell Date: Thu, 7 Mar 2024 21:12:53 +0000 Subject: [PATCH] feat(pop-api): add relay_chain_block_number function --- pop-api/src/lib.rs | 2 +- pop-api/src/v0/mod.rs | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/pop-api/src/lib.rs b/pop-api/src/lib.rs index f1ffe3f5..a1a88aee 100644 --- a/pop-api/src/lib.rs +++ b/pop-api/src/lib.rs @@ -9,7 +9,7 @@ use primitives::storage_keys::*; use scale; pub use sp_runtime::{BoundedVec, MultiAddress, MultiSignature}; use v0::RuntimeCall; -pub use v0::{balances, nfts, state}; +pub use v0::{balances, nfts, relay_chain_block_number, state}; type AccountId = ::AccountId; type Balance = ::Balance; diff --git a/pop-api/src/v0/mod.rs b/pop-api/src/v0/mod.rs index 7b87dc25..0c20f9e6 100644 --- a/pop-api/src/v0/mod.rs +++ b/pop-api/src/v0/mod.rs @@ -1,7 +1,18 @@ +use crate::{ + primitives::storage_keys::{ParachainSystemKeys, RuntimeStateKeys}, + BlockNumber, PopApiError, +}; + pub mod balances; pub mod nfts; pub mod state; +pub fn relay_chain_block_number() -> Result { + Ok(state::read(RuntimeStateKeys::ParachainSystem( + ParachainSystemKeys::LastRelayChainBlockNumber, + ))?) +} + #[derive(scale::Encode)] pub(crate) enum RuntimeCall { #[codec(index = 10)]