2026-06-26 18:54:15 +03:00
|
|
|
use lee::AccountId;
|
|
|
|
|
|
|
|
|
|
use crate::{FfiBytes32, FfiNullifierPublicKey, FfiPdaSeed, FfiProgramId, FfiU128};
|
|
|
|
|
|
|
|
|
|
/// Produce account id for public PDA.
|
|
|
|
|
///
|
|
|
|
|
/// # Parameters
|
|
|
|
|
/// - `program_id`: Id of a owner program
|
|
|
|
|
/// - `pda_seed`: 32 byte seed
|
|
|
|
|
///
|
|
|
|
|
/// # Returns
|
|
|
|
|
/// - `FfiBytes32` representing account id bytes
|
|
|
|
|
#[no_mangle]
|
2026-06-26 18:57:22 +03:00
|
|
|
pub extern "C" fn wallet_ffi_account_id_for_public_pda(
|
2026-06-26 18:54:15 +03:00
|
|
|
program_id: FfiProgramId,
|
|
|
|
|
pda_seed: FfiPdaSeed,
|
|
|
|
|
) -> FfiBytes32 {
|
|
|
|
|
AccountId::for_public_pda(&program_id.data, &pda_seed.into()).into()
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-26 19:01:15 +03:00
|
|
|
/// Produce account id for private PDA.
|
2026-06-26 18:54:15 +03:00
|
|
|
///
|
|
|
|
|
/// # Parameters
|
|
|
|
|
/// - `program_id`: Id of a owner program
|
|
|
|
|
/// - `pda_seed`: 32 byte seed
|
|
|
|
|
/// - `npk`: 32 byte nullifier public key(can be get from `wallet_ffi_get_private_account_keys`)
|
|
|
|
|
/// - `identifier`: little endian encoded `u128`
|
|
|
|
|
///
|
|
|
|
|
/// # Returns
|
|
|
|
|
/// - `FfiBytes32` representing account id bytes
|
|
|
|
|
#[no_mangle]
|
2026-06-26 18:57:22 +03:00
|
|
|
pub extern "C" fn wallet_ffi_account_id_for_private_pda(
|
2026-06-26 18:54:15 +03:00
|
|
|
program_id: FfiProgramId,
|
|
|
|
|
pda_seed: FfiPdaSeed,
|
|
|
|
|
npk: FfiNullifierPublicKey,
|
|
|
|
|
identifier: FfiU128,
|
|
|
|
|
) -> FfiBytes32 {
|
|
|
|
|
AccountId::for_private_pda(
|
|
|
|
|
&program_id.data,
|
|
|
|
|
&pda_seed.into(),
|
|
|
|
|
&npk.into(),
|
|
|
|
|
identifier.into(),
|
|
|
|
|
)
|
|
|
|
|
.into()
|
|
|
|
|
}
|