mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 12:11:02 +00:00
Add few CLI helpers (#764)
* Adding call encoding. * Add message payload encoding. * Nicer output. * Add fee estimation. * cargo fmt --all * Split message payload encoding into separate command. * Use HexBytes. * cargo fmt --all * Fix compilation.
This commit is contained in:
committed by
Bastian Köcher
parent
c9a8ac0b32
commit
3764cda726
@@ -51,8 +51,21 @@ pub enum Command {
|
||||
/// The message is being sent to the source chain, delivered to the target chain and dispatched
|
||||
/// there.
|
||||
SendMessage(SendMessage),
|
||||
/// Generate SCALE-encoded `Call` for choosen network.
|
||||
///
|
||||
/// The call can be used either as message payload or can be wrapped into a transaction
|
||||
/// and executed on the chain directly.
|
||||
EncodeCall(EncodeCall),
|
||||
/// Generate SCALE-encoded `MessagePayload` object that can be sent over selected bridge.
|
||||
///
|
||||
/// The `MessagePayload` can be then fed to `MessageLane::send_message` function and sent over
|
||||
/// the bridge.
|
||||
EncodeMessagePayload(EncodeMessagePayload),
|
||||
/// Estimate Delivery and Dispatch Fee required for message submission to message lane.
|
||||
EstimateFee(EstimateFee),
|
||||
}
|
||||
|
||||
/// Start headers relayer process.
|
||||
#[derive(StructOpt)]
|
||||
pub enum RelayHeaders {
|
||||
/// Relay Millau headers to Rialto.
|
||||
@@ -79,6 +92,7 @@ pub enum RelayHeaders {
|
||||
},
|
||||
}
|
||||
|
||||
/// Start message relayer process.
|
||||
#[derive(StructOpt)]
|
||||
pub enum RelayMessages {
|
||||
/// Serve given lane of Millau -> Rialto messages.
|
||||
@@ -115,6 +129,7 @@ pub enum RelayMessages {
|
||||
},
|
||||
}
|
||||
|
||||
/// Initialize bridge pallet.
|
||||
#[derive(StructOpt)]
|
||||
pub enum InitBridge {
|
||||
/// Initialize Millau headers bridge in Rialto.
|
||||
@@ -141,6 +156,7 @@ pub enum InitBridge {
|
||||
},
|
||||
}
|
||||
|
||||
/// Send bridge message.
|
||||
#[derive(StructOpt)]
|
||||
pub enum SendMessage {
|
||||
/// Submit message to given Millau -> Rialto lane.
|
||||
@@ -195,9 +211,112 @@ pub enum SendMessage {
|
||||
},
|
||||
}
|
||||
|
||||
/// A call to encode.
|
||||
#[derive(StructOpt)]
|
||||
pub enum EncodeCall {
|
||||
/// Encode Rialto's Call.
|
||||
Rialto {
|
||||
#[structopt(flatten)]
|
||||
call: ToRialtoMessage,
|
||||
},
|
||||
/// Encode Millau's Call.
|
||||
Millau {
|
||||
#[structopt(flatten)]
|
||||
call: ToMillauMessage,
|
||||
},
|
||||
}
|
||||
|
||||
/// A `MessagePayload` to encode.
|
||||
#[derive(StructOpt)]
|
||||
pub enum EncodeMessagePayload {
|
||||
/// Message Payload of Rialto to Millau call.
|
||||
RialtoToMillau {
|
||||
#[structopt(flatten)]
|
||||
payload: RialtoToMillauMessagePayload,
|
||||
},
|
||||
/// Message Payload of Millau to Rialto call.
|
||||
MillauToRialto {
|
||||
#[structopt(flatten)]
|
||||
payload: MillauToRialtoMessagePayload,
|
||||
},
|
||||
}
|
||||
|
||||
/// Estimate Delivery & Dispatch Fee command.
|
||||
#[derive(StructOpt)]
|
||||
pub enum EstimateFee {
|
||||
/// Estimate fee of Rialto to Millau message.
|
||||
RialtoToMillau {
|
||||
#[structopt(flatten)]
|
||||
rialto: RialtoConnectionParams,
|
||||
/// Hex-encoded id of lane that will be delivering the message.
|
||||
#[structopt(long)]
|
||||
lane: HexLaneId,
|
||||
/// Payload to send over the bridge.
|
||||
#[structopt(flatten)]
|
||||
payload: RialtoToMillauMessagePayload,
|
||||
},
|
||||
/// Estimate fee of Rialto to Millau message.
|
||||
MillauToRialto {
|
||||
#[structopt(flatten)]
|
||||
millau: MillauConnectionParams,
|
||||
/// Hex-encoded id of lane that will be delivering the message.
|
||||
#[structopt(long)]
|
||||
lane: HexLaneId,
|
||||
/// Payload to send over the bridge.
|
||||
#[structopt(flatten)]
|
||||
payload: MillauToRialtoMessagePayload,
|
||||
},
|
||||
}
|
||||
|
||||
/// MessagePayload that can be delivered to message lane pallet on Millau.
|
||||
#[derive(StructOpt, Debug)]
|
||||
pub enum MillauToRialtoMessagePayload {
|
||||
/// Raw, SCALE-encoded `MessagePayload`.
|
||||
Raw {
|
||||
/// Hex-encoded SCALE data.
|
||||
#[structopt(long)]
|
||||
data: Bytes,
|
||||
},
|
||||
/// Construct message to send over the bridge.
|
||||
Message {
|
||||
/// Message details.
|
||||
#[structopt(flatten)]
|
||||
message: ToRialtoMessage,
|
||||
/// SS58 encoded account that will send the payload (must have SS58Prefix = 42)
|
||||
#[structopt(long)]
|
||||
sender: bp_rialto::AccountId,
|
||||
},
|
||||
}
|
||||
|
||||
/// MessagePayload that can be delivered to message lane pallet on Rialto.
|
||||
#[derive(StructOpt, Debug)]
|
||||
pub enum RialtoToMillauMessagePayload {
|
||||
/// Raw, SCALE-encoded `MessagePayload`.
|
||||
Raw {
|
||||
/// Hex-encoded SCALE data.
|
||||
#[structopt(long)]
|
||||
data: Bytes,
|
||||
},
|
||||
/// Construct message to send over the bridge.
|
||||
Message {
|
||||
/// Message details.
|
||||
#[structopt(flatten)]
|
||||
message: ToMillauMessage,
|
||||
|
||||
/// SS58 encoded account that will send the payload (must have SS58Prefix = 42)
|
||||
#[structopt(long)]
|
||||
sender: bp_rialto::AccountId,
|
||||
},
|
||||
}
|
||||
|
||||
/// All possible messages that may be delivered to the Rialto chain.
|
||||
#[derive(StructOpt, Debug)]
|
||||
pub enum ToRialtoMessage {
|
||||
/// Raw bytes for the message
|
||||
Raw {
|
||||
/// Raw, SCALE-encoded message
|
||||
data: Bytes,
|
||||
},
|
||||
/// Make an on-chain remark (comment).
|
||||
Remark {
|
||||
/// Remark size. If not passed, small UTF8-encoded string is generated by relay as remark.
|
||||
@@ -206,8 +325,10 @@ pub enum ToRialtoMessage {
|
||||
},
|
||||
/// Transfer the specified `amount` of native tokens to a particular `recipient`.
|
||||
Transfer {
|
||||
/// SS58 encoded account that will receive the transfer (must have SS58Prefix = 42)
|
||||
#[structopt(long)]
|
||||
recipient: bp_rialto::AccountId,
|
||||
/// Amount of target tokens to send.
|
||||
#[structopt(long)]
|
||||
amount: bp_rialto::Balance,
|
||||
},
|
||||
@@ -216,6 +337,11 @@ pub enum ToRialtoMessage {
|
||||
/// All possible messages that may be delivered to the Millau chain.
|
||||
#[derive(StructOpt, Debug)]
|
||||
pub enum ToMillauMessage {
|
||||
/// Raw bytes for the message
|
||||
Raw {
|
||||
/// Raw, SCALE-encoded message
|
||||
data: Bytes,
|
||||
},
|
||||
/// Make an on-chain remark (comment).
|
||||
Remark {
|
||||
/// Size of the remark. If not passed, small UTF8-encoded string is generated by relay as remark.
|
||||
@@ -224,8 +350,10 @@ pub enum ToMillauMessage {
|
||||
},
|
||||
/// Transfer the specified `amount` of native tokens to a particular `recipient`.
|
||||
Transfer {
|
||||
/// SS58 encoded account that will receive the transfer (must have SS58Prefix = 42)
|
||||
#[structopt(long)]
|
||||
recipient: bp_millau::AccountId,
|
||||
/// Amount of target tokens to send.
|
||||
#[structopt(long)]
|
||||
amount: bp_millau::Balance,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user