0.1.13 • Published 10 years ago

generate-contract-interface v0.1.13

Weekly downloads
4
License
ISC
Repository
github
Last release
10 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

10 years ago

0.1.12

10 years ago

0.1.11

10 years ago

0.1.10

10 years ago

0.1.9

10 years ago

0.1.8

10 years ago

0.1.7

10 years ago

0.1.6

10 years ago

0.1.5

10 years ago

0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago