rust updates
This commit is contained in:
Generated
+39
-62
@@ -330,9 +330,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "bip32"
|
||||
version = "0.2.1"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b48054b307f98bf2ddb17ffd4e9d029bfaf3e7cd5fe807e412768e4370015e3d"
|
||||
checksum = "c2d0f0fc59c7ba0333eed9dcc1b6980baa7b7a4dc7c6c5885994d0674f7adf34"
|
||||
dependencies = [
|
||||
"bs58",
|
||||
"hkd32",
|
||||
@@ -1124,9 +1124,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "crypto-bigint"
|
||||
version = "0.2.4"
|
||||
version = "0.2.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cc209804a22c34a98fe26a32d997ac64d4284816f65cf1a529c4e31a256218a0"
|
||||
checksum = "e49339137316df1914fdb54a5eae75a73f45068fd0d2178fe235b11d93238a6e"
|
||||
dependencies = [
|
||||
"generic-array 0.14.4",
|
||||
"rand_core 0.6.3",
|
||||
@@ -2891,9 +2891,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "js-sys"
|
||||
version = "0.3.53"
|
||||
version = "0.3.54"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e4bf49d50e2961077d9c99f4b7997d770a1114f087c3c2e0069b36c13fc2979d"
|
||||
checksum = "1866b355d9c878e5e607473cbe3f63282c0b7aad2db1dbebf55076c686918254"
|
||||
dependencies = [
|
||||
"wasm-bindgen",
|
||||
]
|
||||
@@ -3083,9 +3083,9 @@ checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d"
|
||||
|
||||
[[package]]
|
||||
name = "minimal-lexical"
|
||||
version = "0.1.2"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6595bb28ed34f43c3fe088e48f6cfb2e033cab45f25a5384d5fdf564fbc8c4b2"
|
||||
checksum = "0c835948974f68e0bd58636fc6c5b1fbff7b297e3046f11b3b3c18bbac012c6d"
|
||||
|
||||
[[package]]
|
||||
name = "miniz_oxide"
|
||||
@@ -3607,30 +3607,6 @@ dependencies = [
|
||||
"version-checker",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nym_wallet"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bip39",
|
||||
"coconut-interface",
|
||||
"config",
|
||||
"cosmos_sdk",
|
||||
"cosmwasm-std",
|
||||
"credentials",
|
||||
"dirs",
|
||||
"mixnet-contract",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"tauri",
|
||||
"tauri-build",
|
||||
"tendermint-rpc",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
"ts-rs",
|
||||
"url",
|
||||
"validator-client",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nymsphinx"
|
||||
version = "0.1.0"
|
||||
@@ -5327,9 +5303,9 @@ checksum = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d"
|
||||
|
||||
[[package]]
|
||||
name = "sha2"
|
||||
version = "0.9.6"
|
||||
version = "0.9.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9204c41a1597a8c5af23c82d1c921cb01ec0a4c59e07a9c7306062829a3903f3"
|
||||
checksum = "b69f9a4c9740d74c5baa3fd2e547f9525fa8088a8a958e0ca2409a514e33f5fa"
|
||||
dependencies = [
|
||||
"block-buffer 0.9.0",
|
||||
"cfg-if 1.0.0",
|
||||
@@ -5371,9 +5347,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "siphasher"
|
||||
version = "0.3.6"
|
||||
version = "0.3.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "729a25c17d72b06c68cb47955d44fda88ad2d3e7d77e025663fdd69b93dd71a1"
|
||||
checksum = "533494a8f9b724d33625ab53c6c4800f7cc445895924a8ef649222dcb76e938b"
|
||||
|
||||
[[package]]
|
||||
name = "slab"
|
||||
@@ -5960,9 +5936,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.75"
|
||||
version = "1.0.76"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b7f58f7e8eaa0009c5fec437aabf511bd9933e4b2d7407bd05273c01a8906ea7"
|
||||
checksum = "c6f107db402c2c2055242dbf4d2af0e69197202e9faacbef9571bbe47f5a1b84"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -6338,18 +6314,18 @@ checksum = "8eaa81235c7058867fa8c0e7314f33dcce9c215f535d1913822a2b3f5e289f3c"
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.28"
|
||||
version = "1.0.29"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "283d5230e63df9608ac7d9691adc1dfb6e701225436eb64d0b9a7f0a5a04f6ec"
|
||||
checksum = "602eca064b2d83369e2b2f34b09c70b605402801927c65c11071ac911d299b88"
|
||||
dependencies = [
|
||||
"thiserror-impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror-impl"
|
||||
version = "1.0.28"
|
||||
version = "1.0.29"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fa3884228611f5cd3608e2d409bf7dce832e4eb3135e3f11addbd7e41bd68e71"
|
||||
checksum = "bad553cc2c78e8de258400763a647e80e6d1b31ee237275d756f6836d204494c"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -6505,9 +6481,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tokio-util"
|
||||
version = "0.6.7"
|
||||
version = "0.6.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1caa0b0c8d94a049db56b5acf8cba99dc0623aab1b26d5b5f5e2d945846b3592"
|
||||
checksum = "08d3725d3efa29485e87311c5b699de63cde14b00ed4d256b8318aa30ca452cd"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"futures-core",
|
||||
@@ -6801,6 +6777,7 @@ dependencies = [
|
||||
"serde_json",
|
||||
"sha2",
|
||||
"thiserror",
|
||||
"ts-rs",
|
||||
"url",
|
||||
]
|
||||
|
||||
@@ -6882,9 +6859,9 @@ checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f"
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen"
|
||||
version = "0.2.76"
|
||||
version = "0.2.77"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ce9b1b516211d33767048e5d47fa2a381ed8b76fc48d2ce4aa39877f9f183e0"
|
||||
checksum = "5e68338db6becec24d3c7977b5bf8a48be992c934b5d07177e3931f5dc9b076c"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"serde",
|
||||
@@ -6894,9 +6871,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-backend"
|
||||
version = "0.2.76"
|
||||
version = "0.2.77"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cfe8dc78e2326ba5f845f4b5bf548401604fa20b1dd1d365fb73b6c1d6364041"
|
||||
checksum = "f34c405b4f0658583dba0c1c7c9b694f3cac32655db463b56c254a1c75269523"
|
||||
dependencies = [
|
||||
"bumpalo",
|
||||
"lazy_static",
|
||||
@@ -6909,9 +6886,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-futures"
|
||||
version = "0.4.26"
|
||||
version = "0.4.27"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "95fded345a6559c2cfee778d562300c581f7d4ff3edb9b0d230d69800d213972"
|
||||
checksum = "a87d738d4abc4cf22f6eb142f5b9a81301331ee3c767f2fef2fda4e325492060"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"js-sys",
|
||||
@@ -6921,9 +6898,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro"
|
||||
version = "0.2.76"
|
||||
version = "0.2.77"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "44468aa53335841d9d6b6c023eaab07c0cd4bddbcfdee3e2bb1e8d2cb8069fef"
|
||||
checksum = "b9d5a6580be83b19dc570a8f9c324251687ab2184e57086f71625feb57ec77c8"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"wasm-bindgen-macro-support",
|
||||
@@ -6931,9 +6908,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro-support"
|
||||
version = "0.2.76"
|
||||
version = "0.2.77"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0195807922713af1e67dc66132c7328206ed9766af3858164fb583eedc25fbad"
|
||||
checksum = "e3775a030dc6f5a0afd8a84981a21cc92a781eb429acef9ecce476d0c9113e92"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -6944,15 +6921,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-shared"
|
||||
version = "0.2.76"
|
||||
version = "0.2.77"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "acdb075a845574a1fa5f09fd77e43f7747599301ea3417a9fbffdeedfc1f4a29"
|
||||
checksum = "c279e376c7a8e8752a8f1eaa35b7b0bee6bb9fb0cdacfa97cc3f1f289c87e2b4"
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-test"
|
||||
version = "0.3.26"
|
||||
version = "0.3.27"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "046f563713e2e7a602f0b45d49a564355f9a8a404cac3fa27b9855718f6ba97a"
|
||||
checksum = "02129da5406bad6e3b2042d0e19f963c03b84f0b05908599fc7f0980afb3158b"
|
||||
dependencies = [
|
||||
"console_error_panic_hook",
|
||||
"js-sys",
|
||||
@@ -6964,9 +6941,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-test-macro"
|
||||
version = "0.3.26"
|
||||
version = "0.3.27"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3b561e538d0e87b844dd2ce4608581373854f19c4fa2c473570d9fa3797eeb56"
|
||||
checksum = "7848675a1de39f7470ba747c4aa689f2977e190ab9589cdce6bd8a77c5743bd4"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -6986,9 +6963,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "web-sys"
|
||||
version = "0.3.53"
|
||||
version = "0.3.54"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "224b2f6b67919060055ef1a67807367c2066ed520c3862cc013d26cf893a783c"
|
||||
checksum = "0a84d70d1ec7d2da2d26a5bd78f4bca1b8c3254805363ce743b7a05bc30d195a"
|
||||
dependencies = [
|
||||
"js-sys",
|
||||
"wasm-bindgen",
|
||||
|
||||
@@ -49,7 +49,6 @@ members = [
|
||||
"mixnode",
|
||||
"service-providers/network-requester",
|
||||
"validator-api",
|
||||
"tauri-wallet/src-tauri",
|
||||
]
|
||||
|
||||
default-members = [
|
||||
|
||||
@@ -31,6 +31,7 @@ flate2 = { version = "1.0.20", optional = true }
|
||||
sha2 = { version = "0.9.5", optional = true }
|
||||
itertools = { version = "0.10", optional = true }
|
||||
cosmwasm-std = { git = "https://github.com/jstuczyn/cosmwasm", branch="0.14.1-updatedk256", optional = true }
|
||||
ts-rs = "3.0"
|
||||
|
||||
[features]
|
||||
nymd-client = ["async-trait", "bip39", "config", "cosmos_sdk", "prost", "flate2", "sha2", "itertools", "cosmwasm-std"]
|
||||
|
||||
@@ -6,8 +6,10 @@ use cosmos_sdk::tx::{Fee, Gas};
|
||||
use cosmos_sdk::Coin;
|
||||
use cosmwasm_std::Uint128;
|
||||
use std::fmt;
|
||||
use serde::{Serialize, Deserialize};
|
||||
use ts_rs::TS;
|
||||
|
||||
#[derive(Debug, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash)]
|
||||
#[derive(Debug, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Serialize, Deserialize, TS)]
|
||||
pub enum Operation {
|
||||
Upload,
|
||||
Init,
|
||||
@@ -40,28 +42,28 @@ pub(crate) fn calculate_fee(gas_price: &GasPrice, gas_limit: Gas) -> Coin {
|
||||
|
||||
impl fmt::Display for Operation {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match *self {
|
||||
Operation::Upload => f.write_str("Upload"),
|
||||
Operation::Init => f.write_str("Init"),
|
||||
Operation::Migrate => f.write_str("Migrate"),
|
||||
Operation::ChangeAdmin => f.write_str("ChangeAdmin"),
|
||||
Operation::Send => f.write_str("Send"),
|
||||
Operation::BondMixnode => f.write_str("BondMixnode"),
|
||||
Operation::UnbondMixnode => f.write_str("UnbondMixnode"),
|
||||
Operation::DelegateToMixnode => f.write_str("DelegateToMixnode"),
|
||||
Operation::UndelegateFromMixnode => f.write_str("UndelegateFromMixnode"),
|
||||
Operation::BondGateway => f.write_str("BondGateway"),
|
||||
Operation::UnbondGateway => f.write_str("UnbondGateway"),
|
||||
Operation::DelegateToGateway => f.write_str("DelegateToGateway"),
|
||||
Operation::UndelegateFromGateway => f.write_str("UndelegateFromGateway"),
|
||||
Operation::UpdateStateParams => f.write_str("UpdateStateParams"),
|
||||
}
|
||||
match *self {
|
||||
Operation::Upload => f.write_str("Upload"),
|
||||
Operation::Init => f.write_str("Init"),
|
||||
Operation::Migrate => f.write_str("Migrate"),
|
||||
Operation::ChangeAdmin => f.write_str("ChangeAdmin"),
|
||||
Operation::Send => f.write_str("Send"),
|
||||
Operation::BondMixnode => f.write_str("BondMixnode"),
|
||||
Operation::UnbondMixnode => f.write_str("UnbondMixnode"),
|
||||
Operation::DelegateToMixnode => f.write_str("DelegateToMixnode"),
|
||||
Operation::UndelegateFromMixnode => f.write_str("UndelegateFromMixnode"),
|
||||
Operation::BondGateway => f.write_str("BondGateway"),
|
||||
Operation::UnbondGateway => f.write_str("UnbondGateway"),
|
||||
Operation::DelegateToGateway => f.write_str("DelegateToGateway"),
|
||||
Operation::UndelegateFromGateway => f.write_str("UndelegateFromGateway"),
|
||||
Operation::UpdateStateParams => f.write_str("UpdateStateParams"),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Operation {
|
||||
// TODO: some value tweaking
|
||||
pub(crate) fn default_gas_limit(&self) -> Gas {
|
||||
pub fn default_gas_limit(&self) -> Gas {
|
||||
match self {
|
||||
Operation::Upload => 2_500_000u64.into(),
|
||||
Operation::Init => 500_000u64.into(),
|
||||
|
||||
@@ -32,7 +32,7 @@ pub use signing_client::Client as SigningNymdClient;
|
||||
|
||||
pub mod cosmwasm_client;
|
||||
pub mod error;
|
||||
pub(crate) mod fee_helpers;
|
||||
pub mod fee_helpers;
|
||||
pub mod gas_price;
|
||||
pub mod wallet;
|
||||
|
||||
@@ -151,7 +151,7 @@ impl<C> NymdClient<C> {
|
||||
&self.client_address.as_ref().unwrap()[0]
|
||||
}
|
||||
|
||||
fn get_fee(&self, operation: Operation) -> Fee {
|
||||
pub fn get_fee(&self, operation: Operation) -> Fee {
|
||||
let gas_limit = self.custom_gas_limits.get(&operation).cloned();
|
||||
operation.determine_fee(&self.gas_price, gas_limit)
|
||||
}
|
||||
|
||||
Generated
+5207
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,2 @@
|
||||
[workspace]
|
||||
members = ["src-tauri"]
|
||||
@@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "nym_wallet"
|
||||
version = "0.1.0"
|
||||
description = "A Tauri App"
|
||||
description = "Nym Native Wallet"
|
||||
authors = ["you"]
|
||||
license = ""
|
||||
repository = ""
|
||||
@@ -26,6 +26,7 @@ thiserror = "1.0"
|
||||
tendermint-rpc = "0.21.0"
|
||||
ts-rs = "3.0"
|
||||
url = "2.0"
|
||||
rand = "0.6.5"
|
||||
|
||||
cosmos_sdk = { git = "https://github.com/cosmos/cosmos-rust/", rev = "ba012bd820240d3df2d9a0ab1deabe4ecd9a2f30", features = [
|
||||
"rpc",
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
)]
|
||||
|
||||
use ::config::defaults::DENOM;
|
||||
use bip39::Mnemonic;
|
||||
use bip39::{Language, Mnemonic};
|
||||
use cosmos_sdk::Coin as CosmosCoin;
|
||||
use cosmos_sdk::Denom as CosmosDenom;
|
||||
use cosmos_sdk::{AccountId, Decimal};
|
||||
@@ -12,14 +12,16 @@ use cosmwasm_std::Coin as CosmWasmCoin;
|
||||
use error::BackendError;
|
||||
use mixnet_contract::{Gateway, MixNode};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tendermint_rpc::endpoint::broadcast::tx_commit::Response;
|
||||
use std::collections::HashMap;
|
||||
use std::convert::{TryFrom, TryInto};
|
||||
use std::fmt;
|
||||
use std::ops::Add;
|
||||
use std::str::FromStr;
|
||||
use std::sync::Arc;
|
||||
use tendermint_rpc::endpoint::broadcast::tx_commit::Response;
|
||||
use tokio::sync::RwLock;
|
||||
use ts_rs::{export, TS};
|
||||
use validator_client::nymd::fee_helpers::Operation;
|
||||
use validator_client::nymd::GasPrice;
|
||||
use validator_client::nymd::{NymdClient, SigningNymdClient};
|
||||
|
||||
@@ -81,21 +83,20 @@ impl FromStr for Denom {
|
||||
|
||||
#[derive(Deserialize, Serialize, TS)]
|
||||
struct TauriTxResult {
|
||||
code: u32,
|
||||
gas_wanted: u64,
|
||||
gas_used: u64,
|
||||
block_height: u64,
|
||||
details: TransactionDetails,
|
||||
code: u32,
|
||||
gas_wanted: u64,
|
||||
gas_used: u64,
|
||||
block_height: u64,
|
||||
details: TransactionDetails,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, TS)]
|
||||
struct TransactionDetails {
|
||||
from_address: String,
|
||||
to_address: String,
|
||||
amount: Coin
|
||||
amount: Coin,
|
||||
}
|
||||
|
||||
|
||||
impl TauriTxResult {
|
||||
fn new(t: Response, details: TransactionDetails) -> TauriTxResult {
|
||||
TauriTxResult {
|
||||
@@ -103,12 +104,11 @@ impl TauriTxResult {
|
||||
gas_wanted: t.check_tx.gas_wanted.value(),
|
||||
gas_used: t.check_tx.gas_used.value(),
|
||||
block_height: t.height.value(),
|
||||
details
|
||||
details,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Proxy types to allow TS generation
|
||||
#[derive(TS, Serialize, Deserialize, Clone)]
|
||||
struct Coin {
|
||||
@@ -131,6 +131,28 @@ impl fmt::Display for Coin {
|
||||
}
|
||||
}
|
||||
|
||||
// Allows adding minor and major denominations, output will have the LHS denom.
|
||||
impl Add for Coin {
|
||||
type Output = Self;
|
||||
|
||||
fn add(self, rhs: Self) -> Self {
|
||||
let denom = Denom::from_str(&self.denom).unwrap();
|
||||
let lhs = self.to_minor();
|
||||
let rhs = rhs.to_minor();
|
||||
let lhs_amount = lhs.amount.parse::<u64>().unwrap();
|
||||
let rhs_amount = rhs.amount.parse::<u64>().unwrap();
|
||||
let amount = lhs_amount + rhs_amount;
|
||||
let coin = Coin {
|
||||
amount: amount.to_string(),
|
||||
denom: Denom::Minor.to_string(),
|
||||
};
|
||||
match denom {
|
||||
Denom::Major => coin.to_major(),
|
||||
Denom::Minor => coin,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Coin {
|
||||
fn to_major(&self) -> Coin {
|
||||
if let Ok(denom) = Denom::from_str(&self.denom) {
|
||||
@@ -434,34 +456,50 @@ async fn send(
|
||||
let r_state = state.read().await;
|
||||
let client = r_state.client()?;
|
||||
match client.send(&address, vec![cosmos_amount], memo).await {
|
||||
Ok(result) => Ok(TauriTxResult::new(result, TransactionDetails {
|
||||
from_address: client.address().to_string(),
|
||||
to_address: address.to_string(),
|
||||
amount
|
||||
})),
|
||||
Ok(result) => Ok(TauriTxResult::new(
|
||||
result,
|
||||
TransactionDetails {
|
||||
from_address: client.address().to_string(),
|
||||
to_address: address.to_string(),
|
||||
amount,
|
||||
},
|
||||
)),
|
||||
Err(e) => Err(format_err!(e)),
|
||||
}
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
async fn get_gas_price(state: tauri::State<'_, Arc<RwLock<State>>>) -> Result<Coin, String> {
|
||||
async fn get_fee(
|
||||
operation: Operation,
|
||||
state: tauri::State<'_, Arc<RwLock<State>>>,
|
||||
) -> Result<Coin, String> {
|
||||
let r_state = state.read().await;
|
||||
let client = r_state.client()?;
|
||||
let coin = client.get_gas_price().into();
|
||||
let fee = client.get_fee(operation);
|
||||
let mut coin = Coin {
|
||||
amount: "0".to_string(),
|
||||
denom: "upunk".to_string(),
|
||||
};
|
||||
for f in fee.amount {
|
||||
coin = coin + f.into();
|
||||
}
|
||||
|
||||
Ok(coin)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
async fn get_gas_limits(
|
||||
async fn create_new_account(
|
||||
state: tauri::State<'_, Arc<RwLock<State>>>,
|
||||
) -> Result<HashMap<String, u64>, String> {
|
||||
let r_state = state.read().await;
|
||||
let client = r_state.client()?;
|
||||
let mut limits = HashMap::new();
|
||||
for (k, v) in client.get_custom_gas_limits() {
|
||||
limits.insert(k.to_string(), v.value());
|
||||
}
|
||||
Ok(limits)
|
||||
) -> Result<HashMap<&str, String>, String> {
|
||||
let mnemonic = random_mnemonic();
|
||||
let mut client = connect_with_mnemonic(mnemonic.to_string(), state).await?;
|
||||
client.insert("mnemonic", mnemonic.to_string());
|
||||
Ok(client)
|
||||
}
|
||||
|
||||
fn random_mnemonic() -> Mnemonic {
|
||||
let mut rng = rand::thread_rng();
|
||||
Mnemonic::generate_in_with(&mut rng, Language::English, 24).unwrap()
|
||||
}
|
||||
|
||||
fn _connect_with_mnemonic(mnemonic: Mnemonic, config: &Config) -> NymdClient<SigningNymdClient> {
|
||||
@@ -494,13 +532,13 @@ fn main() {
|
||||
delegate_to_gateway,
|
||||
undelegate_from_gateway,
|
||||
send,
|
||||
get_gas_price,
|
||||
get_gas_limits,
|
||||
get_credential,
|
||||
randomise_credential,
|
||||
delete_credential,
|
||||
list_credentials,
|
||||
verify_credential
|
||||
verify_credential,
|
||||
create_new_account,
|
||||
get_fee
|
||||
])
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
@@ -512,5 +550,6 @@ export! {
|
||||
Balance => "../src/types/rust/balance.ts",
|
||||
Gateway => "../src/types/rust/gateway.ts",
|
||||
TauriTxResult => "../src/types/rust/tauritxresult.ts",
|
||||
TransactionDetails => "../src/types/rust/transactiondetails.ts"
|
||||
TransactionDetails => "../src/types/rust/transactiondetails.ts",
|
||||
Operation => "../src/types/rust/operation.ts"
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ export const ApiList = () => {
|
||||
<ListItem>
|
||||
<DocEntry
|
||||
function={{
|
||||
name: "unbond_mixnode",
|
||||
name: 'unbond_mixnode',
|
||||
args: [],
|
||||
}}
|
||||
/>
|
||||
@@ -70,10 +70,10 @@ export const ApiList = () => {
|
||||
<ListItem>
|
||||
<DocEntry
|
||||
function={{
|
||||
name: "bond_gateway",
|
||||
name: 'bond_gateway',
|
||||
args: [
|
||||
{ name: "gateway", type: "object" },
|
||||
{ name: "bond", type: "object" },
|
||||
{ name: 'gateway', type: 'object' },
|
||||
{ name: 'bond', type: 'object' },
|
||||
],
|
||||
}}
|
||||
/>
|
||||
@@ -81,7 +81,7 @@ export const ApiList = () => {
|
||||
<ListItem>
|
||||
<DocEntry
|
||||
function={{
|
||||
name: "unbond_gateway",
|
||||
name: 'unbond_gateway',
|
||||
args: [],
|
||||
}}
|
||||
/>
|
||||
@@ -89,10 +89,10 @@ export const ApiList = () => {
|
||||
<ListItem>
|
||||
<DocEntry
|
||||
function={{
|
||||
name: "delegate_to_mixnode",
|
||||
name: 'delegate_to_mixnode',
|
||||
args: [
|
||||
{ name: "identity", type: "str" },
|
||||
{ name: "amount", type: "object" },
|
||||
{ name: 'identity', type: 'str' },
|
||||
{ name: 'amount', type: 'object' },
|
||||
],
|
||||
}}
|
||||
/>
|
||||
@@ -100,18 +100,18 @@ export const ApiList = () => {
|
||||
<ListItem>
|
||||
<DocEntry
|
||||
function={{
|
||||
name: "undelegate_from_mixnode",
|
||||
args: [{ name: "identity", type: "str" }],
|
||||
name: 'undelegate_from_mixnode',
|
||||
args: [{ name: 'identity', type: 'str' }],
|
||||
}}
|
||||
/>
|
||||
</ListItem>
|
||||
<ListItem>
|
||||
<DocEntry
|
||||
function={{
|
||||
name: "delegate_to_gateway",
|
||||
name: 'delegate_to_gateway',
|
||||
args: [
|
||||
{ name: "identity", type: "str" },
|
||||
{ name: "amount", type: "object" },
|
||||
{ name: 'identity', type: 'str' },
|
||||
{ name: 'amount', type: 'object' },
|
||||
],
|
||||
}}
|
||||
/>
|
||||
@@ -119,19 +119,19 @@ export const ApiList = () => {
|
||||
<ListItem>
|
||||
<DocEntry
|
||||
function={{
|
||||
name: "undelegate_from_gateway",
|
||||
args: [{ name: "identity", type: "str" }],
|
||||
name: 'undelegate_from_gateway',
|
||||
args: [{ name: 'identity', type: 'str' }],
|
||||
}}
|
||||
/>
|
||||
</ListItem>
|
||||
<ListItem>
|
||||
<DocEntry
|
||||
function={{
|
||||
name: "send",
|
||||
name: 'send',
|
||||
args: [
|
||||
{ name: "address", type: "str" },
|
||||
{ name: "amount", type: "object" },
|
||||
{ name: "memo", type: "str" },
|
||||
{ name: 'address', type: 'str' },
|
||||
{ name: 'amount', type: 'object' },
|
||||
{ name: 'memo', type: 'str' },
|
||||
],
|
||||
}}
|
||||
/>
|
||||
@@ -139,7 +139,15 @@ export const ApiList = () => {
|
||||
<ListItem>
|
||||
<DocEntry
|
||||
function={{
|
||||
name: "get_gas_price",
|
||||
name: 'get_fee',
|
||||
args: [{ name: 'operation', type: 'str' }],
|
||||
}}
|
||||
/>
|
||||
</ListItem>
|
||||
<ListItem>
|
||||
<DocEntry
|
||||
function={{
|
||||
name: 'create_new_account',
|
||||
args: [],
|
||||
}}
|
||||
/>
|
||||
@@ -147,8 +155,8 @@ export const ApiList = () => {
|
||||
<ListItem>
|
||||
<DocEntry
|
||||
function={{
|
||||
name: "get_gas_limits",
|
||||
args: [],
|
||||
name: 'connect_with_mnemonic',
|
||||
args: [{ name: 'mnemonic', type: 'str' }],
|
||||
}}
|
||||
/>
|
||||
</ListItem>
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
export type Operation =
|
||||
| "Upload"
|
||||
| "Init"
|
||||
| "Migrate"
|
||||
| "ChangeAdmin"
|
||||
| "Send"
|
||||
| "BondMixnode"
|
||||
| "UnbondMixnode"
|
||||
| "DelegateToMixnode"
|
||||
| "UndelegateFromMixnode"
|
||||
| "BondGateway"
|
||||
| "UnbondGateway"
|
||||
| "DelegateToGateway"
|
||||
| "UndelegateFromGateway"
|
||||
| "UpdateStateParams";
|
||||
Reference in New Issue
Block a user