From 92f0a1361439b5eef695c7ae832ad4b1f2b6e95a Mon Sep 17 00:00:00 2001 From: David Disu Date: Wed, 19 Jan 2022 14:12:11 +0100 Subject: [PATCH] Fixed provider bug in terminal transaction log --- .../src/lib/actions/terminalAction.ts | 10 +++++++--- .../terminal/src/lib/components/Context.tsx | 7 ++++--- .../components/RenderKnownTransactions.tsx | 4 ++-- .../components/RenderUnknownTransactions.tsx | 4 ++-- .../src/lib/reducers/terminalReducer.ts | 20 +++++++++---------- .../terminal/src/lib/remix-ui-terminal.tsx | 2 ++ 6 files changed, 27 insertions(+), 20 deletions(-) diff --git a/libs/remix-ui/terminal/src/lib/actions/terminalAction.ts b/libs/remix-ui/terminal/src/lib/actions/terminalAction.ts index d0efd289b5..5ee522018b 100644 --- a/libs/remix-ui/terminal/src/lib/actions/terminalAction.ts +++ b/libs/remix-ui/terminal/src/lib/actions/terminalAction.ts @@ -111,9 +111,11 @@ export const listenOnNetworkAction = async (plugins, isListening) => { } export const initListeningOnNetwork = (plugins, dispatch: React.Dispatch) => { + const provider = plugins.blockchain.getProvider() + plugins.txListener.event.register(NEW_BLOCK, (block) => { 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, () => { @@ -128,6 +130,8 @@ export const initListeningOnNetwork = (plugins, dispatch: React.Dispatch) = const log = async (plugins, tx, receipt, dispatch: React.Dispatch) => { const resolvedTransaction = await plugins.txListener.resolvedTransaction(tx.hash) + const provider = plugins.blockchain.getProvider() + if (resolvedTransaction) { let compiledContracts = null if (plugins._deps.compilersArtefacts.__last) { @@ -135,11 +139,11 @@ export const initListeningOnNetwork = (plugins, dispatch: React.Dispatch) = } await plugins.eventsDecoder.parseLogs(tx, resolvedTransaction.contractName, compiledContracts, async (error, logs) => { 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 { - await dispatch({ type: UNKNOWN_TRANSACTION, payload: { message: [{ tx: tx, receipt: receipt }] } }) + await dispatch({ type: UNKNOWN_TRANSACTION, payload: { message: [{ tx: tx, receipt: receipt }], provider } }) } } diff --git a/libs/remix-ui/terminal/src/lib/components/Context.tsx b/libs/remix-ui/terminal/src/lib/components/Context.tsx index 9e5d09d93c..d5234f9526 100644 --- a/libs/remix-ui/terminal/src/lib/components/Context.tsx +++ b/libs/remix-ui/terminal/src/lib/components/Context.tsx @@ -4,7 +4,7 @@ import helper from 'apps/remix-ide/src/lib/helper' const remixLib = require('@remix-project/remix-lib') const typeConversion = remixLib.execution.typeConversion -const Context = ({ opts, blockchain }) => { +const Context = ({ opts, provider }: { opts, provider: string }) => { const data = opts.tx || '' const from = opts.from ? helper.shortenHexData(opts.from) : '' let to = opts.to @@ -16,7 +16,8 @@ const Context = ({ opts, blockchain }) => { const block = data.receipt ? data.receipt.blockNumber : data.blockNumber || '' const i = data.receipt ? data.transactionIndex : data.transactionIndex const value = val ? typeConversion.toInt(val) : 0 - if (blockchain.getProvider() === 'vm') { + + if (provider === 'vm') { return (
@@ -29,7 +30,7 @@ const Context = ({ opts, blockchain }) => {
hash: {hash}
) - } else if (blockchain.getProvider() !== 'vm' && data.resolvedData) { + } else if (provider !== 'vm' && data.resolvedData) { return (
diff --git a/libs/remix-ui/terminal/src/lib/components/RenderKnownTransactions.tsx b/libs/remix-ui/terminal/src/lib/components/RenderKnownTransactions.tsx index 3682219e06..64d58248bf 100644 --- a/libs/remix-ui/terminal/src/lib/components/RenderKnownTransactions.tsx +++ b/libs/remix-ui/terminal/src/lib/components/RenderKnownTransactions.tsx @@ -8,7 +8,7 @@ import showTable from './Table' const remixLib = require('@remix-project/remix-lib') 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) => { event.stopPropagation() if (tx.isCall && tx.envMode !== 'vm') { @@ -26,7 +26,7 @@ const RenderKnownTransactions = ({ tx, receipt, resolvedData, logs, index, plugi
txDetails(event, tx)}> - +
{ +const RenderUnKnownTransactions = ({ tx, receipt, index, plugin, showTableHash, txDetails, modal, provider }) => { const debug = (event, tx) => { event.stopPropagation() if (tx.isCall && tx.envMode !== 'vm') { @@ -21,7 +21,7 @@ const RenderUnKnownTransactions = ({ tx, receipt, index, plugin, showTableHash,
txDetails(event, tx)}> - +
{ case HTML: return { ...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: return { ...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: return { ...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: return { ...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: return { ...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: return { ...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: return { ...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: return { ...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: return { ...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: return { ...state, - journalBlocks: initialState.journalBlocks.push({ message: action.payload.message, style: '' }) + journalBlocks: initialState.journalBlocks.push({ message: action.payload.message, style: '', provider: action.payload.provider }) } } } diff --git a/libs/remix-ui/terminal/src/lib/remix-ui-terminal.tsx b/libs/remix-ui/terminal/src/lib/remix-ui-terminal.tsx index 1de6922dce..e9a1b95f03 100644 --- a/libs/remix-ui/terminal/src/lib/remix-ui-terminal.tsx +++ b/libs/remix-ui/terminal/src/lib/remix-ui-terminal.tsx @@ -490,6 +490,7 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => { showTableHash={showTableHash} txDetails={txDetails} modal={modal} + provider={x.provider} />}
) @@ -517,6 +518,7 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => { showTableHash = { showTableHash } txDetails = { txDetails } modal={modal} + provider={x.provider} />) }
)