Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
"overrideFeatureInstallOrder": [
"ghcr.io/devcontainers/features/common-utils",
"ghcr.io/devcontainers/features/git",
"ghcr.io/devcontainers/features/node",
"ghcr.io/devcontainers/features/python",
"ghcr.io/devcontainers/features/node",
"ghcr.io/devcontainers/features/sshd",
"ghcr.io/devcontainers/features/git-lfs",
"ghcr.io/devcontainers/features/github-cli",
Expand Down Expand Up @@ -67,11 +67,15 @@
"go.toolsManagement.checkForUpdates": "local",
"go.useLanguageServer": true,
"go.gopath": "/go",
"python.defaultInterpreterPath": "/home/codespace/.python/current/bin/python3",
"lldb.executable": "/usr/bin/lldb"
"python.defaultInterpreterPath": "/home/codespace/.python/current/bin/python3"
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": ["GitHub.vscode-pull-request-github"]
"extensions": [
"golang.go",
"rust-lang.rust-analyzer",
"JuanBlanco.solidity",
"esbenp.prettier-vscode"
]
}
}
}
50 changes: 37 additions & 13 deletions .devcontainer/justfile
Original file line number Diff line number Diff line change
@@ -1,31 +1,55 @@
# Define the PATH variable to include Foundry's bin directory
foundry_path := env_var('PATH') + ":" + env_var('HOME') + "/.foundry/bin"

# Add Foundry's bin directory to the PATH for all recipes
export PATH := env_var('PATH') + ":" + env_var('HOME') + "/.foundry/bin"
export PATH := foundry_path

# Clone the Optimism repository
clone:
op-clone:
git clone https://github.com/ethereum-optimism/optimism.git ~/optimism

# Install Foundry
install-foundry:
just --working-directory ~/optimism install-foundry
# Based on https://book.getfoundry.sh/getting-started/installation
foundry-install:
curl -L https://foundry.paradigm.xyz | bash

# Update Foundry
# Based on https://book.getfoundry.sh/getting-started/installation
foundry-update:
foundryup

# Initialize op-devnet
op-devnet-up:
make --directory ~/optimism op-devnet-up
PATH={{foundry_path}} make --directory ~/optimism devnet-up
@echo "OP Devnet initialized"

# Shut down devnet
op-devnet-down:
make --directory ~/optimism op-devnet-down
PATH={{foundry_path}} make --directory ~/optimism devnet-down
@echo "OP Devnet shut down"

# Create aliases for devnet commands in both Bash and Zsh
create-aliases:
#!/bin/bash
for rc_file in ~/.bashrc ~/.zshrc; do
if [[ -f "$rc_file" ]]; then
echo "# Foundry PATH" >> "$rc_file"
echo "export PATH=\"\$PATH:\$HOME/.foundry/bin\"" >> "$rc_file"
echo "# Foundry aliases" >> "$rc_file"
echo "alias foundry-install='just -f {{justfile()}} foundry-install'" >> "$rc_file"
echo "alias foundry-update='just -f {{justfile()}} foundry-update'" >> "$rc_file"
echo "# Metabased DevNet aliases" >> "$rc_file"
echo "alias op-up='just -f {{justfile()}} op-devnet-up'" >> "$rc_file"
echo "alias op-down='just -f {{justfile()}} op-devnet-down'" >> "$rc_file"
echo "Aliases created in $rc_file"
else
echo "Warning: $rc_file does not exist. Skipping."
fi
done

# Run all steps in sequence
# OP Devnet setup based on https://docs.optimism.io/chain/testing/dev-node
all: clone install-foundry op-devnet-up op-devnet-down copy-justfile
# We initialize and then spin down the devnet to get the initialization time out
# of the way upfront
all: op-clone foundry-install foundry-update op-devnet-up create-aliases
@echo "Post-create script completed successfully"

# Copy Justfile to ~/Metabased.justfile
# This gives easy access to op-devnet commands after the container is created
copy-justfile:
cp {{justfile()}} ~/metabased-devnet.justfile
@echo "Justfile copied to ~/metabased-devnet.justfile"