/** * Pocket Discovery Test * * Usage: npx ts-node test-pocket-discovery.ts */ import { EVMVM } from './utils/evm/evm'; import { SVMVM } from './utils/svm/svm'; import { JsonRpcProvider } from 'ethers'; import { Connection } from '@solana/web3.js'; import { DiscoveredWallet } from './utils/types'; const MNEMONIC = 'olive gasp beach rug swift voice during during differ reject reunion rib'; async function testEVMPocketDiscovery() { console.log('╔════════════════════════════════════════════════╗'); console.log('║ EVM Pocket Discovery Test ║'); console.log('╚════════════════════════════════════════════════╝\n'); const evmVM = EVMVM.fromMnemonic(MNEMONIC) as EVMVM; const provider = new JsonRpcProvider('https://eth.llamarpc.com'); console.log('Network: Ethereum Mainnet'); console.log('Wallet Index: 0'); console.log('Checking pockets 0-10...\n'); const result = await evmVM.discoverPockets(provider, { walletIndex: 0, startIndex: 0, maxIndex: 10, gapLimit: 20, onProgress: (current: number, total: number, found: number) => { process.stdout.write(`\rProgress: ${current}/${total} pockets checked, ${found} with funds`); }, onDiscovered: (pocket: DiscoveredWallet) => { console.log(`\n✓ Pocket ${pocket.index}: ${pocket.address}`); console.log(` Balance: ${pocket.nativeBalance.formatted} ETH`); console.log(` Path: ${pocket.derivationPath}`); } }); console.log(`\n\n✅ EVM Complete: ${result.discovered.length} pockets found in ${result.duration}ms\n`); } async function testSVMPocketDiscovery() { console.log('╔════════════════════════════════════════════════╗'); console.log('║ SVM Pocket Discovery Test ║'); console.log('╚════════════════════════════════════════════════╝\n'); const svmVM = SVMVM.fromMnemonic(MNEMONIC) as SVMVM; const connection = new Connection('https://api.mainnet-beta.solana.com'); console.log('Network: Solana Mainnet'); console.log('Wallet Index: 0'); console.log('Checking pockets 0-10...\n'); const result = await svmVM.discoverPockets(connection, { walletIndex: 0, startIndex: 0, maxIndex: 10, gapLimit: 20, onProgress: (current: number, total: number, found: number) => { process.stdout.write(`\rProgress: ${current}/${total} pockets checked, ${found} with funds`); }, onDiscovered: (pocket: DiscoveredWallet) => { console.log(`\n✓ Pocket ${pocket.index}: ${pocket.address}`); console.log(` Balance: ${pocket.nativeBalance.formatted} SOL`); console.log(` Path: ${pocket.derivationPath}`); } }); console.log(`\n\n✅ SVM Complete: ${result.discovered.length} pockets found in ${result.duration}ms\n`); } async function main() { console.log('\n🔍 Testing Savings Pocket Discovery\n'); await testEVMPocketDiscovery(); await testSVMPocketDiscovery(); console.log('✨ All pocket discovery tests complete!\n'); } main().catch(console.error);