mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 06:21:11 +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
@@ -36,6 +36,9 @@ pub mod kovan;
|
||||
pub mod millau_messages;
|
||||
pub mod rialto_poa;
|
||||
|
||||
use crate::millau_messages::{ToMillauMessagePayload, WithMillauMessageBridge};
|
||||
|
||||
use bridge_runtime_common::messages::{source::estimate_message_dispatch_and_delivery_fee, MessageBridge};
|
||||
use codec::Decode;
|
||||
use pallet_grandpa::{fg_primitives, AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList};
|
||||
use sp_api::impl_runtime_apis;
|
||||
@@ -695,7 +698,17 @@ impl_runtime_apis! {
|
||||
}
|
||||
}
|
||||
|
||||
impl bp_millau::ToMillauOutboundLaneApi<Block> for Runtime {
|
||||
impl bp_millau::ToMillauOutboundLaneApi<Block, Balance, ToMillauMessagePayload> for Runtime {
|
||||
fn estimate_message_delivery_and_dispatch_fee(
|
||||
_lane_id: bp_message_lane::LaneId,
|
||||
payload: ToMillauMessagePayload,
|
||||
) -> Option<Balance> {
|
||||
estimate_message_dispatch_and_delivery_fee::<WithMillauMessageBridge>(
|
||||
&payload,
|
||||
WithMillauMessageBridge::RELAYER_FEE_PERCENT,
|
||||
).ok()
|
||||
}
|
||||
|
||||
fn messages_dispatch_weight(
|
||||
lane: bp_message_lane::LaneId,
|
||||
begin: bp_message_lane::MessageNonce,
|
||||
|
||||
@@ -125,9 +125,9 @@ impl MessageBridge for WithMillauMessageBridge {
|
||||
<crate::Runtime as pallet_transaction_payment::Config>::WeightToFee::calc(&weight) as _
|
||||
}
|
||||
|
||||
fn this_balance_to_bridged_balance(this_balance: bp_rialto::Balance) -> bp_millau::Balance {
|
||||
fn bridged_balance_to_this_balance(bridged_balance: bp_millau::Balance) -> bp_rialto::Balance {
|
||||
// 1:1 conversion that will probably change in the future
|
||||
this_balance as _
|
||||
bridged_balance as _
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user