#!/bin/bash

# Setup script for Tatum SDK integration

set -e

echo "Setting up Tatum SDK for ChainID 138..."
echo "========================================"
echo ""

# Check if Node.js is installed
if ! command -v node &> /dev/null; then
    echo "Error: Node.js is not installed. Please install Node.js 18+ first."
    exit 1
fi

# Check Node.js version
NODE_VERSION=$(node -v | cut -d'v' -f2 | cut -d'.' -f1)
if [ "$NODE_VERSION" -lt 18 ]; then
    echo "Warning: Node.js version is less than 18. Recommended: Node.js 18+"
fi

echo "Node.js version: $(node -v)"
echo ""

# Install dependencies
echo "Installing dependencies..."
npm install

# Create .env file if it doesn't exist
if [ ! -f .env ]; then
    echo "Creating .env file from env.example..."
    cp env.example .env
    echo "Please update .env with your RPC endpoint configuration"
else
    echo ".env file already exists"
fi

echo ""
echo "Setup complete!"
echo ""
echo "Next steps:"
echo "1. Update .env with your RPC endpoint:"
echo "   RPC_URL=https://rpc.defi-oracle-meta-mainnet.org"
echo ""
echo "2. Test connection:"
echo "   npm run test"
echo ""
echo "3. Run examples:"
echo "   npm run example:basic"
echo "   npm run example:transaction"
echo "   npm run example:contract"
echo ""

