From 207700fad4c28c827183288adf4874dd84c4fab3 Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 29 Mar 2018 12:37:03 +0200 Subject: [PATCH] remove getContract && getContracts --- src/app.js | 6 ------ src/app/tabs/run-tab.js | 18 +++++++++--------- src/recorder.js | 4 ++-- 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/src/app.js b/src/app.js index 5a78b77e16..180dcdbde3 100644 --- a/src/app.js +++ b/src/app.js @@ -713,12 +713,6 @@ Please make a backup of your contracts and start using http://remix.ethereum.org currentFile: () => { return config.get('currentFile') }, - getContracts: () => { - return compiler.getContracts() - }, - getContract: (name) => { - return compiler.getContract(name) - }, visitContracts: (cb) => { compiler.visitContracts(cb) }, diff --git a/src/app/tabs/run-tab.js b/src/app/tabs/run-tab.js index cae541f6d1..8eaacafa8f 100644 --- a/src/app/tabs/run-tab.js +++ b/src/app/tabs/run-tab.js @@ -30,7 +30,7 @@ function runTab (appAPI = {}, appEvents = {}, opts = {}) { clearInstanceElement.addEventListener('click', () => { event.trigger('clearInstance', []) }) - var recorderInterface = makeRecorder(event, appAPI, appEvents) + var recorderInterface = makeRecorder(event, appAPI, appEvents, opts) var pendingTxsContainer = yo`
@@ -46,7 +46,7 @@ function runTab (appAPI = {}, appEvents = {}, opts = {}) { var el = yo`
${settings(container, appAPI, appEvents, opts)} - ${contractDropdown(event, appAPI, appEvents, instanceContainer)} + ${contractDropdown(event, appAPI, appEvents, opts, instanceContainer)} ${pendingTxsContainer} ${instanceContainer}
@@ -134,8 +134,8 @@ function updateAccountBalances (container, appAPI) { /* ------------------------------------------------ RECORDER ------------------------------------------------ */ -function makeRecorder (events, appAPI, appEvents) { - var recorder = new Recorder({ +function makeRecorder (events, appAPI, appEvents, opts) { + var recorder = new Recorder(opts.compiler, { events: { udapp: appEvents.udapp, executioncontext: executionContext.event, @@ -206,7 +206,7 @@ function makeRecorder (events, appAPI, appEvents) { section CONTRACT DROPDOWN and BUTTONS ------------------------------------------------ */ -function contractDropdown (events, appAPI, appEvents, instanceContainer) { +function contractDropdown (events, appAPI, appEvents, opts, instanceContainer) { instanceContainer.appendChild(noInstancesText) var compFails = yo`` appEvents.compiler.register('compilationFinished', function (success, data, source) { @@ -229,7 +229,7 @@ function contractDropdown (events, appAPI, appEvents, instanceContainer) { if (contractName) { return { name: contractName, - contract: appAPI.getContract(contractName) + contract: opts.compiler.getContract(contractName) } } return null @@ -256,7 +256,7 @@ function contractDropdown (events, appAPI, appEvents, instanceContainer) { function setInputParamsPlaceHolder () { createButtonInput.value = '' - if (appAPI.getContract && selectContractNames.selectedIndex >= 0 && selectContractNames.children.length > 0) { + if (opts.compiler.getContract && selectContractNames.selectedIndex >= 0 && selectContractNames.children.length > 0) { var ctrabi = txHelper.getConstructorInterface(getSelectedContract().contract.object.abi) if (ctrabi.inputs.length) { createButtonInput.setAttribute('placeholder', txHelper.inputParametersDeclarationToString(ctrabi.inputs)) @@ -281,7 +281,7 @@ function contractDropdown (events, appAPI, appEvents, instanceContainer) { var constructor = txHelper.getConstructorInterface(selectedContract.contract.object.abi) var args = createButtonInput.value - txFormat.buildData(selectedContract.name, selectedContract.contract.object, appAPI.getContracts(), true, constructor, args, (error, data) => { + txFormat.buildData(selectedContract.name, selectedContract.contract.object, opts.compiler.getContracts(), true, constructor, args, (error, data) => { if (!error) { appAPI.logMessage(`creation of ${selectedContract.name} pending...`) appAPI.udapp().createContract(data, (error, txResult) => { @@ -333,7 +333,7 @@ function contractDropdown (events, appAPI, appEvents, instanceContainer) { instanceContainer.appendChild(appAPI.udappUI().renderInstanceFromABI(abi, address, address)) }) } else { - var contract = appAPI.getContract(contractNames.children[contractNames.selectedIndex].innerHTML) + var contract = opts.compiler.getContract(contractNames.children[contractNames.selectedIndex].innerHTML) instanceContainer.appendChild(appAPI.udappUI().renderInstance(contract.object, address, selectContractNames.value)) } } diff --git a/src/recorder.js b/src/recorder.js index 6a6c8a5d40..8ac01464e5 100644 --- a/src/recorder.js +++ b/src/recorder.js @@ -13,7 +13,7 @@ var modal = require('./app/ui/modal-dialog-custom') * */ class Recorder { - constructor (opts = {}) { + constructor (compiler, opts = {}) { var self = this self._api = opts.api self.event = new EventManager() @@ -33,7 +33,7 @@ class Recorder { if (this.data._listen) { var record = { value, parameters: payLoad.funArgs } if (!to) { - var selectedContract = self._api.getContract(payLoad.contractName) + var selectedContract = compiler.getContract(payLoad.contractName) if (selectedContract) { var abi = selectedContract.object.abi var sha3 = ethutil.bufferToHex(ethutil.sha3(abi))