From 91e14bf20009d4a2141234ced24f84cc7d40ba19 Mon Sep 17 00:00:00 2001 From: Kurdistan Tech Ministry Date: Wed, 4 Feb 2026 12:19:29 +0300 Subject: [PATCH] fix: add production fallback endpoints for blockchain connection - Add VITE_NETWORK and endpoint env vars to CI/CD build - Add Asset Hub and People Chain endpoints to build config - Add hardcoded production fallbacks in PezkuwiContext - Disable WebSocket real-time service (not deployed yet) - Endpoints: rpc.pezkuwichain.io, mainnet, beta, asset-hub, people --- .github/workflows/quality-gate.yml | 7 +++++++ web/src/contexts/PezkuwiContext.tsx | 16 ++++++++++++---- web/src/contexts/WebSocketContext.tsx | 9 +++++---- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/.github/workflows/quality-gate.yml b/.github/workflows/quality-gate.yml index 8c471edf..4fb31063 100644 --- a/.github/workflows/quality-gate.yml +++ b/.github/workflows/quality-gate.yml @@ -61,6 +61,13 @@ jobs: - name: Build Project working-directory: ./web run: npm run build + env: + VITE_NETWORK: BETA + VITE_WS_ENDPOINT: wss://rpc.pezkuwichain.io:9944 + VITE_WS_ENDPOINT_FALLBACK_1: wss://mainnet.pezkuwichain.io + VITE_WS_ENDPOINT_FALLBACK_2: wss://beta.pezkuwichain.io + VITE_ASSET_HUB_ENDPOINT: wss://asset-hub-rpc.pezkuwichain.io + VITE_PEOPLE_CHAIN_ENDPOINT: wss://people-rpc.pezkuwichain.io - name: Upload build artifact uses: actions/upload-artifact@v4 diff --git a/web/src/contexts/PezkuwiContext.tsx b/web/src/contexts/PezkuwiContext.tsx index 052ccd8c..864463f4 100644 --- a/web/src/contexts/PezkuwiContext.tsx +++ b/web/src/contexts/PezkuwiContext.tsx @@ -5,9 +5,9 @@ import type { InjectedAccountWithMeta } from '@pezkuwi/extension-inject/types'; import { DEFAULT_ENDPOINT } from '../../../shared/blockchain/pezkuwi'; import { isMobileApp, getNativeWalletAddress, getNativeAccountName } from '@/lib/mobile-bridge'; -// Parachain endpoints -const ASSET_HUB_ENDPOINT = 'wss://asset-hub-rpc.pezkuwichain.io'; -const PEOPLE_CHAIN_ENDPOINT = 'wss://people-rpc.pezkuwichain.io'; +// Teyrchain endpoints (from environment or defaults) +const ASSET_HUB_ENDPOINT = import.meta.env.VITE_ASSET_HUB_ENDPOINT || 'wss://asset-hub-rpc.pezkuwichain.io'; +const PEOPLE_CHAIN_ENDPOINT = import.meta.env.VITE_PEOPLE_CHAIN_ENDPOINT || 'wss://people-rpc.pezkuwichain.io'; interface PezkuwiContextType { api: ApiPromise | null; @@ -65,11 +65,19 @@ export const PezkuwiProvider: React.FC = ({ // Initialize Pezkuwi API with fallback endpoints useEffect(() => { + // Hardcoded production fallbacks ensure app works even if env vars are missing + const PRODUCTION_FALLBACKS = [ + 'wss://rpc.pezkuwichain.io:9944', + 'wss://mainnet.pezkuwichain.io', + 'wss://beta.pezkuwichain.io', + ]; + const FALLBACK_ENDPOINTS = [ endpoint, import.meta.env.VITE_WS_ENDPOINT_FALLBACK_1, import.meta.env.VITE_WS_ENDPOINT_FALLBACK_2, - ].filter(Boolean); + ...PRODUCTION_FALLBACKS, + ].filter((ep, index, arr) => ep && arr.indexOf(ep) === index); // Remove duplicates and empty const initApi = async () => { let lastError: unknown = null; diff --git a/web/src/contexts/WebSocketContext.tsx b/web/src/contexts/WebSocketContext.tsx index 89d26b10..d518c77c 100644 --- a/web/src/contexts/WebSocketContext.tsx +++ b/web/src/contexts/WebSocketContext.tsx @@ -21,15 +21,16 @@ const WebSocketContext = createContext(null); const isLocalhost = typeof window !== 'undefined' && (window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1'); +// WebSocket endpoints for real-time updates (separate from blockchain RPC) +// Note: Real-time WebSocket service is optional - app works without it const ENDPOINTS = isLocalhost ? [ 'ws://localhost:8082', // Local Vite dev server - 'ws://127.0.0.1:9944', // Local development node (primary) - 'ws://localhost:9944', // Local development node (alternative) - 'wss://ws.pezkuwichain.io', // Production WebSocket (fallback) + 'ws://127.0.0.1:8082', // Alternative local server ] : [ - 'wss://ws.pezkuwichain.io', // Production WebSocket only + // Production WebSocket service - currently disabled (service not deployed) + // Will be re-enabled when wss://ws.pezkuwichain.io is deployed ]; export const useWebSocket = () => {