prebuild:
  ./scripts/checks/check-foundry-install.sh

dep-status:
  git submodule status

install:
  forge install

build: prebuild
  forge build

build-go-ffi:
  cd scripts/go-ffi && go build

autogen-invariant-docs:
  go run ./scripts/autogen/generate-invariant-docs .

test: build-go-ffi
  forge test

test-kontrol:
  ./test/kontrol/scripts/run-kontrol.sh script

test-rerun: build-go-ffi
  forge test --rerun -vvv

genesis:
  forge script scripts/L2Genesis.s.sol:L2Genesis --sig 'runWithStateDump()'

coverage: build-go-ffi
  forge coverage || (bash -c "forge coverage 2>&1 | grep -q 'Stack too deep' && echo -e '\\033[1;33mWARNING\\033[0m: Coverage failed with stack too deep, so overriding and exiting successfully' && exit 0 || exit 1")

coverage-lcov: build-go-ffi
  forge coverage --report lcov || (bash -c "forge coverage --report lcov 2>&1 | grep -q 'Stack too deep' && echo -e '\\033[1;33mWARNING\\033[0m: Coverage failed with stack too deep, so overriding and exiting successfully' && exit 0 || exit 1")

deploy:
  ./scripts/deploy/deploy.sh

gas-snapshot-no-build:
  forge snapshot --match-contract GasBenchMark

statediff:
  ./scripts/utils/statediff.sh && git diff --exit-code

gas-snapshot: build-go-ffi gas-snapshot-no-build

gas-snapshot-check: build-go-ffi
  forge snapshot --match-contract GasBenchMark --check

kontrol-summary:
  ./test/kontrol/scripts/make-summary-deployment.sh

kontrol-summary-fp:
  KONTROL_FP_DEPLOYMENT=true ./test/kontrol/scripts/make-summary-deployment.sh

snapshots-abi-storage:
  go run ./scripts/autogen/generate-snapshots .

snapshots: build snapshots-no-build

snapshots-no-build: snapshots-abi-storage kontrol-summary-fp kontrol-summary

snapshots-check:
  ./scripts/checks/check-snapshots.sh

semver-lock:
  forge script scripts/autogen/SemverLock.s.sol

validate-deploy-configs:
  ./scripts/checks/check-deploy-configs.sh

validate-spacers-no-build:
  go run ./scripts/checks/spacers

validate-spacers: build validate-spacers-no-build

clean:
  rm -rf ./artifacts ./forge-artifacts ./cache ./scripts/go-ffi/go-ffi ./.testdata ./deployments/hardhat/*

pre-pr-no-build: gas-snapshot-no-build snapshots-no-build semver-lock autogen-invariant-docs lint

pre-pr: clean build-go-ffi build pre-pr-no-build

pre-pr-full: test validate-deploy-configs validate-spacers pre-pr

lint-forge-tests-check:
  go run ./scripts/checks/names

lint-contracts-check:
  forge fmt --check

lint-check: lint-contracts-check

lint-contracts-fix:
  forge fmt

lint-fix: lint-contracts-fix

lint: lint-fix lint-check
