Skip to content

Commit

Permalink
Rename all account_group_id instances to wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
grod220 committed Oct 5, 2023
1 parent 5f2a279 commit d7b2a6e
Show file tree
Hide file tree
Showing 40 changed files with 1,925 additions and 1,990 deletions.
12 changes: 6 additions & 6 deletions crates/bin/pcli/src/command/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ pub enum ImportCmd {
pub enum ExportCmd {
/// Export the full viewing key for the wallet.
FullViewingKey,
/// Export the account group ID.
AccountGroupId,
/// Export the wallet.
Wallet,
}

impl KeysCmd {
Expand Down Expand Up @@ -122,10 +122,10 @@ impl KeysCmd {
let wallet = KeyStore::load(data_dir.join(crate::CUSTODY_FILE_NAME))?;
println!("{}", wallet.spend_key.full_viewing_key());
}
KeysCmd::Export(ExportCmd::AccountGroupId) => {
let wallet = KeyStore::load(data_dir.join(crate::CUSTODY_FILE_NAME))?;
let account_group_id = wallet.spend_key.full_viewing_key().account_group_id();
println!("{}", serde_json::to_string_pretty(&account_group_id)?);
KeysCmd::Export(ExportCmd::Wallet) => {
let key_store = KeyStore::load(data_dir.join(crate::CUSTODY_FILE_NAME))?;
let wallet = key_store.spend_key.full_viewing_key().wallet();
println!("{}", serde_json::to_string_pretty(&wallet)?);
}
KeysCmd::Delete => {
let wallet_path = data_dir.join(crate::CUSTODY_FILE_NAME);
Expand Down
58 changes: 29 additions & 29 deletions crates/bin/pcli/src/command/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ use regex::Regex;
use crate::App;

mod proposal;

use proposal::ProposalCmd;

mod liquidity_position;

use liquidity_position::PositionCmd;

mod replicate;
Expand Down Expand Up @@ -203,7 +205,7 @@ pub enum TxCmd {
#[clap(long, default_value = "0", display_order = 150)]
timeout_timestamp: u64,

/// Only withdraw funds from the specified account group within Penumbra.
/// Only withdraw funds from the specified wallet within Penumbra.
#[clap(long, default_value = "0", display_order = 200)]
source: u32,
},
Expand Down Expand Up @@ -290,7 +292,7 @@ impl TxCmd {
};

let plan = plan::send(
app.fvk.account_group_id(),
app.fvk.wallet(),
app.view.as_mut().context("view service initialized")?,
OsRng,
&values,
Expand Down Expand Up @@ -323,15 +325,15 @@ impl TxCmd {
app.view
.as_mut()
.context("view service must be initialized")?,
app.fvk.account_group_id(),
app.fvk.wallet(),
AddressIndex::new(*source),
)
.await?;
app.build_and_submit_transaction(plan).await?;
}
TxCmd::Sweep => loop {
let plans = plan::sweep(
app.fvk.account_group_id(),
app.fvk.wallet(),
app.view
.as_mut()
.context("view service must be initialized")?,
Expand Down Expand Up @@ -378,9 +380,9 @@ impl TxCmd {
planner.fee(swap_fee);
planner.swap(input, into.id(), swap_claim_fee.clone(), claim_address)?;

let account_group_id = app.fvk.account_group_id();
let wallet = app.fvk.wallet();
let plan = planner
.plan(app.view(), account_group_id, AddressIndex::new(*source))
.plan(app.view(), wallet, AddressIndex::new(*source))
.await
.context("can't plan swap transaction")?;

Expand All @@ -399,7 +401,7 @@ impl TxCmd {
// Fetch the SwapRecord with the claimable swap.
let swap_record = app
.view()
.swap_by_commitment(account_group_id, swap_plaintext.swap_commitment())
.swap_by_commitment(wallet, swap_plaintext.swap_commitment())
.await?;

let asset_cache = app.view().assets().await?;
Expand All @@ -412,12 +414,12 @@ impl TxCmd {
"You will receive outputs of {} and {}. Claiming now...",
Value {
amount: pro_rata_outputs.0,
asset_id: swap_record.output_data.trading_pair.asset_1()
asset_id: swap_record.output_data.trading_pair.asset_1(),
}
.format(&asset_cache),
Value {
amount: pro_rata_outputs.1,
asset_id: swap_record.output_data.trading_pair.asset_2()
asset_id: swap_record.output_data.trading_pair.asset_2(),
}
.format(&asset_cache),
);
Expand All @@ -429,7 +431,7 @@ impl TxCmd {
.app_params()
.await?;

let account_group_id = app.fvk.account_group_id();
let wallet = app.fvk.wallet();

let mut planner = Planner::new(OsRng);
let plan = planner
Expand All @@ -441,7 +443,7 @@ impl TxCmd {
proof_blinding_r: Fq::rand(&mut OsRng),
proof_blinding_s: Fq::rand(&mut OsRng),
})
.plan(app.view(), account_group_id, AddressIndex::new(*source))
.plan(app.view(), wallet, AddressIndex::new(*source))
.await
.context("can't plan swap claim")?;

Expand Down Expand Up @@ -475,7 +477,7 @@ impl TxCmd {
let fee = Fee::from_staking_token_amount((*fee).into());

let plan = plan::delegate(
app.fvk.account_group_id(),
app.fvk.wallet(),
app.view
.as_mut()
.context("view service must be initialized")?,
Expand Down Expand Up @@ -530,7 +532,7 @@ impl TxCmd {
app.view
.as_mut()
.context("view service must be initialized")?,
app.fvk.account_group_id(),
app.fvk.wallet(),
AddressIndex::new(*source),
)
.await
Expand All @@ -541,7 +543,7 @@ impl TxCmd {
TxCmd::UndelegateClaim { fee } => {
let fee = Fee::from_staking_token_amount((*fee).into());

let account_group_id = app.fvk.account_group_id(); // this should be optional? or saved in the client statefully?
let wallet = app.fvk.wallet(); // this should be optional? or saved in the client statefully?

let channel = app.pd_channel().await?;
let view: &mut dyn ViewClient = app
Expand All @@ -550,7 +552,7 @@ impl TxCmd {
.context("view service must be initialized")?;

let params = view.app_params().await?;
let current_height = view.status(account_group_id).await?.sync_height;
let current_height = view.status(wallet).await?.sync_height;
let mut client = ChainQueryServiceClient::new(channel.clone());
let current_epoch = client
.epoch_by_height(EpochByHeightRequest {
Expand All @@ -564,9 +566,7 @@ impl TxCmd {

// Query the view client for the list of undelegations that are ready to be claimed.
// We want to claim them into the same address index that currently holds the tokens.
let notes = view
.unspent_notes_by_address_and_asset(account_group_id)
.await?;
let notes = view.unspent_notes_by_address_and_asset(wallet).await?;

for (address_index, notes_by_asset) in notes.into_iter() {
for (token, notes) in
Expand Down Expand Up @@ -627,7 +627,7 @@ impl TxCmd {
app.view
.as_mut()
.context("view service must be initialized")?,
app.fvk.account_group_id(),
app.fvk.wallet(),
address_index,
)
.await?;
Expand All @@ -648,7 +648,7 @@ impl TxCmd {
.context("can't parse proposal file")?;
let fee = Fee::from_staking_token_amount((*fee).into());
let plan = plan::proposal_submit(
app.fvk.account_group_id(),
app.fvk.wallet(),
app.view
.as_mut()
.context("view service must be initialized")?,
Expand All @@ -668,7 +668,7 @@ impl TxCmd {
}) => {
let fee = Fee::from_staking_token_amount((*fee).into());
let plan = plan::proposal_withdraw(
app.fvk.account_group_id(),
app.fvk.wallet(),
app.view
.as_mut()
.context("view service must be initialized")?,
Expand Down Expand Up @@ -755,7 +755,7 @@ impl TxCmd {
app.view
.as_mut()
.context("view service must be initialized")?,
app.fvk.account_group_id(),
app.fvk.wallet(),
AddressIndex::new(*source),
)
.await?;
Expand Down Expand Up @@ -823,7 +823,7 @@ impl TxCmd {
app.view
.as_mut()
.context("view service must be initialized")?,
app.fvk.account_group_id(),
app.fvk.wallet(),
AddressIndex::new(*source),
)
.await?;
Expand All @@ -846,7 +846,7 @@ impl TxCmd {
app.view
.as_mut()
.context("view service must be initialized")?,
app.fvk.account_group_id(),
app.fvk.wallet(),
source,
)
.await?;
Expand Down Expand Up @@ -918,7 +918,7 @@ impl TxCmd {
app.view
.as_mut()
.context("view service must be initialized")?,
app.fvk.account_group_id(),
app.fvk.wallet(),
AddressIndex::new(*source),
)
.await?;
Expand All @@ -938,7 +938,7 @@ impl TxCmd {
app.view
.as_mut()
.context("view service must be initialized")?,
app.fvk.account_group_id(),
app.fvk.wallet(),
AddressIndex::new(*source),
)
.await?;
Expand Down Expand Up @@ -978,7 +978,7 @@ impl TxCmd {
app.view
.as_mut()
.context("view service must be initialized")?,
app.fvk.account_group_id(),
app.fvk.wallet(),
AddressIndex::new(*source),
)
.await?;
Expand Down Expand Up @@ -1052,7 +1052,7 @@ impl TxCmd {
app.view
.as_mut()
.context("view service must be initialized")?,
app.fvk.account_group_id(),
app.fvk.wallet(),
AddressIndex::new(*source),
)
.await?;
Expand Down Expand Up @@ -1103,7 +1103,7 @@ impl TxCmd {
app.view
.as_mut()
.context("view service must be initialized")?,
app.fvk.account_group_id(),
app.fvk.wallet(),
AddressIndex::new(*source),
)
.await?;
Expand Down
14 changes: 8 additions & 6 deletions crates/bin/pcli/src/command/tx/replicate.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use crate::{warning, App};
use std::io::Write;
use std::path::PathBuf;

use crate::dex_utils;
use crate::dex_utils::replicate::debug;
use anyhow::{anyhow, bail, Context, Result};
use dialoguer::Confirm;
use rand_core::OsRng;

use penumbra_asset::Value;
use penumbra_dex::{lp::position::Position, DirectedUnitPair};
use penumbra_keys::keys::AddressIndex;
Expand All @@ -13,8 +13,10 @@ use penumbra_proto::core::component::dex::v1alpha1::{
query_service_client::QueryServiceClient as DexQueryServiceClient, SpreadRequest,
};
use penumbra_view::{Planner, ViewClient};
use rand_core::OsRng;
use std::io::Write;

use crate::dex_utils;
use crate::dex_utils::replicate::debug;
use crate::{warning, App};

/// Queries the chain for a transaction by hash.
#[derive(Debug, clap::Subcommand)]
Expand Down Expand Up @@ -153,7 +155,7 @@ impl ConstantProduct {
app.view
.as_mut()
.context("view service must be initialized")?,
app.fvk.account_group_id(),
app.fvk.wallet(),
AddressIndex::new(self.source),
)
.await?;
Expand Down
8 changes: 4 additions & 4 deletions crates/bin/pcli/src/command/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ impl ValidatorCmd {
};
// Construct a new transaction and include the validator definition.

let account_group_id = app.fvk.account_group_id();
let wallet = app.fvk.wallet();
let plan = plan::validator_definition(
account_group_id,
wallet,
app.view
.as_mut()
.context("view service must be initialized")?,
Expand Down Expand Up @@ -205,10 +205,10 @@ impl ValidatorCmd {
// Construct a new transaction and include the validator definition.
let fee = Fee::from_staking_token_amount((*fee).into());

let account_group_id = app.fvk.account_group_id();
let wallet = app.fvk.wallet();

let plan = plan::validator_vote(
account_group_id,
wallet,
app.view
.as_mut()
.context("view service must be initialized")?,
Expand Down
5 changes: 3 additions & 2 deletions crates/bin/pcli/src/command/view/balance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use comfy_table::{presets, Table};
use penumbra_asset::{asset::Cache, Value};
use penumbra_keys::{keys::AddressIndex, FullViewingKey};
use penumbra_view::ViewClient;

#[derive(Debug, clap::Args)]
pub struct BalanceCmd {
#[clap(long)]
Expand All @@ -24,7 +25,7 @@ impl BalanceCmd {

let rows: Vec<(Option<AddressIndex>, Value)> = if self.by_note {
let notes = view
.unspent_notes_by_address_and_asset(fvk.account_group_id())
.unspent_notes_by_address_and_asset(fvk.wallet())
.await?;

notes
Expand All @@ -40,7 +41,7 @@ impl BalanceCmd {
.collect()
} else {
let notes = view
.unspent_notes_by_address_and_asset(fvk.account_group_id())
.unspent_notes_by_address_and_asset(fvk.wallet())
.await?;

notes
Expand Down
4 changes: 2 additions & 2 deletions crates/bin/pcli/src/command/view/staked.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ impl StakedCmd {
.map(TryInto::try_into)
.collect::<Result<Vec<validator::Info>, _>>()?;

let account_group_id = full_viewing_key.account_group_id();
let wallet = full_viewing_key.wallet();
let notes = view_client
.unspent_notes_by_asset_and_address(account_group_id)
.unspent_notes_by_asset_and_address(wallet)
.await?;
let mut total = 0u128;

Expand Down
3 changes: 2 additions & 1 deletion crates/bin/pcli/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![deny(clippy::unwrap_used)]
#![allow(clippy::clone_on_copy)]

use std::fs;

use anyhow::{Context, Result};
Expand Down Expand Up @@ -49,7 +50,7 @@ impl App {
async fn sync(&mut self) -> Result<()> {
let mut status_stream = ViewClient::status_stream(
self.view.as_mut().expect("view service initialized"),
self.fvk.account_group_id(),
self.fvk.wallet(),
)
.await?;

Expand Down
Loading

0 comments on commit d7b2a6e

Please sign in to comment.