import '../just/go.just'

# Build ldflags string
_VERSION_META_STR := if VERSION_META != "" { "+" + VERSION_META } else { "" }
_LDFLAGSSTRING := "'" + trim(
    "-X main.GitCommit=" + GITCOMMIT + " " + \
    "-X main.GitDate=" + GITDATE + " " + \
    "-X github.com/ethereum-optimism/optimism/op-chain-ops/deployer/version.Version=" + VERSION + " " + \
    "-X github.com/ethereum-optimism/optimism/op-chain-ops/deployer/version.Meta=" + _VERSION_META_STR + " " + \
    "") + "'"

# Build ecotone-scalar binary
ecotone-scalar: (go_build "./bin/ecotone-scalar" "./cmd/ecotone-scalar" "-ldflags" _LDFLAGSSTRING)

# Build receipt-reference-builder binary  
receipt-reference-builder: (go_build "./bin/receipt-reference-builder" "./cmd/receipt-reference-builder" "-ldflags" _LDFLAGSSTRING)

# Run tests
test: (go_test "./...")

# Build op-deployer binary
op-deployer:
    just ../op-deployer/build
    mkdir -p ./bin && ln -f ../op-deployer/bin/op-deployer ./bin/op-deployer

# Run fuzzing tests
[private]
fuzz_task FUZZ TIME='10s': (go_fuzz FUZZ TIME "./crossdomain")

fuzz:
    printf "%s\n" \
        "FuzzEncodeDecodeWithdrawal" \
        "FuzzEncodeDecodeLegacyWithdrawal" \
        "FuzzAliasing" \
        "FuzzVersionedNonce" \
    | parallel -j {{PARALLEL_JOBS}} {{just_executable()}} fuzz_task {}

# Sync standard versions
sync-standard-version:
    curl -Lo ./deployer/opcm/standard-versions-mainnet.toml https://raw.githubusercontent.com/ethereum-optimism/superchain-registry/refs/heads/main/validation/standard/standard-versions-mainnet.toml
    curl -Lo ./deployer/opcm/standard-versions-sepolia.toml https://raw.githubusercontent.com/ethereum-optimism/superchain-registry/refs/heads/main/validation/standard/standard-versions-sepolia.toml
