@pioneer-platform/eth-network 8.32.0 → 8.33.1
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 +20 -0
- package/lib/index.d.ts +5 -0
- package/lib/index.js +42 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @pioneer-platform/eth-network
|
|
2
2
|
|
|
3
|
+
## 8.33.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 163653b: chore: fix(swap): Fix critical swap amount bug causing 0 ETH transfers
|
|
8
|
+
- Updated dependencies [163653b]
|
|
9
|
+
- @pioneer-platform/blockbook@8.32.2
|
|
10
|
+
|
|
11
|
+
## 8.33.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- chore: chore: chore: feat(pioneer-sdk): Add ERC-20/BEP-20 token table to portfolio dashboard
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
- @pioneer-platform/blockbook@8.32.0
|
|
21
|
+
- @pioneer-platform/nodes@8.30.0
|
|
22
|
+
|
|
3
23
|
## 8.32.0
|
|
4
24
|
|
|
5
25
|
### Minor Changes
|
package/lib/index.d.ts
CHANGED
|
@@ -26,6 +26,11 @@ export declare const getNonce: (address: string) => Promise<any>;
|
|
|
26
26
|
* Get transaction count by network
|
|
27
27
|
*/
|
|
28
28
|
export declare const getNonceByNetwork: (networkId: string, address: string) => Promise<number>;
|
|
29
|
+
/**
|
|
30
|
+
* Get current block height/number by network
|
|
31
|
+
* Returns the latest block number for the specified EVM network
|
|
32
|
+
*/
|
|
33
|
+
export declare const getBlockHeightByNetwork: (networkId: string) => Promise<number>;
|
|
29
34
|
/**
|
|
30
35
|
* Get current gas price
|
|
31
36
|
* @deprecated Use getGasPriceByNetwork instead - this method relies on environment variables
|
package/lib/index.js
CHANGED
|
@@ -43,7 +43,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
43
43
|
};
|
|
44
44
|
})();
|
|
45
45
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
-
exports.getFees = exports.getBalanceAddress = exports.getTransactionsByNetwork = exports.getTransactionByNetwork = exports.broadcastByNetwork = exports.estimateGasByNetwork = exports.getTokenMetadataByNetwork = exports.getTokenMetadata = exports.getTokenDecimalsByNetwork = exports.getBalanceTokensByNetwork = exports.getBalanceTokenByNetwork = exports.getBalanceAddressByNetwork = exports.getMemoEncoded = exports.getTransferData = exports.broadcast = exports.getTransaction = exports.getSymbolFromContract = exports.getAllowanceByNetwork = exports.getAllowance = exports.getBalanceToken = exports.getBalances = exports.getBalance = exports.estimateFee = exports.getGasPriceByNetwork = exports.getGasPrice = exports.getNonceByNetwork = exports.getNonce = exports.addNodes = exports.addNode = exports.getNodes = exports.init = void 0;
|
|
46
|
+
exports.getFees = exports.getBalanceAddress = exports.getTransactionsByNetwork = exports.getTransactionByNetwork = exports.broadcastByNetwork = exports.estimateGasByNetwork = exports.getTokenMetadataByNetwork = exports.getTokenMetadata = exports.getTokenDecimalsByNetwork = exports.getBalanceTokensByNetwork = exports.getBalanceTokenByNetwork = exports.getBalanceAddressByNetwork = exports.getMemoEncoded = exports.getTransferData = exports.broadcast = exports.getTransaction = exports.getSymbolFromContract = exports.getAllowanceByNetwork = exports.getAllowance = exports.getBalanceToken = exports.getBalances = exports.getBalance = exports.estimateFee = exports.getGasPriceByNetwork = exports.getGasPrice = exports.getBlockHeightByNetwork = exports.getNonceByNetwork = exports.getNonce = exports.addNodes = exports.addNode = exports.getNodes = exports.init = void 0;
|
|
47
47
|
const TAG = " | eth-network | ";
|
|
48
48
|
const ethers = __importStar(require("ethers"));
|
|
49
49
|
const BigNumber = require('bignumber.js');
|
|
@@ -448,6 +448,47 @@ const getNonceByNetwork = async function (networkId, address) {
|
|
|
448
448
|
throw lastError || Error(`Failed to get nonce from any node for ${networkId}`);
|
|
449
449
|
};
|
|
450
450
|
exports.getNonceByNetwork = getNonceByNetwork;
|
|
451
|
+
/**
|
|
452
|
+
* Get current block height/number by network
|
|
453
|
+
* Returns the latest block number for the specified EVM network
|
|
454
|
+
*/
|
|
455
|
+
const getBlockHeightByNetwork = async function (networkId) {
|
|
456
|
+
let tag = TAG + ' | getBlockHeightByNetwork | ';
|
|
457
|
+
// Get ALL nodes for this network
|
|
458
|
+
let nodes = NODES.filter((n) => n.networkId === networkId);
|
|
459
|
+
if (!nodes || nodes.length === 0) {
|
|
460
|
+
throw Error(`No nodes found for networkId: ${networkId}`);
|
|
461
|
+
}
|
|
462
|
+
// Extract chain ID from networkId (e.g., "eip155:1" -> 1)
|
|
463
|
+
let chainId;
|
|
464
|
+
if (networkId.includes(':')) {
|
|
465
|
+
chainId = parseInt(networkId.split(':')[1]);
|
|
466
|
+
}
|
|
467
|
+
// Try each node until one succeeds
|
|
468
|
+
let lastError = null;
|
|
469
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
470
|
+
const node = nodes[i];
|
|
471
|
+
try {
|
|
472
|
+
// Use StaticJsonRpcProvider to skip network auto-detection
|
|
473
|
+
const provider = new ethers.providers.StaticJsonRpcProvider(node.service, chainId ? { chainId, name: node.networkId } : undefined);
|
|
474
|
+
const blockNumber = await withTimeout(provider.getBlockNumber(), RPC_TIMEOUT_MS, `Block height fetch timeout after ${RPC_TIMEOUT_MS}ms for ${node.service.substring(0, 50)}`);
|
|
475
|
+
// Success! Log which node worked (only if not the first one)
|
|
476
|
+
if (i > 0) {
|
|
477
|
+
log.info(tag, `Successfully fetched block height from node ${i + 1}/${nodes.length}: ${node.service.substring(0, 50)}`);
|
|
478
|
+
}
|
|
479
|
+
return blockNumber;
|
|
480
|
+
}
|
|
481
|
+
catch (e) {
|
|
482
|
+
lastError = e;
|
|
483
|
+
log.warn(tag, `Node ${i + 1}/${nodes.length} failed (${node.service.substring(0, 50)}): ${e.message}`);
|
|
484
|
+
// Continue to next node
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
// All nodes failed
|
|
488
|
+
log.error(tag, `All ${nodes.length} nodes failed for ${networkId}`);
|
|
489
|
+
throw lastError || Error(`Failed to get block height from any node for ${networkId}`);
|
|
490
|
+
};
|
|
491
|
+
exports.getBlockHeightByNetwork = getBlockHeightByNetwork;
|
|
451
492
|
/**
|
|
452
493
|
* Get current gas price
|
|
453
494
|
* @deprecated Use getGasPriceByNetwork instead - this method relies on environment variables
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pioneer-platform/eth-network",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.33.1",
|
|
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.
|
|
21
|
+
"@pioneer-platform/blockbook": "^8.32.2",
|
|
22
22
|
"@pioneer-platform/loggerdog": "^8.11.0",
|
|
23
|
-
"@pioneer-platform/nodes": "^8.
|
|
23
|
+
"@pioneer-platform/nodes": "^8.30.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",
|