🚀 Fix Drift Protocol integration - Connection now working
✅ Key fixes: - Bypass problematic SDK subscription that caused 410 Gone errors - Use direct account verification without subscription - Add fallback modes for better reliability - Switch to Helius RPC endpoint for better rate limits - Implement proper error handling and retry logic 🔧 Technical changes: - Enhanced drift-trading.ts with no-subscription approach - Added Drift API endpoints (/api/drift/login, /balance, /positions) - Created DriftAccountStatus and DriftTradingPanel components - Updated Dashboard.tsx to show Drift account status - Added comprehensive test scripts for debugging 📊 Results: - Connection Status: Connected ✅ - Account verification: Working ✅ - Balance retrieval: Working ✅ (21.94 total collateral) - Private key authentication: Working ✅ - User account: 3dG7wayp7b9NBMo92D2qL2sy1curSC4TTmskFpaGDrtA 🌐 RPC improvements: - Using Helius RPC for better reliability - Added fallback RPC options in .env - Eliminated rate limiting issues
This commit is contained in:
47
test-basic-setup.js
Normal file
47
test-basic-setup.js
Normal file
@@ -0,0 +1,47 @@
|
||||
require('dotenv').config();
|
||||
const { Connection, Keypair } = require('@solana/web3.js');
|
||||
|
||||
async function testBasicSetup() {
|
||||
console.log('🔍 Testing basic wallet setup...');
|
||||
|
||||
try {
|
||||
// Test environment variables
|
||||
console.log('📋 Environment check:');
|
||||
console.log('- SOLANA_RPC_URL:', process.env.SOLANA_RPC_URL ? '✅ Set' : '❌ Missing');
|
||||
console.log('- SOLANA_PRIVATE_KEY:', process.env.SOLANA_PRIVATE_KEY ? '✅ Set' : '❌ Missing');
|
||||
|
||||
if (!process.env.SOLANA_PRIVATE_KEY) {
|
||||
throw new Error('SOLANA_PRIVATE_KEY not found in environment');
|
||||
}
|
||||
|
||||
// Test keypair creation
|
||||
console.log('\n🔑 Testing keypair creation...');
|
||||
const secret = process.env.SOLANA_PRIVATE_KEY;
|
||||
const keypair = Keypair.fromSecretKey(Buffer.from(JSON.parse(secret)));
|
||||
console.log('✅ Keypair created successfully');
|
||||
console.log('🔑 Public key:', keypair.publicKey.toString());
|
||||
|
||||
// Test connection
|
||||
console.log('\n🌐 Testing Solana connection...');
|
||||
const rpcUrl = process.env.SOLANA_RPC_URL || 'https://api.mainnet-beta.solana.com';
|
||||
const connection = new Connection(rpcUrl, 'confirmed');
|
||||
|
||||
// Test balance check
|
||||
const balance = await connection.getBalance(keypair.publicKey);
|
||||
console.log('✅ Connection successful');
|
||||
console.log('💰 SOL Balance:', (balance / 1e9).toFixed(4), 'SOL');
|
||||
|
||||
if (balance === 0) {
|
||||
console.log('⚠️ Warning: Wallet has 0 SOL balance. You need SOL for transactions.');
|
||||
}
|
||||
|
||||
console.log('\n✅ Basic setup is working correctly!');
|
||||
console.log('🔄 The issue might be with Drift SDK or user account initialization.');
|
||||
|
||||
} catch (error) {
|
||||
console.error('❌ Basic setup failed:', error.message);
|
||||
console.error('Stack:', error.stack);
|
||||
}
|
||||
}
|
||||
|
||||
testBasicSetup().catch(console.error);
|
||||
Reference in New Issue
Block a user