fix keycard and lint

This commit is contained in:
jonesmarvin8 2026-05-27 17:33:01 -04:00
parent d2ec64ddef
commit 2e52d36948
3 changed files with 22 additions and 9 deletions

View File

@ -274,14 +274,17 @@ impl AccountManager {
}
pub fn public_account_nonces(&self) -> Vec<Nonce> {
self.states
.iter()
.filter_map(|state| match state {
State::Public { account, sk } => sk.as_ref().map(|_| account.account.nonce),
State::PublicKeycard { account, .. } => Some(account.account.nonce),
State::Private(_) => None,
})
.collect()
// Must match the signature order produced by sign_message(): local accounts first,
// keycard accounts second.
let local = self.states.iter().filter_map(|state| match state {
State::Public { account, sk } => sk.as_ref().map(|_| account.account.nonce),
State::PublicKeycard { .. } | State::Private(_) => None,
});
let keycard = self.states.iter().filter_map(|state| match state {
State::PublicKeycard { account, .. } => Some(account.account.nonce),
State::Public { .. } | State::Private(_) => None,
});
local.chain(keycard).collect()
}
pub fn private_account_keys(&self) -> Vec<PrivateAccountKeys> {

View File

@ -259,6 +259,7 @@ impl WalletSubcommand for AmmProgramAgnosticSubcommand {
max_amount_b,
&user_holding_a,
&user_holding_b,
&user_holding_lp,
)
.await?;
println!("Transaction hash is {tx_hash}");

View File

@ -284,6 +284,7 @@ impl Amm<'_> {
max_amount_to_add_token_b: u128,
user_holding_a_mention: &CliAccountMention,
user_holding_b_mention: &CliAccountMention,
user_holding_lp_mention: &CliAccountMention,
) -> Result<HashType, ExecutionFailureKind> {
let user_holding_a_identity = user_holding_a_mention.key_path().map_or(
AccountIdentity::Public(user_holding_a),
@ -301,6 +302,14 @@ impl Amm<'_> {
},
);
let user_holding_lp_identity = user_holding_lp_mention.key_path().map_or(
AccountIdentity::Public(user_holding_lp),
|key_path| AccountIdentity::PublicKeycard {
account_id: user_holding_lp,
key_path: key_path.to_owned(),
},
);
let program = Program::amm();
let amm_program_id = Program::amm().id();
let user_a_acc = self
@ -343,7 +352,7 @@ impl Amm<'_> {
AccountIdentity::PublicNoSign(pool_lp),
user_holding_a_identity,
user_holding_b_identity,
AccountIdentity::PublicNoSign(user_holding_lp),
user_holding_lp_identity,
],
instruction_data,
&program.into(),