move ponder
This commit is contained in:
parent
a9207de195
commit
36b7b429ef
22 changed files with 50 additions and 14 deletions
|
|
@ -17,6 +17,7 @@ WEBAPP_LOG="$LOG_DIR/webapp.log"
|
|||
TXNBOT_LOG="$LOG_DIR/txnBot.log"
|
||||
SETUP_LOG="$LOG_DIR/setup.log"
|
||||
TXNBOT_ENV_FILE="$STATE_DIR/txnBot.env"
|
||||
MNEMONIC_FILE="$ROOT_DIR/onchain/.secret.local"
|
||||
|
||||
FORK_URL=${FORK_URL:-"https://sepolia.base.org"}
|
||||
ANVIL_RPC="http://127.0.0.1:8545"
|
||||
|
|
@ -29,8 +30,10 @@ FORGE="$FOUNDRY_BIN/forge"
|
|||
CAST="$FOUNDRY_BIN/cast"
|
||||
ANVIL="$FOUNDRY_BIN/anvil"
|
||||
|
||||
DEPLOYER_PK=${DEPLOYER_PK:-"0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"}
|
||||
DEPLOYER_ADDR="0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"
|
||||
DEFAULT_DEPLOYER_PK="0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
|
||||
DEFAULT_DEPLOYER_ADDR="0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"
|
||||
DEPLOYER_PK=${DEPLOYER_PK:-$DEFAULT_DEPLOYER_PK}
|
||||
DEPLOYER_ADDR=${DEPLOYER_ADDR:-$DEFAULT_DEPLOYER_ADDR}
|
||||
FEE_DEST="0xf6a3eef9088A255c32b6aD2025f83E57291D9011"
|
||||
WETH="0x4200000000000000000000000000000000000006"
|
||||
SWAP_ROUTER="0x94cC0AaC535CCDB3C01d6787D6413C739ae12bc4"
|
||||
|
|
@ -108,6 +111,29 @@ wait_for_http() {
|
|||
return 1
|
||||
}
|
||||
|
||||
set_deployer_credentials() {
|
||||
if [[ -n "$DEPLOYER_PK" && -n "$DEPLOYER_ADDR" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ -f "$MNEMONIC_FILE" ]]; then
|
||||
local mnemonic
|
||||
mnemonic="$(tr -d '\n\r' < "$MNEMONIC_FILE")"
|
||||
if [[ -n "$mnemonic" ]]; then
|
||||
local derived_pk
|
||||
derived_pk="$("$CAST" wallet private-key --mnemonic "$mnemonic" \
|
||||
--mnemonic-derivation-path "m/44'/60'/0'/0/0")"
|
||||
local derived_addr
|
||||
derived_addr="$("$CAST" wallet address --private-key "$derived_pk")"
|
||||
DEPLOYER_PK=${DEPLOYER_PK:-$derived_pk}
|
||||
DEPLOYER_ADDR=${DEPLOYER_ADDR:-$derived_addr}
|
||||
fi
|
||||
fi
|
||||
|
||||
DEPLOYER_PK=${DEPLOYER_PK:-$DEFAULT_DEPLOYER_PK}
|
||||
DEPLOYER_ADDR=${DEPLOYER_ADDR:-$DEFAULT_DEPLOYER_ADDR}
|
||||
}
|
||||
|
||||
ensure_tools() {
|
||||
for cmd in "$ANVIL" "$FORGE" "$CAST" jq npm curl; do
|
||||
if ! command -v "$cmd" >/dev/null 2>&1; then
|
||||
|
|
@ -122,9 +148,9 @@ start_directories() {
|
|||
}
|
||||
|
||||
ensure_dependencies() {
|
||||
if [[ ! -d "$ROOT_DIR/ponder/node_modules" ]]; then
|
||||
if [[ ! -d "$ROOT_DIR/services/ponder/node_modules" ]]; then
|
||||
log "Installing ponder dependencies"
|
||||
pushd "$ROOT_DIR/ponder" >/dev/null
|
||||
pushd "$ROOT_DIR/services/ponder" >/dev/null
|
||||
npm install >>"$SETUP_LOG" 2>&1
|
||||
popd >/dev/null
|
||||
fi
|
||||
|
|
@ -151,9 +177,18 @@ start_anvil() {
|
|||
fi
|
||||
|
||||
log "Starting Anvil (forking $FORK_URL)"
|
||||
"$ANVIL" --fork-url "$FORK_URL" --chain-id 31337 --block-time 1 \
|
||||
--host 127.0.0.1 --port 8545 \
|
||||
>"$ANVIL_LOG" 2>&1 &
|
||||
local anvil_args=("--fork-url" "$FORK_URL" "--chain-id" 31337 "--block-time" 1 \
|
||||
"--host" 127.0.0.1 "--port" 8545)
|
||||
|
||||
if [[ -f "$MNEMONIC_FILE" ]]; then
|
||||
local mnemonic
|
||||
mnemonic="$(tr -d '\n\r' < "$MNEMONIC_FILE")"
|
||||
if [[ -n "$mnemonic" ]]; then
|
||||
anvil_args+=("--mnemonic" "$mnemonic")
|
||||
fi
|
||||
fi
|
||||
|
||||
"$ANVIL" "${anvil_args[@]}" >"$ANVIL_LOG" 2>&1 &
|
||||
echo $! >"$ANVIL_PID_FILE"
|
||||
|
||||
wait_for_rpc "$ANVIL_RPC"
|
||||
|
|
@ -194,7 +229,7 @@ extract_addresses() {
|
|||
deploy_block="$(jq -r '.receipts[0].blockNumber' "$run_file" | xargs printf "%d")"
|
||||
|
||||
# Create .env.local for Ponder with deployed addresses
|
||||
cat > "$ROOT_DIR/ponder/.env.local" <<EOF
|
||||
cat > "$ROOT_DIR/services/ponder/.env.local" <<EOF
|
||||
# Auto-generated by local_env.sh
|
||||
PONDER_NETWORK=BASE_SEPOLIA_LOCAL_FORK
|
||||
KRAIKEN_ADDRESS=$KRAIKEN
|
||||
|
|
@ -310,7 +345,7 @@ start_ponder() {
|
|||
fi
|
||||
|
||||
log "Starting Ponder indexer"
|
||||
pushd "$ROOT_DIR/ponder" >/dev/null
|
||||
pushd "$ROOT_DIR/services/ponder" >/dev/null
|
||||
PONDER_NETWORK=BASE_SEPOLIA_LOCAL_FORK npm run dev >"$PONDER_LOG" 2>&1 &
|
||||
popd >/dev/null
|
||||
echo $! >"$PONDER_PID_FILE"
|
||||
|
|
@ -335,6 +370,7 @@ start_frontend() {
|
|||
|
||||
start_environment() {
|
||||
ensure_tools
|
||||
set_deployer_credentials
|
||||
start_directories
|
||||
ensure_dependencies
|
||||
start_anvil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue