mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-09 01:18:00 +00:00
Add Bridge calls encoding to relay CLI (#780)
* Bridge calls. * Allow encoding messages for both Rialto and Millua. * Add docs. * Display full extrinsics in debug. * cargo fmt --all * Use info instead of debug,. * Clarify units.
This commit is contained in:
committed by
Bastian Köcher
parent
077e2cc11b
commit
da41afd105
@@ -176,7 +176,7 @@ pub enum SendMessage {
|
||||
/// Dispatch weight of the message. If not passed, determined automatically.
|
||||
#[structopt(long)]
|
||||
dispatch_weight: Option<ExplicitOrMaximal<Weight>>,
|
||||
/// Delivery and dispatch fee. If not passed, determined automatically.
|
||||
/// Delivery and dispatch fee in source chain base currency units. If not passed, determined automatically.
|
||||
#[structopt(long)]
|
||||
fee: Option<bp_millau::Balance>,
|
||||
/// Message type.
|
||||
@@ -201,7 +201,7 @@ pub enum SendMessage {
|
||||
/// Dispatch weight of the message. If not passed, determined automatically.
|
||||
#[structopt(long)]
|
||||
dispatch_weight: Option<ExplicitOrMaximal<Weight>>,
|
||||
/// Delivery and dispatch fee. If not passed, determined automatically.
|
||||
/// Delivery and dispatch fee in source chain base currency units. If not passed, determined automatically.
|
||||
#[structopt(long)]
|
||||
fee: Option<bp_rialto::Balance>,
|
||||
/// Message type.
|
||||
@@ -291,7 +291,6 @@ pub enum MillauToRialtoMessagePayload {
|
||||
/// Raw, SCALE-encoded `MessagePayload`.
|
||||
Raw {
|
||||
/// Hex-encoded SCALE data.
|
||||
#[structopt(long)]
|
||||
data: Bytes,
|
||||
},
|
||||
/// Construct message to send over the bridge.
|
||||
@@ -311,7 +310,6 @@ pub enum RialtoToMillauMessagePayload {
|
||||
/// Raw, SCALE-encoded `MessagePayload`.
|
||||
Raw {
|
||||
/// Hex-encoded SCALE data.
|
||||
#[structopt(long)]
|
||||
data: Bytes,
|
||||
},
|
||||
/// Construct message to send over the bridge.
|
||||
@@ -319,7 +317,6 @@ pub enum RialtoToMillauMessagePayload {
|
||||
/// Message details.
|
||||
#[structopt(flatten)]
|
||||
message: ToMillauMessage,
|
||||
|
||||
/// SS58 encoded account that will send the payload (must have SS58Prefix = 42)
|
||||
#[structopt(long)]
|
||||
sender: AccountId,
|
||||
@@ -345,10 +342,22 @@ pub enum ToRialtoMessage {
|
||||
/// SS58 encoded account that will receive the transfer (must have SS58Prefix = 42)
|
||||
#[structopt(long)]
|
||||
recipient: AccountId,
|
||||
/// Amount of target tokens to send.
|
||||
/// Amount of target tokens to send in target chain base currency units.
|
||||
#[structopt(long)]
|
||||
amount: bp_rialto::Balance,
|
||||
},
|
||||
/// A call to the Millau Bridge Message Lane pallet to send a message over the bridge.
|
||||
MillauSendMessage {
|
||||
/// Hex-encoded lane id that should be served by the relay. Defaults to `00000000`.
|
||||
#[structopt(long, default_value = "00000000")]
|
||||
lane: HexLaneId,
|
||||
/// Raw SCALE-encoded Message Payload to submit to the message lane pallet.
|
||||
#[structopt(long)]
|
||||
payload: Bytes,
|
||||
/// Declared delivery and dispatch fee in base source-chain currency units.
|
||||
#[structopt(long)]
|
||||
fee: bp_rialto::Balance,
|
||||
},
|
||||
}
|
||||
|
||||
/// All possible messages that may be delivered to the Millau chain.
|
||||
@@ -370,10 +379,22 @@ pub enum ToMillauMessage {
|
||||
/// SS58 encoded account that will receive the transfer (must have SS58Prefix = 42)
|
||||
#[structopt(long)]
|
||||
recipient: AccountId,
|
||||
/// Amount of target tokens to send.
|
||||
/// Amount of target tokens to send in target chain base currency units.
|
||||
#[structopt(long)]
|
||||
amount: bp_millau::Balance,
|
||||
},
|
||||
/// A call to the Rialto Bridge Message Lane pallet to send a message over the bridge.
|
||||
RialtoSendMessage {
|
||||
/// Hex-encoded lane id that should be served by the relay. Defaults to `00000000`.
|
||||
#[structopt(long, default_value = "00000000")]
|
||||
lane: HexLaneId,
|
||||
/// Raw SCALE-encoded Message Payload to submit to the message lane pallet.
|
||||
#[structopt(long)]
|
||||
payload: Bytes,
|
||||
/// Declared delivery and dispatch fee in base source-chain currency units.
|
||||
#[structopt(long)]
|
||||
fee: bp_millau::Balance,
|
||||
},
|
||||
}
|
||||
|
||||
arg_enum! {
|
||||
|
||||
@@ -283,6 +283,7 @@ async fn run_send_message(command: cli::SendMessage) -> Result<(), String> {
|
||||
dispatch_weight,
|
||||
fee,
|
||||
);
|
||||
log::info!(target: "bridge", "Signed Millau Call: {:?}", HexBytes::encode(&signed_millau_call));
|
||||
|
||||
millau_client.submit_extrinsic(Bytes(signed_millau_call)).await?;
|
||||
}
|
||||
@@ -338,6 +339,7 @@ async fn run_send_message(command: cli::SendMessage) -> Result<(), String> {
|
||||
dispatch_weight,
|
||||
fee,
|
||||
);
|
||||
log::info!(target: "bridge", "Signed Rialto Call: {:?}", HexBytes::encode(&signed_rialto_call));
|
||||
|
||||
rialto_client.submit_extrinsic(Bytes(signed_rialto_call)).await?;
|
||||
}
|
||||
@@ -728,6 +730,13 @@ impl crate::cli::ToRialtoMessage {
|
||||
let recipient = recipient.into_rialto();
|
||||
rialto_runtime::Call::Balances(rialto_runtime::BalancesCall::transfer(recipient, amount))
|
||||
}
|
||||
cli::ToRialtoMessage::MillauSendMessage { lane, payload, fee } => {
|
||||
let payload = cli::RialtoToMillauMessagePayload::Raw { data: payload }.into_payload()?;
|
||||
let lane = lane.into();
|
||||
rialto_runtime::Call::BridgeMillauMessageLane(rialto_runtime::MessageLaneCall::send_message(
|
||||
lane, payload, fee,
|
||||
))
|
||||
}
|
||||
};
|
||||
|
||||
log::info!(target: "bridge", "Generated Rialto call: {:#?}", call);
|
||||
@@ -758,6 +767,13 @@ impl crate::cli::ToMillauMessage {
|
||||
let recipient = recipient.into_millau();
|
||||
millau_runtime::Call::Balances(millau_runtime::BalancesCall::transfer(recipient, amount))
|
||||
}
|
||||
cli::ToMillauMessage::RialtoSendMessage { lane, payload, fee } => {
|
||||
let payload = cli::MillauToRialtoMessagePayload::Raw { data: payload }.into_payload()?;
|
||||
let lane = lane.into();
|
||||
millau_runtime::Call::BridgeRialtoMessageLane(millau_runtime::MessageLaneCall::send_message(
|
||||
lane, payload, fee,
|
||||
))
|
||||
}
|
||||
};
|
||||
|
||||
log::info!(target: "bridge", "Generated Millau call: {:#?}", call);
|
||||
|
||||
Reference in New Issue
Block a user