optimism icon indicating copy to clipboard operation
optimism copied to clipboard

Contract sources are only copied into root before publish, breaking usage within monorepo

Open smartcontracts opened this issue 4 years ago • 2 comments

We copy our contract sources into the root of packages/contracts before we publish to NPM:

https://github.com/ethereum-optimism/optimism/blob/e88e85d1ee2449d636a9315d25a9a2afdae5494f/packages/contracts/package.json#L41

We do this so that users can import contracts as follows:

import { MyContract } from "@eth-optimism/contracts/OVM/MyContract.sol";

However, because this step only happens before publish to NPM, we cannot use the same import style when attempting to import contracts from within the monorepo. This CI failure shows this problem in action: https://github.com/ben-chain/optimism/pull/4/checks?check_run_id=2562513730#step:7:14.

Fix would be to copy the sources into the root of packages/contracts during a build step instead of during prepublishOnly.

smartcontracts avatar May 12 '21 16:05 smartcontracts

@gakonst I saw you added the line in question so you might have more context, lmk if you're having trouble understanding the underlying issue.

smartcontracts avatar May 12 '21 16:05 smartcontracts

Makes sense.

I think that running the copy action before running/building the integration tests fixes this, if you agree, I'm supportive.

I wouldn't want the copy action to run after each build of the contracts package.

gakonst avatar May 13 '21 08:05 gakonst