Skip to content

feat!: add unit flag for cheque deposit and withraw#686

Merged
slapec93 merged 26 commits intomasterfrom
feat/it-is-hard-to-specify-bzz-amount-in-cheque-deposit-and-cheque-withdraw-commands
May 4, 2026
Merged

feat!: add unit flag for cheque deposit and withraw#686
slapec93 merged 26 commits intomasterfrom
feat/it-is-hard-to-specify-bzz-amount-in-cheque-deposit-and-cheque-withdraw-commands

Conversation

@slapec93
Copy link
Copy Markdown
Collaborator

@slapec93 slapec93 commented Apr 24, 2026

Add a new flag called --unit for cheque deposit and withdraw command, which the user can use to pick between bzz and plur, when specifying amount

@slapec93 slapec93 marked this pull request as ready for review April 24, 2026 12:09
@slapec93 slapec93 requested a review from Cafe137 as a code owner April 24, 2026 12:09
Comment thread src/command/cheque/deposit.ts Outdated
Comment on lines 19 to 21
minimum: BigInt(1),
})
public amount!: bigint
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably needs to have type string

With type bigint it probably won't accept decimal values such as 0.5 (truncates to 0, invalid) or 1.5 (loses decimal part)

Comment thread src/command/cheque/withdraw.ts Outdated
Comment on lines 15 to 19
key: 'amount',
type: 'bigint',
description: 'Amount of tokens to withdraw in PLUR',
description: 'Amount of tokens to withdraw',
required: true,
minimum: BigInt(1),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably needs to have type string

With type bigint it probably won't accept decimal values such as 0.5 (truncates to 0, invalid) or 1.5 (loses decimal part)

@Cafe137
Copy link
Copy Markdown
Collaborator

Cafe137 commented Apr 27, 2026

Please check manually with decimal values. For example try depositing 0.5 BZZ to the chequebook and then withdrawing it back to the node wallet.

slapec93 and others added 20 commits April 28, 2026 09:22
…-and-cheque-withdraw-commands' of github.com:ethersphere/swarm-cli into feat/it-is-hard-to-specify-bzz-amount-in-cheque-deposit-and-cheque-withdraw-commands
…-and-cheque-withdraw-commands' of github.com:ethersphere/swarm-cli into feat/it-is-hard-to-specify-bzz-amount-in-cheque-deposit-and-cheque-withdraw-commands
…-and-cheque-withdraw-commands' of github.com:ethersphere/swarm-cli into feat/it-is-hard-to-specify-bzz-amount-in-cheque-deposit-and-cheque-withdraw-commands
Comment thread src/command/cheque/withdraw.ts Outdated
const response = await this.bee.withdrawTokens(this.amount.toString())
const amountBzz = this.unit === 'bzz' ? BZZ.fromDecimalString(this.amount) : BZZ.fromPLUR(this.amount)

process.stderr.write(JSON.stringify(amountBzz) + '\n')
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accidental?

Comment thread test/misc/monetary-units.spec.ts Outdated
Comment on lines 39 to 47
it('should show units in help: cheque withdraw', async () => {
await invokeTestCli(['cheque', 'withdraw', '--help'])
expectSubstringsPrinted('amount', 'in PLUR')
expectSubstringsPrinted('amount', 'Amount of tokens to withdraw')
})

it('should show units in help: cheque deposit', async () => {
await invokeTestCli(['cheque', 'deposit', '--help'])
expectSubstringsPrinted('amount', 'in PLUR')
expectSubstringsPrinted('amount', 'Amount of tokens to deposit')
})
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two tests can now be removed

Copy link
Copy Markdown
Collaborator

@Cafe137 Cafe137 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there 😌

Copy link
Copy Markdown
Collaborator

@Cafe137 Cafe137 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was a test failure, if that passes we can merge

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

