143 lines
3.5 KiB
Bash
Executable File
143 lines
3.5 KiB
Bash
Executable File
#!/bin/bash
|
|
# ๐ FIXED ONE SCRIPT TO DEPLOY EVERYTHING
|
|
|
|
set -e
|
|
echo "๐ Deploying Stellar Price Oracle - Fixed Version"
|
|
|
|
# Install Stellar CLI
|
|
echo "๐ฆ Installing Stellar CLI..."
|
|
cargo install --locked stellar-cli --features opt --force
|
|
|
|
# Add WASM target
|
|
rustup target add wasm32-unknown-unknown
|
|
|
|
# Setup testnet
|
|
echo "๐ Setting up testnet..."
|
|
stellar network add --global testnet \
|
|
--rpc-url https://soroban-testnet.stellar.org:443 \
|
|
--network-passphrase "Test SDF Network ; September 2015"
|
|
|
|
# Create account
|
|
echo "๐ Creating deployment account..."
|
|
stellar keys generate deployer --network testnet --global
|
|
|
|
# Fund account with proper network passphrase
|
|
echo "๐ฐ Funding account..."
|
|
stellar keys fund deployer \
|
|
--network testnet \
|
|
--network-passphrase "Test SDF Network ; September 2015"
|
|
|
|
# Check balance
|
|
echo "๐ณ Checking balance..."
|
|
stellar account --id $(stellar keys address deployer) --network testnet
|
|
|
|
# Build contract
|
|
echo "๐๏ธ Building smart contract..."
|
|
cd contract
|
|
cargo build --target wasm32-unknown-unknown --release
|
|
cd ..
|
|
|
|
# Deploy contract with alias
|
|
echo "๐ Deploying contract to Stellar..."
|
|
stellar contract deploy \
|
|
--wasm contract/target/wasm32-unknown-unknown/release/stellar_price_oracle.wasm \
|
|
--source deployer \
|
|
--network testnet \
|
|
--alias price_oracle
|
|
|
|
CONTRACT_ID=$(stellar contract id --alias price_oracle --network testnet)
|
|
echo "โ
Contract deployed: $CONTRACT_ID"
|
|
|
|
# Create .env with everything
|
|
echo "โ๏ธ Creating .env..."
|
|
cat > .env << EOF
|
|
STELLAR_RPC_URL=https://soroban-testnet.stellar.org:443
|
|
STELLAR_NETWORK=testnet
|
|
PROVIDER_SECRET=$(stellar keys show deployer)
|
|
ORACLE_CONTRACT_ID=$CONTRACT_ID
|
|
API_PORT=3001
|
|
UPDATE_INTERVAL=30000
|
|
VITE_API_URL=http://localhost:3001
|
|
VITE_STELLAR_RPC=https://soroban-testnet.stellar.org:443
|
|
VITE_CONTRACT_ID=$CONTRACT_ID
|
|
EOF
|
|
|
|
# Install backend dependencies
|
|
echo "๐ฆ Installing backend..."
|
|
cd oracle-service
|
|
npm install
|
|
cd ..
|
|
|
|
# Install frontend dependencies
|
|
echo "๐จ Installing frontend..."
|
|
cd frontend
|
|
npm install
|
|
cd ..
|
|
|
|
# Start backend
|
|
echo "๐ Starting backend..."
|
|
cd oracle-service
|
|
npm start &
|
|
BACKEND_PID=$!
|
|
cd ..
|
|
|
|
# Wait for backend
|
|
sleep 5
|
|
|
|
# Test backend
|
|
echo "๐งช Testing backend..."
|
|
curl -s http://localhost:3001/health || echo "Backend starting..."
|
|
|
|
# Start frontend
|
|
echo "๐จ Starting frontend..."
|
|
cd frontend
|
|
npm run dev &
|
|
FRONTEND_PID=$!
|
|
cd ..
|
|
|
|
# Wait for frontend
|
|
sleep 5
|
|
|
|
# Example test call (set price)
|
|
echo "๐งช Testing contract..."
|
|
stellar contract invoke \
|
|
--id price_oracle \
|
|
--source deployer \
|
|
--network testnet \
|
|
-- \
|
|
set_price \
|
|
--pair BTC \
|
|
--price 123456 \
|
|
--provider $(stellar keys address deployer)
|
|
|
|
# Example test call (get price)
|
|
stellar contract invoke \
|
|
--id price_oracle \
|
|
--source deployer \
|
|
--network testnet \
|
|
-- \
|
|
get_price \
|
|
--pair BTC
|
|
|
|
echo ""
|
|
echo "๐ EVERYTHING IS RUNNING!"
|
|
echo "========================"
|
|
echo ""
|
|
echo "๐ Contract ID: $CONTRACT_ID"
|
|
echo "๐ Explorer: https://stellar.expert/explorer/testnet/contract/$CONTRACT_ID"
|
|
echo "๐ Frontend: http://localhost:5173"
|
|
echo "๐ Backend: http://localhost:3001/health"
|
|
echo ""
|
|
echo "๐ To stop: kill $BACKEND_PID $FRONTEND_PID"
|
|
echo ""
|
|
echo "๐ Your oracle is live with real smart contracts!"
|
|
|
|
# Save PIDs for easy stopping
|
|
echo "BACKEND_PID=$BACKEND_PID" > .pids
|
|
echo "FRONTEND_PID=$FRONTEND_PID" >> .pids
|
|
|
|
echo ""
|
|
echo "๐ก Quick commands:"
|
|
echo " Test contract: stellar contract invoke --id $CONTRACT_ID --source deployer --network testnet -- get_assets"
|
|
echo " Stop services: kill $BACKEND_PID $FRONTEND_PID"
|
|
echo " View logs: tail -f oracle-service/*.log" |