| … | … | @@ -822,8 +822,20 @@ async function syncTransactionsFromWDK(wdk, config = {}) { |
| 822 | 822 | |
| 823 | 823 | for (const chain of chains) { |
| 824 | 824 | try { |
| 825 | | // Get WDK account for this chain |
| 826 | | const account = await wdk.getAccount(chain, 0) |
| 825 | // Determine base chain for WDK (ethereum-usdt -> ethereum) |
| 826 | const baseChain = chain.replace(/-usdt$/, '') |
| 827 | |
| 828 | // Get current address index from storage |
| 829 | // For USDT, check both ethereum-usdt and ethereum (they share addresses) |
| 830 | let currentAddr = await getCurrentAddress(`${config.network ? config.network + '-' : ''}${chain}`) |
| 831 | if (!currentAddr && chain.includes('usdt')) { |
| 832 | // Try base chain if token chain not found |
| 833 | currentAddr = await getCurrentAddress(`${config.network ? config.network + '-' : ''}${baseChain}`) |
| 834 | } |
| 835 | const accountIndex = currentAddr ? currentAddr.index : 0 |
| 836 | |
| 837 | // Get WDK account for this chain at the correct index |
| 838 | const account = await wdk.getAccount(baseChain, accountIndex) |
| 827 | 839 | if (!account) { |
| 828 | 840 | results.errors.push(`No account found for chain: ${chain}`) |
| 829 | 841 | continue |
| … | … | @@ -884,14 +896,15 @@ async function syncTransactionsFromWDK(wdk, config = {}) { |
| 884 | 896 | chainSynced++ |
| 885 | 897 | results.synced++ |
| 886 | 898 | } |
| 887 | | } else if (chain === 'ethereum') { |
| 888 | | // Ethereum: Fetch transactions from blockchain provider |
| 899 | } else if (baseChain === 'ethereum') { |
| 900 | // Ethereum (including USDT): Fetch transactions from blockchain provider |
| 889 | 901 | try { |
| 890 | 902 | const config = getConfig() |
| 891 | 903 | const network = config.network || 'testnet' |
| 892 | 904 | |
| 893 | 905 | // Fetch transactions using blockchain-providers.cjs |
| 894 | | const providerTxs = await fetchTransactions(chain, currentAddress, network, config) |
| 906 | // Use base chain for provider (ethereum, not ethereum-usdt) |
| 907 | const providerTxs = await fetchTransactions(baseChain, currentAddress, network, config) |
| 895 | 908 | |
| 896 | 909 | for (const tx of providerTxs) { |
| 897 | 910 | // Check if already stored |