pass config object to udapp

pull/1/head
Iuri Matias 6 years ago committed by yann300
parent e2fa3aebc6
commit 16a5f48930
  1. 2
      src/app.js
  2. 2
      src/config.js
  3. 10
      src/universal-dapp.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)

@ -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
}

@ -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)
}

Loading…
Cancel
Save