UNPKG

@ethersphere/swarm-cli

Version:
81 lines (80 loc) 3.16 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Withdraw = void 0; const furious_commander_1 = require("furious-commander"); const bee_js_1 = require("@ethersphere/bee-js"); const text_1 = require("../../utils/text"); const cheque_command_1 = require("./cheque-command"); const validate_1 = require("../../utils/validate"); class Withdraw extends cheque_command_1.ChequeCommand { constructor() { super(...arguments); Object.defineProperty(this, "name", { enumerable: true, configurable: true, writable: true, value: 'withdraw' }); Object.defineProperty(this, "alias", { enumerable: true, configurable: true, writable: true, value: 'wd' }); Object.defineProperty(this, "description", { enumerable: true, configurable: true, writable: true, value: 'Withdraw tokens from the chequebook to the overlay address' }); Object.defineProperty(this, "amount", { enumerable: true, configurable: true, writable: true, value: void 0 }); Object.defineProperty(this, "unit", { enumerable: true, configurable: true, writable: true, value: void 0 }); } async run() { super.init(); const amountBzz = this.unit === 'bzz' ? bee_js_1.BZZ.fromDecimalString(this.amount) : bee_js_1.BZZ.fromPLUR(this.amount); const response = await this.bee.withdrawBZZFromChequebook(amountBzz); this.console.log((0, text_1.createKeyValue)('Tx', response.toHex())); this.console.quiet(response.toHex()); } } exports.Withdraw = Withdraw; __decorate([ (0, furious_commander_1.Argument)({ key: 'amount', type: 'string', description: 'Amount of tokens to withdraw', required: true, validate: validate_1.validateTokenAmount, }), __metadata("design:type", String) ], Withdraw.prototype, "amount", void 0); __decorate([ (0, furious_commander_1.Option)({ key: 'unit', type: 'enum', description: 'Unit of the amount', enum: ['bzz', 'plur'], default: 'bzz', }), __metadata("design:type", String) ], Withdraw.prototype, "unit", void 0);