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
43 changes: 34 additions & 9 deletions oracledesk-stellar/scripts/gen-bindings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,28 @@
set -euo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")/.."

# Source toolchain versions for deterministic builds
source scripts/toolchain.env

# Verify stellar CLI version for deterministic bindings generation
INSTALLED_VERSION=$(stellar --version 2>/dev/null | awk '{print $2}' || echo "not found")
if [ "$INSTALLED_VERSION" != "$STELLAR_CLI_VERSION" ]; then
if [ "${ALLOW_CLI_MISMATCH:-}" = "1" ]; then
echo "WARNING: stellar CLI version mismatch (expected $STELLAR_CLI_VERSION, got $INSTALLED_VERSION)" >&2
echo " Bindings may differ from CI. Set ALLOW_CLI_MISMATCH=1 to suppress this warning." >&2
else
echo "ERROR: stellar CLI version mismatch" >&2
echo " Expected: $STELLAR_CLI_VERSION" >&2
echo " Installed: $INSTALLED_VERSION" >&2
echo "" >&2
echo "Install the correct version with:" >&2
echo " cargo install --locked stellar-cli --version $STELLAR_CLI_VERSION" >&2
echo "" >&2
echo "Or set ALLOW_CLI_MISMATCH=1 to proceed anyway (not recommended)." >&2
exit 1
fi
fi

WASM_DIR=target/wasm32v1-none/release
OUT_DIR=packages/bindings

Expand All @@ -21,18 +43,21 @@ for f in market_core resolver reasoning_registry treasury timelock router; do
fi
done

declare -A NAMES=(
[market_core]="market-core"
[resolver]="resolver"
[reasoning_registry]="reasoning-registry"
[treasury]="treasury"
[timelock]="timelock"
[router]="router"
# Fixed iteration order for deterministic bindings generation
# Format: wasm_name:pkg_name
CONTRACTS=(
"market_core:market-core"
"resolver:resolver"
"reasoning_registry:reasoning-registry"
"treasury:treasury"
"timelock:timelock"
"router:router"
)

mkdir -p "$OUT_DIR"
for wasm_name in "${!NAMES[@]}"; do
pkg_name=${NAMES[$wasm_name]}
for entry in "${CONTRACTS[@]}"; do
wasm_name="${entry%%:*}"
pkg_name="${entry##*:}"
echo "==> generating bindings for $pkg_name" >&2
# `--overwrite` deletes files it does not generate, including the committed
# package-lock.json — which would make CI's "bindings are stale" diff fail on
Expand Down
7 changes: 7 additions & 0 deletions oracledesk-stellar/scripts/toolchain.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Pinned versions for deterministic builds and bindings generation
# Source this file from scripts to ensure consistent tooling across local
# and CI environments.

# Stellar CLI version for contract bindings generation
# Must match the version used in .github/workflows/ci.yml
STELLAR_CLI_VERSION=27.1.0