// SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2023 Snowfork //! Helpers for implementing runtime api use crate::{Config, MessageLeaves}; use frame_support::storage::StorageStreamIter; use snowbridge_core::{ outbound::{Command, Fee, GasMeter}, PricingParameters, }; use snowbridge_outbound_queue_merkle_tree::{merkle_proof, MerkleProof}; use sp_core::Get; pub fn prove_message(leaf_index: u64) -> Option where T: Config, { if !MessageLeaves::::exists() { return None } let proof = merkle_proof::<::Hashing, _>(MessageLeaves::::stream_iter(), leaf_index); Some(proof) } pub fn calculate_fee( command: Command, parameters: Option>, ) -> Fee where T: Config, { let gas_used_at_most = T::GasMeter::maximum_gas_used_at_most(&command); let parameters = parameters.unwrap_or(T::PricingParameters::get()); crate::Pallet::::calculate_fee(gas_used_at_most, parameters) }