29091aab8e
* Renaming all instances of nymd to nyxd * Might as well get the changelogs too * Making it clearer that an ApiClient is a NymApiClient * Lining up config templates with struct keys on gateway * Changed the last references to validator_urls to nyxd_urls * Fixed up a few type errors after refactoring * Changed the changelog * Fixed typo in changelog * Further instances of renaming 'nymd' + introducing additional clap aliases * updated environmental variables and allowed usage of deprecated variants * missing occurences of coconut-locked environmental variables Co-authored-by: Jędrzej Stuczyński <jedrzej.stuczynski@gmail.com>
67 lines
1.6 KiB
Rust
67 lines
1.6 KiB
Rust
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
use clap::Parser;
|
|
use log::info;
|
|
use serde_json::json;
|
|
|
|
use validator_client::nyxd::{AccountId, Coin};
|
|
|
|
use crate::context::SigningClient;
|
|
|
|
#[derive(Debug, Parser)]
|
|
pub struct Args {
|
|
#[clap(value_parser, help = "The recipient account address")]
|
|
pub recipient: AccountId,
|
|
|
|
#[clap(
|
|
value_parser,
|
|
help = "Amount to transfer in micro denomination (e.g. unym or unyx)"
|
|
)]
|
|
pub amount: u128,
|
|
|
|
#[clap(long, help = "Override the denomination")]
|
|
pub denom: Option<String>,
|
|
|
|
#[clap(long)]
|
|
pub memo: Option<String>,
|
|
}
|
|
|
|
pub async fn send(args: Args, client: &SigningClient) {
|
|
let memo = args
|
|
.memo
|
|
.unwrap_or_else(|| "Sending tokens with nym-cli".to_owned());
|
|
let denom = args
|
|
.denom
|
|
.unwrap_or_else(|| client.current_chain_details().mix_denom.base.clone());
|
|
|
|
let coin = Coin {
|
|
denom,
|
|
amount: args.amount,
|
|
};
|
|
|
|
info!(
|
|
"Sending {} {} from {} to {}...",
|
|
coin.amount,
|
|
coin.denom,
|
|
client.address(),
|
|
args.recipient
|
|
);
|
|
|
|
let res = client
|
|
.send(&args.recipient, vec![coin], memo, None)
|
|
.await
|
|
.expect("failed to send tokens!");
|
|
|
|
info!("Sending result: {}", json!(res));
|
|
|
|
println!();
|
|
println!(
|
|
"Nodesguru: https://nym.explorers.guru/transaction/{}",
|
|
&res.hash
|
|
);
|
|
println!("Mintscan: https://www.mintscan.io/nyx/txs/{}", &res.hash);
|
|
println!("Transaction result code: {}", &res.tx_result.code.value());
|
|
println!("Transaction hash: {}", &res.hash);
|
|
}
|