mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 10:31:03 +00:00
Allow parachains to send messages (#274)
* Slots module * Integrate slots * More drafting * Minor updates * Update parachains to use trati * More build fixes * Full code now compiles * Add renew bid function * Implement calculate_winner * Warning remove * Update gitignore * Test framework * Tests * Further testing * More tests, new parameterisation. * Fix and new test * Thread-safe tests * Test off-boarding and a fix. * Test onboarding * Allow late onboarding. * Another test and fix * Avoid println in nostd * Compact representation of paraids * Introduce documentation. * Introduce events. * Additional test and fix * Additional test * Tidy up line lengths. * Remove printlns * Use later substrate utils. * Allow parachains to send messages. * Fix build/test * Make slots work with latest substrate * Update runtime/src/slot_range.rs Co-Authored-By: Robert Habermeier <rphmeier@gmail.com> * Update runtime/src/slots.rs Co-Authored-By: Shawn Tabrizi <shawntabrizi@gmail.com> * Update runtime/src/slots.rs Co-Authored-By: Shawn Tabrizi <shawntabrizi@gmail.com> * Polish logic * Rewind to earlier substrate master * Remove dead code. * Fix build * Update substrate ref to master * Update to new inherent digests API * address grumbles * fix * Fix a warning. * Reworded a comment. * Check that receipt matches expectations * Add test for final checks * Split out queuing logic. * Test final piece of queuing logic * Fix up docs. * More docs fixes
This commit is contained in:
@@ -197,3 +197,37 @@ pub struct MessageRef<'a> {
|
||||
/// Underlying data of the message.
|
||||
pub data: &'a [u8],
|
||||
}
|
||||
|
||||
/// Which origin a parachain's message to the relay chain should be dispatched from.
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Decode)]
|
||||
#[cfg_attr(feature = "std", derive(Debug))]
|
||||
#[repr(u8)]
|
||||
pub enum ParachainDispatchOrigin {
|
||||
/// As a simple `Origin::Signed`, using `ParaId::account_id` as its value. This is good when
|
||||
/// interacting with standard modules such as `balances`.
|
||||
Signed,
|
||||
/// As the special `Origin::Parachain(ParaId)`. This is good when interacting with parachain-
|
||||
/// aware modules which need to succinctly verify that the origin is a parachain.
|
||||
Parachain,
|
||||
}
|
||||
|
||||
impl core::convert::TryFrom<u8> for ParachainDispatchOrigin {
|
||||
type Error = ();
|
||||
fn try_from(x: u8) -> core::result::Result<ParachainDispatchOrigin, ()> {
|
||||
const SIGNED: u8 = ParachainDispatchOrigin::Signed as u8;
|
||||
const PARACHAIN: u8 = ParachainDispatchOrigin::Parachain as u8;
|
||||
Ok(match x {
|
||||
SIGNED => ParachainDispatchOrigin::Signed,
|
||||
PARACHAIN => ParachainDispatchOrigin::Parachain,
|
||||
_ => return Err(()),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// A reference to an upward message.
|
||||
pub struct UpwardMessageRef<'a> {
|
||||
/// The origin type.
|
||||
pub origin: ParachainDispatchOrigin,
|
||||
/// Underlying data of the message.
|
||||
pub data: &'a [u8],
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user