fix: suggestions fix 1

This commit is contained in:
Pravdyvy 2026-01-15 12:05:35 +02:00
parent dfd28b423b
commit 0426bfe9c9
7 changed files with 31 additions and 32 deletions

View File

@ -75,7 +75,6 @@ chrono = "0.4.41"
borsh = "1.5.7"
base58 = "0.2.0"
itertools = "0.14.0"
paste = "1.0.15"
rocksdb = { version = "0.24.0", default-features = false, features = [
"snappy",

View File

@ -28,5 +28,5 @@ futures.workspace = true
risc0-zkvm.workspace = true
async-stream = "0.3.6"
indicatif = { version = "0.18.3", features = ["improved_unicode"] }
paste.workspace = true
paste = "1.0.15"
optfield = "0.4.0"

View File

@ -18,15 +18,15 @@ trait ParsePrivacyPreservingAccount {
#[macro_export]
macro_rules! owned_account_name {
($classname: ident, $field: ident) => {
($structname: ident, $field: ident) => {
#[derive(Debug, Args, Clone)]
pub struct $classname {
pub struct $structname {
/// $field - valid 32 byte base58 string with privacy prefix
#[arg(long)]
pub $field: String,
}
impl ParsePrivacyPreservingAccount for $classname {
impl ParsePrivacyPreservingAccount for $structname {
fn parse(&self) -> Result<PrivacyPreservingAccount> {
let (account_id, privacy) = parse_addr_with_privacy_prefix(&self.$field)?;
@ -47,10 +47,10 @@ owned_account_name!(ArgsSenderOwned, from);
#[macro_export]
macro_rules! maybe_unowned_account_name {
($classname: ident, $field: ident) => {
($structname: ident, $field: ident) => {
paste! {
#[derive(Debug, Args, Clone)]
pub struct $classname {
pub struct $structname {
/// $field - valid 32 byte base58 string with privacy prefix
#[arg(long)]
pub $field: Option<String>,
@ -62,7 +62,7 @@ macro_rules! maybe_unowned_account_name {
pub [<$field _ipk>]: Option<String>,
}
impl ParsePrivacyPreservingAccount for $classname {
impl ParsePrivacyPreservingAccount for $structname {
fn parse(&self) -> Result<PrivacyPreservingAccount> {
match (&self.$field, &self.[<$field _npk>], &self.[<$field _ipk>]) {
(None, None, None) => {
@ -74,28 +74,28 @@ macro_rules! maybe_unowned_account_name {
);
}
(_, Some(_), None) | (_, None, Some(_)) => {
anyhow::bail!("List of public keys is uncomplete");
anyhow::bail!("List of public keys is incomplete");
}
(Some($field), None, None) => ArgsSenderOwned {
from: $field.clone(),
}
.parse(),
(None, Some([<$field _npk>]), Some([<$field _ipk>])) => {
let [<$field _npk_res>] = hex::decode([<$field _npk>])?;
let mut [<$field _npk>] = [0; 32];
[<$field _npk>].copy_from_slice(&[<$field _npk_res>]);
let [<$field _npk>] = nssa_core::NullifierPublicKey([<$field _npk>]);
(None, Some(npk), Some(ipk)) => {
let npk_res = hex::decode(npk)?;
let mut npk = [0; 32];
npk.copy_from_slice(&npk_res);
let npk = nssa_core::NullifierPublicKey(npk);
let [<$field _ipk_res>] = hex::decode([<$field _ipk>])?;
let mut [<$field _ipk>] = [0u8; 33];
[<$field _ipk>].copy_from_slice(&[<$field _ipk_res>]);
let [<$field _ipk>] = nssa_core::encryption::shared_key_derivation::Secp256k1Point(
[<$field _ipk>].to_vec(),
let ipk_res = hex::decode(ipk)?;
let mut ipk = [0u8; 33];
ipk.copy_from_slice(&ipk_res);
let ipk = nssa_core::encryption::shared_key_derivation::Secp256k1Point(
ipk.to_vec(),
);
Ok(PrivacyPreservingAccount::PrivateForeign {
npk: [<$field _npk>],
ipk: [<$field _ipk>],
npk,
ipk,
})
}
}

View File

@ -39,7 +39,7 @@ impl PrivacyPreservingAccount {
)
}
pub fn prepare_authorized_account(account_id: AccountId, privacy: AccountPrivacyKind) -> Self {
pub fn from_privacy_kind(account_id: AccountId, privacy: AccountPrivacyKind) -> Self {
match privacy {
AccountPrivacyKind::Private => Self::PrivateOwned(account_id),
AccountPrivacyKind::Public => Self::Public(account_id),

View File

@ -13,7 +13,7 @@ pub mod pinata;
pub mod token;
pub trait ProgramArgs {
fn private_transfer_preparation(
fn prepare_private_transfer(
&self,
) -> (
InstructionData,
@ -27,7 +27,7 @@ pub async fn send_privacy_preserving_transaction_unified<PD: ProgramArgs>(
acc_vector: Vec<PrivacyPreservingAccount>,
method_data: PD,
) -> Result<(SendTxResponse, Vec<AccDecodeData>), ExecutionFailureKind> {
let (instruction_data, program, tx_pre_check) = method_data.private_transfer_preparation();
let (instruction_data, program, tx_pre_check) = method_data.prepare_private_transfer();
wallet_core
.send_privacy_preserving_tx_with_pre_check(

View File

@ -17,7 +17,7 @@ pub struct NativeBalanceToMove {
pub struct InitArgs {}
impl ProgramArgs for NativeBalanceToMove {
fn private_transfer_preparation(
fn prepare_private_transfer(
&self,
) -> (
InstructionData,
@ -40,7 +40,7 @@ impl ProgramArgs for NativeBalanceToMove {
}
impl ProgramArgs for InitArgs {
fn private_transfer_preparation(
fn prepare_private_transfer(
&self,
) -> (
InstructionData,

View File

@ -82,7 +82,7 @@ impl Token<'_> {
amount: u128,
) -> Result<SendTxResponse, ExecutionFailureKind> {
let account_ids = vec![definition_account_id, holder_account_id];
let (instruction, program, _) = TokenBurnArgs { amount }.private_transfer_preparation();
let (instruction, program, _) = TokenBurnArgs { amount }.prepare_private_transfer();
let Ok(nonces) = self.0.get_accounts_nonces(vec![holder_account_id]).await else {
return Err(ExecutionFailureKind::SequencerError);
@ -115,7 +115,7 @@ impl Token<'_> {
amount: u128,
) -> Result<SendTxResponse, ExecutionFailureKind> {
let account_ids = vec![definition_account_id, holder_account_id];
let (instruction, program, _) = TokenMintArgs { amount }.private_transfer_preparation();
let (instruction, program, _) = TokenMintArgs { amount }.prepare_private_transfer();
let Ok(nonces) = self
.0
@ -155,7 +155,7 @@ pub struct TokenDefinitionArgs {
}
impl ProgramArgs for TokenDefinitionArgs {
fn private_transfer_preparation(
fn prepare_private_transfer(
&self,
) -> (
InstructionData,
@ -179,7 +179,7 @@ pub struct TokenTransferArgs {
}
impl ProgramArgs for TokenTransferArgs {
fn private_transfer_preparation(
fn prepare_private_transfer(
&self,
) -> (
InstructionData,
@ -204,7 +204,7 @@ pub struct TokenBurnArgs {
}
impl ProgramArgs for TokenBurnArgs {
fn private_transfer_preparation(
fn prepare_private_transfer(
&self,
) -> (
InstructionData,
@ -229,7 +229,7 @@ pub struct TokenMintArgs {
}
impl ProgramArgs for TokenMintArgs {
fn private_transfer_preparation(
fn prepare_private_transfer(
&self,
) -> (
InstructionData,