-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
73 lines (56 loc) · 2.09 KB
/
deploy.sh
File metadata and controls
73 lines (56 loc) · 2.09 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
#!/bin/bash
# Scammer Detection Smart Contract Deployment Script
# This script deploys the smart contract and updates the frontend configuration
echo "🚀 Deploying Scammer Detection Smart Contract..."
# Navigate to contract directory
cd "$(dirname "$0")/scammer"
# Build the contract
echo "📦 Building smart contract..."
sui move build
if [ $? -ne 0 ]; then
echo "❌ Contract build failed"
exit 1
fi
echo "✅ Contract built successfully"
# Deploy the contract
echo "🌐 Deploying contract to devnet..."
DEPLOY_OUTPUT=$(sui client publish --gas-budget 100000000 --json)
if [ $? -ne 0 ]; then
echo "❌ Contract deployment failed"
exit 1
fi
echo "✅ Contract deployed successfully"
# Extract package ID and object IDs from deployment output
PACKAGE_ID=$(echo "$DEPLOY_OUTPUT" | jq -r '.objectChanges[] | select(.type == "published") | .packageId')
DETECTOR_STATE_ID=$(echo "$DEPLOY_OUTPUT" | jq -r '.objectChanges[] | select(.objectType | contains("DetectorState")) | .objectId')
echo "📄 Deployment Results:"
echo "Package ID: $PACKAGE_ID"
echo "Detector State ID: $DETECTOR_STATE_ID"
# Update frontend configuration
echo "🔧 Updating frontend configuration..."
cd "../scammer-client"
# Update .env file
cat > .env << EOF
# Smart Contract Configuration - Auto-generated by deployment script
VITE_PACKAGE_ID=$PACKAGE_ID
VITE_DETECTOR_STATE_ID=$DETECTOR_STATE_ID
VITE_NETWORK=devnet
EOF
echo "✅ Frontend configuration updated"
# Update contract.ts with the new values
sed -i.bak "s/import.meta.env.VITE_PACKAGE_ID || \"0x0\"/\"$PACKAGE_ID\"/g" src/config/contract.ts
sed -i.bak "s/import.meta.env.VITE_DETECTOR_STATE_ID || \"0x0\"/\"$DETECTOR_STATE_ID\"/g" src/config/contract.ts
echo "✅ Contract configuration updated"
echo ""
echo "🎉 Deployment Complete!"
echo ""
echo "📋 Summary:"
echo " Package ID: $PACKAGE_ID"
echo " Detector State ID: $DETECTOR_STATE_ID"
echo " Network: devnet"
echo ""
echo "🔗 Next Steps:"
echo " 1. Start the frontend: cd scammer-client && pnpm dev"
echo " 2. Connect your wallet and start monitoring!"
echo " 3. Test the scam detection features"
echo ""