diff --git a/src/app.js b/src/app.js index b6ccac3a44..b1d68d3e55 100644 --- a/src/app.js +++ b/src/app.js @@ -1,5 +1,4 @@ var $ = require('jquery'); -var UniversalDApp = require('./universal-dapp.js'); var web3 = require('./web3-adapter.js'); var utils = require('./app/utils'); @@ -427,6 +426,7 @@ var run = function() { if (!hidingRHP) compiler.compile(); }); + function getHidingRHP() { return hidingRHP; } // ----------------- editor resize --------------- @@ -442,215 +442,9 @@ var run = function() { // ----------------- compiler output renderer ---------------------- - var detailsOpen = {}; - - var renderError = function(message) { - var type = utils.errortype(message); - var $pre = $("
").text(message);
-		var $error = $('
').prepend($pre); - $('#output').append( $error ); - var err = message.match(/^([^:]*):([0-9]*):(([0-9]*):)? /); - if (err) { - var errFile = err[1]; - var errLine = parseInt(err[2], 10) - 1; - var errCol = err[4] ? parseInt(err[4], 10) : 0; - if (errFile == '' || errFile == editor.getCacheFile()) { - compiler.addAnnotation({ - row: errLine, - column: errCol, - text: message, - type: type - }); - } - $error.click(function(ev){ - if (errFile != '' && errFile != editor.getCacheFile() && editor.getFiles().indexOf(utils.fileKey(errFile)) !== -1) { - // Switch to file - editor.setCacheFile(errFile); - updateFiles(); - //@TODO could show some error icon in files with errors - } - editor.handleErrorClick(errLine, errCol); - }); - $error.find('.close').click(function(ev){ - ev.preventDefault(); - $error.remove(); - return false; - }); - } - }; - - var gethDeploy = function(contractName, jsonInterface, bytecode){ - var code = ""; - var funABI = getConstructorInterface($.parseJSON(jsonInterface)); - - $.each(funABI.inputs, function(i, inp) { - code += "var " + inp.name + " = /* var of type " + inp.type + " here */ ;\n"; - }); - - code += "var " + contractName + "Contract = web3.eth.contract(" + jsonInterface.replace("\n","") + ");" - +"\nvar " + contractName + " = " + contractName + "Contract.new("; - - $.each(funABI.inputs, function(i, inp) { - code += "\n " + inp.name + ","; - }); - - code += "\n {"+ - "\n from: web3.eth.accounts[0], "+ - "\n data: '"+bytecode+"', "+ - "\n gas: 3000000"+ - "\n }, function(e, contract){"+ - "\n console.log(e, contract);"+ - "\n if (typeof contract.address != 'undefined') {"+ - "\n console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash);" + - "\n }" + - "\n })"; - - - return code; - }; - - var combined = function(contractName, jsonInterface, bytecode){ - return JSON.stringify([{name: contractName, interface: jsonInterface, bytecode: bytecode}]); - }; - - var renderContracts = function(data, source) { - var udappContracts = []; - for (var contractName in data.contracts) { - var contract = data.contracts[contractName]; - udappContracts.push({ - name: contractName, - interface: contract['interface'], - bytecode: contract.bytecode - }); - } - var dapp = new UniversalDApp(udappContracts, { - vm: executionContext === 'vm', - removable: false, - getAddress: function(){ return $('#txorigin').val(); }, - getValue: function(){ - var comp = $('#value').val().split(' '); - return web3.toWei(comp[0], comp.slice(1).join(' ')); - }, - removable_instances: true, - renderOutputModifier: function(contractName, $contractOutput) { - var contract = data.contracts[contractName]; - return $contractOutput - .append(textRow('Bytecode', contract.bytecode)) - .append(textRow('Interface', contract['interface'])) - .append(textRow('Web3 deploy', gethDeploy(contractName.toLowerCase(),contract['interface'],contract.bytecode), 'deploy')) - .append(textRow('uDApp', combined(contractName,contract['interface'],contract.bytecode), 'deploy')) - .append(getDetails(contract, source, contractName)); - }}); - var $contractOutput = dapp.render(); - - $txOrigin = $('#txorigin'); - function renderAccounts(err, accounts) { - if (err) - renderError(err.message); - if (accounts && accounts[0]){ - $txOrigin.empty(); - for( var a in accounts) { $txOrigin.append($('