Merge pull request #1975 from ethereum/injected-web3

Fixed Terminal logs for udapp transactions
pull/1977/head^2
David Disu 3 years ago committed by GitHub
commit adbb7a50c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      apps/remix-ide/src/blockchain/blockchain.js
  2. 2
      libs/remix-lib/src/execution/txRunnerWeb3.ts
  3. 2
      libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx
  4. 10
      libs/remix-ui/terminal/src/lib/actions/terminalAction.ts
  5. 7
      libs/remix-ui/terminal/src/lib/components/Context.tsx
  6. 4
      libs/remix-ui/terminal/src/lib/components/RenderKnownTransactions.tsx
  7. 4
      libs/remix-ui/terminal/src/lib/components/RenderUnknownTransactions.tsx
  8. 20
      libs/remix-ui/terminal/src/lib/reducers/terminalReducer.ts
  9. 2
      libs/remix-ui/terminal/src/lib/remix-ui-terminal.tsx

@ -353,7 +353,7 @@ export class Blockchain extends Plugin {
if (network.name === 'VM') return if (network.name === 'VM') return
this.call('terminal', 'logHtml', this.call('terminal', 'logHtml',
(<a href={etherScanLink(network.name, txhash)} target="_blank"> (<a href={etherScanLink(network.name, txhash)} target="_blank">
open in etherscan view on etherscan
</a>)) </a>))
}) })
}) })

