Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
8e3677c8
Commit
8e3677c8
authored
Oct 19, 2015
by
d11e9
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow using legacy versions via npm
parent
a9d1cc56
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
17 deletions
+33
-17
README.md
README.md
+9
-0
index.js
index.js
+24
-17
No files found.
README.md
View file @
8e3677c8
...
@@ -29,3 +29,12 @@ Starting from version 0.1.6, multiple files are supported with automatic import
...
@@ -29,3 +29,12 @@ Starting from version 0.1.6, multiple files are supported with automatic import
console.log(contractName + ': ' + output.contracts[contractName].bytecode);
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.
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 );
index.js
View file @
8e3677c8
var
soljson
=
require
(
'./bin/soljson-latest.js'
);
function
setupMethods
(
soljson
){
var
compileJSON
=
soljson
.
cwrap
(
"compileJSON"
,
"string"
,
[
"string"
,
"number"
]);
var
compileJSON
=
soljson
.
cwrap
(
"compileJSON"
,
"string"
,
[
"string"
,
"number"
]);
var
compileJSONMulti
=
var
compileJSONMulti
=
'_compileJSONMulti'
in
soljson
?
'_compileJSONMulti'
in
soljson
?
soljson
.
cwrap
(
"compileJSONMulti"
,
"string"
,
[
"string"
,
"number"
])
:
soljson
.
cwrap
(
"compileJSONMulti"
,
"string"
,
[
"string"
,
"number"
])
:
null
;
null
;
var
compile
=
function
(
input
,
optimise
)
{
var
compile
=
function
(
input
,
optimise
)
{
var
result
=
''
;
var
result
=
''
;
if
(
typeof
(
input
)
!=
typeof
(
''
)
&&
compileJSONMulti
!==
null
)
if
(
typeof
(
input
)
!=
typeof
(
''
)
&&
compileJSONMulti
!==
null
)
result
=
compileJSONMulti
(
JSON
.
stringify
(
input
),
optimise
);
result
=
compileJSONMulti
(
JSON
.
stringify
(
input
),
optimise
);
else
else
result
=
compileJSON
(
input
,
optimise
);
result
=
compileJSON
(
input
,
optimise
);
return
JSON
.
parse
(
result
);
return
JSON
.
parse
(
result
);
}
}
var
version
=
soljson
.
cwrap
(
"version"
,
"string"
,
[]);
module
.
exports
=
{
return
{
compile
:
compile
,
version
:
version
,
version
:
soljson
.
cwrap
(
"version"
,
"string"
,
[])
compile
:
compile
,
useVersion
:
function
(
versionString
){
return
setupMethods
(
require
(
'./bin/soljson-'
+
versionString
+
'.js'
)
);
}
}
}
}
module
.
exports
=
setupMethods
(
require
(
'./bin/soljson-latest.js'
)
);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment