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 authored and hdevalence committed Oct 6, 2023
1 parent 8dc50e6 commit b4bdc88
Show file tree
Hide file tree
Showing 44 changed files with 2,039 additions and 1,994 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
67 changes: 32 additions & 35 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 @@ -43,17 +47,12 @@ use penumbra_stake::{DelegationToken, IdentityKey, Penalty, UnbondingToken, Unde
use penumbra_transaction::{gas::swap_claim_gas_cost, 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 @@ -183,7 +182,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 id within Penumbra.
#[clap(long, default_value = "0", display_order = 200)]
source: u32,
},
Expand Down Expand Up @@ -289,7 +288,7 @@ impl TxCmd {
app.view
.as_mut()
.context("view service must be initialized")?,
app.fvk.account_group_id(),
app.fvk.wallet_id(),
AddressIndex::new(*from),
)
.await
Expand All @@ -312,15 +311,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 @@ -374,9 +373,9 @@ impl TxCmd {
);
planner.swap(input, into.id(), estimated_claim_fee, 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 @@ -395,7 +394,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 All @@ -418,7 +417,7 @@ impl TxCmd {
.format(&asset_cache),
);

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

let params = app
.view
Expand All @@ -438,7 +437,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 @@ -467,10 +466,10 @@ impl TxCmd {

let mut planner = Planner::new(OsRng);
planner.set_gas_prices(gas_prices);
let account_group_id = app.fvk.account_group_id().clone();
let wallet_id = app.fvk.wallet_id().clone();
let plan = planner
.delegate(unbonded_amount.value(), rate_data)
.plan(app.view(), account_group_id, AddressIndex::new(*source))
.plan(app.view(), wallet_id, AddressIndex::new(*source))
.await
.context("can't plan delegation")?;

Expand Down Expand Up @@ -511,7 +510,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 @@ -520,15 +519,15 @@ impl TxCmd {
app.build_and_submit_transaction(plan).await?;
}
TxCmd::UndelegateClaim {} => {
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
.view
.as_mut()
.context("view service must be initialized")?;

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 @@ -542,9 +541,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 @@ -612,7 +609,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 Down Expand Up @@ -644,7 +641,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 @@ -663,7 +660,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 @@ -743,7 +740,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 @@ -809,7 +806,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 @@ -832,7 +829,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 @@ -904,7 +901,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 @@ -924,7 +921,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 @@ -965,7 +962,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 @@ -1042,7 +1039,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 @@ -1095,7 +1092,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 @@ -168,7 +168,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 b4bdc88

Please sign in to comment.