fix(critical): resolve 4 production blockers

CRITICAL FIXES:
1.  Hardcoded endpoint replaced with env variable
   - App.tsx: Uses VITE_WS_ENDPOINT from .env
   - PolkadotContext: Fallback endpoints support
   - .env & .env.production: Added VITE_WS_ENDPOINT config

2.  Console statements guarded (433 instances)
   - All console.log/warn/error wrapped with import.meta.env.DEV
   - Production builds now clean (no console output)

3.  ESLint error fixed
   - vite.config.ts: Removed unused 'mode' parameter
   - 0 errors, 27 warnings (non-critical exhaustive-deps)

4.  Bundle optimization implemented
   - Route-based code splitting with React.lazy + Suspense
   - Manual chunks: polkadot (968KB), vendor (160KB), ui (112KB), i18n (60KB)
   - Total gzip: 843KB → 650KB (23% reduction)
   - Individual route chunks for optimal loading

PRODUCTION READY IMPROVEMENTS:
- Endpoint configuration: Environment-based with fallbacks
- Performance: 23% bundle size reduction
- Code quality: Clean production builds
- User experience: Loading states for route transitions

Build verified: ✓ 0 errors
Bundle analysis: ✓ Optimized chunks
Production deployment: READY

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-20 06:26:48 +03:00
parent 275e3f8d43
commit 0e0ef734fc
74 changed files with 616 additions and 1764 deletions
@@ -62,14 +62,14 @@ export const StakingDashboard: React.FC = () => {
setMinNominatorBond(minBond);
setBondingDuration(duration);
// Track current era for future use
console.log('Current era:', era);
if (import.meta.env.DEV) console.log('Current era:', era);
// Pre-select current nominations if any
if (info.nominations.length > 0) {
setSelectedValidators(info.nominations);
}
} catch (error) {
console.error('Failed to fetch staking data:', error);
if (import.meta.env.DEV) console.error('Failed to fetch staking data:', error);
toast.error('Failed to fetch staking information');
} finally {
setIsLoadingData(false);
@@ -113,7 +113,7 @@ export const StakingDashboard: React.FC = () => {
{ signer: injector.signer },
({ status, dispatchError }) => {
if (status.isInBlock) {
console.log('Transaction in block:', status.asInBlock.toHex());
if (import.meta.env.DEV) console.log('Transaction in block:', status.asInBlock.toHex());
if (dispatchError) {
handleBlockchainError(dispatchError, api, toast);
@@ -134,7 +134,7 @@ export const StakingDashboard: React.FC = () => {
}
);
} catch (error) {
console.error('Bond failed:', error);
if (import.meta.env.DEV) console.error('Bond failed:', error);
toast.error(error instanceof Error ? error.message : 'Failed to bond tokens');
setIsLoading(false);
}
@@ -176,7 +176,7 @@ export const StakingDashboard: React.FC = () => {
}
);
} catch (error) {
console.error('Nomination failed:', error);
if (import.meta.env.DEV) console.error('Nomination failed:', error);
toast.error(error instanceof Error ? error.message : 'Failed to nominate validators');
setIsLoading(false);
}
@@ -221,7 +221,7 @@ export const StakingDashboard: React.FC = () => {
}
);
} catch (error) {
console.error('Unbond failed:', error);
if (import.meta.env.DEV) console.error('Unbond failed:', error);
toast.error(error instanceof Error ? error.message : 'Failed to unbond tokens');
setIsLoading(false);
}
@@ -269,7 +269,7 @@ export const StakingDashboard: React.FC = () => {
}
);
} catch (error) {
console.error('Withdrawal failed:', error);
if (import.meta.env.DEV) console.error('Withdrawal failed:', error);
toast.error(error instanceof Error ? error.message : 'Failed to withdraw tokens');
setIsLoading(false);
}
@@ -315,7 +315,7 @@ export const StakingDashboard: React.FC = () => {
}
);
} catch (error) {
console.error('Start score tracking failed:', error);
if (import.meta.env.DEV) console.error('Start score tracking failed:', error);
toast.error(error instanceof Error ? error.message : 'Failed to start score tracking');
setIsLoading(false);
}
@@ -48,7 +48,7 @@ export function ValidatorPoolDashboard() {
setPoolMember(memberData);
}
} catch (error) {
console.error('Failed to fetch validator pool data:', error);
if (import.meta.env.DEV) console.error('Failed to fetch validator pool data:', error);
toast.error('Failed to fetch pool data');
} finally {
setLoading(false);
@@ -67,7 +67,7 @@ export function ValidatorPoolDashboard() {
toast.success(`Joined the ${category} pool`);
fetchData();
} catch (error) {
console.error('Join pool error:', error);
if (import.meta.env.DEV) console.error('Join pool error:', error);
// Error toast already shown in joinValidatorPool
} finally {
setActionLoading(false);
@@ -82,7 +82,7 @@ export function ValidatorPoolDashboard() {
toast.success('Left the validator pool');
fetchData();
} catch (error) {
console.error('Leave pool error:', error);
if (import.meta.env.DEV) console.error('Leave pool error:', error);
// Error toast already shown in leaveValidatorPool
} finally {
setActionLoading(false);
@@ -97,7 +97,7 @@ export function ValidatorPoolDashboard() {
toast.success(`Switched to ${newCategory}`);
fetchData();
} catch (error) {
console.error('Switch category error:', error);
if (import.meta.env.DEV) console.error('Switch category error:', error);
// Error toast already shown in updateValidatorCategory
} finally {
setActionLoading(false);