UNPKG

burst-whale-watch

Version:

An account watcher for Burstcoin

68 lines 2.49 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const blessed = require("neo-blessed"); const selectors_1 = require("../state/selectors"); const util_1 = require("@burstjs/util"); const constants_1 = require("../constants"); const transactionTable_view_1 = require("./transactionTable.view"); class AccountView { constructor(parentView, index, total) { const width = 100 / total; const left = `${index * width}%+1`; this.box = blessed.box({ parent: parentView, top: 2, left, width: `${width}%-4`, height: '80%', tags: true, label: { text: `{bold}${constants_1.LOADING_TEXT}{/}`, side: 'left' }, border: { type: 'line' }, style: { bg: 'black', border: { fg: 'white', bold: true, }, } }); const textBaseSettings = { parent: this.box, top: 0, width: '100%-2', tags: true, style: { fg: 'white', bold: true, bg: 'black', border: { fg: '#ffffff' }, } }; this.text = blessed.text(Object.assign(Object.assign({}, textBaseSettings), { left: 0 })); this.transactionTable = new transactionTable_view_1.TransactionTableView(this.box); } get element() { return this.box; } update(state, accountData) { const isLoading = selectors_1.selectIsLoadingTransactions(state); if (isLoading || !accountData) { return; } const accountId = accountData.id; const address = util_1.convertNumericIdToAddress(accountId); const balanceBurst = util_1.convertNQTStringToNumber(accountData.balance).toFixed(3); let startLine = 1; this.box.setLabel({ text: `(${accountData.index}) {bold}${address}{/}`, side: 'left' }); this.text.setLine(startLine, ` Account: ${accountId}`); this.text.setLine(++startLine, ` Total [BURST]: ${balanceBurst}`); const accountTransactions = selectors_1.selectGetAccountTransactions(state); this.transactionTable.update(state, accountId, accountTransactions[accountId]); } } exports.AccountView = AccountView; //# sourceMappingURL=account.view.js.map