Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add cheque withdraw-all command #519

Merged
merged 4 commits into from
Jun 26, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat: add cheque withdraw-all command
Cafe137 committed Jun 26, 2024
commit 1beeeda5a8d27f38f32923a401de9fec1834f331
3 changes: 2 additions & 1 deletion src/command/cheque/index.ts
Original file line number Diff line number Diff line change
@@ -3,11 +3,12 @@ import { Cashout } from './cashout'
import { Deposit } from './deposit'
import { List } from './list'
import { Withdraw } from './withdraw'
import { WithdrawAll } from './withdraw-all'

export class Cheque implements GroupCommand {
public readonly name = 'cheque'

public readonly description = 'Deposit, withdraw and manage cheques'

public subCommandClasses = [List, Cashout, Deposit, Withdraw]
public subCommandClasses = [List, Cashout, Deposit, Withdraw, WithdrawAll]
}
20 changes: 20 additions & 0 deletions src/command/cheque/withdraw-all.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { LeafCommand } from 'furious-commander'
import { createKeyValue } from '../../utils/text'
import { ChequeCommand } from './cheque-command'

export class WithdrawAll extends ChequeCommand implements LeafCommand {
public readonly name = 'withdraw-all'

public readonly alias = 'wa'

public readonly description = 'Withdraw all available tokens from the chequebook to the overlay address'

public async run(): Promise<void> {
await super.init()

const balance = await this.bee.getChequebookBalance()
const response = await this.bee.withdrawTokens(balance.availableBalance)
this.console.log(createKeyValue('Tx', response))
this.console.quiet(response)
}
}