Skip to content

Commit

Permalink
accidentally added a proposal.json
Browse files Browse the repository at this point in the history
  • Loading branch information
bengtlofgren committed Jan 24, 2023
1 parent 93f496f commit 0d72562
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 54 deletions.
5 changes: 2 additions & 3 deletions apps/src/lib/cli/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use crate::client::tx::ShieldedContext;
use crate::config::genesis::genesis_config;
use crate::config::global::GlobalConfig;
use crate::config::{self, Config};
use crate::wallet::{Wallet, AddressVpType};
use crate::wallet::{AddressVpType, Wallet};
use crate::wasm_loader;

/// Env. var to set chain ID
Expand Down Expand Up @@ -188,12 +188,11 @@ impl Context {
pub fn read_wasm(&self, file_name: impl AsRef<Path>) -> Vec<u8> {
wasm_loader::read_wasm_or_exit(self.wasm_dir(), file_name)
}

/// Get address with vp type
pub fn tokens(&self) -> HashSet<Address> {
self.wallet.get_addresses_with_vp_type(AddressVpType::Token)
}

}

/// Load global config from expected path in the `base_dir` or try to generate a
Expand Down
59 changes: 31 additions & 28 deletions apps/src/lib/client/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,10 @@ pub async fn query_transfers(mut ctx: Context, args: args::QueryTransfers) {
if account != masp() {
print!(" {}:", account);
for (addr, val) in amt.components() {
let readable =
tokens.get(addr).cloned().unwrap_or(addr.clone());
let readable = tokens
.get(addr)
.cloned()
.unwrap_or_else(|| addr.clone());
let sign = match val.cmp(&0) {
Ordering::Greater => "+",
Ordering::Less => "-",
Expand All @@ -358,8 +360,10 @@ pub async fn query_transfers(mut ctx: Context, args: args::QueryTransfers) {
if fvk_map.contains_key(&account) {
print!(" {}:", fvk_map[&account]);
for (addr, val) in amt.components() {
let readable =
tokens.get(addr).cloned().unwrap_or(addr.clone());
let readable = tokens
.get(addr)
.cloned()
.unwrap_or_else(|| addr.clone());
let sign = match val.cmp(&0) {
Ordering::Greater => "+",
Ordering::Less => "-",
Expand Down Expand Up @@ -659,7 +663,10 @@ pub async fn query_pinned_balance(ctx: &mut Context, args: args::QueryBalance) {
}
println!(
" {}: {}",
tokens.get(addr).cloned().unwrap_or(addr.clone()),
tokens
.get(addr)
.cloned()
.unwrap_or_else(|| addr.clone()),
asset_value,
);
}
Expand All @@ -686,10 +693,7 @@ fn print_balances(

// Token
let tokens = ctx.tokens();
let currency_code = tokens
.get(token)
.map(|addr| addr)
.unwrap_or_else(|| token);
let currency_code = tokens.get(token).unwrap_or(token);
writeln!(w, "Token {}", currency_code).unwrap();

let print_num = balances
Expand Down Expand Up @@ -930,10 +934,7 @@ pub async fn query_shielded_balance(
.as_ref(),
)
.unwrap();
let currency_code = tokens
.get(&token)
.map(|addr| addr)
.unwrap_or_else(|| &token);
let currency_code = tokens.get(&token).unwrap_or(&token);
if balance[&asset_type] == 0 {
println!(
"No shielded {} balance found for given key",
Expand Down Expand Up @@ -991,7 +992,7 @@ pub async fn query_shielded_balance(
tokens
.get(&addr)
.cloned()
.unwrap_or(addr.clone())
.unwrap_or_else(|| addr.clone())
);
read_tokens.insert(addr);
}
Expand All @@ -1015,17 +1016,19 @@ pub async fn query_shielded_balance(
for token in tokens {
if !read_tokens.contains(&token) {
match ctx.wallet.find_alias(&token) {
Some(currency_code) => {
Some(currency_code) => {
println!("Shielded Token {}:", currency_code);
println!(
"No shielded {} balance found for any wallet key",
"No shielded {} balance found for any wallet \
key",
currency_code
);
}

None => println!("Could not find the alias for {}", &token),
None => {
println!("Could not find the alias for {}", &token)
}
}

}
}
}
Expand All @@ -1041,10 +1044,7 @@ pub async fn query_shielded_balance(
.as_ref(),
)
.unwrap();
let currency_code = tokens
.get(&token)
.map(|addr| addr)
.unwrap_or_else(|| &token);
let currency_code = tokens.get(&token).unwrap_or(&token);
println!("Shielded Token {}:", currency_code);
let mut found_any = false;
for fvk in viewing_keys {
Expand Down Expand Up @@ -1116,14 +1116,17 @@ pub async fn query_shielded_balance(
}
}

pub fn print_decoded_balance(ctx : &mut Context, decoded_balance: Amount<Address>) {
pub fn print_decoded_balance(
ctx: &mut Context,
decoded_balance: Amount<Address>,
) {
let tokens = ctx.tokens();
let mut found_any = false;
for (addr, value) in decoded_balance.components() {
let asset_value = token::Amount::from(*value as u64);
println!(
"{} : {}",
tokens.get(addr).cloned().unwrap_or(addr.clone()),
tokens.get(addr).cloned().unwrap_or_else(|| addr.clone()),
asset_value
);
found_any = true;
Expand All @@ -1134,7 +1137,7 @@ pub fn print_decoded_balance(ctx : &mut Context, decoded_balance: Amount<Address
}

pub fn print_decoded_balance_with_epoch(
ctx : &mut Context,
ctx: &mut Context,
decoded_balance: Amount<(Address, Epoch)>,
) {
let tokens = ctx.tokens();
Expand All @@ -1143,7 +1146,7 @@ pub fn print_decoded_balance_with_epoch(
let asset_value = token::Amount::from(*value as u64);
println!(
"{} | {} : {}",
tokens.get(addr).cloned().unwrap_or(addr.clone()),
tokens.get(addr).cloned().unwrap_or_else(|| addr.clone()),
epoch,
asset_value
);
Expand Down Expand Up @@ -2216,7 +2219,7 @@ pub async fn query_conversions(ctx: Context, args: args::QueryConversions) {
// Print the asset to which the conversion applies
print!(
"{}[{}]: ",
tokens.get(addr).cloned().unwrap_or(addr.clone()),
tokens.get(addr).cloned().unwrap_or_else(|| addr.clone()),
epoch,
);
// Now print out the components of the allowed conversion
Expand All @@ -2230,7 +2233,7 @@ pub async fn query_conversions(ctx: Context, args: args::QueryConversions) {
"{}{} {}[{}]",
prefix,
val,
tokens.get(addr).cloned().unwrap_or(addr.clone()),
tokens.get(addr).cloned().unwrap_or_else(|| addr.clone()),
epoch
);
// Future iterations need to be prefixed with +
Expand Down
4 changes: 3 additions & 1 deletion apps/src/lib/config/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,9 @@ pub fn genesis(base_dir: impl AsRef<Path>, chain_id: &ChainId) -> Genesis {
}
#[cfg(feature = "dev")]
pub fn genesis() -> Genesis {
use namada::types::address::{self, nam, btc, eth, schnitzel, dot, apfel, kartoffel};
use namada::types::address::{
self, apfel, btc, dot, eth, kartoffel, nam, schnitzel,
};
use rust_decimal_macros::dec;

use crate::wallet;
Expand Down
2 changes: 1 addition & 1 deletion apps/src/lib/wallet/alias.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl Display for Alias {
}
}

impl Default for Alias{
impl Default for Alias {
fn default() -> Self {
Alias(String::from("Unknown Alias"))
}
Expand Down
4 changes: 3 additions & 1 deletion apps/src/lib/wallet/defaults.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ mod dev {

use borsh::BorshDeserialize;
use namada::ledger::{governance, pos};
use namada::types::address::{self, Address, kartoffel, apfel, schnitzel, dot, eth, btc, nam};
use namada::types::address::{
apfel, btc, dot, eth, kartoffel, nam, schnitzel, Address,
};
use namada::types::key::dkg_session_keys::DkgKeypair;
use namada::types::key::*;

Expand Down
2 changes: 0 additions & 2 deletions core/src/types/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -556,8 +556,6 @@ pub fn masp_tx_key() -> crate::types::key::common::SecretKey {
common::SecretKey::try_from_slice(bytes.as_ref()).unwrap()
}



/// Temporary helper for testing, a hash map of tokens addresses with their
/// MASP XAN incentive schedules. If the reward is (a, b) then a rewarded tokens
/// are dispensed for every b possessed tokens.
Expand Down
18 changes: 0 additions & 18 deletions proposal.json

This file was deleted.

0 comments on commit 0d72562

Please sign in to comment.