mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-08-08 05:55:45 +00:00
18d53dbf91
# Description Adds Snowbridge to the Rococo bridge hub runtime. Includes config changes required in Rococo asset hub. --------- Co-authored-by: Alistair Singh <alistair.singh7@gmail.com> Co-authored-by: ron <yrong1997@gmail.com> Co-authored-by: Vincent Geddes <vincent.geddes@hey.com> Co-authored-by: claravanstaden <Cats 4 life!>
31 lines
801 B
Rust
31 lines
801 B
Rust
// SPDX-License-Identifier: Apache-2.0
|
|
// SPDX-FileCopyrightText: 2023 Snowfork <hello@snowfork.com>
|
|
//! Helpers for implementing runtime api
|
|
|
|
use crate::{Config, MessageLeaves};
|
|
use frame_support::storage::StorageStreamIter;
|
|
use snowbridge_core::outbound::{Message, SendMessage};
|
|
use snowbridge_outbound_queue_merkle_tree::{merkle_proof, MerkleProof};
|
|
|
|
pub fn prove_message<T>(leaf_index: u64) -> Option<MerkleProof>
|
|
where
|
|
T: Config,
|
|
{
|
|
if !MessageLeaves::<T>::exists() {
|
|
return None
|
|
}
|
|
let proof =
|
|
merkle_proof::<<T as Config>::Hashing, _>(MessageLeaves::<T>::stream_iter(), leaf_index);
|
|
Some(proof)
|
|
}
|
|
|
|
pub fn calculate_fee<T>(message: Message) -> Option<T::Balance>
|
|
where
|
|
T: Config,
|
|
{
|
|
match crate::Pallet::<T>::validate(&message) {
|
|
Ok((_, fees)) => Some(fees.total()),
|
|
_ => None,
|
|
}
|
|
}
|