forked from Netwalls/BOXMEOUT_STELLA
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_contracts.sh
More file actions
executable file
·116 lines (105 loc) · 3.78 KB
/
build_contracts.sh
File metadata and controls
executable file
·116 lines (105 loc) · 3.78 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/bin/bash
# Build script for BoxMeOut Stella smart contracts
# Builds each contract separately as a WASM module
set -e
# Support for --check flag
CHECK_ONLY=false
if [ "$1" == "--check" ]; then
CHECK_ONLY=true
COMMAND="cargo check"
echo "🔍 Running check-only mode..."
else
COMMAND="cargo build --target wasm32-unknown-unknown --release"
fi
echo "🚀 Building BoxMeOut Stella Smart Contracts..."
echo ""
# Navigate to contract directory
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
CONTRACT_DIR="$SCRIPT_DIR/contracts/contracts/boxmeout"
cd "$CONTRACT_DIR"
echo "📍 Working directory: $(pwd)"
echo ""
# Build Market Contract
echo "📦 Building Market Contract..."
$COMMAND --features market
if [ $? -eq 0 ]; then
echo "✅ Market contract check/build successful"
if [ "$CHECK_ONLY" == false ] && [ -f "target/wasm32-unknown-unknown/release/boxmeout.wasm" ]; then
cp target/wasm32-unknown-unknown/release/boxmeout.wasm target/wasm32-unknown-unknown/release/market.wasm
echo " 📄 Saved as market.wasm"
fi
else
echo "❌ Market contract check/build failed"
exit 1
fi
echo ""
# Build Oracle Contract
echo "📦 Building Oracle Contract..."
$COMMAND --features oracle
if [ $? -eq 0 ]; then
echo "✅ Oracle contract check/build successful"
if [ "$CHECK_ONLY" == false ] && [ -f "target/wasm32-unknown-unknown/release/boxmeout.wasm" ]; then
cp target/wasm32-unknown-unknown/release/boxmeout.wasm target/wasm32-unknown-unknown/release/oracle.wasm
echo " 📄 Saved as oracle.wasm"
fi
else
echo "❌ Oracle contract check/build failed"
exit 1
fi
echo ""
# Build AMM Contract
echo "📦 Building AMM Contract..."
$COMMAND --features amm
if [ $? -eq 0 ]; then
echo "✅ AMM contract check/build successful"
if [ "$CHECK_ONLY" == false ] && [ -f "target/wasm32-unknown-unknown/release/boxmeout.wasm" ]; then
cp target/wasm32-unknown-unknown/release/boxmeout.wasm target/wasm32-unknown-unknown/release/amm.wasm
echo " 📄 Saved as amm.wasm"
fi
else
echo "❌ AMM contract check/build failed"
exit 1
fi
echo ""
# Build Factory Contract
echo "📦 Building Factory Contract..."
$COMMAND --features factory
if [ $? -eq 0 ]; then
echo "✅ Factory contract check/build successful"
if [ "$CHECK_ONLY" == false ] && [ -f "target/wasm32-unknown-unknown/release/boxmeout.wasm" ]; then
cp target/wasm32-unknown-unknown/release/boxmeout.wasm target/wasm32-unknown-unknown/release/factory.wasm
echo " 📄 Saved as factory.wasm"
fi
else
echo "❌ Factory contract check/build failed"
exit 1
fi
echo ""
# Build Treasury Contract
echo "📦 Building Treasury Contract..."
$COMMAND --features treasury
if [ $? -eq 0 ]; then
echo "✅ Treasury contract check/build successful"
if [ "$CHECK_ONLY" == false ] && [ -f "target/wasm32-unknown-unknown/release/boxmeout.wasm" ]; then
cp target/wasm32-unknown-unknown/release/boxmeout.wasm target/wasm32-unknown-unknown/release/treasury.wasm
echo " 📄 Saved as treasury.wasm"
fi
else
echo "❌ Treasury contract check/build failed"
exit 1
fi
echo ""
if [ "$CHECK_ONLY" == true ]; then
echo "🎉 All contract checks passed!"
else
echo "🎉 All 5 contracts built successfully!"
echo ""
echo "📁 Output files:"
ls -lh target/wasm32-unknown-unknown/release/{market,oracle,amm,factory,treasury}.wasm 2>/dev/null || echo "⚠️ Some WASM files missing"
fi
echo ""
echo "Next steps:"
echo " 1. Optimize: stellar contract optimize --wasm target/wasm32-unknown-unknown/release/market.wasm"
echo " 2. Deploy: stellar contract deploy --wasm <file> --network testnet --source <account>"
echo " 3. Initialize each contract with proper addresses"
echo " 4. Update backend .env with deployed contract addresses"