Skip to content

Commit 7cc927b

Browse files
committed
Merge branch 'main' into moet-redemption
Resolved conflicts: - .gitignore: Merged both versions - test_helpers.cdc: Kept moet-redemption version with redemption test functions All tests still passing after merge.
2 parents 562db39 + ea94fb9 commit 7cc927b

13 files changed

Lines changed: 504 additions & 131 deletions

File tree

.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
db
2+
cache
3+
broadcast

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
!local/emulator-account.pkey
88
!local/evm-gateway.pkey
99
!local/test-user.pkey
10-
!local/tidal.pkey
10+
!local/emulator-tidal.pkey
1111
imports
1212
coverage.lcov
1313
coverage.json
@@ -23,3 +23,7 @@ testnet-deployer.pkey
2323
testnet-uniswapV3-connectors-deployer.pkey
2424
mock-strategy-deployer.pkey
2525
local/deployed_addresses.env
26+
27+
broadcast
28+
cache
29+
db

Dockerfile

Lines changed: 59 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,87 @@ FROM debian:stable-slim
22

33
ENV FLOW_INSTALL_URL=https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh \
44
APP_HOME=/app \
5-
SEED_DIR=/seed/state
5+
SEED_DIR=/seed/state \
6+
FOUNDRY_DIR=/root/.foundry
67

8+
# Base deps + build essentials for Foundry (Rust) toolchain
79
RUN apt-get update && apt-get install -y --no-install-recommends \
810
curl ca-certificates jq bash openssl netcat-openbsd git \
11+
build-essential pkg-config libssl-dev \
912
&& rm -rf /var/lib/apt/lists/*
1013

14+
# --- Install Foundry ---
15+
RUN bash -lc 'curl -L https://foundry.paradigm.xyz | bash' \
16+
&& bash -lc '"$FOUNDRY_DIR/bin/foundryup"' \
17+
&& ln -s "$FOUNDRY_DIR/bin/forge" /usr/local/bin/forge \
18+
&& ln -s "$FOUNDRY_DIR/bin/anvil" /usr/local/bin/anvil \
19+
&& ln -s "$FOUNDRY_DIR/bin/cast" /usr/local/bin/cast \
20+
&& ln -s "$FOUNDRY_DIR/bin/chisel" /usr/local/bin/chisel \
21+
&& forge --version && anvil --version && cast --version
22+
1123
# Install Flow CLI
1224
RUN bash -lc 'curl -fsSL "$FLOW_INSTALL_URL" | bash' \
1325
&& mv /root/.local/bin/flow /usr/local/bin/flow \
1426
&& chmod +x /usr/local/bin/flow \
1527
&& flow version
1628

1729
WORKDIR ${APP_HOME}
18-
# Bring in your project files (flow.json, contracts/, scripts/, transactions/, etc.)
1930
COPY . ${APP_HOME}
20-
RUN chmod +x ${APP_HOME}/scripts/*.sh || true
31+
RUN chmod +x ${APP_HOME}/local/*.sh || true
32+
33+
# Use bash as default shell for subsequent RUNs
34+
SHELL ["/bin/bash", "-lc"]
2135

2236
# ---------- PRE-SEED AT BUILD TIME ----------
23-
# Start emulator in background with --persist, wait, seed, then stop.
24-
RUN bash -lc '\
25-
set -euo pipefail; \
37+
RUN set -euo pipefail; \
2638
mkdir -p "$SEED_DIR"; \
2739
echo "▶ Start emulator (build-time) with --persist to ${SEED_DIR}"; \
28-
flow emulator start --verbose --persist "$SEED_DIR" > /tmp/emulator-build.log 2>&1 & \
40+
flow emulator start --verbose --contracts --persist "$SEED_DIR" > /tmp/emulator-build.log 2>&1 & \
2941
EM_PID=$!; \
42+
cleanup() { \
43+
echo "▶ Stop EVM Gateway"; \
44+
[[ -n "${GW_PID:-}" ]] && kill "$GW_PID" 2>/dev/null || true; \
45+
[[ -n "${GW_PID:-}" ]] && wait "$GW_PID" 2>/dev/null || true; \
46+
echo "▶ Stop emulator (build-time)"; \
47+
kill "$EM_PID" 2>/dev/null || true; \
48+
wait "$EM_PID" 2>/dev/null || true; \
49+
}; \
50+
trap cleanup EXIT; \
3051
echo -n "⏳ Waiting for emulator ... "; \
3152
for i in {1..60}; do nc -z 127.0.0.1 3569 && break || { echo -n "."; sleep 1; }; done; echo; \
3253
echo "▶ Seeding"; \
33-
# Your seed scripts can use `--network emulator` exactly like at runtime:
34-
[ -x ./local/setup_wallets.sh ] && ./local/setup_wallets.sh || true; \
35-
[ -x ./local/setup_emulator.sh ] && ./local/setup_emulator.sh || true; \
36-
echo "▶ Stop emulator (build-time)"; \
37-
kill $EM_PID && wait $EM_PID || true \
38-
'
54+
./local/setup_wallets.sh; \
55+
echo "▶ Start EVM Gateway"; \
56+
rm -rf db/; \
57+
flow evm gateway \
58+
--flow-network-id=emulator \
59+
--evm-network-id=preview \
60+
--coinbase=FACF71692421039876a5BB4F10EF7A439D8ef61E \
61+
--coa-address=e03daebed8ca0615 \
62+
--coa-key=7549ce91aa82b6b42b060df5ab60d1246ae61e83177b5adb81c697e41d9e587a \
63+
--gas-price=0 \
64+
--rpc-port 8545 \
65+
> /tmp/evm-gateway-build.log 2>&1 & \
66+
GW_PID=$!; \
67+
echo -n "⏳ Waiting for EVM Gateway (8545) ... "; \
68+
for i in {1..120}; do \
69+
if nc -z 127.0.0.1 8545; then echo " ready."; break; fi; \
70+
# bail out if the gateway died and show logs
71+
if ! kill -0 "$GW_PID" 2>/dev/null; then \
72+
echo; echo "❌ Gateway exited early. Last 200 lines:"; \
73+
tail -n 200 /tmp/evm-gateway-build.log || true; \
74+
exit 1; \
75+
fi; \
76+
echo -n "."; sleep 1; \
77+
done; echo; \
78+
./local/punchswap/setup_punchswap.sh; \
79+
./local/punchswap/e2e_punchswap.sh; \
80+
./local/setup_emulator.sh; \
81+
./local/setup_bridged_tokens.sh; \
82+
echo "✅ Build-time seeding complete."
3983

4084
# ---------- RUNTIME ----------
41-
EXPOSE 3569 8080
42-
ENV FLOW_EMULATOR_FLAGS="--verbose --persist /seed/state"
85+
EXPOSE 3569 8080 8545
4386

44-
# At runtime we just start the emulator that already contains the baked state.
87+
ENV FLOW_EMULATOR_FLAGS="--verbose --contracts --persist /seed/state"
4588
ENTRYPOINT [ "bash", "-lc", "flow emulator start $FLOW_EMULATOR_FLAGS" ]

0 commit comments

Comments
 (0)