node unbond
This commit is contained in:
@@ -1,9 +1,7 @@
|
|||||||
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
|
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
use config::defaults::{
|
use config::defaults::{default_validators, ValidatorDetails, DEFAULT_MIXNET_CONTRACT_ADDRESS};
|
||||||
default_api_endpoints, default_validators, ValidatorDetails, DEFAULT_MIXNET_CONTRACT_ADDRESS
|
|
||||||
};
|
|
||||||
use config::NymConfig;
|
use config::NymConfig;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
@@ -39,7 +37,7 @@ impl Default for Base {
|
|||||||
Base {
|
Base {
|
||||||
validators: default_validators(),
|
validators: default_validators(),
|
||||||
mixnet_contract_address: DEFAULT_MIXNET_CONTRACT_ADDRESS.to_string(),
|
mixnet_contract_address: DEFAULT_MIXNET_CONTRACT_ADDRESS.to_string(),
|
||||||
mnemonic: String::default()
|
mnemonic: String::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,19 +3,19 @@ use validator_client::nymd::error::NymdError;
|
|||||||
|
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
pub enum BackendError {
|
pub enum BackendError {
|
||||||
#[error("Error parsing bip39 mnemonic")]
|
#[error("Error parsing bip39 mnemonic")]
|
||||||
Bip39Error {
|
Bip39Error {
|
||||||
#[from]
|
#[from]
|
||||||
source: bip39::Error
|
source: bip39::Error,
|
||||||
},
|
},
|
||||||
#[error("Error parsing into tendermint Url")]
|
#[error("Error parsing into tendermint Url")]
|
||||||
TendermintError {
|
TendermintError {
|
||||||
#[from]
|
#[from]
|
||||||
source: tendermint_rpc::Error
|
source: tendermint_rpc::Error,
|
||||||
},
|
},
|
||||||
#[error("Error getting balances")]
|
#[error("Error getting balances")]
|
||||||
NymdError {
|
NymdError {
|
||||||
#[from]
|
#[from]
|
||||||
source: NymdError
|
source: NymdError,
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,9 +47,9 @@ enum Denom {
|
|||||||
|
|
||||||
impl fmt::Display for Denom {
|
impl fmt::Display for Denom {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
match self {
|
match *self {
|
||||||
&Denom::Major => f.write_str(&DENOM[1..].to_uppercase()),
|
Denom::Major => f.write_str(&DENOM[1..].to_uppercase()),
|
||||||
&Denom::Minor => f.write_str(DENOM),
|
Denom::Minor => f.write_str(DENOM),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -162,7 +162,7 @@ struct State {
|
|||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
fn major_to_minor(amount: String) -> Result<Coin, String> {
|
fn major_to_minor(amount: String) -> Result<Coin, String> {
|
||||||
let coin = Coin {
|
let coin = Coin {
|
||||||
amount: amount,
|
amount,
|
||||||
denom: Denom::Major.to_string(),
|
denom: Denom::Major.to_string(),
|
||||||
};
|
};
|
||||||
Ok(coin.to_minor())
|
Ok(coin.to_minor())
|
||||||
@@ -171,7 +171,7 @@ fn major_to_minor(amount: String) -> Result<Coin, String> {
|
|||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
fn minor_to_major(amount: String) -> Result<Coin, String> {
|
fn minor_to_major(amount: String) -> Result<Coin, String> {
|
||||||
let coin = Coin {
|
let coin = Coin {
|
||||||
amount: amount,
|
amount,
|
||||||
denom: Denom::Minor.to_string(),
|
denom: Denom::Minor.to_string(),
|
||||||
};
|
};
|
||||||
Ok(coin.to_major())
|
Ok(coin.to_major())
|
||||||
@@ -272,9 +272,20 @@ async fn owns_gateway(state: tauri::State<'_, Arc<RwLock<State>>>) -> Result<boo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// coin: {"denom": "upunk", "amount": 0}
|
#[tauri::command]
|
||||||
|
async fn unbond_mixnode(state: tauri::State<'_, Arc<RwLock<State>>>) -> Result<(), String> {
|
||||||
// {"host": "", "mix_port": 0, "verloc_port": 0, "http_api_port": 0, "sphinx_key": "", "identity_key": "", "version": ""}
|
let r_state = state.read().await;
|
||||||
|
if let Some(client) = &r_state.signing_client {
|
||||||
|
match client.unbond_mixnode().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",
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
async fn bond_mixnode(
|
async fn bond_mixnode(
|
||||||
@@ -320,7 +331,8 @@ fn main() {
|
|||||||
major_to_minor,
|
major_to_minor,
|
||||||
owns_gateway,
|
owns_gateway,
|
||||||
owns_mixnode,
|
owns_mixnode,
|
||||||
bond_mixnode
|
bond_mixnode,
|
||||||
|
unbond_mixnode
|
||||||
])
|
])
|
||||||
.run(tauri::generate_context!())
|
.run(tauri::generate_context!())
|
||||||
.expect("error while running tauri application");
|
.expect("error while running tauri application");
|
||||||
|
|||||||
Reference in New Issue
Block a user