logging winnerName from Run and Deploy to terminal

pull/1342/head
davidzagi93@gmail.com 3 years ago
parent e594d7a06c
commit 09ba14aa90
  1. 3
      apps/remix-ide-e2e/src/commands/testFunction.ts
  2. 1
      apps/remix-ide/src/app/panels/terminal.js
  3. 27
      libs/remix-ui/terminal/src/lib/actions/terminalAction.ts
  4. 1
      libs/remix-ui/terminal/src/lib/reducers/terminalReducer.ts
  5. 55
      libs/remix-ui/terminal/src/lib/remix-ui-terminal.tsx

@ -25,7 +25,6 @@ class TestFunction extends EventEmitter {
browser.waitForElementVisible(`[data-id="block_tx${txHash}"]`, 60000)
.click(`[data-id="block_tx${txHash}"]`)
.waitForElementVisible(`*[data-id="txLoggerTable${txHash}"]`, 60000)
.pause(10000)
// fetch and format transaction logs as key => pair object
.elements('css selector', `*[data-shared="key_${txHash}"]`, (res) => {
Array.isArray(res.value) && res.value.forEach(function (jsonWebElement) {
@ -55,10 +54,10 @@ class TestFunction extends EventEmitter {
})
}).perform(() => done())
})
.click(`[data-id="block_tx${txHash}"]`)
.perform(() => {
Object.keys(expectedValue).forEach(key => {
let equal = false
try {
const receivedValue = JSON.parse(logs[key])

@ -106,6 +106,7 @@ class Terminal extends Plugin {
// console.log({ html: html.innerText })
this.logHtmlResponse.push(html.innerText)
this.renderComponent()
this.logHtmlResponse = []
}
render () {

@ -1,6 +1,5 @@
export const registerCommandAction = (name, command, activate, dispatch) => {
console.log(name, ' object key')
const commands: any = {}
const _commands: any = {}
_commands[name] = command
@ -55,12 +54,10 @@ export const registerCommandAction = (name, command, activate, dispatch) => {
item.step = steps.push(item) - 1
item.args = params
// _appendItem(item)
console.log({ item }, 'append items')
// self._appendItem(item)
}
var scopedCommands = _scopeCommands(append)
command(args, scopedCommands, el => append(null, args, blockify(el)))
console.log({ args })
}
const help = typeof command.help === 'string' ? command.help : [
'// no help available for:', `terminal.command.${name}`
@ -84,15 +81,11 @@ export const registerCommandAction = (name, command, activate, dispatch) => {
var command = _commands[cmd]
scopedCommands[cmd] = function _command () {
var args = [...arguments]
console.log({ cmd }, { args }, { blockify })
command(args, scopedCommands, el => append(cmd, args, blockify(el)))
}
})
console.log({ scopedCommands })
return scopedCommands
}
console.log('david test dispatch')
}
export const filterFnAction = (name, filterFn, dispatch) => {
@ -145,20 +138,16 @@ export const initListeningOnNetwork = (props, dispatch) => {
props.txListener.event.register('newBlock', (block) => {
if (!block.transactions || (block.transactions && !block.transactions.length)) {
dispatch({ type: 'emptyBlock', payload: { message: 0 } })
console.log({ block }, ' david')
// registerCommandAction('emptyBlock', (args, cmds, append) => {
// const data = args[0]
// console.log({ data }, ' useEffect props')
// // // var el = renderEmptyBlock(this, data)
// // // append(el)
// }, { activate: true }, dispatch)
} else {
registerCommandAction('knownTransaction', function (args) {
var data = args[0]
console.log({ data })
// let el
// if (data.tx.isCall) {
// console.log({ data })
// // el = renderCall(this, data)
// } else {
// // el = renderKnownTransaction(this, data, blockchain)
@ -168,12 +157,14 @@ export const initListeningOnNetwork = (props, dispatch) => {
}, { activate: true }, dispatch)
}
})
props.txListener.event.register('newCall', () => {
console.log('new call action')
props.txListener.event.register('knownTransaction', (block) => {
console.log({ block }, ' is call transaction test')
})
props.txListener.event.register('newCall', (tx, receipt) => {
log(props, tx, receipt, dispatch)
// log(this, tx, null)
})
props.txListener.event.register('newTransaction', (tx, receipt) => {
console.log('new Transaction now')
log(props, tx, receipt, dispatch)
})
@ -184,16 +175,12 @@ export const initListeningOnNetwork = (props, dispatch) => {
if (props._deps.compilersArtefacts.__last) {
compiledContracts = await props._deps.compilersArtefacts.__last.getContracts()
}
console.log({ compiledContracts })
await props.eventsDecoder.parseLogs(tx, resolvedTransaction.contractName, compiledContracts, async (error, logs) => {
if (!error) {
console.log({ tx: tx, receipt: receipt, resolvedData: resolvedTransaction, logs: logs })
console.log('knownTransaction dispatch')
await dispatch({ type: 'knownTransaction', payload: { message: [{ tx: tx, receipt: receipt, resolvedData: resolvedTransaction, logs: logs }] } })
}
})
} else {
console.log('unknownTransaction')
// contract unknown - just displaying raw tx.
// logUnknownTX({ tx: tx, receipt: receipt })
await dispatch({ type: 'unknownTransaction', payload: { message: [{ tx: tx, receipt: receipt }] } })
@ -206,8 +193,4 @@ export const initListeningOnNetwork = (props, dispatch) => {
props.thisState.call('menuicons', 'select', 'debugger')
props.thisState.call('debugger', 'debug', hash)
})
props.thisState.on('udapp', 'logHtml', (log) => {
console.log({ log }, ' listen to logHTML call')
})
}

@ -183,7 +183,6 @@ export const registerScriptRunnerReducer = (state, action) => {
journalBlocks: initialState.journalBlocks.push({ message: action.payload.message, style: '', name: 'unknownTransaction' })
}
case 'emptyBlock':
console.log({ action: action.payload.message }, ' emptyBLock reducer')
return {
...state,
journalBlocks: initialState.journalBlocks.push({ message: action.payload.message, style: '', name: 'emptyBlock' })

@ -575,13 +575,13 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
<tr className='tr'>
<td className='td' data-shared={`key_${opts.hash}`}> status </td>
<td className='td' data-id={`txLoggerTableStatus${opts.hash}`} data-shared={`pair_${opts.hash}`}>{`${opts.status} ${msg}`}</td>
</tr>
<tr className='tr'>
</tr>)
{opts.hash && (<tr className='tr'>
<td className='td' data-shared={`key_${opts.hash}`}> transaction hash </td>
<td className='td' data-id={`txLoggerTableHash${opts.hash}`} data-shared={`pair_${opts.hash}`}>{opts.hash}
<CopyToClipboard content={opts.hash}/>
</td>
</tr>
</tr>) }
{
opts.contractAddress && (
<tr className='tr'>
@ -660,7 +660,7 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
)}
{opts['decoded input'] && (
<tr className='tr'>
<td className='td' data-shared={`key_${opts.hash}`}> decode input </td>
<td className='td' data-shared={`key_${opts.hash}`}> decoded input </td>
<td className='td' data-id={`txLoggerTableHash${opts.hash}`} data-shared={`pair_${opts.hash}`}>{opts['decoded input'].trim()}
<CopyToClipboard content={opts['decoded input']}/>
</td>
@ -668,7 +668,7 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
)}
{opts['decoded output'] && (
<tr className='tr'>
<td className='td' data-shared={`key_${opts.hash}`}> decode output </td>
<td className='td' data-shared={`key_${opts.hash}`}> decoded output </td>
<td className='td' data-id={`txLoggerTableHash${opts.hash}`} data-shared={`pair_${opts.hash}`}>{opts['decoded output']}
<CopyToClipboard content={opts['decoded output']}/>
</td>
@ -779,6 +779,48 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
)
}
const renderCall = (tx, resolvedData, logs, index) => {
const to = resolvedData.contractName + '.' + resolvedData.fn
const from = tx.from ? tx.from : ' - '
const input = tx.input ? helper.shortenHexData(tx.input) : ''
const obj = { from, to }
const txType = 'call'
return (
<span id={`tx${tx.hash}`} key={index}>
<div className="log" onClick={(event) => txDetails(event, tx)}>
{checkTxStatus(tx, txType)}
<span className="txLog">
<span className="tx">[call]</span>
<div className='txItem'><span className='txItemTitle'>from:</span> {from}</div>
<div className='txItem'><span className='txItemTitle'>to:</span> {to}</div>
<div className='txItem'><span className='txItemTitle'>data:</span> {input}</div>
</span>
<div className='buttons'>
<div className="debug btn btn-primary btn-sm" onClick={(event) => debug(event, tx)}>Debug</div>
</div>
<i className="arrow fas fa-angle-down"></i>
</div>
{showTableHash.includes(tx.hash) ? showTable({
hash: tx.hash,
isCall: tx.isCall,
contractAddress: tx.contractAddress,
data: tx,
from,
to,
gas: tx.gas,
input: tx.input,
'decoded input': resolvedData && resolvedData.params ? JSON.stringify(typeConversion.stringify(resolvedData.params), null, '\t') : ' - ',
'decoded output': resolvedData && resolvedData.decodedReturnValue ? JSON.stringify(typeConversion.stringify(resolvedData.decodedReturnValue), null, '\t') : ' - ',
val: tx.value,
logs: logs,
transactionCost: tx.transactionCost,
executionCost: tx.executionCost
}) : null}
</span>
)
}
const handleAutoComplete = () => (
<div className='popup alert alert-secondary' style={{ display: autoCompletState.showSuggestions && autoCompletState.userInput !== '' ? 'block' : 'none' }}>
<div>
@ -881,7 +923,8 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
})
} else if (x.name === 'knownTransaction') {
return x.message.map((trans) => {
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>)
console.log({ trans }, ' resolveData')
return (<div className='px-4 block' data-id={`block_tx${trans.tx.hash}`} key={index}> { trans.tx.isCall ? renderCall(trans.tx, trans.resolvedData, trans.logs, index) : renderKnownTransactions(trans.tx, trans.receipt, trans.resolvedData, trans.logs, index)} </div>)
})
} else {
return x.message.map((x, i) => {

Loading…
Cancel
Save