Commit 50b41316 authored by Rob Stupay's avatar Rob Stupay

update to runtabs & udapp

parent 2cb7b975
...@@ -410,7 +410,19 @@ function run () { ...@@ -410,7 +410,19 @@ function run () {
return offsetToLineColumnConverter.offsetToLineColumn(location, file, compiler.lastCompilationResult) 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 -------------------- // ---------------- Righthand-panel --------------------
var rhpAPI = { var rhpAPI = {
......
...@@ -296,13 +296,14 @@ function contractDropdown (appAPI, appEvents, instanceContainer) { ...@@ -296,13 +296,14 @@ function contractDropdown (appAPI, appEvents, instanceContainer) {
// appAPI.logMessage('transaction added ...') // appAPI.logMessage('transaction added ...')
var contractNames = document.querySelector(`.${css.contractNames.classNames[0]}`) var contractNames = document.querySelector(`.${css.contractNames.classNames[0]}`)
var contracts = appAPI.getContracts() var contracts = appAPI.getContracts()
var contractName = [contractNames.children[contractNames.selectedIndex].innerHTML]
var contract = appAPI.getContracts()[contractNames.children[contractNames.selectedIndex].innerHTML] var contract = appAPI.getContracts()[contractNames.children[contractNames.selectedIndex].innerHTML]
var constructor = txHelper.getConstructorInterface(contract.interface) var constructor = txHelper.getConstructorInterface(contract.interface)
var args = createButtonInput.value var args = createButtonInput.value
txFormat.buildData(contract, contracts, true, constructor, args, appAPI.udapp(), (error, data) => { txFormat.buildData(contract, contracts, true, constructor, args, appAPI.udapp(), (error, data) => {
if (!error) { if (!error) {
console.log(`${JSON.parse(JSON.stringify(contract.metadata, null, 4))}`) appAPI.logMessage(`creation of ${contractName} pending...`)
appAPI.logMessage(`B creation of ${contract} pending`)
txExecution.createContract(data, appAPI.udapp(), (error, txResult) => { txExecution.createContract(data, appAPI.udapp(), (error, txResult) => {
if (!error) { if (!error) {
var isVM = executionContext.isVM() var isVM = executionContext.isVM()
......
...@@ -117,7 +117,6 @@ function UniversalDApp (opts = {}) { ...@@ -117,7 +117,6 @@ function UniversalDApp (opts = {}) {
personalMode: this.personalMode personalMode: this.personalMode
}) })
} }
UniversalDApp.prototype.reset = function (contracts, transactionContextAPI) { UniversalDApp.prototype.reset = function (contracts, transactionContextAPI) {
this.el.innerHTML = '' this.el.innerHTML = ''
this.contracts = contracts this.contracts = contracts
...@@ -223,6 +222,8 @@ UniversalDApp.prototype.getBalance = function (address, cb) { ...@@ -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 // basically this has to be called for the "atAddress" (line 393) and when a contract creation succeed
// this returns a DOM element // this returns a DOM element
UniversalDApp.prototype.renderInstance = function (contract, address, contractName) { UniversalDApp.prototype.renderInstance = function (contract, address, contractName) {
var self = this
function remove () { $instance.remove() } function remove () { $instance.remove() }
var $instance = $(`<div class="instance ${css.instance}"/>`) var $instance = $(`<div class="instance ${css.instance}"/>`)
var context = executionContext.isVM() ? 'memory' : 'blockchain' var context = executionContext.isVM() ? 'memory' : 'blockchain'
...@@ -233,7 +234,7 @@ UniversalDApp.prototype.renderInstance = function (contract, address, contractNa ...@@ -233,7 +234,7 @@ UniversalDApp.prototype.renderInstance = function (contract, address, contractNa
<div class="${css.titleText}"> ${contractName} at ${shortAddress} (${context}) </div> <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> <i class="fa fa-clipboard ${css.copy}" aria-hidden="true" onclick=${copyToClipboard} title='Copy to clipboard'></i>
</div>` </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>` var close = yo`<div class="${css.udappClose}" onclick=${remove}><i class="${css.closeIcon} fa fa-close" aria-hidden="true"></i></div>`
title.appendChild(close) title.appendChild(close)
} }
...@@ -257,7 +258,8 @@ UniversalDApp.prototype.renderInstance = function (contract, address, contractNa ...@@ -257,7 +258,8 @@ UniversalDApp.prototype.renderInstance = function (contract, address, contractNa
$instance.append(this.getCallButton({ $instance.append(this.getCallButton({
funABI: fallback, funABI: fallback,
address: address, address: address,
contractAbi: abi contractAbi: abi,
contractName: contractName
})) }))
} }
...@@ -269,7 +271,8 @@ UniversalDApp.prototype.renderInstance = function (contract, address, contractNa ...@@ -269,7 +271,8 @@ UniversalDApp.prototype.renderInstance = function (contract, address, contractNa
$instance.append(this.getCallButton({ $instance.append(this.getCallButton({
funABI: funABI, funABI: funABI,
address: address, address: address,
contractAbi: abi contractAbi: abi,
contractName: contractName
})) }))
}) })
...@@ -303,15 +306,21 @@ UniversalDApp.prototype.getCallButton = function (args) { ...@@ -303,15 +306,21 @@ UniversalDApp.prototype.getCallButton = function (args) {
.attr('title', title) .attr('title', title)
.text(title) .text(title)
.click(() => { .click(() => {
call() call(true)
}) })
function call () { function call (isUserAction) {
txFormat.buildData(args.contractAbi, self.contracts, false, args.funABI, inputField.val(), self, (error, data) => { txFormat.buildData(args.contractAbi, self.contracts, false, args.funABI, inputField.val(), self, (error, data) => {
if (!error) { if (!error) {
txExecution.callFunction(args.address, data, args.funABI, self, (error, txResult) => { txExecution.callFunction(args.address, data, args.funABI, self, (error, txResult) => {
if (!error) { 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() var isVM = executionContext.isVM()
if (isVM) { if (isVM) {
var vmError = txExecution.checkVMError(txResult) var vmError = txExecution.checkVMError(txResult)
...@@ -348,7 +357,7 @@ UniversalDApp.prototype.getCallButton = function (args) { ...@@ -348,7 +357,7 @@ UniversalDApp.prototype.getCallButton = function (args) {
if (lookupOnly) { if (lookupOnly) {
$contractProperty.addClass('constant') $contractProperty.addClass('constant')
button.attr('title', (title + ' - call')) button.attr('title', (title + ' - call'))
call() call(false)
} }
if (args.funABI.inputs && args.funABI.inputs.length > 0) { if (args.funABI.inputs && args.funABI.inputs.length > 0) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment