-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy-devnet.ps1
More file actions
87 lines (72 loc) · 3.86 KB
/
deploy-devnet.ps1
File metadata and controls
87 lines (72 loc) · 3.86 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
# Deploy DarkDrop program to devnet
# This script uses Docker to deploy the program
# Set KEYPAIR_PATH environment variable or update the default path below
Write-Host "Deploying DarkDrop program to devnet..." -ForegroundColor Cyan
# Resolve script directory so relative paths work from any cwd
$scriptRoot = Split-Path -Parent $MyInvocation.MyCommand.Path
# Check if Docker is running
$dockerRunning = docker ps 2>&1
if ($LASTEXITCODE -ne 0) {
Write-Host "`nError: Docker is not running or not installed" -ForegroundColor Red
exit 1
}
Write-Host "Docker is running" -ForegroundColor Green
# Check if program is built
if (-not (Test-Path (Join-Path $scriptRoot "target/deploy/darkpool.so")) -or `
-not (Test-Path (Join-Path $scriptRoot "target/deploy/groth16_verifier.so"))) {
Write-Host "`nWarning: Program not built yet. Building first..." -ForegroundColor Yellow
& (Join-Path $scriptRoot "build-with-docker.ps1")
if ($LASTEXITCODE -ne 0) {
Write-Host "`nError: Build failed. Cannot deploy." -ForegroundColor Red
exit 1
}
}
Write-Host "`nProgram binaries found" -ForegroundColor Green
# Find keypair file - use environment variable or default
$keypairPath = $env:KEYPAIR_PATH
if (-not $keypairPath) {
# Default to Solana CLI default location
$solanaConfig = solana config get 2>&1 | Select-String "Keypair Path"
if ($solanaConfig) {
$keypairPath = ($solanaConfig.ToString() -replace ".*Keypair Path:\s*", "").Trim()
} else {
Write-Host "`nError: Keypair path not found" -ForegroundColor Red
Write-Host "Set KEYPAIR_PATH environment variable or configure Solana CLI" -ForegroundColor Yellow
Write-Host "Example: `$env:KEYPAIR_PATH = 'path/to/keypair.json'" -ForegroundColor Gray
exit 1
}
}
if (-not (Test-Path $keypairPath)) {
Write-Host "`nError: Keypair file not found: $keypairPath" -ForegroundColor Red
Write-Host "Set KEYPAIR_PATH environment variable or update Solana config" -ForegroundColor Yellow
exit 1
}
Write-Host "`nUsing keypair: $keypairPath" -ForegroundColor Cyan
# Deploy using Docker
Write-Host "`nDeploying to devnet..." -ForegroundColor Yellow
Write-Host "Note: Make sure you have devnet SOL in your wallet!" -ForegroundColor Cyan
Write-Host "Get free SOL: solana airdrop 2 --url devnet" -ForegroundColor Gray
# Get the directory and filename of the keypair
$keypairDir = Split-Path -Parent $keypairPath
$keypairFile = Split-Path -Leaf $keypairPath
$workspace = Resolve-Path $scriptRoot
docker run --rm `
-v "${workspace}:/workspace" `
-v "${keypairDir}:/keys" `
-w /workspace `
darkpool-builder `
bash -c "solana config set --url devnet && solana config set --keypair /keys/$keypairFile && solana program deploy /workspace/target/deploy/groth16_verifier.so --program-id /workspace/target/deploy/groth16_verifier-keypair.json --use-rpc --max-sign-attempts 10 && solana program deploy /workspace/target/deploy/darkpool.so --program-id /workspace/target/deploy/darkpool-keypair.json --use-rpc --max-sign-attempts 10"
if ($LASTEXITCODE -eq 0) {
Write-Host "`nDeployment successful!" -ForegroundColor Green
Write-Host "`nNext steps:" -ForegroundColor Cyan
Write-Host "1. Update program ID in your code if it changed" -ForegroundColor White
Write-Host "2. Test the program with your app" -ForegroundColor White
Write-Host "3. Check deployment: solana program show <PROGRAM_ID> --url devnet" -ForegroundColor White
} else {
Write-Host "`nDeployment failed" -ForegroundColor Red
Write-Host "Check errors above" -ForegroundColor Yellow
Write-Host "`nCommon issues:" -ForegroundColor Yellow
Write-Host "- Not enough SOL: solana airdrop 2 --url devnet" -ForegroundColor White
Write-Host "- Wrong network: solana config set --url devnet" -ForegroundColor White
Write-Host "- Wallet not found: Check Solana config keypair path" -ForegroundColor White
}