immortal-bnb/check-env.js
caelum0x 28e5c4997a โœจ Fix TypeScript errors & add Polymarket agents submodule
- Fixed all 25 TypeScript compilation errors in frontend
- Updated usePolling hook interface for cleaner usage
- Added proper type exports for API functions
- Fixed Dashboard profitChange null safety
- Added wallet validation in config
- Created wallet setup utilities (check-env.js, generate-wallet.js)
- Added Polymarket agents as git submodule
- Added comprehensive documentation (TYPESCRIPT_FIXES.md, WALLET_SETUP.md, GIT_SUBMODULES.md)
2025-11-11 19:06:10 +03:00

58 lines
1.8 KiB
JavaScript

#!/usr/bin/env node
/**
* Check environment configuration
*/
require('dotenv').config();
console.log('\n๐Ÿ” Checking Environment Configuration...\n');
// Check WALLET_PRIVATE_KEY
const privateKey = process.env.WALLET_PRIVATE_KEY;
if (!privateKey) {
console.error('โŒ WALLET_PRIVATE_KEY is not set in .env file');
console.log('\n๐Ÿ“ To fix this:');
console.log(' 1. Open your .env file');
console.log(' 2. Add: WALLET_PRIVATE_KEY=0x...(your 64 character hex private key)');
console.log(' 3. Make sure it\'s 64 hex characters (or 66 with 0x prefix)');
process.exit(1);
}
console.log('โœ… WALLET_PRIVATE_KEY is set');
console.log(` Length: ${privateKey.length} characters`);
// Validate length
if (privateKey.length !== 64 && privateKey.length !== 66) {
console.error(`โŒ Invalid private key length: ${privateKey.length}`);
console.error(' Expected: 64 hex characters OR 66 with "0x" prefix');
console.log('\n๐Ÿ“ Current format: ' + privateKey.substring(0, 10) + '...');
console.log(' Correct format: 0x followed by 64 hex characters');
console.log(' Example: 0x1234567890abcdef... (total 66 chars)');
process.exit(1);
}
// Validate hex format
const hexPattern = /^(0x)?[0-9a-fA-F]+$/;
if (!hexPattern.test(privateKey)) {
console.error('โŒ Private key contains invalid characters');
console.error(' Should only contain: 0-9, a-f, A-F');
process.exit(1);
}
console.log('โœ… Private key format is valid');
// Try to create wallet
try {
const { ethers } = require('ethers');
const wallet = new ethers.Wallet(privateKey);
console.log('โœ… Wallet created successfully');
console.log(` Address: ${wallet.address}`);
} catch (error) {
console.error('โŒ Failed to create wallet:', error.message);
process.exit(1);
}
console.log('\nโœ… All checks passed! Your configuration is valid.\n');