Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit cb494a3

Browse files
authored
Add claim command (#95)
1 parent e416659 commit cb494a3

File tree

5 files changed

+37
-7
lines changed

5 files changed

+37
-7
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cli-wallet"
3-
version = "1.0.0-alpha.1"
3+
version = "1.0.0-alpha.2"
44
authors = [ "IOTA Stiftung" ]
55
edition = "2021"
66
homepage = "https://iota.org"

documentation/docs/03_account.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@ Prints the account balance.
2727
> Account "main": balance
2828
```
2929

30+
### `claim`
31+
32+
Tries to claim outputs with storage deposit return, expiration or timelock unlock conditions.
33+
34+
#### Example
35+
36+
```sh
37+
> Account "main": claim
38+
```
39+
3040
### `clear`
3141

3242
Clears the terminal.

src/account.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ use iota_wallet::account::AccountHandle;
77

88
use crate::{
99
command::account::{
10-
addresses_command, balance_command, consolidate_command, faucet_command, mint_native_token_command,
11-
mint_nft_command, new_address_command, send_command, send_micro_command, send_native_token_command,
12-
send_nft_command, sync_command, transactions_command, AccountCli, AccountCommand,
10+
addresses_command, balance_command, claim_command, consolidate_command, faucet_command,
11+
mint_native_token_command, mint_nft_command, new_address_command, send_command, send_micro_command,
12+
send_native_token_command, send_nft_command, sync_command, transactions_command, AccountCli, AccountCommand,
1313
},
1414
error::Error,
1515
};
@@ -56,6 +56,7 @@ pub async fn account_prompt_internal(account_handle: AccountHandle) -> Result<bo
5656
if let Err(err) = match account_cli.command {
5757
AccountCommand::NewAddress => new_address_command(&account_handle).await,
5858
AccountCommand::Balance => balance_command(&account_handle).await,
59+
AccountCommand::Claim => claim_command(&account_handle).await,
5960
AccountCommand::Consolidate => consolidate_command(&account_handle).await,
6061
AccountCommand::Exit => {
6162
return Ok(true);

src/command/account.rs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use clap::{Parser, Subcommand};
77
use iota_wallet::{
88
account::{
99
types::{AccountAddress, Transaction},
10-
AccountHandle,
10+
AccountHandle, OutputsToCollect,
1111
},
1212
iota_client::{
1313
bee_block::output::{NftId, TokenId},
@@ -33,6 +33,8 @@ pub enum AccountCommand {
3333
Addresses,
3434
/// Print the account balance.
3535
Balance,
36+
/// Claim outputs with storage deposit return, expiration or timelock unlock conditions.
37+
Claim,
3638
/// Consolidate all basic outputs into one address.
3739
Consolidate,
3840
/// Exit from the account prompt.
@@ -100,11 +102,28 @@ pub async fn balance_command(account_handle: &AccountHandle) -> Result<(), Error
100102
Ok(())
101103
}
102104

105+
// `claim` command
106+
pub async fn claim_command(account_handle: &AccountHandle) -> Result<(), Error> {
107+
log::info!("Claiming outputs.");
108+
109+
let claiming_txs = account_handle.try_collect_outputs(OutputsToCollect::All).await?;
110+
111+
for claim_tx in claiming_txs {
112+
log::info!("Claim transaction sent: {claim_tx:?}");
113+
}
114+
115+
Ok(())
116+
}
117+
103118
// `consolidate` command
104119
pub async fn consolidate_command(account_handle: &AccountHandle) -> Result<(), Error> {
105120
log::info!("Consolidating outputs.");
106121

107-
account_handle.consolidate_outputs(true, None).await?;
122+
let consolidation_txs = account_handle.consolidate_outputs(true, None).await?;
123+
124+
for consolidation_tx in consolidation_txs {
125+
log::info!("Consolidation transaction sent: {consolidation_tx:?}");
126+
}
108127

109128
Ok(())
110129
}

0 commit comments

Comments
 (0)