From 57b2963f568c638290f1eb648990ffb5c6fe96ca Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Tue, 31 Dec 2019 10:45:25 -0500 Subject: [PATCH] remove udapp and executionContext from universal dapp ui --- src/app/tabs/runTab/model/blockchain.js | 4 ++++ src/app/udapp/run-tab.js | 2 +- src/app/ui/universal-dapp-ui.js | 13 +++++-------- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/app/tabs/runTab/model/blockchain.js b/src/app/tabs/runTab/model/blockchain.js index 599f9a38b8..3c8f422f53 100644 --- a/src/app/tabs/runTab/model/blockchain.js +++ b/src/app/tabs/runTab/model/blockchain.js @@ -304,6 +304,10 @@ class Blockchain { }) } + context () { + return (this.executionContext.isVM() ? 'memory' : 'blockchain') + } + } module.exports = Blockchain diff --git a/src/app/udapp/run-tab.js b/src/app/udapp/run-tab.js index f9cfc583bc..24171f6ab8 100644 --- a/src/app/udapp/run-tab.js +++ b/src/app/udapp/run-tab.js @@ -49,7 +49,7 @@ export class RunTab extends LibraryPlugin { } onActivationInternal () { - this.udappUI = new UniversalDAppUI(this.blockchain, this.udapp, this.logCallback, this.executionContext) + this.udappUI = new UniversalDAppUI(this.blockchain, this.logCallback) this.udapp.resetAPI({ getAddress: (cb) => { cb(null, $('#txorigin').val()) diff --git a/src/app/ui/universal-dapp-ui.js b/src/app/ui/universal-dapp-ui.js index a3af0c564c..ea892b1e05 100644 --- a/src/app/ui/universal-dapp-ui.js +++ b/src/app/ui/universal-dapp-ui.js @@ -14,12 +14,10 @@ var txFormat = remixLib.execution.txFormat var TreeView = require('./TreeView') var txCallBacks = require('./sendTxCallbacks') -function UniversalDAppUI (blockchain, udapp, logCallback, executionContext) { +function UniversalDAppUI (blockchain, logCallback) { this.blockchain = blockchain - this.udapp = udapp this.logCallback = logCallback this.compilerData = {contractsDetails: {}} - this.executionContext = executionContext } function decodeResponseToTreeView (response, fnabi) { @@ -52,11 +50,10 @@ UniversalDAppUI.prototype.renderInstance = function (contract, address, contract // basically this has to be called for the "atAddress" (line 393) and when a contract creation succeed // this returns a DOM element UniversalDAppUI.prototype.renderInstanceFromABI = function (contractABI, address, contractName) { - var self = this address = (address.slice(0, 2) === '0x' ? '' : '0x') + address.toString('hex') address = ethJSUtil.toChecksumAddress(address) var instance = yo`
` - var context = self.udapp.context() + const context = this.blockchain.context() var shortAddress = helper.shortenAddress(address) var title = yo` @@ -160,8 +157,8 @@ UniversalDAppUI.prototype.renderInstanceFromABI = function (contractABI, address } setLLIError('') - const fallback = self.udapp.getFallbackInterface(contractABI) - const receive = self.udapp.getReceiveInterface(contractABI) + const fallback = this.udapp.getFallbackInterface(contractABI) + const receive = this.udapp.getReceiveInterface(contractABI) const args = { funABI: fallback || receive, address: address, @@ -203,7 +200,7 @@ UniversalDAppUI.prototype.renderInstanceFromABI = function (contractABI, address else if (fallback) args.funABI = fallback if (!args.funABI) return setLLIError(`Please define a 'Fallback' function to send calldata and a either 'Receive' or payable 'Fallback' to send ethers`) - self.runTransaction(false, args, null, calldataInput.value, null) + this.runTransaction(false, args, null, calldataInput.value, null) } contractActionsWrapper.appendChild(lowLevelInteracions)