use clap::Args; use pallas_addresses::Address; use tokio::runtime::Runtime; use crate::{ cardano::cardano::Cardano, env::get_env, tx::{ context::TxContext, from_env, send::{self, send}, }, }; #[derive(Debug, Args)] pub struct Params { /// `:` It can be used multiple times #[arg(long)] to: Vec, } pub fn handle(params: Params) { let outputs = params .to .iter() .map(|x| parse_to(x)) .collect::>(); let env = get_env(); let tx_ctx = from_env(&env); let rt = Runtime::new().expect("Failed to create Tokio runtime"); let tx = rt.block_on(async { send(tx_ctx, vec![]).await }); println!("{:?}", tx); } pub fn parse_to(to: &str) -> (Address, u64) { let (a, b) = to.split_once(":").expect("Expect `:`"); let addr = Address::from_bech32(a).expect("Cannot parse address"); let amount = b.parse::().expect("Cannot parse amount"); (addr, amount) }