# Foundry Configuration
# This file configures Foundry for the project

[profile.default]
# Full historical repo config. For day-to-day monorepo work, prefer
# `bash scripts/forge/scope.sh ...` so Forge only sees the contract subtree you
# are actively editing.
src = "contracts"
# Vendored Uniswap V2 trees pin solc 0.5.x / 0.6.x; skip lets `forge test` use 0.8.20
# without legacy solc installs. Nothing outside vendor/ imports these paths.
skip = [
    "contracts/vendor/uniswap-v2-core/**/*.sol",
    "contracts/vendor/uniswap-v2-periphery/**/*.sol",
    "contracts/vendor/sushiswap-v2/**/*.sol",
    "contracts/bridge/integration/eMoneyBridgeIntegration.sol",
    "contracts/bridge/integration/eMoneyPolicyEnforcer.sol",
]
out = "out"
libs = ["lib"]
solc = "0.8.20"
optimizer = true
optimizer_runs = 200
via_ir = true
auto_detect_remappings = false
# Fork tests execute live mainnet bytecode; Cancun matches post-Dencun execution (MCOPY, etc.).
evm_version = "cancun"
fs_permissions = [
    { access = "read", path = "./config" },
    { access = "read", path = "../reports" }
]
remappings = [
    "@chainlink/contracts-ccip/=node_modules/@chainlink/contracts-ccip/",
    "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
    "@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
    "forge-std/=lib/forge-std/src/",
    "ds-test/=lib/forge-std/lib/ds-test/src/",
    "@emoney/=contracts/emoney/",
    "@emoney-scripts/=script/emoney/",
    "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
    "openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/",
    "@gru/=lib/gru-contracts/"
]

[profile.ci]
fuzz = { runs = 100 }
invariant = { runs = 10 }

[profile.lite]
optimizer = false
via_ir = false

[profile.fast]
optimizer = true
optimizer_runs = 1
via_ir = false

[profile.fork]
optimizer = true
optimizer_runs = 1
via_ir = true
evm_version = "cancun"

[profile.deploy]
optimizer = true
optimizer_runs = 100
via_ir = true
# Generic deploy profile for post-Dencun EVMs. Do not use for Chain 138.
evm_version = "cancun"

[profile.chain138]
optimizer = true
optimizer_runs = 100
via_ir = true
# Chain 138 Besu v25.12 is configured for Paris. Shanghai/Cancun bytecode
# (PUSH0/MCOPY) is rejected on-chain, so all Chain 138 deploys must target Paris.
evm_version = "paris"

[profile.m00-diamond]
solc = "0.8.21"
optimizer = true
optimizer_runs = 100
via_ir = true
evm_version = "paris"
fs_permissions = [
    { access = "read", path = "./config" },
    { access = "read", path = "../config" }
]
remappings = [
    "@chainlink/contracts-ccip/=node_modules/@chainlink/contracts-ccip/",
    "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
    "@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
    "forge-std/=lib/forge-std/src/",
    "@gru/=lib/gru-contracts/",
    "@emoney/=contracts/emoney/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/"
]


[profile.cronos_legacy]
optimizer = true
optimizer_runs = 100
via_ir = true
# Cronos chain 25 currently needs pre-Shanghai bytecode; target Paris to avoid PUSH0.
evm_version = "paris"

[profile.chain138_legacy]
optimizer = true
optimizer_runs = 100
via_ir = true
# Backwards-compatible alias for older scripts; prefer profile.chain138.
evm_version = "paris"

# BSC CompliantWrappedToken — matches verified cWUSDT on BscScan (chain 56).
# Use with scoped build: FOUNDRY_SRC=contracts/tokens FOUNDRY_OUT=out/scopes/tokens
#   bash scripts/forge/scope.sh build tokens
# EVM london (not cancun); solc 0.8.20; optimizer 200; via_ir required (stack depth).
[profile.bsc_tokens_verify]
src = "contracts/tokens,contracts/interfaces"
out = "out/scopes/tokens"
cache_path = "cache/scopes/tokens"
solc = "0.8.20"
optimizer = true
optimizer_runs = 200
via_ir = true
evm_version = "london"
auto_detect_remappings = false
remappings = [
    "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
    "@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
    "forge-std/=lib/forge-std/src/",
    "ds-test/=lib/forge-std/lib/ds-test/src/",
    "@emoney/=contracts/emoney/",
    "@emoney-scripts/=script/emoney/",
    "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
    "openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/",
    "@gru/=lib/gru-contracts/"
]

# Mainnet checkpoint hub — minimize runtime bytecode (EIP-170 24 KiB).
[profile.mainnet-checkpoint]
optimizer = true
optimizer_runs = 1
via_ir = true
evm_version = "cancun"
bytecode_hash = "none"
cbor_metadata = false

# RPC endpoints — use: forge create ... --rpc-url chain138
# Prevents default localhost:8545 when ETH_RPC_URL not set
[rpc_endpoints]
chain138 = "http://192.168.11.211:8545"
avalanche = "https://avalanche-c-chain.publicnode.com"
arbitrum = "https://arbitrum-one.publicnode.com"
cronos = "https://evm.cronos.org"

# Etherscan-compatible verification (Etherscan V2 API key works across many chains)
[etherscan]
avalanche = { key = "${SNOWTRACE_API_KEY:-${ETHERSCAN_API_KEY}}", url = "https://api.snowtrace.io/api" }
arbitrum = { key = "${ARBISCAN_API_KEY:-${ETHERSCAN_API_KEY}}", url = "https://api.arbiscan.io/api" }
# Cronos mainnet (chain 25). Legacy entry — forge verify-contract does not
# successfully submit to Cronos Explorer (see CRONOS_EXPLORER_OPERATIONS.md).
# Kept for cast/ethers compatibility if tooling expects [etherscan].cronos.
cronos = { key = "${CRONOSCAN_API_KEY:-${ETHERSCAN_API_KEY}}", url = "https://explorer-api.cronos.org/mainnet/api?chainid=25" }
