@ethersphere/swarm-cli
Version:
CLI tool for Bee
42 lines (33 loc) • 1.19 kB
text/typescript
import { Argument, LeafCommand, Option } from 'furious-commander'
import { BZZ } from '@ethersphere/bee-js'
import { createKeyValue } from '../../utils/text'
import { ChequeCommand } from './cheque-command'
import { validateTokenAmount } from '../../utils/validate'
export class Deposit extends ChequeCommand implements LeafCommand {
public readonly name = 'deposit'
public readonly alias = 'dep'
public readonly description = 'Deposit tokens from overlay address into chequebook'
({
key: 'amount',
description: 'Amount of tokens to deposit',
type: 'decimal-string',
required: true,
validate: validateTokenAmount,
})
public amount!: string
({
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 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())
}
}