mirror of
https://github.com/logos-blockchain/lssa.git
synced 2026-06-03 07:39:28 +00:00
fix(wallet): no sign option added
This commit is contained in:
parent
0210d70602
commit
43e7fa9be2
@ -13,6 +13,8 @@ use crate::{ExecutionFailureKind, WalletCore};
|
|||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub enum AccountManagerAccountIdentity {
|
pub enum AccountManagerAccountIdentity {
|
||||||
Public(AccountId),
|
Public(AccountId),
|
||||||
|
/// A public account without signing. Would not try to sign, even if account is owned.
|
||||||
|
PublicNoSign(AccountId),
|
||||||
PrivateOwned(AccountId),
|
PrivateOwned(AccountId),
|
||||||
PrivateForeign {
|
PrivateForeign {
|
||||||
npk: NullifierPublicKey,
|
npk: NullifierPublicKey,
|
||||||
@ -53,7 +55,7 @@ pub enum AccountManagerAccountIdentity {
|
|||||||
impl AccountManagerAccountIdentity {
|
impl AccountManagerAccountIdentity {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub const fn is_public(&self) -> bool {
|
pub const fn is_public(&self) -> bool {
|
||||||
matches!(&self, Self::Public(_))
|
matches!(&self, Self::Public(_) | Self::PublicNoSign(_))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
@ -109,6 +111,17 @@ impl AccountManager {
|
|||||||
|
|
||||||
State::Public { account, sk }
|
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) => {
|
AccountManagerAccountIdentity::PrivateOwned(account_id) => {
|
||||||
let pre = private_key_tree_acc_preparation(wallet, account_id, false).await?;
|
let pre = private_key_tree_acc_preparation(wallet, account_id, false).await?;
|
||||||
|
|
||||||
|
|||||||
@ -51,10 +51,10 @@ impl Amm<'_> {
|
|||||||
self.0
|
self.0
|
||||||
.send_pub_tx(
|
.send_pub_tx(
|
||||||
vec![
|
vec![
|
||||||
AccountManagerAccountIdentity::Public(amm_pool),
|
AccountManagerAccountIdentity::PublicNoSign(amm_pool),
|
||||||
AccountManagerAccountIdentity::Public(vault_holding_a),
|
AccountManagerAccountIdentity::PublicNoSign(vault_holding_a),
|
||||||
AccountManagerAccountIdentity::Public(vault_holding_b),
|
AccountManagerAccountIdentity::PublicNoSign(vault_holding_b),
|
||||||
AccountManagerAccountIdentity::Public(pool_lp),
|
AccountManagerAccountIdentity::PublicNoSign(pool_lp),
|
||||||
AccountManagerAccountIdentity::Public(user_holding_a),
|
AccountManagerAccountIdentity::Public(user_holding_a),
|
||||||
AccountManagerAccountIdentity::Public(user_holding_b),
|
AccountManagerAccountIdentity::Public(user_holding_b),
|
||||||
AccountManagerAccountIdentity::Public(user_holding_lp),
|
AccountManagerAccountIdentity::Public(user_holding_lp),
|
||||||
@ -105,14 +105,34 @@ impl Amm<'_> {
|
|||||||
let instruction_data =
|
let instruction_data =
|
||||||
Program::serialize_instruction(instruction).expect("Instruction should serialize");
|
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
|
self.0
|
||||||
.send_pub_tx(
|
.send_pub_tx(
|
||||||
vec![
|
vec![
|
||||||
AccountManagerAccountIdentity::Public(amm_pool),
|
AccountManagerAccountIdentity::PublicNoSign(amm_pool),
|
||||||
AccountManagerAccountIdentity::Public(vault_holding_a),
|
AccountManagerAccountIdentity::PublicNoSign(vault_holding_a),
|
||||||
AccountManagerAccountIdentity::Public(vault_holding_b),
|
AccountManagerAccountIdentity::PublicNoSign(vault_holding_b),
|
||||||
AccountManagerAccountIdentity::Public(user_holding_a),
|
user_a_signing_indentity,
|
||||||
AccountManagerAccountIdentity::Public(user_holding_b),
|
user_b_signing_indentity,
|
||||||
],
|
],
|
||||||
instruction_data,
|
instruction_data,
|
||||||
&program.into(),
|
&program.into(),
|
||||||
@ -160,14 +180,34 @@ impl Amm<'_> {
|
|||||||
let instruction_data =
|
let instruction_data =
|
||||||
Program::serialize_instruction(instruction).expect("Instruction should serialize");
|
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
|
self.0
|
||||||
.send_pub_tx(
|
.send_pub_tx(
|
||||||
vec![
|
vec![
|
||||||
AccountManagerAccountIdentity::Public(amm_pool),
|
AccountManagerAccountIdentity::Public(amm_pool),
|
||||||
AccountManagerAccountIdentity::Public(vault_holding_a),
|
AccountManagerAccountIdentity::Public(vault_holding_a),
|
||||||
AccountManagerAccountIdentity::Public(vault_holding_b),
|
AccountManagerAccountIdentity::Public(vault_holding_b),
|
||||||
AccountManagerAccountIdentity::Public(user_holding_a),
|
user_a_signing_indentity,
|
||||||
AccountManagerAccountIdentity::Public(user_holding_b),
|
user_b_signing_indentity,
|
||||||
],
|
],
|
||||||
instruction_data,
|
instruction_data,
|
||||||
&program.into(),
|
&program.into(),
|
||||||
@ -220,13 +260,13 @@ impl Amm<'_> {
|
|||||||
self.0
|
self.0
|
||||||
.send_pub_tx(
|
.send_pub_tx(
|
||||||
vec![
|
vec![
|
||||||
AccountManagerAccountIdentity::Public(amm_pool),
|
AccountManagerAccountIdentity::PublicNoSign(amm_pool),
|
||||||
AccountManagerAccountIdentity::Public(vault_holding_a),
|
AccountManagerAccountIdentity::PublicNoSign(vault_holding_a),
|
||||||
AccountManagerAccountIdentity::Public(vault_holding_b),
|
AccountManagerAccountIdentity::PublicNoSign(vault_holding_b),
|
||||||
AccountManagerAccountIdentity::Public(pool_lp),
|
AccountManagerAccountIdentity::PublicNoSign(pool_lp),
|
||||||
AccountManagerAccountIdentity::Public(user_holding_a),
|
AccountManagerAccountIdentity::Public(user_holding_a),
|
||||||
AccountManagerAccountIdentity::Public(user_holding_b),
|
AccountManagerAccountIdentity::Public(user_holding_b),
|
||||||
AccountManagerAccountIdentity::Public(user_holding_lp),
|
AccountManagerAccountIdentity::PublicNoSign(user_holding_lp),
|
||||||
],
|
],
|
||||||
instruction_data,
|
instruction_data,
|
||||||
&program.into(),
|
&program.into(),
|
||||||
@ -279,12 +319,12 @@ impl Amm<'_> {
|
|||||||
self.0
|
self.0
|
||||||
.send_pub_tx(
|
.send_pub_tx(
|
||||||
vec![
|
vec![
|
||||||
AccountManagerAccountIdentity::Public(amm_pool),
|
AccountManagerAccountIdentity::PublicNoSign(amm_pool),
|
||||||
AccountManagerAccountIdentity::Public(vault_holding_a),
|
AccountManagerAccountIdentity::PublicNoSign(vault_holding_a),
|
||||||
AccountManagerAccountIdentity::Public(vault_holding_b),
|
AccountManagerAccountIdentity::PublicNoSign(vault_holding_b),
|
||||||
AccountManagerAccountIdentity::Public(pool_lp),
|
AccountManagerAccountIdentity::PublicNoSign(pool_lp),
|
||||||
AccountManagerAccountIdentity::Public(user_holding_a),
|
AccountManagerAccountIdentity::PublicNoSign(user_holding_a),
|
||||||
AccountManagerAccountIdentity::Public(user_holding_b),
|
AccountManagerAccountIdentity::PublicNoSign(user_holding_b),
|
||||||
AccountManagerAccountIdentity::Public(user_holding_lp),
|
AccountManagerAccountIdentity::Public(user_holding_lp),
|
||||||
],
|
],
|
||||||
instruction_data,
|
instruction_data,
|
||||||
|
|||||||
@ -31,8 +31,8 @@ impl Ata<'_> {
|
|||||||
.send_pub_tx(
|
.send_pub_tx(
|
||||||
vec![
|
vec![
|
||||||
AccountManagerAccountIdentity::Public(owner_id),
|
AccountManagerAccountIdentity::Public(owner_id),
|
||||||
AccountManagerAccountIdentity::Public(definition_id),
|
AccountManagerAccountIdentity::PublicNoSign(definition_id),
|
||||||
AccountManagerAccountIdentity::Public(ata_id),
|
AccountManagerAccountIdentity::PublicNoSign(ata_id),
|
||||||
],
|
],
|
||||||
instruction_data,
|
instruction_data,
|
||||||
&program.into(),
|
&program.into(),
|
||||||
@ -64,8 +64,8 @@ impl Ata<'_> {
|
|||||||
.send_pub_tx(
|
.send_pub_tx(
|
||||||
vec![
|
vec![
|
||||||
AccountManagerAccountIdentity::Public(owner_id),
|
AccountManagerAccountIdentity::Public(owner_id),
|
||||||
AccountManagerAccountIdentity::Public(sender_ata_id),
|
AccountManagerAccountIdentity::PublicNoSign(sender_ata_id),
|
||||||
AccountManagerAccountIdentity::Public(recipient_id),
|
AccountManagerAccountIdentity::PublicNoSign(recipient_id),
|
||||||
],
|
],
|
||||||
instruction_data,
|
instruction_data,
|
||||||
&program.into(),
|
&program.into(),
|
||||||
@ -96,8 +96,8 @@ impl Ata<'_> {
|
|||||||
.send_pub_tx(
|
.send_pub_tx(
|
||||||
vec![
|
vec![
|
||||||
AccountManagerAccountIdentity::Public(owner_id),
|
AccountManagerAccountIdentity::Public(owner_id),
|
||||||
AccountManagerAccountIdentity::Public(holder_ata_id),
|
AccountManagerAccountIdentity::PublicNoSign(holder_ata_id),
|
||||||
AccountManagerAccountIdentity::Public(definition_id),
|
AccountManagerAccountIdentity::PublicNoSign(definition_id),
|
||||||
],
|
],
|
||||||
instruction_data,
|
instruction_data,
|
||||||
&program.into(),
|
&program.into(),
|
||||||
|
|||||||
@ -21,8 +21,8 @@ impl Pinata<'_> {
|
|||||||
self.0
|
self.0
|
||||||
.send_pub_tx(
|
.send_pub_tx(
|
||||||
vec![
|
vec![
|
||||||
AccountManagerAccountIdentity::Public(pinata_account_id),
|
AccountManagerAccountIdentity::PublicNoSign(pinata_account_id),
|
||||||
AccountManagerAccountIdentity::Public(winner_account_id),
|
AccountManagerAccountIdentity::PublicNoSign(winner_account_id),
|
||||||
],
|
],
|
||||||
instruction_data,
|
instruction_data,
|
||||||
&program.into(),
|
&program.into(),
|
||||||
|
|||||||
@ -345,7 +345,7 @@ impl Token<'_> {
|
|||||||
self.0
|
self.0
|
||||||
.send_pub_tx(
|
.send_pub_tx(
|
||||||
vec![
|
vec![
|
||||||
AccountManagerAccountIdentity::Public(definition_account_id),
|
AccountManagerAccountIdentity::PublicNoSign(definition_account_id),
|
||||||
AccountManagerAccountIdentity::Public(holder_account_id),
|
AccountManagerAccountIdentity::Public(holder_account_id),
|
||||||
],
|
],
|
||||||
instruction_data,
|
instruction_data,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user