Some checks failed
CI/CD Pipeline / Solidity Contracts (push) Failing after 1m13s
CI/CD Pipeline / Security Scanning (push) Successful in 2m30s
CI/CD Pipeline / Lint and Format (push) Failing after 45s
CI/CD Pipeline / Terraform Validation (push) Failing after 26s
CI/CD Pipeline / Kubernetes Validation (push) Successful in 28s
Deploy ChainID 138 / Deploy ChainID 138 (push) Failing after 39s
HYBX OMNL TypeScript & anchor / token-aggregation build + reconcile artifact (push) Failing after 21s
Validation / validate-genesis (push) Successful in 30s
Validation / validate-terraform (push) Failing after 25s
Validation / validate-kubernetes (push) Failing after 13s
Validation / validate-smart-contracts (push) Failing after 16s
Validation / validate-security (push) Failing after 1m28s
Validation / validate-documentation (push) Failing after 19s
Verify Deployment / Verify Deployment (push) Failing after 53s
Ship Z Chain slot, International Z Wallet routes, in-app Z Bot APIs, Besu bootstrap, and local/production deployment tooling for digital.omdnl.org. Co-authored-by: Cursor <cursoragent@cursor.com>
91 lines
3.2 KiB
PowerShell
91 lines
3.2 KiB
PowerShell
# Complete Z Chain local setup: RPC node + contract deploy + config sync.
|
|
# Uses Docker Besu when available; otherwise Hardhat node chainId 900002.
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
$Root = (Resolve-Path (Join-Path $PSScriptRoot "..\..")).Path
|
|
$RpcPort = if ($env:Z_CHAIN_RPC_PORT) { $env:Z_CHAIN_RPC_PORT } else { "8546" }
|
|
$RpcUrl = "http://127.0.0.1:$RpcPort"
|
|
$NodeLog = Join-Path $Root "logs\z-chain-node.log"
|
|
$ErrLog = Join-Path $Root "logs\z-chain-node.err.log"
|
|
$PidFile = Join-Path $Root "logs\z-chain-node.pid"
|
|
|
|
Set-Location $Root
|
|
New-Item -ItemType Directory -Force -Path (Join-Path $Root "logs") | Out-Null
|
|
|
|
function Test-RpcReady {
|
|
try {
|
|
$body = '{"jsonrpc":"2.0","id":1,"method":"eth_chainId","params":[]}'
|
|
$r = Invoke-RestMethod -Uri $RpcUrl -Method Post -Body $body -ContentType "application/json" -TimeoutSec 2
|
|
return ($r.result -eq "0xdbba2")
|
|
} catch {
|
|
return $false
|
|
}
|
|
}
|
|
|
|
function Stop-ZChainNode {
|
|
if (Test-Path $PidFile) {
|
|
$oldPid = Get-Content $PidFile -ErrorAction SilentlyContinue
|
|
if ($oldPid) {
|
|
Stop-Process -Id $oldPid -Force -ErrorAction SilentlyContinue
|
|
}
|
|
Remove-Item $PidFile -Force -ErrorAction SilentlyContinue
|
|
}
|
|
try {
|
|
docker rm -f z-chain-besu 2>$null | Out-Null
|
|
} catch {}
|
|
$conn = Get-NetTCPConnection -LocalPort $RpcPort -ErrorAction SilentlyContinue | Select-Object -First 1
|
|
if ($conn -and $conn.OwningProcess) {
|
|
Stop-Process -Id $conn.OwningProcess -Force -ErrorAction SilentlyContinue
|
|
Start-Sleep -Seconds 2
|
|
}
|
|
}
|
|
|
|
$dockerOk = $false
|
|
try {
|
|
docker info 2>&1 | Out-Null
|
|
if ($LASTEXITCODE -eq 0) { $dockerOk = $true }
|
|
} catch {}
|
|
|
|
Stop-ZChainNode
|
|
|
|
if ($dockerOk) {
|
|
Write-Host "Starting Z Chain via Docker Besu ..."
|
|
& "$PSScriptRoot\bootstrap-z-chain-local.ps1"
|
|
} else {
|
|
$env:Z_CHAIN_LOCAL = "1"
|
|
$hardhat = Join-Path $Root "node_modules\.bin\hardhat.cmd"
|
|
$nodeCmd = "set Z_CHAIN_LOCAL=1&& `"$hardhat`" node --port $RpcPort --hostname 127.0.0.1"
|
|
$nodeProc = Start-Process -FilePath "cmd.exe" -ArgumentList @("/c", $nodeCmd) -WorkingDirectory $Root -PassThru -WindowStyle Hidden -RedirectStandardOutput $NodeLog -RedirectStandardError $ErrLog
|
|
$nodeProc.Id | Set-Content $PidFile
|
|
Start-Sleep -Seconds 8
|
|
}
|
|
|
|
$deadline = (Get-Date).AddSeconds(90)
|
|
while (-not (Test-RpcReady)) {
|
|
if ((Get-Date) -gt $deadline) {
|
|
Write-Error "Z Chain RPC not ready at $RpcUrl after 90s. See $NodeLog and $ErrLog"
|
|
}
|
|
Start-Sleep -Seconds 2
|
|
}
|
|
Write-Host "Z Chain RPC ready at $RpcUrl"
|
|
|
|
$env:CHAIN_900002_RPC_URL = $RpcUrl
|
|
$env:Z_CHAIN_LOCAL = "1"
|
|
if (-not $env:PRIVATE_KEY) {
|
|
$env:PRIVATE_KEY = "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
|
|
}
|
|
|
|
Write-Host "Compiling Z Chain contracts ..."
|
|
npx hardhat compile --config hardhat.zchain.config.js 2>&1 | Out-Null
|
|
if ($LASTEXITCODE -ne 0) { throw "zchain compile failed" }
|
|
|
|
Write-Host "Deploying Z Chain contracts ..."
|
|
npx hardhat run scripts/deployment/deploy-z-chain-contracts.js --network zchain --config hardhat.zchain.config.js
|
|
if ($LASTEXITCODE -ne 0) { throw "contract deploy failed" }
|
|
|
|
Write-Host ""
|
|
Write-Host "Z Chain setup complete."
|
|
Write-Host " RPC: $RpcUrl"
|
|
Write-Host " Set VITE_ENABLE_Z_WALLET=true and VITE_RPC_URL_900002=$RpcUrl"
|
|
Write-Host " Updated config/z-chain-deployed.v1.json"
|