File Coverage Now Coverage Before Delta% Rating
Total 2186 / 2863 2155 / 2835 0.34 🟢
application.ts 0 / 2 0 / 2 0.00
config.ts 32 / 33 32 / 33 0.00
curl.ts 24 / 24 24 / 24 0.00
index.ts 0 / 16 0 / 16 0.00
printer.ts 3 / 7 3 / 7 0.00
command/addresses.ts 32 / 37 32 / 37 0.00
command/download.ts 28 / 35 28 / 35 0.00
command/hash.ts 8 / 10 8 / 10 0.00
command/quickstart.ts 35 / 38 35 / 38 0.00
command/status.ts 79 / 79 79 / 79 0.00
command/upload.ts 157 / 223 157 / 223 0.00
command/cheque/cashout.ts 30 / 32 30 / 32 0.00
command/cheque/cheque-command.ts 21 / 25 21 / 25 0.00
command/cheque/deposit.ts 23 / 25 8 / 12 25.33 🟢
command/cheque/index.ts 9 / 9 9 / 9 0.00
command/cheque/list.ts 13 / 13 13 / 13 0.00
command/cheque/withdraw-all.ts 6 / 15 6 / 15 0.00
command/cheque/withdraw.ts 23 / 25 8 / 12 25.33 🟢
command/feed/feed-command.ts 49 / 49 49 / 49 0.00
command/feed/index.ts 7 / 7 7 / 7 0.00
command/feed/print.ts 26 / 80 26 / 80 0.00
command/feed/update.ts 14 / 15 14 / 15 0.00
command/feed/upload.ts 26 / 28 26 / 28 0.00
command/grantee/create.ts 20 / 20 20 / 20 0.00
command/grantee/get.ts 11 / 11 11 / 11 0.00
command/grantee/grantee-command.ts 2 / 2 2 / 2 0.00
command/grantee/index.ts 7 / 7 7 / 7 0.00
command/grantee/patch.ts 21 / 21 21 / 21 0.00
command/history/disable.ts 18 / 18 18 / 18 0.00
command/history/enable.ts 15 / 15 15 / 15 0.00
command/history/history-command.ts 2 / 2 2 / 2 0.00
command/history/index.ts 9 / 9 9 / 9 0.00
command/history/list.ts 17 / 17 17 / 17 0.00
command/history/show.ts 26 / 28 26 / 28 0.00
command/history/status.ts 16 / 16 16 / 16 0.00
command/identity/create.ts 36 / 41 36 / 41 0.00
command/identity/export.ts 20 / 22 20 / 22 0.00
command/identity/identity-command.ts 21 / 27 21 / 27 0.00
command/identity/import.ts 50 / 63 50 / 63 0.00
command/identity/index.ts 11 / 11 11 / 11 0.00
command/identity/list.ts 21 / 21 21 / 21 0.00
command/identity/remove.ts 15 / 21 15 / 21 0.00
command/identity/rename.ts 16 / 16 16 / 16 0.00
command/identity/show.ts 27 / 33 27 / 33 0.00
command/manifest/add.ts 38 / 39 38 / 39 0.00
command/manifest/create.ts 16 / 17 16 / 17 0.00
command/manifest/download.ts 49 / 50 49 / 50 0.00
command/manifest/index.ts 11 / 11 11 / 11 0.00
command/manifest/list.ts 40 / 42 40 / 42 0.00
command/manifest/merge.ts 24 / 25 24 / 25 0.00
command/manifest/remove.ts 26 / 29 26 / 29 0.00
command/manifest/sync.ts 46 / 50 46 / 50 0.00
command/pinning/index.ts 9 / 9 9 / 9 0.00
command/pinning/list.ts 14 / 14 14 / 14 0.00
command/pinning/pin.ts 10 / 11 10 / 11 0.00
command/pinning/pinning-command.ts 5 / 8 5 / 8 0.00
command/pinning/reupload-all.ts 21 / 23 21 / 23 0.00
command/pinning/reupload.ts 9 / 17 9 / 17 0.00
command/pinning/unpin.ts 11 / 11 11 / 11 0.00
command/pss/index.ts 7 / 7 7 / 7 0.00
command/pss/pss-command.ts 8 / 8 8 / 8 0.00
command/pss/receive.ts 18 / 24 18 / 24 0.00
command/pss/send.ts 29 / 34 29 / 34 0.00
command/pss/subscribe.ts 8 / 18 8 / 18 0.00
command/root-command/command-config.ts 33 / 39 33 / 39 0.00
command/root-command/command-log.ts 60 / 78 60 / 78 0.00
command/root-command/index.ts 40 / 44 40 / 44 0.00
command/root-command/printer.ts 9 / 9 9 / 9 0.00
command/stake/deposit.ts 31 / 40 31 / 40 0.00
command/stake/index.ts 8 / 8 8 / 8 0.00
command/stake/recover.ts 10 / 22 10 / 22 0.00
command/stake/status.ts 11 / 11 11 / 11 0.00
command/stake/withdraw.ts 7 / 25 7 / 25 0.00
command/stamp/buy.ts 51 / 65 51 / 65 0.00
command/stamp/create.ts 18 / 72 18 / 72 0.00
command/stamp/dilute.ts 12 / 27 12 / 27 0.00
command/stamp/extend.ts 10 / 51 10 / 51 0.00
command/stamp/index.ts 11 / 11 11 / 11 0.00
command/stamp/list.ts 28 / 31 28 / 31 0.00
command/stamp/show.ts 13 / 14 13 / 14 0.00
command/stamp/stamp-command.ts 3 / 7 3 / 7 0.00
command/stamp/topup.ts 11 / 23 11 / 23 0.00
command/utility/cid.ts 8 / 13 8 / 13 0.00
command/utility/create-batch.ts 14 / 34 14 / 34 0.00
command/utility/index.ts 14 / 22 14 / 22 0.00
command/utility/lock.ts 7 / 11 7 / 11 0.00
command/utility/rchash.ts 7 / 23 7 / 23 0.00
command/utility/redeem.ts 12 / 51 12 / 51 0.00
command/utility/unlock.ts 7 / 12 7 / 12 0.00
command/wallet/index.ts 7 / 7 7 / 7 0.00
command/wallet/status.ts 11 / 11 11 / 11 0.00
command/wallet/withdraw-bzz.ts 19 / 21 19 / 21 0.00
command/wallet/withdraw-dai.ts 19 / 21 19 / 21 0.00
service/history/index.ts 19 / 21 19 / 21 0.00
service/identity/index.ts 32 / 36 32 / 36 0.00
service/identity/types/identity.ts 4 / 4 4 / 4 0.00
service/identity/types/index.ts 1 / 1 1 / 1 0.00
service/stamp/index.ts 30 / 32 30 / 32 0.00
utils/bzz-address.ts 24 / 30 24 / 30 0.00
utils/chainsync.ts 4 / 4 4 / 4 0.00
utils/contracts.ts 3 / 3 3 / 3 0.00
utils/error.ts 39 / 44 39 / 44 0.00
utils/hex.ts 10 / 14 10 / 14 0.00
utils/index.ts 51 / 83 51 / 83 0.00
utils/message.ts 3 / 12 3 / 12 0.00
utils/mime.ts 5 / 5 5 / 5 0.00
utils/option.ts 3 / 3 3 / 3 0.00
utils/rpc.ts 9 / 37 9 / 37 0.00
utils/spinner.ts 15 / 15 15 / 15 0.00
utils/text.ts 18 / 21 17 / 19 -3.76 🔴

@Cafe137 Cafe137 changed the title feat: add unit flag for cheque deposit and withraw feat!: add unit flag for cheque deposit and withraw May 4, 2026
@slapec93 slapec93 merged commit 2d6cd7a into master May 4, 2026
@slapec93 slapec93 deleted the feat/it-is-hard-to-specify-bzz-amount-in-cheque-deposit-and-cheque-withdraw-commands branch May 4, 2026 11:04
@bee-worker bee-worker mentioned this pull request May 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

It is hard to specify BZZ amount in cheque deposit and cheque withdraw commands

2 participants