From f0ed6402e3f0a812c4c4a23ed00c421e212b1909 Mon Sep 17 00:00:00 2001 From: Thibault Martinez Date: Tue, 21 Nov 2023 12:30:22 +0100 Subject: [PATCH] Add to CLI --- cli/src/wallet_cli/completer.rs | 1 + cli/src/wallet_cli/mod.rs | 15 +++++++++++++++ sdk/src/wallet/operations/transaction/account.rs | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/cli/src/wallet_cli/completer.rs b/cli/src/wallet_cli/completer.rs index 140183b0b6..af3bc3a843 100644 --- a/cli/src/wallet_cli/completer.rs +++ b/cli/src/wallet_cli/completer.rs @@ -25,6 +25,7 @@ const WALLET_COMMANDS: &[&str] = &[ "exit", "faucet", "implicit-account-creation-address", + "implicit-account-transition", "implicit-accounts", "melt-native-token", "mint-native-token", diff --git a/cli/src/wallet_cli/mod.rs b/cli/src/wallet_cli/mod.rs index 5715f0dabe..18a0e810e5 100644 --- a/cli/src/wallet_cli/mod.rs +++ b/cli/src/wallet_cli/mod.rs @@ -120,6 +120,11 @@ pub enum WalletCommand { }, /// Returns the implicit account creation address of the wallet if it is Ed25519 based. ImplicitAccountCreationAddress, + /// Transitions an implicit account to an account. + ImplicitAccountTransition { + /// Identifier of the implicit account output. + output_id: OutputId, + }, /// Lists the implicit accounts of the wallet. ImplicitAccounts, /// Mint additional native tokens. @@ -578,6 +583,13 @@ pub async fn implicit_account_creation_address_command(wallet: &Wallet) -> Resul Ok(()) } +// `implicit-account-transition` command +pub async fn implicit_account_transition_command(wallet: &Wallet, output_id: OutputId) -> Result<(), Error> { + wallet.implicit_account_transition(&output_id).await?; + + Ok(()) +} + // `implicit-accounts` command pub async fn implicit_accounts_command(wallet: &Wallet) -> Result<(), Error> { print_outputs(wallet.implicit_accounts().await, "Implicit accounts:").await @@ -1103,6 +1115,9 @@ pub async fn prompt_internal( WalletCommand::ImplicitAccountCreationAddress => { implicit_account_creation_address_command(wallet).await } + WalletCommand::ImplicitAccountTransition { output_id } => { + implicit_account_transition_command(wallet, output_id).await + } WalletCommand::ImplicitAccounts => implicit_accounts_command(wallet).await, WalletCommand::MeltNativeToken { token_id, amount } => { melt_native_token_command(wallet, token_id, amount).await diff --git a/sdk/src/wallet/operations/transaction/account.rs b/sdk/src/wallet/operations/transaction/account.rs index ab0a9d7055..b28bff853f 100644 --- a/sdk/src/wallet/operations/transaction/account.rs +++ b/sdk/src/wallet/operations/transaction/account.rs @@ -19,7 +19,7 @@ where crate::wallet::Error: From, crate::client::Error: From, { - async fn implicit_account_transition(&self, output_id: &OutputId) -> Result { + pub async fn implicit_account_transition(&self, output_id: &OutputId) -> Result { let implicit_account_data = self.data().await.unspent_outputs.get(output_id).cloned(); let implicit_account = if let Some(implicit_account_data) = &implicit_account_data {