From 96d6e137a6cc5618e91e2fb2a7bce1f2f28c573c Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Fri, 11 Jan 2019 17:59:22 -0500 Subject: [PATCH] move resetAPI call --- src/app.js | 26 ++++++++++++++++++++++ src/app/tabs/run-tab.js | 25 --------------------- src/app/tabs/runTab/model/dropdownlogic.js | 1 + 3 files changed, 27 insertions(+), 25 deletions(-) diff --git a/src/app.js b/src/app.js index e766ee5de9..3c4239b46b 100644 --- a/src/app.js +++ b/src/app.js @@ -1,5 +1,6 @@ 'use strict' +var $ = require('jquery') var csjs = require('csjs-inject') var yo = require('yo-yo') var async = require('async') @@ -502,6 +503,31 @@ Please make a backup of your contracts and start using http://remix.ethereum.org var txLogger = new TxLogger() // eslint-disable-line txLogger.event.register('debuggingRequested', (hash) => { debug.debugger().debug(hash) }) + let transactionContextAPI = { + getAddress: (cb) => { + cb(null, $('#txorigin').val()) + }, + getValue: (cb) => { + try { + var number = document.querySelector('#value').value + var select = document.getElementById('unit') + var index = select.selectedIndex + var selectedUnit = select.querySelectorAll('option')[index].dataset.unit + var unit = 'ether' // default + if (['ether', 'finney', 'gwei', 'wei'].indexOf(selectedUnit) >= 0) { + unit = selectedUnit + } + cb(null, executionContext.web3().toWei(number, unit)) + } catch (e) { + cb(e) + } + }, + getGasLimit: (cb) => { + cb(null, $('#gasLimit').val()) + } + } + udapp.resetAPI(transactionContextAPI) + var queryParams = new QueryParams() var loadingFromGist = self.loadFromGist(queryParams.get()) diff --git a/src/app/tabs/run-tab.js b/src/app/tabs/run-tab.js index a53a3b88ae..b47df1ba66 100644 --- a/src/app/tabs/run-tab.js +++ b/src/app/tabs/run-tab.js @@ -1,4 +1,3 @@ -var $ = require('jquery') var yo = require('yo-yo') var EventManager = require('../../lib/events') var globalRegistry = require('../../global/registry') @@ -24,30 +23,6 @@ class RunTab { this._view = {} this.registry = globalRegistry - this.transactionContextAPI = { - getAddress: (cb) => { - cb(null, $('#txorigin').val()) - }, - getValue: (cb) => { - try { - var number = document.querySelector('#value').value - var select = document.getElementById('unit') - var index = select.selectedIndex - var selectedUnit = select.querySelectorAll('option')[index].dataset.unit - var unit = 'ether' // default - if (['ether', 'finney', 'gwei', 'wei'].indexOf(selectedUnit) >= 0) { - unit = selectedUnit - } - cb(null, executionContext.web3().toWei(number, unit)) - } catch (e) { - cb(e) - } - }, - getGasLimit: (cb) => { - cb(null, $('#gasLimit').val()) - } - } - udapp.resetAPI(this.transactionContextAPI) self._view.recorderCount = yo`0` self._view.instanceContainer = yo`
` self._view.clearInstanceElement = yo` diff --git a/src/app/tabs/runTab/model/dropdownlogic.js b/src/app/tabs/runTab/model/dropdownlogic.js index f05b5a9ef8..afc8685760 100644 --- a/src/app/tabs/runTab/model/dropdownlogic.js +++ b/src/app/tabs/runTab/model/dropdownlogic.js @@ -27,6 +27,7 @@ class DropdownLogic { }) } + // TODO: can be moved up; the event in contractDropdown will have to refactored a method instead listenToCompilationEvents () { this.pluginManager.event.register('sendCompilationResult', (file, source, languageVersion, data) => { // TODO check whether the tab is configured