|
|
|
@ -24,15 +24,18 @@ var confirmDialog = require('./app/execution/confirmDialog') |
|
|
|
|
function UniversalDApp (opts, localRegistry) { |
|
|
|
|
this.event = new EventManager() |
|
|
|
|
var self = this |
|
|
|
|
self.data = {} |
|
|
|
|
self._components = {} |
|
|
|
|
self._components.registry = localRegistry || globalRegistry |
|
|
|
|
self.removable = opts.removable |
|
|
|
|
self.removable_instances = opts.removable_instances |
|
|
|
|
self._deps = { |
|
|
|
|
config: self._components.registry.get('config').api, |
|
|
|
|
compiler: self._components.registry.get('compiler').api, |
|
|
|
|
logCallback: self._components.registry.get('logCallback').api |
|
|
|
|
} |
|
|
|
|
executionContext.event.register('contextChanged', this, function (context) { |
|
|
|
|
self.reset(self.contracts) |
|
|
|
|
self.resetEnvironment() |
|
|
|
|
}) |
|
|
|
|
self._txRunnerAPI = { |
|
|
|
|
config: self._deps.config, |
|
|
|
@ -44,16 +47,15 @@ function UniversalDApp (opts, localRegistry) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
self.txRunner = new TxRunner({}, self._txRunnerAPI) |
|
|
|
|
self.data.contractsDetails = {} |
|
|
|
|
self._deps.compiler.event.register('compilationFinished', (success, data, source) => { |
|
|
|
|
self.data.contractsDetails = success && data ? data.contracts : {} |
|
|
|
|
}) |
|
|
|
|
self.accounts = {} |
|
|
|
|
self.resetEnvironment() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UniversalDApp.prototype.reset = function (contracts, transactionContextAPI) { |
|
|
|
|
this._deps.editorpanel = this._components.registry.get('editorpanel') |
|
|
|
|
if (this._deps.editorpanel) this._deps.editorpanel = this._deps.editorpanel.api |
|
|
|
|
|
|
|
|
|
this.contracts = contracts |
|
|
|
|
if (transactionContextAPI) { |
|
|
|
|
this.transactionContextAPI = transactionContextAPI |
|
|
|
|
} |
|
|
|
|
UniversalDApp.prototype.resetEnvironment = function () { |
|
|
|
|
this.accounts = {} |
|
|
|
|
if (executionContext.isVM()) { |
|
|
|
|
this._addAccount('3cd7232cd6f3fc66a57a6bedc1a8ed6c228fff0a327e169c2bcc5e869ed49511', '0x56BC75E2D63100000') |
|
|
|
@ -68,12 +70,16 @@ UniversalDApp.prototype.reset = function (contracts, transactionContextAPI) { |
|
|
|
|
executionContext.detectNetwork((error, network) => { |
|
|
|
|
if (!error && network) { |
|
|
|
|
var txLink = executionContext.txDetailsLink(network.name, txhash) |
|
|
|
|
if (txLink) this._deps.editorpanel.logHtmlMessage(yo`<a href="${txLink}" target="_blank">${txLink}</a>`) |
|
|
|
|
if (txLink) this._deps.logCallback(yo`<a href="${txLink}" target="_blank">${txLink}</a>`) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UniversalDApp.prototype.resetAPI = function (transactionContextAPI) { |
|
|
|
|
this.transactionContextAPI = transactionContextAPI |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UniversalDApp.prototype.newAccount = function (password, cb) { |
|
|
|
|
if (!executionContext.isVM()) { |
|
|
|
|
if (!this._deps.config.get('settings/personal-mode')) { |
|
|
|
@ -186,7 +192,8 @@ UniversalDApp.prototype.call = function (isUserAction, args, value, lookupOnly, |
|
|
|
|
logMsg = `call to ${args.contractName}.${(args.funABI.name) ? args.funABI.name : '(fallback)'}` |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
txFormat.buildData(args.contractName, args.contractAbi, self.contracts, false, args.funABI, value, (error, data) => { |
|
|
|
|
// contractsDetails is used to resolve libraries
|
|
|
|
|
txFormat.buildData(args.contractName, args.contractAbi, self.data.contractsDetails, false, args.funABI, value, (error, data) => { |
|
|
|
|
if (!error) { |
|
|
|
|
if (isUserAction) { |
|
|
|
|
if (!args.funABI.constant) { |
|
|
|
|