mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 21:01:02 +00:00
Declare declare_bridge_chain_runtime_apis! macro
Signed-off-by: Serban Iorga <serban@parity.io>
This commit is contained in:
committed by
Bastian Köcher
parent
5cc874e7b8
commit
59c168e89b
@@ -7,6 +7,7 @@ edition = "2021"
|
||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||
|
||||
[dependencies]
|
||||
paste = "1.0"
|
||||
|
||||
# Bridge Dependencies
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
use bp_messages::{
|
||||
InboundMessageDetails, LaneId, MessageNonce, MessagePayload, OutboundMessageDetails,
|
||||
};
|
||||
use bp_runtime::Chain;
|
||||
use bp_runtime::{declare_bridge_chain_runtime_apis, Chain};
|
||||
use frame_support::{
|
||||
weights::{constants::WEIGHT_PER_SECOND, DispatchClass, IdentityFee, Weight},
|
||||
Parameter, RuntimeDebug,
|
||||
@@ -193,75 +193,4 @@ pub const MILLAU_TO_RIALTO_PARACHAIN_CONVERSION_RATE_PARAMETER_NAME: &str =
|
||||
/// Name of the Millau fee multiplier parameter, stored in the Rialto parachain runtime.
|
||||
pub const MILLAU_FEE_MULTIPLIER_PARAMETER_NAME: &str = "MillauFeeMultiplier";
|
||||
|
||||
/// Name of the `RialtoParachainFinalityApi::best_finalized` runtime method.
|
||||
pub const BEST_FINALIZED_RIALTO_PARACHAIN_HEADER_METHOD: &str =
|
||||
"RialtoParachainFinalityApi_best_finalized";
|
||||
|
||||
/// Name of the `ToRialtoParachainOutboundLaneApi::estimate_message_delivery_and_dispatch_fee`
|
||||
/// runtime method.
|
||||
pub const TO_RIALTO_PARACHAIN_ESTIMATE_MESSAGE_FEE_METHOD: &str =
|
||||
"ToRialtoParachainOutboundLaneApi_estimate_message_delivery_and_dispatch_fee";
|
||||
/// Name of the `ToRialtoParachainOutboundLaneApi::message_details` runtime method.
|
||||
pub const TO_RIALTO_PARACHAIN_MESSAGE_DETAILS_METHOD: &str =
|
||||
"ToRialtoParachainOutboundLaneApi_message_details";
|
||||
|
||||
/// Name of the `FromRialtoParachainInboundLaneApi::message_details` runtime method.
|
||||
pub const FROM_RIALTO_PARACHAIN_MESSAGE_DETAILS_METHOD: &str =
|
||||
"FromRialtoParachainInboundLaneApi_message_details";
|
||||
|
||||
sp_api::decl_runtime_apis! {
|
||||
/// API for querying information about the finalized RialtoParachain headers.
|
||||
///
|
||||
/// This API is implemented by runtimes that are bridging with the RialtoParachain chain, not the
|
||||
/// RialtoParachain runtime itself.
|
||||
pub trait RialtoParachainFinalityApi {
|
||||
/// Returns number and hash of the best finalized header known to the bridge module.
|
||||
fn best_finalized() -> Option<bp_runtime::HeaderId<Hash, BlockNumber>>;
|
||||
}
|
||||
|
||||
/// Outbound message lane API for messages that are sent to RialtoParachain chain.
|
||||
///
|
||||
/// This API is implemented by runtimes that are sending messages to RialtoParachain chain, not the
|
||||
/// RialtoParachain runtime itself.
|
||||
pub trait ToRialtoParachainOutboundLaneApi<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 RialtoParachain from this chain.
|
||||
///
|
||||
/// Please keep in mind that this method returns the 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,
|
||||
rialto_parachain_to_this_conversion_rate: Option<FixedU128>,
|
||||
) -> Option<OutboundMessageFee>;
|
||||
/// Returns dispatch weight, encoded payload size and delivery+dispatch fee of all
|
||||
/// messages in given inclusive range.
|
||||
///
|
||||
/// If some (or all) messages are missing from the storage, they'll also will
|
||||
/// be missing from the resulting vector. The vector is ordered by the nonce.
|
||||
fn message_details(
|
||||
lane: LaneId,
|
||||
begin: MessageNonce,
|
||||
end: MessageNonce,
|
||||
) -> Vec<OutboundMessageDetails<OutboundMessageFee>>;
|
||||
}
|
||||
|
||||
/// Inbound message lane API for messages sent by RialtoParachain chain.
|
||||
///
|
||||
/// This API is implemented by runtimes that are receiving messages from RialtoParachain chain, not the
|
||||
/// RialtoParachain runtime itself.
|
||||
///
|
||||
/// Entries of the resulting vector are matching entries of the `messages` vector. Entries of the
|
||||
/// `messages` vector may (and need to) be read using `To<ThisChain>OutboundLaneApi::message_details`.
|
||||
pub trait FromRialtoParachainInboundLaneApi<InboundMessageFee: Parameter> {
|
||||
/// Return details of given inbound messages.
|
||||
fn message_details(
|
||||
lane: LaneId,
|
||||
messages: Vec<(MessagePayload, OutboundMessageDetails<InboundMessageFee>)>,
|
||||
) -> Vec<InboundMessageDetails>;
|
||||
}
|
||||
}
|
||||
declare_bridge_chain_runtime_apis!(rialto_parachain);
|
||||
|
||||
Reference in New Issue
Block a user