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

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

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

@ -575,13 +575,13 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
<tr className='tr'> <tr className='tr'>
<td className='td' data-shared={`key_${opts.hash}`}> status </td> <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> <td className='td' data-id={`txLoggerTableStatus${opts.hash}`} data-shared={`pair_${opts.hash}`}>{`${opts.status} ${msg}`}</td>
</tr> </tr>)
<tr className='tr'> {opts.hash && (<tr className='tr'>
<td className='td' data-shared={`key_${opts.hash}`}> transaction hash </td> <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} <td className='td' data-id={`txLoggerTableHash${opts.hash}`} data-shared={`pair_${opts.hash}`}>{opts.hash}
<CopyToClipboard content={opts.hash}/> <CopyToClipboard content={opts.hash}/>
</td> </td>
</tr> </tr>) }
{ {
opts.contractAddress && ( opts.contractAddress && (
<tr className='tr'> <tr className='tr'>
@ -660,7 +660,7 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
)} )}
{opts['decoded input'] && ( {opts['decoded input'] && (
<tr className='tr'> <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()} <td className='td' data-id={`txLoggerTableHash${opts.hash}`} data-shared={`pair_${opts.hash}`}>{opts['decoded input'].trim()}
<CopyToClipboard content={opts['decoded input']}/> <CopyToClipboard content={opts['decoded input']}/>
</td> </td>
@ -668,7 +668,7 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
)} )}
{opts['decoded output'] && ( {opts['decoded output'] && (
<tr className='tr'> <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']} <td className='td' data-id={`txLoggerTableHash${opts.hash}`} data-shared={`pair_${opts.hash}`}>{opts['decoded output']}
<CopyToClipboard content={opts['decoded output']}/> <CopyToClipboard content={opts['decoded output']}/>
</td> </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 = () => ( const handleAutoComplete = () => (
<div className='popup alert alert-secondary' style={{ display: autoCompletState.showSuggestions && autoCompletState.userInput !== '' ? 'block' : 'none' }}> <div className='popup alert alert-secondary' style={{ display: autoCompletState.showSuggestions && autoCompletState.userInput !== '' ? 'block' : 'none' }}>
<div> <div>
@ -881,7 +923,8 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
}) })
} else if (x.name === 'knownTransaction') { } else if (x.name === 'knownTransaction') {
return x.message.map((trans) => { 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 { } else {
return x.message.map((x, i) => { return x.message.map((x, i) => {

Loading…
Cancel
Save