mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 11:01:01 +00:00
Estimate message fee api (#600)
* estimate_message_delivery_and_dispatch_fee runtime API * auto-determine message fees in relay * remove fee argument from relay calls * Fix import of weight contant Co-authored-by: Hernando Castano <castano.ha@gmail.com>
This commit is contained in:
committed by
Bastian Köcher
parent
0624fd0d94
commit
9fbb922766
@@ -26,7 +26,7 @@ use bp_message_lane::{LaneId, MessageNonce, UnrewardedRelayersState};
|
||||
use bp_runtime::Chain;
|
||||
use frame_support::{
|
||||
weights::{constants::WEIGHT_PER_SECOND, DispatchClass, Weight},
|
||||
RuntimeDebug,
|
||||
Parameter, RuntimeDebug,
|
||||
};
|
||||
use frame_system::limits;
|
||||
use sp_core::Hasher as HasherT;
|
||||
@@ -191,6 +191,9 @@ pub const IS_KNOWN_MILLAU_BLOCK_METHOD: &str = "MillauHeaderApi_is_known_block";
|
||||
/// Name of the `MillauHeaderApi::incomplete_headers` runtime method.
|
||||
pub const INCOMPLETE_MILLAU_HEADERS_METHOD: &str = "MillauHeaderApi_incomplete_headers";
|
||||
|
||||
/// Name of the `ToMillauOutboundLaneApi::estimate_message_delivery_and_dispatch_fee` runtime method.
|
||||
pub const TO_MILLAU_ESTIMATE_MESSAGE_FEE_METHOD: &str =
|
||||
"ToMillauOutboundLaneApi_estimate_message_delivery_and_dispatch_fee";
|
||||
/// Name of the `ToMillauOutboundLaneApi::messages_dispatch_weight` runtime method.
|
||||
pub const TO_MILLAU_MESSAGES_DISPATCH_WEIGHT_METHOD: &str = "ToMillauOutboundLaneApi_messages_dispatch_weight";
|
||||
/// Name of the `ToMillauOutboundLaneApi::latest_received_nonce` runtime method.
|
||||
@@ -235,7 +238,20 @@ sp_api::decl_runtime_apis! {
|
||||
///
|
||||
/// This API is implemented by runtimes that are sending messages to Millau chain, not the
|
||||
/// Millau runtime itself.
|
||||
pub trait ToMillauOutboundLaneApi {
|
||||
pub trait ToMillauOutboundLaneApi<OutboundMessageFee: Parameter, OutboundPayload: Parameter> {
|
||||
/// Estimate message delivery and dispatch fee that needs to be paid by the sender on
|
||||
/// this chain.
|
||||
///
|
||||
/// Returns `None` if message is too expensive to be sent to Millau from this chain.
|
||||
///
|
||||
/// Please keep in mind that this method returns lowest message fee required for message
|
||||
/// to be accepted to the lane. It may be good idea to pay a bit over this price to account
|
||||
/// future exchange rate changes and guarantee that relayer would deliver your message
|
||||
/// to the target chain.
|
||||
fn estimate_message_delivery_and_dispatch_fee(
|
||||
lane_id: LaneId,
|
||||
payload: OutboundPayload,
|
||||
) -> Option<OutboundMessageFee>;
|
||||
/// Returns total dispatch weight and encoded payload size of all messages in given inclusive range.
|
||||
///
|
||||
/// If some (or all) messages are missing from the storage, they'll also will
|
||||
|
||||
Reference in New Issue
Block a user