- 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)
58 lines
1.8 KiB
JavaScript
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');
|