mirror of
https://github.com/logos-blockchain/logos-execution-zone.git
synced 2026-05-27 02:19:25 +00:00
feat(wallet-ffi): exposed account identity, added resolve functions.
This commit is contained in:
parent
7920b17c6d
commit
fb4c5ce46d
@ -1,5 +1,5 @@
|
|||||||
use nssa::{AccountId, program::Program};
|
use nssa::{AccountId, program::Program};
|
||||||
use wallet::{AccountManagerAccountIdentity, WalletCore};
|
use wallet::{AccountIdentity, WalletCore};
|
||||||
|
|
||||||
// Before running this example, compile the `hello_world.rs` guest program with:
|
// Before running this example, compile the `hello_world.rs` guest program with:
|
||||||
//
|
//
|
||||||
@ -44,7 +44,7 @@ async fn main() {
|
|||||||
// Define the desired greeting in ASCII
|
// Define the desired greeting in ASCII
|
||||||
let greeting: Vec<u8> = vec![72, 111, 108, 97, 32, 109, 117, 110, 100, 111, 33];
|
let greeting: Vec<u8> = vec![72, 111, 108, 97, 32, 109, 117, 110, 100, 111, 33];
|
||||||
|
|
||||||
let accounts = vec![AccountManagerAccountIdentity::PrivateOwned(account_id)];
|
let accounts = vec![AccountIdentity::PrivateOwned(account_id)];
|
||||||
|
|
||||||
// Construct and submit the privacy-preserving transaction
|
// Construct and submit the privacy-preserving transaction
|
||||||
wallet_core
|
wallet_core
|
||||||
|
|||||||
@ -4,7 +4,7 @@ use nssa::{
|
|||||||
AccountId, ProgramId, privacy_preserving_transaction::circuit::ProgramWithDependencies,
|
AccountId, ProgramId, privacy_preserving_transaction::circuit::ProgramWithDependencies,
|
||||||
program::Program,
|
program::Program,
|
||||||
};
|
};
|
||||||
use wallet::{AccountManagerAccountIdentity, WalletCore};
|
use wallet::{AccountIdentity, WalletCore};
|
||||||
|
|
||||||
// Before running this example, compile the `simple_tail_call.rs` guest program with:
|
// Before running this example, compile the `simple_tail_call.rs` guest program with:
|
||||||
//
|
//
|
||||||
@ -51,7 +51,7 @@ async fn main() {
|
|||||||
std::iter::once((hello_world.id(), hello_world)).collect();
|
std::iter::once((hello_world.id(), hello_world)).collect();
|
||||||
let program_with_dependencies = ProgramWithDependencies::new(simple_tail_call, dependencies);
|
let program_with_dependencies = ProgramWithDependencies::new(simple_tail_call, dependencies);
|
||||||
|
|
||||||
let accounts = vec![AccountManagerAccountIdentity::PrivateOwned(account_id)];
|
let accounts = vec![AccountIdentity::PrivateOwned(account_id)];
|
||||||
|
|
||||||
// Construct and submit the privacy-preserving transaction
|
// Construct and submit the privacy-preserving transaction
|
||||||
let instruction = ();
|
let instruction = ();
|
||||||
|
|||||||
@ -2,7 +2,7 @@ use clap::{Parser, Subcommand};
|
|||||||
use common::transaction::NSSATransaction;
|
use common::transaction::NSSATransaction;
|
||||||
use nssa::{PublicTransaction, program::Program, public_transaction};
|
use nssa::{PublicTransaction, program::Program, public_transaction};
|
||||||
use sequencer_service_rpc::RpcClient as _;
|
use sequencer_service_rpc::RpcClient as _;
|
||||||
use wallet::{AccountManagerAccountIdentity, WalletCore};
|
use wallet::{AccountIdentity, WalletCore};
|
||||||
|
|
||||||
// Before running this example, compile the `hello_world_with_move_function.rs` guest program with:
|
// Before running this example, compile the `hello_world_with_move_function.rs` guest program with:
|
||||||
//
|
//
|
||||||
@ -99,7 +99,7 @@ async fn main() {
|
|||||||
} => {
|
} => {
|
||||||
let instruction: Instruction = (WRITE_FUNCTION_ID, greeting.into_bytes());
|
let instruction: Instruction = (WRITE_FUNCTION_ID, greeting.into_bytes());
|
||||||
let account_id = account_id.parse().unwrap();
|
let account_id = account_id.parse().unwrap();
|
||||||
let accounts = vec![AccountManagerAccountIdentity::PrivateOwned(account_id)];
|
let accounts = vec![AccountIdentity::PrivateOwned(account_id)];
|
||||||
|
|
||||||
wallet_core
|
wallet_core
|
||||||
.send_privacy_preserving_tx(
|
.send_privacy_preserving_tx(
|
||||||
@ -138,8 +138,8 @@ async fn main() {
|
|||||||
let to = to.parse().unwrap();
|
let to = to.parse().unwrap();
|
||||||
|
|
||||||
let accounts = vec![
|
let accounts = vec![
|
||||||
AccountManagerAccountIdentity::Public(from),
|
AccountIdentity::Public(from),
|
||||||
AccountManagerAccountIdentity::PrivateOwned(to),
|
AccountIdentity::PrivateOwned(to),
|
||||||
];
|
];
|
||||||
|
|
||||||
wallet_core
|
wallet_core
|
||||||
|
|||||||
@ -10,7 +10,7 @@ use sequencer_service_rpc::RpcClient as _;
|
|||||||
use tempfile::TempDir;
|
use tempfile::TempDir;
|
||||||
use testcontainers::compose::DockerCompose;
|
use testcontainers::compose::DockerCompose;
|
||||||
use wallet::{
|
use wallet::{
|
||||||
AccDecodeData::Decode, AccountManagerAccountIdentity, WalletCore, config::WalletConfigOverrides,
|
AccDecodeData::Decode, AccountIdentity, WalletCore, config::WalletConfigOverrides,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
@ -293,8 +293,8 @@ async fn claim_funds_from_vault_to_private(
|
|||||||
let (tx_hash, mut secrets) = wallet
|
let (tx_hash, mut secrets) = wallet
|
||||||
.send_privacy_preserving_tx(
|
.send_privacy_preserving_tx(
|
||||||
vec![
|
vec![
|
||||||
AccountManagerAccountIdentity::PrivateOwned(owner_id),
|
AccountIdentity::PrivateOwned(owner_id),
|
||||||
AccountManagerAccountIdentity::Public(owner_vault_id),
|
AccountIdentity::Public(owner_vault_id),
|
||||||
],
|
],
|
||||||
instruction_data,
|
instruction_data,
|
||||||
&program_with_dependencies,
|
&program_with_dependencies,
|
||||||
|
|||||||
@ -18,7 +18,7 @@ use nssa::{
|
|||||||
use nssa_core::{NullifierPublicKey, encryption::ViewingPublicKey, program::PdaSeed};
|
use nssa_core::{NullifierPublicKey, encryption::ViewingPublicKey, program::PdaSeed};
|
||||||
use tokio::test;
|
use tokio::test;
|
||||||
use wallet::{
|
use wallet::{
|
||||||
AccountManagerAccountIdentity, WalletCore,
|
AccountIdentity, WalletCore,
|
||||||
cli::{Command, account::AccountSubcommand},
|
cli::{Command, account::AccountSubcommand},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -46,8 +46,8 @@ async fn fund_private_pda(
|
|||||||
wallet
|
wallet
|
||||||
.send_privacy_preserving_tx(
|
.send_privacy_preserving_tx(
|
||||||
vec![
|
vec![
|
||||||
AccountManagerAccountIdentity::Public(sender),
|
AccountIdentity::Public(sender),
|
||||||
AccountManagerAccountIdentity::PrivatePdaForeign {
|
AccountIdentity::PrivatePdaForeign {
|
||||||
account_id: pda_account_id,
|
account_id: pda_account_id,
|
||||||
npk,
|
npk,
|
||||||
vpk,
|
vpk,
|
||||||
@ -83,8 +83,8 @@ async fn spend_private_pda(
|
|||||||
wallet
|
wallet
|
||||||
.send_privacy_preserving_tx(
|
.send_privacy_preserving_tx(
|
||||||
vec![
|
vec![
|
||||||
AccountManagerAccountIdentity::PrivatePdaOwned(pda_account_id),
|
AccountIdentity::PrivatePdaOwned(pda_account_id),
|
||||||
AccountManagerAccountIdentity::PrivateForeign {
|
AccountIdentity::PrivateForeign {
|
||||||
npk: recipient_npk,
|
npk: recipient_npk,
|
||||||
vpk: recipient_vpk,
|
vpk: recipient_vpk,
|
||||||
identifier: 0,
|
identifier: 0,
|
||||||
|
|||||||
@ -3,11 +3,13 @@
|
|||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
|
||||||
use nssa::{AccountId, PublicKey};
|
use nssa::{AccountId, PublicKey};
|
||||||
|
use wallet::AccountIdentity;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
error::{print_error, WalletFfiError},
|
error::{print_error, WalletFfiError},
|
||||||
types::{FfiBytes32, FfiPrivateAccountKeys, FfiPublicAccountKey, WalletHandle},
|
types::{FfiBytes32, FfiPrivateAccountKeys, FfiPublicAccountKey, WalletHandle},
|
||||||
wallet::get_wallet,
|
wallet::get_wallet,
|
||||||
|
FfiAccountIdentity,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Get the public key for a public account.
|
/// Get the public key for a public account.
|
||||||
@ -250,3 +252,85 @@ pub unsafe extern "C" fn wallet_ffi_account_id_from_base58(
|
|||||||
|
|
||||||
WalletFfiError::Success
|
WalletFfiError::Success
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Resolve public account.
|
||||||
|
///
|
||||||
|
/// # Parameters
|
||||||
|
/// - `account_id`: 32 bytes of the public account ID
|
||||||
|
/// - `needs_sign`: does account needs signing
|
||||||
|
/// - `out_account_identity`: valid pointer, where output will be written
|
||||||
|
///
|
||||||
|
/// # Returns
|
||||||
|
/// - `Success` on successful retrieval
|
||||||
|
///
|
||||||
|
/// # Safety
|
||||||
|
/// - `out_account_identity` must be a valid pointer to a `FfiAccountManagerAccountIdentity` struct
|
||||||
|
#[no_mangle]
|
||||||
|
pub unsafe extern "C" fn wallet_ffi_resolve_public_account(
|
||||||
|
account_id: FfiBytes32,
|
||||||
|
needs_sign: bool,
|
||||||
|
out_account_identity: *mut FfiAccountIdentity,
|
||||||
|
) -> WalletFfiError {
|
||||||
|
let resolved_account = if needs_sign {
|
||||||
|
AccountIdentity::Public(account_id.into())
|
||||||
|
} else {
|
||||||
|
AccountIdentity::PublicNoSign(account_id.into())
|
||||||
|
};
|
||||||
|
|
||||||
|
unsafe {
|
||||||
|
*out_account_identity = resolved_account.into();
|
||||||
|
}
|
||||||
|
|
||||||
|
WalletFfiError::Success
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Resolve private account.
|
||||||
|
///
|
||||||
|
/// # Parameters
|
||||||
|
/// - `handle`: Valid wallet handle
|
||||||
|
/// - `account_id`: 32 bytes of the public account ID
|
||||||
|
/// - `out_account_identity`: valid pointer, where output will be written
|
||||||
|
///
|
||||||
|
/// # Returns
|
||||||
|
/// - `Success` on successful retrieval
|
||||||
|
/// - `InternalError` if wailed to lock wallet
|
||||||
|
/// - `AccountNotFound` if failed to found account
|
||||||
|
///
|
||||||
|
/// # Safety
|
||||||
|
/// - `handle` must be a valid wallet handle from `wallet_ffi_create_new` or `wallet_ffi_open`
|
||||||
|
/// - `out_account_identity` must be a valid pointer to a `FfiAccountManagerAccountIdentity` struct
|
||||||
|
#[no_mangle]
|
||||||
|
pub unsafe extern "C" fn wallet_ffi_resolve_private_account(
|
||||||
|
handle: *mut WalletHandle,
|
||||||
|
account_id: FfiBytes32,
|
||||||
|
out_account_identity: *mut FfiAccountIdentity,
|
||||||
|
) -> WalletFfiError {
|
||||||
|
let wrapper = match get_wallet(handle) {
|
||||||
|
Ok(w) => w,
|
||||||
|
Err(e) => return e,
|
||||||
|
};
|
||||||
|
|
||||||
|
let wallet = match wrapper.core.lock() {
|
||||||
|
Ok(w) => w,
|
||||||
|
Err(e) => {
|
||||||
|
print_error(format!("Failed to lock wallet: {e}"));
|
||||||
|
return WalletFfiError::InternalError;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let account_id = account_id.into();
|
||||||
|
|
||||||
|
let resolved_account = match wallet.resolve_private_account(account_id) {
|
||||||
|
Some(v) => v,
|
||||||
|
None => {
|
||||||
|
print_error(format!("Account not found"));
|
||||||
|
return WalletFfiError::AccountNotFound;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
unsafe {
|
||||||
|
*out_account_identity = resolved_account.into();
|
||||||
|
}
|
||||||
|
|
||||||
|
WalletFfiError::Success
|
||||||
|
}
|
||||||
|
|||||||
@ -4,7 +4,8 @@ use core::slice;
|
|||||||
use std::{ffi::c_char, ptr};
|
use std::{ffi::c_char, ptr};
|
||||||
|
|
||||||
use nssa::Data;
|
use nssa::Data;
|
||||||
use nssa_core::encryption::shared_key_derivation::Secp256k1Point;
|
use nssa_core::{encryption::shared_key_derivation::Secp256k1Point, NullifierPublicKey};
|
||||||
|
use wallet::AccountIdentity;
|
||||||
|
|
||||||
use crate::error::WalletFfiError;
|
use crate::error::WalletFfiError;
|
||||||
|
|
||||||
@ -172,6 +173,45 @@ impl FfiPrivateAccountKeys {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Enumeration to represent kinds of FfiAccountManagerAccountIdentity
|
||||||
|
#[repr(C)]
|
||||||
|
pub enum FfiAccountIdentityKind {
|
||||||
|
Public = 0,
|
||||||
|
PublicNoSign = 1,
|
||||||
|
PrivateOwned = 2,
|
||||||
|
PrivateForeign = 3,
|
||||||
|
PrivatePdaOwned = 4,
|
||||||
|
PrivatePdaForeign = 5,
|
||||||
|
PrivateShared = 6,
|
||||||
|
PrivatePdaShared = 7,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Struct representing of account identity, given to `AccountManager` at intialization
|
||||||
|
#[repr(C)]
|
||||||
|
pub struct FfiAccountIdentity {
|
||||||
|
kind: FfiAccountIdentityKind,
|
||||||
|
pub account_id: FfiBytes32,
|
||||||
|
pub nullifier_secret_key: FfiBytes32,
|
||||||
|
pub nullifier_public_key: FfiBytes32,
|
||||||
|
pub viewing_public_key: *const u8,
|
||||||
|
pub viewing_public_key_len: usize,
|
||||||
|
pub identifier: FfiU128,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for FfiAccountIdentity {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
kind: FfiAccountIdentityKind::Public,
|
||||||
|
account_id: FfiBytes32::default(),
|
||||||
|
nullifier_secret_key: FfiBytes32::default(),
|
||||||
|
nullifier_public_key: FfiBytes32::default(),
|
||||||
|
viewing_public_key: std::ptr::null(),
|
||||||
|
viewing_public_key_len: 0,
|
||||||
|
identifier: FfiU128::default(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl From<u128> for FfiU128 {
|
impl From<u128> for FfiU128 {
|
||||||
fn from(value: u128) -> Self {
|
fn from(value: u128) -> Self {
|
||||||
Self {
|
Self {
|
||||||
@ -192,6 +232,12 @@ impl From<nssa::AccountId> for FfiBytes32 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<[u8; 32]> for FfiBytes32 {
|
||||||
|
fn from(value: [u8; 32]) -> Self {
|
||||||
|
Self { data: value }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl From<FfiBytes32> for nssa::AccountId {
|
impl From<FfiBytes32> for nssa::AccountId {
|
||||||
fn from(bytes: FfiBytes32) -> Self {
|
fn from(bytes: FfiBytes32) -> Self {
|
||||||
Self::new(bytes.data)
|
Self::new(bytes.data)
|
||||||
@ -266,3 +312,230 @@ impl TryFrom<&FfiPublicAccountKey> for nssa::PublicKey {
|
|||||||
Ok(public_key)
|
Ok(public_key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<AccountIdentity> for FfiAccountIdentity {
|
||||||
|
fn from(value: AccountIdentity) -> Self {
|
||||||
|
match value {
|
||||||
|
AccountIdentity::Public(account_id) => Self {
|
||||||
|
kind: FfiAccountIdentityKind::Public,
|
||||||
|
account_id: account_id.into(),
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
AccountIdentity::PublicNoSign(account_id) => Self {
|
||||||
|
kind: FfiAccountIdentityKind::PublicNoSign,
|
||||||
|
account_id: account_id.into(),
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
AccountIdentity::PrivateOwned(account_id) => Self {
|
||||||
|
kind: FfiAccountIdentityKind::PrivateOwned,
|
||||||
|
account_id: account_id.into(),
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
AccountIdentity::PrivateForeign {
|
||||||
|
npk,
|
||||||
|
vpk,
|
||||||
|
identifier,
|
||||||
|
} => {
|
||||||
|
let vpk_vec = vpk.0;
|
||||||
|
let vpk_len = vpk_vec.len();
|
||||||
|
let vpk_data = if vpk_len > 0 {
|
||||||
|
let vpk_data_boxed = vpk_vec.into_boxed_slice();
|
||||||
|
Box::into_raw(vpk_data_boxed) as *const u8
|
||||||
|
} else {
|
||||||
|
ptr::null()
|
||||||
|
};
|
||||||
|
|
||||||
|
Self {
|
||||||
|
kind: FfiAccountIdentityKind::PrivateForeign,
|
||||||
|
nullifier_public_key: npk.0.into(),
|
||||||
|
viewing_public_key: vpk_data,
|
||||||
|
viewing_public_key_len: vpk_len,
|
||||||
|
identifier: identifier.into(),
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
AccountIdentity::PrivatePdaOwned(account_id) => Self {
|
||||||
|
kind: FfiAccountIdentityKind::PrivatePdaOwned,
|
||||||
|
account_id: account_id.into(),
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
AccountIdentity::PrivatePdaForeign {
|
||||||
|
account_id,
|
||||||
|
npk,
|
||||||
|
vpk,
|
||||||
|
identifier,
|
||||||
|
} => {
|
||||||
|
let vpk_vec = vpk.0;
|
||||||
|
let vpk_len = vpk_vec.len();
|
||||||
|
let vpk_data = if vpk_len > 0 {
|
||||||
|
let vpk_data_boxed = vpk_vec.into_boxed_slice();
|
||||||
|
Box::into_raw(vpk_data_boxed) as *const u8
|
||||||
|
} else {
|
||||||
|
ptr::null()
|
||||||
|
};
|
||||||
|
|
||||||
|
Self {
|
||||||
|
kind: FfiAccountIdentityKind::PrivatePdaForeign,
|
||||||
|
account_id: account_id.into(),
|
||||||
|
nullifier_public_key: npk.0.into(),
|
||||||
|
viewing_public_key: vpk_data,
|
||||||
|
viewing_public_key_len: vpk_len,
|
||||||
|
identifier: identifier.into(),
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
AccountIdentity::PrivateShared {
|
||||||
|
nsk,
|
||||||
|
npk,
|
||||||
|
vpk,
|
||||||
|
identifier,
|
||||||
|
} => {
|
||||||
|
let vpk_vec = vpk.0;
|
||||||
|
let vpk_len = vpk_vec.len();
|
||||||
|
let vpk_data = if vpk_len > 0 {
|
||||||
|
let vpk_data_boxed = vpk_vec.into_boxed_slice();
|
||||||
|
Box::into_raw(vpk_data_boxed) as *const u8
|
||||||
|
} else {
|
||||||
|
ptr::null()
|
||||||
|
};
|
||||||
|
|
||||||
|
Self {
|
||||||
|
kind: FfiAccountIdentityKind::PrivateShared,
|
||||||
|
nullifier_secret_key: nsk.into(),
|
||||||
|
nullifier_public_key: npk.0.into(),
|
||||||
|
viewing_public_key: vpk_data,
|
||||||
|
viewing_public_key_len: vpk_len,
|
||||||
|
identifier: identifier.into(),
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
AccountIdentity::PrivatePdaShared {
|
||||||
|
account_id,
|
||||||
|
nsk,
|
||||||
|
npk,
|
||||||
|
vpk,
|
||||||
|
identifier,
|
||||||
|
} => {
|
||||||
|
let vpk_vec = vpk.0;
|
||||||
|
let vpk_len = vpk_vec.len();
|
||||||
|
let vpk_data = if vpk_len > 0 {
|
||||||
|
let vpk_data_boxed = vpk_vec.into_boxed_slice();
|
||||||
|
Box::into_raw(vpk_data_boxed) as *const u8
|
||||||
|
} else {
|
||||||
|
ptr::null()
|
||||||
|
};
|
||||||
|
|
||||||
|
Self {
|
||||||
|
kind: FfiAccountIdentityKind::PrivateShared,
|
||||||
|
account_id: account_id.into(),
|
||||||
|
nullifier_secret_key: nsk.into(),
|
||||||
|
nullifier_public_key: npk.0.into(),
|
||||||
|
viewing_public_key: vpk_data,
|
||||||
|
viewing_public_key_len: vpk_len,
|
||||||
|
identifier: identifier.into(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TryFrom<&FfiAccountIdentity> for AccountIdentity {
|
||||||
|
type Error = WalletFfiError;
|
||||||
|
|
||||||
|
fn try_from(value: &FfiAccountIdentity) -> Result<Self, Self::Error> {
|
||||||
|
match value.kind {
|
||||||
|
FfiAccountIdentityKind::Public => Ok(
|
||||||
|
AccountIdentity::Public(value.account_id.into()),
|
||||||
|
),
|
||||||
|
FfiAccountIdentityKind::PublicNoSign => Ok(
|
||||||
|
AccountIdentity::PublicNoSign(value.account_id.into()),
|
||||||
|
),
|
||||||
|
FfiAccountIdentityKind::PrivateOwned => Ok(
|
||||||
|
AccountIdentity::PrivateOwned(value.account_id.into()),
|
||||||
|
),
|
||||||
|
FfiAccountIdentityKind::PrivateForeign => {
|
||||||
|
let vpk = if value.viewing_public_key_len == 33 {
|
||||||
|
let slice = unsafe {
|
||||||
|
slice::from_raw_parts(
|
||||||
|
value.viewing_public_key,
|
||||||
|
value.viewing_public_key_len,
|
||||||
|
)
|
||||||
|
};
|
||||||
|
Ok(Secp256k1Point(slice.to_vec()))
|
||||||
|
} else {
|
||||||
|
Err(WalletFfiError::InvalidKeyValue)
|
||||||
|
}?;
|
||||||
|
|
||||||
|
Ok(AccountIdentity::PrivateForeign {
|
||||||
|
npk: NullifierPublicKey(value.nullifier_public_key.data),
|
||||||
|
vpk,
|
||||||
|
identifier: value.identifier.into(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
FfiAccountIdentityKind::PrivatePdaOwned => Ok(
|
||||||
|
AccountIdentity::PrivatePdaOwned(value.account_id.into()),
|
||||||
|
),
|
||||||
|
FfiAccountIdentityKind::PrivatePdaForeign => {
|
||||||
|
let vpk = if value.viewing_public_key_len == 33 {
|
||||||
|
let slice = unsafe {
|
||||||
|
slice::from_raw_parts(
|
||||||
|
value.viewing_public_key,
|
||||||
|
value.viewing_public_key_len,
|
||||||
|
)
|
||||||
|
};
|
||||||
|
Ok(Secp256k1Point(slice.to_vec()))
|
||||||
|
} else {
|
||||||
|
Err(WalletFfiError::InvalidKeyValue)
|
||||||
|
}?;
|
||||||
|
|
||||||
|
Ok(AccountIdentity::PrivatePdaForeign {
|
||||||
|
account_id: value.account_id.into(),
|
||||||
|
npk: NullifierPublicKey(value.nullifier_public_key.data),
|
||||||
|
vpk,
|
||||||
|
identifier: value.identifier.into(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
FfiAccountIdentityKind::PrivateShared => {
|
||||||
|
let vpk = if value.viewing_public_key_len == 33 {
|
||||||
|
let slice = unsafe {
|
||||||
|
slice::from_raw_parts(
|
||||||
|
value.viewing_public_key,
|
||||||
|
value.viewing_public_key_len,
|
||||||
|
)
|
||||||
|
};
|
||||||
|
Ok(Secp256k1Point(slice.to_vec()))
|
||||||
|
} else {
|
||||||
|
Err(WalletFfiError::InvalidKeyValue)
|
||||||
|
}?;
|
||||||
|
|
||||||
|
Ok(AccountIdentity::PrivateShared {
|
||||||
|
nsk: value.nullifier_secret_key.data,
|
||||||
|
npk: NullifierPublicKey(value.nullifier_public_key.data),
|
||||||
|
vpk,
|
||||||
|
identifier: value.identifier.into(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
FfiAccountIdentityKind::PrivatePdaShared => {
|
||||||
|
let vpk = if value.viewing_public_key_len == 33 {
|
||||||
|
let slice = unsafe {
|
||||||
|
slice::from_raw_parts(
|
||||||
|
value.viewing_public_key,
|
||||||
|
value.viewing_public_key_len,
|
||||||
|
)
|
||||||
|
};
|
||||||
|
Ok(Secp256k1Point(slice.to_vec()))
|
||||||
|
} else {
|
||||||
|
Err(WalletFfiError::InvalidKeyValue)
|
||||||
|
}?;
|
||||||
|
|
||||||
|
Ok(AccountIdentity::PrivatePdaShared {
|
||||||
|
account_id: value.account_id.into(),
|
||||||
|
nsk: value.nullifier_secret_key.data,
|
||||||
|
npk: NullifierPublicKey(value.nullifier_public_key.data),
|
||||||
|
vpk,
|
||||||
|
identifier: value.identifier.into(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -109,6 +109,20 @@ typedef enum WalletFfiError {
|
|||||||
INTERNAL_ERROR = 99,
|
INTERNAL_ERROR = 99,
|
||||||
} WalletFfiError;
|
} WalletFfiError;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enumeration to represent kinds of FfiAccountManagerAccountIdentity
|
||||||
|
*/
|
||||||
|
typedef enum FfiAccountIdentityKind {
|
||||||
|
PUBLIC = 0,
|
||||||
|
PUBLIC_NO_SIGN = 1,
|
||||||
|
PRIVATE_OWNED = 2,
|
||||||
|
PRIVATE_FOREIGN = 3,
|
||||||
|
PRIVATE_PDA_OWNED = 4,
|
||||||
|
PRIVATE_PDA_FOREIGN = 5,
|
||||||
|
PRIVATE_SHARED = 6,
|
||||||
|
PRIVATE_PDA_SHARED = 7,
|
||||||
|
} FfiAccountIdentityKind;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Opaque pointer to the Wallet instance.
|
* Opaque pointer to the Wallet instance.
|
||||||
*
|
*
|
||||||
@ -207,6 +221,19 @@ typedef struct FfiPublicAccountKey {
|
|||||||
struct FfiBytes32 public_key;
|
struct FfiBytes32 public_key;
|
||||||
} FfiPublicAccountKey;
|
} FfiPublicAccountKey;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Struct representing of account identity, given to `AccountManager` at intialization
|
||||||
|
*/
|
||||||
|
typedef struct FfiAccountIdentity {
|
||||||
|
enum FfiAccountIdentityKind kind;
|
||||||
|
struct FfiBytes32 account_id;
|
||||||
|
struct FfiBytes32 nullifier_secret_key;
|
||||||
|
struct FfiBytes32 nullifier_public_key;
|
||||||
|
const uint8_t *viewing_public_key;
|
||||||
|
uintptr_t viewing_public_key_len;
|
||||||
|
struct FfiU128 identifier;
|
||||||
|
} FfiAccountIdentity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Result of a transfer operation.
|
* Result of a transfer operation.
|
||||||
*/
|
*/
|
||||||
@ -552,6 +579,45 @@ char *wallet_ffi_account_id_to_base58(const struct FfiBytes32 *account_id);
|
|||||||
enum WalletFfiError wallet_ffi_account_id_from_base58(const char *base58_str,
|
enum WalletFfiError wallet_ffi_account_id_from_base58(const char *base58_str,
|
||||||
struct FfiBytes32 *out_account_id);
|
struct FfiBytes32 *out_account_id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolve public account.
|
||||||
|
*
|
||||||
|
* # Parameters
|
||||||
|
* - `account_id`: 32 bytes of the public account ID
|
||||||
|
* - `needs_sign`: does account needs signing
|
||||||
|
* - `out_account_identity`: valid pointer, where output will be written
|
||||||
|
*
|
||||||
|
* # Returns
|
||||||
|
* - `Success` on successful retrieval
|
||||||
|
*
|
||||||
|
* # Safety
|
||||||
|
* - `out_account_identity` must be a valid pointer to a `FfiAccountManagerAccountIdentity` struct
|
||||||
|
*/
|
||||||
|
enum WalletFfiError wallet_ffi_resolve_public_account(struct FfiBytes32 account_id,
|
||||||
|
bool needs_sign,
|
||||||
|
struct FfiAccountIdentity *out_account_identity);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolve private account.
|
||||||
|
*
|
||||||
|
* # Parameters
|
||||||
|
* - `handle`: Valid wallet handle
|
||||||
|
* - `account_id`: 32 bytes of the public account ID
|
||||||
|
* - `out_account_identity`: valid pointer, where output will be written
|
||||||
|
*
|
||||||
|
* # Returns
|
||||||
|
* - `Success` on successful retrieval
|
||||||
|
* - `InternalError` if wailed to lock wallet
|
||||||
|
* - `AccountNotFound` if failed to found account
|
||||||
|
*
|
||||||
|
* # Safety
|
||||||
|
* - `handle` must be a valid wallet handle from `wallet_ffi_create_new` or `wallet_ffi_open`
|
||||||
|
* - `out_account_identity` must be a valid pointer to a `FfiAccountManagerAccountIdentity` struct
|
||||||
|
*/
|
||||||
|
enum WalletFfiError wallet_ffi_resolve_private_account(struct WalletHandle *handle,
|
||||||
|
struct FfiBytes32 account_id,
|
||||||
|
struct FfiAccountIdentity *out_account_identity);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Claim a pinata reward using a public transaction.
|
* Claim a pinata reward using a public transaction.
|
||||||
*
|
*
|
||||||
|
|||||||
@ -11,7 +11,7 @@ use nssa_core::{
|
|||||||
use crate::{ExecutionFailureKind, WalletCore};
|
use crate::{ExecutionFailureKind, WalletCore};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub enum AccountManagerAccountIdentity {
|
pub enum AccountIdentity {
|
||||||
Public(AccountId),
|
Public(AccountId),
|
||||||
/// A public account without signing. Would not try to sign, even if account is owned.
|
/// A public account without signing. Would not try to sign, even if account is owned.
|
||||||
PublicNoSign(AccountId),
|
PublicNoSign(AccountId),
|
||||||
@ -52,7 +52,7 @@ pub enum AccountManagerAccountIdentity {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AccountManagerAccountIdentity {
|
impl AccountIdentity {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub const fn is_public(&self) -> bool {
|
pub const fn is_public(&self) -> bool {
|
||||||
matches!(&self, Self::Public(_) | Self::PublicNoSign(_))
|
matches!(&self, Self::Public(_) | Self::PublicNoSign(_))
|
||||||
@ -94,13 +94,13 @@ pub struct AccountManager {
|
|||||||
impl AccountManager {
|
impl AccountManager {
|
||||||
pub async fn new(
|
pub async fn new(
|
||||||
wallet: &WalletCore,
|
wallet: &WalletCore,
|
||||||
accounts: Vec<AccountManagerAccountIdentity>,
|
accounts: Vec<AccountIdentity>,
|
||||||
) -> Result<Self, ExecutionFailureKind> {
|
) -> Result<Self, ExecutionFailureKind> {
|
||||||
let mut states = Vec::with_capacity(accounts.len());
|
let mut states = Vec::with_capacity(accounts.len());
|
||||||
|
|
||||||
for account in accounts {
|
for account in accounts {
|
||||||
let state = match account {
|
let state = match account {
|
||||||
AccountManagerAccountIdentity::Public(account_id) => {
|
AccountIdentity::Public(account_id) => {
|
||||||
let acc = wallet
|
let acc = wallet
|
||||||
.get_account_public(account_id)
|
.get_account_public(account_id)
|
||||||
.await
|
.await
|
||||||
@ -111,7 +111,7 @@ impl AccountManager {
|
|||||||
|
|
||||||
State::Public { account, sk }
|
State::Public { account, sk }
|
||||||
}
|
}
|
||||||
AccountManagerAccountIdentity::PublicNoSign(account_id) => {
|
AccountIdentity::PublicNoSign(account_id) => {
|
||||||
let acc = wallet
|
let acc = wallet
|
||||||
.get_account_public(account_id)
|
.get_account_public(account_id)
|
||||||
.await
|
.await
|
||||||
@ -122,12 +122,12 @@ impl AccountManager {
|
|||||||
|
|
||||||
State::Public { account, sk }
|
State::Public { account, sk }
|
||||||
}
|
}
|
||||||
AccountManagerAccountIdentity::PrivateOwned(account_id) => {
|
AccountIdentity::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?;
|
||||||
|
|
||||||
State::Private(pre)
|
State::Private(pre)
|
||||||
}
|
}
|
||||||
AccountManagerAccountIdentity::PrivateForeign {
|
AccountIdentity::PrivateForeign {
|
||||||
npk,
|
npk,
|
||||||
vpk,
|
vpk,
|
||||||
identifier,
|
identifier,
|
||||||
@ -151,11 +151,11 @@ impl AccountManager {
|
|||||||
|
|
||||||
State::Private(pre)
|
State::Private(pre)
|
||||||
}
|
}
|
||||||
AccountManagerAccountIdentity::PrivatePdaOwned(account_id) => {
|
AccountIdentity::PrivatePdaOwned(account_id) => {
|
||||||
let pre = private_key_tree_acc_preparation(wallet, account_id, true).await?;
|
let pre = private_key_tree_acc_preparation(wallet, account_id, true).await?;
|
||||||
State::Private(pre)
|
State::Private(pre)
|
||||||
}
|
}
|
||||||
AccountManagerAccountIdentity::PrivatePdaForeign {
|
AccountIdentity::PrivatePdaForeign {
|
||||||
account_id,
|
account_id,
|
||||||
npk,
|
npk,
|
||||||
vpk,
|
vpk,
|
||||||
@ -179,7 +179,7 @@ impl AccountManager {
|
|||||||
};
|
};
|
||||||
State::Private(pre)
|
State::Private(pre)
|
||||||
}
|
}
|
||||||
AccountManagerAccountIdentity::PrivateShared {
|
AccountIdentity::PrivateShared {
|
||||||
nsk,
|
nsk,
|
||||||
npk,
|
npk,
|
||||||
vpk,
|
vpk,
|
||||||
@ -193,7 +193,7 @@ impl AccountManager {
|
|||||||
|
|
||||||
State::Private(pre)
|
State::Private(pre)
|
||||||
}
|
}
|
||||||
AccountManagerAccountIdentity::PrivatePdaShared {
|
AccountIdentity::PrivatePdaShared {
|
||||||
account_id,
|
account_id,
|
||||||
nsk,
|
nsk,
|
||||||
npk,
|
npk,
|
||||||
@ -423,7 +423,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn private_shared_is_private() {
|
fn private_shared_is_private() {
|
||||||
let acc = AccountManagerAccountIdentity::PrivateShared {
|
let acc = AccountIdentity::PrivateShared {
|
||||||
nsk: [0; 32],
|
nsk: [0; 32],
|
||||||
npk: NullifierPublicKey([1; 32]),
|
npk: NullifierPublicKey([1; 32]),
|
||||||
vpk: ViewingPublicKey::from_scalar([2; 32]),
|
vpk: ViewingPublicKey::from_scalar([2; 32]),
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
pub use account_manager::AccountManagerAccountIdentity;
|
pub use account_manager::AccountIdentity;
|
||||||
use anyhow::{Context as _, Result};
|
use anyhow::{Context as _, Result};
|
||||||
use bip39::Mnemonic;
|
use bip39::Mnemonic;
|
||||||
use common::{HashType, transaction::NSSATransaction};
|
use common::{HashType, transaction::NSSATransaction};
|
||||||
@ -276,7 +276,7 @@ impl WalletCore {
|
|||||||
pub fn resolve_private_account(
|
pub fn resolve_private_account(
|
||||||
&self,
|
&self,
|
||||||
account_id: nssa::AccountId,
|
account_id: nssa::AccountId,
|
||||||
) -> Option<AccountManagerAccountIdentity> {
|
) -> Option<AccountIdentity> {
|
||||||
// Check key tree first
|
// Check key tree first
|
||||||
if self
|
if self
|
||||||
.storage
|
.storage
|
||||||
@ -284,7 +284,7 @@ impl WalletCore {
|
|||||||
.private_account(account_id)
|
.private_account(account_id)
|
||||||
.is_some()
|
.is_some()
|
||||||
{
|
{
|
||||||
return Some(AccountManagerAccountIdentity::PrivateOwned(account_id));
|
return Some(AccountIdentity::PrivateOwned(account_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check shared private accounts
|
// Check shared private accounts
|
||||||
@ -299,7 +299,7 @@ impl WalletCore {
|
|||||||
|
|
||||||
if let (Some(pda_seed), Some(program_id)) = (entry.pda_seed, entry.pda_program_id) {
|
if let (Some(pda_seed), Some(program_id)) = (entry.pda_seed, entry.pda_program_id) {
|
||||||
let keys = holder.derive_keys_for_pda(&program_id, &pda_seed);
|
let keys = holder.derive_keys_for_pda(&program_id, &pda_seed);
|
||||||
Some(AccountManagerAccountIdentity::PrivatePdaShared {
|
Some(AccountIdentity::PrivatePdaShared {
|
||||||
account_id,
|
account_id,
|
||||||
nsk: keys.nullifier_secret_key,
|
nsk: keys.nullifier_secret_key,
|
||||||
npk: keys.generate_nullifier_public_key(),
|
npk: keys.generate_nullifier_public_key(),
|
||||||
@ -316,7 +316,7 @@ impl WalletCore {
|
|||||||
result
|
result
|
||||||
};
|
};
|
||||||
let keys = holder.derive_keys_for_shared_account(&derivation_seed);
|
let keys = holder.derive_keys_for_shared_account(&derivation_seed);
|
||||||
Some(AccountManagerAccountIdentity::PrivateShared {
|
Some(AccountIdentity::PrivateShared {
|
||||||
nsk: keys.nullifier_secret_key,
|
nsk: keys.nullifier_secret_key,
|
||||||
npk: keys.generate_nullifier_public_key(),
|
npk: keys.generate_nullifier_public_key(),
|
||||||
vpk: keys.generate_viewing_public_key(),
|
vpk: keys.generate_viewing_public_key(),
|
||||||
@ -541,7 +541,7 @@ impl WalletCore {
|
|||||||
|
|
||||||
pub async fn send_privacy_preserving_tx(
|
pub async fn send_privacy_preserving_tx(
|
||||||
&self,
|
&self,
|
||||||
accounts: Vec<AccountManagerAccountIdentity>,
|
accounts: Vec<AccountIdentity>,
|
||||||
instruction_data: InstructionData,
|
instruction_data: InstructionData,
|
||||||
program: &ProgramWithDependencies,
|
program: &ProgramWithDependencies,
|
||||||
) -> Result<(HashType, Vec<SharedSecretKey>), ExecutionFailureKind> {
|
) -> Result<(HashType, Vec<SharedSecretKey>), ExecutionFailureKind> {
|
||||||
@ -553,7 +553,7 @@ impl WalletCore {
|
|||||||
|
|
||||||
pub async fn send_privacy_preserving_tx_with_pre_check(
|
pub async fn send_privacy_preserving_tx_with_pre_check(
|
||||||
&self,
|
&self,
|
||||||
accounts: Vec<AccountManagerAccountIdentity>,
|
accounts: Vec<AccountIdentity>,
|
||||||
instruction_data: InstructionData,
|
instruction_data: InstructionData,
|
||||||
program: &ProgramWithDependencies,
|
program: &ProgramWithDependencies,
|
||||||
tx_pre_check: impl FnOnce(&[&Account]) -> Result<(), ExecutionFailureKind>,
|
tx_pre_check: impl FnOnce(&[&Account]) -> Result<(), ExecutionFailureKind>,
|
||||||
@ -612,7 +612,7 @@ impl WalletCore {
|
|||||||
|
|
||||||
pub async fn send_pub_tx(
|
pub async fn send_pub_tx(
|
||||||
&self,
|
&self,
|
||||||
accounts: Vec<AccountManagerAccountIdentity>,
|
accounts: Vec<AccountIdentity>,
|
||||||
instruction_data: InstructionData,
|
instruction_data: InstructionData,
|
||||||
program: &ProgramWithDependencies,
|
program: &ProgramWithDependencies,
|
||||||
) -> Result<HashType, ExecutionFailureKind> {
|
) -> Result<HashType, ExecutionFailureKind> {
|
||||||
@ -622,7 +622,7 @@ impl WalletCore {
|
|||||||
|
|
||||||
pub async fn send_pub_tx_with_pre_check(
|
pub async fn send_pub_tx_with_pre_check(
|
||||||
&self,
|
&self,
|
||||||
accounts: Vec<AccountManagerAccountIdentity>,
|
accounts: Vec<AccountIdentity>,
|
||||||
instruction_data: InstructionData,
|
instruction_data: InstructionData,
|
||||||
program: &ProgramWithDependencies,
|
program: &ProgramWithDependencies,
|
||||||
tx_pre_check: impl FnOnce(&[&Account]) -> Result<(), ExecutionFailureKind>,
|
tx_pre_check: impl FnOnce(&[&Account]) -> Result<(), ExecutionFailureKind>,
|
||||||
@ -630,7 +630,7 @@ impl WalletCore {
|
|||||||
// Public transaction, all accounts must be public
|
// Public transaction, all accounts must be public
|
||||||
if accounts
|
if accounts
|
||||||
.iter()
|
.iter()
|
||||||
.any(AccountManagerAccountIdentity::is_private)
|
.any(AccountIdentity::is_private)
|
||||||
{
|
{
|
||||||
return Err(ExecutionFailureKind::TransactionBuildError(
|
return Err(ExecutionFailureKind::TransactionBuildError(
|
||||||
nssa::error::NssaError::InvalidInput(
|
nssa::error::NssaError::InvalidInput(
|
||||||
|
|||||||
@ -3,7 +3,7 @@ use common::HashType;
|
|||||||
use nssa::{AccountId, program::Program};
|
use nssa::{AccountId, program::Program};
|
||||||
use token_core::TokenHolding;
|
use token_core::TokenHolding;
|
||||||
|
|
||||||
use crate::{AccountManagerAccountIdentity, ExecutionFailureKind, WalletCore};
|
use crate::{AccountIdentity, ExecutionFailureKind, WalletCore};
|
||||||
pub struct Amm<'wallet>(pub &'wallet WalletCore);
|
pub struct Amm<'wallet>(pub &'wallet WalletCore);
|
||||||
|
|
||||||
impl Amm<'_> {
|
impl Amm<'_> {
|
||||||
@ -51,13 +51,13 @@ impl Amm<'_> {
|
|||||||
self.0
|
self.0
|
||||||
.send_pub_tx(
|
.send_pub_tx(
|
||||||
vec![
|
vec![
|
||||||
AccountManagerAccountIdentity::PublicNoSign(amm_pool),
|
AccountIdentity::PublicNoSign(amm_pool),
|
||||||
AccountManagerAccountIdentity::PublicNoSign(vault_holding_a),
|
AccountIdentity::PublicNoSign(vault_holding_a),
|
||||||
AccountManagerAccountIdentity::PublicNoSign(vault_holding_b),
|
AccountIdentity::PublicNoSign(vault_holding_b),
|
||||||
AccountManagerAccountIdentity::PublicNoSign(pool_lp),
|
AccountIdentity::PublicNoSign(pool_lp),
|
||||||
AccountManagerAccountIdentity::Public(user_holding_a),
|
AccountIdentity::Public(user_holding_a),
|
||||||
AccountManagerAccountIdentity::Public(user_holding_b),
|
AccountIdentity::Public(user_holding_b),
|
||||||
AccountManagerAccountIdentity::Public(user_holding_lp),
|
AccountIdentity::Public(user_holding_lp),
|
||||||
],
|
],
|
||||||
instruction_data,
|
instruction_data,
|
||||||
&program.into(),
|
&program.into(),
|
||||||
@ -114,23 +114,23 @@ impl Amm<'_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let user_a_signing_indentity = if token_definition_id_in == definition_token_a_id {
|
let user_a_signing_indentity = if token_definition_id_in == definition_token_a_id {
|
||||||
AccountManagerAccountIdentity::Public(user_holding_a)
|
AccountIdentity::Public(user_holding_a)
|
||||||
} else {
|
} else {
|
||||||
AccountManagerAccountIdentity::PublicNoSign(user_holding_a)
|
AccountIdentity::PublicNoSign(user_holding_a)
|
||||||
};
|
};
|
||||||
|
|
||||||
let user_b_signing_indentity = if token_definition_id_in == definition_token_b_id {
|
let user_b_signing_indentity = if token_definition_id_in == definition_token_b_id {
|
||||||
AccountManagerAccountIdentity::Public(user_holding_b)
|
AccountIdentity::Public(user_holding_b)
|
||||||
} else {
|
} else {
|
||||||
AccountManagerAccountIdentity::PublicNoSign(user_holding_b)
|
AccountIdentity::PublicNoSign(user_holding_b)
|
||||||
};
|
};
|
||||||
|
|
||||||
self.0
|
self.0
|
||||||
.send_pub_tx(
|
.send_pub_tx(
|
||||||
vec![
|
vec![
|
||||||
AccountManagerAccountIdentity::PublicNoSign(amm_pool),
|
AccountIdentity::PublicNoSign(amm_pool),
|
||||||
AccountManagerAccountIdentity::PublicNoSign(vault_holding_a),
|
AccountIdentity::PublicNoSign(vault_holding_a),
|
||||||
AccountManagerAccountIdentity::PublicNoSign(vault_holding_b),
|
AccountIdentity::PublicNoSign(vault_holding_b),
|
||||||
user_a_signing_indentity,
|
user_a_signing_indentity,
|
||||||
user_b_signing_indentity,
|
user_b_signing_indentity,
|
||||||
],
|
],
|
||||||
@ -189,23 +189,23 @@ impl Amm<'_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let user_a_signing_indentity = if token_definition_id_in == definition_token_a_id {
|
let user_a_signing_indentity = if token_definition_id_in == definition_token_a_id {
|
||||||
AccountManagerAccountIdentity::Public(user_holding_a)
|
AccountIdentity::Public(user_holding_a)
|
||||||
} else {
|
} else {
|
||||||
AccountManagerAccountIdentity::PublicNoSign(user_holding_a)
|
AccountIdentity::PublicNoSign(user_holding_a)
|
||||||
};
|
};
|
||||||
|
|
||||||
let user_b_signing_indentity = if token_definition_id_in == definition_token_b_id {
|
let user_b_signing_indentity = if token_definition_id_in == definition_token_b_id {
|
||||||
AccountManagerAccountIdentity::Public(user_holding_b)
|
AccountIdentity::Public(user_holding_b)
|
||||||
} else {
|
} else {
|
||||||
AccountManagerAccountIdentity::PublicNoSign(user_holding_b)
|
AccountIdentity::PublicNoSign(user_holding_b)
|
||||||
};
|
};
|
||||||
|
|
||||||
self.0
|
self.0
|
||||||
.send_pub_tx(
|
.send_pub_tx(
|
||||||
vec![
|
vec![
|
||||||
AccountManagerAccountIdentity::Public(amm_pool),
|
AccountIdentity::Public(amm_pool),
|
||||||
AccountManagerAccountIdentity::Public(vault_holding_a),
|
AccountIdentity::Public(vault_holding_a),
|
||||||
AccountManagerAccountIdentity::Public(vault_holding_b),
|
AccountIdentity::Public(vault_holding_b),
|
||||||
user_a_signing_indentity,
|
user_a_signing_indentity,
|
||||||
user_b_signing_indentity,
|
user_b_signing_indentity,
|
||||||
],
|
],
|
||||||
@ -260,13 +260,13 @@ impl Amm<'_> {
|
|||||||
self.0
|
self.0
|
||||||
.send_pub_tx(
|
.send_pub_tx(
|
||||||
vec![
|
vec![
|
||||||
AccountManagerAccountIdentity::PublicNoSign(amm_pool),
|
AccountIdentity::PublicNoSign(amm_pool),
|
||||||
AccountManagerAccountIdentity::PublicNoSign(vault_holding_a),
|
AccountIdentity::PublicNoSign(vault_holding_a),
|
||||||
AccountManagerAccountIdentity::PublicNoSign(vault_holding_b),
|
AccountIdentity::PublicNoSign(vault_holding_b),
|
||||||
AccountManagerAccountIdentity::PublicNoSign(pool_lp),
|
AccountIdentity::PublicNoSign(pool_lp),
|
||||||
AccountManagerAccountIdentity::Public(user_holding_a),
|
AccountIdentity::Public(user_holding_a),
|
||||||
AccountManagerAccountIdentity::Public(user_holding_b),
|
AccountIdentity::Public(user_holding_b),
|
||||||
AccountManagerAccountIdentity::PublicNoSign(user_holding_lp),
|
AccountIdentity::PublicNoSign(user_holding_lp),
|
||||||
],
|
],
|
||||||
instruction_data,
|
instruction_data,
|
||||||
&program.into(),
|
&program.into(),
|
||||||
@ -319,13 +319,13 @@ impl Amm<'_> {
|
|||||||
self.0
|
self.0
|
||||||
.send_pub_tx(
|
.send_pub_tx(
|
||||||
vec![
|
vec![
|
||||||
AccountManagerAccountIdentity::PublicNoSign(amm_pool),
|
AccountIdentity::PublicNoSign(amm_pool),
|
||||||
AccountManagerAccountIdentity::PublicNoSign(vault_holding_a),
|
AccountIdentity::PublicNoSign(vault_holding_a),
|
||||||
AccountManagerAccountIdentity::PublicNoSign(vault_holding_b),
|
AccountIdentity::PublicNoSign(vault_holding_b),
|
||||||
AccountManagerAccountIdentity::PublicNoSign(pool_lp),
|
AccountIdentity::PublicNoSign(pool_lp),
|
||||||
AccountManagerAccountIdentity::PublicNoSign(user_holding_a),
|
AccountIdentity::PublicNoSign(user_holding_a),
|
||||||
AccountManagerAccountIdentity::PublicNoSign(user_holding_b),
|
AccountIdentity::PublicNoSign(user_holding_b),
|
||||||
AccountManagerAccountIdentity::Public(user_holding_lp),
|
AccountIdentity::Public(user_holding_lp),
|
||||||
],
|
],
|
||||||
instruction_data,
|
instruction_data,
|
||||||
&program.into(),
|
&program.into(),
|
||||||
|
|||||||
@ -7,7 +7,7 @@ use nssa::{
|
|||||||
};
|
};
|
||||||
use nssa_core::SharedSecretKey;
|
use nssa_core::SharedSecretKey;
|
||||||
|
|
||||||
use crate::{AccountManagerAccountIdentity, ExecutionFailureKind, WalletCore};
|
use crate::{AccountIdentity, ExecutionFailureKind, WalletCore};
|
||||||
|
|
||||||
pub struct Ata<'wallet>(pub &'wallet WalletCore);
|
pub struct Ata<'wallet>(pub &'wallet WalletCore);
|
||||||
|
|
||||||
@ -30,9 +30,9 @@ impl Ata<'_> {
|
|||||||
self.0
|
self.0
|
||||||
.send_pub_tx(
|
.send_pub_tx(
|
||||||
vec![
|
vec![
|
||||||
AccountManagerAccountIdentity::Public(owner_id),
|
AccountIdentity::Public(owner_id),
|
||||||
AccountManagerAccountIdentity::PublicNoSign(definition_id),
|
AccountIdentity::PublicNoSign(definition_id),
|
||||||
AccountManagerAccountIdentity::PublicNoSign(ata_id),
|
AccountIdentity::PublicNoSign(ata_id),
|
||||||
],
|
],
|
||||||
instruction_data,
|
instruction_data,
|
||||||
&program.into(),
|
&program.into(),
|
||||||
@ -63,9 +63,9 @@ impl Ata<'_> {
|
|||||||
self.0
|
self.0
|
||||||
.send_pub_tx(
|
.send_pub_tx(
|
||||||
vec![
|
vec![
|
||||||
AccountManagerAccountIdentity::Public(owner_id),
|
AccountIdentity::Public(owner_id),
|
||||||
AccountManagerAccountIdentity::PublicNoSign(sender_ata_id),
|
AccountIdentity::PublicNoSign(sender_ata_id),
|
||||||
AccountManagerAccountIdentity::PublicNoSign(recipient_id),
|
AccountIdentity::PublicNoSign(recipient_id),
|
||||||
],
|
],
|
||||||
instruction_data,
|
instruction_data,
|
||||||
&program.into(),
|
&program.into(),
|
||||||
@ -95,9 +95,9 @@ impl Ata<'_> {
|
|||||||
self.0
|
self.0
|
||||||
.send_pub_tx(
|
.send_pub_tx(
|
||||||
vec![
|
vec![
|
||||||
AccountManagerAccountIdentity::Public(owner_id),
|
AccountIdentity::Public(owner_id),
|
||||||
AccountManagerAccountIdentity::PublicNoSign(holder_ata_id),
|
AccountIdentity::PublicNoSign(holder_ata_id),
|
||||||
AccountManagerAccountIdentity::PublicNoSign(definition_id),
|
AccountIdentity::PublicNoSign(definition_id),
|
||||||
],
|
],
|
||||||
instruction_data,
|
instruction_data,
|
||||||
&program.into(),
|
&program.into(),
|
||||||
@ -124,8 +124,8 @@ impl Ata<'_> {
|
|||||||
self.0
|
self.0
|
||||||
.resolve_private_account(owner_id)
|
.resolve_private_account(owner_id)
|
||||||
.ok_or(ExecutionFailureKind::KeyNotFoundError)?,
|
.ok_or(ExecutionFailureKind::KeyNotFoundError)?,
|
||||||
AccountManagerAccountIdentity::Public(definition_id),
|
AccountIdentity::Public(definition_id),
|
||||||
AccountManagerAccountIdentity::Public(ata_id),
|
AccountIdentity::Public(ata_id),
|
||||||
];
|
];
|
||||||
|
|
||||||
self.0
|
self.0
|
||||||
@ -161,8 +161,8 @@ impl Ata<'_> {
|
|||||||
self.0
|
self.0
|
||||||
.resolve_private_account(owner_id)
|
.resolve_private_account(owner_id)
|
||||||
.ok_or(ExecutionFailureKind::KeyNotFoundError)?,
|
.ok_or(ExecutionFailureKind::KeyNotFoundError)?,
|
||||||
AccountManagerAccountIdentity::Public(sender_ata_id),
|
AccountIdentity::Public(sender_ata_id),
|
||||||
AccountManagerAccountIdentity::Public(recipient_id),
|
AccountIdentity::Public(recipient_id),
|
||||||
];
|
];
|
||||||
|
|
||||||
self.0
|
self.0
|
||||||
@ -197,8 +197,8 @@ impl Ata<'_> {
|
|||||||
self.0
|
self.0
|
||||||
.resolve_private_account(owner_id)
|
.resolve_private_account(owner_id)
|
||||||
.ok_or(ExecutionFailureKind::KeyNotFoundError)?,
|
.ok_or(ExecutionFailureKind::KeyNotFoundError)?,
|
||||||
AccountManagerAccountIdentity::Public(holder_ata_id),
|
AccountIdentity::Public(holder_ata_id),
|
||||||
AccountManagerAccountIdentity::Public(definition_id),
|
AccountIdentity::Public(definition_id),
|
||||||
];
|
];
|
||||||
|
|
||||||
self.0
|
self.0
|
||||||
|
|||||||
@ -2,7 +2,7 @@ use common::HashType;
|
|||||||
use nssa::AccountId;
|
use nssa::AccountId;
|
||||||
|
|
||||||
use super::{NativeTokenTransfer, auth_transfer_preparation};
|
use super::{NativeTokenTransfer, auth_transfer_preparation};
|
||||||
use crate::{AccountManagerAccountIdentity, ExecutionFailureKind};
|
use crate::{AccountIdentity, ExecutionFailureKind};
|
||||||
|
|
||||||
impl NativeTokenTransfer<'_> {
|
impl NativeTokenTransfer<'_> {
|
||||||
pub async fn send_deshielded_transfer(
|
pub async fn send_deshielded_transfer(
|
||||||
@ -19,7 +19,7 @@ impl NativeTokenTransfer<'_> {
|
|||||||
self.0
|
self.0
|
||||||
.resolve_private_account(from)
|
.resolve_private_account(from)
|
||||||
.ok_or(ExecutionFailureKind::KeyNotFoundError)?,
|
.ok_or(ExecutionFailureKind::KeyNotFoundError)?,
|
||||||
AccountManagerAccountIdentity::Public(to),
|
AccountIdentity::Public(to),
|
||||||
],
|
],
|
||||||
instruction_data,
|
instruction_data,
|
||||||
&program.into(),
|
&program.into(),
|
||||||
|
|||||||
@ -5,7 +5,7 @@ use nssa::{AccountId, program::Program};
|
|||||||
use nssa_core::{Identifier, NullifierPublicKey, SharedSecretKey, encryption::ViewingPublicKey};
|
use nssa_core::{Identifier, NullifierPublicKey, SharedSecretKey, encryption::ViewingPublicKey};
|
||||||
|
|
||||||
use super::{NativeTokenTransfer, auth_transfer_preparation};
|
use super::{NativeTokenTransfer, auth_transfer_preparation};
|
||||||
use crate::{AccountManagerAccountIdentity, ExecutionFailureKind};
|
use crate::{AccountIdentity, ExecutionFailureKind};
|
||||||
|
|
||||||
impl NativeTokenTransfer<'_> {
|
impl NativeTokenTransfer<'_> {
|
||||||
pub async fn register_account_private(
|
pub async fn register_account_private(
|
||||||
@ -49,7 +49,7 @@ impl NativeTokenTransfer<'_> {
|
|||||||
self.0
|
self.0
|
||||||
.resolve_private_account(from)
|
.resolve_private_account(from)
|
||||||
.ok_or(ExecutionFailureKind::KeyNotFoundError)?,
|
.ok_or(ExecutionFailureKind::KeyNotFoundError)?,
|
||||||
AccountManagerAccountIdentity::PrivateForeign {
|
AccountIdentity::PrivateForeign {
|
||||||
npk: to_npk,
|
npk: to_npk,
|
||||||
vpk: to_vpk,
|
vpk: to_vpk,
|
||||||
identifier: to_identifier,
|
identifier: to_identifier,
|
||||||
|
|||||||
@ -4,7 +4,7 @@ use nssa::{AccountId, program::Program};
|
|||||||
|
|
||||||
use super::NativeTokenTransfer;
|
use super::NativeTokenTransfer;
|
||||||
use crate::{
|
use crate::{
|
||||||
AccountManagerAccountIdentity, ExecutionFailureKind,
|
AccountIdentity, ExecutionFailureKind,
|
||||||
program_facades::native_token_transfer::auth_transfer_preparation,
|
program_facades::native_token_transfer::auth_transfer_preparation,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -20,8 +20,8 @@ impl NativeTokenTransfer<'_> {
|
|||||||
self.0
|
self.0
|
||||||
.send_pub_tx_with_pre_check(
|
.send_pub_tx_with_pre_check(
|
||||||
vec![
|
vec![
|
||||||
AccountManagerAccountIdentity::Public(from),
|
AccountIdentity::Public(from),
|
||||||
AccountManagerAccountIdentity::Public(to),
|
AccountIdentity::Public(to),
|
||||||
],
|
],
|
||||||
instruction_data,
|
instruction_data,
|
||||||
&program.into(),
|
&program.into(),
|
||||||
@ -39,7 +39,7 @@ impl NativeTokenTransfer<'_> {
|
|||||||
|
|
||||||
self.0
|
self.0
|
||||||
.send_pub_tx(
|
.send_pub_tx(
|
||||||
vec![AccountManagerAccountIdentity::Public(from)],
|
vec![AccountIdentity::Public(from)],
|
||||||
instruction_data,
|
instruction_data,
|
||||||
&program.into(),
|
&program.into(),
|
||||||
)
|
)
|
||||||
|
|||||||
@ -3,7 +3,7 @@ use nssa::AccountId;
|
|||||||
use nssa_core::{Identifier, NullifierPublicKey, SharedSecretKey, encryption::ViewingPublicKey};
|
use nssa_core::{Identifier, NullifierPublicKey, SharedSecretKey, encryption::ViewingPublicKey};
|
||||||
|
|
||||||
use super::{NativeTokenTransfer, auth_transfer_preparation};
|
use super::{NativeTokenTransfer, auth_transfer_preparation};
|
||||||
use crate::{AccountManagerAccountIdentity, ExecutionFailureKind};
|
use crate::{AccountIdentity, ExecutionFailureKind};
|
||||||
|
|
||||||
impl NativeTokenTransfer<'_> {
|
impl NativeTokenTransfer<'_> {
|
||||||
pub async fn send_shielded_transfer(
|
pub async fn send_shielded_transfer(
|
||||||
@ -17,7 +17,7 @@ impl NativeTokenTransfer<'_> {
|
|||||||
self.0
|
self.0
|
||||||
.send_privacy_preserving_tx_with_pre_check(
|
.send_privacy_preserving_tx_with_pre_check(
|
||||||
vec![
|
vec![
|
||||||
AccountManagerAccountIdentity::Public(from),
|
AccountIdentity::Public(from),
|
||||||
self.0
|
self.0
|
||||||
.resolve_private_account(to)
|
.resolve_private_account(to)
|
||||||
.ok_or(ExecutionFailureKind::KeyNotFoundError)?,
|
.ok_or(ExecutionFailureKind::KeyNotFoundError)?,
|
||||||
@ -49,8 +49,8 @@ impl NativeTokenTransfer<'_> {
|
|||||||
self.0
|
self.0
|
||||||
.send_privacy_preserving_tx_with_pre_check(
|
.send_privacy_preserving_tx_with_pre_check(
|
||||||
vec![
|
vec![
|
||||||
AccountManagerAccountIdentity::Public(from),
|
AccountIdentity::Public(from),
|
||||||
AccountManagerAccountIdentity::PrivateForeign {
|
AccountIdentity::PrivateForeign {
|
||||||
npk: to_npk,
|
npk: to_npk,
|
||||||
vpk: to_vpk,
|
vpk: to_vpk,
|
||||||
identifier: to_identifier,
|
identifier: to_identifier,
|
||||||
|
|||||||
@ -2,7 +2,7 @@ use common::HashType;
|
|||||||
use nssa::{AccountId, program::Program};
|
use nssa::{AccountId, program::Program};
|
||||||
use nssa_core::{MembershipProof, SharedSecretKey};
|
use nssa_core::{MembershipProof, SharedSecretKey};
|
||||||
|
|
||||||
use crate::{AccountManagerAccountIdentity, ExecutionFailureKind, WalletCore};
|
use crate::{AccountIdentity, ExecutionFailureKind, WalletCore};
|
||||||
|
|
||||||
pub struct Pinata<'wallet>(pub &'wallet WalletCore);
|
pub struct Pinata<'wallet>(pub &'wallet WalletCore);
|
||||||
|
|
||||||
@ -21,8 +21,8 @@ impl Pinata<'_> {
|
|||||||
self.0
|
self.0
|
||||||
.send_pub_tx(
|
.send_pub_tx(
|
||||||
vec![
|
vec![
|
||||||
AccountManagerAccountIdentity::PublicNoSign(pinata_account_id),
|
AccountIdentity::PublicNoSign(pinata_account_id),
|
||||||
AccountManagerAccountIdentity::PublicNoSign(winner_account_id),
|
AccountIdentity::PublicNoSign(winner_account_id),
|
||||||
],
|
],
|
||||||
instruction_data,
|
instruction_data,
|
||||||
&program.into(),
|
&program.into(),
|
||||||
@ -55,7 +55,7 @@ impl Pinata<'_> {
|
|||||||
self.0
|
self.0
|
||||||
.send_privacy_preserving_tx(
|
.send_privacy_preserving_tx(
|
||||||
vec![
|
vec![
|
||||||
AccountManagerAccountIdentity::Public(pinata_account_id),
|
AccountIdentity::Public(pinata_account_id),
|
||||||
self.0
|
self.0
|
||||||
.resolve_private_account(winner_account_id)
|
.resolve_private_account(winner_account_id)
|
||||||
.ok_or(ExecutionFailureKind::KeyNotFoundError)?,
|
.ok_or(ExecutionFailureKind::KeyNotFoundError)?,
|
||||||
|
|||||||
@ -3,7 +3,7 @@ use nssa::{AccountId, program::Program};
|
|||||||
use nssa_core::{Identifier, NullifierPublicKey, SharedSecretKey, encryption::ViewingPublicKey};
|
use nssa_core::{Identifier, NullifierPublicKey, SharedSecretKey, encryption::ViewingPublicKey};
|
||||||
use token_core::Instruction;
|
use token_core::Instruction;
|
||||||
|
|
||||||
use crate::{AccountManagerAccountIdentity, ExecutionFailureKind, WalletCore};
|
use crate::{AccountIdentity, ExecutionFailureKind, WalletCore};
|
||||||
|
|
||||||
pub struct Token<'wallet>(pub &'wallet WalletCore);
|
pub struct Token<'wallet>(pub &'wallet WalletCore);
|
||||||
|
|
||||||
@ -23,8 +23,8 @@ impl Token<'_> {
|
|||||||
self.0
|
self.0
|
||||||
.send_pub_tx(
|
.send_pub_tx(
|
||||||
vec![
|
vec![
|
||||||
AccountManagerAccountIdentity::Public(definition_account_id),
|
AccountIdentity::Public(definition_account_id),
|
||||||
AccountManagerAccountIdentity::Public(supply_account_id),
|
AccountIdentity::Public(supply_account_id),
|
||||||
],
|
],
|
||||||
instruction_data,
|
instruction_data,
|
||||||
&program.into(),
|
&program.into(),
|
||||||
@ -46,7 +46,7 @@ impl Token<'_> {
|
|||||||
self.0
|
self.0
|
||||||
.send_privacy_preserving_tx(
|
.send_privacy_preserving_tx(
|
||||||
vec![
|
vec![
|
||||||
AccountManagerAccountIdentity::Public(definition_account_id),
|
AccountIdentity::Public(definition_account_id),
|
||||||
self.0
|
self.0
|
||||||
.resolve_private_account(supply_account_id)
|
.resolve_private_account(supply_account_id)
|
||||||
.ok_or(ExecutionFailureKind::KeyNotFoundError)?,
|
.ok_or(ExecutionFailureKind::KeyNotFoundError)?,
|
||||||
@ -81,7 +81,7 @@ impl Token<'_> {
|
|||||||
self.0
|
self.0
|
||||||
.resolve_private_account(definition_account_id)
|
.resolve_private_account(definition_account_id)
|
||||||
.ok_or(ExecutionFailureKind::KeyNotFoundError)?,
|
.ok_or(ExecutionFailureKind::KeyNotFoundError)?,
|
||||||
AccountManagerAccountIdentity::Public(supply_account_id),
|
AccountIdentity::Public(supply_account_id),
|
||||||
],
|
],
|
||||||
instruction_data,
|
instruction_data,
|
||||||
&Program::token().into(),
|
&Program::token().into(),
|
||||||
@ -145,8 +145,8 @@ impl Token<'_> {
|
|||||||
self.0
|
self.0
|
||||||
.send_pub_tx(
|
.send_pub_tx(
|
||||||
vec![
|
vec![
|
||||||
AccountManagerAccountIdentity::Public(sender_account_id),
|
AccountIdentity::Public(sender_account_id),
|
||||||
AccountManagerAccountIdentity::Public(recipient_account_id),
|
AccountIdentity::Public(recipient_account_id),
|
||||||
],
|
],
|
||||||
instruction_data,
|
instruction_data,
|
||||||
&program.into(),
|
&program.into(),
|
||||||
@ -208,7 +208,7 @@ impl Token<'_> {
|
|||||||
self.0
|
self.0
|
||||||
.resolve_private_account(sender_account_id)
|
.resolve_private_account(sender_account_id)
|
||||||
.ok_or(ExecutionFailureKind::KeyNotFoundError)?,
|
.ok_or(ExecutionFailureKind::KeyNotFoundError)?,
|
||||||
AccountManagerAccountIdentity::PrivateForeign {
|
AccountIdentity::PrivateForeign {
|
||||||
npk: recipient_npk,
|
npk: recipient_npk,
|
||||||
vpk: recipient_vpk,
|
vpk: recipient_vpk,
|
||||||
identifier: recipient_identifier,
|
identifier: recipient_identifier,
|
||||||
@ -244,7 +244,7 @@ impl Token<'_> {
|
|||||||
self.0
|
self.0
|
||||||
.resolve_private_account(sender_account_id)
|
.resolve_private_account(sender_account_id)
|
||||||
.ok_or(ExecutionFailureKind::KeyNotFoundError)?,
|
.ok_or(ExecutionFailureKind::KeyNotFoundError)?,
|
||||||
AccountManagerAccountIdentity::Public(recipient_account_id),
|
AccountIdentity::Public(recipient_account_id),
|
||||||
],
|
],
|
||||||
instruction_data,
|
instruction_data,
|
||||||
&Program::token().into(),
|
&Program::token().into(),
|
||||||
@ -274,7 +274,7 @@ impl Token<'_> {
|
|||||||
self.0
|
self.0
|
||||||
.send_privacy_preserving_tx(
|
.send_privacy_preserving_tx(
|
||||||
vec![
|
vec![
|
||||||
AccountManagerAccountIdentity::Public(sender_account_id),
|
AccountIdentity::Public(sender_account_id),
|
||||||
self.0
|
self.0
|
||||||
.resolve_private_account(recipient_account_id)
|
.resolve_private_account(recipient_account_id)
|
||||||
.ok_or(ExecutionFailureKind::KeyNotFoundError)?,
|
.ok_or(ExecutionFailureKind::KeyNotFoundError)?,
|
||||||
@ -309,8 +309,8 @@ impl Token<'_> {
|
|||||||
self.0
|
self.0
|
||||||
.send_privacy_preserving_tx(
|
.send_privacy_preserving_tx(
|
||||||
vec![
|
vec![
|
||||||
AccountManagerAccountIdentity::Public(sender_account_id),
|
AccountIdentity::Public(sender_account_id),
|
||||||
AccountManagerAccountIdentity::PrivateForeign {
|
AccountIdentity::PrivateForeign {
|
||||||
npk: recipient_npk,
|
npk: recipient_npk,
|
||||||
vpk: recipient_vpk,
|
vpk: recipient_vpk,
|
||||||
identifier: recipient_identifier,
|
identifier: recipient_identifier,
|
||||||
@ -345,8 +345,8 @@ impl Token<'_> {
|
|||||||
self.0
|
self.0
|
||||||
.send_pub_tx(
|
.send_pub_tx(
|
||||||
vec![
|
vec![
|
||||||
AccountManagerAccountIdentity::PublicNoSign(definition_account_id),
|
AccountIdentity::PublicNoSign(definition_account_id),
|
||||||
AccountManagerAccountIdentity::Public(holder_account_id),
|
AccountIdentity::Public(holder_account_id),
|
||||||
],
|
],
|
||||||
instruction_data,
|
instruction_data,
|
||||||
&program.into(),
|
&program.into(),
|
||||||
@ -406,7 +406,7 @@ impl Token<'_> {
|
|||||||
self.0
|
self.0
|
||||||
.resolve_private_account(definition_account_id)
|
.resolve_private_account(definition_account_id)
|
||||||
.ok_or(ExecutionFailureKind::KeyNotFoundError)?,
|
.ok_or(ExecutionFailureKind::KeyNotFoundError)?,
|
||||||
AccountManagerAccountIdentity::Public(holder_account_id),
|
AccountIdentity::Public(holder_account_id),
|
||||||
],
|
],
|
||||||
instruction_data,
|
instruction_data,
|
||||||
&Program::token().into(),
|
&Program::token().into(),
|
||||||
@ -436,7 +436,7 @@ impl Token<'_> {
|
|||||||
self.0
|
self.0
|
||||||
.send_privacy_preserving_tx(
|
.send_privacy_preserving_tx(
|
||||||
vec![
|
vec![
|
||||||
AccountManagerAccountIdentity::Public(definition_account_id),
|
AccountIdentity::Public(definition_account_id),
|
||||||
self.0
|
self.0
|
||||||
.resolve_private_account(holder_account_id)
|
.resolve_private_account(holder_account_id)
|
||||||
.ok_or(ExecutionFailureKind::KeyNotFoundError)?,
|
.ok_or(ExecutionFailureKind::KeyNotFoundError)?,
|
||||||
@ -470,8 +470,8 @@ impl Token<'_> {
|
|||||||
self.0
|
self.0
|
||||||
.send_pub_tx(
|
.send_pub_tx(
|
||||||
vec![
|
vec![
|
||||||
AccountManagerAccountIdentity::Public(definition_account_id),
|
AccountIdentity::Public(definition_account_id),
|
||||||
AccountManagerAccountIdentity::Public(holder_account_id),
|
AccountIdentity::Public(holder_account_id),
|
||||||
],
|
],
|
||||||
instruction_data,
|
instruction_data,
|
||||||
&program.into(),
|
&program.into(),
|
||||||
@ -533,7 +533,7 @@ impl Token<'_> {
|
|||||||
self.0
|
self.0
|
||||||
.resolve_private_account(definition_account_id)
|
.resolve_private_account(definition_account_id)
|
||||||
.ok_or(ExecutionFailureKind::KeyNotFoundError)?,
|
.ok_or(ExecutionFailureKind::KeyNotFoundError)?,
|
||||||
AccountManagerAccountIdentity::PrivateForeign {
|
AccountIdentity::PrivateForeign {
|
||||||
npk: holder_npk,
|
npk: holder_npk,
|
||||||
vpk: holder_vpk,
|
vpk: holder_vpk,
|
||||||
identifier: holder_identifier,
|
identifier: holder_identifier,
|
||||||
@ -569,7 +569,7 @@ impl Token<'_> {
|
|||||||
self.0
|
self.0
|
||||||
.resolve_private_account(definition_account_id)
|
.resolve_private_account(definition_account_id)
|
||||||
.ok_or(ExecutionFailureKind::KeyNotFoundError)?,
|
.ok_or(ExecutionFailureKind::KeyNotFoundError)?,
|
||||||
AccountManagerAccountIdentity::Public(holder_account_id),
|
AccountIdentity::Public(holder_account_id),
|
||||||
],
|
],
|
||||||
instruction_data,
|
instruction_data,
|
||||||
&Program::token().into(),
|
&Program::token().into(),
|
||||||
@ -599,7 +599,7 @@ impl Token<'_> {
|
|||||||
self.0
|
self.0
|
||||||
.send_privacy_preserving_tx(
|
.send_privacy_preserving_tx(
|
||||||
vec![
|
vec![
|
||||||
AccountManagerAccountIdentity::Public(definition_account_id),
|
AccountIdentity::Public(definition_account_id),
|
||||||
self.0
|
self.0
|
||||||
.resolve_private_account(holder_account_id)
|
.resolve_private_account(holder_account_id)
|
||||||
.ok_or(ExecutionFailureKind::KeyNotFoundError)?,
|
.ok_or(ExecutionFailureKind::KeyNotFoundError)?,
|
||||||
@ -634,8 +634,8 @@ impl Token<'_> {
|
|||||||
self.0
|
self.0
|
||||||
.send_privacy_preserving_tx(
|
.send_privacy_preserving_tx(
|
||||||
vec![
|
vec![
|
||||||
AccountManagerAccountIdentity::Public(definition_account_id),
|
AccountIdentity::Public(definition_account_id),
|
||||||
AccountManagerAccountIdentity::PrivateForeign {
|
AccountIdentity::PrivateForeign {
|
||||||
npk: holder_npk,
|
npk: holder_npk,
|
||||||
vpk: holder_vpk,
|
vpk: holder_vpk,
|
||||||
identifier: holder_identifier,
|
identifier: holder_identifier,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user