mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 09:51:02 +00:00
Fix invalid batch transaction (#1957)
* fix invalid batch transaction * RaceState is now trait * clippy
This commit is contained in:
committed by
Bastian Köcher
parent
ce89a2edca
commit
2a848fd836
@@ -91,18 +91,21 @@ impl<AccountId> TaggedAccount<AccountId> {
|
||||
}
|
||||
|
||||
/// Batch call builder.
|
||||
pub trait BatchCallBuilder<Call>: Send {
|
||||
pub trait BatchCallBuilder<Call>: Clone + Send {
|
||||
/// Create batch call from given calls vector.
|
||||
fn build_batch_call(&self, _calls: Vec<Call>) -> Call;
|
||||
}
|
||||
|
||||
/// Batch call builder constructor.
|
||||
pub trait BatchCallBuilderConstructor<Call> {
|
||||
pub trait BatchCallBuilderConstructor<Call>: Clone {
|
||||
/// Call builder, used by this constructor.
|
||||
type CallBuilder: BatchCallBuilder<Call>;
|
||||
/// Create a new instance of a batch call builder.
|
||||
fn new_builder() -> Option<Box<dyn BatchCallBuilder<Call>>>;
|
||||
fn new_builder() -> Option<Self::CallBuilder>;
|
||||
}
|
||||
|
||||
/// Batch call builder based on `pallet-utility`.
|
||||
#[derive(Clone)]
|
||||
pub struct UtilityPalletBatchCallBuilder<C: Chain>(PhantomData<C>);
|
||||
|
||||
impl<C: Chain> BatchCallBuilder<C::Call> for UtilityPalletBatchCallBuilder<C>
|
||||
@@ -118,14 +121,25 @@ impl<C: Chain> BatchCallBuilderConstructor<C::Call> for UtilityPalletBatchCallBu
|
||||
where
|
||||
C: ChainWithUtilityPallet,
|
||||
{
|
||||
fn new_builder() -> Option<Box<dyn BatchCallBuilder<C::Call>>> {
|
||||
Some(Box::new(Self(Default::default())))
|
||||
type CallBuilder = Self;
|
||||
|
||||
fn new_builder() -> Option<Self::CallBuilder> {
|
||||
Some(Self(Default::default()))
|
||||
}
|
||||
}
|
||||
|
||||
/// A `BatchCallBuilderConstructor` that always returns `None`.
|
||||
// A `BatchCallBuilderConstructor` that always returns `None`.
|
||||
impl<Call> BatchCallBuilderConstructor<Call> for () {
|
||||
fn new_builder() -> Option<Box<dyn BatchCallBuilder<Call>>> {
|
||||
type CallBuilder = ();
|
||||
fn new_builder() -> Option<Self::CallBuilder> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
// Dummy `BatchCallBuilder` implementation that must never be used outside
|
||||
// of the `impl BatchCallBuilderConstructor for ()` code.
|
||||
impl<Call> BatchCallBuilder<Call> for () {
|
||||
fn build_batch_call(&self, _calls: Vec<Call>) -> Call {
|
||||
unreachable!("never called, because ()::new_builder() returns None; qed")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,8 +111,9 @@ pub struct MessagesRelayParams<P: SubstrateMessageLane> {
|
||||
|
||||
/// Batch transaction that brings headers + and messages delivery/receiving confirmations to the
|
||||
/// source node.
|
||||
#[derive(Clone)]
|
||||
pub struct BatchProofTransaction<SC: Chain, TC: Chain, B: BatchCallBuilderConstructor<CallOf<SC>>> {
|
||||
builder: Box<dyn BatchCallBuilder<CallOf<SC>>>,
|
||||
builder: B::CallBuilder,
|
||||
proved_header: HeaderIdOf<TC>,
|
||||
prove_calls: Vec<CallOf<SC>>,
|
||||
|
||||
@@ -120,6 +121,16 @@ pub struct BatchProofTransaction<SC: Chain, TC: Chain, B: BatchCallBuilderConstr
|
||||
_phantom: PhantomData<fn() -> B>,
|
||||
}
|
||||
|
||||
impl<SC: Chain, TC: Chain, B: BatchCallBuilderConstructor<CallOf<SC>>> std::fmt::Debug
|
||||
for BatchProofTransaction<SC, TC, B>
|
||||
{
|
||||
fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
fmt.debug_struct("BatchProofTransaction")
|
||||
.field("proved_header", &self.proved_header)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl<SC: Chain, TC: Chain, B: BatchCallBuilderConstructor<CallOf<SC>>>
|
||||
BatchProofTransaction<SC, TC, B>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user