Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/raineorshine/generate-contract-interface
Generates an abstract contract in Solidity from a given contract.
https://github.com/raineorshine/generate-contract-interface
ethereum solidity
Last synced: about 1 month ago
JSON representation
Generates an abstract contract in Solidity from a given contract.
- Host: GitHub
- URL: https://github.com/raineorshine/generate-contract-interface
- Owner: raineorshine
- License: isc
- Created: 2016-11-20T22:29:58.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2016-12-06T20:57:35.000Z (almost 8 years ago)
- Last Synced: 2024-08-09T01:43:09.168Z (3 months ago)
- Topics: ethereum, solidity
- Language: JavaScript
- Homepage:
- Size: 50.8 KB
- Stars: 19
- Watchers: 2
- Forks: 2
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# generate-contract-interface
[![npm version](https://img.shields.io/npm/v/generate-contract-interface.svg)](https://npmjs.org/package/generate-contract-interface)Generates an abstract contract in Solidity from a given contract.
## Install
```sh
$ npm install --save generate-contract-interface
```## CLI Usage
```js
$ generate-contract-interface < MyContract.sol
```It does support inheritance, although it currently only works if you are doing one contract per file. You may specify a root directory for imports if it is different from the current working directory:
```js
$ generate-contract-interface --importRoot ./contracts < MyContract.sol
```MyContract.sol:
```js
import './B.sol';contract A is B {
function a() {
}
}
```B.sol:
```js
contract B {
function b() {
}
}
```Output:
```
contract IA {
function b();
function a();
}
```## API Usage
```js
const generateInterface = require('generate-contract-interface')const src = `contract MyContract {
function foo(uint a) constant public returns(uint) {
return 0;
}function bar(uint a, uint b) {
}
}`console.log(generateInterface(src))
/* Output:
contract IMyContract {
function foo(uint a) constant public returns(uint);
function bar(uint a, uint b);
}
*/```
## Issues
Before reporting, please makes sure your source is parseable via [solidity-parser](https://github.com/ConsenSys/solidity-parser).
### Contributing Opportunities
The following are known issues and great opportunities to make an open source contribution:
- Does not handle multiple contracts per file.
- Duplicates methods shadowing inherited methods.
- Does not output multiple levels of inheritance properly.## License
ISC © [Raine Revere](https://github.com/raineorshine)