Skip to content

Commit

Permalink
feat(pop-api): add relay_chain_block_number function
Browse files Browse the repository at this point in the history
  • Loading branch information
evilrobot-01 committed Mar 7, 2024
1 parent 3f244cf commit 5a2ec5b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pop-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use primitives::storage_keys::*;
use scale;

Check warning on line 9 in pop-api/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

this import is redundant

warning: this import is redundant --> pop-api/src/lib.rs:9:1 | 9 | use scale; | ^^^^^^^^^^ help: remove it entirely | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_component_path_imports = note: `#[warn(clippy::single_component_path_imports)]` on by default
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 = <Environment as ink::env::Environment>::AccountId;
type Balance = <Environment as ink::env::Environment>::Balance;
Expand Down
11 changes: 11 additions & 0 deletions pop-api/src/v0/mod.rs
Original file line number Diff line number Diff line change
@@ -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<BlockNumber, PopApiError> {
Ok(state::read(RuntimeStateKeys::ParachainSystem(
ParachainSystemKeys::LastRelayChainBlockNumber,
))?)

Check warning on line 13 in pop-api/src/v0/mod.rs

View workflow job for this annotation

GitHub Actions / clippy

question mark operator is useless here

warning: question mark operator is useless here --> pop-api/src/v0/mod.rs:11:2 | 11 | / Ok(state::read(RuntimeStateKeys::ParachainSystem( 12 | | ParachainSystemKeys::LastRelayChainBlockNumber, 13 | | ))?) | |________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_question_mark = note: `#[warn(clippy::needless_question_mark)]` on by default help: try removing question mark and `Ok()` | 11 ~ state::read(RuntimeStateKeys::ParachainSystem( 12 ~ ParachainSystemKeys::LastRelayChainBlockNumber, 13 ~ )) |
}

#[derive(scale::Encode)]
pub(crate) enum RuntimeCall {
#[codec(index = 10)]
Expand Down

0 comments on commit 5a2ec5b

Please sign in to comment.