diff --git a/lez/wallet-ffi/src/transfer.rs b/lez/wallet-ffi/src/transfer.rs index 1fcd3133..6f174f98 100644 --- a/lez/wallet-ffi/src/transfer.rs +++ b/lez/wallet-ffi/src/transfer.rs @@ -191,7 +191,7 @@ pub unsafe extern "C" fn wallet_ffi_transfer_shielded( let transfer = NativeTokenTransfer(&wallet); match block_on(transfer.send_shielded_transfer_to_outer_account( - from_mention.into_public_identity(from_id), + from_mention.into_public_identity(from_id, true), to_npk, to_vpk, to_identifier, @@ -464,7 +464,7 @@ pub unsafe extern "C" fn wallet_ffi_transfer_shielded_owned( let transfer = NativeTokenTransfer(&wallet); match block_on(transfer.send_shielded_transfer( - from_mention.into_public_identity(from_id), + from_mention.into_public_identity(from_id, true), to_id, amount, )) { diff --git a/lez/wallet/src/cli/mod.rs b/lez/wallet/src/cli/mod.rs index 43b6dc7a..e66271be 100644 --- a/lez/wallet/src/cli/mod.rs +++ b/lez/wallet/src/cli/mod.rs @@ -162,14 +162,22 @@ impl CliAccountMention { } } + /// Convert to an [`crate::AccountIdentity`] for use in a public transaction. + /// + /// The `sign` flag indicates whether to sign or not with the account keys. #[must_use] - pub fn into_public_identity(self, account_id: lee::AccountId) -> crate::AccountIdentity { + pub fn into_public_identity( + self, + account_id: lee::AccountId, + sign: bool, + ) -> crate::AccountIdentity { match self { Self::KeyPath(key_path) => crate::AccountIdentity::PublicKeycard { account_id, key_path, }, - Self::Id(_) | Self::Label(_) => crate::AccountIdentity::Public(account_id), + Self::Id(_) | Self::Label(_) if sign => crate::AccountIdentity::Public(account_id), + Self::Id(_) | Self::Label(_) => crate::AccountIdentity::PublicNoSign(account_id), } } } diff --git a/lez/wallet/src/cli/programs/amm.rs b/lez/wallet/src/cli/programs/amm.rs index 0f544c42..61f6dfe1 100644 --- a/lez/wallet/src/cli/programs/amm.rs +++ b/lez/wallet/src/cli/programs/amm.rs @@ -138,9 +138,9 @@ impl AmmProgramAgnosticSubcommand { ) => { let tx_hash = Amm(wallet_core) .send_new_definition( - user_holding_a.into_public_identity(a), - user_holding_b.into_public_identity(b), - user_holding_lp.into_public_identity(lp), + user_holding_a.into_public_identity(a, true), + user_holding_b.into_public_identity(b, true), + user_holding_lp.into_public_identity(lp, true), balance_a, balance_b, ) @@ -170,8 +170,8 @@ impl AmmProgramAgnosticSubcommand { (AccountIdWithPrivacy::Public(a), AccountIdWithPrivacy::Public(b)) => { let tx_hash = Amm(wallet_core) .send_swap_exact_input( - user_holding_a.into_public_identity(a), - user_holding_b.into_public_identity(b), + user_holding_a.into_public_identity(a, true), + user_holding_b.into_public_identity(b, true), amount_in, min_amount_out, token_definition, @@ -202,8 +202,8 @@ impl AmmProgramAgnosticSubcommand { (AccountIdWithPrivacy::Public(a), AccountIdWithPrivacy::Public(b)) => { let tx_hash = Amm(wallet_core) .send_swap_exact_output( - user_holding_a.into_public_identity(a), - user_holding_b.into_public_identity(b), + user_holding_a.into_public_identity(a, true), + user_holding_b.into_public_identity(b, true), exact_amount_out, max_amount_in, token_definition, @@ -240,9 +240,9 @@ impl AmmProgramAgnosticSubcommand { ) => { let tx_hash = Amm(wallet_core) .send_add_liquidity( - user_holding_a.into_public_identity(a), - user_holding_b.into_public_identity(b), - user_holding_lp.into_public_identity(lp), + user_holding_a.into_public_identity(a, true), + user_holding_b.into_public_identity(b, true), + user_holding_lp.into_public_identity(lp, true), min_amount_lp, max_amount_a, max_amount_b, @@ -281,7 +281,7 @@ impl AmmProgramAgnosticSubcommand { .send_remove_liquidity( a, b, - user_holding_lp.into_public_identity(lp), + user_holding_lp.into_public_identity(lp, true), balance_lp, min_amount_a, min_amount_b, diff --git a/lez/wallet/src/cli/programs/ata.rs b/lez/wallet/src/cli/programs/ata.rs index 1d207b35..0a9f3221 100644 --- a/lez/wallet/src/cli/programs/ata.rs +++ b/lez/wallet/src/cli/programs/ata.rs @@ -94,7 +94,7 @@ impl AtaSubcommand { match owner_resolved { AccountIdWithPrivacy::Public(owner_id) => { let tx_hash = Ata(wallet_core) - .send_create(owner.into_public_identity(owner_id), definition_id) + .send_create(owner.into_public_identity(owner_id, true), definition_id) .await?; wallet_core .poll_and_finalize_public_transaction(tx_hash) @@ -127,7 +127,7 @@ impl AtaSubcommand { AccountIdWithPrivacy::Public(from_id) => { let tx_hash = Ata(wallet_core) .send_transfer( - from.into_public_identity(from_id), + from.into_public_identity(from_id, true), definition_id, to_id, amount, @@ -162,7 +162,7 @@ impl AtaSubcommand { AccountIdWithPrivacy::Public(holder_id) => { let tx_hash = Ata(wallet_core) .send_burn( - holder.into_public_identity(holder_id), + holder.into_public_identity(holder_id, true), definition_id, amount, ) diff --git a/lez/wallet/src/cli/programs/native_token_transfer.rs b/lez/wallet/src/cli/programs/native_token_transfer.rs index ccc2f14c..4afd7592 100644 --- a/lez/wallet/src/cli/programs/native_token_transfer.rs +++ b/lez/wallet/src/cli/programs/native_token_transfer.rs @@ -61,7 +61,7 @@ impl AuthTransferSubcommand { match resolved { AccountIdWithPrivacy::Public(pub_account_id) => { let tx_hash = NativeTokenTransfer(wallet_core) - .register_account(account_id.into_public_identity(pub_account_id)) + .register_account(account_id.into_public_identity(pub_account_id, true)) .await?; wallet_core @@ -123,8 +123,8 @@ impl AuthTransferSubcommand { (AccountIdWithPrivacy::Public(from), AccountIdWithPrivacy::Public(to)) => { let to_mention = to_account.expect("matched Some branch"); NativeTokenTransferProgramSubcommand::Public { - from: Some(from_account.into_public_identity(from)), - to: Some(to_mention.into_public_identity(to)), + from: Some(from_account.into_public_identity(from, true)), + to: Some(to_mention.into_public_identity(to, false)), amount, } } @@ -143,7 +143,7 @@ impl AuthTransferSubcommand { (AccountIdWithPrivacy::Public(from), AccountIdWithPrivacy::Private(to)) => { NativeTokenTransferProgramSubcommand::Shielded( NativeTokenTransferProgramSubcommandShielded::ShieldedOwned { - from: Some(from_account.into_public_identity(from)), + from: Some(from_account.into_public_identity(from, true)), to, amount, }, @@ -165,7 +165,7 @@ impl AuthTransferSubcommand { AccountIdWithPrivacy::Public(from) => { NativeTokenTransferProgramSubcommand::Shielded( NativeTokenTransferProgramSubcommandShielded::ShieldedForeign { - from: Some(from_account.into_public_identity(from)), + from: Some(from_account.into_public_identity(from, true)), to_npk, to_vpk, to_identifier, diff --git a/lez/wallet/src/cli/programs/token.rs b/lez/wallet/src/cli/programs/token.rs index 6486f58c..bd00edba 100644 --- a/lez/wallet/src/cli/programs/token.rs +++ b/lez/wallet/src/cli/programs/token.rs @@ -208,7 +208,7 @@ impl TokenProgramAgnosticSubcommand { (AccountIdWithPrivacy::Public(from), AccountIdWithPrivacy::Private(to)) => { TokenProgramSubcommand::Shielded( TokenProgramSubcommandShielded::TransferTokenShieldedOwned { - sender: Some(from_mention.into_public_identity(from)), + sender: Some(from_mention.into_public_identity(from, true)), recipient_account_id: to, balance_to_move: amount, }, @@ -237,7 +237,7 @@ impl TokenProgramAgnosticSubcommand { ), AccountIdWithPrivacy::Public(from) => TokenProgramSubcommand::Shielded( TokenProgramSubcommandShielded::TransferTokenShieldedForeign { - sender: Some(from_mention.into_public_identity(from)), + sender: Some(from_mention.into_public_identity(from, true)), recipient_npk: to_npk, recipient_vpk: to_vpk, recipient_identifier: to_identifier, @@ -830,8 +830,8 @@ impl TokenProgramSubcommandPublic { }; let tx_hash = Token(wallet_core) .send_transfer_transaction( - sender_account_id.into_public_identity(sender_id), - recipient_account_id.into_public_identity(recipient_id), + sender_account_id.into_public_identity(sender_id, true), + recipient_account_id.into_public_identity(recipient_id, false), balance_to_move, ) .await?; @@ -855,7 +855,7 @@ impl TokenProgramSubcommandPublic { let tx_hash = Token(wallet_core) .send_burn_transaction( definition_account_id, - holder_account_id.into_public_identity(holder_id), + holder_account_id.into_public_identity(holder_id, true), amount, ) .await?; @@ -881,8 +881,8 @@ impl TokenProgramSubcommandPublic { }; let tx_hash = Token(wallet_core) .send_mint_transaction( - definition_account_id.into_public_identity(def_id), - holder_account_id.into_public_identity(holder_id), + definition_account_id.into_public_identity(def_id, true), + holder_account_id.into_public_identity(holder_id, false), amount, ) .await?; @@ -1546,8 +1546,8 @@ impl CreateNewTokenProgramSubcommand { }; let tx_hash = Token(wallet_core) .send_new_definition( - definition_account_id.into_public_identity(def_id), - supply_account_id.into_public_identity(sup_id), + definition_account_id.into_public_identity(def_id, true), + supply_account_id.into_public_identity(sup_id, true), name, total_supply, ) diff --git a/lez/wallet/src/program_facades/native_token_transfer/deshielded.rs b/lez/wallet/src/program_facades/native_token_transfer/deshielded.rs index f060e0fa..04ca723a 100644 --- a/lez/wallet/src/program_facades/native_token_transfer/deshielded.rs +++ b/lez/wallet/src/program_facades/native_token_transfer/deshielded.rs @@ -19,7 +19,7 @@ impl NativeTokenTransfer<'_> { self.0 .resolve_private_account(from) .ok_or(ExecutionFailureKind::KeyNotFoundError)?, - AccountIdentity::Public(to), + AccountIdentity::PublicNoSign(to), ], instruction_data, &program.into(),