0.1.13 • Published 7 years ago

generate-contract-interface v0.1.13

Weekly downloads
4
License
ISC
Repository
github
Last release
7 years ago

generate-contract-interface

npm version

Generates an abstract contract in Solidity from a given contract.

Install

$ npm install --save generate-contract-interface

CLI Usage

$ 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:

$ generate-contract-interface --importRoot ./contracts < MyContract.sol

MyContract.sol:

import './B.sol';

contract A is B {
  function a() {
  }
}

B.sol:

contract B {
  function b() {
  }
}

Output:

contract IA {
  function b();
  function a();
}

API Usage

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.

Known Issues

  • Does not handle multiple contracts per file.

License

ISC © Raine Revere

0.1.13

7 years ago

0.1.12

7 years ago

0.1.11

7 years ago

0.1.10

7 years ago

0.1.9

7 years ago

0.1.8

7 years ago

0.1.7

7 years ago

0.1.6

7 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago