Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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.
//
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.
//
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);
}
}
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);
}
}