Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

solc

Package Overview
Dependencies
Maintainers
2
Versions
117
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

solc - npm Package Compare versions

Comparing version 0.5.12 to 0.5.13

14

package.json
{
"name": "solc",
"version": "0.5.12",
"version": "0.5.13",
"description": "Solidity compiler",

@@ -10,8 +10,8 @@ "main": "index.js",

"scripts": {
"lint": "semistandard",
"lint": "node ./node_modules/semistandard/bin/cmd.js",
"prepublish": "node downloadCurrentVersion.js && node verifyVersion.js",
"pretest": "npm run lint",
"test": "tape ./test/index.js",
"coverage": "istanbul cover node_modules/tape/bin/tape ./test/index.js",
"coveralls": "npm run coverage && coveralls <coverage/lcov.info"
"coverage": "node ./node_modules/istanbul/lib/cli.js cover ./node_modules/tape/bin/tape ./test/index.js",
"coveralls": "npm run coverage && node ./node_modules/coveralls/bin/coveralls.js <coverage/lcov.info"
},

@@ -46,9 +46,9 @@ "repository": {

"command-exists": "^1.2.8",
"commander": "3.0.2",
"fs-extra": "^0.30.0",
"js-sha3": "0.8.0",
"memorystream": "^0.3.1",
"require-from-string": "^2.0.0",
"semver": "^5.5.0",
"js-sha3": "0.8.0",
"tmp": "0.0.33",
"yargs": "^13.2.0"
"tmp": "0.0.33"
},

@@ -55,0 +55,0 @@ "devDependencies": {

@@ -6,2 +6,3 @@ [![Build Status](https://img.shields.io/travis/ethereum/solc-js.svg?branch=master&style=flat-square)](https://travis-ci.org/ethereum/solc-js)

# solc-js
JavaScript bindings for the [Solidity compiler](https://github.com/ethereum/solidity).

@@ -39,5 +40,6 @@

There are two ways to use `solc`:
1) Through a high-level API giving a uniform interface to all compiler versions
2) Through a low-level API giving access to all the compiler interfaces, which depend on the version of the compiler
1. Through a high-level API giving a uniform interface to all compiler versions
2. Through a low-level API giving access to all the compiler interfaces, which depend on the version of the compiler
#### High-level API

@@ -53,3 +55,3 @@

*Note*: as an intermittent backwards compatibility feature, between versions 0.5.0 and 0.5.2, `compileStandard` and `compileStandardWrapper` also exists and behave like `compile` does.
_Note_: as an intermittent backwards compatibility feature, between versions 0.5.0 and 0.5.2, `compileStandard` and `compileStandardWrapper` also exists and behave like `compile` does.

@@ -59,26 +61,31 @@ #### Example usage without the import callback

Example:
```javascript
var solc = require('solc')
var solc = require('solc');
var input = {
language: 'Solidity',
sources: {
'test.sol': {
content: 'contract C { function f() public { } }'
}
},
settings: {
outputSelection: {
'*': {
'*': [ '*' ]
}
}
}
}
language: 'Solidity',
sources: {
'test.sol': {
content: 'contract C { function f() public { } }'
}
},
settings: {
outputSelection: {
'*': {
'*': ['*']
}
}
}
};
var output = JSON.parse(solc.compile(JSON.stringify(input)))
var output = JSON.parse(solc.compile(JSON.stringify(input)));
// `output` here contains the JSON output as specified in the documentation
for (var contractName in output.contracts['test.sol']) {
console.log(contractName + ': ' + output.contracts['test.sol'][contractName].evm.bytecode.object)
console.log(
contractName +
': ' +
output.contracts['test.sol'][contractName].evm.bytecode.object
);
}

@@ -90,36 +97,44 @@ ```

```javascript
var solc = require('solc')
var solc = require('solc');
var input = {
language: 'Solidity',
sources: {
'test.sol': {
content: 'import "lib.sol"; contract C { function f() public { L.f(); } }'
}
},
settings: {
outputSelection: {
'*': {
'*': [ '*' ]
}
}
}
}
language: 'Solidity',
sources: {
'test.sol': {
content: 'import "lib.sol"; contract C { function f() public { L.f(); } }'
}
},
settings: {
outputSelection: {
'*': {
'*': ['*']
}
}
}
};
function findImports (path) {
if (path === 'lib.sol')
return { contents: 'library L { function f() internal returns (uint) { return 7; } }' }
else
return { error: 'File not found' }
function findImports(path) {
if (path === 'lib.sol')
return {
contents:
'library L { function f() internal returns (uint) { return 7; } }'
};
else return { error: 'File not found' };
}
// Current syntax
var output = JSON.parse(solc.compile(JSON.stringify(input), findImports))
var output = JSON.parse(solc.compile(JSON.stringify(input), findImports));
// New syntax (supported from 0.5.12)
var output = JSON.parse(solc.compile(JSON.stringify(input), { import: findImports }))
var output = JSON.parse(
solc.compile(JSON.stringify(input), { import: findImports })
);
// `output` here contains the JSON output as specified in the documentation
for (var contractName in output.contracts['test.sol']) {
console.log(contractName + ': ' + output.contracts['test.sol'][contractName].evm.bytecode.object)
console.log(
contractName +
': ' +
output.contracts['test.sol'][contractName].evm.bytecode.object
);
}

@@ -131,2 +146,3 @@ ```

The low-level API is as follows:
- `solc.lowlevel.compileSingle`: the original entry point, supports only a single file

@@ -148,6 +164,6 @@ - `solc.lowlevel.compileMulti`: this supports multiple files, introduced in 0.1.6

new BrowserWindow({
webPreferences: {
nodeIntegration: false
}
})
webPreferences: {
nodeIntegration: false
}
});
```

@@ -157,3 +173,3 @@

In order to compile contracts using a specific version of Solidity, the `solc.loadRemoteVersion(version, callback)` method is available. This returns a new `solc` object that uses a version of the compiler specified.
In order to compile contracts using a specific version of Solidity, the `solc.loadRemoteVersion(version, callback)` method is available. This returns a new `solc` object that uses a version of the compiler specified.

@@ -168,12 +184,12 @@ You can also load the "binary" manually and use `setupMethods` to create the familiar wrapper functions described above:

```javascript
var solc = require('solc')
var solc = require('solc');
// getting the development snapshot
solc.loadRemoteVersion('latest', function (err, solcSnapshot) {
if (err) {
// An error was encountered, display and quit
} else {
// NOTE: Use `solcSnapshot` here with the same interface `solc` has
}
})
solc.loadRemoteVersion('latest', function(err, solcSnapshot) {
if (err) {
// An error was encountered, display and quit
} else {
// NOTE: Use `solcSnapshot` here with the same interface `solc` has
}
});
```

@@ -190,8 +206,8 @@

```javascript
var linker = require('solc/linker')
var linker = require('solc/linker');
bytecode = linker.linkBytecode(bytecode, { 'MyLibrary': '0x123456...' })
bytecode = linker.linkBytecode(bytecode, { MyLibrary: '0x123456...' });
```
As of Solidity 0.4.11 the compiler supports [standard JSON input and output](https://solidity.readthedocs.io/en/develop/using-the-compiler.html#compiler-input-and-output-json-description) which outputs a *link references* map. This gives a map of library names to offsets in the bytecode to replace the addresses at. It also doesn't have the limitation on library file and contract name lengths.
As of Solidity 0.4.11 the compiler supports [standard JSON input and output](https://solidity.readthedocs.io/en/develop/using-the-compiler.html#compiler-input-and-output-json-description) which outputs a _link references_ map. This gives a map of library names to offsets in the bytecode to replace the addresses at. It also doesn't have the limitation on library file and contract name lengths.

@@ -201,5 +217,5 @@ There is a method available in the `linker` module called `findLinkReferences` which can find such link references in bytecode produced by an older compiler:

```javascript
var linker = require('solc/linker')
var linker = require('solc/linker');
var linkReferences = linker.findLinkReferences(bytecode)
var linkReferences = linker.findLinkReferences(bytecode);
```

@@ -209,12 +225,21 @@

The ABI generated by Solidity versions can differ slightly, due to new features introduced. There is a tool included which aims to translate the ABI generated by an older Solidity version to conform to the latest standard.
The ABI generated by Solidity versions can differ slightly, due to new features introduced. There is a tool included which aims to translate the ABI generated by an older Solidity version to conform to the latest standard.
It can be used as:
```javascript
var abi = require('solc/abi')
var abi = require('solc/abi');
var inputABI = [{"constant":false,"inputs":[],"name":"hello","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function"}]
var outputABI = abi.update('0.3.6', inputABI)
var inputABI = [
{
constant: false,
inputs: [],
name: 'hello',
outputs: [{ name: '', type: 'string' }],
payable: false,
type: 'function'
}
];
var outputABI = abi.update('0.3.6', inputABI);
// Output contains: [{"constant":false,"inputs":[],"name":"hello","outputs":[{"name":"","type":"string"}],"payable":true,"type":"function"},{"type":"fallback","payable":true}]
```

@@ -238,3 +263,6 @@

```html
<script type="text/javascript" src="https://solc-bin.ethereum.org/bin/{{ SOLC VERSION }}.js"></script>
<script
type="text/javascript"
src="https://solc-bin.ethereum.org/bin/{{ SOLC VERSION }}.js"
></script>
```

@@ -247,18 +275,22 @@

```javascript
var wrapper = require('solc/wrapper')
var solc = wrapper(window.Module)
var wrapper = require('solc/wrapper');
var solc = wrapper(window.Module);
```
Or in ES6 syntax:
```javascript
import * as wrapper from 'solc/wrapper'
const solc = wrapper(window.Module)
import * as wrapper from 'solc/wrapper';
const solc = wrapper(window.Module);
```
Alternatively, to iterate the releases, one can load `list.js` from `solc-bin`:
```html
<script type="text/javascript" src="https://solc-bin.ethereum.org/bin/list.js"></script>
<script
type="text/javascript"
src="https://solc-bin.ethereum.org/bin/list.js"
></script>
```
This will result in two global variables, `window.soljsonReleases` listing all releases and `window.soljsonSources` listing all nightly builds and releases.

@@ -6,10 +6,12 @@ var commandExistsSync = require('command-exists').sync;

const timeout = 10000;
var potentialSolvers = [
{
name: 'z3',
params: '-smt2'
params: '-smt2 -t:' + timeout
},
{
name: 'cvc4',
params: '--lang=smt2'
params: '--lang=smt2 --tlimit=' + timeout
}

@@ -16,0 +18,0 @@ ];

@@ -8,2 +8,25 @@ var assert = require('assert');

function setupMethods (soljson) {
var version;
if ('_solidity_version' in soljson) {
version = soljson.cwrap('solidity_version', 'string', []);
} else {
version = soljson.cwrap('version', 'string', []);
}
var versionToSemver = function () {
return translate.versionToSemver(version());
};
var license;
if ('_solidity_license' in soljson) {
license = soljson.cwrap('solidity_license', 'string', []);
} else if ('_license' in soljson) {
license = soljson.cwrap('license', 'string', []);
} else {
// pre 0.4.14
license = function () {
// return undefined
};
}
var copyString = function (str, ptr) {

@@ -113,6 +136,11 @@ var length = soljson.lengthBytesUTF8(str);

if (readCallback !== undefined && typeof readCallback !== 'function') {
return formatFatalError('Invalid import callback supplied');
// Forward compatibility with 0.6.x
if (typeof readCallback === 'object') {
readCallback = readCallback.import;
}
if (readCallback !== undefined) {
assert(typeof readCallback === 'function', 'Invalid callback specified.');
}
try {

@@ -156,3 +184,3 @@ input = JSON.parse(input);

function librariesSupplied (input) {
if (input['settings'] !== null) {
if (input['settings']) {
return input['settings']['libraries'];

@@ -200,25 +228,2 @@ }

var version;
if ('_solidity_version' in soljson) {
version = soljson.cwrap('solidity_version', 'string', []);
} else {
version = soljson.cwrap('version', 'string', []);
}
var versionToSemver = function () {
return translate.versionToSemver(version());
};
var license;
if ('_solidity_license' in soljson) {
license = soljson.cwrap('solidity_license', 'string', []);
} else if ('_license' in soljson) {
license = soljson.cwrap('license', 'string', []);
} else {
// pre 0.4.14
license = function () {
// return undefined
};
}
return {

@@ -225,0 +230,0 @@ version: version,

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc