From 5a628416d26d2e89fda4828846ad960154562c77 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 26 Oct 2022 16:32:30 +0200 Subject: [PATCH] fix logging to terminal --- apps/remix-ide/src/app/tabs/compile-and-run.ts | 4 ++-- apps/remix-ide/src/app/tabs/web3-provider.js | 2 +- libs/remix-ui/terminal/src/lib/remix-ui-terminal.tsx | 8 +++++++- libs/remixd/src/services/foundryClient.ts | 4 ++-- libs/remixd/src/services/hardhatClient.ts | 6 ++---- libs/remixd/src/services/truffleClient.ts | 4 ++-- 6 files changed, 16 insertions(+), 12 deletions(-) diff --git a/apps/remix-ide/src/app/tabs/compile-and-run.ts b/apps/remix-ide/src/app/tabs/compile-and-run.ts index e90d9f5844..a8ce143125 100644 --- a/apps/remix-ide/src/app/tabs/compile-and-run.ts +++ b/apps/remix-ide/src/app/tabs/compile-and-run.ts @@ -51,11 +51,11 @@ export class CompileAndRun extends Plugin { } async runScript (fileName, clearAllInstances) { - await this.call('terminal', 'log', `running ${fileName} ...`) + await this.call('terminal', 'log', { value: `running ${fileName} ...`, type: 'info' }) try { const exists = await this.call('fileManager', 'exists', fileName) if (!exists) { - await this.call('terminal', 'log', `${fileName} does not exist.`) + await this.call('terminal', 'log', { value: `${fileName} does not exist.`, type: 'info' } ) return } const content = await this.call('fileManager', 'readFile', fileName) diff --git a/apps/remix-ide/src/app/tabs/web3-provider.js b/apps/remix-ide/src/app/tabs/web3-provider.js index 1a0e10a637..615170a9c9 100644 --- a/apps/remix-ide/src/app/tabs/web3-provider.js +++ b/apps/remix-ide/src/app/tabs/web3-provider.js @@ -32,7 +32,7 @@ export class Web3ProviderModule extends Plugin { if (error) { const errorData = error.data ? error.data : error.message ? error.message : error // See: https://github.com/ethers-io/ethers.js/issues/901 - if (!(typeof errorData === 'string' && errorData.includes("unknown method eth_chainId"))) this.call('terminal', 'log', error.data ? error.data : error.message) + if (!(typeof errorData === 'string' && errorData.includes("unknown method eth_chainId"))) this.call('terminal', 'log', { value: error.data ? error.data : error.message, type: 'error' } ) return reject(errorData) } if (payload.method === 'eth_sendTransaction') { 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 11a3cbd57d..03b7ea99db 100644 --- a/libs/remix-ui/terminal/src/lib/remix-ui-terminal.tsx +++ b/libs/remix-ui/terminal/src/lib/remix-ui-terminal.tsx @@ -87,7 +87,13 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => { }, log: (message) => { - scriptRunnerDispatch({ type: 'log', payload: { message: [message] } }) + if (typeof message === 'string') { + message = { + value: message, + type: 'info' + } + } + scriptRunnerDispatch({ type: message.type ? message.type : 'log', payload: { message: [message.value] } }) } }) }, []) diff --git a/libs/remixd/src/services/foundryClient.ts b/libs/remixd/src/services/foundryClient.ts index 96a90c5080..4591a132c6 100644 --- a/libs/remixd/src/services/foundryClient.ts +++ b/libs/remixd/src/services/foundryClient.ts @@ -83,7 +83,7 @@ export class FoundryClient extends PluginClient { } if (!this.warnlog) { // @ts-ignore - this.call('terminal', 'log', 'receiving compilation result from Foundry') + this.call('terminal', 'log', { type: 'info', value: 'receiving compilation result from Foundry' }) this.warnlog = true } } @@ -167,6 +167,6 @@ export class FoundryClient extends PluginClient { console.log('syncing from Foundry') this.processArtifact() // @ts-ignore - this.call('terminal', 'log', 'synced with Foundry') + this.call('terminal', 'log', { type: 'info', value: 'synced with Foundry'}) } } diff --git a/libs/remixd/src/services/hardhatClient.ts b/libs/remixd/src/services/hardhatClient.ts index c19479766e..a9b944538c 100644 --- a/libs/remixd/src/services/hardhatClient.ts +++ b/libs/remixd/src/services/hardhatClient.ts @@ -105,14 +105,12 @@ export class HardhatClient extends PluginClient { } } if (!this.warnLog) { - // @ts-ignore - this.call('terminal', 'log', 'receiving compilation result from Hardhat') + this.call('terminal', 'log', { value: 'receiving compilation result from Hardhat', type: 'info'} ) this.warnLog = true } if (targetsSynced.length) { console.log(`Processing artifacts for files: ${[...new Set(targetsSynced)].join(', ')}`) - // @ts-ignore - this.call('terminal', 'log', `synced with Hardhat: ${[...new Set(targetsSynced)].join(', ')}`) + this.call('terminal', 'log', { type: 'info', value: `synced with Hardhat: ${[...new Set(targetsSynced)].join(', ')}` }) } } diff --git a/libs/remixd/src/services/truffleClient.ts b/libs/remixd/src/services/truffleClient.ts index 6dfd3b6f66..23ada4c9a9 100644 --- a/libs/remixd/src/services/truffleClient.ts +++ b/libs/remixd/src/services/truffleClient.ts @@ -81,7 +81,7 @@ export class TruffleClient extends PluginClient { } if (!this.warnLog) { // @ts-ignore - this.call('terminal', 'log', 'receiving compilation result from Truffle') + this.call('terminal', 'log', { type: 'info', value: 'receiving compilation result from Truffle' }) this.warnLog = true } } @@ -141,6 +141,6 @@ export class TruffleClient extends PluginClient { console.log('syncing from Truffle') this.processArtifact() // @ts-ignore - this.call('terminal', 'log', 'synced with Truffle') + this.call('terminal', 'log', { type: 'info', value: 'synced with Truffle' }) } }