update to runtabs & udapp

pull/1/head
Rob Stupay 7 years ago
parent 2cb7b97546
commit 50b4131664
  1. 14
      src/app.js
  2. 5
      src/app/tabs/run-tab.js
  3. 25
      src/universal-dapp.js

@ -410,7 +410,19 @@ function run () {
return offsetToLineColumnConverter.offsetToLineColumn(location, file, compiler.lastCompilationResult)
}
}
var staticanalysis = new StaticAnalysis(staticAnalysisAPI, compiler.event)
var udapp = new UniversalDApp({
api: {
logMessage: (msg) => {
self._components.editorpanel.log({ type: 'log', value: msg })
}
},
opt: { removable: false, removable_instances: true }
})
udapp.reset({}, transactionContextAPI)
udapp.event.register('debugRequested', this, function (txResult) {
startdebugging(txResult.transactionHash)
})
// ---------------- Righthand-panel --------------------
var rhpAPI = {

@ -296,13 +296,14 @@ function contractDropdown (appAPI, appEvents, instanceContainer) {
// appAPI.logMessage('transaction added ...')
var contractNames = document.querySelector(`.${css.contractNames.classNames[0]}`)
var contracts = appAPI.getContracts()
var contractName = [contractNames.children[contractNames.selectedIndex].innerHTML]
var contract = appAPI.getContracts()[contractNames.children[contractNames.selectedIndex].innerHTML]
var constructor = txHelper.getConstructorInterface(contract.interface)
var args = createButtonInput.value
txFormat.buildData(contract, contracts, true, constructor, args, appAPI.udapp(), (error, data) => {
if (!error) {
console.log(`${JSON.parse(JSON.stringify(contract.metadata, null, 4))}`)
appAPI.logMessage(`B creation of ${contract} pending`)
appAPI.logMessage(`creation of ${contractName} pending...`)
txExecution.createContract(data, appAPI.udapp(), (error, txResult) => {
if (!error) {
var isVM = executionContext.isVM()

@ -117,7 +117,6 @@ function UniversalDApp (opts = {}) {
personalMode: this.personalMode
})
}
UniversalDApp.prototype.reset = function (contracts, transactionContextAPI) {
this.el.innerHTML = ''
this.contracts = contracts
@ -223,6 +222,8 @@ UniversalDApp.prototype.getBalance = function (address, cb) {
// basically this has to be called for the "atAddress" (line 393) and when a contract creation succeed
// this returns a DOM element
UniversalDApp.prototype.renderInstance = function (contract, address, contractName) {
var self = this
function remove () { $instance.remove() }
var $instance = $(`<div class="instance ${css.instance}"/>`)
var context = executionContext.isVM() ? 'memory' : 'blockchain'
@ -233,7 +234,7 @@ UniversalDApp.prototype.renderInstance = function (contract, address, contractNa
<div class="${css.titleText}"> ${contractName} at ${shortAddress} (${context}) </div>
<i class="fa fa-clipboard ${css.copy}" aria-hidden="true" onclick=${copyToClipboard} title='Copy to clipboard'></i>
</div>`
if (this.removable_instance) {
if (self.removable_instances) {
var close = yo`<div class="${css.udappClose}" onclick=${remove}><i class="${css.closeIcon} fa fa-close" aria-hidden="true"></i></div>`
title.appendChild(close)
}
@ -257,7 +258,8 @@ UniversalDApp.prototype.renderInstance = function (contract, address, contractNa
$instance.append(this.getCallButton({
funABI: fallback,
address: address,
contractAbi: abi
contractAbi: abi,
contractName: contractName
}))
}
@ -269,7 +271,8 @@ UniversalDApp.prototype.renderInstance = function (contract, address, contractNa
$instance.append(this.getCallButton({
funABI: funABI,
address: address,
contractAbi: abi
contractAbi: abi,
contractName: contractName
}))
})
@ -303,15 +306,21 @@ UniversalDApp.prototype.getCallButton = function (args) {
.attr('title', title)
.text(title)
.click(() => {
call()
call(true)
})
function call () {
function call (isUserAction) {
txFormat.buildData(args.contractAbi, self.contracts, false, args.funABI, inputField.val(), self, (error, data) => {
if (!error) {
txExecution.callFunction(args.address, data, args.funABI, self, (error, txResult) => {
if (!error) {
self._api.logMessage('UDApp transaction added ...')
if (isUserAction) {
if (args.funABI.constant) {
self._api.logMessage(`transact to ${args.contractName}.${(args.funABI.name) ? args.funABI.name : '(fallback)'} pending ... `)
} else {
self._api.logMessage(`call to ${args.contractName}.${(args.funABI.name) ? args.funABI.name : '(fallback)'} pending ... `)
}
}
var isVM = executionContext.isVM()
if (isVM) {
var vmError = txExecution.checkVMError(txResult)
@ -348,7 +357,7 @@ UniversalDApp.prototype.getCallButton = function (args) {
if (lookupOnly) {
$contractProperty.addClass('constant')
button.attr('title', (title + ' - call'))
call()
call(false)
}
if (args.funABI.inputs && args.funABI.inputs.length > 0) {

Loading…
Cancel
Save