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

solparse

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

solparse - npm Package Compare versions

Comparing version 1.3.1 to 1.3.2

6

package.json
{
"name": "solparse",
"version": "1.3.1",
"version": "1.3.2",
"description": "PEG.js Solidity parser for Javascript",

@@ -37,5 +37,5 @@ "main": "index.js",

"dependencies": {
"mocha": "^2.4.5",
"mocha": "^4.0.1",
"pegjs": "^0.10.0",
"yargs": "^4.6.0"
"yargs": "^10.0.3"
},

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

@@ -1,4 +0,4 @@

Solparse is a fork of Consensys' solidity-parser. Solium is heavily dependant on a parser for operating on the AST and so I needed full control over whichever parse was added as a depandancy to the linter. Hence, the fork which I maintain and have the flexibility to release whenever I need to.
Solparse is a fork of [Consensys' solidity-parser](https://github.com/ConsenSys/solidity-parser). Solium is heavily dependant on a parser for operating on the AST and so I needed full control over whichever parse was added as a depandancy to the linter. Hence, the fork which I maintain and have the flexibility to release whenever I need to.
# Solidity Parser
# Solparse

@@ -15,16 +15,14 @@ A Solidity parser in Javascript. So we can evaluate and alter Solidity code without resorting to cruddy preprocessing.

```
npm install solidity-parser
```
npm install solidity-parser
Then, in your code:
```javascript
var SolidityParser = require("solidity-parser");
```
const SolidityParser = require('solidity-parser');
// Parse Solidity code as a string:
var result = SolidityParser.parse("contract { ... }");
// Parse Solidity code as a string:
const result = SolidityParser.parse('contract { ... }');
// Or, parse a file:
var result = SolidityParser.parseFile("./path/to/file.sol");
// Or, parse a file:
const result = SolidityParser.parseFile('./path/to/file.sol');
```

@@ -34,20 +32,15 @@

```javascript
const SolidityParser = require('solidity-parser');
var SolidityParser = require("solidity-parser");
const result = SolidityParser.parseFile('./path/to/file.sol', 'imports');
var result = SolidityParser.parseFile("./path/to/file.sol", "imports");
console.log(result);
// [
// 'SomeFile.sol',
// 'AnotherFile.sol'
// ]
console.log(result);
// [
// "SomeFile.sol",
// "AnotherFile.sol"
// ]
```
**Command Line** (for convenience)
```
$ solidity-parser ./path/to/file.js
```
$ solidity-parser ./path/to/file.js

@@ -58,59 +51,55 @@ ### Results

```
import "Foo.sol";
import "Foo.sol";
contract MyContract {
mapping (uint => address) public addresses;
}
```
contract MyContract {
mapping (uint => address) public addresses;
}
You'll receiving the following (or something very similar) as output. Note that the structure of mappings could be made more clear, and this will likely be changed in the future.
```json
{
"type": "Program",
"body": [
{
"type": "ImportStatement",
"value": "Foo.sol"
},
{
"type": "ContractStatement",
"name": "MyContract",
"is": [],
"type": "Program",
"body": [
{
"type": "ExpressionStatement",
"expression": {
"type": "DeclarativeExpression",
"name": "addresses",
"literal": {
"type": "Type",
"literal": {
"type": "MappingExpression",
"from": {
"type": "ImportStatement",
"value": "Foo.sol"
},
{
"type": "ContractStatement",
"name": "MyContract",
"is": [],
"body": [
{
"type": "ExpressionStatement",
"expression": {
"type": "DeclarativeExpression",
"name": "addresses",
"literal": {
"type": "Type",
"literal": "uint",
"literal": {
"type": "MappingExpression",
"from": {
"type": "Type",
"literal": "uint",
"members": [],
"array_parts": []
},
"to": {
"type": "Type",
"literal": "address",
"members": [],
"array_parts": []
}
},
"members": [],
"array_parts": []
},
"to": {
"type": "Type",
"literal": "address",
"members": [],
"array_parts": []
}
},
"members": [],
"array_parts": []
},
"is_constant": false,
"is_public": true
}
"is_constant": false,
"is_public": true
}
}
]
}
]
}
]
}
```

@@ -121,5 +110,3 @@ ### Test

```
$ npm test
```
$ npm test

@@ -126,0 +113,0 @@ ### License

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