Skip to content
This repository has been archived by the owner on Sep 8, 2022. It is now read-only.

Commit

Permalink
feature: Replaces system-wide solc with solc from npm (#13)
Browse files Browse the repository at this point in the history
Does not recompile template.js as there is an issue discussed in #10
  • Loading branch information
JirkaChadima authored and dpilch committed Apr 6, 2018
1 parent 8f5bb17 commit bb825bf
Show file tree
Hide file tree
Showing 5 changed files with 380 additions and 74 deletions.
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ Generate lightweight markdown documentation for Solidity contracts.

```
npm install -g solmd
```

Requires [solc](http://solidity.readthedocs.io/en/develop/installing-solidity.html) to installed in your path.

```
solmd <src> [--dest <target>]
```

Expand Down
42 changes: 32 additions & 10 deletions lib/compile/solc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,53 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < argument

exports.default = function (src) {
return new Promise(function (resolve) {
var exec = 'solc --combined-json abi,asm,ast,bin,bin-runtime,clone-bin,devdoc,interface,opcodes,srcmap,srcmap-runtime,userdoc ' + src;
var rawRes = _child_process2.default.execSync(exec);
var res = JSON.parse(rawRes);
var sources = {};
sources[src] = {
urls: ['file://' + src]
};
var output = _solc2.default.compileStandardWrapper(JSON.stringify({
language: 'Solidity',
sources: sources,
settings: {
outputSelection: {
'*': {
'*': ['abi', 'asm', 'ast', 'bin', 'bin-runtime', 'clone-bin', 'interface', 'opcodes', 'srcmap', 'srcmap-runtime', 'devdoc', 'userdoc']
}
}
}
}), findImports);
var res = JSON.parse(output);
resolve({
contracts: Object.keys(res.contracts).reduce(function (o, k) {
var file = k.split(':')[0];
var fileFragments = file.split('/');
var contractName = fileFragments[fileFragments.length - 1].split('.sol')[0];
var contract = res.contracts[k];
var contract = res.contracts[k][contractName];
var fileName = process.env.PWD + '/' + k.split(':')[0];
return _extends({}, o, _defineProperty({}, contractName, _extends({}, contract, {
fileName: fileName,
abi: JSON.parse(contract.abi),
devdoc: JSON.parse(contract.devdoc),
userdoc: JSON.parse(contract.userdoc)
abi: contract.abi,
devdoc: contract.devdoc,
userdoc: contract.userdoc
})));
}, {})
});
});
};

var _child_process = require('child_process');
var _fs = require('fs');

var _child_process2 = _interopRequireDefault(_child_process);
var _fs2 = _interopRequireDefault(_fs);

var _solc = require('solc');

var _solc2 = _interopRequireDefault(_solc);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

function findImports(path) {
var output = _fs2.default.readFileSync(path.replace('file://', ''));
return { contents: output.toString() };
}
Loading

0 comments on commit bb825bf

Please sign in to comment.