diff --git a/src/components/timeseries/ScreenStatusMessage.js b/src/components/timeseries/ScreenStatusMessage.js
index 179e21f..d63787e 100644
--- a/src/components/timeseries/ScreenStatusMessage.js
+++ b/src/components/timeseries/ScreenStatusMessage.js
@@ -1,10 +1,10 @@
import React from 'react';
import { get } from 'lodash';
+import { numberUtils } from '@hathor/wallet-lib';
import blockApi from '../../api/blockApi';
import { SCREEN_STATUS_LOOP_INTERVAL_IN_SECONDS } from '../../constants';
import dateFormatter from '../../utils/date';
-import { numberUtils } from '@hathor/wallet-lib';
import ErrorMessageWithIcon from '../error/ErrorMessageWithIcon';
import Loading from '../Loading';
@@ -60,11 +60,17 @@ class ScreenStatusMessage extends React.Component {
render() {
const height = numberUtils.prettyValue(this.state.height, 0);
+ if (this.state.error) {
+ return (
+
- {this.state.error ? (
-
- ) : this.state.loading ? (
+ {this.state.loading ? (
) : (
diff --git a/src/components/token/TokenAutoCompleteField.js b/src/components/token/TokenAutoCompleteField.js
index c42fa27..c6899af 100644
--- a/src/components/token/TokenAutoCompleteField.js
+++ b/src/components/token/TokenAutoCompleteField.js
@@ -1,10 +1,10 @@
import React from 'react';
import PropTypes from 'prop-types';
-import Loading from '../Loading';
-import tokensApi from '../../api/tokensApi';
import { debounce, get } from 'lodash';
import { constants as hathorLibConstants } from '@hathor/wallet-lib';
import { connect } from 'react-redux';
+import tokensApi from '../../api/tokensApi';
+import Loading from '../Loading';
const DEBOUNCE_SEARCH_TIME = 200; // ms
@@ -45,7 +45,7 @@ class TokenAutoCompleteField extends React.Component {
* @param {*} event
*/
_handleClick(e) {
- const target = e.target;
+ const { target } = e;
if (!target) {
return;
}
@@ -262,7 +262,11 @@ class TokenAutoCompleteField extends React.Component {
_renderAutocompleteResults() {
return this.state.searchResults.map(result => (
-
this.onItemSelected(result)} className="autocomplete-result-item">
+ this.onItemSelected(result)}
+ className="autocomplete-result-item"
+ >
{result.name} ({result.symbol}) - {result.id}
));
diff --git a/src/components/token/Tokens.js b/src/components/token/Tokens.js
index d2c14e6..042df49 100644
--- a/src/components/token/Tokens.js
+++ b/src/components/token/Tokens.js
@@ -7,12 +7,12 @@
import React from 'react';
import PropTypes from 'prop-types';
+import { get, last, find, isEmpty } from 'lodash';
+import { withRouter } from 'react-router-dom';
import TokensTable from './TokensTable';
import TokenSearchField from './TokenSearchField';
import tokensApi from '../../api/tokensApi';
-import { get, last, find, isEmpty } from 'lodash';
import PaginationURL from '../../utils/pagination';
-import { withRouter } from 'react-router-dom';
import ErrorMessageWithIcon from '../error/ErrorMessageWithIcon';
import helpers from '../../utils/helpers';
@@ -127,7 +127,7 @@ class Tokens extends React.Component {
this.setState({ isSearchLoading: true });
const tokens = await this.getTokens([]);
- //When search button is clicked, results return to the first page
+ // When search button is clicked, results return to the first page
this.setState({
isSearchLoading: false,
page: 1,
@@ -184,7 +184,7 @@ class Tokens extends React.Component {
*
* @param {*} event
*/
- nextPageClicked = async event => {
+ nextPageClicked = async _event => {
this.setState({ calculatingPage: true });
const nextPage = this.state.page + 1;
@@ -222,7 +222,7 @@ class Tokens extends React.Component {
*
* @param {*} event
*/
- previousPageClicked = async event => {
+ previousPageClicked = async _event => {
this.setState({ calculatingPage: true });
const previousPage = this.state.page - 1;
@@ -236,7 +236,7 @@ class Tokens extends React.Component {
this.setState({
tokens: tokens.hits,
hasAfter: true,
- hasBefore: previousPage === 1 ? false : true,
+ hasBefore: previousPage !== 1,
page: previousPage,
calculatingPage: false,
});
diff --git a/src/components/tx/TxData.js b/src/components/tx/TxData.js
index 0dd0e3c..aa5aa4e 100644
--- a/src/components/tx/TxData.js
+++ b/src/components/tx/TxData.js
@@ -6,25 +6,25 @@
*/
import $ from 'jquery';
-import HathorAlert from '../HathorAlert';
import React from 'react';
+import Viz from 'viz.js';
+import hathorLib from '@hathor/wallet-lib';
+import { CopyToClipboard } from 'react-copy-to-clipboard';
+import { Link } from 'react-router-dom';
+import { Module, render } from 'viz.js/full.render';
+import { connect } from 'react-redux';
+import { get, upperFirst } from 'lodash';
+import HathorAlert from '../HathorAlert';
import TokenMarkers from '../token/TokenMarkers';
import TxAlerts from './TxAlerts';
import TxMarkers from './TxMarkers';
-import Viz from 'viz.js';
import dateFormatter from '../../utils/date';
-import hathorLib from '@hathor/wallet-lib';
import helpers from '../../utils/helpers';
import metadataApi from '../../api/metadataApi';
import graphvizApi from '../../api/graphvizApi';
-import { CopyToClipboard } from 'react-copy-to-clipboard';
-import { Link } from 'react-router-dom';
-import { Module, render } from 'viz.js/full.render.js';
import Loading from '../Loading';
import FeatureDataRow from '../feature_activation/FeatureDataRow';
import featureApi from '../../api/featureApi';
-import { connect } from 'react-redux';
-import { get, upperFirst } from 'lodash';
const mapStateToProps = state => ({
nativeToken: state.serverInfo.native_token,
@@ -121,7 +121,7 @@ class TxData extends React.Component {
* Add all tokens of this transaction (inputs and outputs) to the state
*/
calculateTokens = () => {
- let tokens = this.props.transaction.tokens;
+ const { tokens } = this.props.transaction;
const metaRequests = tokens.map(token => this.getTokenMetadata(token));
@@ -131,7 +131,7 @@ class TxData extends React.Component {
};
getNativeToken = () => {
- const nativeToken = this.props.nativeToken;
+ const { nativeToken } = this.props;
return { ...nativeToken, uid: hathorLib.constants.NATIVE_TOKEN_UID };
};
@@ -147,7 +147,7 @@ class TxData extends React.Component {
...token,
meta: data,
}))
- .catch(err => token);
+ .catch(_err => token);
};
/**
@@ -215,7 +215,7 @@ class TxData extends React.Component {
toggleGraph = async (e, index) => {
e.preventDefault();
- let graphs = [...this.state.graphs];
+ const graphs = [...this.state.graphs];
graphs[index].showNeighbors = !graphs[index].showNeighbors;
this.setState({ graphs });
@@ -299,13 +299,12 @@ class TxData extends React.Component {
const renderBlockOrTransaction = () => {
if (hathorLib.transactionUtils.isBlock(this.props.transaction)) {
return 'block';
- } else {
- return 'transaction';
}
+ return 'transaction';
};
const renderInputs = inputs => {
- return inputs.map((input, idx) => {
+ return inputs.map((input, _idx) => {
return (
{helpers.getShortHash(input.tx_id)} (
@@ -327,30 +326,26 @@ class TxData extends React.Component {
if (hathorLib.transactionUtils.isAuthorityOutput(output)) {
if (hathorLib.transactionUtils.isMint(output)) {
return 'Mint authority';
- } else if (hathorLib.transactionUtils.isMelt(output)) {
- return 'Melt authority';
- } else {
- // Should never come here
- return 'Unknown authority';
}
- } else {
- if (!this.state.metadataLoaded) {
- // We show 'Loading' until all metadatas are loaded
- // to prevent switching from decimal to integer if one of the tokens is an NFT
- return 'Loading...';
+ if (hathorLib.transactionUtils.isMelt(output)) {
+ return 'Melt authority';
}
-
- // if it's an NFT token we should show integer value
- const uid = this.getUIDFromTokenData(
- hathorLib.tokensUtils.getTokenIndexFromData(output.token_data)
- );
- const tokenData = this.state.tokens.find(token => token.uid === uid);
- const isNFT = tokenData && tokenData.meta && tokenData.meta.nft;
- return hathorLib.numberUtils.prettyValue(
- output.value,
- isNFT ? 0 : this.props.decimalPlaces
- );
+ // Should never come here
+ return 'Unknown authority';
+ }
+ if (!this.state.metadataLoaded) {
+ // We show 'Loading' until all metadatas are loaded
+ // to prevent switching from decimal to integer if one of the tokens is an NFT
+ return 'Loading...';
}
+
+ // if it's an NFT token we should show integer value
+ const uid = this.getUIDFromTokenData(
+ hathorLib.tokensUtils.getTokenIndexFromData(output.token_data)
+ );
+ const tokenData = this.state.tokens.find(token => token.uid === uid);
+ const isNFT = tokenData && tokenData.meta && tokenData.meta.nft;
+ return hathorLib.numberUtils.prettyValue(output.value, isNFT ? 0 : this.props.decimalPlaces);
};
const renderOutputLink = idx => {
@@ -361,9 +356,8 @@ class TxData extends React.Component {
(
Spent)
);
- } else {
- return null;
}
+ return null;
};
const renderInputOrOutput = (output, idx, isOutput) => {
@@ -387,12 +381,13 @@ class TxData extends React.Component {
};
const renderDecodedScript = output => {
+ let script;
switch (output.decoded.type) {
case 'P2PKH':
case 'MultiSig':
return renderP2PKHorMultiSig(output.decoded);
default:
- let script = output.script;
+ script = output.script;
// Try to parse as script data
try {
// The output script is decoded to base64 in the full node
@@ -401,6 +396,7 @@ class TxData extends React.Component {
// In the future we must receive from the full node
// the decoded.type as script data but this still needs
// some refactor there that won't happen soon
+ // eslint-disable-next-line new-cap
const buff = new Buffer.from(script, 'base64');
const parsedData = hathorLib.scriptsUtils.parseScriptData(buff);
return renderDataScript(parsedData.data);
@@ -414,7 +410,9 @@ class TxData extends React.Component {
try {
script = atob(output.script);
- } catch {}
+ } catch (e) {
+ console.error(e);
+ }
return `Unable to decode script: ${script.trim()}`;
}
@@ -425,7 +423,7 @@ class TxData extends React.Component {
};
const renderP2PKHorMultiSig = decoded => {
- var ret = decoded.address;
+ let ret = decoded.address;
if (decoded.timelock) {
ret = `${ret} | Locked until ${dateFormatter.parseTimestamp(decoded.timelock)}`;
}
@@ -435,7 +433,7 @@ class TxData extends React.Component {
const renderListWithLinks = (hashes, textDark) => {
if (hashes.length === 0) {
- return;
+ return undefined;
}
if (hashes.length === 1) {
const h = hashes[0];
@@ -465,9 +463,7 @@ class TxData extends React.Component {
};
const renderTwins = () => {
- if (!this.props.meta.twins.length) {
- return;
- } else {
+ if (this.props.meta.twins.length) {
return (
This transaction has twin{' '}
@@ -476,11 +472,13 @@ class TxData extends React.Component {
);
}
+
+ return undefined;
};
const renderConflicts = () => {
- let twins = this.props.meta.twins;
- let conflictNotTwin = this.props.meta.conflict_with.length
+ const { twins } = this.props.meta;
+ const conflictNotTwin = this.props.meta.conflict_with.length
? this.props.meta.conflict_with.filter(hash => twins.indexOf(hash) < 0)
: [];
if (!this.props.meta.voided_by.length) {
@@ -513,7 +511,7 @@ class TxData extends React.Component {
);
}
- return;
+ return undefined;
}
if (!this.props.meta.conflict_with.length) {
@@ -590,15 +588,13 @@ class TxData extends React.Component {
if (!this.props.confirmationData.success) {
return 'Not available';
}
- let acc = helpers.roundFloat(this.props.confirmationData.accumulated_weight);
+ const acc = helpers.roundFloat(this.props.confirmationData.accumulated_weight);
if (this.props.confirmationData.accumulated_bigger) {
return `Over ${acc}`;
- } else {
- return acc;
}
- } else {
- return 'Retrieving accumulated weight data...';
+ return acc;
}
+ return 'Retrieving accumulated weight data...';
};
const renderHeight = () => {
@@ -621,9 +617,8 @@ class TxData extends React.Component {
const renderTokenUID = token => {
if (token.uid === hathorLib.constants.NATIVE_TOKEN_UID) {
return token.uid;
- } else {
- return
{token.uid};
}
+ return
{token.uid};
};
const tokens = this.state.tokens.map(token => {
return (