UNPKG

@ethersphere/swarm-cli

Version:
81 lines (80 loc) 3.49 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.WithdrawDAI = void 0; const bee_js_1 = require("@ethersphere/bee-js"); const furious_commander_1 = require("furious-commander"); const text_1 = require("../../utils/text"); const root_command_1 = require("../root-command"); class WithdrawDAI extends root_command_1.RootCommand { constructor() { super(...arguments); Object.defineProperty(this, "name", { enumerable: true, configurable: true, writable: true, value: 'withdraw-dai' }); Object.defineProperty(this, "address", { enumerable: true, configurable: true, writable: true, value: void 0 }); Object.defineProperty(this, "amountDai", { enumerable: true, configurable: true, writable: true, value: void 0 }); Object.defineProperty(this, "description", { enumerable: true, configurable: true, writable: true, value: `Withdraw xDAI to a whitelisted wallet address` }); } async run() { super.init(); const amount = bee_js_1.DAI.fromDecimalString(this.amountDai); this.console.log('The address you are withdrawing to must be whitelisted in the Bee config.'); this.console.log('If you receive status code 400, the address may not be whitelisted.'); this.console.log(''); if (!this.quiet && !this.yes) { this.yes = await this.console.confirm(`You are about to withdraw ${amount.toDecimalString()} xDAI to ${this.address}, are you sure you wish to proceed?`); } if (!this.yes && !this.quiet) { return; } const transaction = await this.bee.withdrawDAIToExternalWallet(amount, this.address); this.console.log((0, text_1.createKeyValue)('Transaction', transaction.represent())); this.console.log((0, text_1.createKeyValue)('URL', `https://gnosisscan.io/tx/0x${transaction.represent()}`)); } } exports.WithdrawDAI = WithdrawDAI; __decorate([ (0, furious_commander_1.Option)({ key: 'address', type: 'hex-string', description: 'Target wallet address, must be allowlisted in Bee config', required: true, }), __metadata("design:type", String) ], WithdrawDAI.prototype, "address", void 0); __decorate([ (0, furious_commander_1.Option)({ key: 'dai', description: 'Amount of xDAI to withdraw to the external wallet', type: 'string', required: true, }), __metadata("design:type", String) ], WithdrawDAI.prototype, "amountDai", void 0);