From 44559ef06abc3b653e248fadd7295404da65dbfb Mon Sep 17 00:00:00 2001 From: aniket-engg Date: Wed, 11 Aug 2021 19:58:10 +0530 Subject: [PATCH] blockchain as a plugin --- apps/remix-ide/src/app.js | 3 ++- apps/remix-ide/src/blockchain/blockchain.js | 14 +++++++++++++- apps/remix-ide/src/remixAppManager.js | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/apps/remix-ide/src/app.js b/apps/remix-ide/src/app.js index 67ede9b1bd..d6ecdee7e4 100644 --- a/apps/remix-ide/src/app.js +++ b/apps/remix-ide/src/app.js @@ -306,6 +306,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org const contextualListener = new ContextualListener({ editor }) engine.register([ + blockchain, contentImport, themeModule, editor, @@ -481,7 +482,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org await appManager.activatePlugin(['sidePanel']) // activating host plugin separately await appManager.activatePlugin(['home']) await appManager.activatePlugin(['settings']) - await appManager.activatePlugin(['hiddenPanel', 'pluginManager', 'filePanel', 'contextualListener', 'terminal', 'fetchAndCompile', 'contentImport']) + await appManager.activatePlugin(['hiddenPanel', 'pluginManager', 'filePanel', 'contextualListener', 'terminal', 'blockchain', 'fetchAndCompile', 'contentImport']) // Set workspace after initial activation if (Array.isArray(workspace)) { diff --git a/apps/remix-ide/src/blockchain/blockchain.js b/apps/remix-ide/src/blockchain/blockchain.js index 4f5e0ffac7..c310298f54 100644 --- a/apps/remix-ide/src/blockchain/blockchain.js +++ b/apps/remix-ide/src/blockchain/blockchain.js @@ -1,4 +1,5 @@ import Web3 from 'web3' +import { Plugin } from '@remixproject/engine' import { toBuffer, addHexPrefix } from 'ethereumjs-util' import { waterfall } from 'async' import { EventEmitter } from 'events' @@ -9,10 +10,20 @@ import NodeProvider from './providers/node.js' import { execution, EventManager, helpers } from '@remix-project/remix-lib' const { txFormat, txExecution, typeConversion, txListener: Txlistener, TxRunner, TxRunnerWeb3, txHelper } = execution const { txResultHelper: resultToRemixTx } = helpers +const packageJson = require('../../../../package.json') + +const profile = { + name: 'blockchain', + displayName: 'Blockchain', + description: 'Blockchain - Logic', + methods: [], + version: packageJson.version +} -class Blockchain { +class Blockchain extends Plugin { // NOTE: the config object will need to be refactored out in remix-lib constructor (config) { + super(profile) this.event = new EventManager() this.executionContext = new ExecutionContext() @@ -489,6 +500,7 @@ class Blockchain { if (isVM) { const hhlogs = await this.web3().eth.getHHLogsForTx(txResult.transactionHash) console.log('hhLogs--2->', hhlogs) + this.call('terminal', 'log', { type: 'info', value: hhlogs }) execResult = await this.web3().eth.getExecutionResultFromSimulator(txResult.transactionHash) if (execResult) { // if it's not the VM, we don't have return value. We only have the transaction, and it does not contain the return value. diff --git a/apps/remix-ide/src/remixAppManager.js b/apps/remix-ide/src/remixAppManager.js index 45bc5a7421..d58f6403a9 100644 --- a/apps/remix-ide/src/remixAppManager.js +++ b/apps/remix-ide/src/remixAppManager.js @@ -8,7 +8,7 @@ const _paq = window._paq = window._paq || [] const requiredModules = [ // services + layout views + system views 'manager', 'compilerArtefacts', 'compilerMetadata', 'contextualListener', 'editor', 'offsetToLineColumnConverter', 'network', 'theme', - 'fileManager', 'contentImport', 'web3Provider', 'scriptRunner', 'fetchAndCompile', 'mainPanel', 'hiddenPanel', 'sidePanel', 'menuicons', + 'fileManager', 'contentImport', 'blockchain', 'web3Provider', 'scriptRunner', 'fetchAndCompile', 'mainPanel', 'hiddenPanel', 'sidePanel', 'menuicons', 'filePanel', 'terminal', 'settings', 'pluginManager', 'tabs', 'udapp', 'dGitProvider'] const dependentModules = ['git', 'hardhat'] // module which shouldn't be manually activated (e.g git is activated by remixd)