Skip to content

Commit

Permalink
Merge pull request #260 from HathorNetwork/dev
Browse files Browse the repository at this point in the history
Release v0.18.0
  • Loading branch information
pedroferreira1 committed Apr 17, 2024
2 parents 81a649b + c49e7ad commit d9013ea
Show file tree
Hide file tree
Showing 22 changed files with 3,197 additions and 2,401 deletions.
4,896 changes: 2,603 additions & 2,293 deletions package-lock.json

Large diffs are not rendered by default.

74 changes: 34 additions & 40 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,56 +1,50 @@
{
"name": "hathor-admin",
"version": "0.17.0",
"version": "0.18.0",
"private": true,
"dependencies": {
"@hathor/wallet-lib": "^0.29.0",
"axios": "^0.17.1",
"bootstrap": "^4.0.0",
"d3-selection": "^1.3.2",
"d3-zoom": "^1.7.3",
"font-awesome": "^4.7.0",
"jquery": "^3.2.1",
"lodash": "^4.17.11",
"npm-run-all": "^4.1.2",
"popper.js": "^1.12.9",
"prop-types": "^15.7.2",
"qrcode.react": "^0.8.0",
"react": "^16.12.0",
"react-cookie-consent": "^6.2.4",
"react-copy-to-clipboard": "^5.0.1",
"react-dom": "^16.2.0",
"react-gtm-module": "^2.0.11",
"react-loading": "^1.0.3",
"react-paginate": "^5.0.0",
"react-redux": "^5.0.7",
"@hathor/wallet-lib": "1.4.0",
"axios": "0.17.1",
"bootstrap": "4.6.2",
"d3-selection": "1.4.2",
"d3-zoom": "1.8.3",
"font-awesome": "4.7.0",
"jquery": "3.7.0",
"lodash": "4.17.21",
"npm-run-all": "4.1.5",
"popper.js": "1.16.1",
"prop-types": "15.8.1",
"qrcode.react": "0.8.0",
"react": "16.14.0",
"react-cookie-consent": "6.4.1",
"react-copy-to-clipboard": "5.1.0",
"react-dom": "16.14.0",
"react-gtm-module": "2.0.11",
"react-loading": "1.0.5",
"react-paginate": "5.3.1",
"react-redux": "5.1.2",
"react-router-dom": "4.2.2",
"react-scripts": "^3.2.0",
"redux": "^4.0.0",
"sass": "^1.44.0",
"viz.js": "^2.1.2",
"unleash-proxy-client": "^1.11.0",
"@unleash/proxy-client-react": "^1.0.4"
"react-scripts": "3.4.4",
"redux": "4.2.1",
"sass": "1.64.2",
"viz.js": "2.1.2",
"unleash-proxy-client": "1.11.0",
"@unleash/proxy-client-react": "1.0.4"
},
"scripts": {
"build-css": "sass src:src",
"watch-css": "npm run build-css && sass --watch src:src",
"start-js": "react-scripts start",
"start-js": "react-scripts --openssl-legacy-provider start",
"start": "npm-run-all -p watch-css start-js",
"build-js": "react-scripts --openssl-legacy-provider build",
"build": "npm-run-all build-css build-js",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
}
19 changes: 12 additions & 7 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,17 @@ import Dag from './screens/Dag';
import Dashboard from './screens/Dashboard';
import VersionError from './screens/VersionError';
import WebSocketHandler from './WebSocketHandler';
import NanoContractDetail from './screens/nano/NanoContractDetail';
import BlueprintDetail from './screens/nano/BlueprintDetail';
import { apiLoadErrorUpdate, dashboardUpdate, isVersionAllowedUpdate } from "./actions/index";
import { connect } from "react-redux";
import versionApi from './api/version';
import helpers from './utils/helpers';
import hathorLib from '@hathor/wallet-lib';
import { axios as hathorLibAxios, config as hathorLibConfig } from '@hathor/wallet-lib';
import { BASE_URL } from './constants';
import createRequestInstance from './api/customAxiosInstance';

const store = new hathorLib.MemoryStore();
hathorLib.storage.setStore(store);
hathorLib.storage.setItem('wallet:server', BASE_URL);

hathorLibConfig.setServerUrl(BASE_URL);

const mapDispatchToProps = dispatch => {
return {
Expand All @@ -58,11 +57,15 @@ class Root extends React.Component {
componentDidMount() {
WebSocketHandler.on('dashboard', this.handleWebsocket);

hathorLib.axios.registerNewCreateRequestInstance(createRequestInstance);
hathorLibAxios.registerNewCreateRequestInstance(createRequestInstance);
this.props.apiLoadErrorUpdate({apiLoadError: false});

versionApi.getVersion().then((data) => {
hathorLib.network.setNetwork(data.network.split('-')[0]);
let network = data.network;
if (data.network.includes('testnet')) {
network = 'testnet';
}
hathorLibConfig.setNetwork(network);
this.props.isVersionAllowedUpdate({allowed: helpers.isVersionAllowed(data.version)});
}, (e) => {
// Error in request
Expand Down Expand Up @@ -120,6 +123,8 @@ class Root extends React.Component {
<NavigationRoute exact path="/statistics" component={Dashboard} />
<NavigationRoute exact path="/token_detail/:tokenUID" component={TokenDetail} />
<NavigationRoute exact path="/address/:address" component={AddressDetail} />
<NavigationRoute exact path="/nano_contract/detail/:nc_id" component={NanoContractDetail} />
<NavigationRoute exact path="/blueprint/detail/:blueprint_id" component={BlueprintDetail} />
<NavigationRoute exact path="" component={DashboardTx} />
</Switch>
</Router>
Expand Down
63 changes: 63 additions & 0 deletions src/api/nanoApi.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/**
* Copyright (c) Hathor Labs and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

import requestExplorerServiceV1 from './axiosInstance';

const nanoApi = {
/**
* Get the state of a nano contract
*
* @param {string} id Nano contract id
* @param {string[]} fields List of fields to get the state
* @param {string[]} balances List of token uids to get the balance
* @param {string[]} fields List of private methods with parameters to call
*
* For more details, see full node api docs
*/
getState(id, fields, balances, calls) {
const data = { id, fields, balances, calls };
return requestExplorerServiceV1.get(`node_api/nc_state`, {params: data}).then((res) => {
return res.data
}, (res) => {
throw new Error(res.data.message);
});
},

/**
* Get the history of transactions of a nano contract
*
* @param {string} id Nano contract id
*
* For more details, see full node api docs
*/
getHistory(id) {
const data = { id };
return requestExplorerServiceV1.get(`node_api/nc_history`, {params: data}).then((res) => {
return res.data
}, (res) => {
throw new Error(res.data.message);
});
},

/**
* Get the blueprint information
*
* @param {string} blueprintId ID of the blueprint
*
* For more details, see full node api docs
*/
getBlueprintInformation(blueprintId) {
const data = { blueprint_id: blueprintId };
return requestExplorerServiceV1.get(`node_api/nc_blueprint_information`, {params: data}).then((res) => {
return res.data
}, (res) => {
throw new Error(res.data.message);
});
},
};

export default nanoApi;
4 changes: 3 additions & 1 deletion src/components/AddressDetailExplorer.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@ class AddressDetailExplorer extends React.Component {
*/
updateAddress = (address) => {
this.setState({ queryParams: this.pagination.obtainQueryParams() }, () => {
if (hathorLib.transaction.isAddressValid(address)) {
const network = hathorLib.config.getNetwork();
const addressObj = new hathorLib.Address(address, { network });
if (addressObj.isValid()) {
this.setState({
address,
loadingTokens: true,
Expand Down
4 changes: 3 additions & 1 deletion src/components/AddressDetailLegacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ class AddressDetailLegacy extends React.Component {
*/
updateAddress = (address) => {
this.setState({ queryParams: this.pagination.obtainQueryParams() }, () => {
if (hathorLib.transaction.isAddressValid(address)) {
const network = hathorLib.config.getNetwork();
const addressObj = new hathorLib.Address(address, { network });
if (addressObj.isValid()) {
this.setState({ address, loadingSummary: true, transactions: [], errorMessage: '' }, () => {
const queryParams = this.pagination.obtainQueryParams();
if (queryParams.token !== null) {
Expand Down
10 changes: 5 additions & 5 deletions src/components/AddressHistory.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ class AddressHistory extends SortableTable {
*/
isAllAuthority = (tx) => {
for (let txin of tx.inputs) {
if (!hathorLib.wallet.isAuthorityOutput(txin) && txin.decoded.address === this.props.address) {
if (!hathorLib.transactionUtils.isAuthorityOutput(txin) && txin.decoded.address === this.props.address) {
return false;
}
}

for (let txout of tx.outputs) {
if (!hathorLib.wallet.isAuthorityOutput(txout) && txout.decoded.address === this.props.address) {
if (!hathorLib.transactionUtils.isAuthorityOutput(txout) && txout.decoded.address === this.props.address) {
return false;
}
}
Expand Down Expand Up @@ -103,12 +103,12 @@ class AddressHistory extends SortableTable {
}
return (
<tr key={tx.tx_id} className={trClass} onClick={(e) => this.props.onRowClicked(tx.tx_id)}>
<td className="d-none d-lg-table-cell pr-3">{hathorLib.helpers.getTxType(tx)}</td>
<td className="d-none d-lg-table-cell pr-3">{hathorLib.helpers.getShortHash(tx.tx_id)}</td>
<td className="d-none d-lg-table-cell pr-3">{hathorLib.transactionUtils.getTxType(tx)}</td>
<td className="d-none d-lg-table-cell pr-3">{hathorLib.helpersUtils.getShortHash(tx.tx_id)}</td>
<td className="d-none d-lg-table-cell pr-3">{dateFormatter.parseTimestamp(tx.timestamp)}</td>
<td className="state">{statusElement}</td>
<td className="value"><span className="">{prettyValue}</span></td>
<td className="d-lg-none d-table-cell pr-3" colSpan="3">{hathorLib.helpers.getTxType(tx)}<br/>{hathorLib.helpers.getShortHash(tx.tx_id)}<br/>{dateFormatter.parseTimestamp(tx.timestamp)}</td>
<td className="d-lg-none d-table-cell pr-3" colSpan="3">{hathorLib.transactionUtils.getTxType(tx)}<br/>{hathorLib.helpersUtils.getShortHash(tx.tx_id)}<br/>{dateFormatter.parseTimestamp(tx.timestamp)}</td>
</tr>
)
});
Expand Down
14 changes: 7 additions & 7 deletions src/components/AddressHistoryLegacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ class AddressHistory extends React.Component {

for (let txin of tx.inputs) {
if (txin.token === token && txin.decoded.address === this.props.address) {
if (!hathorLib.wallet.isAuthorityOutput(txin)) {
if (!hathorLib.transactionUtils.isAuthorityOutput(txin)) {
value -= txin.value;
}
}
}

for (let txout of tx.outputs) {
if (txout.token === token && txout.decoded.address === this.props.address) {
if (!hathorLib.wallet.isAuthorityOutput(txout)) {
if (!hathorLib.transactionUtils.isAuthorityOutput(txout)) {
value += txout.value;
}
}
Expand All @@ -54,13 +54,13 @@ class AddressHistory extends React.Component {
*/
isAllAuthority = (tx) => {
for (let txin of tx.inputs) {
if (!hathorLib.wallet.isAuthorityOutput(txin) && txin.decoded.address === this.props.address) {
if (!hathorLib.transactionUtils.isAuthorityOutput(txin) && txin.decoded.address === this.props.address) {
return false;
}
}

for (let txout of tx.outputs) {
if (!hathorLib.wallet.isAuthorityOutput(txout) && txout.decoded.address === this.props.address) {
if (!hathorLib.transactionUtils.isAuthorityOutput(txout) && txout.decoded.address === this.props.address) {
return false;
}
}
Expand Down Expand Up @@ -165,13 +165,13 @@ class AddressHistory extends React.Component {

return (
<tr key={tx.tx_id} className={trClass} onClick={(e) => this.props.onRowClicked(tx.tx_id)}>
<td className="d-none d-lg-table-cell pr-3">{hathorLib.helpers.getTxType(tx)}</td>
<td className="d-none d-lg-table-cell pr-3">{hathorLib.helpers.getShortHash(tx.tx_id)}</td>
<td className="d-none d-lg-table-cell pr-3">{hathorLib.transactionUtils.getTxType(tx)}</td>
<td className="d-none d-lg-table-cell pr-3">{hathorLib.helpersUtils.getShortHash(tx.tx_id)}</td>
<td className="d-none d-lg-table-cell pr-3">{dateFormatter.parseTimestamp(tx.timestamp)}</td>
<td className={tx.is_voided ? 'voided state' : 'state'}>{statusElement}</td>
<td>{tx.is_voided && <span className="voided-element">Voided</span>}</td>
<td className='value'><span className={tx.is_voided ? 'voided' : ''}>{prettyValue}</span></td>
<td className="d-lg-none d-table-cell pr-3" colSpan="3">{hathorLib.helpers.getTxType(tx)}<br/>{hathorLib.helpers.getShortHash(tx.tx_id)}<br/>{dateFormatter.parseTimestamp(tx.timestamp)}</td>
<td className="d-lg-none d-table-cell pr-3" colSpan="3">{hathorLib.transactionUtils.getTxType(tx)}<br/>{hathorLib.helpersUtils.getShortHash(tx.tx_id)}<br/>{dateFormatter.parseTimestamp(tx.timestamp)}</td>
</tr>
);
});
Expand Down
12 changes: 8 additions & 4 deletions src/components/Navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,15 @@ class Navigation extends React.Component {
if (regex.test(text)) {
// It's a valid hash
this.props.history.push(`/transaction/${text}`);
} else if (hathorLib.transaction.isAddressValid(text)) {
// It's a valid address
this.props.history.push(`/address/${text}`);
} else {
this.showError();
const network = hathorLib.config.getNetwork();
const addressObj = new hathorLib.Address(text, { network });
if (addressObj.isValid()) {
// It's a valid address
this.props.history.push(`/address/${text}`);
} else {
this.showError();
}
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions src/components/feature_activation/FeatureRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import React from 'react';
import featureActivation from '../../utils/featureActivation';
import helpers from '../../utils/helpers';


class FeatureRow extends React.Component {
Expand All @@ -21,9 +22,9 @@ class FeatureRow extends React.Component {
<td className="d-lg-table-cell pr-3">{prettyState}</td>
<td className="d-lg-table-cell pr-3">{acceptance_percentage}</td>
<td className="d-lg-table-cell pr-3">{(this.props.feature.threshold * 100).toFixed(0)}%</td>
<td className="d-lg-table-cell pr-3">{this.props.feature.start_height}</td>
<td className="d-lg-table-cell pr-3">{this.props.feature.minimum_activation_height}</td>
<td className="d-lg-table-cell pr-3">{this.props.feature.timeout_height}</td>
<td className="d-lg-table-cell pr-3">{helpers.renderValue(this.props.feature.start_height, true)}</td>
<td className="d-lg-table-cell pr-3">{helpers.renderValue(this.props.feature.minimum_activation_height, true)}</td>
<td className="d-lg-table-cell pr-3">{helpers.renderValue(this.props.feature.timeout_height, true)}</td>
<td className="d-lg-table-cell pr-3">{this.props.feature.lock_in_on_timeout.toString()}</td>
<td className="d-lg-table-cell pr-3">{this.props.feature.version}</td>
</tr>
Expand Down
4 changes: 3 additions & 1 deletion src/components/feature_activation/Features.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import FeatureRow from './FeatureRow';
import colors from '../../index.scss';
import PaginationURL from '../../utils/pagination';
import featureApi from '../../api/featureApi';
import helpers from '../../utils/helpers';


class Features extends React.Component {
constructor(props) {
Expand Down Expand Up @@ -184,7 +186,7 @@ class Features extends React.Component {
const loadFeaturesPage = () => {
return (
<div>
<div>Showing feature states for <Link to={`/transaction/${this.state.block_hash}`}>current best block</Link> at height {this.state.block_height}.</div>
<div>Showing feature states for <Link to={`/transaction/${this.state.block_hash}`}>current best block</Link> at height {helpers.renderValue(this.state.block_height, true)}.</div>
{!this.state.loaded ? <ReactLoading type='spin' color={colors.purpleHathor} delay={500} /> : loadTable()}
{loadPagination()}
<div className="f-flex flex-column align-items-start common-div bordered-wrapper mt-3 mt-lg-0 w-100 feature-column-descriptions">
Expand Down
2 changes: 1 addition & 1 deletion src/components/token/TokenConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const TokenConfig = (props) => {

const [token, setToken] = useState(props.token);
const [successMessage, setSuccessMessage] = useState('');
const configurationString = hathorLib.tokens.getConfigurationString(token.uid, token.name, token.symbol);
const configurationString = hathorLib.tokensUtils.getConfigurationString(token.uid, token.name, token.symbol);
const alertSuccess = useRef(null);

useEffect(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/token/TokenRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class TokenRow extends React.Component {
render() {
return (
<tr onClick={(e) => this.onRowClicked(this.props.token.uid)}>
<td className="d-lg-table-cell pr-3">{hathorLib.helpers.getShortHash(this.props.token.uid)}</td>
<td className="d-lg-table-cell pr-3">{hathorLib.helpersUtils.getShortHash(this.props.token.uid)}</td>
<td className="d-lg-table-cell pr-3">{this.props.token.name}</td>
<td className="d-lg-table-cell pr-3">{this.props.token.symbol}</td>
<td className="d-lg-table-cell pr-3">{this.props.token.nft ? 'NFT' : 'Custom Token'}</td>
Expand Down
Loading

0 comments on commit d9013ea

Please sign in to comment.