From a9d1cc56bcfa8246ef4f0ef43179f312bc936dff Mon Sep 17 00:00:00 2001 From: d11e9 Date: Mon, 19 Oct 2015 15:49:20 +0100 Subject: [PATCH 1/5] bump npm version for publish --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9a20094e1a..f8794a777a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "solc", - "version": "0.1.6", + "version": "0.1.6-1", "description": "Solidity compiler", "main": "index.js", "scripts": { From 8e3677c83afc3003c80392fb8a3e0e808812da73 Mon Sep 17 00:00:00 2001 From: d11e9 Date: Mon, 19 Oct 2015 17:30:03 +0100 Subject: [PATCH 2/5] allow using legacy versions via npm --- README.md | 9 +++++++++ index.js | 41 ++++++++++++++++++++++++----------------- 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 921f73d5bc..7f45f27c02 100644 --- a/README.md +++ b/README.md @@ -29,3 +29,12 @@ Starting from version 0.1.6, multiple files are supported with automatic import console.log(contractName + ': ' + output.contracts[contractName].bytecode); Note that all input files that are imported have to be supplied, the compiler will not load any additional files on its own. + +###Using a legacy version + +In order to allow compiling contracts using a specific version of solidity, the `solc.setVersion` method is available. + + var solc = require('solc'); + solc.setVersion( 'latest' ); // this is used by default + solc.setVersion( 'v0.1.1-2015-08-04-6ff4cd6' ); + var output = solc.compile( "contract t { function g() {} }", 1 ); diff --git a/index.js b/index.js index 2e3e2552c7..7e2988bb75 100644 --- a/index.js +++ b/index.js @@ -1,23 +1,30 @@ -var soljson = require('./bin/soljson-latest.js'); +function setupMethods (soljson){ -var compileJSON = soljson.cwrap("compileJSON", "string", ["string", "number"]); -var compileJSONMulti = - '_compileJSONMulti' in soljson ? - soljson.cwrap("compileJSONMulti", "string", ["string", "number"]) : - null; + var compileJSON = soljson.cwrap("compileJSON", "string", ["string", "number"]); + var compileJSONMulti = + '_compileJSONMulti' in soljson ? + soljson.cwrap("compileJSONMulti", "string", ["string", "number"]) : + null; -var compile = function(input, optimise) { - var result = ''; - if (typeof(input) != typeof('') && compileJSONMulti !== null) - result = compileJSONMulti(JSON.stringify(input), optimise); - else - result = compileJSON(input, optimise); - return JSON.parse(result); -} + var compile = function(input, optimise) { + var result = ''; + if (typeof(input) != typeof('') && compileJSONMulti !== null) + result = compileJSONMulti(JSON.stringify(input), optimise); + else + result = compileJSON(input, optimise); + return JSON.parse(result); + } + var version = soljson.cwrap("version", "string", []); -module.exports = { - compile: compile, - version: soljson.cwrap("version", "string", []) + return { + version: version, + compile: compile, + useVersion: function( versionString ){ + return setupMethods( require('./bin/soljson-' + versionString + '.js' ) ); + } + } } + +module.exports = setupMethods( require('./bin/soljson-latest.js') ); From 53e225e7be0d259f37b8f77f1a94840bb23478b6 Mon Sep 17 00:00:00 2001 From: d11e9 Date: Mon, 19 Oct 2015 17:38:13 +0100 Subject: [PATCH 3/5] update readme for legacy versions --- README.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7f45f27c02..5965c9de57 100644 --- a/README.md +++ b/README.md @@ -32,9 +32,12 @@ Note that all input files that are imported have to be supplied, the compiler wi ###Using a legacy version -In order to allow compiling contracts using a specific version of solidity, the `solc.setVersion` method is available. +In order to allow compiling contracts using a specific version of solidity, the `solc.useVersion` method is available. this returns a new solc object using the version provided. **Note**: version strings must match the version substring of the files availble in `/bin/soljson-*.js`. See below for an example. var solc = require('solc'); - solc.setVersion( 'latest' ); // this is used by default - solc.setVersion( 'v0.1.1-2015-08-04-6ff4cd6' ); - var output = solc.compile( "contract t { function g() {} }", 1 ); + // by default the latest version is used + // ie: solc.useVersion('latest') + + // getting a legacy version + var solcV011 = solc.useVersion( 'v0.1.1-2015-08-04-6ff4cd6' ); + var output = solcV011.compile( "contract t { function g() {} }", 1 ); From 2274586cb348d25747112745191db86c2cf2c42a Mon Sep 17 00:00:00 2001 From: d11e9 Date: Mon, 19 Oct 2015 17:46:49 +0100 Subject: [PATCH 4/5] bump npm publish version --- index.js | 1 - package.json | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/index.js b/index.js index 7e2988bb75..ed5f2a7d3b 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,3 @@ - function setupMethods (soljson){ var compileJSON = soljson.cwrap("compileJSON", "string", ["string", "number"]); diff --git a/package.json b/package.json index f8794a777a..91aa00e6d9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "solc", - "version": "0.1.6-1", + "version": "0.1.6-2", "description": "Solidity compiler", "main": "index.js", "scripts": { From 65fb2a47f416750d1f4fa0f2e74a4081ff8c5cf5 Mon Sep 17 00:00:00 2001 From: d11e9 Date: Tue, 20 Oct 2015 10:10:47 +0100 Subject: [PATCH 5/5] Fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5965c9de57..68a7c79925 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ Note that all input files that are imported have to be supplied, the compiler wi ###Using a legacy version -In order to allow compiling contracts using a specific version of solidity, the `solc.useVersion` method is available. this returns a new solc object using the version provided. **Note**: version strings must match the version substring of the files availble in `/bin/soljson-*.js`. See below for an example. +In order to allow compiling contracts using a specific version of solidity, the `solc.useVersion` method is available. This returns a new solc object using the version provided. **Note**: version strings must match the version substring of the files availble in `/bin/soljson-*.js`. See below for an example. var solc = require('solc'); // by default the latest version is used