Skip to content

Commit

Permalink
Rename account_group_id to wallet_id
Browse files Browse the repository at this point in the history
  • Loading branch information
grod220 committed Oct 5, 2023
1 parent f48b092 commit f7f1881
Show file tree
Hide file tree
Showing 43 changed files with 1,904 additions and 1,956 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 ID.
WalletId,
}

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::WalletId) => {
let key_store = KeyStore::load(data_dir.join(crate::CUSTODY_FILE_NAME))?;
let wallet_id = key_store.spend_key.full_viewing_key().wallet_id();
println!("{}", serde_json::to_string_pretty(&wallet_id)?);
}
KeysCmd::Delete => {
let wallet_path = data_dir.join(crate::CUSTODY_FILE_NAME);
Expand Down
65 changes: 31 additions & 34 deletions crates/bin/pcli/src/command/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ use anyhow::{Context, Result};
use ark_ff::UniformRand;
use decaf377::{Fq, Fr};
use ibc_types::core::{channel::ChannelId, client::Height as IbcHeight};
use rand_core::OsRng;
use regex::Regex;

use liquidity_position::PositionCmd;
use penumbra_asset::{asset, asset::DenomMetadata, Value, STAKING_TOKEN_ASSET_ID};
use penumbra_dex::{lp::position, swap_claim::SwapClaimPlan};
use penumbra_fee::Fee;
Expand Down Expand Up @@ -39,17 +43,12 @@ use penumbra_stake::{DelegationToken, IdentityKey, Penalty, UnbondingToken, Unde
use penumbra_transaction::memo::MemoPlaintext;
use penumbra_view::ViewClient;
use penumbra_wallet::plan::{self, Planner};
use rand_core::OsRng;
use regex::Regex;
use proposal::ProposalCmd;

use crate::App;

mod proposal;
use proposal::ProposalCmd;

mod liquidity_position;
use liquidity_position::PositionCmd;

mod proposal;
mod replicate;

#[derive(Debug, clap::Subcommand)]
Expand Down Expand Up @@ -203,7 +202,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 +289,7 @@ impl TxCmd {
};

let plan = plan::send(
app.fvk.account_group_id(),
app.fvk.wallet_id(),
app.view.as_mut().context("view service initialized")?,
OsRng,
&values,
Expand Down Expand Up @@ -323,15 +322,15 @@ impl TxCmd {
app.view
.as_mut()
.context("view service must be initialized")?,
app.fvk.account_group_id(),
app.fvk.wallet_id(),
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_id(),
app.view
.as_mut()
.context("view service must be initialized")?,
Expand Down Expand Up @@ -378,9 +377,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_id = app.fvk.wallet_id();
let plan = planner
.plan(app.view(), account_group_id, AddressIndex::new(*source))
.plan(app.view(), wallet_id, AddressIndex::new(*source))
.await
.context("can't plan swap transaction")?;

Expand All @@ -399,7 +398,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_id, swap_plaintext.swap_commitment())
.await?;

let asset_cache = app.view().assets().await?;
Expand Down Expand Up @@ -429,7 +428,7 @@ impl TxCmd {
.app_params()
.await?;

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

let mut planner = Planner::new(OsRng);
let plan = planner
Expand All @@ -441,7 +440,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_id, AddressIndex::new(*source))
.await
.context("can't plan swap claim")?;

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

let plan = plan::delegate(
app.fvk.account_group_id(),
app.fvk.wallet_id(),
app.view
.as_mut()
.context("view service must be initialized")?,
Expand Down Expand Up @@ -530,7 +529,7 @@ impl TxCmd {
app.view
.as_mut()
.context("view service must be initialized")?,
app.fvk.account_group_id(),
app.fvk.wallet_id(),
AddressIndex::new(*source),
)
.await
Expand All @@ -541,7 +540,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_id = app.fvk.wallet_id(); // 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 +549,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_id).await?.sync_height;
let mut client = ChainQueryServiceClient::new(channel.clone());
let current_epoch = client
.epoch_by_height(EpochByHeightRequest {
Expand All @@ -564,9 +563,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_id).await?;

for (address_index, notes_by_asset) in notes.into_iter() {
for (token, notes) in
Expand Down Expand Up @@ -627,7 +624,7 @@ impl TxCmd {
app.view
.as_mut()
.context("view service must be initialized")?,
app.fvk.account_group_id(),
app.fvk.wallet_id(),
address_index,
)
.await?;
Expand All @@ -648,7 +645,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_id(),
app.view
.as_mut()
.context("view service must be initialized")?,
Expand All @@ -668,7 +665,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_id(),
app.view
.as_mut()
.context("view service must be initialized")?,
Expand Down Expand Up @@ -755,7 +752,7 @@ impl TxCmd {
app.view
.as_mut()
.context("view service must be initialized")?,
app.fvk.account_group_id(),
app.fvk.wallet_id(),
AddressIndex::new(*source),
)
.await?;
Expand Down Expand Up @@ -823,7 +820,7 @@ impl TxCmd {
app.view
.as_mut()
.context("view service must be initialized")?,
app.fvk.account_group_id(),
app.fvk.wallet_id(),
AddressIndex::new(*source),
)
.await?;
Expand All @@ -846,7 +843,7 @@ impl TxCmd {
app.view
.as_mut()
.context("view service must be initialized")?,
app.fvk.account_group_id(),
app.fvk.wallet_id(),
source,
)
.await?;
Expand Down Expand Up @@ -918,7 +915,7 @@ impl TxCmd {
app.view
.as_mut()
.context("view service must be initialized")?,
app.fvk.account_group_id(),
app.fvk.wallet_id(),
AddressIndex::new(*source),
)
.await?;
Expand All @@ -938,7 +935,7 @@ impl TxCmd {
app.view
.as_mut()
.context("view service must be initialized")?,
app.fvk.account_group_id(),
app.fvk.wallet_id(),
AddressIndex::new(*source),
)
.await?;
Expand Down Expand Up @@ -978,7 +975,7 @@ impl TxCmd {
app.view
.as_mut()
.context("view service must be initialized")?,
app.fvk.account_group_id(),
app.fvk.wallet_id(),
AddressIndex::new(*source),
)
.await?;
Expand Down Expand Up @@ -1052,7 +1049,7 @@ impl TxCmd {
app.view
.as_mut()
.context("view service must be initialized")?,
app.fvk.account_group_id(),
app.fvk.wallet_id(),
AddressIndex::new(*source),
)
.await?;
Expand Down Expand Up @@ -1103,7 +1100,7 @@ impl TxCmd {
app.view
.as_mut()
.context("view service must be initialized")?,
app.fvk.account_group_id(),
app.fvk.wallet_id(),
AddressIndex::new(*source),
)
.await?;
Expand Down
2 changes: 1 addition & 1 deletion crates/bin/pcli/src/command/tx/replicate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ impl ConstantProduct {
app.view
.as_mut()
.context("view service must be initialized")?,
app.fvk.account_group_id(),
app.fvk.wallet_id(),
AddressIndex::new(self.source),
)
.await?;
Expand Down
13 changes: 7 additions & 6 deletions crates/bin/pcli/src/command/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ use std::{
};

use anyhow::{Context, Result};
use rand_core::OsRng;
use serde_json::Value;

use penumbra_fee::Fee;
use penumbra_governance::{
ValidatorVote, ValidatorVoteBody, ValidatorVoteReason, Vote, MAX_VALIDATOR_VOTE_REASON_LENGTH,
Expand All @@ -18,8 +21,6 @@ use penumbra_stake::{
FundingStream, FundingStreams, GovernanceKey, IdentityKey,
};
use penumbra_wallet::plan;
use rand_core::OsRng;
use serde_json::Value;

use crate::App;

Expand Down Expand Up @@ -149,9 +150,9 @@ impl ValidatorCmd {
};
// Construct a new transaction and include the validator definition.

let account_group_id = app.fvk.account_group_id();
let wallet_id = app.fvk.wallet_id();
let plan = plan::validator_definition(
account_group_id,
wallet_id,
app.view
.as_mut()
.context("view service must be initialized")?,
Expand Down Expand Up @@ -205,10 +206,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_id = app.fvk.wallet_id();

let plan = plan::validator_vote(
account_group_id,
wallet_id,
app.view
.as_mut()
.context("view service must be initialized")?,
Expand Down
4 changes: 2 additions & 2 deletions crates/bin/pcli/src/command/view/balance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,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_id())
.await?;

notes
Expand All @@ -40,7 +40,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_id())
.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_id = full_viewing_key.wallet_id();
let notes = view_client
.unspent_notes_by_asset_and_address(account_group_id)
.unspent_notes_by_asset_and_address(wallet_id)
.await?;
let mut total = 0u128;

Expand Down
2 changes: 1 addition & 1 deletion crates/bin/pcli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,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_id(),
)
.await?;

Expand Down
Loading

0 comments on commit f7f1881

Please sign in to comment.