openzeppelin-contract-loader
openzeppelin-contract-loader copied to clipboard
dependencyArtifactPath() requires build/contracts path
Function dependencyArtifactPath() is adding hard-coded build/contracts to the path already using artifactsDir from loadArtifact(), failing to load artifacts on test environment.
function dependencyArtifactPath(contractWithDependency: string): string {
const fragments = contractWithDependency.split('/');
const contract = fragments.pop();
const dependency = fragments.join('/');
try {
return require.resolve(`${dependency}/build/contracts/${contract}.json`);
} catch (err) {
throw new Error(`Cannot find contract ${contractWithDependency}: ${err.message}`);
}
}
Trying to get this a contract outside of the current project like this...
const { accounts, contract } = require('@openzeppelin/test-environment');
const ChromaFive = contract.fromArtifact('../../../../../cc-dapp/src/contracts/chroma/ChromaFive');
Results in this error...
Error: Cannot find contract ../../../../../cc-dapp/src/contracts/chroma/ChromaFive: Cannot find module '../../../../../cc-dapp/src/contracts/chroma/build/contracts/ChromaFive.json'