mirror of
https://github.com/logos-blockchain/logos-execution-zone.git
synced 2026-05-13 19:49:29 +00:00
ci fixes
This commit is contained in:
parent
574ae746d4
commit
eb05957182
@ -89,7 +89,7 @@ async fn create_ata_initializes_holding_account() -> Result<()> {
|
||||
Command::Ata(AtaSubcommand::Create {
|
||||
owner: Some(format_public_account_id(owner_account_id)),
|
||||
token_definition: definition_account_id.to_string(),
|
||||
key_path: None,
|
||||
key_path: None,
|
||||
}),
|
||||
)
|
||||
.await?;
|
||||
@ -156,7 +156,7 @@ async fn create_ata_is_idempotent() -> Result<()> {
|
||||
Command::Ata(AtaSubcommand::Create {
|
||||
owner: Some(format_public_account_id(owner_account_id)),
|
||||
token_definition: definition_account_id.to_string(),
|
||||
key_path: None,
|
||||
key_path: None,
|
||||
}),
|
||||
)
|
||||
.await?;
|
||||
@ -170,7 +170,7 @@ async fn create_ata_is_idempotent() -> Result<()> {
|
||||
Command::Ata(AtaSubcommand::Create {
|
||||
owner: Some(format_public_account_id(owner_account_id)),
|
||||
token_definition: definition_account_id.to_string(),
|
||||
key_path: None,
|
||||
key_path: None,
|
||||
}),
|
||||
)
|
||||
.await?;
|
||||
@ -251,7 +251,7 @@ async fn transfer_and_burn_via_ata() -> Result<()> {
|
||||
Command::Ata(AtaSubcommand::Create {
|
||||
owner: Some(format_public_account_id(sender_account_id)),
|
||||
token_definition: definition_account_id.to_string(),
|
||||
key_path: None,
|
||||
key_path: None,
|
||||
}),
|
||||
)
|
||||
.await?;
|
||||
@ -260,7 +260,7 @@ async fn transfer_and_burn_via_ata() -> Result<()> {
|
||||
Command::Ata(AtaSubcommand::Create {
|
||||
owner: Some(format_public_account_id(recipient_account_id)),
|
||||
token_definition: definition_account_id.to_string(),
|
||||
key_path: None,
|
||||
key_path: None,
|
||||
}),
|
||||
)
|
||||
.await?;
|
||||
@ -282,7 +282,7 @@ async fn transfer_and_burn_via_ata() -> Result<()> {
|
||||
to_identifier: Some(0),
|
||||
amount: fund_amount,
|
||||
from_key_path: None,
|
||||
to_key_path: None,
|
||||
to_key_path: None,
|
||||
}),
|
||||
)
|
||||
.await?;
|
||||
@ -299,7 +299,7 @@ async fn transfer_and_burn_via_ata() -> Result<()> {
|
||||
token_definition: definition_account_id.to_string(),
|
||||
to: recipient_ata_id.to_string(),
|
||||
amount: transfer_amount,
|
||||
from_key_path: None,
|
||||
from_key_path: None,
|
||||
}),
|
||||
)
|
||||
.await?;
|
||||
@ -337,7 +337,7 @@ async fn transfer_and_burn_via_ata() -> Result<()> {
|
||||
holder: Some(format_public_account_id(sender_account_id)),
|
||||
token_definition: definition_account_id.to_string(),
|
||||
amount: burn_amount,
|
||||
key_path: None,
|
||||
key_path: None,
|
||||
}),
|
||||
)
|
||||
.await?;
|
||||
@ -407,7 +407,7 @@ async fn create_ata_with_private_owner() -> Result<()> {
|
||||
Command::Ata(AtaSubcommand::Create {
|
||||
owner: Some(format_private_account_id(owner_account_id)),
|
||||
token_definition: definition_account_id.to_string(),
|
||||
key_path: None,
|
||||
key_path: None,
|
||||
}),
|
||||
)
|
||||
.await?;
|
||||
@ -495,7 +495,7 @@ async fn transfer_via_ata_private_owner() -> Result<()> {
|
||||
Command::Ata(AtaSubcommand::Create {
|
||||
owner: Some(format_private_account_id(sender_account_id)),
|
||||
token_definition: definition_account_id.to_string(),
|
||||
key_path: None,
|
||||
key_path: None,
|
||||
}),
|
||||
)
|
||||
.await?;
|
||||
@ -504,7 +504,7 @@ async fn transfer_via_ata_private_owner() -> Result<()> {
|
||||
Command::Ata(AtaSubcommand::Create {
|
||||
owner: Some(format_public_account_id(recipient_account_id)),
|
||||
token_definition: definition_account_id.to_string(),
|
||||
key_path: None,
|
||||
key_path: None,
|
||||
}),
|
||||
)
|
||||
.await?;
|
||||
@ -543,7 +543,7 @@ async fn transfer_via_ata_private_owner() -> Result<()> {
|
||||
token_definition: definition_account_id.to_string(),
|
||||
to: recipient_ata_id.to_string(),
|
||||
amount: transfer_amount,
|
||||
from_key_path: None,
|
||||
from_key_path: None,
|
||||
}),
|
||||
)
|
||||
.await?;
|
||||
@ -625,7 +625,7 @@ async fn burn_via_ata_private_owner() -> Result<()> {
|
||||
Command::Ata(AtaSubcommand::Create {
|
||||
owner: Some(format_private_account_id(holder_account_id)),
|
||||
token_definition: definition_account_id.to_string(),
|
||||
key_path: None,
|
||||
key_path: None,
|
||||
}),
|
||||
)
|
||||
.await?;
|
||||
@ -663,7 +663,7 @@ async fn burn_via_ata_private_owner() -> Result<()> {
|
||||
holder: Some(format_private_account_id(holder_account_id)),
|
||||
token_definition: definition_account_id.to_string(),
|
||||
amount: burn_amount,
|
||||
key_path: None,
|
||||
key_path: None,
|
||||
}),
|
||||
)
|
||||
.await?;
|
||||
|
||||
@ -56,7 +56,7 @@ impl KeycardWallet {
|
||||
|
||||
PublicKey::try_new(public_key)
|
||||
.map_err(|e| PyErr::new::<pyo3::exceptions::PyValueError, _>(e.to_string()))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_public_key_for_path_with_connect(pin: &str, path: &str) -> PyResult<PublicKey> {
|
||||
Python::with_gil(|py| {
|
||||
@ -94,7 +94,7 @@ impl KeycardWallet {
|
||||
// The keycard Python library strips the leading zero from the S component when
|
||||
// S < 2^248. Re-insert it so the slice is always the expected 64 bytes (R || S).
|
||||
let py_signature = if py_signature.len() == 63 {
|
||||
let mut padded = [0u8; 64];
|
||||
let mut padded = [0_u8; 64];
|
||||
padded[..32].copy_from_slice(&py_signature[..32]);
|
||||
padded[33..].copy_from_slice(&py_signature[32..]);
|
||||
padded.to_vec()
|
||||
@ -153,7 +153,10 @@ impl KeycardWallet {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn get_public_account_id_for_path_with_connect(pin: &str, key_path: &str) -> PyResult<String> {
|
||||
pub fn get_public_account_id_for_path_with_connect(
|
||||
pin: &str,
|
||||
key_path: &str,
|
||||
) -> PyResult<String> {
|
||||
let public_key = Self::get_public_key_for_path_with_connect(pin, key_path)?;
|
||||
|
||||
Ok(format!("Public/{}", AccountId::from(&public_key)))
|
||||
@ -211,7 +214,10 @@ impl KeycardWallet {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn get_private_account_id_for_path_with_connect(pin: &str, key_path: &str) -> PyResult<String> {
|
||||
pub fn get_private_account_id_for_path_with_connect(
|
||||
pin: &str,
|
||||
key_path: &str,
|
||||
) -> PyResult<String> {
|
||||
let (nsk, _vsk) = Self::get_private_keys_for_path_with_connect(pin, key_path)?;
|
||||
let npk = NullifierPublicKey::from(&nsk);
|
||||
|
||||
|
||||
@ -67,7 +67,7 @@ pub enum AccountSubcommand {
|
||||
},
|
||||
/// Print the raw account ID (without privacy prefix) for shell scripting.
|
||||
///
|
||||
/// Example: LEE_DEF=$(wallet account id --account-label lee-def)
|
||||
/// Example: `LEE_DEF=$(wallet account id --account-label lee-def)`.
|
||||
Id {
|
||||
/// Account label.
|
||||
#[arg(long, conflicts_with = "account_id", required_unless_present_any = ["account_id", "key_path"])]
|
||||
|
||||
@ -27,10 +27,18 @@ pub enum AmmProgramAgnosticSubcommand {
|
||||
)]
|
||||
user_holding_a: Option<String>,
|
||||
/// User holding A account label (alternative to --user-holding-a).
|
||||
#[arg(long, conflicts_with = "user_holding_a", conflicts_with = "user_holding_a_key_path")]
|
||||
#[arg(
|
||||
long,
|
||||
conflicts_with = "user_holding_a",
|
||||
conflicts_with = "user_holding_a_key_path"
|
||||
)]
|
||||
user_holding_a_label: Option<String>,
|
||||
/// Key path for user holding A (uses Keycard, alternative to --user-holding-a/label).
|
||||
#[arg(long, conflicts_with = "user_holding_a", conflicts_with = "user_holding_a_label")]
|
||||
#[arg(
|
||||
long,
|
||||
conflicts_with = "user_holding_a",
|
||||
conflicts_with = "user_holding_a_label"
|
||||
)]
|
||||
user_holding_a_key_path: Option<String>,
|
||||
/// `user_holding_b` - valid 32 byte base58 string with privacy prefix.
|
||||
#[arg(
|
||||
@ -41,10 +49,18 @@ pub enum AmmProgramAgnosticSubcommand {
|
||||
)]
|
||||
user_holding_b: Option<String>,
|
||||
/// User holding B account label (alternative to --user-holding-b).
|
||||
#[arg(long, conflicts_with = "user_holding_b", conflicts_with = "user_holding_b_key_path")]
|
||||
#[arg(
|
||||
long,
|
||||
conflicts_with = "user_holding_b",
|
||||
conflicts_with = "user_holding_b_key_path"
|
||||
)]
|
||||
user_holding_b_label: Option<String>,
|
||||
/// Key path for user holding B (uses Keycard, alternative to --user-holding-b/label).
|
||||
#[arg(long, conflicts_with = "user_holding_b", conflicts_with = "user_holding_b_label")]
|
||||
#[arg(
|
||||
long,
|
||||
conflicts_with = "user_holding_b",
|
||||
conflicts_with = "user_holding_b_label"
|
||||
)]
|
||||
user_holding_b_key_path: Option<String>,
|
||||
/// `user_holding_lp` - valid 32 byte base58 string with privacy prefix.
|
||||
#[arg(
|
||||
@ -136,10 +152,18 @@ pub enum AmmProgramAgnosticSubcommand {
|
||||
)]
|
||||
user_holding_a: Option<String>,
|
||||
/// User holding A account label (alternative to --user-holding-a).
|
||||
#[arg(long, conflicts_with = "user_holding_a", conflicts_with = "user_holding_a_key_path")]
|
||||
#[arg(
|
||||
long,
|
||||
conflicts_with = "user_holding_a",
|
||||
conflicts_with = "user_holding_a_key_path"
|
||||
)]
|
||||
user_holding_a_label: Option<String>,
|
||||
/// Key path for user holding A (uses Keycard).
|
||||
#[arg(long, conflicts_with = "user_holding_a", conflicts_with = "user_holding_a_label")]
|
||||
#[arg(
|
||||
long,
|
||||
conflicts_with = "user_holding_a",
|
||||
conflicts_with = "user_holding_a_label"
|
||||
)]
|
||||
user_holding_a_key_path: Option<String>,
|
||||
/// `user_holding_b` - valid 32 byte base58 string with privacy prefix.
|
||||
#[arg(
|
||||
@ -150,10 +174,18 @@ pub enum AmmProgramAgnosticSubcommand {
|
||||
)]
|
||||
user_holding_b: Option<String>,
|
||||
/// User holding B account label (alternative to --user-holding-b).
|
||||
#[arg(long, conflicts_with = "user_holding_b", conflicts_with = "user_holding_b_key_path")]
|
||||
#[arg(
|
||||
long,
|
||||
conflicts_with = "user_holding_b",
|
||||
conflicts_with = "user_holding_b_key_path"
|
||||
)]
|
||||
user_holding_b_label: Option<String>,
|
||||
/// Key path for user holding B (uses Keycard).
|
||||
#[arg(long, conflicts_with = "user_holding_b", conflicts_with = "user_holding_b_label")]
|
||||
#[arg(
|
||||
long,
|
||||
conflicts_with = "user_holding_b",
|
||||
conflicts_with = "user_holding_b_label"
|
||||
)]
|
||||
user_holding_b_key_path: Option<String>,
|
||||
/// `user_holding_lp` - valid 32 byte base58 string with privacy prefix.
|
||||
#[arg(
|
||||
@ -207,10 +239,18 @@ pub enum AmmProgramAgnosticSubcommand {
|
||||
)]
|
||||
user_holding_lp: Option<String>,
|
||||
/// User holding LP account label (alternative to --user-holding-lp).
|
||||
#[arg(long, conflicts_with = "user_holding_lp", conflicts_with = "user_holding_lp_key_path")]
|
||||
#[arg(
|
||||
long,
|
||||
conflicts_with = "user_holding_lp",
|
||||
conflicts_with = "user_holding_lp_key_path"
|
||||
)]
|
||||
user_holding_lp_label: Option<String>,
|
||||
/// Key path for user holding LP (uses Keycard).
|
||||
#[arg(long, conflicts_with = "user_holding_lp", conflicts_with = "user_holding_lp_label")]
|
||||
#[arg(
|
||||
long,
|
||||
conflicts_with = "user_holding_lp",
|
||||
conflicts_with = "user_holding_lp_label"
|
||||
)]
|
||||
user_holding_lp_key_path: Option<String>,
|
||||
#[arg(long)]
|
||||
balance_lp: u128,
|
||||
|
||||
@ -159,7 +159,13 @@ impl WalletSubcommand for AtaSubcommand {
|
||||
match from_privacy {
|
||||
AccountPrivacyKind::Public => {
|
||||
Ata(wallet_core)
|
||||
.send_transfer(from_id, definition_id, to_id, amount, from_key_path.as_deref())
|
||||
.send_transfer(
|
||||
from_id,
|
||||
definition_id,
|
||||
to_id,
|
||||
amount,
|
||||
from_key_path.as_deref(),
|
||||
)
|
||||
.await?;
|
||||
Ok(SubcommandReturnValue::Empty)
|
||||
}
|
||||
@ -194,7 +200,8 @@ impl WalletSubcommand for AtaSubcommand {
|
||||
(None, Some(kp)) => resolve_keycard_id(kp)?,
|
||||
(None, None) => anyhow::bail!("Provide --holder or --key-path"),
|
||||
};
|
||||
let (holder_str, holder_privacy) = parse_addr_with_privacy_prefix(&holder_resolved)?;
|
||||
let (holder_str, holder_privacy) =
|
||||
parse_addr_with_privacy_prefix(&holder_resolved)?;
|
||||
let holder_id: AccountId = holder_str.parse()?;
|
||||
let definition_id: AccountId = token_definition.parse()?;
|
||||
|
||||
|
||||
@ -5,8 +5,7 @@ use nssa::AccountId;
|
||||
|
||||
use crate::{
|
||||
AccDecodeData::Decode,
|
||||
PrivacyPreservingAccount,
|
||||
WalletCore,
|
||||
PrivacyPreservingAccount, WalletCore,
|
||||
cli::{SubcommandReturnValue, WalletSubcommand},
|
||||
helperfunctions::{
|
||||
AccountPrivacyKind, parse_addr_with_privacy_prefix, resolve_account_label,
|
||||
@ -29,10 +28,18 @@ pub enum TokenProgramAgnosticSubcommand {
|
||||
)]
|
||||
definition_account_id: Option<String>,
|
||||
/// Definition account label (alternative to --definition-account-id).
|
||||
#[arg(long, conflicts_with = "definition_account_id", conflicts_with = "definition_key_path")]
|
||||
#[arg(
|
||||
long,
|
||||
conflicts_with = "definition_account_id",
|
||||
conflicts_with = "definition_key_path"
|
||||
)]
|
||||
definition_account_label: Option<String>,
|
||||
/// Key path for the definition account (uses Keycard).
|
||||
#[arg(long, conflicts_with = "definition_account_id", conflicts_with = "definition_account_label")]
|
||||
#[arg(
|
||||
long,
|
||||
conflicts_with = "definition_account_id",
|
||||
conflicts_with = "definition_account_label"
|
||||
)]
|
||||
definition_key_path: Option<String>,
|
||||
/// `supply_account_id` - valid 32 byte base58 string with privacy prefix.
|
||||
#[arg(
|
||||
@ -43,10 +50,18 @@ pub enum TokenProgramAgnosticSubcommand {
|
||||
)]
|
||||
supply_account_id: Option<String>,
|
||||
/// Supply account label (alternative to --supply-account-id).
|
||||
#[arg(long, conflicts_with = "supply_account_id", conflicts_with = "supply_key_path")]
|
||||
#[arg(
|
||||
long,
|
||||
conflicts_with = "supply_account_id",
|
||||
conflicts_with = "supply_key_path"
|
||||
)]
|
||||
supply_account_label: Option<String>,
|
||||
/// Key path for the supply account (uses Keycard).
|
||||
#[arg(long, conflicts_with = "supply_account_id", conflicts_with = "supply_account_label")]
|
||||
#[arg(
|
||||
long,
|
||||
conflicts_with = "supply_account_id",
|
||||
conflicts_with = "supply_account_label"
|
||||
)]
|
||||
supply_key_path: Option<String>,
|
||||
#[arg(short, long)]
|
||||
name: String,
|
||||
@ -121,10 +136,20 @@ pub enum TokenProgramAgnosticSubcommand {
|
||||
#[arg(long)]
|
||||
amount: u128,
|
||||
/// `from_key_path` (alternative to --from) uses Keycard.
|
||||
#[arg(long, conflicts_with = "from", conflicts_with = "from", conflicts_with = "from_label")]
|
||||
#[arg(
|
||||
long,
|
||||
conflicts_with = "from",
|
||||
conflicts_with = "from",
|
||||
conflicts_with = "from_label"
|
||||
)]
|
||||
from_key_path: Option<String>,
|
||||
/// `to_key_path` (alternative to --to) uses Keycard.
|
||||
#[arg(long, conflicts_with = "to", conflicts_with = "to", conflicts_with = "to_label")]
|
||||
#[arg(
|
||||
long,
|
||||
conflicts_with = "to",
|
||||
conflicts_with = "to",
|
||||
conflicts_with = "to_label"
|
||||
)]
|
||||
to_key_path: Option<String>,
|
||||
},
|
||||
/// Burn tokens on `holder`, modify `definition`.
|
||||
@ -174,10 +199,18 @@ pub enum TokenProgramAgnosticSubcommand {
|
||||
)]
|
||||
definition: Option<String>,
|
||||
/// Definition account label (alternative to --definition).
|
||||
#[arg(long, conflicts_with = "definition", conflicts_with = "definition_key_path")]
|
||||
#[arg(
|
||||
long,
|
||||
conflicts_with = "definition",
|
||||
conflicts_with = "definition_key_path"
|
||||
)]
|
||||
definition_label: Option<String>,
|
||||
/// Key path for the definition account (uses Keycard).
|
||||
#[arg(long, conflicts_with = "definition", conflicts_with = "definition_label")]
|
||||
#[arg(
|
||||
long,
|
||||
conflicts_with = "definition",
|
||||
conflicts_with = "definition_label"
|
||||
)]
|
||||
definition_key_path: Option<String>,
|
||||
/// holder - valid 32 byte base58 string with privacy prefix.
|
||||
#[arg(long, conflicts_with = "holder_label", conflicts_with = "holder_key_path", required_unless_present_any = ["holder_label", "holder_key_path"])]
|
||||
@ -417,9 +450,7 @@ impl WalletSubcommand for TokenProgramAgnosticSubcommand {
|
||||
&wallet_core.storage.labels,
|
||||
&wallet_core.storage.user_data,
|
||||
)?),
|
||||
(None, None, Some(to_key_path)) => {
|
||||
Some(resolve_keycard_id(&to_key_path)?)
|
||||
}
|
||||
(None, None, Some(to_key_path)) => Some(resolve_keycard_id(&to_key_path)?),
|
||||
_ => {
|
||||
anyhow::bail!("Provide only one of --to or --to-label")
|
||||
}
|
||||
@ -608,7 +639,9 @@ impl WalletSubcommand for TokenProgramAgnosticSubcommand {
|
||||
)?),
|
||||
(None, None, Some(kp)) => Some(resolve_keycard_id(kp)?),
|
||||
_ => {
|
||||
anyhow::bail!("Provide only one of --holder, --holder-label, or --holder-key-path")
|
||||
anyhow::bail!(
|
||||
"Provide only one of --holder, --holder-label, or --holder-key-path"
|
||||
)
|
||||
}
|
||||
};
|
||||
let underlying_subcommand = match (holder, holder_npk, holder_vpk) {
|
||||
|
||||
@ -80,16 +80,14 @@ pub fn resolve_id_or_label(
|
||||
match (id, label, key_path) {
|
||||
(Some(id), None, None) => Ok(id),
|
||||
(None, Some(label), None) => resolve_account_label(&label, labels, user_data),
|
||||
(None, None, Some(key_path)) => {
|
||||
resolve_keycard_id(key_path)
|
||||
}
|
||||
(None, None, Some(key_path)) => resolve_keycard_id(key_path),
|
||||
_ => anyhow::bail!("provide exactly one of account id, account label or keycard path"),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn resolve_keycard_id(key_path: &str) -> Result<String> {
|
||||
let pin = read_pin()?;
|
||||
KeycardWallet::get_public_account_id_for_path_with_connect(&pin, key_path)
|
||||
KeycardWallet::get_public_account_id_for_path_with_connect(&pin, key_path)
|
||||
.map_err(anyhow::Error::from)
|
||||
}
|
||||
|
||||
|
||||
@ -136,7 +136,7 @@ impl AccountManager {
|
||||
self.states
|
||||
.iter()
|
||||
.filter_map(|state| match state {
|
||||
State::Public { account, .. } => Some(account.account.nonce),
|
||||
State::Public { account, sk } => sk.as_ref().map(|_| account.account.nonce),
|
||||
State::Private(_) => None,
|
||||
})
|
||||
.collect()
|
||||
|
||||
@ -8,7 +8,10 @@ use crate::{ExecutionFailureKind, WalletCore};
|
||||
pub struct Amm<'wallet>(pub &'wallet WalletCore);
|
||||
|
||||
impl Amm<'_> {
|
||||
#[expect(clippy::too_many_arguments, reason = "each parameter is distinct; grouping into a struct would add unnecessary indirection")]
|
||||
#[expect(
|
||||
clippy::too_many_arguments,
|
||||
reason = "each parameter is distinct; grouping into a struct would add unnecessary indirection"
|
||||
)]
|
||||
pub async fn send_new_definition(
|
||||
&self,
|
||||
user_holding_a: AccountId,
|
||||
@ -98,9 +101,10 @@ impl Amm<'_> {
|
||||
let msg_hash = message.hash();
|
||||
let pin = if key_path_a.is_some() || key_path_b.is_some() {
|
||||
Some(crate::helperfunctions::read_pin().map_err(|e| {
|
||||
ExecutionFailureKind::KeycardError(pyo3::PyErr::new::<pyo3::exceptions::PyRuntimeError, _>(
|
||||
e.to_string(),
|
||||
))
|
||||
ExecutionFailureKind::KeycardError(pyo3::PyErr::new::<
|
||||
pyo3::exceptions::PyRuntimeError,
|
||||
_,
|
||||
>(e.to_string()))
|
||||
})?)
|
||||
} else {
|
||||
None
|
||||
@ -119,7 +123,10 @@ impl Amm<'_> {
|
||||
.user_data
|
||||
.get_pub_account_signing_key(user_holding_a)
|
||||
.ok_or(ExecutionFailureKind::KeyNotFoundError)?;
|
||||
(nssa::Signature::new(sk, &msg_hash), nssa::PublicKey::new_from_private_key(sk))
|
||||
(
|
||||
nssa::Signature::new(sk, &msg_hash),
|
||||
nssa::PublicKey::new_from_private_key(sk),
|
||||
)
|
||||
};
|
||||
|
||||
let (sig_b, pk_b) = if let Some(kp) = key_path_b {
|
||||
@ -135,7 +142,10 @@ impl Amm<'_> {
|
||||
.user_data
|
||||
.get_pub_account_signing_key(user_holding_b)
|
||||
.ok_or(ExecutionFailureKind::KeyNotFoundError)?;
|
||||
(nssa::Signature::new(sk, &msg_hash), nssa::PublicKey::new_from_private_key(sk))
|
||||
(
|
||||
nssa::Signature::new(sk, &msg_hash),
|
||||
nssa::PublicKey::new_from_private_key(sk),
|
||||
)
|
||||
};
|
||||
|
||||
let mut sigs = vec![sig_a, sig_b];
|
||||
@ -233,12 +243,14 @@ impl Amm<'_> {
|
||||
let msg_hash = message.hash();
|
||||
let witness_set = if let Some(kp) = key_path {
|
||||
let pin = crate::helperfunctions::read_pin().map_err(|e| {
|
||||
ExecutionFailureKind::KeycardError(pyo3::PyErr::new::<pyo3::exceptions::PyRuntimeError, _>(
|
||||
e.to_string(),
|
||||
))
|
||||
ExecutionFailureKind::KeycardError(pyo3::PyErr::new::<
|
||||
pyo3::exceptions::PyRuntimeError,
|
||||
_,
|
||||
>(e.to_string()))
|
||||
})?;
|
||||
let (sig, pk) =
|
||||
keycard_wallet::KeycardWallet::sign_message_for_path_with_connect(&pin, kp, &msg_hash)?;
|
||||
let (sig, pk) = keycard_wallet::KeycardWallet::sign_message_for_path_with_connect(
|
||||
&pin, kp, &msg_hash,
|
||||
)?;
|
||||
nssa::public_transaction::WitnessSet::from_list(&message, &[sig], &[pk])
|
||||
.map_err(ExecutionFailureKind::TransactionBuildError)?
|
||||
} else {
|
||||
@ -335,12 +347,14 @@ impl Amm<'_> {
|
||||
let msg_hash = message.hash();
|
||||
let witness_set = if let Some(kp) = key_path {
|
||||
let pin = crate::helperfunctions::read_pin().map_err(|e| {
|
||||
ExecutionFailureKind::KeycardError(pyo3::PyErr::new::<pyo3::exceptions::PyRuntimeError, _>(
|
||||
e.to_string(),
|
||||
))
|
||||
ExecutionFailureKind::KeycardError(pyo3::PyErr::new::<
|
||||
pyo3::exceptions::PyRuntimeError,
|
||||
_,
|
||||
>(e.to_string()))
|
||||
})?;
|
||||
let (sig, pk) =
|
||||
keycard_wallet::KeycardWallet::sign_message_for_path_with_connect(&pin, kp, &msg_hash)?;
|
||||
let (sig, pk) = keycard_wallet::KeycardWallet::sign_message_for_path_with_connect(
|
||||
&pin, kp, &msg_hash,
|
||||
)?;
|
||||
nssa::public_transaction::WitnessSet::from_list(&message, &[sig], &[pk])
|
||||
.map_err(ExecutionFailureKind::TransactionBuildError)?
|
||||
} else {
|
||||
@ -362,7 +376,10 @@ impl Amm<'_> {
|
||||
.await?)
|
||||
}
|
||||
|
||||
#[expect(clippy::too_many_arguments, reason = "each parameter is distinct; grouping into a struct would add unnecessary indirection")]
|
||||
#[expect(
|
||||
clippy::too_many_arguments,
|
||||
reason = "each parameter is distinct; grouping into a struct would add unnecessary indirection"
|
||||
)]
|
||||
pub async fn send_add_liquidity(
|
||||
&self,
|
||||
user_holding_a: AccountId,
|
||||
@ -433,9 +450,10 @@ impl Amm<'_> {
|
||||
let msg_hash = message.hash();
|
||||
let pin = if key_path_a.is_some() || key_path_b.is_some() {
|
||||
Some(crate::helperfunctions::read_pin().map_err(|e| {
|
||||
ExecutionFailureKind::KeycardError(pyo3::PyErr::new::<pyo3::exceptions::PyRuntimeError, _>(
|
||||
e.to_string(),
|
||||
))
|
||||
ExecutionFailureKind::KeycardError(pyo3::PyErr::new::<
|
||||
pyo3::exceptions::PyRuntimeError,
|
||||
_,
|
||||
>(e.to_string()))
|
||||
})?)
|
||||
} else {
|
||||
None
|
||||
@ -454,7 +472,10 @@ impl Amm<'_> {
|
||||
.user_data
|
||||
.get_pub_account_signing_key(user_holding_a)
|
||||
.ok_or(ExecutionFailureKind::KeyNotFoundError)?;
|
||||
(nssa::Signature::new(sk, &msg_hash), nssa::PublicKey::new_from_private_key(sk))
|
||||
(
|
||||
nssa::Signature::new(sk, &msg_hash),
|
||||
nssa::PublicKey::new_from_private_key(sk),
|
||||
)
|
||||
};
|
||||
|
||||
let (sig_b, pk_b) = if let Some(kp) = key_path_b {
|
||||
@ -470,12 +491,18 @@ impl Amm<'_> {
|
||||
.user_data
|
||||
.get_pub_account_signing_key(user_holding_b)
|
||||
.ok_or(ExecutionFailureKind::KeyNotFoundError)?;
|
||||
(nssa::Signature::new(sk, &msg_hash), nssa::PublicKey::new_from_private_key(sk))
|
||||
(
|
||||
nssa::Signature::new(sk, &msg_hash),
|
||||
nssa::PublicKey::new_from_private_key(sk),
|
||||
)
|
||||
};
|
||||
|
||||
let witness_set =
|
||||
nssa::public_transaction::WitnessSet::from_list(&message, &[sig_a, sig_b], &[pk_a, pk_b])
|
||||
.map_err(ExecutionFailureKind::TransactionBuildError)?;
|
||||
let witness_set = nssa::public_transaction::WitnessSet::from_list(
|
||||
&message,
|
||||
&[sig_a, sig_b],
|
||||
&[pk_a, pk_b],
|
||||
)
|
||||
.map_err(ExecutionFailureKind::TransactionBuildError)?;
|
||||
|
||||
let tx = nssa::PublicTransaction::new(message, witness_set);
|
||||
|
||||
@ -486,7 +513,10 @@ impl Amm<'_> {
|
||||
.await?)
|
||||
}
|
||||
|
||||
#[expect(clippy::too_many_arguments, reason = "each parameter is distinct; grouping into a struct would add unnecessary indirection")]
|
||||
#[expect(
|
||||
clippy::too_many_arguments,
|
||||
reason = "each parameter is distinct; grouping into a struct would add unnecessary indirection"
|
||||
)]
|
||||
pub async fn send_remove_liquidity(
|
||||
&self,
|
||||
user_holding_a: AccountId,
|
||||
@ -556,12 +586,14 @@ impl Amm<'_> {
|
||||
let msg_hash = message.hash();
|
||||
let witness_set = if let Some(kp) = key_path_lp {
|
||||
let pin = crate::helperfunctions::read_pin().map_err(|e| {
|
||||
ExecutionFailureKind::KeycardError(pyo3::PyErr::new::<pyo3::exceptions::PyRuntimeError, _>(
|
||||
e.to_string(),
|
||||
))
|
||||
ExecutionFailureKind::KeycardError(pyo3::PyErr::new::<
|
||||
pyo3::exceptions::PyRuntimeError,
|
||||
_,
|
||||
>(e.to_string()))
|
||||
})?;
|
||||
let (sig, pk) =
|
||||
keycard_wallet::KeycardWallet::sign_message_for_path_with_connect(&pin, kp, &msg_hash)?;
|
||||
let (sig, pk) = keycard_wallet::KeycardWallet::sign_message_for_path_with_connect(
|
||||
&pin, kp, &msg_hash,
|
||||
)?;
|
||||
nssa::public_transaction::WitnessSet::from_list(&message, &[sig], &[pk])
|
||||
.map_err(ExecutionFailureKind::TransactionBuildError)?
|
||||
} else {
|
||||
|
||||
@ -46,12 +46,14 @@ impl Ata<'_> {
|
||||
let msg_hash = message.hash();
|
||||
let witness_set = if let Some(kp) = key_path {
|
||||
let pin = crate::helperfunctions::read_pin().map_err(|e| {
|
||||
ExecutionFailureKind::KeycardError(pyo3::PyErr::new::<pyo3::exceptions::PyRuntimeError, _>(
|
||||
e.to_string(),
|
||||
))
|
||||
ExecutionFailureKind::KeycardError(pyo3::PyErr::new::<
|
||||
pyo3::exceptions::PyRuntimeError,
|
||||
_,
|
||||
>(e.to_string()))
|
||||
})?;
|
||||
let (sig, pk) =
|
||||
keycard_wallet::KeycardWallet::sign_message_for_path_with_connect(&pin, kp, &msg_hash)?;
|
||||
let (sig, pk) = keycard_wallet::KeycardWallet::sign_message_for_path_with_connect(
|
||||
&pin, kp, &msg_hash,
|
||||
)?;
|
||||
nssa::public_transaction::WitnessSet::from_list(&message, &[sig], &[pk])
|
||||
.map_err(ExecutionFailureKind::TransactionBuildError)?
|
||||
} else {
|
||||
@ -113,12 +115,14 @@ impl Ata<'_> {
|
||||
let msg_hash = message.hash();
|
||||
let witness_set = if let Some(kp) = key_path {
|
||||
let pin = crate::helperfunctions::read_pin().map_err(|e| {
|
||||
ExecutionFailureKind::KeycardError(pyo3::PyErr::new::<pyo3::exceptions::PyRuntimeError, _>(
|
||||
e.to_string(),
|
||||
))
|
||||
ExecutionFailureKind::KeycardError(pyo3::PyErr::new::<
|
||||
pyo3::exceptions::PyRuntimeError,
|
||||
_,
|
||||
>(e.to_string()))
|
||||
})?;
|
||||
let (sig, pk) =
|
||||
keycard_wallet::KeycardWallet::sign_message_for_path_with_connect(&pin, kp, &msg_hash)?;
|
||||
let (sig, pk) = keycard_wallet::KeycardWallet::sign_message_for_path_with_connect(
|
||||
&pin, kp, &msg_hash,
|
||||
)?;
|
||||
nssa::public_transaction::WitnessSet::from_list(&message, &[sig], &[pk])
|
||||
.map_err(ExecutionFailureKind::TransactionBuildError)?
|
||||
} else {
|
||||
@ -179,12 +183,14 @@ impl Ata<'_> {
|
||||
let msg_hash = message.hash();
|
||||
let witness_set = if let Some(kp) = key_path {
|
||||
let pin = crate::helperfunctions::read_pin().map_err(|e| {
|
||||
ExecutionFailureKind::KeycardError(pyo3::PyErr::new::<pyo3::exceptions::PyRuntimeError, _>(
|
||||
e.to_string(),
|
||||
))
|
||||
ExecutionFailureKind::KeycardError(pyo3::PyErr::new::<
|
||||
pyo3::exceptions::PyRuntimeError,
|
||||
_,
|
||||
>(e.to_string()))
|
||||
})?;
|
||||
let (sig, pk) =
|
||||
keycard_wallet::KeycardWallet::sign_message_for_path_with_connect(&pin, kp, &msg_hash)?;
|
||||
let (sig, pk) = keycard_wallet::KeycardWallet::sign_message_for_path_with_connect(
|
||||
&pin, kp, &msg_hash,
|
||||
)?;
|
||||
nssa::public_transaction::WitnessSet::from_list(&message, &[sig], &[pk])
|
||||
.map_err(ExecutionFailureKind::TransactionBuildError)?
|
||||
} else {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
use common::{HashType, transaction::NSSATransaction};
|
||||
use keycard_wallet::KeycardWallet;
|
||||
use nssa::{AccountId, Signature, PublicKey, program::Program, public_transaction::WitnessSet};
|
||||
use nssa::{AccountId, PublicKey, Signature, program::Program, public_transaction::WitnessSet};
|
||||
use nssa_core::{Identifier, NullifierPublicKey, SharedSecretKey, encryption::ViewingPublicKey};
|
||||
use pyo3::exceptions::PyRuntimeError;
|
||||
use sequencer_service_rpc::RpcClient as _;
|
||||
@ -56,7 +56,10 @@ impl Token<'_> {
|
||||
.user_data
|
||||
.get_pub_account_signing_key(definition_account_id)
|
||||
.ok_or(ExecutionFailureKind::KeyNotFoundError)?;
|
||||
(Signature::new(sk, &msg_hash), PublicKey::new_from_private_key(sk))
|
||||
(
|
||||
Signature::new(sk, &msg_hash),
|
||||
PublicKey::new_from_private_key(sk),
|
||||
)
|
||||
};
|
||||
|
||||
let (sig_sup, pk_sup) = if let Some(kp) = supply_key_path {
|
||||
@ -68,7 +71,10 @@ impl Token<'_> {
|
||||
.user_data
|
||||
.get_pub_account_signing_key(supply_account_id)
|
||||
.ok_or(ExecutionFailureKind::KeyNotFoundError)?;
|
||||
(Signature::new(sk, &msg_hash), PublicKey::new_from_private_key(sk))
|
||||
(
|
||||
Signature::new(sk, &msg_hash),
|
||||
PublicKey::new_from_private_key(sk),
|
||||
)
|
||||
};
|
||||
|
||||
let witness_set = nssa::public_transaction::WitnessSet::from_list(
|
||||
@ -441,15 +447,17 @@ impl Token<'_> {
|
||||
|
||||
let witness_set = if let Some(key_path) = key_path {
|
||||
let pin = crate::helperfunctions::read_pin().map_err(|e| {
|
||||
ExecutionFailureKind::KeycardError(
|
||||
pyo3::PyErr::new::<pyo3::exceptions::PyRuntimeError, _>(e.to_string()),
|
||||
)
|
||||
ExecutionFailureKind::KeycardError(pyo3::PyErr::new::<
|
||||
pyo3::exceptions::PyRuntimeError,
|
||||
_,
|
||||
>(e.to_string()))
|
||||
})?;
|
||||
let (signature, pub_key) = keycard_wallet::KeycardWallet::sign_message_for_path_with_connect(
|
||||
&pin,
|
||||
key_path,
|
||||
&message.hash(),
|
||||
)?;
|
||||
let (signature, pub_key) =
|
||||
keycard_wallet::KeycardWallet::sign_message_for_path_with_connect(
|
||||
&pin,
|
||||
key_path,
|
||||
&message.hash(),
|
||||
)?;
|
||||
nssa::public_transaction::WitnessSet::from_list(&message, &[signature], &[pub_key])
|
||||
.map_err(ExecutionFailureKind::TransactionBuildError)?
|
||||
} else {
|
||||
@ -517,8 +525,7 @@ impl Token<'_> {
|
||||
e.to_string(),
|
||||
))
|
||||
})?;
|
||||
let (sig, pk) =
|
||||
KeycardWallet::sign_message_for_path_with_connect(&pin, kp, &msg_hash)?;
|
||||
let (sig, pk) = KeycardWallet::sign_message_for_path_with_connect(&pin, kp, &msg_hash)?;
|
||||
nssa::public_transaction::WitnessSet::from_list(&message, &[sig], &[pk])
|
||||
.map_err(ExecutionFailureKind::TransactionBuildError)?
|
||||
} else {
|
||||
@ -687,8 +694,7 @@ impl Token<'_> {
|
||||
e.to_string(),
|
||||
))
|
||||
})?;
|
||||
let (sig, pk) =
|
||||
KeycardWallet::sign_message_for_path_with_connect(&pin, kp, &msg_hash)?;
|
||||
let (sig, pk) = KeycardWallet::sign_message_for_path_with_connect(&pin, kp, &msg_hash)?;
|
||||
nssa::public_transaction::WitnessSet::from_list(&message, &[sig], &[pk])
|
||||
.map_err(ExecutionFailureKind::TransactionBuildError)?
|
||||
} else {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user