mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 22:11:02 +00:00
Rename MessageId -> BridgeMessageId (#1152)
This commit is contained in:
committed by
Bastian Köcher
parent
084da4343d
commit
eaf519dc1b
@@ -211,7 +211,7 @@ impl pallet_aura::Config for Runtime {
|
|||||||
}
|
}
|
||||||
impl pallet_bridge_dispatch::Config for Runtime {
|
impl pallet_bridge_dispatch::Config for Runtime {
|
||||||
type Event = Event;
|
type Event = Event;
|
||||||
type MessageId = (bp_messages::LaneId, bp_messages::MessageNonce);
|
type BridgeMessageId = (bp_messages::LaneId, bp_messages::MessageNonce);
|
||||||
type Call = Call;
|
type Call = Call;
|
||||||
type CallFilter = ();
|
type CallFilter = ();
|
||||||
type EncodedCall = crate::rialto_messages::FromRialtoEncodedCall;
|
type EncodedCall = crate::rialto_messages::FromRialtoEncodedCall;
|
||||||
|
|||||||
@@ -291,7 +291,7 @@ impl pallet_bridge_currency_exchange::Config<KovanCurrencyExchange> for Runtime
|
|||||||
|
|
||||||
impl pallet_bridge_dispatch::Config for Runtime {
|
impl pallet_bridge_dispatch::Config for Runtime {
|
||||||
type Event = Event;
|
type Event = Event;
|
||||||
type MessageId = (bp_messages::LaneId, bp_messages::MessageNonce);
|
type BridgeMessageId = (bp_messages::LaneId, bp_messages::MessageNonce);
|
||||||
type Call = Call;
|
type Call = Call;
|
||||||
type CallFilter = ();
|
type CallFilter = ();
|
||||||
type EncodedCall = crate::millau_messages::FromMillauEncodedCall;
|
type EncodedCall = crate::millau_messages::FromMillauEncodedCall;
|
||||||
|
|||||||
@@ -495,7 +495,7 @@ pub mod target {
|
|||||||
where
|
where
|
||||||
BalanceOf<ThisChain<B>>: Saturating + FixedPointOperand,
|
BalanceOf<ThisChain<B>>: Saturating + FixedPointOperand,
|
||||||
ThisDispatchInstance: 'static,
|
ThisDispatchInstance: 'static,
|
||||||
ThisRuntime: pallet_bridge_dispatch::Config<ThisDispatchInstance, MessageId = (LaneId, MessageNonce)>
|
ThisRuntime: pallet_bridge_dispatch::Config<ThisDispatchInstance, BridgeMessageId = (LaneId, MessageNonce)>
|
||||||
+ pallet_transaction_payment::Config,
|
+ pallet_transaction_payment::Config,
|
||||||
<ThisRuntime as pallet_transaction_payment::Config>::OnChargeTransaction:
|
<ThisRuntime as pallet_transaction_payment::Config>::OnChargeTransaction:
|
||||||
pallet_transaction_payment::OnChargeTransaction<ThisRuntime, Balance = BalanceOf<ThisChain<B>>>,
|
pallet_transaction_payment::OnChargeTransaction<ThisRuntime, Balance = BalanceOf<ThisChain<B>>>,
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ pub mod pallet {
|
|||||||
/// Id of the message. Whenever message is passed to the dispatch module, it emits
|
/// Id of the message. Whenever message is passed to the dispatch module, it emits
|
||||||
/// event with this id + dispatch result. Could be e.g. (LaneId, MessageNonce) if
|
/// event with this id + dispatch result. Could be e.g. (LaneId, MessageNonce) if
|
||||||
/// it comes from the messages module.
|
/// it comes from the messages module.
|
||||||
type MessageId: Parameter;
|
type BridgeMessageId: Parameter;
|
||||||
/// Type of account ID on source chain.
|
/// Type of account ID on source chain.
|
||||||
type SourceChainAccountId: Parameter + Member + MaybeSerializeDeserialize + Debug + MaybeDisplay + Ord + Default;
|
type SourceChainAccountId: Parameter + Member + MaybeSerializeDeserialize + Debug + MaybeDisplay + Ord + Default;
|
||||||
/// Type of account public key on target chain.
|
/// Type of account public key on target chain.
|
||||||
@@ -91,7 +91,7 @@ pub mod pallet {
|
|||||||
type AccountIdConverter: sp_runtime::traits::Convert<sp_core::hash::H256, Self::AccountId>;
|
type AccountIdConverter: sp_runtime::traits::Convert<sp_core::hash::H256, Self::AccountId>;
|
||||||
}
|
}
|
||||||
|
|
||||||
type MessageIdOf<T, I> = <T as Config<I>>::MessageId;
|
type BridgeMessageIdOf<T, I> = <T as Config<I>>::BridgeMessageId;
|
||||||
|
|
||||||
#[pallet::pallet]
|
#[pallet::pallet]
|
||||||
#[pallet::generate_store(pub(super) trait Store)]
|
#[pallet::generate_store(pub(super) trait Store)]
|
||||||
@@ -105,37 +105,37 @@ pub mod pallet {
|
|||||||
|
|
||||||
#[pallet::event]
|
#[pallet::event]
|
||||||
#[pallet::generate_deposit(pub(super) fn deposit_event)]
|
#[pallet::generate_deposit(pub(super) fn deposit_event)]
|
||||||
#[pallet::metadata(<T as frame_system::Config>::AccountId = "AccountId", MessageIdOf<T, I> = "MessageId")]
|
#[pallet::metadata(<T as frame_system::Config>::AccountId = "AccountId", BridgeMessageIdOf<T, I> = "BridgeMessageId")]
|
||||||
pub enum Event<T: Config<I>, I: 'static = ()> {
|
pub enum Event<T: Config<I>, I: 'static = ()> {
|
||||||
/// Message has been rejected before reaching dispatch.
|
/// Message has been rejected before reaching dispatch.
|
||||||
MessageRejected(ChainId, MessageIdOf<T, I>),
|
MessageRejected(ChainId, BridgeMessageIdOf<T, I>),
|
||||||
/// Message has been rejected by dispatcher because of spec version mismatch.
|
/// Message has been rejected by dispatcher because of spec version mismatch.
|
||||||
/// Last two arguments are: expected and passed spec version.
|
/// Last two arguments are: expected and passed spec version.
|
||||||
MessageVersionSpecMismatch(ChainId, MessageIdOf<T, I>, SpecVersion, SpecVersion),
|
MessageVersionSpecMismatch(ChainId, BridgeMessageIdOf<T, I>, SpecVersion, SpecVersion),
|
||||||
/// Message has been rejected by dispatcher because of weight mismatch.
|
/// Message has been rejected by dispatcher because of weight mismatch.
|
||||||
/// Last two arguments are: expected and passed call weight.
|
/// Last two arguments are: expected and passed call weight.
|
||||||
MessageWeightMismatch(ChainId, MessageIdOf<T, I>, Weight, Weight),
|
MessageWeightMismatch(ChainId, BridgeMessageIdOf<T, I>, Weight, Weight),
|
||||||
/// Message signature mismatch.
|
/// Message signature mismatch.
|
||||||
MessageSignatureMismatch(ChainId, MessageIdOf<T, I>),
|
MessageSignatureMismatch(ChainId, BridgeMessageIdOf<T, I>),
|
||||||
/// We have failed to decode Call from the message.
|
/// We have failed to decode Call from the message.
|
||||||
MessageCallDecodeFailed(ChainId, MessageIdOf<T, I>),
|
MessageCallDecodeFailed(ChainId, BridgeMessageIdOf<T, I>),
|
||||||
/// The call from the message has been rejected by the call filter.
|
/// The call from the message has been rejected by the call filter.
|
||||||
MessageCallRejected(ChainId, MessageIdOf<T, I>),
|
MessageCallRejected(ChainId, BridgeMessageIdOf<T, I>),
|
||||||
/// The origin account has failed to pay fee for dispatching the message.
|
/// The origin account has failed to pay fee for dispatching the message.
|
||||||
MessageDispatchPaymentFailed(
|
MessageDispatchPaymentFailed(
|
||||||
ChainId,
|
ChainId,
|
||||||
MessageIdOf<T, I>,
|
BridgeMessageIdOf<T, I>,
|
||||||
<T as frame_system::Config>::AccountId,
|
<T as frame_system::Config>::AccountId,
|
||||||
Weight,
|
Weight,
|
||||||
),
|
),
|
||||||
/// Message has been dispatched with given result.
|
/// Message has been dispatched with given result.
|
||||||
MessageDispatched(ChainId, MessageIdOf<T, I>, DispatchResult),
|
MessageDispatched(ChainId, BridgeMessageIdOf<T, I>, DispatchResult),
|
||||||
/// Phantom member, never used. Needed to handle multiple pallet instances.
|
/// Phantom member, never used. Needed to handle multiple pallet instances.
|
||||||
_Dummy(PhantomData<I>),
|
_Dummy(PhantomData<I>),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Config<I>, I: 'static> MessageDispatch<T::AccountId, T::MessageId> for Pallet<T, I> {
|
impl<T: Config<I>, I: 'static> MessageDispatch<T::AccountId, T::BridgeMessageId> for Pallet<T, I> {
|
||||||
type Message =
|
type Message =
|
||||||
MessagePayload<T::SourceChainAccountId, T::TargetChainAccountPublic, T::TargetChainSignature, T::EncodedCall>;
|
MessagePayload<T::SourceChainAccountId, T::TargetChainAccountPublic, T::TargetChainSignature, T::EncodedCall>;
|
||||||
|
|
||||||
@@ -146,7 +146,7 @@ impl<T: Config<I>, I: 'static> MessageDispatch<T::AccountId, T::MessageId> for P
|
|||||||
fn dispatch<P: FnOnce(&T::AccountId, bp_message_dispatch::Weight) -> Result<(), ()>>(
|
fn dispatch<P: FnOnce(&T::AccountId, bp_message_dispatch::Weight) -> Result<(), ()>>(
|
||||||
source_chain: ChainId,
|
source_chain: ChainId,
|
||||||
target_chain: ChainId,
|
target_chain: ChainId,
|
||||||
id: T::MessageId,
|
id: T::BridgeMessageId,
|
||||||
message: Result<Self::Message, ()>,
|
message: Result<Self::Message, ()>,
|
||||||
pay_dispatch_fee: P,
|
pay_dispatch_fee: P,
|
||||||
) -> MessageDispatchResult {
|
) -> MessageDispatchResult {
|
||||||
@@ -416,7 +416,7 @@ mod tests {
|
|||||||
};
|
};
|
||||||
|
|
||||||
type AccountId = u64;
|
type AccountId = u64;
|
||||||
type MessageId = [u8; 4];
|
type BridgeMessageId = [u8; 4];
|
||||||
|
|
||||||
const SOURCE_CHAIN_ID: ChainId = *b"srce";
|
const SOURCE_CHAIN_ID: ChainId = *b"srce";
|
||||||
const TARGET_CHAIN_ID: ChainId = *b"trgt";
|
const TARGET_CHAIN_ID: ChainId = *b"trgt";
|
||||||
@@ -502,7 +502,7 @@ mod tests {
|
|||||||
|
|
||||||
impl Config for TestRuntime {
|
impl Config for TestRuntime {
|
||||||
type Event = Event;
|
type Event = Event;
|
||||||
type MessageId = MessageId;
|
type BridgeMessageId = BridgeMessageId;
|
||||||
type SourceChainAccountId = AccountId;
|
type SourceChainAccountId = AccountId;
|
||||||
type TargetChainAccountPublic = TestAccountPublic;
|
type TargetChainAccountPublic = TestAccountPublic;
|
||||||
type TargetChainSignature = TestSignature;
|
type TargetChainSignature = TestSignature;
|
||||||
@@ -542,7 +542,7 @@ mod tests {
|
|||||||
fn prepare_message(
|
fn prepare_message(
|
||||||
origin: CallOrigin<AccountId, TestAccountPublic, TestSignature>,
|
origin: CallOrigin<AccountId, TestAccountPublic, TestSignature>,
|
||||||
call: Call,
|
call: Call,
|
||||||
) -> <Pallet<TestRuntime> as MessageDispatch<AccountId, <TestRuntime as Config>::MessageId>>::Message {
|
) -> <Pallet<TestRuntime> as MessageDispatch<AccountId, <TestRuntime as Config>::BridgeMessageId>>::Message {
|
||||||
MessagePayload {
|
MessagePayload {
|
||||||
spec_version: TEST_SPEC_VERSION,
|
spec_version: TEST_SPEC_VERSION,
|
||||||
weight: TEST_WEIGHT,
|
weight: TEST_WEIGHT,
|
||||||
@@ -554,20 +554,20 @@ mod tests {
|
|||||||
|
|
||||||
fn prepare_root_message(
|
fn prepare_root_message(
|
||||||
call: Call,
|
call: Call,
|
||||||
) -> <Pallet<TestRuntime> as MessageDispatch<AccountId, <TestRuntime as Config>::MessageId>>::Message {
|
) -> <Pallet<TestRuntime> as MessageDispatch<AccountId, <TestRuntime as Config>::BridgeMessageId>>::Message {
|
||||||
prepare_message(CallOrigin::SourceRoot, call)
|
prepare_message(CallOrigin::SourceRoot, call)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn prepare_target_message(
|
fn prepare_target_message(
|
||||||
call: Call,
|
call: Call,
|
||||||
) -> <Pallet<TestRuntime> as MessageDispatch<AccountId, <TestRuntime as Config>::MessageId>>::Message {
|
) -> <Pallet<TestRuntime> as MessageDispatch<AccountId, <TestRuntime as Config>::BridgeMessageId>>::Message {
|
||||||
let origin = CallOrigin::TargetAccount(1, TestAccountPublic(1), TestSignature(1));
|
let origin = CallOrigin::TargetAccount(1, TestAccountPublic(1), TestSignature(1));
|
||||||
prepare_message(origin, call)
|
prepare_message(origin, call)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn prepare_source_message(
|
fn prepare_source_message(
|
||||||
call: Call,
|
call: Call,
|
||||||
) -> <Pallet<TestRuntime> as MessageDispatch<AccountId, <TestRuntime as Config>::MessageId>>::Message {
|
) -> <Pallet<TestRuntime> as MessageDispatch<AccountId, <TestRuntime as Config>::BridgeMessageId>>::Message {
|
||||||
let origin = CallOrigin::SourceAccount(1);
|
let origin = CallOrigin::SourceAccount(1);
|
||||||
prepare_message(origin, call)
|
prepare_message(origin, call)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ pub type Weight = u64;
|
|||||||
pub type SpecVersion = u32;
|
pub type SpecVersion = u32;
|
||||||
|
|
||||||
/// A generic trait to dispatch arbitrary messages delivered over the bridge.
|
/// A generic trait to dispatch arbitrary messages delivered over the bridge.
|
||||||
pub trait MessageDispatch<AccountId, MessageId> {
|
pub trait MessageDispatch<AccountId, BridgeMessageId> {
|
||||||
/// A type of the message to be dispatched.
|
/// A type of the message to be dispatched.
|
||||||
type Message: codec::Decode;
|
type Message: codec::Decode;
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@ pub trait MessageDispatch<AccountId, MessageId> {
|
|||||||
fn dispatch<P: FnOnce(&AccountId, Weight) -> Result<(), ()>>(
|
fn dispatch<P: FnOnce(&AccountId, Weight) -> Result<(), ()>>(
|
||||||
source_chain: ChainId,
|
source_chain: ChainId,
|
||||||
target_chain: ChainId,
|
target_chain: ChainId,
|
||||||
id: MessageId,
|
id: BridgeMessageId,
|
||||||
message: Result<Self::Message, ()>,
|
message: Result<Self::Message, ()>,
|
||||||
pay_dispatch_fee: P,
|
pay_dispatch_fee: P,
|
||||||
) -> MessageDispatchResult;
|
) -> MessageDispatchResult;
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ pub type LaneId = [u8; 4];
|
|||||||
pub type MessageNonce = u64;
|
pub type MessageNonce = u64;
|
||||||
|
|
||||||
/// Message id as a tuple.
|
/// Message id as a tuple.
|
||||||
pub type MessageId = (LaneId, MessageNonce);
|
pub type BridgeMessageId = (LaneId, MessageNonce);
|
||||||
|
|
||||||
/// Opaque message payload. We only decode this payload when it is dispatched.
|
/// Opaque message payload. We only decode this payload when it is dispatched.
|
||||||
pub type MessagePayload = Vec<u8>;
|
pub type MessagePayload = Vec<u8>;
|
||||||
|
|||||||
Reference in New Issue
Block a user