Skip to content

Commit

Permalink
merge pr#39 - detailed debug trace
Browse files Browse the repository at this point in the history
  • Loading branch information
robcxyz committed Jul 12, 2022
2 parents 9baf68f + a724744 commit cdc308b
Show file tree
Hide file tree
Showing 13 changed files with 626 additions and 13 deletions.
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"babel-loader": "8.0.5",
"babel-plugin-named-asset-import": "^0.3.1",
"babel-plugin-transform-remove-console": "^6.9.4",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react-app": "^7.0.2",
"bfj": "6.1.1",
"bignumber.js": "^7.2.1",
Expand Down Expand Up @@ -77,7 +78,8 @@
"redux-logger": "^3.0.6",
"redux-saga": "^0.16.0",
"resolve": "^1.10.0",
"sass-loader": "7.1.0",
"sass": "^1.53.0",
"sass-loader": "^10.1.1",
"style-loader": "0.23.1",
"sw-precache-webpack-plugin": "0.11.4",
"terser-webpack-plugin": "1.2.2",
Expand Down Expand Up @@ -152,7 +154,7 @@
},
"babel": {
"presets": [
"react-app"
"react-app","@babel/preset-env", "@babel/preset-react"
]
},
"eslintConfig": {
Expand Down
Binary file added public/iconex.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/Assets/iconex.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 4 additions & 2 deletions src/Routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import GovernancePage from './pages/GovernancePage'
import ProposalListPage from './pages/ProposalListPage'
import ProposalDetailPage from './pages/ProposalDetailPage'
import TxPage from './pages/TxPage'
import TraceTransactionPage from './pages/TraceTransactionPage'
import { TX_TYPE, SEARCH_TYPE } from './utils/const'
import { getIsSolo } from './utils/utils'
import BodyClassName from 'react-body-classname'
Expand All @@ -40,7 +41,7 @@ class Routes extends Component {
const isMain = window.location.pathname === '/'
const isGovernance = window.location.pathname.includes('governance')
const bodyClassName = isMain ? 'main-back' : (isGovernance ? 'main-back' : '')

console.log(window.location.pathname.includes('trace'),"pathname")
return (
<BodyClassName className={bodyClassName}>
<div id="app-root">
Expand All @@ -62,6 +63,7 @@ class Routes extends Component {
<Route onEnter={window.scroll(0, 0)} path={`/${TX_TYPE.TRANSACTIONS}`} component={TransactionListPage} exact />
<Route onEnter={window.scroll(0, 0)} path={`/${TX_TYPE.TRANSACTIONS}/:pageId`} component={TransactionListPage} />
<Route onEnter={window.scroll(0, 0)} path='/transaction/:txHash' component={TransactionDetailPage} exact />
<Route onEnter={window.scroll(0, 0)} path='/transaction/trace/:txHash' component={TraceTransactionPage} />

<Route onEnter={window.scroll(0, 0)} path={`/${SEARCH_TYPE.CONTRACTS}`} component={ContractListPage} exact />
<Route onEnter={window.scroll(0, 0)} path={`/${SEARCH_TYPE.CONTRACTS}/:pageId`} component={ContractListPage} />
Expand Down Expand Up @@ -125,7 +127,7 @@ class Routes extends Component {
<Route onEnter={window.scroll(0, 0)} component={NotFoundPage} />
</Switch>
</div>
<div className="blank"></div>
<div className={window.location.pathname.includes('trace') ?"tx-blank": "blank"}></div>
</div>
<Footer />
<Popup />
Expand Down
66 changes: 66 additions & 0 deletions src/components/ErrorBlock/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import React, { useState, useEffect } from "react";
// import './toggle.scss';
import "../../style/scss/logs.scss";

function Logs({ logs, logs_error, checkError }) {
const [viewLog, setViewLog] = useState(logs);

const [showOnlyError, setShowOnlyError] = useState(false);
useEffect(() => {
if (showOnlyError) {
setViewLog(logs_error);
} else {
setViewLog(logs);
}
}, [showOnlyError]);
useEffect(() => {
if (showOnlyError) {
setViewLog(logs_error);
} else {
setViewLog(logs);
}
}, [logs, logs_error]);
return (
<div className="log_block">
<h2>
ICON Trace Log
{logs ? (
<div>
<input
type="checkbox"
onChange={(e) => {
setShowOnlyError(e.target.checked);
}}
id="cb-toggle"
/>
<label className={`label`}>Show only errors</label>
</div>
) : null}
</h2>
<ol className="activity-feed">
{viewLog && viewLog?.map(({ level, msg, ts }, index) => {
console.log(msg,level,ts,'===========================>value')
let color = "#dadada";
let dotBackground = "rgb(113, 211, 0)";
if (checkError(msg)) {
color = "#CE2F2F";
dotBackground = "#CE2F2F";
}
return (
<li className={`feed-item time-${ts}`} key={index}>
<time className={`date`}>
time - {ts} | level - {level}
</time>
<span className="text" style={{ color: color }}>
{msg}
</span>
<div className="dot" style={{ background: dotBackground }}></div>
</li>
);
})}
</ol>
</div>
);
}

export default Logs;
2 changes: 1 addition & 1 deletion src/components/GovernancePage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class GovernancePage extends Component {
this.publicTreasury = await getPublicTreasury()
}
async componentDidMount() {
const { data: preps } = await getPReps()
const { data: preps } = await getPReps();
const {totalStake: totalStakedLoop, totalDelegated: totalVotedLoop } = await getPRepsRPC()
const lastBlock = await getLastBlock()
const stepPriceLoop = await getStepPrice()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
epochToFromNow,
convertHexToValue,
} from '../../../utils/utils'
import { TX_TYPE } from '../../../utils/const';

const COUNT = 10

Expand All @@ -32,7 +33,8 @@ class TransactionInfo extends Component {
super(props)
this.state = {
download: undefined,
feeInUSD: 0
feeInUSD: 0,
errorlogs:null
}
}

Expand All @@ -41,6 +43,8 @@ class TransactionInfo extends Component {
const lastBlock = await getLastBlock()
this.setState({lastBlock, currentUSD})
let moreMsg = await getFailMessage(this.props.match.params.txHash)

this.setState({errorlogs:moreMsg})
if(moreMsg && Array.isArray(moreMsg) && moreMsg.length) {
moreMsg = moreMsg[moreMsg.length - 1]
}
Expand Down Expand Up @@ -122,6 +126,7 @@ class TransactionInfo extends Component {
reportedCount,
// stepUsedDetails
} = data
console.log(data,"values========>")

const _stepPrice = step_price || "0"
const stepPriceLoop = IconAmount.of(_stepPrice, IconAmount.Unit.LOOP)
Expand Down Expand Up @@ -150,9 +155,9 @@ class TransactionInfo extends Component {
</td>
</tr>
<tr>
<td>Status</td>
<td className={isFail ? 'fail' : ''} > {isSuccess ? 'Success' : 'Fail'} {(isFail) && `- ${this.state.msgList}`}</td>
</tr>
<td >Status</td>
<td style={{cursor:isFail? 'pointer':'none'}} onClick={()=>isFail && this.props.history.push(`/transaction/trace/${hash}`)} className={isFail ? 'fail' : ''} > {isSuccess ? 'Success' : 'Fail'} {(isFail) && `- ${this.state.msgList}`}</td>
</tr>
<tr>
<td>Block Height</td>
<td><span><BlockLink to={block_number} label={numberWithCommas(block_number)} /></span><em>{`(${ this.state.lastBlock? Number(this.state.lastBlock.height - block_number) : ' -'} Confirmation(s))`}</em></td>
Expand Down
67 changes: 67 additions & 0 deletions src/pages/TraceTransactionPage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import React, { Component } from 'react';
import Logs from '../components/ErrorBlock/index'
import { getFailMessage } from '../redux/store/iiss';
class TraceTransaction extends Component {
constructor(props) {
super(props)
this.state = {
logs:null,
logs_error:[],
status:true
}
}
async componentDidMount(){
try {
let moreMsg = await getFailMessage(this.props.match.params.txHash,'wholemsg');
let err=[];
moreMsg.result.logs.map(e=>{
if (this.checkError(e.msg)) {
err.push(e);
}
})
this.setState({logs:moreMsg.result.logs,logs_error:err,status:true})
} catch (error) {
this.setState({status:false})
}

}
checkError = (data) => {
if (
data.toUpperCase().includes("ERROR") ||
data.toUpperCase().includes("FAILURE") ||
data.toUpperCase().includes("INVALID") ||
data.toUpperCase().includes("SUCCESS=FALSE") ||
data.toUpperCase().includes("SYSTEMEXCEPTION") ||
data.toUpperCase().includes("OUTOFSTEP") ||
data.toUpperCase().includes("REVERTED") ||
data.toUpperCase().includes("SCOREEXCEPTION") ||
data.toUpperCase().includes("ONLY NFT OWNER")
) {
return true;
} else {
return false;
}
};

render() {
console.log(this.state.logs_error.length,"length========>")
return (
<div className="tx-screen0">
<h2 className="tx-title">Transaction Logs</h2>
{this.state.status ?
<Logs checkError={this.checkError} logs_error={this.state.logs_error} logs={this.state.logs} />
:
<div className="log_block">
<h2>
Transaction has been completed successfully
</h2>
</div>
}

</div>
)
}

}

export default TraceTransaction;
6 changes: 4 additions & 2 deletions src/redux/store/iiss.js
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ export async function getLastBlock() {
});
}

export const getFailMessage = async (txHash) => {
export const getFailMessage = async (txHash,type) => {
const param = {
jsonrpc: "2.0",
id: randomUint32(),
Expand All @@ -600,6 +600,7 @@ export const getFailMessage = async (txHash) => {
}
}
try {

const apiUrl = await getWalletApiUrl()
const response = await fetch(`${apiUrl}/api/v3d`, {
method: 'POST',
Expand All @@ -610,7 +611,8 @@ export const getFailMessage = async (txHash) => {
data.result.logs.map(log => {
errorList.push(log.msg)
})
return errorList;
return type==="wholemsg"? data:errorList;

} catch (e) {
console.log(e, "Error from getFailMessage")

Expand Down
1 change: 1 addition & 0 deletions src/redux/store/transactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export function transactionRecentTxAction(payload) {
}

export function transactionTxDetailAction(payload){
console.log(payload,"payload=======>")
return {
type: actionTypes.transactionTxDetail,
payload
Expand Down
21 changes: 19 additions & 2 deletions src/style/css/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,11 @@ body {
position: relative;
background: #fff;
}

.tx-blank {
min-height: 200px;
position: relative;
background: black;
}
.content.half > li {
width: 50%;
}
Expand Down Expand Up @@ -1966,7 +1970,7 @@ body {
}
.table-typeB .fail {
color: #e6001b;
pointer-events: none;
/* pointer-events: none; */
}
.table-typeB .fail em {
color: #e6001b;
Expand Down Expand Up @@ -6142,6 +6146,7 @@ input[type='checkbox']:checked + label {
font-size: .8em !important;
padding: .3em;
}

th#age-format {
color: #3498db;
cursor: pointer;
Expand Down Expand Up @@ -6184,6 +6189,18 @@ th#age-format {
font-weight: 600;
}

.tx-screen0 {
background-color: black;
padding-top: 120px;
min-height: 500px;
}
h2.tx-title {
color: #b6b6b6;
padding-left: 42px;
font-size: 25px;
font-weight: bold;
}

@-webkit-keyframes bubble {
0% {
-webkit-transform: translateY(5px);
Expand Down
Loading

0 comments on commit cdc308b

Please sign in to comment.