mirror of
https://github.com/logos-blockchain/logos-execution-zone.git
synced 2026-05-15 12:39:30 +00:00
Merge branch 'main' into marvin/keycard-commands
This commit is contained in:
commit
d2b6597119
@ -391,7 +391,7 @@ async fn initialize_private_account() -> Result<()> {
|
||||
};
|
||||
|
||||
let command = Command::AuthTransfer(AuthTransferSubcommand::Init {
|
||||
account: private_mention(account_id),
|
||||
account_id: private_mention(account_id),
|
||||
});
|
||||
wallet::cli::execute_subcommand(ctx.wallet_mut(), command).await?;
|
||||
|
||||
@ -488,7 +488,7 @@ async fn initialize_private_account_using_label() -> Result<()> {
|
||||
|
||||
// Initialize using the label instead of account ID
|
||||
let command = Command::AuthTransfer(AuthTransferSubcommand::Init {
|
||||
account: label.into(),
|
||||
account_id: label.into(),
|
||||
});
|
||||
wallet::cli::execute_subcommand(ctx.wallet_mut(), command).await?;
|
||||
|
||||
|
||||
@ -236,7 +236,7 @@ async fn initialize_public_account() -> Result<()> {
|
||||
};
|
||||
|
||||
let command = Command::AuthTransfer(AuthTransferSubcommand::Init {
|
||||
account: public_mention(account_id),
|
||||
account_id: public_mention(account_id),
|
||||
});
|
||||
wallet::cli::execute_subcommand(ctx.wallet_mut(), command).await?;
|
||||
|
||||
|
||||
@ -233,7 +233,7 @@ async fn claim_pinata_to_new_private_account() -> Result<()> {
|
||||
|
||||
// Initialize account under auth transfer program
|
||||
let command = Command::AuthTransfer(AuthTransferSubcommand::Init {
|
||||
account: private_mention(winner_account_id),
|
||||
account_id: private_mention(winner_account_id),
|
||||
});
|
||||
wallet::cli::execute_subcommand(ctx.wallet_mut(), command).await?;
|
||||
|
||||
|
||||
@ -187,7 +187,7 @@ async fn fund_shared_account_from_public() -> Result<()> {
|
||||
|
||||
// Initialize the shared account under auth-transfer
|
||||
let command = Command::AuthTransfer(AuthTransferSubcommand::Init {
|
||||
account: private_mention(shared_id),
|
||||
account_id: private_mention(shared_id),
|
||||
});
|
||||
wallet::cli::execute_subcommand(ctx.wallet_mut(), command).await?;
|
||||
|
||||
|
||||
@ -16,9 +16,9 @@ use crate::{
|
||||
pub enum AuthTransferSubcommand {
|
||||
/// Initialize account under authenticated transfer program.
|
||||
Init {
|
||||
/// Account id, label, or Keycard key path (e.g. `Public/9bKm...`, `my-label`, `m/44'/60'/0'/0/0`).
|
||||
/// Either 32 byte base58 account id string with privacy prefix or a label.
|
||||
#[arg(long)]
|
||||
account: CliAccountMention,
|
||||
account_id: CliAccountMention,
|
||||
},
|
||||
/// Send native tokens from one account to another with variable privacy.
|
||||
///
|
||||
@ -55,8 +55,8 @@ impl WalletSubcommand for AuthTransferSubcommand {
|
||||
wallet_core: &mut WalletCore,
|
||||
) -> Result<SubcommandReturnValue> {
|
||||
match self {
|
||||
Self::Init { account } => {
|
||||
let resolved = account.resolve(wallet_core.storage())?;
|
||||
Self::Init { account_id } => {
|
||||
let resolved = account_id.resolve(wallet_core.storage())?;
|
||||
match resolved {
|
||||
AccountIdWithPrivacy::Public(account_id) => {
|
||||
let tx_hash = NativeTokenTransfer(wallet_core)
|
||||
@ -124,13 +124,7 @@ impl WalletSubcommand for AuthTransferSubcommand {
|
||||
}
|
||||
(Some(to), None, None) => match (from, to) {
|
||||
(AccountIdWithPrivacy::Public(from), AccountIdWithPrivacy::Public(to)) => {
|
||||
NativeTokenTransferProgramSubcommand::Public {
|
||||
from,
|
||||
to,
|
||||
amount,
|
||||
from_mention: from_account,
|
||||
to_mention: to_account.expect("Some in this branch"),
|
||||
}
|
||||
NativeTokenTransferProgramSubcommand::Public { from, to, amount }
|
||||
}
|
||||
(
|
||||
AccountIdWithPrivacy::Private(from),
|
||||
|
||||
@ -25,15 +25,6 @@ impl NativeTokenTransfer<'_> {
|
||||
from_mention: &CliAccountMention,
|
||||
to_mention: &CliAccountMention,
|
||||
) -> Result<HashType, ExecutionFailureKind> {
|
||||
let balance = self
|
||||
.0
|
||||
.get_account_balance(from)
|
||||
.await
|
||||
.map_err(ExecutionFailureKind::SequencerError)?;
|
||||
|
||||
if balance < balance_to_move {
|
||||
return Err(ExecutionFailureKind::InsufficientFundsError);
|
||||
}
|
||||
|
||||
let from_signer = from_mention
|
||||
.to_signer(self.0)
|
||||
@ -102,6 +93,34 @@ impl NativeTokenTransfer<'_> {
|
||||
.sequencer_client
|
||||
.send_transaction(NSSATransaction::Public(tx))
|
||||
.await?)
|
||||
} else {
|
||||
println!(
|
||||
"Receiver's account ({to}) private key not found in wallet. Proceeding with only sender's key."
|
||||
);
|
||||
}
|
||||
|
||||
let message = Message::try_new(
|
||||
program_id,
|
||||
account_ids,
|
||||
nonces,
|
||||
AuthTransferInstruction::Transfer {
|
||||
amount: balance_to_move,
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
let witness_set = WitnessSet::for_message(&message, &private_keys);
|
||||
|
||||
let tx = PublicTransaction::new(message, witness_set);
|
||||
|
||||
Ok(self
|
||||
.0
|
||||
.sequencer_client
|
||||
.send_transaction(NSSATransaction::Public(tx))
|
||||
.await?)
|
||||
} else {
|
||||
Err(ExecutionFailureKind::InsufficientFundsError)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
pub async fn register_account(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user