feat: Multi-Chain Support Implementation#17
Merged
caxtonacollins merged 18 commits intomainfrom Apr 9, 2026
Merged
Conversation
- Add CORS configuration to Socket.IO server matching Express CORS - Support dynamic ngrok URLs via NGROK_URL environment variable - Allow any *.ngrok-free.app URL via regex pattern - Fixes WebSocket connection failures on ngrok tunnels
- Add polling as fallback transport when websocket fails - Configure reconnection strategy (1-5s delays, 5 attempts) - Improves connection stability on unstable networks like ngrok
- Poll USDC balance every 5 seconds - Handles ngrok's slower response times gracefully - Prevents balance from showing stale or zero values
- Add mounted state to prevent SSR/client mismatch - Prevents hydration errors when chain info is unavailable during SSR - Eliminates flickering on page load
- Add mounted state to prevent SSR/client mismatch - Prevents hydration errors when chain switching is unavailable during SSR - Eliminates flickering on page load
- Add mounted state to prevent SSR/client mismatch - Return minimal header during SSR to avoid wallet-dependent rendering - Prevents hydration errors and wallet connection flickering
- Read NGROK_URL from environment variable - Add ngrok URL to allowedDevOrigins at build time - Fixes 'Blocked cross-origin request' errors for /_next/* resources
- Add frontend/.env.example with API/WS URL setup instructions - Add NGROK_URL documentation to backend/.env.example - Include commented examples for ngrok configuration
- Add getChainConfig() to support both numeric chain IDs and string keys - Validates chain configuration and contract address availability - Provides clear error messages for unsupported chains
- Add optional chainId parameter to constructor - Store chainId as instance property for reference - Add contract debugging logs for troubleshooting - Improve error logging with additional context (player, amount, roundId)
- Add optional chainId parameter to placeBet() method - Add optional chainId parameter to cashOutById() method - Create chain-specific ChainService instances when chainId provided - Improve error logging with chainId context
- Add chainId parameter to placeBet endpoint - Add chainId parameter to cashOut endpoint - Pass chainId through to GameEngine methods
- Remove global chainService instance - Add getChainServiceForRequest() helper for chain-specific operations - Update all admin endpoints to support chainId parameter - Include chain info (label, chainId) in all responses - Support chainId from both request body and query parameters
- Add chainId parameter to placeBetRest() and cashOutRest() - Add admin API functions for contract management: - adminFetchContractStatus() - adminGetHouseBalance() - adminWithdrawHouse() - adminFundHouse() - adminPauseContract() - adminUnpauseContract() - adminSetOperator() - adminWithdrawETH() - All admin functions support optional chainId parameter
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Multi-Chain Support Implementation for betting
Overview
This PR adds comprehensive multi-chain support to the Aviator game, enabling operations across Base and Celo networks.
Key Changes
Backend
backend/src/config/chains.ts): Centralized chain configuration with support for Base (8453) and Celo (42220), including RPC URLs, contract addresses, and explorer linkschainIdparameter for chain-specific operationsFrontend
frontend/lib/api.ts): All admin and game functions now supportchainIdparameter for multi-chain operationsfrontend/app/admin/page.tsx): Refactored UI to allow switching between chains and managing operations per chainfrontend/hooks/useGame.ts): Enhanced to supportchainIdparameter for chain-aware game stateImpact
Files Changed
backend/src/config/chains.ts(new)backend/src/routes/admin.tsbackend/src/routes/rounds.tsbackend/src/services/chain.service.tsbackend/src/services/game-engine.service.tsbackend/src/__tests__/chain.service.spec.tsfrontend/lib/api.tsfrontend/app/admin/page.tsxfrontend/hooks/useGame.ts.gitignore