No longer exposing plain 'DENOM'
This commit is contained in:
@@ -31,7 +31,7 @@ impl Client {
|
||||
None,
|
||||
)
|
||||
.unwrap();
|
||||
let denom = Denom::from_str(network_defaults::DENOM).unwrap();
|
||||
let denom = Denom::from_str(network_defaults::MIX_DENOM.base).unwrap();
|
||||
let contract_address = AccountId::from_str(CONTRACT_ADDRESS).unwrap();
|
||||
|
||||
Client {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Copyright 2022 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
use config::defaults::DENOM;
|
||||
use config::defaults::MIX_DENOM;
|
||||
use cosmwasm_std::{Coin, Timestamp};
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -11,7 +11,7 @@ pub mod events;
|
||||
pub mod messages;
|
||||
|
||||
pub fn one_ucoin() -> Coin {
|
||||
Coin::new(1, DENOM)
|
||||
Coin::new(1, MIX_DENOM.base)
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "generate-ts", derive(ts_rs::TS))]
|
||||
|
||||
@@ -17,24 +17,24 @@ pub mod sandbox;
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(network = "mainnet")] {
|
||||
pub const DEFAULT_NETWORK: all::Network = all::Network::MAINNET;
|
||||
pub const DENOM: &str = mainnet::DENOM;
|
||||
// pub const STAKE_DENOM: &str = mainnet::STAKE_DENOM;
|
||||
pub const MIX_DENOM: DenomDetails = mainnet::MIX_DENOM;
|
||||
pub const STAKE_DENOM: DenomDetails = mainnet::STAKE_DENOM;
|
||||
|
||||
pub const ETH_CONTRACT_ADDRESS: [u8; 20] = mainnet::_ETH_CONTRACT_ADDRESS;
|
||||
pub const ETH_ERC20_CONTRACT_ADDRESS: [u8; 20] = mainnet::_ETH_ERC20_CONTRACT_ADDRESS;
|
||||
|
||||
} else if #[cfg(network = "qa")] {
|
||||
pub const DEFAULT_NETWORK: all::Network = all::Network::QA;
|
||||
pub const DENOM: &str = qa::DENOM;
|
||||
// pub const STAKE_DENOM: &str = qa::STAKE_DENOM;
|
||||
pub const MIX_DENOM: DenomDetails = qa::MIX_DENOM;
|
||||
pub const STAKE_DENOM: DenomDetails = qa::STAKE_DENOM;
|
||||
|
||||
pub const ETH_CONTRACT_ADDRESS: [u8; 20] = qa::_ETH_CONTRACT_ADDRESS;
|
||||
pub const ETH_ERC20_CONTRACT_ADDRESS: [u8; 20] = qa::_ETH_ERC20_CONTRACT_ADDRESS;
|
||||
|
||||
} else if #[cfg(network = "sandbox")] {
|
||||
pub const DEFAULT_NETWORK: all::Network = all::Network::SANDBOX;
|
||||
pub const DENOM: &str = sandbox::DENOM;
|
||||
// pub const STAKE_DENOM: &str = sandbox::STAKE_DENOM;
|
||||
pub const MIX_DENOM: DenomDetails = sandbox::MIX_DENOM;
|
||||
pub const STAKE_DENOM: DenomDetails = sandbox::STAKE_DENOM;
|
||||
|
||||
pub const ETH_CONTRACT_ADDRESS: [u8; 20] = sandbox::_ETH_CONTRACT_ADDRESS;
|
||||
pub const ETH_ERC20_CONTRACT_ADDRESS: [u8; 20] = sandbox::_ETH_ERC20_CONTRACT_ADDRESS;
|
||||
|
||||
+53
-129
@@ -11,6 +11,8 @@ use std::str::FromStr;
|
||||
use strum::{Display, EnumString, EnumVariantNames};
|
||||
use validator_client::nymd::{Coin, CosmosCoin};
|
||||
|
||||
pub type Denom = String;
|
||||
|
||||
#[cfg_attr(feature = "generate-ts", derive(ts_rs::TS))]
|
||||
#[cfg_attr(
|
||||
feature = "generate-ts",
|
||||
@@ -76,31 +78,67 @@ pub struct MajorAmountString(String); // see https://github.com/Aleph-Alpha/ts-r
|
||||
feature = "generate-ts",
|
||||
ts(export_to = "ts-packages/types/src/types/rust/Currency.ts")
|
||||
)]
|
||||
// #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
||||
pub struct MajorCurrencyAmount {
|
||||
// temporarly going back to original impl to speed up merge
|
||||
pub amount: MajorAmountString,
|
||||
pub denom: CurrencyDenom,
|
||||
// // temporary...
|
||||
// #[cfg_attr(feature = "generate-ts", ts(skip))]
|
||||
// pub coin: Coin,
|
||||
}
|
||||
|
||||
// impl JsonSchema for MajorCurrencyAmount {
|
||||
// fn schema_name() -> String {
|
||||
// todo!()
|
||||
// }
|
||||
//
|
||||
// fn json_schema(gen: &mut SchemaGenerator) -> Schema {
|
||||
// todo!()
|
||||
// }
|
||||
// }
|
||||
// TODO: should this live here?
|
||||
// attempts to replicate cosmos-sdk's coin metadata
|
||||
// https://docs.cosmos.network/master/architecture/adr-024-coin-metadata.html
|
||||
// this way we could more easily handle multiple coin types simultaneously (like nym/nyx/nymt/nyx + local currencies)
|
||||
pub struct DenomUnit {
|
||||
pub denom: Denom,
|
||||
pub exponent: u32,
|
||||
// pub aliases: Vec<String>,
|
||||
}
|
||||
|
||||
impl DenomUnit {
|
||||
pub fn new(denom: Denom, exponent: u32) -> Self {
|
||||
DenomUnit { denom, exponent }
|
||||
}
|
||||
}
|
||||
|
||||
pub struct CoinMetadata {
|
||||
pub denom_units: Vec<DenomUnit>,
|
||||
pub base: Denom,
|
||||
pub display: Denom,
|
||||
}
|
||||
|
||||
impl CoinMetadata {
|
||||
pub fn new(denom_units: Vec<DenomUnit>, base: Denom, display: Denom) -> Self {
|
||||
CoinMetadata {
|
||||
denom_units,
|
||||
base,
|
||||
display,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// tries to semi-replicate cosmos-sdk's DecCoin for being able to handle tokens with decimal amounts
|
||||
// https://github.com/cosmos/cosmos-sdk/blob/v0.45.4/types/dec_coin.go
|
||||
#[cfg_attr(feature = "generate-ts", derive(ts_rs::TS))]
|
||||
#[cfg_attr(
|
||||
feature = "generate-ts",
|
||||
ts(export_to = "ts-packages/types/src/types/rust/DecCoin.ts")
|
||||
)]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
||||
pub struct DecCoin {
|
||||
//
|
||||
pub denom: Denom,
|
||||
// Decimal is already serialized to string and using string in its schema, so lets also go straight to string for ts_rs
|
||||
// todo: is `Decimal` the correct type to use? Do we want to depend on cosmwasm_std here?
|
||||
#[cfg_attr(feature = "generate-ts", ts(type = "string"))]
|
||||
pub amount: Decimal,
|
||||
}
|
||||
|
||||
impl From<Coin> for DecCoin {
|
||||
fn from(coin: Coin) -> Self {
|
||||
DecCoin {
|
||||
denom: coin.denom,
|
||||
amount: Decimal::from_atomics(coin.amount, 0).unwrap(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl MajorCurrencyAmount {
|
||||
@@ -114,120 +152,6 @@ impl MajorCurrencyAmount {
|
||||
pub fn zero(denom: &CurrencyDenom) -> MajorCurrencyAmount {
|
||||
MajorCurrencyAmount::new("0", denom.clone())
|
||||
}
|
||||
//
|
||||
// pub fn from_cosmrs_coin(coin: &CosmosCoin) -> Result<MajorCurrencyAmount, TypesError> {
|
||||
// MajorCurrencyAmount::from_cosmrs_decimal_and_denom(coin.amount, coin.denom.to_string())
|
||||
// }
|
||||
//
|
||||
// pub fn from_minor_uint128_and_denom(
|
||||
// amount_minor: Uint128,
|
||||
// denom_minor: &str,
|
||||
// ) -> Result<MajorCurrencyAmount, TypesError> {
|
||||
// MajorCurrencyAmount::from_minor_decimal_and_denom(
|
||||
// Decimal::from_atomics(amount_minor, 0)?,
|
||||
// denom_minor,
|
||||
// )
|
||||
// }
|
||||
//
|
||||
// pub fn from_minor_decimal_and_denom(
|
||||
// amount_minor: Decimal,
|
||||
// denom_minor: &str,
|
||||
// ) -> Result<MajorCurrencyAmount, TypesError> {
|
||||
// if !(denom_minor.starts_with('u') || denom_minor.starts_with('U')) {
|
||||
// return Err(TypesError::InvalidDenom(denom_minor.to_string()));
|
||||
// }
|
||||
// let major = amount_minor / Uint128::from(1_000_000u64);
|
||||
// if let Ok(denom) = CurrencyDenom::from_str(&denom_minor[1..].to_string()) {
|
||||
// return Ok(MajorCurrencyAmount {
|
||||
// amount: MajorAmountString(major.to_string()),
|
||||
// denom,
|
||||
// });
|
||||
// }
|
||||
// Err(TypesError::InvalidDenom(denom_minor.to_string()))
|
||||
// }
|
||||
// pub fn from_decimal_and_denom(
|
||||
// amount: Decimal,
|
||||
// denom: String,
|
||||
// ) -> Result<MajorCurrencyAmount, TypesError> {
|
||||
// if denom.starts_with('u') || denom.starts_with('U') {
|
||||
// return MajorCurrencyAmount::from_minor_decimal_and_denom(amount, &denom);
|
||||
// }
|
||||
// if let Ok(denom) = CurrencyDenom::from_str(denom.as_str()) {
|
||||
// return Ok(MajorCurrencyAmount {
|
||||
// amount: MajorAmountString(amount.to_string()),
|
||||
// denom,
|
||||
// });
|
||||
// }
|
||||
// Err(TypesError::InvalidDenom(denom))
|
||||
// }
|
||||
// pub fn from_cosmrs_decimal_and_denom(
|
||||
// amount: CosmosDecimal,
|
||||
// denom: String,
|
||||
// ) -> Result<MajorCurrencyAmount, TypesError> {
|
||||
// if denom.starts_with('u') || denom.starts_with('U') {
|
||||
// return match Decimal::from_str(&amount.to_string()) {
|
||||
// Ok(amount) => MajorCurrencyAmount::from_minor_decimal_and_denom(amount, &denom),
|
||||
// Err(_e) => Err(TypesError::InvalidAmount(amount.to_string())),
|
||||
// };
|
||||
// }
|
||||
//
|
||||
// if let Ok(denom) = CurrencyDenom::from_str(denom.as_str()) {
|
||||
// return Ok(MajorCurrencyAmount {
|
||||
// amount: MajorAmountString(amount.to_string()),
|
||||
// denom,
|
||||
// });
|
||||
// }
|
||||
// Err(TypesError::InvalidDenom(denom))
|
||||
// }
|
||||
//
|
||||
// pub fn into_cosmos_coin(self) -> CosmosCoin {
|
||||
// self.coin.into()
|
||||
// }
|
||||
//
|
||||
// pub fn to_minor_uint128(&self) -> Result<Uint128, TypesError> {
|
||||
// if self.amount.0.contains('.') {
|
||||
// // has a decimal point (Cosmos assumes "." is the decimal separator)
|
||||
// let parts = self.amount.0.split('.');
|
||||
// let str = parts.collect_vec();
|
||||
// if str.is_empty() || str.len() > 2 {
|
||||
// return Err(TypesError::InvalidAmount("Amount is invalid".to_string()));
|
||||
// }
|
||||
// if str.len() == 2 {
|
||||
// // has a decimal, so check decimal places first
|
||||
// if str[1].len() > 6 {
|
||||
// return Err(TypesError::InvalidDenom(
|
||||
// "Amount is invalid, only 6 decimal places of precision are allowed"
|
||||
// .to_string(),
|
||||
// ));
|
||||
// }
|
||||
//
|
||||
// // so multiple whole part by 1e6 and add decimal part
|
||||
// let whole_part = Uint128::from_str(str[0])? * Uint128::from(1_000_000u64);
|
||||
//
|
||||
// // TODO: has Rust got anything that deals with fixed point values, or parsing from format strings? Leading zeroes are causing issues
|
||||
// return match format!("0.{}", str[1]).parse::<f64>() {
|
||||
// Ok(decimal_part_float) => {
|
||||
// // this makes an assumption that 6 decimal places of f64 can never lose precision
|
||||
// let truncated = (decimal_part_float * 1_000_000.).trunc() as u32;
|
||||
// let decimal_part = Uint128::from(truncated);
|
||||
// let sum = whole_part + decimal_part;
|
||||
// Ok(sum)
|
||||
// }
|
||||
// Err(_e) => Err(TypesError::InvalidAmount(
|
||||
// "Amount decimal part is invalid".to_string(),
|
||||
// )),
|
||||
// };
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// let major = Uint128::from_str(&self.amount.0)?;
|
||||
// let scaled = major * Uint128::new(1_000_000u128);
|
||||
// Ok(scaled)
|
||||
// }
|
||||
|
||||
// pub fn denom_to_string(&self) -> String {
|
||||
// self.denom.to_string()
|
||||
// }
|
||||
}
|
||||
|
||||
impl Display for MajorCurrencyAmount {
|
||||
|
||||
@@ -14,9 +14,6 @@ use validator_client::nymd::GasPrice;
|
||||
pub struct Gas {
|
||||
/// units of gas used
|
||||
pub gas_units: u64,
|
||||
//
|
||||
// /// gas units converted to fee as major coin amount
|
||||
// pub amount: MajorCurrencyAmount,
|
||||
}
|
||||
|
||||
impl Gas {
|
||||
|
||||
@@ -62,7 +62,7 @@ pub fn migrate(_deps: DepsMut<'_>, _env: Env, _msg: MigrateMsg) -> Result<Respon
|
||||
pub mod tests {
|
||||
use super::*;
|
||||
use bandwidth_claim_contract::payment::PagedPaymentResponse;
|
||||
use config::defaults::DENOM;
|
||||
use config::defaults::MIX_DENOM;
|
||||
use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info};
|
||||
use cosmwasm_std::{coins, from_binary};
|
||||
|
||||
@@ -91,11 +91,11 @@ pub mod tests {
|
||||
|
||||
// Contract balance should match what we initialized it as
|
||||
assert_eq!(
|
||||
coins(0, DENOM),
|
||||
coins(0, MIX_DENOM.base),
|
||||
vec![deps
|
||||
.as_ref()
|
||||
.querier
|
||||
.query_balance(env.contract.address, DENOM)
|
||||
.query_balance(env.contract.address, MIX_DENOM.base)
|
||||
.unwrap()]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ mod tests {
|
||||
use super::*;
|
||||
use crate::support::tests::helpers::*;
|
||||
use coconut_bandwidth_contract_common::deposit::DepositData;
|
||||
use config::defaults::DENOM;
|
||||
use config::defaults::MIX_DENOM;
|
||||
use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info};
|
||||
use cosmwasm_std::{coins, Addr};
|
||||
use cw_multi_test::Executor;
|
||||
@@ -84,20 +84,20 @@ mod tests {
|
||||
|
||||
// Contract balance should be 0
|
||||
assert_eq!(
|
||||
coins(0, DENOM),
|
||||
coins(0, MIX_DENOM.base),
|
||||
vec![deps
|
||||
.as_ref()
|
||||
.querier
|
||||
.query_balance(env.contract.address, DENOM)
|
||||
.query_balance(env.contract.address, MIX_DENOM.base)
|
||||
.unwrap()]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn deposit_and_release() {
|
||||
let init_funds = coins(10, DENOM);
|
||||
let deposit_funds = coins(1, DENOM);
|
||||
let release_funds = coins(2, DENOM);
|
||||
let init_funds = coins(10, MIX_DENOM.base);
|
||||
let deposit_funds = coins(1, MIX_DENOM.base);
|
||||
let release_funds = coins(2, MIX_DENOM.base);
|
||||
let mut app = mock_app(&init_funds);
|
||||
let multisig_addr = String::from(MULTISIG_CONTRACT);
|
||||
let pool_addr = String::from(POOL_CONTRACT);
|
||||
@@ -157,7 +157,7 @@ mod tests {
|
||||
&[],
|
||||
)
|
||||
.unwrap();
|
||||
let pool_bal = app.wrap().query_balance(pool_addr, DENOM).unwrap();
|
||||
let pool_bal = app.wrap().query_balance(pool_addr, MIX_DENOM.base).unwrap();
|
||||
assert_eq!(pool_bal, deposit_funds[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ use cosmwasm_std::StdError;
|
||||
use cw_controllers::AdminError;
|
||||
use thiserror::Error;
|
||||
|
||||
use config::defaults::DENOM;
|
||||
use config::defaults::MIX_DENOM;
|
||||
|
||||
/// Custom errors for contract failure conditions.
|
||||
///
|
||||
@@ -22,7 +22,7 @@ pub enum ContractError {
|
||||
#[error("No coin was sent for voucher")]
|
||||
NoCoin,
|
||||
|
||||
#[error("Wrong coin denomination, you must send {}", DENOM)]
|
||||
#[error("Wrong coin denomination, you must send {}", MIX_DENOM.base)]
|
||||
WrongDenom,
|
||||
|
||||
#[error("There aren't enough funds in the contract")]
|
||||
|
||||
@@ -11,7 +11,7 @@ use coconut_bandwidth_contract_common::events::{
|
||||
DEPOSITED_FUNDS_EVENT_TYPE, DEPOSIT_ENCRYPTION_KEY, DEPOSIT_IDENTITY_KEY, DEPOSIT_INFO,
|
||||
DEPOSIT_VALUE,
|
||||
};
|
||||
use config::defaults::DENOM;
|
||||
use config::defaults::MIX_DENOM;
|
||||
|
||||
pub(crate) fn deposit_funds(
|
||||
_deps: DepsMut<'_>,
|
||||
@@ -25,7 +25,7 @@ pub(crate) fn deposit_funds(
|
||||
if info.funds.len() > 1 {
|
||||
return Err(ContractError::MultipleDenoms);
|
||||
}
|
||||
if info.funds[0].denom != DENOM {
|
||||
if info.funds[0].denom != MIX_DENOM.base {
|
||||
return Err(ContractError::WrongDenom);
|
||||
}
|
||||
|
||||
@@ -45,10 +45,12 @@ pub(crate) fn release_funds(
|
||||
info: MessageInfo,
|
||||
funds: Coin,
|
||||
) -> Result<Response, ContractError> {
|
||||
if funds.denom != DENOM {
|
||||
if funds.denom != MIX_DENOM.base {
|
||||
return Err(ContractError::WrongDenom);
|
||||
}
|
||||
let current_balance = deps.querier.query_balance(env.contract.address, DENOM)?;
|
||||
let current_balance = deps
|
||||
.querier
|
||||
.query_balance(env.contract.address, MIX_DENOM.base)?;
|
||||
if funds.amount > current_balance.amount {
|
||||
return Err(ContractError::NotEnoughFunds);
|
||||
}
|
||||
@@ -90,7 +92,7 @@ mod tests {
|
||||
Err(ContractError::NoCoin)
|
||||
);
|
||||
|
||||
let coin = Coin::new(1000000, DENOM);
|
||||
let coin = Coin::new(1000000, MIX_DENOM.base);
|
||||
let second_coin = Coin::new(1000000, "some_denom");
|
||||
|
||||
let info = mock_info("requester", &[coin, second_coin.clone()]);
|
||||
@@ -120,7 +122,7 @@ mod tests {
|
||||
verification_key.clone(),
|
||||
encryption_key.clone(),
|
||||
);
|
||||
let coin = Coin::new(deposit_value, DENOM);
|
||||
let coin = Coin::new(deposit_value, MIX_DENOM.base);
|
||||
let info = mock_info("requester", &[coin]);
|
||||
|
||||
let tx = deposit_funds(deps.as_mut(), env.clone(), info, data).unwrap();
|
||||
@@ -169,7 +171,7 @@ mod tests {
|
||||
let mut deps = helpers::init_contract();
|
||||
let env = mock_env();
|
||||
let invalid_admin = "invalid admin";
|
||||
let funds = Coin::new(1, DENOM);
|
||||
let funds = Coin::new(1, MIX_DENOM.base);
|
||||
|
||||
let err = release_funds(
|
||||
deps.as_mut(),
|
||||
@@ -205,7 +207,7 @@ mod tests {
|
||||
fn valid_release() {
|
||||
let mut deps = helpers::init_contract();
|
||||
let env = mock_env();
|
||||
let coin = Coin::new(1, DENOM);
|
||||
let coin = Coin::new(1, MIX_DENOM.base);
|
||||
|
||||
deps.querier
|
||||
.update_balance(env.contract.address.clone(), vec![coin.clone()]);
|
||||
|
||||
@@ -200,7 +200,7 @@ pub(crate) fn query_mixnode_delegations_paged(
|
||||
pub(crate) mod tests {
|
||||
use super::*;
|
||||
use crate::support::tests::test_helpers;
|
||||
use config::defaults::DENOM;
|
||||
use config::defaults::MIX_DENOM;
|
||||
use cosmwasm_std::{coin, Addr, Storage};
|
||||
use rand::Rng;
|
||||
|
||||
@@ -385,7 +385,7 @@ pub(crate) mod tests {
|
||||
let delegation = Delegation::new(
|
||||
delegation_owner.clone(),
|
||||
node_identity.clone(),
|
||||
coin(1234, DENOM),
|
||||
coin(1234, MIX_DENOM.base),
|
||||
1234,
|
||||
None,
|
||||
);
|
||||
@@ -433,7 +433,7 @@ pub(crate) mod tests {
|
||||
let delegation = Delegation::new(
|
||||
delegation_owner2,
|
||||
node_identity1.clone(),
|
||||
coin(1234, DENOM),
|
||||
coin(1234, MIX_DENOM.base),
|
||||
1234,
|
||||
None,
|
||||
);
|
||||
@@ -460,7 +460,7 @@ pub(crate) mod tests {
|
||||
let delegation = Delegation::new(
|
||||
delegation_owner1.clone(),
|
||||
node_identity2,
|
||||
coin(1234, DENOM),
|
||||
coin(1234, MIX_DENOM.base),
|
||||
1234,
|
||||
None,
|
||||
);
|
||||
|
||||
@@ -77,7 +77,7 @@ mod tests {
|
||||
mod reverse_mix_delegations {
|
||||
use super::*;
|
||||
use crate::support::tests::test_helpers;
|
||||
use config::defaults::DENOM;
|
||||
use config::defaults::MIX_DENOM;
|
||||
use cosmwasm_std::testing::mock_env;
|
||||
use cosmwasm_std::{coin, Order};
|
||||
use mixnet_contract_common::Delegation;
|
||||
@@ -87,7 +87,7 @@ mod tests {
|
||||
let mut deps = test_helpers::init_contract();
|
||||
let node_identity: IdentityKey = "foo".into();
|
||||
let delegation_owner = Addr::unchecked("bar");
|
||||
let delegation = coin(12345, DENOM);
|
||||
let delegation = coin(12345, MIX_DENOM.base);
|
||||
|
||||
let dummy_data = Delegation::new(
|
||||
delegation_owner.clone(),
|
||||
@@ -125,7 +125,7 @@ mod tests {
|
||||
let node_identity2: IdentityKey = "foo2".into();
|
||||
let delegation_owner1 = Addr::unchecked("bar");
|
||||
let delegation_owner2 = Addr::unchecked("bar2");
|
||||
let delegation = coin(12345, DENOM);
|
||||
let delegation = coin(12345, MIX_DENOM.base);
|
||||
|
||||
assert!(test_helpers::read_delegation(
|
||||
deps.as_ref().storage,
|
||||
|
||||
@@ -6,7 +6,7 @@ use super::storage::{self, PENDING_DELEGATION_EVENTS};
|
||||
use crate::error::ContractError;
|
||||
use crate::mixnet_contract_settings::storage as mixnet_params_storage;
|
||||
use crate::mixnodes::storage as mixnodes_storage;
|
||||
use config::defaults::DENOM;
|
||||
use config::defaults::MIX_DENOM;
|
||||
use cosmwasm_std::{
|
||||
coins, wasm_execute, Addr, Api, BankMsg, Coin, DepsMut, Env, Event, MessageInfo, Order,
|
||||
Response, Storage, Uint128, WasmMsg,
|
||||
@@ -85,7 +85,7 @@ fn validate_delegation_stake(mut delegation: Vec<Coin>) -> Result<Coin, Contract
|
||||
}
|
||||
|
||||
// check that the denomination is correct
|
||||
if delegation[0].denom != DENOM {
|
||||
if delegation[0].denom != MIX_DENOM.base {
|
||||
return Err(ContractError::WrongDenom {});
|
||||
}
|
||||
|
||||
@@ -389,7 +389,7 @@ pub(crate) fn try_reconcile_undelegation(
|
||||
.as_ref()
|
||||
.unwrap_or(&pending_undelegate.delegate())
|
||||
.to_string(),
|
||||
amount: coins(total_funds.u128(), DENOM),
|
||||
amount: coins(total_funds.u128(), MIX_DENOM.base),
|
||||
})
|
||||
} else {
|
||||
None
|
||||
@@ -401,7 +401,7 @@ pub(crate) fn try_reconcile_undelegation(
|
||||
let msg = Some(VestingContractExecuteMsg::TrackUndelegation {
|
||||
owner: pending_undelegate.delegate().as_str().to_string(),
|
||||
mix_identity: pending_undelegate.mix_identity(),
|
||||
amount: Coin::new(total_funds.u128(), DENOM),
|
||||
amount: Coin::new(total_funds.u128(), MIX_DENOM.base),
|
||||
});
|
||||
|
||||
wasm_msg = Some(wasm_execute(proxy, &msg, vec![one_ucoin()])?);
|
||||
@@ -492,7 +492,7 @@ mod tests {
|
||||
assert_eq!(
|
||||
Err(ContractError::MultipleDenoms),
|
||||
validate_delegation_stake(vec![
|
||||
coin(123, DENOM),
|
||||
coin(123, MIX_DENOM.base),
|
||||
coin(123, "BTC"),
|
||||
coin(123, "DOGE")
|
||||
])
|
||||
@@ -511,16 +511,16 @@ mod tests {
|
||||
fn stake_coin_must_have_value_greater_than_zero() {
|
||||
assert_eq!(
|
||||
Err(ContractError::EmptyDelegation),
|
||||
validate_delegation_stake(coins(0, DENOM))
|
||||
validate_delegation_stake(coins(0, MIX_DENOM.base))
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn stake_can_have_any_positive_value() {
|
||||
// this might change in the future, but right now an arbitrary (positive) value can be delegated
|
||||
assert!(validate_delegation_stake(coins(1, DENOM)).is_ok());
|
||||
assert!(validate_delegation_stake(coins(123, DENOM)).is_ok());
|
||||
assert!(validate_delegation_stake(coins(10000000000, DENOM)).is_ok());
|
||||
assert!(validate_delegation_stake(coins(1, MIX_DENOM.base)).is_ok());
|
||||
assert!(validate_delegation_stake(coins(123, MIX_DENOM.base)).is_ok());
|
||||
assert!(validate_delegation_stake(coins(10000000000, MIX_DENOM.base)).is_ok());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -543,7 +543,7 @@ mod tests {
|
||||
try_delegate_to_mixnode(
|
||||
deps.as_mut(),
|
||||
mock_env(),
|
||||
mock_info("sender", &coins(123, DENOM)),
|
||||
mock_info("sender", &coins(123, MIX_DENOM.base)),
|
||||
"non-existent-mix-identity".into(),
|
||||
)
|
||||
);
|
||||
@@ -559,7 +559,7 @@ mod tests {
|
||||
deps.as_mut(),
|
||||
);
|
||||
let delegation_owner = Addr::unchecked("sender");
|
||||
let delegation = coin(123, DENOM);
|
||||
let delegation = coin(123, MIX_DENOM.base);
|
||||
assert!(try_delegate_to_mixnode(
|
||||
deps.as_mut(),
|
||||
mock_env(),
|
||||
@@ -616,7 +616,7 @@ mod tests {
|
||||
try_delegate_to_mixnode(
|
||||
deps.as_mut(),
|
||||
mock_env(),
|
||||
mock_info(delegation_owner.as_str(), &coins(123, DENOM)),
|
||||
mock_info(delegation_owner.as_str(), &coins(123, MIX_DENOM.base)),
|
||||
identity,
|
||||
)
|
||||
);
|
||||
@@ -637,7 +637,7 @@ mod tests {
|
||||
tests::fixtures::good_mixnode_pledge(),
|
||||
deps.as_mut(),
|
||||
);
|
||||
let delegation = coin(123, DENOM);
|
||||
let delegation = coin(123, MIX_DENOM.base);
|
||||
let delegation_owner = Addr::unchecked("sender");
|
||||
assert!(try_delegate_to_mixnode(
|
||||
deps.as_mut(),
|
||||
@@ -687,8 +687,8 @@ mod tests {
|
||||
deps.as_mut(),
|
||||
);
|
||||
let delegation_owner = Addr::unchecked("sender");
|
||||
let delegation1 = coin(100, DENOM);
|
||||
let delegation2 = coin(50, DENOM);
|
||||
let delegation1 = coin(100, MIX_DENOM.base);
|
||||
let delegation2 = coin(50, MIX_DENOM.base);
|
||||
|
||||
let mut env = mock_env();
|
||||
|
||||
@@ -715,7 +715,7 @@ mod tests {
|
||||
// let expected = Delegation::new(
|
||||
// delegation_owner.clone(),
|
||||
// identity.clone(),
|
||||
// coin(delegation1.amount.u128() + delegation2.amount.u128(), DENOM),
|
||||
// coin(delegation1.amount.u128() + delegation2.amount.u128(), MIX_DENOM.base),
|
||||
// mock_env().block.height,
|
||||
// None,
|
||||
// );
|
||||
@@ -750,7 +750,7 @@ mod tests {
|
||||
deps.as_mut(),
|
||||
);
|
||||
let delegation_owner = Addr::unchecked("sender");
|
||||
let delegation = coin(100, DENOM);
|
||||
let delegation = coin(100, MIX_DENOM.base);
|
||||
let env1 = mock_env();
|
||||
let mut env2 = mock_env();
|
||||
let initial_height = env1.block.height;
|
||||
@@ -815,8 +815,8 @@ mod tests {
|
||||
);
|
||||
let delegation_owner1 = Addr::unchecked("sender1");
|
||||
let delegation_owner2 = Addr::unchecked("sender2");
|
||||
let delegation1 = coin(100, DENOM);
|
||||
let delegation2 = coin(120, DENOM);
|
||||
let delegation1 = coin(100, MIX_DENOM.base);
|
||||
let delegation2 = coin(120, MIX_DENOM.base);
|
||||
let env1 = mock_env();
|
||||
let mut env2 = mock_env();
|
||||
let initial_height = env1.block.height;
|
||||
@@ -891,7 +891,7 @@ mod tests {
|
||||
try_delegate_to_mixnode(
|
||||
deps.as_mut(),
|
||||
mock_env(),
|
||||
mock_info(delegation_owner.as_str(), &coins(100, DENOM)),
|
||||
mock_info(delegation_owner.as_str(), &coins(100, MIX_DENOM.base)),
|
||||
identity.clone(),
|
||||
)
|
||||
.unwrap();
|
||||
@@ -903,7 +903,7 @@ mod tests {
|
||||
try_delegate_to_mixnode(
|
||||
deps.as_mut(),
|
||||
mock_env(),
|
||||
mock_info(delegation_owner.as_str(), &coins(50, DENOM)),
|
||||
mock_info(delegation_owner.as_str(), &coins(50, MIX_DENOM.base)),
|
||||
identity,
|
||||
)
|
||||
);
|
||||
@@ -928,14 +928,14 @@ mod tests {
|
||||
assert!(try_delegate_to_mixnode(
|
||||
deps.as_mut(),
|
||||
mock_env(),
|
||||
mock_info(delegation_owner.as_str(), &coins(123, DENOM)),
|
||||
mock_info(delegation_owner.as_str(), &coins(123, MIX_DENOM.base)),
|
||||
identity1.clone(),
|
||||
)
|
||||
.is_ok());
|
||||
assert!(try_delegate_to_mixnode(
|
||||
deps.as_mut(),
|
||||
mock_env(),
|
||||
mock_info(delegation_owner.as_str(), &coins(42, DENOM)),
|
||||
mock_info(delegation_owner.as_str(), &coins(42, MIX_DENOM.base)),
|
||||
identity2.clone(),
|
||||
)
|
||||
.is_ok());
|
||||
@@ -945,7 +945,7 @@ mod tests {
|
||||
let expected1 = Delegation::new(
|
||||
delegation_owner.clone(),
|
||||
identity1.clone(),
|
||||
coin(123, DENOM),
|
||||
coin(123, MIX_DENOM.base),
|
||||
mock_env().block.height,
|
||||
None,
|
||||
);
|
||||
@@ -953,7 +953,7 @@ mod tests {
|
||||
let expected2 = Delegation::new(
|
||||
delegation_owner.clone(),
|
||||
identity2.clone(),
|
||||
coin(42, DENOM),
|
||||
coin(42, MIX_DENOM.base),
|
||||
mock_env().block.height,
|
||||
None,
|
||||
);
|
||||
@@ -989,8 +989,8 @@ mod tests {
|
||||
tests::fixtures::good_mixnode_pledge(),
|
||||
deps.as_mut(),
|
||||
);
|
||||
let delegation1 = coin(123, DENOM);
|
||||
let delegation2 = coin(234, DENOM);
|
||||
let delegation1 = coin(123, MIX_DENOM.base);
|
||||
let delegation2 = coin(234, MIX_DENOM.base);
|
||||
assert!(try_delegate_to_mixnode(
|
||||
deps.as_mut(),
|
||||
mock_env(),
|
||||
@@ -1026,7 +1026,7 @@ mod tests {
|
||||
deps.as_mut(),
|
||||
);
|
||||
let delegation_owner = Addr::unchecked("sender");
|
||||
let delegation_amount = coin(100, DENOM);
|
||||
let delegation_amount = coin(100, MIX_DENOM.base);
|
||||
try_delegate_to_mixnode(
|
||||
deps.as_mut(),
|
||||
mock_env(),
|
||||
@@ -1118,7 +1118,7 @@ mod tests {
|
||||
try_delegate_to_mixnode(
|
||||
deps.as_mut(),
|
||||
mock_env(),
|
||||
mock_info(delegation_owner.as_str(), &coins(100, DENOM)),
|
||||
mock_info(delegation_owner.as_str(), &coins(100, MIX_DENOM.base)),
|
||||
identity.clone(),
|
||||
)
|
||||
.unwrap();
|
||||
@@ -1137,7 +1137,7 @@ mod tests {
|
||||
let expected_response = Response::new()
|
||||
.add_message(BankMsg::Send {
|
||||
to_address: delegation_owner.clone().into(),
|
||||
amount: coins(100, DENOM),
|
||||
amount: coins(100, MIX_DENOM.base),
|
||||
})
|
||||
.add_event(new_undelegation_event(
|
||||
&delegation_owner,
|
||||
@@ -1188,7 +1188,7 @@ mod tests {
|
||||
try_delegate_to_mixnode(
|
||||
deps.as_mut(),
|
||||
mock_env(),
|
||||
mock_info(delegation_owner.as_str(), &coins(100, DENOM)),
|
||||
mock_info(delegation_owner.as_str(), &coins(100, MIX_DENOM.base)),
|
||||
identity.clone(),
|
||||
)
|
||||
.unwrap();
|
||||
@@ -1207,7 +1207,7 @@ mod tests {
|
||||
let expected_response = Response::new()
|
||||
.add_message(BankMsg::Send {
|
||||
to_address: delegation_owner.clone().into(),
|
||||
amount: coins(100, DENOM),
|
||||
amount: coins(100, MIX_DENOM.base),
|
||||
})
|
||||
.add_event(new_undelegation_event(
|
||||
&delegation_owner,
|
||||
@@ -1251,8 +1251,8 @@ mod tests {
|
||||
);
|
||||
let delegation_owner1 = Addr::unchecked("sender1");
|
||||
let delegation_owner2 = Addr::unchecked("sender2");
|
||||
let delegation1 = coin(123, DENOM);
|
||||
let delegation2 = coin(234, DENOM);
|
||||
let delegation1 = coin(123, MIX_DENOM.base);
|
||||
let delegation2 = coin(234, MIX_DENOM.base);
|
||||
assert!(try_delegate_to_mixnode(
|
||||
deps.as_mut(),
|
||||
mock_env(),
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use config::defaults::DENOM;
|
||||
use config::defaults::MIX_DENOM;
|
||||
use cosmwasm_std::{Addr, StdError};
|
||||
use mixnet_contract_common::{error::MixnetContractError, IdentityKey};
|
||||
use thiserror::Error;
|
||||
@@ -33,13 +33,13 @@ pub enum ContractError {
|
||||
#[error("MIXNET ({}): Unauthorized", line!())]
|
||||
Unauthorized,
|
||||
|
||||
#[error("MIXNET ({}): Wrong coin denomination, you must send {}", line!(), DENOM)]
|
||||
#[error("MIXNET ({}): Wrong coin denomination, you must send {}", line!(), MIX_DENOM.base)]
|
||||
WrongDenom,
|
||||
|
||||
#[error("MIXNET ({}): Received multiple coin types during staking", line!())]
|
||||
MultipleDenoms,
|
||||
|
||||
#[error("MIXNET ({}): No coin was sent for the bonding, you must send {}", line!(), DENOM)]
|
||||
#[error("MIXNET ({}): No coin was sent for the bonding, you must send {}", line!(), MIX_DENOM.base)]
|
||||
NoBondFound,
|
||||
|
||||
#[error("MIXNET ({}): Provided active set size is bigger than the rewarded set", line!())]
|
||||
|
||||
@@ -36,7 +36,7 @@ pub(crate) fn gateways<'a>() -> IndexedMap<'a, IdentityKeyRef<'a>, GatewayBond,
|
||||
mod tests {
|
||||
use super::super::storage;
|
||||
use crate::support::tests;
|
||||
use config::defaults::DENOM;
|
||||
use config::defaults::MIX_DENOM;
|
||||
use cosmwasm_std::testing::MockStorage;
|
||||
use cosmwasm_std::StdResult;
|
||||
use cosmwasm_std::Storage;
|
||||
@@ -84,7 +84,7 @@ mod tests {
|
||||
let pledge_amount = 1000;
|
||||
|
||||
let gateway_bond = GatewayBond {
|
||||
pledge_amount: coin(pledge_amount, DENOM),
|
||||
pledge_amount: coin(pledge_amount, MIX_DENOM.base),
|
||||
owner: node_owner,
|
||||
block_height: 12_345,
|
||||
gateway: Gateway {
|
||||
|
||||
@@ -5,7 +5,7 @@ use super::storage;
|
||||
use crate::error::ContractError;
|
||||
use crate::mixnet_contract_settings::storage as mixnet_params_storage;
|
||||
use crate::support::helpers::{ensure_no_existing_bond, validate_node_identity_signature};
|
||||
use config::defaults::DENOM;
|
||||
use config::defaults::MIX_DENOM;
|
||||
use cosmwasm_std::{
|
||||
wasm_execute, Addr, BankMsg, Coin, DepsMut, Env, MessageInfo, Response, Uint128,
|
||||
};
|
||||
@@ -203,7 +203,7 @@ fn validate_gateway_pledge(
|
||||
}
|
||||
|
||||
// check that the denomination is correct
|
||||
if pledge[0].denom != DENOM {
|
||||
if pledge[0].denom != MIX_DENOM.base {
|
||||
return Err(ContractError::WrongDenom {});
|
||||
}
|
||||
|
||||
@@ -226,7 +226,7 @@ pub mod tests {
|
||||
use crate::gateways::transactions::validate_gateway_pledge;
|
||||
use crate::support::tests;
|
||||
use crate::support::tests::test_helpers;
|
||||
use config::defaults::DENOM;
|
||||
use config::defaults::MIX_DENOM;
|
||||
use cosmwasm_std::testing::{mock_env, mock_info};
|
||||
use cosmwasm_std::{coins, BankMsg, Response};
|
||||
use cosmwasm_std::{from_binary, Addr, Uint128};
|
||||
@@ -238,7 +238,7 @@ pub mod tests {
|
||||
|
||||
// if we fail validation (by say not sending enough funds
|
||||
let insufficient_bond = Into::<u128>::into(INITIAL_GATEWAY_PLEDGE) - 1;
|
||||
let info = mock_info("anyone", &coins(insufficient_bond, DENOM));
|
||||
let info = mock_info("anyone", &coins(insufficient_bond, MIX_DENOM.base));
|
||||
let (msg, _) = tests::messages::valid_bond_gateway_msg("anyone");
|
||||
|
||||
// we are informed that we didn't send enough funds
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use config::defaults::DENOM;
|
||||
use config::defaults::MIX_DENOM;
|
||||
use cosmwasm_std::{StdResult, Storage, Uint128};
|
||||
use cw_storage_plus::{Index, IndexList, IndexedSnapshotMap, Map, Strategy, UniqueIndex};
|
||||
use mixnet_contract_common::{
|
||||
@@ -171,7 +171,7 @@ pub(crate) fn read_full_mixnode_bond(
|
||||
Ok(Some(MixNodeBond {
|
||||
pledge_amount: stored_bond.pledge_amount,
|
||||
total_delegation: Coin {
|
||||
denom: DENOM.to_owned(),
|
||||
denom: MIX_DENOM.base.to_owned(),
|
||||
amount: total_delegation.unwrap_or_default(),
|
||||
},
|
||||
owner: stored_bond.owner,
|
||||
@@ -190,7 +190,7 @@ mod tests {
|
||||
use super::super::storage;
|
||||
use super::*;
|
||||
use crate::support::tests;
|
||||
use config::defaults::DENOM;
|
||||
use config::defaults::MIX_DENOM;
|
||||
use cosmwasm_std::testing::MockStorage;
|
||||
use cosmwasm_std::{coin, Addr, Uint128};
|
||||
use mixnet_contract_common::{IdentityKey, MixNode};
|
||||
@@ -223,7 +223,7 @@ mod tests {
|
||||
let pledge_value = 1000000000;
|
||||
|
||||
let mixnode_bond = StoredMixnodeBond {
|
||||
pledge_amount: coin(pledge_value, DENOM),
|
||||
pledge_amount: coin(pledge_value, MIX_DENOM.base),
|
||||
owner: node_owner,
|
||||
layer: Layer::One,
|
||||
block_height: 12_345,
|
||||
|
||||
@@ -7,7 +7,7 @@ use crate::mixnet_contract_settings::storage as mixnet_params_storage;
|
||||
use crate::mixnodes::layer_queries::query_layer_distribution;
|
||||
use crate::mixnodes::storage::StoredMixnodeBond;
|
||||
use crate::support::helpers::{ensure_no_existing_bond, validate_node_identity_signature};
|
||||
use config::defaults::DENOM;
|
||||
use config::defaults::MIX_DENOM;
|
||||
use cosmwasm_std::{
|
||||
wasm_execute, Addr, BankMsg, Coin, DepsMut, Env, MessageInfo, Response, Storage, Uint128,
|
||||
};
|
||||
@@ -364,7 +364,7 @@ fn validate_mixnode_pledge(
|
||||
}
|
||||
|
||||
// check that the denomination is correct
|
||||
if pledge[0].denom != DENOM {
|
||||
if pledge[0].denom != MIX_DENOM.base {
|
||||
return Err(ContractError::WrongDenom {});
|
||||
}
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ pub(crate) mod tests {
|
||||
use crate::delegations::transactions::try_delegate_to_mixnode;
|
||||
use crate::interval::storage::{save_epoch, save_epoch_reward_params};
|
||||
use crate::rewards::transactions::try_reward_mixnode;
|
||||
use config::defaults::DENOM;
|
||||
use config::defaults::MIX_DENOM;
|
||||
use cosmwasm_std::{coin, Addr};
|
||||
use mixnet_contract_common::{
|
||||
Interval, RewardingResult, RewardingStatus, MIXNODE_DELEGATORS_PAGE_LIMIT,
|
||||
@@ -181,7 +181,10 @@ pub(crate) mod tests {
|
||||
try_delegate_to_mixnode(
|
||||
deps.as_mut(),
|
||||
env.clone(),
|
||||
mock_info(&*format!("delegator{:04}", i), &[coin(200_000000, DENOM)]),
|
||||
mock_info(
|
||||
&*format!("delegator{:04}", i),
|
||||
&[coin(200_000000, MIX_DENOM.base)],
|
||||
),
|
||||
node_identity.clone(),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
@@ -14,7 +14,7 @@ use crate::mixnodes::storage::mixnodes;
|
||||
use crate::mixnodes::storage::{self as mixnodes_storage, StoredMixnodeBond};
|
||||
use crate::rewards::helpers;
|
||||
use crate::support::helpers::is_authorized;
|
||||
use config::defaults::DENOM;
|
||||
use config::defaults::MIX_DENOM;
|
||||
use cosmwasm_std::{
|
||||
coins, wasm_execute, Addr, Api, BankMsg, Coin, DepsMut, Env, MessageInfo, Order, Response,
|
||||
Storage, Uint128,
|
||||
@@ -105,7 +105,7 @@ fn _try_claim_operator_reward(
|
||||
|
||||
let return_tokens = BankMsg::Send {
|
||||
to_address: proxy.as_ref().unwrap_or(&owner).to_string(),
|
||||
amount: coins(reward.u128(), DENOM),
|
||||
amount: coins(reward.u128(), MIX_DENOM.base),
|
||||
};
|
||||
|
||||
let mut response = Response::default()
|
||||
@@ -115,7 +115,7 @@ fn _try_claim_operator_reward(
|
||||
if let Some(proxy) = proxy {
|
||||
let msg = Some(VestingContractExecuteMsg::TrackReward {
|
||||
address: owner.to_string(),
|
||||
amount: Coin::new(reward.u128(), DENOM),
|
||||
amount: Coin::new(reward.u128(), MIX_DENOM.base),
|
||||
});
|
||||
|
||||
let wasm_msg = wasm_execute(proxy, &msg, vec![one_ucoin()])?;
|
||||
@@ -153,7 +153,7 @@ pub fn _try_claim_delegator_reward(
|
||||
|
||||
let return_tokens = BankMsg::Send {
|
||||
to_address: proxy.as_ref().unwrap_or(&owner).to_string(),
|
||||
amount: coins(reward.u128(), DENOM),
|
||||
amount: coins(reward.u128(), MIX_DENOM.base),
|
||||
};
|
||||
|
||||
let mut response =
|
||||
@@ -169,7 +169,7 @@ pub fn _try_claim_delegator_reward(
|
||||
if let Some(proxy) = proxy {
|
||||
let msg = Some(VestingContractExecuteMsg::TrackReward {
|
||||
address: owner.to_string(),
|
||||
amount: Coin::new(reward.u128(), DENOM),
|
||||
amount: Coin::new(reward.u128(), MIX_DENOM.base),
|
||||
});
|
||||
|
||||
let wasm_msg = wasm_execute(proxy, &msg, vec![one_ucoin()])?;
|
||||
@@ -436,7 +436,7 @@ pub fn _try_compound_delegator_reward(
|
||||
owner_address,
|
||||
Coin {
|
||||
amount: compounded_delegation,
|
||||
denom: DENOM.to_string(),
|
||||
denom: MIX_DENOM.base.to_string(),
|
||||
},
|
||||
proxy,
|
||||
)?;
|
||||
@@ -721,7 +721,7 @@ pub mod tests {
|
||||
use crate::support::tests;
|
||||
use crate::support::tests::test_helpers;
|
||||
use az::CheckedCast;
|
||||
use config::defaults::DENOM;
|
||||
use config::defaults::MIX_DENOM;
|
||||
use cosmwasm_std::testing::{mock_env, mock_info};
|
||||
use cosmwasm_std::{coin, coins, Addr, StdError, Timestamp, Uint128};
|
||||
use mixnet_contract_common::events::{
|
||||
@@ -737,7 +737,7 @@ pub mod tests {
|
||||
let mut deps = test_helpers::init_contract();
|
||||
let mut env = mock_env();
|
||||
let sender = rewarding_validator_address(&deps.storage).unwrap();
|
||||
let info = mock_info(&sender, &coins(1000, DENOM));
|
||||
let info = mock_info(&sender, &coins(1000, MIX_DENOM.base));
|
||||
crate::interval::transactions::init_epoch(&mut deps.storage, env.clone()).unwrap();
|
||||
|
||||
// bond the node
|
||||
@@ -878,7 +878,7 @@ pub mod tests {
|
||||
let initial_bond = 10000_000000;
|
||||
let initial_delegation = 20000_000000;
|
||||
let mixnode_bond = StoredMixnodeBond {
|
||||
pledge_amount: coin(initial_bond, DENOM),
|
||||
pledge_amount: coin(initial_bond, MIX_DENOM.base),
|
||||
owner: node_owner,
|
||||
layer: Layer::One,
|
||||
block_height: env.block.height,
|
||||
@@ -918,7 +918,7 @@ pub mod tests {
|
||||
&Delegation::new(
|
||||
Addr::unchecked("delegator"),
|
||||
node_identity.clone(),
|
||||
coin(initial_delegation, DENOM),
|
||||
coin(initial_delegation, MIX_DENOM.base),
|
||||
env.block.height,
|
||||
None,
|
||||
),
|
||||
@@ -1098,7 +1098,7 @@ pub mod tests {
|
||||
assert_eq!(circulating_supply, 750_000_000_000_000u128);
|
||||
|
||||
let sender = Addr::unchecked("alice");
|
||||
let stake = coins(10_000_000_000, DENOM);
|
||||
let stake = coins(10_000_000_000, MIX_DENOM.base);
|
||||
|
||||
let keypair = crypto::asymmetric::identity::KeyPair::new(&mut thread_rng());
|
||||
let owner_signature = keypair
|
||||
@@ -1151,14 +1151,14 @@ pub mod tests {
|
||||
let node_owner: Addr = Addr::unchecked("johnny");
|
||||
let node_identity_2 = test_helpers::add_mixnode(
|
||||
node_owner.as_str(),
|
||||
coins(10_000_000_000, DENOM),
|
||||
coins(10_000_000_000, MIX_DENOM.base),
|
||||
deps.as_mut(),
|
||||
);
|
||||
|
||||
try_delegate_to_mixnode(
|
||||
deps.as_mut(),
|
||||
mock_env(),
|
||||
mock_info("alice_d1", &[coin(8000_000000, DENOM)]),
|
||||
mock_info("alice_d1", &[coin(8000_000000, MIX_DENOM.base)]),
|
||||
node_identity_1.clone(),
|
||||
)
|
||||
.unwrap();
|
||||
@@ -1166,7 +1166,7 @@ pub mod tests {
|
||||
try_delegate_to_mixnode(
|
||||
deps.as_mut(),
|
||||
mock_env(),
|
||||
mock_info("alice_d2", &[coin(2000_000000, DENOM)]),
|
||||
mock_info("alice_d2", &[coin(2000_000000, MIX_DENOM.base)]),
|
||||
node_identity_1.clone(),
|
||||
)
|
||||
.unwrap();
|
||||
@@ -1174,7 +1174,7 @@ pub mod tests {
|
||||
try_delegate_to_mixnode(
|
||||
deps.as_mut(),
|
||||
mock_env(),
|
||||
mock_info("bob_d1", &[coin(8000_000000, DENOM)]),
|
||||
mock_info("bob_d1", &[coin(8000_000000, MIX_DENOM.base)]),
|
||||
node_identity_2.clone(),
|
||||
)
|
||||
.unwrap();
|
||||
@@ -1182,7 +1182,7 @@ pub mod tests {
|
||||
try_delegate_to_mixnode(
|
||||
deps.as_mut(),
|
||||
mock_env(),
|
||||
mock_info("bob_d2", &[coin(2000_000000, DENOM)]),
|
||||
mock_info("bob_d2", &[coin(2000_000000, MIX_DENOM.base)]),
|
||||
node_identity_2.clone(),
|
||||
)
|
||||
.unwrap();
|
||||
@@ -1190,14 +1190,14 @@ pub mod tests {
|
||||
let node_owner: Addr = Addr::unchecked("alicebob");
|
||||
let node_identity_3 = test_helpers::add_mixnode(
|
||||
node_owner.as_str(),
|
||||
coins(10_000_000_000 * 2, DENOM),
|
||||
coins(10_000_000_000 * 2, MIX_DENOM.base),
|
||||
deps.as_mut(),
|
||||
);
|
||||
|
||||
try_delegate_to_mixnode(
|
||||
deps.as_mut(),
|
||||
mock_env(),
|
||||
mock_info("alicebob_d1", &[coin(8000_000000 * 2, DENOM)]),
|
||||
mock_info("alicebob_d1", &[coin(8000_000000 * 2, MIX_DENOM.base)]),
|
||||
node_identity_3.clone(),
|
||||
)
|
||||
.unwrap();
|
||||
@@ -1205,7 +1205,7 @@ pub mod tests {
|
||||
try_delegate_to_mixnode(
|
||||
deps.as_mut(),
|
||||
mock_env(),
|
||||
mock_info("alicebob_d2", &[coin(2000_000000 * 2, DENOM)]),
|
||||
mock_info("alicebob_d2", &[coin(2000_000000 * 2, MIX_DENOM.base)]),
|
||||
node_identity_3.clone(),
|
||||
)
|
||||
.unwrap();
|
||||
@@ -1305,7 +1305,7 @@ pub mod tests {
|
||||
try_delegate_to_mixnode(
|
||||
deps.as_mut(),
|
||||
env.clone(),
|
||||
mock_info("alice_d1", &[coin(8000_000000, DENOM)]),
|
||||
mock_info("alice_d1", &[coin(8000_000000, MIX_DENOM.base)]),
|
||||
node_identity_1.clone(),
|
||||
)
|
||||
.unwrap();
|
||||
@@ -1533,14 +1533,14 @@ pub mod tests {
|
||||
let node_owner: Addr = Addr::unchecked("alice");
|
||||
let node_identity = test_helpers::add_mixnode(
|
||||
node_owner.as_str(),
|
||||
coins(10_000_000_000, DENOM),
|
||||
coins(10_000_000_000, MIX_DENOM.base),
|
||||
deps.as_mut(),
|
||||
);
|
||||
|
||||
try_delegate_to_mixnode(
|
||||
deps.as_mut(),
|
||||
mock_env(),
|
||||
mock_info("alice_d1", &[coin(8000_000000, DENOM)]),
|
||||
mock_info("alice_d1", &[coin(8000_000000, MIX_DENOM.base)]),
|
||||
node_identity.clone(),
|
||||
)
|
||||
.unwrap();
|
||||
@@ -1548,7 +1548,7 @@ pub mod tests {
|
||||
try_delegate_to_mixnode(
|
||||
deps.as_mut(),
|
||||
mock_env(),
|
||||
mock_info("alice_d2", &[coin(2000_000000, DENOM)]),
|
||||
mock_info("alice_d2", &[coin(2000_000000, MIX_DENOM.base)]),
|
||||
node_identity.clone(),
|
||||
)
|
||||
.unwrap();
|
||||
@@ -1698,7 +1698,7 @@ pub mod tests {
|
||||
#[allow(clippy::inconsistent_digit_grouping)]
|
||||
let node_identity = test_helpers::add_mixnode(
|
||||
node_owner.as_str(),
|
||||
coins(10000_000_000, DENOM),
|
||||
coins(10000_000_000, MIX_DENOM.base),
|
||||
deps.as_mut(),
|
||||
);
|
||||
|
||||
@@ -1725,7 +1725,7 @@ pub mod tests {
|
||||
#[allow(clippy::inconsistent_digit_grouping)]
|
||||
let node_identity = test_helpers::add_mixnode(
|
||||
node_owner.as_str(),
|
||||
coins(10000_000_000, DENOM),
|
||||
coins(10000_000_000, MIX_DENOM.base),
|
||||
deps.as_mut(),
|
||||
);
|
||||
|
||||
@@ -1733,7 +1733,10 @@ pub mod tests {
|
||||
try_delegate_to_mixnode(
|
||||
deps.as_mut(),
|
||||
env.clone(),
|
||||
mock_info(&*format!("delegator{:04}", i), &[coin(2000_000000, DENOM)]),
|
||||
mock_info(
|
||||
&*format!("delegator{:04}", i),
|
||||
&[coin(2000_000000, MIX_DENOM.base)],
|
||||
),
|
||||
node_identity.clone(),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::contract::INITIAL_MIXNODE_PLEDGE;
|
||||
use crate::mixnodes::storage as mixnodes_storage;
|
||||
use crate::{mixnodes::storage::StoredMixnodeBond, support::tests};
|
||||
use config::defaults::DENOM;
|
||||
use config::defaults::MIX_DENOM;
|
||||
use cosmwasm_std::{coin, Addr, Coin};
|
||||
use mixnet_contract_common::reward_params::NodeRewardParams;
|
||||
use mixnet_contract_common::{Gateway, GatewayBond, Layer, MixNode};
|
||||
@@ -37,7 +37,7 @@ pub fn gateway_bond_fixture(owner: &str) -> GatewayBond {
|
||||
..tests::fixtures::gateway_fixture()
|
||||
};
|
||||
GatewayBond::new(
|
||||
coin(50, DENOM),
|
||||
coin(50, MIX_DENOM.base),
|
||||
Addr::unchecked(owner),
|
||||
12_345,
|
||||
gateway,
|
||||
@@ -47,7 +47,7 @@ pub fn gateway_bond_fixture(owner: &str) -> GatewayBond {
|
||||
|
||||
pub(crate) fn stored_mixnode_bond_fixture(owner: &str) -> mixnodes_storage::StoredMixnodeBond {
|
||||
StoredMixnodeBond::new(
|
||||
coin(50, DENOM),
|
||||
coin(50, MIX_DENOM.base),
|
||||
Addr::unchecked(owner),
|
||||
Layer::One,
|
||||
12_345,
|
||||
@@ -64,14 +64,14 @@ pub(crate) fn stored_mixnode_bond_fixture(owner: &str) -> mixnodes_storage::Stor
|
||||
|
||||
pub fn good_mixnode_pledge() -> Vec<Coin> {
|
||||
vec![Coin {
|
||||
denom: DENOM.to_string(),
|
||||
denom: MIX_DENOM.base.to_string(),
|
||||
amount: INITIAL_MIXNODE_PLEDGE,
|
||||
}]
|
||||
}
|
||||
|
||||
pub fn good_gateway_pledge() -> Vec<Coin> {
|
||||
vec![Coin {
|
||||
denom: DENOM.to_string(),
|
||||
denom: MIX_DENOM.base.to_string(),
|
||||
amount: INITIAL_MIXNODE_PLEDGE,
|
||||
}]
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use config::defaults::DENOM;
|
||||
use config::defaults::MIX_DENOM;
|
||||
use cosmwasm_std::{
|
||||
from_binary,
|
||||
testing::{mock_env, MockApi, MockQuerier, MockStorage},
|
||||
@@ -45,5 +45,5 @@ pub fn query_contract_balance(
|
||||
deps: OwnedDeps<MockStorage, MockApi, MockQuerier>,
|
||||
) -> Vec<Coin> {
|
||||
let querier = deps.as_ref().querier;
|
||||
vec![querier.query_balance(address, DENOM).unwrap()]
|
||||
vec![querier.query_balance(address, MIX_DENOM.base).unwrap()]
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ use crate::traits::{
|
||||
DelegatingAccount, GatewayBondingAccount, MixnodeBondingAccount, VestingAccount,
|
||||
};
|
||||
use crate::vesting::{populate_vesting_periods, Account};
|
||||
use config::defaults::DENOM;
|
||||
use config::defaults::MIX_DENOM;
|
||||
use cosmwasm_std::{
|
||||
coin, entry_point, to_binary, BankMsg, Coin, Deps, DepsMut, Env, MessageInfo, QueryResponse,
|
||||
Response, Timestamp,
|
||||
@@ -147,8 +147,11 @@ pub fn try_withdraw_vested_coins(
|
||||
info: MessageInfo,
|
||||
deps: DepsMut<'_>,
|
||||
) -> Result<Response, ContractError> {
|
||||
if amount.denom != DENOM {
|
||||
return Err(ContractError::WrongDenom(amount.denom, DENOM.to_string()));
|
||||
if amount.denom != MIX_DENOM.base {
|
||||
return Err(ContractError::WrongDenom(
|
||||
amount.denom,
|
||||
MIX_DENOM.base.to_string(),
|
||||
));
|
||||
}
|
||||
|
||||
let address = info.sender.clone();
|
||||
@@ -611,10 +614,10 @@ fn validate_funds(funds: &[Coin]) -> Result<Coin, ContractError> {
|
||||
return Err(ContractError::MultipleDenoms);
|
||||
}
|
||||
|
||||
if funds[0].denom != DENOM {
|
||||
if funds[0].denom != MIX_DENOM.base {
|
||||
return Err(ContractError::WrongDenom(
|
||||
funds[0].denom.clone(),
|
||||
DENOM.to_string(),
|
||||
MIX_DENOM.base.to_string(),
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
pub mod helpers {
|
||||
use crate::contract::instantiate;
|
||||
use crate::vesting::{populate_vesting_periods, Account};
|
||||
use config::defaults::DENOM;
|
||||
use config::defaults::MIX_DENOM;
|
||||
use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info, MockApi, MockQuerier};
|
||||
use cosmwasm_std::{Addr, Coin, Empty, Env, MemoryStorage, OwnedDeps, Storage, Uint128};
|
||||
use vesting_contract_common::messages::{InitMsg, VestingSpecification};
|
||||
@@ -31,7 +31,7 @@ pub mod helpers {
|
||||
Some(Addr::unchecked("staking")),
|
||||
Coin {
|
||||
amount: Uint128::new(1_000_000_000_000),
|
||||
denom: DENOM.to_string(),
|
||||
denom: MIX_DENOM.base.to_string(),
|
||||
},
|
||||
start_time_ts,
|
||||
periods,
|
||||
@@ -50,7 +50,7 @@ pub mod helpers {
|
||||
Some(Addr::unchecked("staking")),
|
||||
Coin {
|
||||
amount: Uint128::new(1_000_000_000_000),
|
||||
denom: DENOM.to_string(),
|
||||
denom: MIX_DENOM.base.to_string(),
|
||||
},
|
||||
start_time,
|
||||
periods,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::errors::ContractError;
|
||||
use crate::storage::{delete_account, save_account, DELEGATIONS};
|
||||
use crate::traits::VestingAccount;
|
||||
use config::defaults::DENOM;
|
||||
use config::defaults::MIX_DENOM;
|
||||
use cosmwasm_std::{Addr, Coin, Env, Order, Storage, Timestamp, Uint128};
|
||||
use vesting_contract_common::{OriginalVestingResponse, Period};
|
||||
|
||||
@@ -38,7 +38,7 @@ impl VestingAccount for Account {
|
||||
.u128(),
|
||||
),
|
||||
),
|
||||
denom: DENOM.to_string(),
|
||||
denom: MIX_DENOM.base.to_string(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ impl VestingAccount for Account {
|
||||
.u128()
|
||||
.saturating_sub(self.locked_coins(block_time, env, storage)?.amount.u128()),
|
||||
),
|
||||
denom: DENOM.to_string(),
|
||||
denom: MIX_DENOM.base.to_string(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -69,15 +69,15 @@ impl VestingAccount for Account {
|
||||
let amount = match period {
|
||||
Period::Before => Coin {
|
||||
amount: Uint128::new(0),
|
||||
denom: DENOM.to_string(),
|
||||
denom: MIX_DENOM.base.to_string(),
|
||||
},
|
||||
Period::In(idx) => Coin {
|
||||
amount: Uint128::new(self.tokens_per_period()? * idx as u128),
|
||||
denom: DENOM.to_string(),
|
||||
denom: MIX_DENOM.base.to_string(),
|
||||
},
|
||||
Period::After => Coin {
|
||||
amount: self.coin.amount,
|
||||
denom: DENOM.to_string(),
|
||||
denom: MIX_DENOM.base.to_string(),
|
||||
},
|
||||
};
|
||||
Ok(amount)
|
||||
@@ -91,7 +91,7 @@ impl VestingAccount for Account {
|
||||
Ok(Coin {
|
||||
amount: self.get_original_vesting().amount().amount
|
||||
- self.get_vested_coins(block_time, env)?.amount,
|
||||
denom: DENOM.to_string(),
|
||||
denom: MIX_DENOM.base.to_string(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ impl VestingAccount for Account {
|
||||
|
||||
Ok(Coin {
|
||||
amount,
|
||||
denom: DENOM.to_string(),
|
||||
denom: MIX_DENOM.base.to_string(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ impl VestingAccount for Account {
|
||||
|
||||
Ok(Coin {
|
||||
amount,
|
||||
denom: DENOM.to_string(),
|
||||
denom: MIX_DENOM.base.to_string(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@ impl VestingAccount for Account {
|
||||
|
||||
Ok(Coin {
|
||||
amount,
|
||||
denom: DENOM.to_string(),
|
||||
denom: MIX_DENOM.base.to_string(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -217,12 +217,12 @@ impl VestingAccount for Account {
|
||||
let amount = bond.amount().amount - bonded_free.amount;
|
||||
Ok(Coin {
|
||||
amount,
|
||||
denom: DENOM.to_string(),
|
||||
denom: MIX_DENOM.base.to_string(),
|
||||
})
|
||||
} else {
|
||||
Ok(Coin {
|
||||
amount: Uint128::zero(),
|
||||
denom: DENOM.to_string(),
|
||||
denom: MIX_DENOM.base.to_string(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ mod tests {
|
||||
use crate::traits::DelegatingAccount;
|
||||
use crate::traits::VestingAccount;
|
||||
use crate::traits::{GatewayBondingAccount, MixnodeBondingAccount};
|
||||
use config::defaults::DENOM;
|
||||
use config::defaults::MIX_DENOM;
|
||||
use cosmwasm_std::testing::{mock_env, mock_info};
|
||||
use cosmwasm_std::{coins, Addr, Coin, Timestamp, Uint128};
|
||||
use mixnet_contract_common::{Gateway, MixNode};
|
||||
@@ -55,7 +55,7 @@ mod tests {
|
||||
fn test_account_creation() {
|
||||
let mut deps = init_contract();
|
||||
let env = mock_env();
|
||||
let info = mock_info("not_admin", &coins(1_000_000_000_000, DENOM));
|
||||
let info = mock_info("not_admin", &coins(1_000_000_000_000, MIX_DENOM.base));
|
||||
let msg = ExecuteMsg::CreateAccount {
|
||||
owner_address: "owner".to_string(),
|
||||
staking_address: Some("staking".to_string()),
|
||||
@@ -65,7 +65,7 @@ mod tests {
|
||||
let response = execute(deps.as_mut(), env.clone(), info.clone(), msg.clone());
|
||||
assert!(response.is_err());
|
||||
|
||||
let info = mock_info("admin", &coins(1_000_000_000_000, DENOM));
|
||||
let info = mock_info("admin", &coins(1_000_000_000_000, MIX_DENOM.base));
|
||||
let _response = execute(deps.as_mut(), env.clone(), info.clone(), msg.clone());
|
||||
let created_account = load_account(&Addr::unchecked("owner"), &deps.storage)
|
||||
.unwrap()
|
||||
@@ -131,7 +131,7 @@ mod tests {
|
||||
let msg = ExecuteMsg::WithdrawVestedCoins {
|
||||
amount: Coin {
|
||||
amount: Uint128::new(1),
|
||||
denom: DENOM.to_string(),
|
||||
denom: MIX_DENOM.base.to_string(),
|
||||
},
|
||||
};
|
||||
let info = mock_info("new_owner", &[]);
|
||||
@@ -262,7 +262,7 @@ mod tests {
|
||||
|
||||
let delegation = Coin {
|
||||
amount: Uint128::new(500_000_000_000),
|
||||
denom: DENOM.to_string(),
|
||||
denom: MIX_DENOM.base.to_string(),
|
||||
};
|
||||
|
||||
let ok = account.try_delegate_to_mixnode(
|
||||
@@ -388,7 +388,7 @@ mod tests {
|
||||
"alice".to_string(),
|
||||
Coin {
|
||||
amount: Uint128::new(1_000_000_000_001),
|
||||
denom: DENOM.to_string(),
|
||||
denom: MIX_DENOM.base.to_string(),
|
||||
},
|
||||
&env,
|
||||
&mut deps.storage,
|
||||
@@ -399,7 +399,7 @@ mod tests {
|
||||
"alice".to_string(),
|
||||
Coin {
|
||||
amount: Uint128::new(500_000_000_000),
|
||||
denom: DENOM.to_string(),
|
||||
denom: MIX_DENOM.base.to_string(),
|
||||
},
|
||||
&env,
|
||||
&mut deps.storage,
|
||||
@@ -414,7 +414,7 @@ mod tests {
|
||||
"alice".to_string(),
|
||||
Coin {
|
||||
amount: Uint128::new(500_000_000_001),
|
||||
denom: DENOM.to_string(),
|
||||
denom: MIX_DENOM.base.to_string(),
|
||||
},
|
||||
&env,
|
||||
&mut deps.storage,
|
||||
@@ -510,7 +510,7 @@ mod tests {
|
||||
"alice".to_string(),
|
||||
Coin {
|
||||
amount: Uint128::new(1_000_000_000_001),
|
||||
denom: DENOM.to_string(),
|
||||
denom: MIX_DENOM.base.to_string(),
|
||||
},
|
||||
&env,
|
||||
&mut deps.storage,
|
||||
@@ -522,7 +522,7 @@ mod tests {
|
||||
"alice".to_string(),
|
||||
Coin {
|
||||
amount: Uint128::new(500_000_000_000),
|
||||
denom: DENOM.to_string(),
|
||||
denom: MIX_DENOM.base.to_string(),
|
||||
},
|
||||
&env,
|
||||
&mut deps.storage,
|
||||
@@ -538,7 +538,7 @@ mod tests {
|
||||
"alice".to_string(),
|
||||
Coin {
|
||||
amount: Uint128::new(500_000_000_001),
|
||||
denom: DENOM.to_string(),
|
||||
denom: MIX_DENOM.base.to_string(),
|
||||
},
|
||||
&env,
|
||||
&mut deps.storage,
|
||||
@@ -630,7 +630,7 @@ mod tests {
|
||||
"alice".to_string(),
|
||||
Coin {
|
||||
amount: Uint128::new(1_000_000_000_001),
|
||||
denom: DENOM.to_string(),
|
||||
denom: MIX_DENOM.base.to_string(),
|
||||
},
|
||||
&env,
|
||||
&mut deps.storage,
|
||||
@@ -642,7 +642,7 @@ mod tests {
|
||||
"alice".to_string(),
|
||||
Coin {
|
||||
amount: Uint128::new(500_000_000_000),
|
||||
denom: DENOM.to_string(),
|
||||
denom: MIX_DENOM.base.to_string(),
|
||||
},
|
||||
&env,
|
||||
&mut deps.storage,
|
||||
@@ -658,7 +658,7 @@ mod tests {
|
||||
"alice".to_string(),
|
||||
Coin {
|
||||
amount: Uint128::new(500_000_000_001),
|
||||
denom: DENOM.to_string(),
|
||||
denom: MIX_DENOM.base.to_string(),
|
||||
},
|
||||
&env,
|
||||
&mut deps.storage,
|
||||
|
||||
@@ -31,10 +31,7 @@ impl SimulateResult {
|
||||
}
|
||||
|
||||
pub fn detailed_fee(&self) -> Result<FeeDetails, TypesError> {
|
||||
let amount: Option<MajorCurrencyAmount> = match self.to_fee_amount() {
|
||||
Some(a) => Some(a.into()),
|
||||
None => None,
|
||||
};
|
||||
let amount: Option<MajorCurrencyAmount> = self.to_fee_amount().map(Into::into);
|
||||
Ok(FeeDetails {
|
||||
amount,
|
||||
fee: self.to_fee(),
|
||||
|
||||
@@ -12,6 +12,7 @@ use once_cell::sync::Lazy;
|
||||
use tokio::sync::RwLock;
|
||||
use url::Url;
|
||||
|
||||
// use nym_types::currency::{CoinMetadata, Denom};
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
@@ -56,6 +57,7 @@ pub struct State {
|
||||
|
||||
/// We fetch (and cache) some metadata, such as names, when available
|
||||
validator_metadata: HashMap<Url, ValidatorMetadata>,
|
||||
// registered_coins: HashMap<Network, HashMap<Denom, CoinMetadata>>,
|
||||
}
|
||||
|
||||
pub(crate) struct WalletAccountIds {
|
||||
|
||||
Reference in New Issue
Block a user