From 16a5f489300d543a104c3dc8523f29d19b6cb85f Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 26 Dec 2018 12:30:33 -0500 Subject: [PATCH] pass config object to udapp --- src/app.js | 2 +- src/config.js | 2 ++ src/universal-dapp.js | 10 +++++----- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/app.js b/src/app.js index 598223283f..5ccb6a3676 100644 --- a/src/app.js +++ b/src/app.js @@ -313,7 +313,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org registry.put({api: self._components.compilersArtefacts, name: 'compilersartefacts'}) // ----------------- UniversalDApp ----------------- - var udapp = new UniversalDApp(registry) + var udapp = new UniversalDApp(registry, registry.get('config').api) registry.put({api: udapp, name: 'udapp'}) udapp.event.register('transactionBroadcasted', (txhash, networkName) => { var txLink = executionContext.txDetailsLink(networkName, txhash) diff --git a/src/config.js b/src/config.js index 6a41ebd133..d5095b919b 100644 --- a/src/config.js +++ b/src/config.js @@ -53,6 +53,8 @@ function Config (storage) { return this.unpersistedItems[key] } + // TODO: this only used for *one* property "doNotShowTransactionConfirmationAgain" + // and can be removed once it's refactored away in txRunner this.setUnpersistedProperty = function (key, value) { this.unpersistedItems[key] = value } diff --git a/src/universal-dapp.js b/src/universal-dapp.js index a9c82b0ef5..56073b0072 100644 --- a/src/universal-dapp.js +++ b/src/universal-dapp.js @@ -8,7 +8,7 @@ var txHelper = remixLib.execution.txHelper var EventManager = remixLib.EventManager var executionContext = remixLib.execution.executionContext -function UniversalDApp (globalRegistry) { +function UniversalDApp (globalRegistry, config) { this.event = new EventManager() this._deps = { config: globalRegistry.get('config').api, @@ -42,12 +42,12 @@ UniversalDApp.prototype.resetEnvironment = function () { executionContext.vm().stateManager.cache.flush(function () {}) } this.txRunner = new TxRunner(this.accounts, { - config: this._deps.config, + config: this.config, detectNetwork: (cb) => { executionContext.detectNetwork(cb) }, personalMode: () => { - return this._deps.config.get('settings/personal-mode') + return this.config.get('settings/personal-mode') } }) this.txRunner.event.register('transactionBroadcasted', (txhash) => { @@ -71,7 +71,7 @@ UniversalDApp.prototype.createVMAccount = function (privateKey, balance, cb) { UniversalDApp.prototype.newAccount = function (password, passwordPromptCb, cb) { if (!executionContext.isVM()) { - if (!this._deps.config.get('settings/personal-mode')) { + if (!this.config.get('settings/personal-mode')) { return cb('Not running in personal mode') } passwordPromptCb((passphrase) => { @@ -112,7 +112,7 @@ UniversalDApp.prototype.getAccounts = function (cb) { // Weirdness of web3: listAccounts() is sync, `getListAccounts()` is async // See: https://github.com/ethereum/web3.js/issues/442 if (this._deps.config.get('settings/personal-mode')) { - executionContext.web3().personal.getListAccounts(cb) + return executionContext.web3().personal.getListAccounts(cb) } else { executionContext.web3().eth.getAccounts(cb) }