diff --git a/documentation/docs/03_account.md b/documentation/docs/03_account.md index 50260c1..074db0f 100644 --- a/documentation/docs/03_account.md +++ b/documentation/docs/03_account.md @@ -66,12 +66,24 @@ Burn a provided NFT. Tries to claim outputs with storage deposit return, expiration or timelock unlock conditions. -#### Example +#### Parameters + +| Name | Optional | Default | Example | +| ----------- | --------- | ------- | ------------------------------------------------------------------------ | +| `output_id` | ✓ | N/A | "0xd5dff9ee869dfa7796d5132b220cb5c00146c36abba27d3562e2d726decb50850000" | +#### Examples + +Try to claim all outputs with storage deposit return, expiration or timelock unlock conditions. ```sh > Account "main": claim ``` +Try to claim a specific output. +```sh +> Account "main": claim 0xd5dff9ee869dfa7796d5132b220cb5c00146c36abba27d3562e2d726decb50850000 +``` + ### `clear` Clears the terminal. diff --git a/src/account.rs b/src/account.rs index 2122964..60275c7 100644 --- a/src/account.rs +++ b/src/account.rs @@ -62,7 +62,7 @@ pub async fn account_prompt_internal(account_handle: AccountHandle) -> Result burn_nft_command(&account_handle, nft_id).await, - AccountCommand::Claim => claim_command(&account_handle).await, + AccountCommand::Claim { output_id } => claim_command(&account_handle, output_id).await, AccountCommand::Consolidate => consolidate_command(&account_handle).await, AccountCommand::DestroyAlias { alias_id } => destroy_alias_command(&account_handle, alias_id).await, AccountCommand::DestroyFoundry { foundry_id } => { diff --git a/src/command/account.rs b/src/command/account.rs index e6a6d52..7e54c56 100644 --- a/src/command/account.rs +++ b/src/command/account.rs @@ -35,7 +35,7 @@ pub enum AccountCommand { /// Burn an NFT: `burn-nft "0x..."` BurnNft { nft_id: String }, /// Claim outputs with storage deposit return, expiration or timelock unlock conditions. - Claim, + Claim { output_id: Option }, /// Consolidate all basic outputs into one address. Consolidate, /// Destroy an alias: `destroy-alias "0x..."` @@ -150,13 +150,21 @@ pub async fn balance_command(account_handle: &AccountHandle) -> Result<(), Error } // `claim` command -pub async fn claim_command(account_handle: &AccountHandle) -> Result<(), Error> { - log::info!("Claiming outputs."); +pub async fn claim_command(account_handle: &AccountHandle, output_id: Option) -> Result<(), Error> { + let claiming_txs = if let Some(output_id) = output_id { + log::info!("Claiming output {output_id}"); - let claiming_txs = account_handle.try_claim_outputs(OutputsToClaim::All).await?; + account_handle + .claim_outputs(vec![OutputId::from_str(&output_id)?]) + .await? + } else { + log::info!("Claiming outputs."); + + account_handle.try_claim_outputs(OutputsToClaim::All).await? + }; - for claim_tx in claiming_txs { - log::info!("Claim transaction sent: {claim_tx:?}"); + for claiming_tx in claiming_txs { + log::info!("Claim transaction sent: {claiming_tx:?}"); } Ok(())