Skip to content
This repository was archived by the owner on Aug 23, 2022. It is now read-only.
This repository was archived by the owner on Aug 23, 2022. It is now read-only.

Location of ABI needs to be variablized #3

@cliffhall

Description

@cliffhall

The output location for ABIs can be changed from the default in Truffle.js:

module.exports = {
    contracts_build_directory: path.join(__dirname, "src/abi"),
}

This often has to be done when building a React application using Drizzle, since React only has access to files under its src folder at compile time. Consequently, this leads to a problem with unit tests that use the truffle-events library, which hardcodes the path to the contract ABI:

  getAbi: function(contractName) {
    let c = JSON.parse(fs.readFileSync(`./build/contracts/${contractName}.json`, `utf8`));
    return c.abi;
  }

Resulting in the following error:

  Error: ENOENT: no such file or directory, open './build/contracts/MyContract.json'
      at Object.openSync (fs.js:448:3)
      at Object.readFileSync (fs.js:348:35)
      at Object.getAbi (node_modules/truffle-events/index.js:6:27)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions