@decent-bet/connex-entity-builder
v1.0.1
Published
A simple builder that reads Truffle generated JSON interfaces and generates imports and entities
Downloads
6
Keywords
Readme
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
- Add library:
const ContractImportBuilder = require('@decent-bet/connex-entity-builder')
- 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)
}
- Configure write event
builder.onWrite = (output) => {
fs.writeFileSync(`./npm/index.js`, output)
}
- 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