#!/bin/bash

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="${PROJECT_ROOT:-$(cd "$SCRIPT_DIR/.." && pwd)}"

source "$PROJECT_ROOT/internal/docker/docker_env.sh"
source "$PROJECT_ROOT/scripts/common.sh"

PROTOCOL_DIR="${PROTOCOL_DIR:-$PROJECT_ROOT/../protocol}"

# get deployed contract address.
DEPLOYMENT_JSON=$(cat "${PROTOCOL_DIR}/deployments/deploy_l1.json")
export INBOX=$(echo "$DEPLOYMENT_JSON" | jq '.shasta_inbox' | sed 's/\"//g')
export TAIKO_ANCHOR=0x1670010000000000000000000000000000010001
export COMPOSE_VERIFIER=$(echo "$DEPLOYMENT_JSON" | jq '.proof_verifier' | sed 's/\"//g')
export L1_CONTRACT_OWNER_PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
export L1_PROPOSER_PRIVATE_KEY=0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a
export L2_SUGGESTED_FEE_RECIPIENT=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
export L1_PROVER_PRIVATE_KEY=0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d
export TEST_ACCOUNT_PRIVATE_KEY=0x7c852118294e51e653712a81e05800f419141751be58f605c371e15141b007a6
export TREASURY=0x1670010000000000000000000000000000010001
export VERBOSITY=${VERBOSITY-3}

# Print the environment variables.
echo "RUN_TESTS=true
L1_HTTP=$L1_HTTP
L1_WS=$L1_WS
L2_SUGGESTED_FEE_RECIPIENT=$L2_SUGGESTED_FEE_RECIPIENT
L2_HTTP=$L2_HTTP
L2_WS=$L2_WS
L2_AUTH=$L2_AUTH
INBOX=$INBOX
COMPOSE_VERIFIER=$COMPOSE_VERIFIER
TAIKO_ANCHOR=$TAIKO_ANCHOR
L1_CONTRACT_OWNER_PRIVATE_KEY=$L1_CONTRACT_OWNER_PRIVATE_KEY
L1_PROPOSER_PRIVATE_KEY=$L1_PROPOSER_PRIVATE_KEY
L1_PROVER_PRIVATE_KEY=$L1_PROVER_PRIVATE_KEY
TEST_ACCOUNT_PRIVATE_KEY=$TEST_ACCOUNT_PRIVATE_KEY
TREASURY=$TREASURY
JWT_SECRET=$JWT_SECRET
VERBOSITY=$VERBOSITY
ANVIL_L1_START_TIMESTAMP=$ANVIL_L1_START_TIMESTAMP" > "$SCRIPT_DIR/.env"
