fix files with linting issues

pull/5370/head
davidzagi93@gmail.com 3 years ago
parent fbf3c0f5cd
commit 50ca839652
  1. 44
      libs/remix-ui/terminal/src/lib/remix-ui-terminal.tsx

@ -54,8 +54,8 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
const [toggleDownUp, setToggleDownUp] = useState('fa-angle-double-down') const [toggleDownUp, setToggleDownUp] = useState('fa-angle-double-down')
const [_cmdIndex, setCmdIndex] = useState(-1) const [_cmdIndex, setCmdIndex] = useState(-1)
const [_cmdTemp, setCmdTemp] = useState('') const [_cmdTemp, setCmdTemp] = useState('')
const [_cmdHistory, setCmdHistory] = useState([]) // const [_cmdHistory, setCmdHistory] = useState([])
const [windowHeight, setWindowHeight] = useState(window.innerHeight) const [, setWindowHeight] = useState(window.innerHeight)
// dragable state // dragable state
const [leftHeight, setLeftHeight] = useState<undefined | number>(undefined) const [leftHeight, setLeftHeight] = useState<undefined | number>(undefined)
const [separatorYPosition, setSeparatorYPosition] = useState<undefined | number>(undefined) const [separatorYPosition, setSeparatorYPosition] = useState<undefined | number>(undefined)
@ -63,8 +63,8 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
const [newstate, dispatch] = useReducer(registerCommandReducer, initialState) const [newstate, dispatch] = useReducer(registerCommandReducer, initialState)
const [cmdHistory, cmdHistoryDispatch] = useReducer(addCommandHistoryReducer, initialState) const [cmdHistory, cmdHistoryDispatch] = useReducer(addCommandHistoryReducer, initialState)
const [scriptRunnserState, scriptRunnerDispatch] = useReducer(registerScriptRunnerReducer, initialState) const [, scriptRunnerDispatch] = useReducer(registerScriptRunnerReducer, initialState)
const [isListeningOnNetwork, setIsListeningOnNetwork] = useState(false) const [, setIsListeningOnNetwork] = useState(false)
const [clearConsole, setClearConsole] = useState(false) const [clearConsole, setClearConsole] = useState(false)
const [paste, setPaste] = useState(false) const [paste, setPaste] = useState(false)
const [autoCompletState, setAutoCompleteState] = useState({ const [autoCompletState, setAutoCompleteState] = useState({
@ -114,7 +114,7 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
registerCommandAction('warn', _blocksRenderer('warn'), { activate: true }, dispatch) registerCommandAction('warn', _blocksRenderer('warn'), { activate: true }, dispatch)
registerCommandAction('error', _blocksRenderer('error'), { activate: true }, dispatch) registerCommandAction('error', _blocksRenderer('error'), { activate: true }, dispatch)
registerCommandAction('script', function execute (args, scopedCommands, append) { registerCommandAction('script', function execute (args, scopedCommands) {
var script = String(args[0]) var script = String(args[0])
_shell(script, scopedCommands, function (error, output) { _shell(script, scopedCommands, function (error, output) {
if (error) scriptRunnerDispatch({ type: 'error', payload: { message: error } }) if (error) scriptRunnerDispatch({ type: 'error', payload: { message: error } })
@ -392,12 +392,13 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
setAutoCompleteState(prevState => ({ ...prevState, activeSuggestion: suggestionCount - 1, userInput: Object.keys(autoCompletState.data._options[autoCompletState.activeSuggestion]).toString() })) setAutoCompleteState(prevState => ({ ...prevState, activeSuggestion: suggestionCount - 1, userInput: Object.keys(autoCompletState.data._options[autoCompletState.activeSuggestion]).toString() }))
console.log({ autoCompletState }, 'disable up an down key in input box') console.log({ autoCompletState }, 'disable up an down key in input box')
} else if (event.which === 38 && !autoCompletState.showSuggestions) { // <arrowUp> } else if (event.which === 38 && !autoCompletState.showSuggestions) { // <arrowUp>
const len = _cmdHistory.length // const len = _cmdHistory.length
if (len === 0) event.preventDefault() // if (len === 0) event.preventDefault()
if (_cmdHistory.length - 1 > _cmdIndex) { if (cmdHistory.length - 1 > _cmdIndex) {
setCmdIndex(prevState => prevState++) setCmdIndex(prevState => prevState++)
} }
inputEl.current.innerText = _cmdHistory[_cmdIndex] // console.log({ _cmdIndex }, 'history')
inputEl.current.innerText = cmdHistory[_cmdIndex]
inputEl.current.focus() inputEl.current.focus()
} else if (event.which === 40 && autoCompletState.showSuggestions) { } else if (event.which === 40 && autoCompletState.showSuggestions) {
event.preventDefault() event.preventDefault()
@ -405,12 +406,11 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
return return
} }
setAutoCompleteState(prevState => ({ ...prevState, activeSuggestion: suggestionCount + 1, userInput: Object.keys(autoCompletState.data._options[autoCompletState.activeSuggestion + 1]).toString() })) setAutoCompleteState(prevState => ({ ...prevState, activeSuggestion: suggestionCount + 1, userInput: Object.keys(autoCompletState.data._options[autoCompletState.activeSuggestion + 1]).toString() }))
console.log('disable up an down key in input box')
} else if (event.which === 40 && !autoCompletState.showSuggestions) { } else if (event.which === 40 && !autoCompletState.showSuggestions) {
if (_cmdIndex > -1) { if (_cmdIndex > -1) {
setCmdIndex(prevState => prevState--) setCmdIndex(prevState => prevState--)
} }
inputEl.current.innerText = _cmdIndex >= 0 ? _cmdHistory[_cmdIndex] : _cmdTemp inputEl.current.innerText = _cmdIndex >= 0 ? cmdHistory[_cmdIndex] : _cmdTemp
inputEl.current.focus() inputEl.current.focus()
} else { } else {
setCmdTemp(inputEl.current.innerText) setCmdTemp(inputEl.current.innerText)
@ -434,7 +434,6 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
setSeparatorYPosition(e.clientY) setSeparatorYPosition(e.clientY)
setLeftHeight(newLeftHeight) setLeftHeight(newLeftHeight)
props.event.trigger('resize', [newLeftHeight + 32]) props.event.trigger('resize', [newLeftHeight + 32])
console.log({ newLeftHeight })
} }
} }
@ -471,7 +470,6 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
const _blocksRenderer = (mode) => { const _blocksRenderer = (mode) => {
if (mode === 'html') { if (mode === 'html') {
return function logger (args) { return function logger (args) {
console.log({ args })
if (args.length) { if (args.length) {
return args[0] return args[0]
} }
@ -498,7 +496,6 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
return val return val
}) })
if (values.length) { if (values.length) {
console.log({ values })
return `<span class="${mode}" >${values}</span>` return `<span class="${mode}" >${values}</span>`
} }
} }
@ -526,7 +523,6 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
event.preventDefault() event.preventDefault()
const inputString = event.target.value const inputString = event.target.value
if (matched(allPrograms, inputString) || inputString.includes('.')) { if (matched(allPrograms, inputString) || inputString.includes('.')) {
console.log(paste, 'onchange')
if (paste) { if (paste) {
setPaste(false) setPaste(false)
setAutoCompleteState(prevState => ({ ...prevState, showSuggestions: false, userInput: inputString })) setAutoCompleteState(prevState => ({ ...prevState, showSuggestions: false, userInput: inputString }))
@ -565,7 +561,6 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
} }
const checkTxStatus = (tx, type) => { const checkTxStatus = (tx, type) => {
console.log('inside checkTxStatus')
if (tx.status === '0x1' || tx.status === true) { if (tx.status === '0x1' || tx.status === true) {
return (<i className='txStatus succeeded fas fa-check-circle'></i>) return (<i className='txStatus succeeded fas fa-check-circle'></i>)
} }
@ -590,11 +585,9 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
const block = data.receipt ? data.receipt.blockNumber : data.blockNumber || '' const block = data.receipt ? data.receipt.blockNumber : data.blockNumber || ''
const i = data.receipt ? data.transactionIndex : data.transactionIndex const i = data.receipt ? data.transactionIndex : data.transactionIndex
const value = val ? typeConversion.toInt(val) : 0 const value = val ? typeConversion.toInt(val) : 0
console.log('inside context method')
if (blockchain.getProvider() === 'vm') { if (blockchain.getProvider() === 'vm') {
return ( return (
<div> <div>
{console.log('inside context method return')}
<span className='txLog_7Xiho'> <span className='txLog_7Xiho'>
<span className='tx'>[vm]</span> <span className='tx'>[vm]</span>
<div className='txItem'><span className='txItemTitle'>from:</span> {from}</div> <div className='txItem'><span className='txItemTitle'>from:</span> {from}</div>
@ -636,7 +629,6 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
const txDetails = (event, tx) => { const txDetails = (event, tx) => {
if (showTableHash.includes(tx.hash)) { if (showTableHash.includes(tx.hash)) {
const index = showTableHash.indexOf(tx.hash) const index = showTableHash.indexOf(tx.hash)
console.log({ index })
if (index > -1) { if (index > -1) {
setShowTableHash((prevState) => prevState.filter((x) => x !== tx.hash)) setShowTableHash((prevState) => prevState.filter((x) => x !== tx.hash))
} }
@ -804,7 +796,6 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
const debug = (event, tx) => { const debug = (event, tx) => {
event.stopPropagation() event.stopPropagation()
if (tx.isCall && tx.envMode !== 'vm') { if (tx.isCall && tx.envMode !== 'vm') {
console.log('start debugging')
return (<ModalDialog return (<ModalDialog
hide={false} hide={false}
handleHide={() => {} } handleHide={() => {} }
@ -812,7 +803,6 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
/>) />)
} else { } else {
props.event.trigger('debuggingRequested', [tx.hash]) props.event.trigger('debuggingRequested', [tx.hash])
console.log('trigger ', { tx: props.event.trigger })
} }
} }
@ -821,13 +811,11 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
const to = tx.to const to = tx.to
// const obj = { from, to } // const obj = { from, to }
const txType = 'unknown' + (tx.isCall ? 'Call' : 'Tx') const txType = 'unknown' + (tx.isCall ? 'Call' : 'Tx')
console.log('render unknown transaction ')
return ( return (
<span id={`tx${tx.hash}`} key={index}> <span id={`tx${tx.hash}`} key={index}>
<div className="log" onClick={(event) => txDetails(event, tx)}> <div className="log" onClick={(event) => txDetails(event, tx)}>
{checkTxStatus(receipt || tx, txType)} {checkTxStatus(receipt || tx, txType)}
{context({ from, to, tx }, props.blockchain)} {context({ from, to, tx }, props.blockchain)}
{ console.log('under context and checkTxStatus')}
<div className='buttons'> <div className='buttons'>
<div className='debug btn btn-primary btn-sm' data-shared='txLoggerDebugButton' data-id={`txLoggerDebugButton${tx.hash}`} onClick={(event) => debug(event, tx)}>Debug</div> <div className='debug btn btn-primary btn-sm' data-shared='txLoggerDebugButton' data-id={`txLoggerDebugButton${tx.hash}`} onClick={(event) => debug(event, tx)}>Debug</div>
</div> </div>
@ -848,7 +836,6 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
transactionCost: tx.transactionCost, transactionCost: tx.transactionCost,
executionCost: tx.executionCost executionCost: tx.executionCost
}) : null} }) : null}
{ console.log('end')}
</span> </span>
) )
} }
@ -858,7 +845,6 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
const to = resolvedData.contractName + '.' + resolvedData.fn const to = resolvedData.contractName + '.' + resolvedData.fn
// const obj = { from, to } // const obj = { from, to }
const txType = 'knownTx' const txType = 'knownTx'
console.log('render unknown transaction ')
return ( return (
<span id={`tx${tx.hash}`} key={index}> <span id={`tx${tx.hash}`} key={index}>
<div className="log" onClick={(event) => txDetails(event, tx)}> <div className="log" onClick={(event) => txDetails(event, tx)}>
@ -886,7 +872,6 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
transactionCost: tx.transactionCost, transactionCost: tx.transactionCost,
executionCost: tx.executionCost executionCost: tx.executionCost
}) : null} }) : null}
{ console.log('end')}
</span> </span>
) )
} }
@ -1373,8 +1358,8 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
return ( return (
<div style={{ height: '323px', flexGrow: 1 }} className='panel'> <div style={{ height: '323px', flexGrow: 1 }} className='panel'>
{console.log({ newstate })} {console.log({ newstate })}
{console.log({ props })} {console.log({ _cmdIndex })}
{console.log({ autoCompletState })} {console.log({ cmdHistory })}
<div className="bar"> <div className="bar">
{/* ${self._view.dragbar} */} {/* ${self._view.dragbar} */}
<div className="dragbarHorizontal" onMouseDown={mousedown} id='dragId'></div> <div className="dragbarHorizontal" onMouseDown={mousedown} id='dragId'></div>
@ -1443,16 +1428,13 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
) )
} else if (x.name === 'unknownTransaction') { } else if (x.name === 'unknownTransaction') {
return x.message.filter(x => x.tx.hash.includes(searchInput) || x.tx.from.includes(searchInput) || (x.tx.to.includes(searchInput))).map((trans) => { return x.message.filter(x => x.tx.hash.includes(searchInput) || x.tx.from.includes(searchInput) || (x.tx.to.includes(searchInput))).map((trans) => {
console.log({ trans }, 'first output from deploy')
return (<div className='px-4 block' data-id={`block_tx${trans.tx.hash}`} key={index}> {renderUnKnownTransactions(trans.tx, trans.receipt, index)} </div>) return (<div className='px-4 block' data-id={`block_tx${trans.tx.hash}`} key={index}> {renderUnKnownTransactions(trans.tx, trans.receipt, index)} </div>)
}) })
} else if (x.name === 'knownTransaction') { } else if (x.name === 'knownTransaction') {
return x.message.map((trans) => { return x.message.map((trans) => {
console.log({ trans }, 'first output from deploy')
return (<div className='px-4 block' data-id={`block_tx${trans.tx.hash}`} key={index}> {renderKnownTransactions(trans.tx, trans.receipt, trans.resolvedData, trans.logs, index)} </div>) return (<div className='px-4 block' data-id={`block_tx${trans.tx.hash}`} key={index}> {renderKnownTransactions(trans.tx, trans.receipt, trans.resolvedData, trans.logs, index)} </div>)
}) })
} else { } else {
console.log({ x }, 'second output from deploy')
return ( return (
<div className="px-4 block" data-id="block_null" key={index}> <div className="px-4 block" data-id="block_null" key={index}>
<span className={x.style}>{x.message}</span> <span className={x.style}>{x.message}</span>

Loading…
Cancel
Save