This repository has been archived by the owner on Sep 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v0.1.3
- Loading branch information
Showing
28 changed files
with
755 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
*~ | ||
node_modules | ||
lib | ||
contracts | ||
.solmd | ||
sol.md | ||
test/output.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1 @@ | ||
*~ | ||
src | ||
contracts | ||
.solmd | ||
sol.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
language: node_js | ||
node_js: | ||
- '4' | ||
cache: | ||
directories: | ||
- node_modules | ||
before_script: | ||
- "sudo add-apt-repository ppa:ethereum/ethereum -y" | ||
- "sudo apt-get update -y" | ||
- "sudo apt-get install solc -y" | ||
|
||
deploy: | ||
provider: npm | ||
email: [email protected] | ||
api_key: | ||
secure: QBcfNa5MXhPTGv9pnqpcex4jD0mb5UtLUrXyDLNU1cKLEU6nQ+XDqoHrrplGWCbMbc+LjTLOX7z9vzwaeSJxGDno6CmNvMo358uiwWv9Kh+CV4521/VOJuzNXs7xGsVuMOJdFvOtp0oY0+R1T27ddW9mxEeGadAjfUOLYiopA3eyYHk38b6sKUyL2fn4Pq277P4F5EXzHNzYZxnzNGlhafxrTgB1dVRxjS/Gt7OD7SL7eqzTyr20GRH4LSxFzkERDlVUxA/W07NftnsbYaY8SNdg5YsrZxZPaPFD1XtZgCF1IN8+248VytcQnriQMgQ2vKua0XM2UfGp5sci6CEZkIWtu4n9GnpjNS9EOYOKAuHbqJTXbkV1vHKWzZJPpF5KtjJU1h1sGzmcA5ax+Wze3YI8+9tNZ16NDATGw+iXKEAhpLR6+66O/OSum4Ez9GFcLDtHAL7wttkVdHZrpsOL5qGkGodcmh8qKrKqHNKAHkfnIeaROIPv+ZAyVVh3DXw9lrqZOMfq1hL3ahrdHfQipOUZlzWUZFBxiTdCUdnuiNL7NTfRdnCWNH//PfyTVGqbbxqC2ru40FwWNM7bzBVrVWu1QbexKvGBfjhJHXlDW9MO/KEuiInCFsDJKga3lbjDwxSSaHWnlKqPfnHqoGV4Z1moomPPakc5tQtz8nnA1OE= | ||
on: | ||
tags: true | ||
branch: master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env node | ||
'use strict'; | ||
|
||
var _fs = require('fs'); | ||
|
||
var _fs2 = _interopRequireDefault(_fs); | ||
|
||
var _path = require('path'); | ||
|
||
var _path2 = _interopRequireDefault(_path); | ||
|
||
var _minimist = require('minimist'); | ||
|
||
var _minimist2 = _interopRequireDefault(_minimist); | ||
|
||
var _index = require('../index'); | ||
|
||
var Solmd = _interopRequireWildcard(_index); | ||
|
||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
|
||
var args = (0, _minimist2.default)(process.argv.slice(2)); | ||
|
||
if (typeof args.help !== 'undefined') { | ||
var _JSON$parse = JSON.parse(_fs2.default.readFileSync(_path2.default.join(__dirname, '../../package.json')).toString()), | ||
version = _JSON$parse.version; | ||
|
||
process.stdout.write('solmd v' + version + '\n\nusage: solmd [--src <solidity>] [--dest <target>]\n\nparameters:\n\n--src Folder that contains the contracts you want to compile\n--dest Destination of markdown output\n--no-toc Do not generate table of contents, defaults false\n\n '); | ||
process.exit(); | ||
} else { | ||
Solmd.default.build(args).catch(function (err) { | ||
console.error(err); // eslint-disable-line no-console | ||
process.exit(1); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
'use strict'; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
|
||
exports.default = function (args) { | ||
return (0, _compile2.default)(args).then(function (data) { | ||
return (0, _markdown2.default)({ args: args, data: data }); | ||
}).catch(function (err) { | ||
console.error(err); // eslint-disable-line no-console | ||
process.exit(1); | ||
}); | ||
}; | ||
|
||
var _compile = require('./compile'); | ||
|
||
var _compile2 = _interopRequireDefault(_compile); | ||
|
||
var _markdown = require('./markdown'); | ||
|
||
var _markdown2 = _interopRequireDefault(_markdown); | ||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
'use strict'; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
|
||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
|
||
exports.default = function (opts) { | ||
opts._.split(' ').forEach(function (file) { | ||
if (!_fs2.default.existsSync(file)) { | ||
process.stderr.write(file + ': No such file or directory\n'); | ||
process.exit(1); | ||
} | ||
}); | ||
return (0, _solc2.default)(opts._).then(function (_ref2) { | ||
var contracts = _ref2.contracts; | ||
return compile(_extends({}, opts, { contracts: contracts })); | ||
}).catch(function () { | ||
console.error('solmd: Failed to compile contracts at ' + opts._); // eslint-disable-line no-console | ||
process.exit(1); | ||
}); | ||
}; | ||
|
||
var _fs = require('fs'); | ||
|
||
var _fs2 = _interopRequireDefault(_fs); | ||
|
||
var _parseAbi = require('./parse-abi'); | ||
|
||
var _parseAbi2 = _interopRequireDefault(_parseAbi); | ||
|
||
var _solc = require('./solc'); | ||
|
||
var _solc2 = _interopRequireDefault(_solc); | ||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
|
||
function compile(_ref) { | ||
var contracts = _ref.contracts; | ||
|
||
var data = []; | ||
Object.keys(contracts).forEach(function (contractName) { | ||
var contract = contracts[contractName]; | ||
var fileName = contract.fileName; | ||
var devdoc = contract.devdoc; | ||
var author = devdoc.author, | ||
title = devdoc.title; | ||
|
||
data.push({ | ||
author: author, | ||
title: title, | ||
fileName: fileName.replace(process.env.PWD, ''), | ||
name: contractName, | ||
abiDocs: (0, _parseAbi2.default)(contract) | ||
}); | ||
}); | ||
|
||
return data; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
'use strict'; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
|
||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
|
||
exports.default = function (contract) { | ||
return contract.abi.map(function (method) { | ||
var inputParams = method.inputs || []; | ||
var signature = method.name && method.name + '(' + inputParams.map(function (i) { | ||
return i.type; | ||
}).join(',') + ')'; | ||
var devDocs = (contract.devdoc.methods || {})[signature] || {}; | ||
var userDocs = (contract.userdoc.methods || {})[signature] || {}; | ||
// map abi inputs to devdoc inputs | ||
var params = devDocs.params || {}; | ||
var inputs = inputParams.map(function (param) { | ||
return _extends({}, param, { description: params[param.name] }); | ||
}); | ||
var argumentList = inputParams.reduce(function (inputString, param) { | ||
return '' + inputString + param.name + ', '; | ||
}, '').slice(0, -2); | ||
// don't write this | ||
delete devDocs.params; | ||
|
||
var outputs = void 0; | ||
try { | ||
var outputParams = JSON.parse(devDocs.return); | ||
outputs = method.outputs.map(function (param) { | ||
return _extends({}, param, { description: outputParams[param.name] }); | ||
}); | ||
} catch (e) { | ||
process.stderr.write('warning: invalid @return for ' + method.name + ' - output may be effected\n'); | ||
outputs = method.outputs; | ||
} | ||
|
||
return _extends({}, method, devDocs, userDocs, { | ||
inputs: inputs, | ||
argumentList: argumentList, | ||
outputs: outputs, | ||
signature: signature, | ||
signatureHash: signature && (0, _helpers.getFunctionSignature)(signature) | ||
}); | ||
}); | ||
}; | ||
|
||
var _helpers = require('../helpers'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
'use strict'; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
|
||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
|
||
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); | ||
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 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) | ||
}))); | ||
}, {}) | ||
}); | ||
}); | ||
}; | ||
|
||
var _child_process = require('child_process'); | ||
|
||
var _child_process2 = _interopRequireDefault(_child_process); | ||
|
||
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; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
'use strict'; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var DEFAULT_DEST = exports.DEFAULT_DEST = 'sol.md'; | ||
var DEFAULT_NO_TOC = exports.DEFAULT_NO_TOC = false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
'use strict'; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.clearDirectory = clearDirectory; | ||
exports.getFunctionSignature = getFunctionSignature; | ||
|
||
var _rimraf = require('rimraf'); | ||
|
||
var _rimraf2 = _interopRequireDefault(_rimraf); | ||
|
||
var _mkdirp = require('mkdirp'); | ||
|
||
var _mkdirp2 = _interopRequireDefault(_mkdirp); | ||
|
||
var _keccakjs = require('keccakjs'); | ||
|
||
var _keccakjs2 = _interopRequireDefault(_keccakjs); | ||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
|
||
function clearDirectory(target) { | ||
return new Promise(function (resolve, reject) { | ||
(0, _mkdirp2.default)(target, function () { | ||
(0, _rimraf2.default)(target, function (err) { | ||
if (err) { | ||
return reject(err); | ||
} | ||
return resolve(); | ||
}); | ||
}); | ||
}); | ||
} | ||
|
||
function getFunctionSignature(signature) { | ||
return new _keccakjs2.default(256).update(signature).digest('hex').substr(0, 8); | ||
} |
Oops, something went wrong.