Commit cc36cd2a authored by yann300's avatar yann300 Committed by GitHub

Merge pull request #787 from ethereum/alert_tx_rob_z

Rebased Tx Alerts - Alert tx rob z
parents 135c82d6 537c14aa
...@@ -168,6 +168,7 @@ module.exports = App ...@@ -168,6 +168,7 @@ module.exports = App
function run () { function run () {
var self = this var self = this
// ----------------- UniversalDApp ----------------- // ----------------- UniversalDApp -----------------
var transactionContextAPI = { var transactionContextAPI = {
getAddress: (cb) => { getAddress: (cb) => {
...@@ -413,6 +414,7 @@ function run () { ...@@ -413,6 +414,7 @@ function run () {
var staticanalysis = new StaticAnalysis(staticAnalysisAPI, compiler.event) var staticanalysis = new StaticAnalysis(staticAnalysisAPI, compiler.event)
// ---------------- Righthand-panel -------------------- // ---------------- Righthand-panel --------------------
var rhpAPI = { var rhpAPI = {
config: config, config: config,
setEditorSize (delta) { setEditorSize (delta) {
...@@ -511,7 +513,6 @@ function run () { ...@@ -511,7 +513,6 @@ function run () {
} }
this.statementMarker = editor.addMarker(lineColumnPos, this.source, 'highlightcode') this.statementMarker = editor.addMarker(lineColumnPos, this.source, 'highlightcode')
editor.scrollToLine(lineColumnPos.start.line, true, true, function () {}) editor.scrollToLine(lineColumnPos.start.line, true, true, function () {})
if (lineColumnPos.start.line === lineColumnPos.end.line) { if (lineColumnPos.start.line === lineColumnPos.end.line) {
this.fullLineMarker = editor.addMarker({ this.fullLineMarker = editor.addMarker({
start: { start: {
......
...@@ -295,12 +295,14 @@ function contractDropdown (appAPI, appEvents, instanceContainer) { ...@@ -295,12 +295,14 @@ function contractDropdown (appAPI, appEvents, instanceContainer) {
function createInstance () { function createInstance () {
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 contract = appAPI.getContracts()[contractNames.children[contractNames.selectedIndex].innerHTML] var contractName = contractNames.children[contractNames.selectedIndex].innerHTML
var contract = appAPI.getContracts()[contractName]
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) {
appAPI.logMessage('Transaction added ...') appAPI.logMessage(`creation of ${contractName} 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()
......
...@@ -223,6 +223,8 @@ UniversalDApp.prototype.getBalance = function (address, cb) { ...@@ -223,6 +223,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 +235,7 @@ UniversalDApp.prototype.renderInstance = function (contract, address, contractNa ...@@ -233,7 +235,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 +259,8 @@ UniversalDApp.prototype.renderInstance = function (contract, address, contractNa ...@@ -257,7 +259,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 +272,8 @@ UniversalDApp.prototype.renderInstance = function (contract, address, contractNa ...@@ -269,7 +272,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 +307,21 @@ UniversalDApp.prototype.getCallButton = function (args) { ...@@ -303,15 +307,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) {
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)'}`)
}
}
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 ...')
var isVM = executionContext.isVM() var isVM = executionContext.isVM()
if (isVM) { if (isVM) {
var vmError = txExecution.checkVMError(txResult) var vmError = txExecution.checkVMError(txResult)
...@@ -348,7 +358,7 @@ UniversalDApp.prototype.getCallButton = function (args) { ...@@ -348,7 +358,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) {
......
...@@ -35,7 +35,7 @@ function runTests (browser) { ...@@ -35,7 +35,7 @@ function runTests (browser) {
.waitForElementPresent('#editor-container div[class^="terminal"] span[id="tx0xa178c603400a184ce5fedbcfab392d9b77822f6ffa7facdec693aded214523bc"]') .waitForElementPresent('#editor-container div[class^="terminal"] span[id="tx0xa178c603400a184ce5fedbcfab392d9b77822f6ffa7facdec693aded214523bc"]')
.assert.containsText('#editor-container div[class^="terminal"] span[id="tx0xa178c603400a184ce5fedbcfab392d9b77822f6ffa7facdec693aded214523bc"]', '[vm] from:0xca3...a733c, to:browser/Untitled.sol:TestContract.f() 0x692...77b3a, value:0 wei, data:0x261...21ff0, 0 logs, hash:0xa17...523bc') .assert.containsText('#editor-container div[class^="terminal"] span[id="tx0xa178c603400a184ce5fedbcfab392d9b77822f6ffa7facdec693aded214523bc"]', '[vm] from:0xca3...a733c, to:browser/Untitled.sol:TestContract.f() 0x692...77b3a, value:0 wei, data:0x261...21ff0, 0 logs, hash:0xa17...523bc')
.click('#editor-container div[class^="terminal"] span[id="tx0xa178c603400a184ce5fedbcfab392d9b77822f6ffa7facdec693aded214523bc"] button[class^="details"]') .click('#editor-container div[class^="terminal"] span[id="tx0xa178c603400a184ce5fedbcfab392d9b77822f6ffa7facdec693aded214523bc"] button[class^="details"]')
.assert.containsText('#editor-container div[class^="terminal"] span[id="tx0xa178c603400a184ce5fedbcfab392d9b77822f6ffa7facdec693aded214523bc"] table[class^="txTable"] #decodedoutput', `"uint256": "8"`) .assert.containsText('#editor-container div[class^="terminal"] span[id="tx0xa178c603400a184ce5fedbcfab392d9b77822f6ffa7facdec693aded214523bc"] table[class^="txTable"] #decodedoutput', '"uint256": "8"')
.end() .end()
/* /*
@TODO: need to check now the return value of the function @TODO: need to check now the return value of the function
......
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