@pioneer-platform/eth-network 8.13.15 → 8.14.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/.turbo/turbo-build.log +1 -2
- package/CHANGELOG.md +19 -0
- package/lib/index.d.ts +7 -0
- package/lib/index.js +39 -21
- package/package.json +2 -2
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
[0m[2m[35m$[0m [2m[1mtsc -p .[0m
|
|
1
|
+
$ tsc -p .
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @pioneer-platform/eth-network
|
|
2
2
|
|
|
3
|
+
## 8.14.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Merge branch 'feature/ethereum-reports'
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
- @pioneer-platform/blockbook@8.12.0
|
|
13
|
+
|
|
14
|
+
## 8.13.16
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- cache work
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
- @pioneer-platform/blockbook@8.11.6
|
|
21
|
+
|
|
3
22
|
## 8.13.15
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
package/lib/index.d.ts
CHANGED
|
@@ -18,6 +18,8 @@ export declare const addNode: (node: any) => number;
|
|
|
18
18
|
export declare const addNodes: (nodeList: any) => void;
|
|
19
19
|
/**
|
|
20
20
|
* Get nonce for address
|
|
21
|
+
* @deprecated Use getNonceByNetwork instead - this method relies on environment variables
|
|
22
|
+
* and does not use the node racing/fallback system
|
|
21
23
|
*/
|
|
22
24
|
export declare const getNonce: (address: string) => Promise<any>;
|
|
23
25
|
/**
|
|
@@ -26,6 +28,8 @@ export declare const getNonce: (address: string) => Promise<any>;
|
|
|
26
28
|
export declare const getNonceByNetwork: (networkId: string, address: string) => Promise<number>;
|
|
27
29
|
/**
|
|
28
30
|
* Get current gas price
|
|
31
|
+
* @deprecated Use getGasPriceByNetwork instead - this method relies on environment variables
|
|
32
|
+
* and does not use the node racing/fallback system
|
|
29
33
|
*/
|
|
30
34
|
export declare const getGasPrice: () => Promise<any>;
|
|
31
35
|
/**
|
|
@@ -38,10 +42,13 @@ export declare const getGasPriceByNetwork: (networkId: string) => Promise<import
|
|
|
38
42
|
export declare const estimateFee: (asset: any, params: any) => Promise<any>;
|
|
39
43
|
/**
|
|
40
44
|
* Get ETH balance for address
|
|
45
|
+
* @deprecated Use getBalanceAddressByNetwork instead - this method relies on environment variables
|
|
46
|
+
* and does not use the node racing/fallback system with health tracking
|
|
41
47
|
*/
|
|
42
48
|
export declare const getBalance: (address: string) => Promise<string>;
|
|
43
49
|
/**
|
|
44
50
|
* Get balances for multiple addresses
|
|
51
|
+
* @deprecated Use getBalanceAddressByNetwork in a loop instead - this method relies on environment variables
|
|
45
52
|
*/
|
|
46
53
|
export declare const getBalances: (addresses: string[]) => Promise<string[]>;
|
|
47
54
|
/**
|
package/lib/index.js
CHANGED
|
@@ -64,7 +64,8 @@ const NodeHealth = __importStar(require("./node-health"));
|
|
|
64
64
|
const log = require('@pioneer-platform/loggerdog')();
|
|
65
65
|
let wait = require('wait-promise');
|
|
66
66
|
let sleep = wait.sleep;
|
|
67
|
-
//
|
|
67
|
+
// Legacy provider instances - DEPRECATED, kept for backward compatibility only
|
|
68
|
+
// All production methods should use *ByNetwork variants with node racing
|
|
68
69
|
let ETHERSCAN;
|
|
69
70
|
let PROVIDER;
|
|
70
71
|
let PROVIDER_BASE;
|
|
@@ -112,14 +113,14 @@ const TIER_PRIORITY = {
|
|
|
112
113
|
// - VALIDATE_NODES_ON_STARTUP: Set to 'false' to disable background validation (default: enabled)
|
|
113
114
|
// - STARTUP_NODE_TIMEOUT: Timeout per node in ms (default: 3000)
|
|
114
115
|
// - STARTUP_NODE_CONCURRENCY: Number of parallel validation workers (default: 20)
|
|
115
|
-
// - STARTUP_VALIDATION_TIER: Comma-separated tiers to validate on startup (default: 'premium,reliable')
|
|
116
|
+
// - STARTUP_VALIDATION_TIER: Comma-separated tiers to validate on startup (default: 'premium,reliable,public')
|
|
116
117
|
// - STARTUP_NODE_SAMPLE: Number of random nodes to test per tier (default: 0 = all)
|
|
117
118
|
//
|
|
118
119
|
// Note: Validation runs in background and does NOT block server startup
|
|
119
120
|
const STARTUP_VALIDATION_ENABLED = process.env.VALIDATE_NODES_ON_STARTUP !== 'false'; // Default true
|
|
120
121
|
const STARTUP_VALIDATION_TIMEOUT = parseInt(process.env.STARTUP_NODE_TIMEOUT || '3000'); // 3s timeout
|
|
121
122
|
const STARTUP_VALIDATION_CONCURRENCY = parseInt(process.env.STARTUP_NODE_CONCURRENCY || '20'); // 20 parallel
|
|
122
|
-
const STARTUP_VALIDATION_TIERS = (process.env.STARTUP_VALIDATION_TIER || 'premium,reliable').split(',');
|
|
123
|
+
const STARTUP_VALIDATION_TIERS = (process.env.STARTUP_VALIDATION_TIER || 'premium,reliable,public').split(',');
|
|
123
124
|
const STARTUP_VALIDATION_SAMPLE_SIZE = parseInt(process.env.STARTUP_NODE_SAMPLE || '0'); // 0 = all nodes in tier
|
|
124
125
|
/**
|
|
125
126
|
* Check if a node is marked as dead
|
|
@@ -291,26 +292,22 @@ const init = async function (settings, redis) {
|
|
|
291
292
|
log.error(tag, 'Background node validation failed:', err);
|
|
292
293
|
});
|
|
293
294
|
}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
295
|
+
// DEPRECATED: Legacy provider initialization for backward compatibility
|
|
296
|
+
// Modern code should use *ByNetwork methods which leverage the full node racing system
|
|
297
|
+
// These globals are only initialized for legacy methods (getNonce, getBalance, etc.)
|
|
298
|
+
// and are NOT used by production endpoints in evm.controller.ts
|
|
299
|
+
// Only initialize Etherscan for legacy compatibility
|
|
300
|
+
if (process.env['ETHERSCAN_API_KEY']) {
|
|
298
301
|
ETHERSCAN = new providers_1.EtherscanProvider('mainnet', process.env['ETHERSCAN_API_KEY']);
|
|
299
|
-
NODE_URL = process.env['PARITY_ARCHIVE_NODE'] || 'https://eth.llamarpc.com';
|
|
300
|
-
}
|
|
301
|
-
else if (settings.testnet) {
|
|
302
|
-
if (!process.env['INFURA_TESTNET_ROPSTEN'])
|
|
303
|
-
throw Error("Missing INFURA_TESTNET_ROPSTEN");
|
|
304
|
-
if (!process.env['ETHERSCAN_API_KEY'])
|
|
305
|
-
throw Error("Missing ETHERSCAN_API_KEY");
|
|
306
|
-
PROVIDER = new ethers.providers.JsonRpcProvider(process.env['INFURA_TESTNET_ROPSTEN']);
|
|
307
|
-
NODE_URL = process.env['INFURA_TESTNET_ROPSTEN'];
|
|
308
|
-
ETHERSCAN = new providers_1.EtherscanProvider('ropsten', process.env['ETHERSCAN_API_KEY']);
|
|
309
|
-
}
|
|
310
|
-
else {
|
|
311
|
-
PROVIDER = new ethers.providers.JsonRpcProvider(process.env['PARITY_ARCHIVE_NODE'] || 'https://eth.llamarpc.com');
|
|
312
302
|
}
|
|
303
|
+
// REMOVED: PROVIDER, PROVIDER_BASE, NODE_URL initialization
|
|
304
|
+
// These environment variables are no longer needed because:
|
|
305
|
+
// 1. All production methods use *ByNetwork variants
|
|
306
|
+
// 2. Node racing system provides superior reliability and performance
|
|
307
|
+
// 3. 1200+ validated nodes vs single environment variable endpoint
|
|
308
|
+
// 4. Automatic failover, health tracking, and tier-based routing
|
|
313
309
|
log.info(tag, 'ETH network module initialized successfully');
|
|
310
|
+
log.info(tag, '✅ Using node racing system for all operations (no env dependencies)');
|
|
314
311
|
};
|
|
315
312
|
exports.init = init;
|
|
316
313
|
/**
|
|
@@ -347,8 +344,12 @@ const addNodes = function (nodeList) {
|
|
|
347
344
|
exports.addNodes = addNodes;
|
|
348
345
|
/**
|
|
349
346
|
* Get nonce for address
|
|
347
|
+
* @deprecated Use getNonceByNetwork instead - this method relies on environment variables
|
|
348
|
+
* and does not use the node racing/fallback system
|
|
350
349
|
*/
|
|
351
350
|
const getNonce = async function (address) {
|
|
351
|
+
if (!PROVIDER)
|
|
352
|
+
throw Error('PROVIDER not initialized - use getNonceByNetwork instead');
|
|
352
353
|
return await PROVIDER.getTransactionCount(address, 'pending');
|
|
353
354
|
};
|
|
354
355
|
exports.getNonce = getNonce;
|
|
@@ -361,7 +362,13 @@ const getNonceByNetwork = async function (networkId, address) {
|
|
|
361
362
|
let node = NODES.find((n) => n.networkId === networkId);
|
|
362
363
|
if (!node)
|
|
363
364
|
throw Error(`Node not found for networkId: ${networkId}`);
|
|
364
|
-
|
|
365
|
+
// Extract chain ID from networkId (e.g., "eip155:1" -> 1)
|
|
366
|
+
let chainId;
|
|
367
|
+
if (networkId.includes(':')) {
|
|
368
|
+
chainId = parseInt(networkId.split(':')[1]);
|
|
369
|
+
}
|
|
370
|
+
// Use StaticJsonRpcProvider to skip network auto-detection
|
|
371
|
+
const provider = new ethers.providers.StaticJsonRpcProvider(node.service, chainId ? { chainId, name: node.networkId } : undefined);
|
|
365
372
|
return await withTimeout(provider.getTransactionCount(address, 'pending'), RPC_TIMEOUT_MS, `Nonce fetch timeout after ${RPC_TIMEOUT_MS}ms`);
|
|
366
373
|
}
|
|
367
374
|
catch (e) {
|
|
@@ -372,8 +379,12 @@ const getNonceByNetwork = async function (networkId, address) {
|
|
|
372
379
|
exports.getNonceByNetwork = getNonceByNetwork;
|
|
373
380
|
/**
|
|
374
381
|
* Get current gas price
|
|
382
|
+
* @deprecated Use getGasPriceByNetwork instead - this method relies on environment variables
|
|
383
|
+
* and does not use the node racing/fallback system
|
|
375
384
|
*/
|
|
376
385
|
const getGasPrice = async function () {
|
|
386
|
+
if (!PROVIDER)
|
|
387
|
+
throw Error('PROVIDER not initialized - use getGasPriceByNetwork instead');
|
|
377
388
|
return await PROVIDER.getGasPrice();
|
|
378
389
|
};
|
|
379
390
|
exports.getGasPrice = getGasPrice;
|
|
@@ -471,9 +482,13 @@ const estimateFee = async function (asset, params) {
|
|
|
471
482
|
exports.estimateFee = estimateFee;
|
|
472
483
|
/**
|
|
473
484
|
* Get ETH balance for address
|
|
485
|
+
* @deprecated Use getBalanceAddressByNetwork instead - this method relies on environment variables
|
|
486
|
+
* and does not use the node racing/fallback system with health tracking
|
|
474
487
|
*/
|
|
475
488
|
const getBalance = async function (address) {
|
|
476
489
|
let tag = TAG + ' | getBalance | ';
|
|
490
|
+
if (!PROVIDER)
|
|
491
|
+
throw Error('PROVIDER not initialized - use getBalanceAddressByNetwork instead');
|
|
477
492
|
try {
|
|
478
493
|
const balance = await PROVIDER.getBalance(address);
|
|
479
494
|
return ethers.utils.formatEther(balance);
|
|
@@ -486,9 +501,12 @@ const getBalance = async function (address) {
|
|
|
486
501
|
exports.getBalance = getBalance;
|
|
487
502
|
/**
|
|
488
503
|
* Get balances for multiple addresses
|
|
504
|
+
* @deprecated Use getBalanceAddressByNetwork in a loop instead - this method relies on environment variables
|
|
489
505
|
*/
|
|
490
506
|
const getBalances = async function (addresses) {
|
|
491
507
|
let tag = TAG + ' | getBalances | ';
|
|
508
|
+
if (!PROVIDER)
|
|
509
|
+
throw Error('PROVIDER not initialized - use getBalanceAddressByNetwork instead');
|
|
492
510
|
try {
|
|
493
511
|
const promises = addresses.map(addr => PROVIDER.getBalance(addr));
|
|
494
512
|
const balances = await Promise.all(promises);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pioneer-platform/eth-network",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.14.0",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"types": "./lib/index.d.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -18,7 +18,7 @@
|
|
|
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.
|
|
21
|
+
"@pioneer-platform/blockbook": "^8.12.0",
|
|
22
22
|
"@pioneer-platform/loggerdog": "^8.11.0",
|
|
23
23
|
"@pioneer-platform/nodes": "^8.11.10",
|
|
24
24
|
"@pioneer-platform/pioneer-caip": "^9.10.0",
|