Skip to content
Snippets Groups Projects

Draft: tx comments

Open Hugo Trentesaux requested to merge hugo/tx-comments into master
8 files
+ 676
37
Compare changes
  • Side-by-side
  • Inline
Files
8
+ 33
5
@@ -12,12 +12,21 @@ pub enum Subcommand {
@@ -12,12 +12,21 @@ pub enum Subcommand {
amount: u64,
amount: u64,
/// Destination address
/// Destination address
dest: AccountId,
dest: AccountId,
/// Prevent from going below account existential deposit
/// Allow going below account existential deposit
#[clap(short = 'k', long = "keep-alive")]
#[clap(short = 'k', long = "allow-death")]
keep_alive: bool,
allow_death: bool,
/// Use universal dividends instead of units
/// Use universal dividends instead of units
#[clap(short = 'u', long = "ud")]
#[clap(short = 'u', long = "ud")]
is_ud: bool,
is_ud: bool,
 
/// Add a transaction comment
 
#[clap(short = 'c', long = "comment")]
 
comment: Option<String>,
 
/// Make transaction comment offchain instead of onchain (requires IPFS)
 
#[clap(short = 'x', long = "offchain")]
 
offchain: bool,
 
/// Make transaction comment offchain instead of onchain and submit index request to datapod (requires IPFS)
 
#[clap(short = 'd', long = "datapod")]
 
datapod: bool,
},
},
/// Transfer the same amount for each space-separated address.
/// Transfer the same amount for each space-separated address.
/// If an address appears mutiple times, it will get multiple times the same amount
/// If an address appears mutiple times, it will get multiple times the same amount
@@ -39,10 +48,29 @@ pub async fn handle_command(data: Data, command: Subcommand) -> Result<(), GcliE
@@ -39,10 +48,29 @@ pub async fn handle_command(data: Data, command: Subcommand) -> Result<(), GcliE
Subcommand::Transfer {
Subcommand::Transfer {
amount,
amount,
dest,
dest,
keep_alive,
allow_death,
is_ud,
is_ud,
 
comment,
 
offchain,
 
datapod,
} => {
} => {
commands::transfer::transfer(&data, amount, dest, keep_alive, is_ud).await?;
if let Some(comment) = comment {
 
if is_ud || allow_death {
 
return Err(GcliError::Input(
 
"ud or allow death commented transfers are not handled yet".to_string(),
 
));
 
}
 
if datapod {
 
commands::commented::transfer_offchain_datapod(&data, amount, dest, comment)
 
.await?;
 
} else if offchain {
 
commands::commented::transfer_offchain(&data, amount, dest, comment).await?;
 
} else {
 
commands::commented::transfer_onchain(&data, amount, dest, comment).await?;
 
}
 
} else {
 
commands::transfer::transfer(&data, amount, dest, allow_death, is_ud).await?;
 
}
}
}
Subcommand::TransferMultiple { amount, dests } => {
Subcommand::TransferMultiple { amount, dests } => {
commands::transfer::transfer_multiple(&data, amount, dests).await?;
commands::transfer::transfer_multiple(&data, amount, dests).await?;
Loading