@ethersphere/swarm-cli
Version:
CLI tool for Bee
42 lines (41 loc) • 1.56 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.WithdrawAll = void 0;
const text_1 = require("../../utils/text");
const cheque_command_1 = require("./cheque-command");
class WithdrawAll extends cheque_command_1.ChequeCommand {
constructor() {
super(...arguments);
Object.defineProperty(this, "name", {
enumerable: true,
configurable: true,
writable: true,
value: 'withdraw-all'
});
Object.defineProperty(this, "alias", {
enumerable: true,
configurable: true,
writable: true,
value: 'wa'
});
Object.defineProperty(this, "description", {
enumerable: true,
configurable: true,
writable: true,
value: 'Withdraw all available tokens from the chequebook to the overlay address'
});
}
async run() {
super.init();
const balance = await this.bee.getChequebookBalance();
if (balance.availableBalance.toPLURBigInt() === BigInt(0)) {
this.console.error('No tokens to withdraw.');
return;
}
this.console.log(`Withdrawing ${balance.availableBalance.toDecimalString()} xBZZ from the chequebook`);
const response = await this.bee.withdrawTokens(balance.availableBalance.toPLURString());
this.console.log((0, text_1.createKeyValue)('Tx', response.toHex()));
this.console.quiet(response.toHex());
}
}
exports.WithdrawAll = WithdrawAll;