| … | … | @@ -826,14 +826,24 @@ const routes = { |
| 826 | 826 | return sendError(res, 'Wallet not initialized', 400) |
| 827 | 827 | } |
| 828 | 828 | |
| 829 | | const { initializeWDK } = require('./lib/wdk-integration.cjs') |
| 829 | const { initializeWDK, getBaseChain } = require('./lib/wdk-integration.cjs') |
| 830 | 830 | const { wdk } = await initializeWDK(walletMnemonic, { testnet: true }) |
| 831 | 831 | |
| 832 | | // Sync transactions |
| 832 | // Get chain name and current account index |
| 833 | 833 | const chainName = chain.replace(/^(testnet|mainnet)-/, '') |
| 834 | const baseChain = getBaseChain(chainName) || chainName |
| 835 | |
| 836 | // Get current address index for this chain |
| 837 | const currentAddr = await getCurrentAddress(baseChain) |
| 838 | const accountIndex = currentAddr ? currentAddr.index : 0 |
| 839 | |
| 840 | console.log(`📡 Syncing transactions for ${chainName} account ${accountIndex}`) |
| 841 | |
| 842 | // Sync transactions for the current account |
| 834 | 843 | const result = await syncTransactionsFromWDK(wdk, { |
| 835 | 844 | chains: [chainName], |
| 836 | | network: 'testnet' |
| 845 | network: 'testnet', |
| 846 | accountIndex: accountIndex |
| 837 | 847 | }) |
| 838 | 848 | |
| 839 | 849 | sendJSON(res, { |