@ -153,7 +153,7 @@ async function tryTillReceiptAvailable (txhash, web3) {
async function tryTillTxAvailable (txhash, web3) { async function tryTillTxAvailable (txhash, web3) {
try { try {
const tx = await web3.eth.getTransaction(txhash) const tx = await web3.eth.getTransaction(txhash)
if (tx) return tx if (tx && tx.blockHash) return tx
} catch (e) {} } catch (e) {}
return await tryTillTxAvailable(txhash, web3) return await tryTillTxAvailable(txhash, web3)
} }

@ -237,7 +237,7 @@ export function ContractDropdownUI (props: ContractDropdownProps) {
</div> </div>
<div className="udapp_orLabel mt-2" style={{ display: loadType === 'abi' ? 'none' : 'block' }}>or</div> <div className="udapp_orLabel mt-2" style={{ display: loadType === 'abi' ? 'none' : 'block' }}>or</div>
<div className="udapp_button udapp_atAddressSect"> <div className="udapp_button udapp_atAddressSect">
<button className="udapp_atAddress btn btn-sm btn-info" id="runAndDeployAtAdressButton" disabled={atAddressOptions.disabled} onClick={loadFromAddress}>At Address</button> <button className="udapp_atAddress btn btn-sm btn-info" id="runAndDeployAtAdressButton" disabled={atAddressOptions.disabled} title={atAddressOptions.title} onClick={loadFromAddress}>At Address</button>
<input <input
className="udapp_input udapp_ataddressinput ataddressinput form-control" className="udapp_input udapp_ataddressinput ataddressinput form-control"
placeholder="Load contract from Address" placeholder="Load contract from Address"

@ -111,9 +111,11 @@ export const listenOnNetworkAction = async (plugins, isListening) => {
} }
export const initListeningOnNetwork = (plugins, dispatch: React.Dispatch<any>) => { export const initListeningOnNetwork = (plugins, dispatch: React.Dispatch<any>) => {
const provider = plugins.blockchain.getProvider()
plugins.txListener.event.register(NEW_BLOCK, (block) => { plugins.txListener.event.register(NEW_BLOCK, (block) => {
if (!block.transactions || (block.transactions && !block.transactions.length)) { if (!block.transactions || (block.transactions && !block.transactions.length)) {
dispatch({ type: EMPTY_BLOCK, payload: { message: 0 } }) dispatch({ type: EMPTY_BLOCK, payload: { message: 0, provider } })
} }
}) })
plugins.txListener.event.register(KNOWN_TRANSACTION, () => { plugins.txListener.event.register(KNOWN_TRANSACTION, () => {
@ -128,6 +130,8 @@ export const initListeningOnNetwork = (plugins, dispatch: React.Dispatch<any>) =
const log = async (plugins, tx, receipt, dispatch: React.Dispatch<any>) => { const log = async (plugins, tx, receipt, dispatch: React.Dispatch<any>) => {
const resolvedTransaction = await plugins.txListener.resolvedTransaction(tx.hash) const resolvedTransaction = await plugins.txListener.resolvedTransaction(tx.hash)
const provider = plugins.blockchain.getProvider()
if (resolvedTransaction) { if (resolvedTransaction) {
let compiledContracts = null let compiledContracts = null
if (plugins._deps.compilersArtefacts.__last) { if (plugins._deps.compilersArtefacts.__last) {
@ -135,11 +139,11 @@ export const initListeningOnNetwork = (plugins, dispatch: React.Dispatch<any>) =
} }
await plugins.eventsDecoder.parseLogs(tx, resolvedTransaction.contractName, compiledContracts, async (error, logs) => { await plugins.eventsDecoder.parseLogs(tx, resolvedTransaction.contractName, compiledContracts, async (error, logs) => {
if (!error) { if (!error) {
await dispatch({ type: KNOWN_TRANSACTION, payload: { message: [{ tx: tx, receipt: receipt, resolvedData: resolvedTransaction, logs: logs }] } }) await dispatch({ type: KNOWN_TRANSACTION, payload: { message: [{ tx: tx, receipt: receipt, resolvedData: resolvedTransaction, logs: logs }], provider } })
} }
}) })
} else { } else {
await dispatch({ type: UNKNOWN_TRANSACTION, payload: { message: [{ tx: tx, receipt: receipt }] } }) await dispatch({ type: UNKNOWN_TRANSACTION, payload: { message: [{ tx: tx, receipt: receipt }], provider } })
} }
} }

@ -4,7 +4,7 @@ import helper from 'apps/remix-ide/src/lib/helper'
const remixLib = require('@remix-project/remix-lib') const remixLib = require('@remix-project/remix-lib')
const typeConversion = remixLib.execution.typeConversion const typeConversion = remixLib.execution.typeConversion
const Context = ({ opts, blockchain }) => { const Context = ({ opts, provider }: { opts, provider: string }) => {
const data = opts.tx || '' const data = opts.tx || ''
const from = opts.from ? helper.shortenHexData(opts.from) : '' const from = opts.from ? helper.shortenHexData(opts.from) : ''
let to = opts.to let to = opts.to
@ -16,7 +16,8 @@ const Context = ({ opts, blockchain }) => {
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
if (blockchain.getProvider() === 'vm') {
if (provider === 'vm') {
return ( return (
<div> <div>
<span> <span>
@ -29,7 +30,7 @@ const Context = ({ opts, blockchain }) => {
<div className='remix_ui_terminal_txItem'><span className='remix_ui_terminal_txItemTitle'>hash:</span> {hash}</div> <div className='remix_ui_terminal_txItem'><span className='remix_ui_terminal_txItemTitle'>hash:</span> {hash}</div>
</span> </span>
</div>) </div>)
} else if (blockchain.getProvider() !== 'vm' && data.resolvedData) { } else if (provider !== 'vm' && data.resolvedData) {
return ( return (
<div> <div>
<span> <span>

@ -8,7 +8,7 @@ import showTable from './Table'
const remixLib = require('@remix-project/remix-lib') const remixLib = require('@remix-project/remix-lib')
const typeConversion = remixLib.execution.typeConversion const typeConversion = remixLib.execution.typeConversion
const RenderKnownTransactions = ({ tx, receipt, resolvedData, logs, index, plugin, showTableHash, txDetails, modal }) => { const RenderKnownTransactions = ({ tx, receipt, resolvedData, logs, index, plugin, showTableHash, txDetails, modal, provider }) => {
const debug = (event, tx) => { const debug = (event, tx) => {
event.stopPropagation() event.stopPropagation()
if (tx.isCall && tx.envMode !== 'vm') { if (tx.isCall && tx.envMode !== 'vm') {
@ -26,7 +26,7 @@ const RenderKnownTransactions = ({ tx, receipt, resolvedData, logs, index, plugi
<span id={`tx${tx.hash}`} key={index}> <span id={`tx${tx.hash}`} key={index}>
<div className="remix_ui_terminal_log" onClick={(event) => txDetails(event, tx)}> <div className="remix_ui_terminal_log" onClick={(event) => txDetails(event, tx)}>
<CheckTxStatus tx={receipt} type={txType} /> <CheckTxStatus tx={receipt} type={txType} />
<Context opts = { options } blockchain={plugin.blockchain} /> <Context opts = { options } provider={provider} />
<div className='remix_ui_terminal_buttons'> <div className='remix_ui_terminal_buttons'>
<div <div
className='remix_ui_terminal_debug btn btn-primary btn-sm' className='remix_ui_terminal_debug btn btn-primary btn-sm'

@ -3,7 +3,7 @@ import CheckTxStatus from './ChechTxStatus' // eslint-disable-line
import Context from './Context' // eslint-disable-line import Context from './Context' // eslint-disable-line
import showTable from './Table' import showTable from './Table'
const RenderUnKnownTransactions = ({ tx, receipt, index, plugin, showTableHash, txDetails, modal }) => { const RenderUnKnownTransactions = ({ tx, receipt, index, plugin, showTableHash, txDetails, modal, provider }) => {
const debug = (event, tx) => { const debug = (event, tx) => {
event.stopPropagation() event.stopPropagation()
if (tx.isCall && tx.envMode !== 'vm') { if (tx.isCall && tx.envMode !== 'vm') {
@ -21,7 +21,7 @@ const RenderUnKnownTransactions = ({ tx, receipt, index, plugin, showTableHash,
<span id={`tx${tx.hash}`} key={index}> <span id={`tx${tx.hash}`} key={index}>
<div className="remix_ui_terminal_log" onClick={(event) => txDetails(event, tx)}> <div className="remix_ui_terminal_log" onClick={(event) => txDetails(event, tx)}>
<CheckTxStatus tx={receipt || tx} type={txType} /> <CheckTxStatus tx={receipt || tx} type={txType} />
<Context opts = { options } blockchain={plugin.blockchain} /> <Context opts = { options } provider={provider} />
<div className='remix_ui_terminal_buttons'> <div className='remix_ui_terminal_buttons'>
<div className='remix_ui_terminal_debug btn btn-primary btn-sm' <div className='remix_ui_terminal_debug btn btn-primary btn-sm'
data-shared='txLoggerDebugButton' data-shared='txLoggerDebugButton'

@ -144,52 +144,52 @@ export const registerScriptRunnerReducer = (state, action) => {
case HTML: case HTML:
return { return {
...state, ...state,
journalBlocks: initialState.journalBlocks.push({ message: action.payload.message, style: 'text-log' }) journalBlocks: initialState.journalBlocks.push({ message: action.payload.message, style: 'text-log', provider: action.payload.provider })
} }
case LOG: case LOG:
return { return {
...state, ...state,
journalBlocks: initialState.journalBlocks.push({ message: action.payload.message, style: 'text-info' }) journalBlocks: initialState.journalBlocks.push({ message: action.payload.message, style: 'text-info', provider: action.payload.provider })
} }
case INFO: case INFO:
return { return {
...state, ...state,
journalBlocks: initialState.journalBlocks.push({ message: action.payload.message, style: 'text-info' }) journalBlocks: initialState.journalBlocks.push({ message: action.payload.message, style: 'text-info', provider: action.payload.provider })
} }
case WARN: case WARN:
return { return {
...state, ...state,
journalBlocks: initialState.journalBlocks.push({ message: action.payload.message, style: 'text-warning' }) journalBlocks: initialState.journalBlocks.push({ message: action.payload.message, style: 'text-warning', provider: action.payload.provider })
} }
case ERROR: case ERROR:
return { return {
...state, ...state,
journalBlocks: initialState.journalBlocks.push({ message: action.payload.message, style: 'text-danger' }) journalBlocks: initialState.journalBlocks.push({ message: action.payload.message, style: 'text-danger', provider: action.payload.provider })
} }
case SCRIPT: case SCRIPT:
return { return {
...state, ...state,
journalBlocks: initialState.journalBlocks.push({ message: action.payload.message, style: 'text-log' }) journalBlocks: initialState.journalBlocks.push({ message: action.payload.message, style: 'text-log', provider: action.payload.provider })
} }
case KNOWN_TRANSACTION: case KNOWN_TRANSACTION:
return { return {
...state, ...state,
journalBlocks: initialState.journalBlocks.push({ message: action.payload.message, style: '', name: 'knownTransaction' }) journalBlocks: initialState.journalBlocks.push({ message: action.payload.message, style: '', name: 'knownTransaction', provider: action.payload.provider })
} }
case UNKNOWN_TRANSACTION: case UNKNOWN_TRANSACTION:
return { return {
...state, ...state,
journalBlocks: initialState.journalBlocks.push({ message: action.payload.message, style: '', name: 'unknownTransaction' }) journalBlocks: initialState.journalBlocks.push({ message: action.payload.message, style: '', name: 'unknownTransaction', provider: action.payload.provider })
} }
case EMPTY_BLOCK: case EMPTY_BLOCK:
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', provider: action.payload.provider })
} }
case NEW_TRANSACTION: case NEW_TRANSACTION:
return { return {
...state, ...state,
journalBlocks: initialState.journalBlocks.push({ message: action.payload.message, style: '' }) journalBlocks: initialState.journalBlocks.push({ message: action.payload.message, style: '', provider: action.payload.provider })
} }
} }
} }

@ -500,6 +500,7 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
showTableHash={showTableHash} showTableHash={showTableHash}
txDetails={txDetails} txDetails={txDetails}
modal={modal} modal={modal}
provider={x.provider}
/>} />}
</div> </div>
) )
@ -527,6 +528,7 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
showTableHash = { showTableHash } showTableHash = { showTableHash }
txDetails = { txDetails } txDetails = { txDetails }
modal={modal} modal={modal}
provider={x.provider}
/>) } />) }
</div> </div>
) )

Loading…
Cancel
Save