From 87a0b05d1adc8ed59dbaf41b7a8e5c64327c5a6f Mon Sep 17 00:00:00 2001 From: Drazen Urch Date: Fri, 3 Sep 2021 07:43:29 +0200 Subject: [PATCH] Send --- tauri-wallet/src-tauri/src/main.rs | 26 ++++++++++++++++++- .../src/routes/internal-docs/ApiList.tsx | 12 +++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/tauri-wallet/src-tauri/src/main.rs b/tauri-wallet/src-tauri/src/main.rs index 558ec2bd19..3f1ec6ac94 100644 --- a/tauri-wallet/src-tauri/src/main.rs +++ b/tauri-wallet/src-tauri/src/main.rs @@ -430,6 +430,29 @@ async fn unbond_gateway(state: tauri::State<'_, Arc>>) -> Result<( } } +#[tauri::command] +async fn send(address: &str, amount: Coin, memo: String, state: tauri::State<'_, Arc>>,) -> Result<(), String> { + let address = match AccountId::from_str(address) { + Ok(addy) => addy, + Err(e) => return Err(format_err!(e)) + }; + let amount: CosmosCoin = match amount.try_into() { + Ok(b) => b, + Err(e) => return Err(format_err!(e)), + }; + let r_state = state.read().await; + if let Some(client) = &r_state.signing_client { + match client.send(&address, vec!(amount), memo).await { + Ok(_result) => Ok(()), + Err(e) => Err(format_err!(e)), + } + } else { + Err(String::from( + "Client has not been initialized yet, connect with mnemonic to initialize", + )) + } +} + fn _connect_with_mnemonic(mnemonic: Mnemonic, config: &Config) -> NymdClient { match NymdClient::connect_with_mnemonic( config.get_nymd_validator_url().unwrap(), @@ -458,7 +481,8 @@ fn main() { delegate_to_mixnode, undelegate_from_mixnode, delegate_to_gateway, - undelegate_from_gateway + undelegate_from_gateway, + send ]) .run(tauri::generate_context!()) .expect("error while running tauri application"); diff --git a/tauri-wallet/src/routes/internal-docs/ApiList.tsx b/tauri-wallet/src/routes/internal-docs/ApiList.tsx index 389711c6d0..9075bcf267 100644 --- a/tauri-wallet/src/routes/internal-docs/ApiList.tsx +++ b/tauri-wallet/src/routes/internal-docs/ApiList.tsx @@ -139,6 +139,18 @@ export const ApiList = () => { }} /> + + + ); };