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
This commit is contained in:
2026-02-04 12:19:29 +03:00
parent 468e8d18f0
commit 91e14bf200
3 changed files with 24 additions and 8 deletions
+7
View File
@@ -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
+12 -4
View File
@@ -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<PezkuwiProviderProps> = ({
// 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;
+5 -4
View File
@@ -21,15 +21,16 @@ const WebSocketContext = createContext<WebSocketContextType | null>(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 = () => {