This commit is contained in:
Marvin Jones 2026-05-22 20:15:36 -04:00
parent 5dc7d54848
commit a927955e04
3 changed files with 36 additions and 31 deletions

View File

@ -266,7 +266,6 @@ impl KeycardWallet {
result
})
}
}
fn pairing_file_path() -> Option<PathBuf> {

View File

@ -40,7 +40,8 @@ impl WalletSubcommand for KeycardSubcommand {
match self {
Self::Available => {
Python::with_gil(|py| {
python_path::add_python_path(py).expect("`wallet::keycard::available`: unable to setup python path");
python_path::add_python_path(py)
.expect("`wallet::keycard::available`: unable to setup python path");
let wallet = KeycardWallet::new(py)
.expect("`wallet::keycard::available`: invalid data received for pin");
@ -61,7 +62,8 @@ impl WalletSubcommand for KeycardSubcommand {
let pin = read_pin()?;
Python::with_gil(|py| {
python_path::add_python_path(py).expect("`wallet::keycard::connect`: unable to setup python path");
python_path::add_python_path(py)
.expect("`wallet::keycard::connect`: unable to setup python path");
let wallet = KeycardWallet::new(py)
.expect("`wallet::keycard::connect`: invalid keycard wallet provided");
@ -80,7 +82,8 @@ impl WalletSubcommand for KeycardSubcommand {
let pin = read_pin()?;
Python::with_gil(|py| {
python_path::add_python_path(py).expect("`wallet::keycard::disconnect`: unable to setup python path");
python_path::add_python_path(py)
.expect("`wallet::keycard::disconnect`: unable to setup python path");
let wallet = KeycardWallet::new(py)
.expect("`wallet::keycard::disconnect`: invalid keycard wallet provided");
@ -103,7 +106,8 @@ impl WalletSubcommand for KeycardSubcommand {
let pin = read_pin()?;
Python::with_gil(|py| {
python_path::add_python_path(py).expect("`wallet::keycard::init`: unable to setup python path");
python_path::add_python_path(py)
.expect("`wallet::keycard::init`: unable to setup python path");
let wallet = KeycardWallet::new(py)
.expect("`wallet::keycard::init`: invalid keycard wallet provided");
@ -125,7 +129,8 @@ impl WalletSubcommand for KeycardSubcommand {
let mnemonic = read_mnemonic()?;
Python::with_gil(|py| {
python_path::add_python_path(py).expect("`wallet::keycard::load`: unable to setup python path");
python_path::add_python_path(py)
.expect("`wallet::keycard::load`: unable to setup python path");
let wallet = KeycardWallet::new(py)
.expect("`wallet::keycard::load`: invalid keycard wallet provided");

View File

@ -649,39 +649,40 @@ impl WalletCore {
let mut pre_states = acc_manager.pre_states();
let (keycard_account, keycard_pin, keycard_path) =
if let Some(key_path_str) = mention.and_then(CliAccountMention::key_path) {
let pin = crate::helperfunctions::read_pin().map_err(|e| {
ExecutionFailureKind::KeycardError(pyo3::PyErr::new::<
pyo3::exceptions::PyRuntimeError,
_,
>(e.to_string()))
})?;
let account_id_str =
KeycardWallet::get_public_account_id_for_path_with_connect(&pin, key_path_str)?;
let account_id: AccountId = match account_id_str
let (keycard_account, keycard_pin, keycard_path) = if let Some(key_path_str) =
mention.and_then(CliAccountMention::key_path)
{
let pin = crate::helperfunctions::read_pin().map_err(|e| {
ExecutionFailureKind::KeycardError(pyo3::PyErr::new::<
pyo3::exceptions::PyRuntimeError,
_,
>(e.to_string()))
})?;
let account_id_str =
KeycardWallet::get_public_account_id_for_path_with_connect(&pin, key_path_str)?;
let account_id: AccountId = match account_id_str
.parse::<AccountIdWithPrivacy>()
.expect("`wallet::lib::send_privacy_preserving_tx_with_pre_check`: invalid account id parsed")
{
AccountIdWithPrivacy::Public(id) | AccountIdWithPrivacy::Private(id) => id,
};
let account = self
let account = self
.get_account_public(account_id)
.await
.expect("`wallet::lib::send_privacy_preserving_tx_with_pre_check`: unable to retrieve public account");
let pin_str = pin.as_str().to_owned();
(
Some(AccountWithMetadata {
account,
is_authorized: true,
account_id,
}),
Some(pin_str),
Some(key_path_str.to_owned()),
)
} else {
(None, None, None)
};
let pin_str = pin.as_str().to_owned();
(
Some(AccountWithMetadata {
account,
is_authorized: true,
account_id,
}),
Some(pin_str),
Some(key_path_str.to_owned()),
)
} else {
(None, None, None)
};
let mut nonces: Vec<Nonce> = acc_manager.public_account_nonces().into_iter().collect();