diff --git a/remappings.txt b/remappings.txt new file mode 100644 index 000000000..b809403eb --- /dev/null +++ b/remappings.txt @@ -0,0 +1,18 @@ +@across-protocol/=node_modules/@across-protocol/ +@ensdomains/=node_modules/@ensdomains/ +@eth-optimism/=node_modules/@eth-optimism/ +@gnosis.pm/=node_modules/@gnosis.pm/ +@maticnetwork/=node_modules/@maticnetwork/ +@matterlabs/=node_modules/@matterlabs/ +@openzeppelin/=node_modules/@openzeppelin/ +@scroll-tech/=node_modules/@scroll-tech/ +@uma/=node_modules/@uma/ +@uniswap/=node_modules/@uniswap/ +arb-bridge-eth/=node_modules/arb-bridge-eth/ +arb-bridge-peripherals/=node_modules/arb-bridge-peripherals/ +arbos-precompiles/=node_modules/arbos-precompiles/ +base64-sol/=node_modules/base64-sol/ +eth-gas-reporter/=node_modules/eth-gas-reporter/ +hardhat-deploy/=node_modules/hardhat-deploy/ +hardhat/=node_modules/hardhat/ +forge-std/=lib/forge-std/src/ diff --git a/scripts/preCommitHook.sh b/scripts/preCommitHook.sh index e8fbc8b15..36f7ba87f 100644 --- a/scripts/preCommitHook.sh +++ b/scripts/preCommitHook.sh @@ -47,3 +47,22 @@ if [ $EXTRACT_ADDRESSES_EXIT -ne 0 ]; then echo "extract-addresses encountered an error. Aborting the hook." exit $EXTRACT_ADDRESSES_EXIT fi + +# Check if foundry.toml was modified in staged changes and update remappings.txt if so +if git diff --cached --name-only --diff-filter=d | grep -q "foundry\.toml"; then + echo "Running forge remappings to update remappings.txt ..." + forge remappings > remappings.txt + FORGE_REMAPPINGS_EXIT=$? + if [ $FORGE_REMAPPINGS_EXIT -ne 0 ]; then + echo "forge remappings encountered an error. Aborting the hook." + exit $FORGE_REMAPPINGS_EXIT + fi + + # Stage remappings.txt if it was modified + if git diff --name-only remappings.txt | grep -q "remappings.txt"; then + git add remappings.txt + echo "Updated and staged remappings.txt" + fi +else + echo "Skipping forge remappings (foundry.toml not modified)" +fi