Skip to content
Open
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
49 changes: 49 additions & 0 deletions scripts/deploy_local.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env bash
set -euo pipefail

ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT_DIR"

# shellcheck disable=SC1091
source scripts/validate_env.sh .env.local standalone deployment

mkdir -p abis

: "${SOROBAN_RPC_URL:=http://localhost:8000/soroban/rpc}"
: "${STELLAR_NETWORK:=standalone}"

echo "Building COMEBACKHERE contracts for local standalone network via $SOROBAN_RPC_URL"
# Build from the contracts repo (sibling directory)
(cd ../COMEBACKHERE-contracts && cargo build --target wasm32-unknown-unknown --release)

cat > abis/deployed.local.json <<JSON
{
"network": "$STELLAR_NETWORK",
"rpc_url": "$SOROBAN_RPC_URL",
"invoice_contract_id": "${INVOICE_CONTRACT_ID:-C...}",
"treasury_contract_id": "${TREASURY_CONTRACT_ID:-C...}",
"compliance_contract_id": "${COMPLIANCE_CONTRACT_ID:-C...}",
"generated_at": "$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
}
JSON

echo "Local contract deployment metadata written to abis/deployed.local.json"
echo "Replace placeholder IDs with actual deployed contract IDs before backend integration."

genenv() {
if [ -f .env.local ]; then
# shellcheck disable=SC1091
set -a
source .env.local
set +a
fi
}

genenv

export STELLAR_NETWORK="${STELLAR_NETWORK:-standalone}"
export INVOICE_CONTRACT_ID="${INVOICE_CONTRACT_ID:-C...}"
export TREASURY_CONTRACT_ID="${TREASURY_CONTRACT_ID:-C...}"
export COMPLIANCE_CONTRACT_ID="${COMPLIANCE_CONTRACT_ID:-C...}"

scripts/export_deployed_addresses.sh
10 changes: 10 additions & 0 deletions scripts/export_deployed_addresses.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
#
# Optional:
# DEPLOYED_ADDRESSES_FILE — override output path (default: artifacts/addresses.json)
# DEPLOYED_ADDRESSES_ENV — override shell env output path (default: artifacts/addresses.env)
set -euo pipefail

ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
OUT_FILE="${DEPLOYED_ADDRESSES_FILE:-$ROOT_DIR/artifacts/addresses.json}"
ENV_FILE="${DEPLOYED_ADDRESSES_ENV:-$ROOT_DIR/artifacts/addresses.env}"
EXAMPLE_FILE="$ROOT_DIR/artifacts/addresses.json.example"

: "${STELLAR_NETWORK:?STELLAR_NETWORK is required}"
Expand Down Expand Up @@ -47,6 +49,14 @@ PY

echo "Deployed addresses written to $OUT_FILE"

echo "Writing shell exports to $ENV_FILE"
cat > "$ENV_FILE" <<EOF
export STELLAR_NETWORK="$STELLAR_NETWORK"
export INVOICE_CONTRACT_ID="$INVOICE_CONTRACT_ID"
export TREASURY_CONTRACT_ID="$TREASURY_CONTRACT_ID"
export COMPLIANCE_CONTRACT_ID="$COMPLIANCE_CONTRACT_ID"
EOF

# ── Schema validation against addresses.json.example ─────────────────────────
if [[ ! -f "$EXAMPLE_FILE" ]]; then
echo "WARNING: $EXAMPLE_FILE not found; skipping schema validation." >&2
Expand Down
7 changes: 6 additions & 1 deletion scripts/validate_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,12 @@ if ! require_any_var "Set SOROBAN_RPC_URL (or RPC_URL) to your Soroban RPC endpo
:
fi

if ! require_var "SOROBAN_NETWORK_PASSPHRASE" "Set SOROBAN_NETWORK_PASSPHRASE to the network passphrase for the target network."; then
# Allow legacy/README env variable name for network passphrase.
if [[ -z "${SOROBAN_NETWORK_PASSPHRASE:-}" && -n "${NETWORK_PASSPHRASE:-}" ]]; then
export SOROBAN_NETWORK_PASSPHRASE="$NETWORK_PASSPHRASE"
fi

if ! require_any_var "Set SOROBAN_NETWORK_PASSPHRASE (or NETWORK_PASSPHRASE) to the network passphrase for the target network." "SOROBAN_NETWORK_PASSPHRASE" "NETWORK_PASSPHRASE"; then
:
fi

Expand Down