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