Prepares the repo to publish functioning npm packages for contracts, extras/linked-token, and extras/axelar-token.
Dependencies as node packages
We stop relying on forge dependencies (submodules in lib) and instead adopts package.json for contract dependency management, i.e. OpenZeppelin, Elliptic Curve, and Fevmate are now taken from node_modules. Unfortunately, murky is not published as a package, so that remains. This is necessary to enable dependents to create build graphs and resolve transitive dependencies correctly. We could've kept both Foundry libs and node_modules in parallel, but we'd have created a footgun, as dependency graphs for local builds (forge) could diverge from the dependency graph as seen by importers (npm).
Migration to pnpm
To make remapping resolution work properly and cleanly from node_modules with contract monorepos like this, we need to prevent node_modules hoisting. That is, inner modules cannot hoist dependencies to the workspace root, as (a) Foundry cannot find them there, and (b) adding a manual remapping would be dirty as it'll need to escape the current module scope. We could avoid using workspaces (that way every node_modules would be isolated), but this would force us to use ugly relative paths in inter-package dependencies (e.g. axelar-token and linked-token need to use the IPC contracts and SDK).
This was our forcing function to migrate from npm to pnpm, which is anyway a more modern, space-efficient and way faster package manager. While it does hoist dependencies to the root, it creates symlinks from the node_modules in inner modules to the real location at the root. This enables Foundry to discover these modules, and makes us happy as we don't need to use tree-dependent paths (e.g. ../../node_modules/...) in our remappings.
I have migrated all Makefiles, GitHub Action Workflows, and scripts to use pnpm.
Other minor cleanups
Removed redundant remappings files and entries.
Makefile: Added .PHONY targets where missing.
Makefile: Added node_modules as a tracked item, rebuilt when package.json or package-lock.json change.
Makefile: Replaced the coverage-for-mac target with a conditional in the coverage target.
Summary
Prepares the repo to publish functioning npm packages for contracts, extras/linked-token, and extras/axelar-token.
Dependencies as node packages
We stop relying on forge dependencies (submodules in lib) and instead adopts
package.json
for contract dependency management, i.e. OpenZeppelin, Elliptic Curve, and Fevmate are now taken fromnode_modules
. Unfortunately,murky
is not published as a package, so that remains. This is necessary to enable dependents to create build graphs and resolve transitive dependencies correctly. We could've kept both Foundry libs andnode_modules
in parallel, but we'd have created a footgun, as dependency graphs for local builds (forge) could diverge from the dependency graph as seen by importers (npm).Migration to pnpm
To make remapping resolution work properly and cleanly from
node_modules
with contract monorepos like this, we need to preventnode_modules
hoisting. That is, inner modules cannot hoist dependencies to the workspace root, as (a) Foundry cannot find them there, and (b) adding a manual remapping would be dirty as it'll need to escape the current module scope. We could avoid using workspaces (that way everynode_modules
would be isolated), but this would force us to use ugly relative paths in inter-package dependencies (e.g.axelar-token
andlinked-token
need to use the IPC contracts and SDK).This was our forcing function to migrate from
npm
topnpm
, which is anyway a more modern, space-efficient and way faster package manager. While it does hoist dependencies to the root, it creates symlinks from thenode_modules
in inner modules to the real location at the root. This enables Foundry to discover these modules, and makes us happy as we don't need to use tree-dependent paths (e.g.../../node_modules/...
) in our remappings.I have migrated all Makefiles, GitHub Action Workflows, and scripts to use pnpm.
Other minor cleanups