diff --git a/index.html b/index.html index 061dbf9320..7af1a53f2b 100644 --- a/index.html +++ b/index.html @@ -56,9 +56,19 @@ body { width: 18ex; display: inline-block; } +strong.col1 { + top: -10px; + position: relative; + margin-bottom: 5px; +} .col2 { width: 60ex; } +textarea.col2 { + height: 20px; + border-color: #bebebe; + margin-bottom: 5px; +} .runButton { width: 30ex; text-align: left; @@ -199,6 +209,36 @@ var detailsOpen = {}; var renderError = function(message) { $('#output').empty().append($('
').text(message)); }; + +var gethDeploy = function(contractName, interface, bytecode){ + var code = ""; + var funABI = getConstructorInterface($.parseJSON(interface)); + + $.each(funABI.inputs, function(i, inp) { + code += "var "+inp.name+" = /* var of type " + inp.type + " here */ ;\n"; + }); + + code += "\nvar "+contractName+"Contract = web3.eth.contract("+interface.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: 1000000"+ + "\n }, function(e, contract){"+ + "\n if (typeof contract.address != 'undefined') {"+ + "\n console.log(e, contract);"+ + "\n console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash);" + + "\n }})"; + + + return code; +} + var renderContracts = function(data, source) { $('#output').empty(); for (var contractName in data.contracts) { @@ -209,7 +249,7 @@ var renderContracts = function(data, source) { .append($('').text((contract.bytecode.length / 2) + ' bytes')) .append(tableRow('Bytecode', contract.bytecode)) .append(tableRow('Interface', contract['interface'])) - .append(tableRow('Solidity Interface', contract.solidity_interface)) + .append(textRow('Geth deploy', gethDeploy(contractName.toLowerCase(),contract['interface'],contract.bytecode))) .append(getDetails(contract, source, contractName)); $('#output').append(contractOutput); } @@ -219,9 +259,15 @@ var tableRow = function(description, data) { .append($('').text(description)) .append($('').val(data)); }; +var textRow = function(description, data) { + return $('') + .append($('').text(description)) + .append($('")); +}; var getDetails = function(contract, source, contractName) { var button = $(''); var details = $('') + .append(tableRow('Solidity Interface', contract.solidity_interface)) .append(tableRow('Opcodes', contract.opcodes)); var funHashes = ''; for (var fun in contract.functionHashes) diff --git a/stylesheets/styles.css b/stylesheets/styles.css index 5bf9a19629..7fdd9a6e82 100644 --- a/stylesheets/styles.css +++ b/stylesheets/styles.css @@ -1,4 +1,4 @@ -@import url(https://fonts.googleapis.com/css?family=Lato:300italic,700italic,300,700); +/*@import url(https://fonts.googleapis.com/css?family=Lato:300italic,700italic,300,700);*/ body { padding:50px;