Skip to content
Snippets Groups Projects
Commit af5b6e16 authored by guenoel's avatar guenoel Committed by Hugo Trentesaux
Browse files

transfer ud

parent 40c8d5f2
No related branches found
No related tags found
No related merge requests found
......@@ -15,6 +15,10 @@ pub enum Subcommand {
/// Prevent from going below account existential deposit
#[clap(short = 'k', long = "keep-alive")]
keep_alive: bool,
/// Use universal dividends instead of units
#[clap(short = 'u', long = "ud")]
is_ud: bool,
},
/// Transfer the same amount for each space-separated address.
/// If an address appears mutiple times, it will get multiple times the same amount
......@@ -38,8 +42,9 @@ pub async fn handle_command(data: Data, command: Subcommand) -> anyhow::Result<(
amount,
dest,
keep_alive,
is_ud
} => {
commands::transfer::transfer(&data, amount, dest, keep_alive).await?;
commands::transfer::transfer(&data, amount, dest, keep_alive, is_ud).await?;
}
Subcommand::TransferMultiple { amount, dests } => {
commands::transfer::transfer_multiple(&data, amount, dests).await?;
......
......@@ -10,27 +10,40 @@ pub async fn transfer(
balance: u64,
dest: AccountId,
keep_alive: bool,
is_ud: bool,
) -> Result<(), subxt::Error> {
let progress = if keep_alive {
data.client()
if is_ud {data.client()
.tx()
.sign_and_submit_then_watch(
&runtime::tx().universal_dividend().transfer_ud(dest.into(), balance),
&PairSigner::new(data.keypair()),
BaseExtrinsicParamsBuilder::new(),
)
.await?} else {data.client()
.tx()
.sign_and_submit_then_watch(
&runtime::tx().balances().transfer(dest.into(), balance),
&PairSigner::new(data.keypair()),
BaseExtrinsicParamsBuilder::new(),
)
.await?
.await?}
} else {
data.client()
if is_ud {data.client()
.tx()
.sign_and_submit_then_watch(
&runtime::tx().universal_dividend().transfer_ud_keep_alive(dest.into(), balance),
&PairSigner::new(data.keypair()),
BaseExtrinsicParamsBuilder::new(),
)
.await?} else {data.client()
.tx()
.sign_and_submit_then_watch(
&runtime::tx()
.balances()
.transfer_keep_alive(dest.into(), balance),
&runtime::tx().balances().transfer_keep_alive(dest.into(), balance),
&PairSigner::new(data.keypair()),
BaseExtrinsicParamsBuilder::new(),
)
.await?
.await?}
};
if data.args.no_wait {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment