Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: show the list of actions of a nano contract tx in the tx data screen #286

Merged
merged 1 commit into from
Aug 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/components/tx/TxData.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ 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) => ({
Expand Down Expand Up @@ -623,6 +624,29 @@ class TxData extends React.Component {
);
}

const renderNCActionsList = () => {
return this.props.transaction.nc_context.actions.map((action, index) => (
<div key={index} className="d-flex flex-column align-items-start">
<div>
<label>Type:</label> {upperFirst(action.type)}
</div>
<div>
<label>Amount:</label> {hathorLib.numberUtils.prettyValue(action.amount, this.props.decimalPlaces)} {this.getSymbol(action.token_uid)}
</div>
</div>
));
}

const renderNCActions = () => {
const actionsCount = get(this.props.transaction, 'nc_context.actions.length', 0);
return (
<div className="d-flex flex-column align-items-start common-div bordered-wrapper mr-3">
<div><label>Actions ({ actionsCount })</label></div>
{actionsCount > 0 && renderNCActionsList()}
</div>
);
}

const renderNCData = () => {
if (this.state.ncLoading) {
return (
Expand Down Expand Up @@ -748,6 +772,9 @@ class TxData extends React.Component {
<div className="d-flex flex-row align-items-start mb-3">
{this.props.transaction.version === hathorLib.constants.NANO_CONTRACTS_VERSION && renderNCData()}
</div>
<div className="d-flex flex-row align-items-start mb-3">
{this.props.transaction.version === hathorLib.constants.NANO_CONTRACTS_VERSION && renderNCActions()}
</div>
<div className="d-flex flex-column flex-lg-row align-items-start mb-3 w-100">
<div className="f-flex flex-column align-items-start common-div bordered-wrapper mr-lg-3 w-100">
<div><label>Inputs ({ this.props.transaction.inputs.length })</label></div>
Expand Down