Send
This commit is contained in:
@@ -430,6 +430,29 @@ async fn unbond_gateway(state: tauri::State<'_, Arc<RwLock<State>>>) -> Result<(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
async fn send(address: &str, amount: Coin, memo: String, state: tauri::State<'_, Arc<RwLock<State>>>,) -> 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<SigningNymdClient> {
|
fn _connect_with_mnemonic(mnemonic: Mnemonic, config: &Config) -> NymdClient<SigningNymdClient> {
|
||||||
match NymdClient::connect_with_mnemonic(
|
match NymdClient::connect_with_mnemonic(
|
||||||
config.get_nymd_validator_url().unwrap(),
|
config.get_nymd_validator_url().unwrap(),
|
||||||
@@ -458,7 +481,8 @@ fn main() {
|
|||||||
delegate_to_mixnode,
|
delegate_to_mixnode,
|
||||||
undelegate_from_mixnode,
|
undelegate_from_mixnode,
|
||||||
delegate_to_gateway,
|
delegate_to_gateway,
|
||||||
undelegate_from_gateway
|
undelegate_from_gateway,
|
||||||
|
send
|
||||||
])
|
])
|
||||||
.run(tauri::generate_context!())
|
.run(tauri::generate_context!())
|
||||||
.expect("error while running tauri application");
|
.expect("error while running tauri application");
|
||||||
|
|||||||
@@ -139,6 +139,18 @@ export const ApiList = () => {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
|
<ListItem>
|
||||||
|
<DocEntry
|
||||||
|
function={{
|
||||||
|
name: "send",
|
||||||
|
args: [
|
||||||
|
{ name: "address", type: "str" },
|
||||||
|
{ name: "amount", type: "object" },
|
||||||
|
{ name: "memo", type: "str" },
|
||||||
|
],
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</ListItem>
|
||||||
</List>
|
</List>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user