fix(wallet): no sign option added

This commit is contained in:
Pravdyvy 2026-05-19 17:54:25 +03:00
parent 0210d70602
commit 43e7fa9be2
5 changed files with 85 additions and 32 deletions

View File

@ -13,6 +13,8 @@ use crate::{ExecutionFailureKind, WalletCore};
#[derive(Clone)]
pub enum AccountManagerAccountIdentity {
Public(AccountId),
/// A public account without signing. Would not try to sign, even if account is owned.
PublicNoSign(AccountId),
PrivateOwned(AccountId),
PrivateForeign {
npk: NullifierPublicKey,
@ -53,7 +55,7 @@ pub enum AccountManagerAccountIdentity {
impl AccountManagerAccountIdentity {
#[must_use]
pub const fn is_public(&self) -> bool {
matches!(&self, Self::Public(_))
matches!(&self, Self::Public(_) | Self::PublicNoSign(_))
}
#[must_use]
@ -109,6 +111,17 @@ impl AccountManager {
State::Public { account, sk }
}
AccountManagerAccountIdentity::PublicNoSign(account_id) => {
let acc = wallet
.get_account_public(account_id)
.await
.map_err(ExecutionFailureKind::SequencerError)?;
let sk = None;
let account = AccountWithMetadata::new(acc.clone(), sk.is_some(), account_id);
State::Public { account, sk }
}
AccountManagerAccountIdentity::PrivateOwned(account_id) => {
let pre = private_key_tree_acc_preparation(wallet, account_id, false).await?;

View File

@ -51,10 +51,10 @@ impl Amm<'_> {
self.0
.send_pub_tx(
vec![
AccountManagerAccountIdentity::Public(amm_pool),
AccountManagerAccountIdentity::Public(vault_holding_a),
AccountManagerAccountIdentity::Public(vault_holding_b),
AccountManagerAccountIdentity::Public(pool_lp),
AccountManagerAccountIdentity::PublicNoSign(amm_pool),
AccountManagerAccountIdentity::PublicNoSign(vault_holding_a),
AccountManagerAccountIdentity::PublicNoSign(vault_holding_b),
AccountManagerAccountIdentity::PublicNoSign(pool_lp),
AccountManagerAccountIdentity::Public(user_holding_a),
AccountManagerAccountIdentity::Public(user_holding_b),
AccountManagerAccountIdentity::Public(user_holding_lp),
@ -105,14 +105,34 @@ impl Amm<'_> {
let instruction_data =
Program::serialize_instruction(instruction).expect("Instruction should serialize");
if (token_definition_id_in != definition_token_a_id)
&& (token_definition_id_in != definition_token_b_id)
{
return Err(ExecutionFailureKind::AccountDataError(
token_definition_id_in,
));
}
let user_a_signing_indentity = if token_definition_id_in == definition_token_a_id {
AccountManagerAccountIdentity::Public(user_holding_a)
} else {
AccountManagerAccountIdentity::PublicNoSign(user_holding_a)
};
let user_b_signing_indentity = if token_definition_id_in == definition_token_b_id {
AccountManagerAccountIdentity::Public(user_holding_b)
} else {
AccountManagerAccountIdentity::PublicNoSign(user_holding_b)
};
self.0
.send_pub_tx(
vec![
AccountManagerAccountIdentity::Public(amm_pool),
AccountManagerAccountIdentity::Public(vault_holding_a),
AccountManagerAccountIdentity::Public(vault_holding_b),
AccountManagerAccountIdentity::Public(user_holding_a),
AccountManagerAccountIdentity::Public(user_holding_b),
AccountManagerAccountIdentity::PublicNoSign(amm_pool),
AccountManagerAccountIdentity::PublicNoSign(vault_holding_a),
AccountManagerAccountIdentity::PublicNoSign(vault_holding_b),
user_a_signing_indentity,
user_b_signing_indentity,
],
instruction_data,
&program.into(),
@ -160,14 +180,34 @@ impl Amm<'_> {
let instruction_data =
Program::serialize_instruction(instruction).expect("Instruction should serialize");
if (token_definition_id_in != definition_token_a_id)
&& (token_definition_id_in != definition_token_b_id)
{
return Err(ExecutionFailureKind::AccountDataError(
token_definition_id_in,
));
}
let user_a_signing_indentity = if token_definition_id_in == definition_token_a_id {
AccountManagerAccountIdentity::Public(user_holding_a)
} else {
AccountManagerAccountIdentity::PublicNoSign(user_holding_a)
};
let user_b_signing_indentity = if token_definition_id_in == definition_token_b_id {
AccountManagerAccountIdentity::Public(user_holding_b)
} else {
AccountManagerAccountIdentity::PublicNoSign(user_holding_b)
};
self.0
.send_pub_tx(
vec![
AccountManagerAccountIdentity::Public(amm_pool),
AccountManagerAccountIdentity::Public(vault_holding_a),
AccountManagerAccountIdentity::Public(vault_holding_b),
AccountManagerAccountIdentity::Public(user_holding_a),
AccountManagerAccountIdentity::Public(user_holding_b),
user_a_signing_indentity,
user_b_signing_indentity,
],
instruction_data,
&program.into(),
@ -220,13 +260,13 @@ impl Amm<'_> {
self.0
.send_pub_tx(
vec![
AccountManagerAccountIdentity::Public(amm_pool),
AccountManagerAccountIdentity::Public(vault_holding_a),
AccountManagerAccountIdentity::Public(vault_holding_b),
AccountManagerAccountIdentity::Public(pool_lp),
AccountManagerAccountIdentity::PublicNoSign(amm_pool),
AccountManagerAccountIdentity::PublicNoSign(vault_holding_a),
AccountManagerAccountIdentity::PublicNoSign(vault_holding_b),
AccountManagerAccountIdentity::PublicNoSign(pool_lp),
AccountManagerAccountIdentity::Public(user_holding_a),
AccountManagerAccountIdentity::Public(user_holding_b),
AccountManagerAccountIdentity::Public(user_holding_lp),
AccountManagerAccountIdentity::PublicNoSign(user_holding_lp),
],
instruction_data,
&program.into(),
@ -279,12 +319,12 @@ impl Amm<'_> {
self.0
.send_pub_tx(
vec![
AccountManagerAccountIdentity::Public(amm_pool),
AccountManagerAccountIdentity::Public(vault_holding_a),
AccountManagerAccountIdentity::Public(vault_holding_b),
AccountManagerAccountIdentity::Public(pool_lp),
AccountManagerAccountIdentity::Public(user_holding_a),
AccountManagerAccountIdentity::Public(user_holding_b),
AccountManagerAccountIdentity::PublicNoSign(amm_pool),
AccountManagerAccountIdentity::PublicNoSign(vault_holding_a),
AccountManagerAccountIdentity::PublicNoSign(vault_holding_b),
AccountManagerAccountIdentity::PublicNoSign(pool_lp),
AccountManagerAccountIdentity::PublicNoSign(user_holding_a),
AccountManagerAccountIdentity::PublicNoSign(user_holding_b),
AccountManagerAccountIdentity::Public(user_holding_lp),
],
instruction_data,

View File

@ -31,8 +31,8 @@ impl Ata<'_> {
.send_pub_tx(
vec![
AccountManagerAccountIdentity::Public(owner_id),
AccountManagerAccountIdentity::Public(definition_id),
AccountManagerAccountIdentity::Public(ata_id),
AccountManagerAccountIdentity::PublicNoSign(definition_id),
AccountManagerAccountIdentity::PublicNoSign(ata_id),
],
instruction_data,
&program.into(),
@ -64,8 +64,8 @@ impl Ata<'_> {
.send_pub_tx(
vec![
AccountManagerAccountIdentity::Public(owner_id),
AccountManagerAccountIdentity::Public(sender_ata_id),
AccountManagerAccountIdentity::Public(recipient_id),
AccountManagerAccountIdentity::PublicNoSign(sender_ata_id),
AccountManagerAccountIdentity::PublicNoSign(recipient_id),
],
instruction_data,
&program.into(),
@ -96,8 +96,8 @@ impl Ata<'_> {
.send_pub_tx(
vec![
AccountManagerAccountIdentity::Public(owner_id),
AccountManagerAccountIdentity::Public(holder_ata_id),
AccountManagerAccountIdentity::Public(definition_id),
AccountManagerAccountIdentity::PublicNoSign(holder_ata_id),
AccountManagerAccountIdentity::PublicNoSign(definition_id),
],
instruction_data,
&program.into(),

View File

@ -21,8 +21,8 @@ impl Pinata<'_> {
self.0
.send_pub_tx(
vec![
AccountManagerAccountIdentity::Public(pinata_account_id),
AccountManagerAccountIdentity::Public(winner_account_id),
AccountManagerAccountIdentity::PublicNoSign(pinata_account_id),
AccountManagerAccountIdentity::PublicNoSign(winner_account_id),
],
instruction_data,
&program.into(),

View File

@ -345,7 +345,7 @@ impl Token<'_> {
self.0
.send_pub_tx(
vec![
AccountManagerAccountIdentity::Public(definition_account_id),
AccountManagerAccountIdentity::PublicNoSign(definition_account_id),
AccountManagerAccountIdentity::Public(holder_account_id),
],
instruction_data,