From cf97d6dd55514ae20b534719e1e75d3ea1ece1a9 Mon Sep 17 00:00:00 2001 From: d11e9 Date: Mon, 28 Sep 2015 18:58:28 +0100 Subject: [PATCH 1/4] organise libs, add readme and npm package.json --- README.md | 15 ++ index.html | 211 +--------------------- mode-solidity.js => libs/mode-solidity.js | 0 web3.min.js => libs/web3.min.js | 0 package.json | 27 +++ stylesheets/browser-solidity.css | 204 +++++++++++++++++++++ 6 files changed, 250 insertions(+), 207 deletions(-) create mode 100644 README.md rename mode-solidity.js => libs/mode-solidity.js (100%) rename web3.min.js => libs/web3.min.js (100%) create mode 100644 package.json create mode 100644 stylesheets/browser-solidity.css diff --git a/README.md b/README.md new file mode 100644 index 0000000000..a83f0a988f --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ + +#Browser-solidity + +Browser solidity is a browser based solidity compiler. To use either visit https://chriseth.github.io/browser-solidity or clone/download this repo and open `index.html` in your browser. + +#Solidity compiler + +To use the solidity compiler via nodejs you can do the following: + + var solc = require('solc'); + var compileJSON = solc.cwrap("compileJSON", "string", ["string", "number"]); + var input = "contract x { function g() {} }"; + var output = JSON.parse(compileJSON(input, 1)); // 1 activates the optimiser + for (var contractName in output.contracts) + console.log(contractName + ': ' + output.contracts[contractName].bytecode); \ No newline at end of file diff --git a/index.html b/index.html index 196038ac3c..d5f2a6cec4 100644 --- a/index.html +++ b/index.html @@ -30,220 +30,17 @@ THE SOFTWARE. Solidity realtime compiler and runtime + - + - - + + diff --git a/mode-solidity.js b/libs/mode-solidity.js similarity index 100% rename from mode-solidity.js rename to libs/mode-solidity.js diff --git a/web3.min.js b/libs/web3.min.js similarity index 100% rename from web3.min.js rename to libs/web3.min.js diff --git a/package.json b/package.json new file mode 100644 index 0000000000..48c8497881 --- /dev/null +++ b/package.json @@ -0,0 +1,27 @@ +{ + "name": "solc", + "version": "0.1.3", + "description": "Solidity compiler", + "main": "soljson-latest.js", + "bin": { + "solc": "soljson-latest.js" + }, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/chriseth/browser-solidity.git" + }, + "keywords": [ + "ethereum", + "solidity", + "compiler" + ], + "author": "chriseth", + "license": "MIT", + "bugs": { + "url": "https://github.com/chriseth/browser-solidity/issues" + }, + "homepage": "https://github.com/chriseth/browser-solidity#readme" +} diff --git a/stylesheets/browser-solidity.css b/stylesheets/browser-solidity.css new file mode 100644 index 0000000000..1d791a52a8 --- /dev/null +++ b/stylesheets/browser-solidity.css @@ -0,0 +1,204 @@ +body { + padding: 0px; + font-size: 12px; + color: #111111; +} +#editor { + position: absolute; + top: 0; + left: 0px; + width: auto; + bottom: 0px; + right: 37em; + +} +#input { + font-size: 15px; + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + min-width: 20vw; +} + +#righthand-panel { + position: absolute; + top: 0; + width: 37em; + max-width: 80vw; + right: 0; + bottom: 0px; + overflow: auto; + border-left: 1px dotted black; + box-sizing: border-box; +} + +#output { + border-top: 1px dotted black; + display: block; +} + +#header { + font-size: 14px; + padding: 1em; + font-size: 12px; +} + +#header h1 { + margin-top: 0; +} + +#header .info { clear: left; } + +#header #solIcon { + float: left; + height: 5em; +} + +.col1 { + width: 30%; + float: left; +} +.col2 { + width: 70%; + float: left; +} + +.row { + overflow: auto; +} +.gethDeployText { + border-color: #bebebe; + height: 2.5em; + width: 100%; + display: block; +} + +.contractInstance { + background-color: #ccc; + margin-bottom: 1em; + padding: 0.6em; +} + +.contractInstance.hide > *:not(.title) { + display: none; +} + + +.contractInstance .contractProperty input, +.contractInstance .contractProperty button { + text-align: left; + padding: 0.3em; + width: 50%; + margin: 0; +} +.contractOutput .contractInstance .contractProperty { + margin-bottom: 0; +} +.contractOutput .contractInstance .contractProperty .output { + padding: 0.4em; + background-color: #333; + color: white; + margin-bottom: 1em; + display: block; +} +.contractInstance .contractProperty .output:empty { display: none; } + +.contractOutput { + border-bottom: 1px dotted black; + padding: 0.6em; + box-sizing: border-box; +} +.contractOutput .contractProperty { + margin-bottom: 0.6em; +} +.contractOutput .contractProperty .output { + display: inline; +} + + +.contractOutput .body { + margin-top: 10px; +} + +.contractOutput.hide { + background-color: #4C4C67; + color: white; +} + +.contractOutput.hide > *:not(.title) { + display: none; +} + +.title { + margin: 0; + cursor: pointer; + font-family: monospace; + font-weight: bold; +} + +.title:before { + content: "\25BC"; + opacity: 0.5; + margin-right: 0.4em; + font-size: 10px; +} + +.hide > .title:before { + content: "\25B6"; +} + +.contractOutput > .title { + border-bottom: #4C4C67; +} + + +.title .size { + font-weight: normal; + float: right; +} + +.solError { + position: absolute; + background-color: rgba(255, 0, 0, 0.2); + z-index:40; +} + +.error { + background-color: rgba(255, 0, 0, 0.5); + border-radius: 0; + word-wrap: break-word; + border: 1px solid #D00909; +} + +#ghostbar { + width: 1px; + background-color: red; + opacity: 0.5; + position: absolute; + cursor: col-resize; + z-index: 9999; + top: 0; + bottom: 0; +} + +#dragbar{ + background-color: transparent; + position: absolute; + width: 5px; + left: 0; + top: 0; + bottom: 0; + cursor: col-resize; + z-index: 999; +} + + +input[readonly] { + padding: .4em; + border: 1px solid #ccc; + box-sizing: border-box; + display: block; + width: 100%; +} From 5f93ea16e856fc529032a0af3ba71cee659333fd Mon Sep 17 00:00:00 2001 From: d11e9 Date: Tue, 29 Sep 2015 10:29:16 +0100 Subject: [PATCH 2/4] Tidy nodejs/npm usage --- README.md | 11 +++++++---- index.js | 10 ++++++++++ package.json | 4 ++-- 3 files changed, 19 insertions(+), 6 deletions(-) create mode 100644 index.js diff --git a/README.md b/README.md index a83f0a988f..14ea9e2ae9 100644 --- a/README.md +++ b/README.md @@ -3,13 +3,16 @@ Browser solidity is a browser based solidity compiler. To use either visit https://chriseth.github.io/browser-solidity or clone/download this repo and open `index.html` in your browser. -#Solidity compiler +#Nodejs usage -To use the solidity compiler via nodejs you can do the following: +To use the solidity compiler via nodejs you can install it via npm + + npm install --save solc + +And then use it like so: var solc = require('solc'); - var compileJSON = solc.cwrap("compileJSON", "string", ["string", "number"]); var input = "contract x { function g() {} }"; - var output = JSON.parse(compileJSON(input, 1)); // 1 activates the optimiser + var output = solc.compile(input, 1); // 1 activates the optimiser for (var contractName in output.contracts) console.log(contractName + ': ' + output.contracts[contractName].bytecode); \ No newline at end of file diff --git a/index.js b/index.js new file mode 100644 index 0000000000..8b516b3bb4 --- /dev/null +++ b/index.js @@ -0,0 +1,10 @@ + +var soljson = require('./bin/soljson-latest.js'); + +compileJSON = soljson.cwrap("compileJSON", "string", ["string", "number"]); + +module.exports = { + compile: function(input, optimise){ + return JSON.parse( compileJSON(input, optimise) ); + } +} \ No newline at end of file diff --git a/package.json b/package.json index 48c8497881..c516420b7a 100644 --- a/package.json +++ b/package.json @@ -2,9 +2,9 @@ "name": "solc", "version": "0.1.3", "description": "Solidity compiler", - "main": "soljson-latest.js", + "main": "index.js", "bin": { - "solc": "soljson-latest.js" + "solc": "bin/soljson-latest.js" }, "scripts": { "test": "echo \"Error: no test specified\" && exit 1" From c28ac8b35c194a6ba149d911fdf468d08158b6ba Mon Sep 17 00:00:00 2001 From: d11e9 Date: Tue, 29 Sep 2015 10:41:01 +0100 Subject: [PATCH 3/4] overload version for npm publishes. --- README.md | 2 +- package.json | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 14ea9e2ae9..e314bb8afe 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ #Browser-solidity -Browser solidity is a browser based solidity compiler. To use either visit https://chriseth.github.io/browser-solidity or clone/download this repo and open `index.html` in your browser. +Browser solidity is a browser based solidity compiler. To use either visit [https://chriseth.github.io/browser-solidity](https://chriseth.github.io/browser-solidity) or clone/download this repo and open `index.html` in your browser. #Nodejs usage diff --git a/package.json b/package.json index c516420b7a..5fa306cb52 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,8 @@ { "name": "solc", - "version": "0.1.3", + "version": "0.1.3-1", "description": "Solidity compiler", "main": "index.js", - "bin": { - "solc": "bin/soljson-latest.js" - }, "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, From 2b031ef2ecf3d062c8a3844addcf8087f3a6745c Mon Sep 17 00:00:00 2001 From: d11e9 Date: Tue, 29 Sep 2015 11:25:34 +0100 Subject: [PATCH 4/4] re-add soljson.js and add version func --- index.js | 3 ++- package.json | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 8b516b3bb4..6589bfd43f 100644 --- a/index.js +++ b/index.js @@ -6,5 +6,6 @@ compileJSON = soljson.cwrap("compileJSON", "string", ["string", "number"]); module.exports = { compile: function(input, optimise){ return JSON.parse( compileJSON(input, optimise) ); - } + }, + version: soljson.cwrap("version", "string", []) } \ No newline at end of file diff --git a/package.json b/package.json index 5fa306cb52..ddfad50340 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "solc", - "version": "0.1.3-1", + "version": "0.1.3-2", "description": "Solidity compiler", "main": "index.js", "scripts": {