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:
Svyatoslav Nikolsky
2021-01-04 23:54:51 +03:00
committed by Bastian Köcher
parent 0624fd0d94
commit 9fbb922766
9 changed files with 144 additions and 35 deletions
+14 -1
View File
@@ -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,