Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
f51489f
feat: add unit flag for cheque deposit and withraw
Apr 24, 2026
bd2259c
fix: update spec and improve CLI output
Apr 24, 2026
95570be
test: update test coverage
github-actions[bot] Apr 24, 2026
1e0111b
Merge branch 'master' into feat/it-is-hard-to-specify-bzz-amount-in-c…
slapec93 Apr 28, 2026
75a45ac
feat: make coverage report gen skippable via env
Apr 28, 2026
83ea667
test: update test coverage
github-actions[bot] Apr 28, 2026
542a038
feat: use validation method and enum
Apr 28, 2026
cba1dbd
Merge branch 'feat/it-is-hard-to-specify-bzz-amount-in-cheque-deposit…
Apr 28, 2026
cdbce62
chore: madlad update
Apr 28, 2026
77e03fe
feat: use new furious command features
Apr 28, 2026
f92bed9
test: add more specs for deposit and withdraw
Apr 29, 2026
f7b17ae
test: fix
Apr 29, 2026
204f9f5
Merge branch 'master' into feat/it-is-hard-to-specify-bzz-amount-in-c…
slapec93 Apr 30, 2026
94dc2a4
test: update test coverage
github-actions[bot] Apr 30, 2026
d5043d9
test: isolate history specs
Apr 30, 2026
4130415
fix: format
Apr 30, 2026
c4740ae
test: update test coverage
github-actions[bot] Apr 30, 2026
49c4fd5
test: use isolated history files
Apr 30, 2026
a29d7b3
Merge branch 'feat/it-is-hard-to-specify-bzz-amount-in-cheque-deposit…
Apr 30, 2026
e3ae139
fix: format
Apr 30, 2026
6fe7f83
test: update test coverage
github-actions[bot] Apr 30, 2026
e64d632
fix: history specs
Apr 30, 2026
849abb4
Merge branch 'feat/it-is-hard-to-specify-bzz-amount-in-cheque-deposit…
Apr 30, 2026
d2580fa
test: update test coverage
github-actions[bot] Apr 30, 2026
0cb8bee
fix: remove unnecessary stuff
May 4, 2026
cb4b0f9
test: update test coverage
github-actions[bot] May 4, 2026
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
2 changes: 1 addition & 1 deletion jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default async (): Promise<Config.InitialOptions> => {
}

return {
collectCoverage: true,
collectCoverage: process.env.SKIP_COVERAGE !== 'true',
coverageDirectory: 'coverage',
coverageReporters: ['lcov', 'json-summary'],
collectCoverageFrom: ['src/**/*.ts'],
Expand Down
27 changes: 8 additions & 19 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 39 additions & 6 deletions src/command/cheque/deposit.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Argument, LeafCommand } from 'furious-commander'
import { Argument, LeafCommand, Option } from 'furious-commander'
import { BZZ } from '@ethersphere/bee-js'
import { Context } from 'madlad'
import { createKeyValue } from '../../utils/text'
import { ChequeCommand } from './cheque-command'

Expand All @@ -11,17 +13,48 @@ export class Deposit extends ChequeCommand implements LeafCommand {

@Argument({
key: 'amount',
type: 'bigint',
description: 'Amount of tokens to deposit in PLUR',
description: 'Amount of tokens to deposit',
type: 'decimal-string',
required: true,
minimum: BigInt(1),
validate: (value: unknown, context: Context): string[] => {
if (context.options.unit === 'bzz') {
const amount = parseFloat(value as string)

if (isNaN(amount) || amount <= 0) {
return [`Invalid amount '${value}'. Amount must be a positive number.`]
}
} else {
try {
const amount = BigInt(value as string)

if (amount <= BigInt(0)) {
return [`Invalid amount '${value}'. Amount must be a positive integer.`]
}
} catch (e) {
return [`Invalid amount '${value}'. Amount must be a positive integer.`]
}
}

return []
},
})
public amount!: bigint
public amount!: string

@Option({
key: 'unit',
type: 'enum',
description: 'Unit of the amount',
enum: ['bzz', 'plur'],
default: 'bzz',
})
public unit!: string

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

const response = await this.bee.depositTokens(this.amount.toString())
const amountBzz = this.unit === 'bzz' ? BZZ.fromDecimalString(this.amount) : BZZ.fromPLUR(this.amount)

const response = await this.bee.depositBZZToChequebook(amountBzz)
this.console.log(createKeyValue('Tx', response.toHex()))
this.console.quiet(response.toHex())
}
Expand Down
45 changes: 39 additions & 6 deletions src/command/cheque/withdraw.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Argument, LeafCommand } from 'furious-commander'
import { Argument, LeafCommand, Option } from 'furious-commander'
import { BZZ } from '@ethersphere/bee-js'
import { Context } from 'madlad'
import { createKeyValue } from '../../utils/text'
import { ChequeCommand } from './cheque-command'

Expand All @@ -11,17 +13,48 @@ export class Withdraw extends ChequeCommand implements LeafCommand {

@Argument({
key: 'amount',
type: 'bigint',
description: 'Amount of tokens to withdraw in PLUR',
type: 'string',
description: 'Amount of tokens to withdraw',
required: true,
minimum: BigInt(1),
validate: (value: unknown, context: Context): string[] => {
if (context.options.unit === 'bzz') {
const amount = parseFloat(value as string)

if (isNaN(amount) || amount <= 0) {
return [`Invalid amount '${value}'. Amount must be a positive number.`]
}
} else {
try {
const amount = BigInt(value as string)

if (amount <= BigInt(0)) {
return [`Invalid amount '${value}'. Amount must be a positive integer.`]
}
} catch (e) {
return [`Invalid amount '${value}'. Amount must be a positive integer.`]
}
}

return []
},
})
public amount!: bigint
public amount!: string

@Option({
key: 'unit',
type: 'enum',
description: 'Unit of the amount',
enum: ['bzz', 'plur'],
default: 'bzz',
})
public unit!: string

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

const response = await this.bee.withdrawTokens(this.amount.toString())
const amountBzz = this.unit === 'bzz' ? BZZ.fromDecimalString(this.amount) : BZZ.fromPLUR(this.amount)

const response = await this.bee.withdrawBZZFromChequebook(amountBzz)
this.console.log(createKeyValue('Tx', response.toHex()))
this.console.quiet(response.toHex())
}
Expand Down
2 changes: 1 addition & 1 deletion src/command/root-command/command-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class CommandConfig {
}

public getHistoryFilePath(): string {
return join(this.configFolderPath, 'upload-history.json')
return process.env.SWARM_CLI_HISTORY_FILE_PATH || join(this.configFolderPath, 'upload-history.json')
}

public setHistoryEnabled(enabled: boolean): void {
Expand Down
2 changes: 1 addition & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export const dev: IOption<boolean> = {
default: false,
}

export const optionParameters: IOption<unknown>[] = [
export const optionParameters: IOption<any>[] = [
beeApiUrl,
configFolder,
configFile,
Expand Down
4 changes: 4 additions & 0 deletions src/utils/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ export function warningText(string: string): string {
return chalk.yellow(string)
}

export function errorText(string: string): string {
return chalk.red(string)
}

export function deletePreviousLine(): void {
process.stdout.write('\r' + goUpOneRow() + deleteWholeRow())
}
Expand Down
Loading