How to use the @nomiclabs/buidler/plugins.readArtifactSync function in @nomiclabs/buidler

To help you get started, we’ve selected a few @nomiclabs/buidler examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nomiclabs / buidler / packages / buidler-truffle5 / src / artifacts.ts View on Github external
if (libraries.length === 0) {
      return;
    }

    for (const library of libraries) {
      if (
        library.address === undefined ||
        library.constructor.network_id === undefined
      ) {
        throw new BuidlerPluginError(
          `Error while linking library ${library._json.contractName} into contract ${destination.contractName}: library not deployed.`
        );
      }
    }

    const destinationArtifact = readArtifactSync(
      this._artifactsPath,
      destination.contractName
    );

    const libraryAddresses: { [libraryName: string]: string } = {};

    const linkReferences = destinationArtifact.linkReferences;

    // Explanation of the following hacks:
    //
    //    1. When compiling a contract that uses libraries solc doesn't know the addresses
    //       of those. So when emitting the contract's bytecode it uses placeholders instead
    //       of them, and outputs a linkReferences object with info about them.
    //
    //    2. solc 0.4.x based those placeholders in the filename of the library and its name.
    //
github nomiclabs / buidler / packages / buidler-truffle4 / src / artifacts.ts View on Github external
if (libraries.length === 0) {
      return;
    }

    for (const library of libraries) {
      if (
        library.address === undefined ||
        library.constructor.network_id === undefined
      ) {
        throw new BuidlerPluginError(
          `Error while linking library ${library._json.contractName} into contract ${destination.contractName}: library not deployed.`
        );
      }
    }

    const destinationArtifact = readArtifactSync(
      this._artifactsPath,
      destination.contractName
    );

    const libraryAddresses: { [libraryName: string]: string } = {};

    const linkReferences = destinationArtifact.linkReferences;

    // Explanation of the following hacks:
    //
    //    1. When compiling a contract that uses libraries solc doesn't know the addresses
    //       of those. So when emitting the contract's bytecode it uses placeholders instead
    //       of them, and outputs a linkReferences object with info about them.
    //
    //    2. solc 0.4.x based those placeholders in the filename of the library and its name.
    //
github nomiclabs / buidler / packages / buidler-truffle4 / src / artifacts.ts View on Github external
private _getTruffleContract(contractName: string): TruffleContract {
    const artifact = readArtifactSync(this._artifactsPath, contractName);
    const TruffleContractFactory = require("truffle-contract");
    const Contract = TruffleContractFactory(artifact);

    return this._provisioner.provision(Contract, this);
  }
}
github nomiclabs / buidler / packages / buidler-truffle5 / src / artifacts.ts View on Github external
private _getTruffleContract(contractName: string): TruffleContract {
    const artifact = readArtifactSync(this._artifactsPath, contractName);
    const TruffleContractFactory = require("@nomiclabs/truffle-contract");
    const Contract = TruffleContractFactory(artifact);

    return this._provisioner.provision(Contract, this);
  }
}