@decent-bet/connex-entity-builder

1.0.1 • Public • Published

connex-entity-builder

A simple builder that reads Truffle generated JSON interfaces and generates imports and entities

Install

npm i @decent-bet/connex-entity-builder

How to use with Truffle migrations

  1. Add library: const ContractImportBuilder = require('@decent-bet/connex-entity-builder')
  2. Create instance and set output
module.exports = (web3, dbet, deployer, args) => {
    const builder = new ContractImportBuilder();
    builder.setOutput(`./npm/index.js`);
    return new MigrationScript(web3, dbet, deployer, builder, args)
}
  1. Configure write event
    builder.onWrite = (output) => {
        fs.writeFileSync(`./npm/index.js`, output)
    }
  1. Add contracts. This will generate a contract import which has the following schema:
{
    VERSION: string,
    [name]: {
        raw: {
            abi: "<_jsonInterface from Truffle ABI>"
        },
        address: {
            [chaintag]: "<address>"
        }
    }
}

The addContract method has the following parameters:

  • name: The friendly name of the contract.
  • contract: Contract object from a Truffle migration.
  • address: The deployed address of a contract.
  • chaintag: The current chaintag or net being deployed.

Example:

builder.addContract("TokenContract", Token, token.options.address, chain);

Pending

  • Generate basic connex contract entities mapped to contract import
  • Enable CI process to npm publish once a PR is merged to master

Readme

Keywords

none

Package Sidebar

Install

npm i @decent-bet/connex-entity-builder

Weekly Downloads

0

Version

1.0.1

License

ISC

Unpacked Size

4.85 kB

Total Files

4

Last publish

Collaborators

  • bradleysuira
  • decent-dev
  • bstahlhood
  • molekilla