Configuring multiple artifacts dirs in test-environment

Is it possible to configure multiple artifacts dirs for test-environment? I need to use a truffle project and want to add it as a git submodule and point test-env to use the artifacts from it.

Currently, contracts.artifactsDir in test-environment.config.js is a string:

and node_modules/@openzeppelin/test-environment/lib/config.d.ts hints that it can only be a string:

Thoughts?

1 Like

Hey @shark0der! Welcome to the community!
It is not possible at that moment to have multiple artifacts dirs but I am pretty sure with some scripting this issue can be easily solved. Can you give more details of our file/folder structure and why you need to have more than one artifactsDir? Do you want to use artifacts from other project in your test? Is your code open source?

1 Like

Hey @yvl-io! Sorry for getting back so late.

My current project is using test-environment and I need to use a couple of contracts from another repository that’s using truffle. I can’t copy the other contracts because there are multiple dependencies and there are name-clashes so I’ve added the project as a git submodule and I’m compiling it using truffle. Afterwards, I want to use the truffle-generated artifacts in my project. Currently, I’ve copied them manually to my build dir - but this is rather dirty and I’m also overwriting a few files because of this. Supporting multiple artifacts dir I believe will be cleaner option.

2 Likes

Hey @shark0der! Using git submodules is certainly one way to do it. There is another way to archive what you want. Contract loader is capable to load artifacts from nmp modules, for example: contract.fromArtifact('@openzeppelin/contracts/IERC20'). What you can do is to convert your dependency project to npm module, add it as dependency to your project, and use contract.fromArtifact(yourmodule/yourcontract) to load artifacts. If you have to change your dependency contract often you can use npm link to speed up things. My two cents on the issue.

2 Likes