Fix coin to cosmwasm coin
This commit is contained in:
@@ -5,8 +5,8 @@ use crate::nymd::GasPrice;
|
|||||||
use cosmos_sdk::tx::{Fee, Gas};
|
use cosmos_sdk::tx::{Fee, Gas};
|
||||||
use cosmos_sdk::Coin;
|
use cosmos_sdk::Coin;
|
||||||
use cosmwasm_std::Uint128;
|
use cosmwasm_std::Uint128;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use serde::{Serialize, Deserialize};
|
|
||||||
use ts_rs::TS;
|
use ts_rs::TS;
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Serialize, Deserialize, 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 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
|
self.client
|
||||||
.execute(
|
.execute(
|
||||||
self.address(),
|
self.address(),
|
||||||
@@ -514,7 +516,9 @@ impl<C> NymdClient<C> {
|
|||||||
{
|
{
|
||||||
let fee = self.get_fee(Operation::UndelegateFromMixnode);
|
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
|
self.client
|
||||||
.execute(
|
.execute(
|
||||||
self.address(),
|
self.address(),
|
||||||
@@ -582,7 +586,9 @@ impl<C> NymdClient<C> {
|
|||||||
{
|
{
|
||||||
let fee = self.get_fee(Operation::DelegateToGateway);
|
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
|
self.client
|
||||||
.execute(
|
.execute(
|
||||||
self.address(),
|
self.address(),
|
||||||
@@ -605,7 +611,9 @@ impl<C> NymdClient<C> {
|
|||||||
{
|
{
|
||||||
let fee = self.get_fee(Operation::UndelegateFromGateway);
|
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
|
self.client
|
||||||
.execute(
|
.execute(
|
||||||
self.address(),
|
self.address(),
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ use cosmos_sdk::Coin as CosmosCoin;
|
|||||||
use cosmos_sdk::Decimal;
|
use cosmos_sdk::Decimal;
|
||||||
use cosmos_sdk::Denom as CosmosDenom;
|
use cosmos_sdk::Denom as CosmosDenom;
|
||||||
use cosmwasm_std::Coin as CosmWasmCoin;
|
use cosmwasm_std::Coin as CosmWasmCoin;
|
||||||
|
use cosmwasm_std::Uint128;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
@@ -34,9 +35,10 @@ impl FromStr for Denom {
|
|||||||
type Err = String;
|
type Err = String;
|
||||||
|
|
||||||
fn from_str(s: &str) -> Result<Denom, 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)
|
Ok(Denom::Minor)
|
||||||
} else if s.to_lowercase() == DENOM[1..].to_lowercase() {
|
} else if s == DENOM[1..].to_lowercase() || s == "major" {
|
||||||
Ok(Denom::Major)
|
Ok(Denom::Major)
|
||||||
} else {
|
} else {
|
||||||
Err(format_err!(format!(
|
Err(format_err!(format!(
|
||||||
@@ -132,13 +134,11 @@ impl TryFrom<Coin> for CosmWasmCoin {
|
|||||||
type Error = String;
|
type Error = String;
|
||||||
|
|
||||||
fn try_from(coin: Coin) -> Result<CosmWasmCoin, String> {
|
fn try_from(coin: Coin) -> Result<CosmWasmCoin, String> {
|
||||||
match serde_json::to_value(coin) {
|
let coin = coin.to_minor();
|
||||||
Ok(value) => match serde_json::from_value(value) {
|
Ok(CosmWasmCoin::new(
|
||||||
Ok(coin) => Ok(coin),
|
Uint128::try_from(coin.amount.as_str()).unwrap().u128(),
|
||||||
Err(e) => Err(format_err!(e)),
|
coin.denom.to_string(),
|
||||||
},
|
))
|
||||||
Err(e) => Err(format_err!(e)),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@
|
|||||||
"windows": [
|
"windows": [
|
||||||
{
|
{
|
||||||
"title": "nym-wallet",
|
"title": "nym-wallet",
|
||||||
"width": 1024,
|
"width": 1268,
|
||||||
"height": 768,
|
"height": 768,
|
||||||
"resizable": true,
|
"resizable": true,
|
||||||
"fullscreen": false
|
"fullscreen": false
|
||||||
|
|||||||
+5094
-6205
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user