-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathpackage-wasm.sh
More file actions
executable file
·93 lines (77 loc) · 3.27 KB
/
Copy pathpackage-wasm.sh
File metadata and controls
executable file
·93 lines (77 loc) · 3.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/usr/bin/env bash
# =============================================================================
# StellarSettle – WASM Packaging & Checksum Script
# =============================================================================
#
# Compiles all Soroban contracts to WASM and generates a deterministic
# SHA256 checksums file for release transparency and contract verification.
#
# Usage:
# bash scripts/package-wasm.sh [output_dir]
#
# Arguments:
# output_dir Directory to place WASM files and checksums.txt
# (default: dist/)
#
# Requirements:
# - Rust with wasm32-unknown-unknown target installed
# - sha256sum (coreutils)
# =============================================================================
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
OUTPUT_DIR="${1:-${REPO_ROOT}/dist}"
RED='\033[0;31m'
GREEN='\033[0;32m'
CYAN='\033[0;36m'
NC='\033[0m'
info() { echo -e "${CYAN}[INFO]${NC} $*"; }
success() { echo -e "${GREEN}[OK]${NC} $*"; }
die() { echo -e "${RED}[ERROR]${NC} $*" >&2; exit 1; }
# ---------------------------------------------------------------------------
# Verify required tools
# ---------------------------------------------------------------------------
command -v sha256sum >/dev/null 2>&1 || die "sha256sum not found. Install coreutils."
# ---------------------------------------------------------------------------
# Build WASM contracts
# ---------------------------------------------------------------------------
info "Building WASM contracts..."
cd "${REPO_ROOT}"
cargo build --release --target wasm32-unknown-unknown \
-p invoice-escrow -p invoice-token -p payment-distributor
WASM_DIR="target/wasm32-unknown-unknown/release"
REQUIRED_FILES=(
"invoice_escrow.wasm"
"invoice_token.wasm"
"payment_distributor.wasm"
)
for wasm in "${REQUIRED_FILES[@]}"; do
[[ -f "${WASM_DIR}/${wasm}" ]] || die "WASM not found: ${WASM_DIR}/${wasm}"
done
# ---------------------------------------------------------------------------
# Copy WASM artifacts to output directory
# ---------------------------------------------------------------------------
info "Packaging WASM artifacts to ${OUTPUT_DIR}..."
mkdir -p "${OUTPUT_DIR}"
for wasm in "${REQUIRED_FILES[@]}"; do
cp "${WASM_DIR}/${wasm}" "${OUTPUT_DIR}/${wasm}"
success "Copied ${wasm}"
done
# ---------------------------------------------------------------------------
# Generate SHA256 checksums
# ---------------------------------------------------------------------------
info "Generating checksums..."
cd "${OUTPUT_DIR}"
sha256sum "${REQUIRED_FILES[@]}" > checksums.txt
success "checksums.txt generated"
# ---------------------------------------------------------------------------
# Summary
# ---------------------------------------------------------------------------
echo ""
echo "════════════════════════════════════════════════════════"
echo " Package complete"
echo "════════════════════════════════════════════════════════"
echo ""
cat checksums.txt
echo ""
info "Output directory: ${OUTPUT_DIR}"