@pioneer-platform/eth-network 8.28.4 → 8.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,39 @@
1
1
  # @pioneer-platform/eth-network
2
2
 
3
+ ## 8.31.0
4
+
5
+ ### Minor Changes
6
+
7
+ - chore: feat(pioneer-sdk): Add ERC-20/BEP-20 token table to portfolio dashboard
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies
12
+ - @pioneer-platform/blockbook@8.30.0
13
+ - @pioneer-platform/nodes@8.28.0
14
+
15
+ ## 8.30.0
16
+
17
+ ### Minor Changes
18
+
19
+ - chore: feat(pioneer-sdk): Add transaction history integration
20
+
21
+ ### Patch Changes
22
+
23
+ - Updated dependencies
24
+ - @pioneer-platform/blockbook@8.29.0
25
+
26
+ ## 8.29.0
27
+
28
+ ### Minor Changes
29
+
30
+ - feat(pioneer-sdk): Add transaction history integration
31
+
32
+ ### Patch Changes
33
+
34
+ - Updated dependencies
35
+ - @pioneer-platform/blockbook@8.28.0
36
+
3
37
  ## 8.28.4
4
38
 
5
39
  ### Patch Changes
package/lib/index.js CHANGED
@@ -316,9 +316,16 @@ const validateNodesOnStartup = async () => {
316
316
  */
317
317
  const init = async function (settings, redis) {
318
318
  const tag = TAG + ' | init | ';
319
- // NOTE: Blockbook is initialized globally by the server with all networks
320
- // Do NOT call blockbook.init() here as it would overwrite the server's initialization
321
- log.debug(tag, 'Blockbook should already be initialized by server for transaction history');
319
+ // CRITICAL: Initialize blockbook if not already initialized (for standalone/test usage)
320
+ // Check if blockbook has been initialized by checking if it has any URLs configured
321
+ const blockbookUrls = blockbook.getBlockbooks ? blockbook.getBlockbooks() : {};
322
+ if (!blockbookUrls || Object.keys(blockbookUrls).length === 0) {
323
+ log.info(tag, 'Blockbook not initialized - initializing now for transaction history support');
324
+ await blockbook.init();
325
+ }
326
+ else {
327
+ log.debug(tag, 'Blockbook already initialized by server');
328
+ }
322
329
  // Initialize node health tracking (with optional Redis)
323
330
  await NodeHealth.initNodeHealth(redis);
324
331
  // Load web3 nodes from @pioneer-platform/nodes
@@ -1378,6 +1385,12 @@ exports.getTransactionByNetwork = getTransactionByNetwork;
1378
1385
  const getTransactionsByNetwork = async function (networkId, address, options = {}) {
1379
1386
  let tag = TAG + ' | getTransactionsByNetwork | ';
1380
1387
  try {
1388
+ // Auto-initialize blockbook if not already initialized
1389
+ const blockbookUrls = blockbook.getBlockbooks ? blockbook.getBlockbooks() : {};
1390
+ if (!blockbookUrls || Object.keys(blockbookUrls).length === 0) {
1391
+ log.info(tag, 'Blockbook not initialized - initializing now');
1392
+ await blockbook.init();
1393
+ }
1381
1394
  log.info(tag, `Fetching transactions for ${address} on ${networkId}`);
1382
1395
  // Normalize address to checksummed format
1383
1396
  let checksummedAddress;
@@ -1388,27 +1401,29 @@ const getTransactionsByNetwork = async function (networkId, address, options = {
1388
1401
  log.error(tag, `Invalid Ethereum address format: ${address} - ${e.message}`);
1389
1402
  throw new Error(`Invalid Ethereum address: ${address}`);
1390
1403
  }
1391
- // Determine which coin symbol to use for Blockbook
1392
- // ETH mainnet uses "ETH", other networks would need mapping
1393
- let coinSymbol = 'ETH'; // Default to ETH mainnet
1394
- // Map network ID to Blockbook coin symbol
1395
- const networkToCoin = {
1404
+ // Map networkId to Blockbook coin symbol
1405
+ // Blockbook uses coin symbols ('ETH'), not networkIds ('eip155:1')
1406
+ const networkToSymbol = {
1396
1407
  'eip155:1': 'ETH', // Ethereum Mainnet
1397
- 'eip155:137': 'MATIC', // Polygon (if supported)
1398
- 'eip155:56': 'BSC', // BSC (if supported)
1408
+ 'eip155:137': 'MATIC', // Polygon
1409
+ 'eip155:56': 'BSC', // BSC
1410
+ 'eip155:43114': 'AVAX', // Avalanche C-Chain
1411
+ 'eip155:250': 'FTM', // Fantom
1412
+ 'eip155:42161': 'ARB', // Arbitrum
1413
+ 'eip155:10': 'OP', // Optimism
1414
+ 'eip155:8453': 'BASE', // Base
1399
1415
  // Add more as needed
1400
1416
  };
1401
- if (networkToCoin[networkId]) {
1402
- coinSymbol = networkToCoin[networkId];
1403
- }
1404
- else {
1405
- log.warn(tag, `Unknown networkId ${networkId}, defaulting to ETH`);
1417
+ const coinSymbol = networkToSymbol[networkId];
1418
+ if (!coinSymbol) {
1419
+ log.warn(tag, `Unknown networkId ${networkId} for Blockbook - no transaction history available`);
1420
+ return [];
1406
1421
  }
1407
1422
  // Fetch address info from Blockbook with transaction details
1408
1423
  const page = options?.page || 1;
1409
1424
  const pageSize = options?.pageSize || 1000; // Max transactions per page
1410
- log.info(tag, `Fetching from Blockbook: ${coinSymbol} address ${checksummedAddress} page ${page} pageSize ${pageSize}`);
1411
- // Use Blockbook to get address info with transactions
1425
+ log.info(tag, `Fetching from Blockbook: ${coinSymbol} (${networkId}) address ${checksummedAddress} page ${page} pageSize ${pageSize}`);
1426
+ // Use Blockbook to get address info with transactions - pass symbol
1412
1427
  const addressInfo = await blockbook.getAddressInfo(coinSymbol, checksummedAddress, 'txs', { page, pageSize });
1413
1428
  if (!addressInfo || !addressInfo.transactions) {
1414
1429
  log.warn(tag, 'No transactions found for address');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pioneer-platform/eth-network",
3
- "version": "8.28.4",
3
+ "version": "8.31.0",
4
4
  "main": "./lib/index.js",
5
5
  "types": "./lib/index.d.ts",
6
6
  "scripts": {
@@ -18,9 +18,9 @@
18
18
  "@ethersproject/abstract-provider": "^5.8.0",
19
19
  "@ethersproject/bignumber": "^5.8.0",
20
20
  "@ethersproject/providers": "^5.8.0",
21
- "@pioneer-platform/blockbook": "^8.27.5",
21
+ "@pioneer-platform/blockbook": "^8.30.0",
22
22
  "@pioneer-platform/loggerdog": "^8.11.0",
23
- "@pioneer-platform/nodes": "^8.26.2",
23
+ "@pioneer-platform/nodes": "^8.28.0",
24
24
  "@pioneer-platform/pioneer-caip": "^9.19.0",
25
25
  "@xchainjs/xchain-client": "0.9.0",
26
26
  "@xchainjs/xchain-util": "0.2.6",