Fix coin to cosmwasm coin

This commit is contained in:
Drazen Urch
2021-09-13 14:31:33 +02:00
parent a601c28a20
commit 0278bd2c26
5 changed files with 5117 additions and 6220 deletions
@@ -5,8 +5,8 @@ use crate::nymd::GasPrice;
use cosmos_sdk::tx::{Fee, Gas};
use cosmos_sdk::Coin;
use cosmwasm_std::Uint128;
use serde::{Deserialize, Serialize};
use std::fmt;
use serde::{Serialize, Deserialize};
use ts_rs::TS;
#[derive(Debug, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Serialize, Deserialize, TS)]
@@ -491,7 +491,9 @@ impl<C> NymdClient<C> {
{
let fee = self.get_fee(Operation::DelegateToMixnode);
let req = ExecuteMsg::DelegateToMixnode { mix_identity: mix_identity.to_string() };
let req = ExecuteMsg::DelegateToMixnode {
mix_identity: mix_identity.to_string(),
};
self.client
.execute(
self.address(),
@@ -514,7 +516,9 @@ impl<C> NymdClient<C> {
{
let fee = self.get_fee(Operation::UndelegateFromMixnode);
let req = ExecuteMsg::UndelegateFromMixnode { mix_identity: mix_identity.to_string() };
let req = ExecuteMsg::UndelegateFromMixnode {
mix_identity: mix_identity.to_string(),
};
self.client
.execute(
self.address(),
@@ -582,7 +586,9 @@ impl<C> NymdClient<C> {
{
let fee = self.get_fee(Operation::DelegateToGateway);
let req = ExecuteMsg::DelegateToGateway { gateway_identity: gateway_identity.to_string() };
let req = ExecuteMsg::DelegateToGateway {
gateway_identity: gateway_identity.to_string(),
};
self.client
.execute(
self.address(),
@@ -605,7 +611,9 @@ impl<C> NymdClient<C> {
{
let fee = self.get_fee(Operation::UndelegateFromGateway);
let req = ExecuteMsg::UndelegateFromGateway { gateway_identity: gateway_identity.to_string() };
let req = ExecuteMsg::UndelegateFromGateway {
gateway_identity: gateway_identity.to_string(),
};
self.client
.execute(
self.address(),
+9 -9
View File
@@ -5,6 +5,7 @@ use cosmos_sdk::Coin as CosmosCoin;
use cosmos_sdk::Decimal;
use cosmos_sdk::Denom as CosmosDenom;
use cosmwasm_std::Coin as CosmWasmCoin;
use cosmwasm_std::Uint128;
use serde::{Deserialize, Serialize};
use std::convert::TryFrom;
use std::fmt;
@@ -34,9 +35,10 @@ impl FromStr for Denom {
type Err = String;
fn from_str(s: &str) -> Result<Denom, String> {
if s.to_lowercase() == DENOM.to_lowercase() {
let s = s.to_lowercase();
if s == DENOM.to_lowercase() || s == "minor" {
Ok(Denom::Minor)
} else if s.to_lowercase() == DENOM[1..].to_lowercase() {
} else if s == DENOM[1..].to_lowercase() || s == "major" {
Ok(Denom::Major)
} else {
Err(format_err!(format!(
@@ -132,13 +134,11 @@ impl TryFrom<Coin> for CosmWasmCoin {
type Error = String;
fn try_from(coin: Coin) -> Result<CosmWasmCoin, String> {
match serde_json::to_value(coin) {
Ok(value) => match serde_json::from_value(value) {
Ok(coin) => Ok(coin),
Err(e) => Err(format_err!(e)),
},
Err(e) => Err(format_err!(e)),
}
let coin = coin.to_minor();
Ok(CosmWasmCoin::new(
Uint128::try_from(coin.amount.as_str()).unwrap().u128(),
coin.denom.to_string(),
))
}
}
+1 -1
View File
@@ -52,7 +52,7 @@
"windows": [
{
"title": "nym-wallet",
"width": 1024,
"width": 1268,
"height": 768,
"resizable": true,
"fullscreen": false
+5094 -6205
View File
File diff suppressed because it is too large Load Diff