@pioneer-platform/eth-network 8.28.2 → 8.30.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 -1
- package/CHANGELOG.md +40 -0
- package/lib/index.js +26 -17
- package/lib/types/client-types.d.ts +1 -2
- package/lib/utils.d.ts +3 -3
- package/lib/utils.js +10 -7
- package/package.json +4 -4
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
|
|
2
|
-
[0m[2m[35m$[0m [2m[1mtsc -p
|
|
2
|
+
[0m[2m[35m$[0m [2m[1mtsc -p . --skipLibCheck[0m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,45 @@
|
|
|
1
1
|
# @pioneer-platform/eth-network
|
|
2
2
|
|
|
3
|
+
## 8.30.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- chore: feat(pioneer-sdk): Add transaction history integration
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
- @pioneer-platform/blockbook@8.29.0
|
|
13
|
+
|
|
14
|
+
## 8.29.0
|
|
15
|
+
|
|
16
|
+
### Minor Changes
|
|
17
|
+
|
|
18
|
+
- feat(pioneer-sdk): Add transaction history integration
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- Updated dependencies
|
|
23
|
+
- @pioneer-platform/blockbook@8.28.0
|
|
24
|
+
|
|
25
|
+
## 8.28.4
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- chore: fix: transaction event channel mismatch + add networkId to event payload
|
|
30
|
+
- Updated dependencies
|
|
31
|
+
- @pioneer-platform/blockbook@8.27.5
|
|
32
|
+
- @pioneer-platform/nodes@8.26.2
|
|
33
|
+
|
|
34
|
+
## 8.28.3
|
|
35
|
+
|
|
36
|
+
### Patch Changes
|
|
37
|
+
|
|
38
|
+
- fix: transaction event channel mismatch + add networkId to event payload
|
|
39
|
+
- Updated dependencies
|
|
40
|
+
- @pioneer-platform/blockbook@8.27.4
|
|
41
|
+
- @pioneer-platform/nodes@8.26.1
|
|
42
|
+
|
|
3
43
|
## 8.28.2
|
|
4
44
|
|
|
5
45
|
### 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
|
-
//
|
|
320
|
-
//
|
|
321
|
-
|
|
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
|
|
@@ -1388,27 +1395,29 @@ const getTransactionsByNetwork = async function (networkId, address, options = {
|
|
|
1388
1395
|
log.error(tag, `Invalid Ethereum address format: ${address} - ${e.message}`);
|
|
1389
1396
|
throw new Error(`Invalid Ethereum address: ${address}`);
|
|
1390
1397
|
}
|
|
1391
|
-
//
|
|
1392
|
-
//
|
|
1393
|
-
|
|
1394
|
-
// Map network ID to Blockbook coin symbol
|
|
1395
|
-
const networkToCoin = {
|
|
1398
|
+
// Map networkId to Blockbook coin symbol
|
|
1399
|
+
// Blockbook uses coin symbols ('ETH'), not networkIds ('eip155:1')
|
|
1400
|
+
const networkToSymbol = {
|
|
1396
1401
|
'eip155:1': 'ETH', // Ethereum Mainnet
|
|
1397
|
-
'eip155:137': 'MATIC', // Polygon
|
|
1398
|
-
'eip155:56': 'BSC', // BSC
|
|
1402
|
+
'eip155:137': 'MATIC', // Polygon
|
|
1403
|
+
'eip155:56': 'BSC', // BSC
|
|
1404
|
+
'eip155:43114': 'AVAX', // Avalanche C-Chain
|
|
1405
|
+
'eip155:250': 'FTM', // Fantom
|
|
1406
|
+
'eip155:42161': 'ARB', // Arbitrum
|
|
1407
|
+
'eip155:10': 'OP', // Optimism
|
|
1408
|
+
'eip155:8453': 'BASE', // Base
|
|
1399
1409
|
// Add more as needed
|
|
1400
1410
|
};
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
log.warn(tag, `Unknown networkId ${networkId}, defaulting to ETH`);
|
|
1411
|
+
const coinSymbol = networkToSymbol[networkId];
|
|
1412
|
+
if (!coinSymbol) {
|
|
1413
|
+
log.warn(tag, `Unknown networkId ${networkId} for Blockbook - no transaction history available`);
|
|
1414
|
+
return [];
|
|
1406
1415
|
}
|
|
1407
1416
|
// Fetch address info from Blockbook with transaction details
|
|
1408
1417
|
const page = options?.page || 1;
|
|
1409
1418
|
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
|
|
1419
|
+
log.info(tag, `Fetching from Blockbook: ${coinSymbol} (${networkId}) address ${checksummedAddress} page ${page} pageSize ${pageSize}`);
|
|
1420
|
+
// Use Blockbook to get address info with transactions - pass symbol
|
|
1412
1421
|
const addressInfo = await blockbook.getAddressInfo(coinSymbol, checksummedAddress, 'txs', { page, pageSize });
|
|
1413
1422
|
if (!addressInfo || !addressInfo.transactions) {
|
|
1414
1423
|
log.warn(tag, 'No transactions found for address');
|
package/lib/utils.d.ts
CHANGED
|
@@ -4,11 +4,11 @@ import { Network as EthNetwork, Address, ETHTransactionInfo, TokenTransactionInf
|
|
|
4
4
|
import { BigNumber } from '@ethersproject/bignumber';
|
|
5
5
|
export declare const ETH_DECIMAL = 18;
|
|
6
6
|
export declare const ETHPLORER_FREEKEY = "freekey";
|
|
7
|
-
export declare const SIMPLE_GAS_COST:
|
|
8
|
-
export declare const BASE_TOKEN_GAS_COST:
|
|
7
|
+
export declare const SIMPLE_GAS_COST: bigint;
|
|
8
|
+
export declare const BASE_TOKEN_GAS_COST: bigint;
|
|
9
9
|
export declare const DEFAULT_GAS_PRICE = 50;
|
|
10
10
|
export declare const ETHAddress = "0x0000000000000000000000000000000000000000";
|
|
11
|
-
export declare const MAX_APPROVAL:
|
|
11
|
+
export declare const MAX_APPROVAL: bigint;
|
|
12
12
|
/**
|
|
13
13
|
* XChainNetwork -> EthNetwork
|
|
14
14
|
*
|
package/lib/utils.js
CHANGED
|
@@ -3,19 +3,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.erc20ABI = exports.filterSelfTxs = exports.getPrefix = exports.getDefaultGasPrices = exports.getDefaultFees = exports.estimateDefaultFeesWithGasPricesAndLimits = exports.getFee = exports.getTxFromEthTransaction = exports.getTxFromTokenTransaction = exports.validateSymbol = exports.getTokenAddress = exports.validateAddress = exports.ethNetworkToXchains = exports.xchainNetworkToEths = exports.MAX_APPROVAL = exports.ETHAddress = exports.DEFAULT_GAS_PRICE = exports.BASE_TOKEN_GAS_COST = exports.SIMPLE_GAS_COST = exports.ETHPLORER_FREEKEY = exports.ETH_DECIMAL = void 0;
|
|
4
4
|
const xchain_util_1 = require("@xchainjs/xchain-util");
|
|
5
5
|
const types_1 = require("./types");
|
|
6
|
-
const bignumber_1 = require("@ethersproject/bignumber");
|
|
7
6
|
const ethers_1 = require("ethers");
|
|
7
|
+
const bignumber_1 = require("@ethersproject/bignumber");
|
|
8
8
|
const utils_1 = require("ethers/lib/utils");
|
|
9
|
+
// Define AssetETH and ETHChain locally since they're not exported in xchain-util@0.2.8
|
|
10
|
+
const AssetETH = { chain: 'ETH', symbol: 'ETH', ticker: 'ETH', type: 0 }; // AssetType.NATIVE = 0
|
|
11
|
+
const ETHChain = 'ETH';
|
|
9
12
|
exports.ETH_DECIMAL = 18;
|
|
10
13
|
exports.ETHPLORER_FREEKEY = 'freekey';
|
|
11
14
|
// from https://github.com/MetaMask/metamask-extension/blob/ee205b893fe61dc4736efc576e0663189a9d23da/ui/app/pages/send/send.constants.js#L39
|
|
12
15
|
// and based on recommendations of https://ethgasstation.info/blog/gas-limit/
|
|
13
|
-
exports.SIMPLE_GAS_COST =
|
|
14
|
-
exports.BASE_TOKEN_GAS_COST =
|
|
16
|
+
exports.SIMPLE_GAS_COST = BigInt(21000);
|
|
17
|
+
exports.BASE_TOKEN_GAS_COST = BigInt(100000);
|
|
15
18
|
// default gas price in gwei
|
|
16
19
|
exports.DEFAULT_GAS_PRICE = 50;
|
|
17
20
|
exports.ETHAddress = '0x0000000000000000000000000000000000000000';
|
|
18
|
-
exports.MAX_APPROVAL =
|
|
21
|
+
exports.MAX_APPROVAL = (BigInt(2) ** BigInt(256)) - BigInt(1);
|
|
19
22
|
/**
|
|
20
23
|
* XChainNetwork -> EthNetwork
|
|
21
24
|
*
|
|
@@ -105,7 +108,7 @@ const getTxFromTokenTransaction = (tx) => {
|
|
|
105
108
|
const symbol = tx.tokenSymbol;
|
|
106
109
|
const address = tx.contractAddress;
|
|
107
110
|
if ((0, exports.validateSymbol)(symbol) && (0, exports.validateAddress)(address)) {
|
|
108
|
-
const tokenAsset = (0, xchain_util_1.assetFromString)(`${
|
|
111
|
+
const tokenAsset = (0, xchain_util_1.assetFromString)(`${ETHChain}.${symbol}-${address}`);
|
|
109
112
|
if (tokenAsset) {
|
|
110
113
|
return {
|
|
111
114
|
asset: tokenAsset,
|
|
@@ -138,7 +141,7 @@ exports.getTxFromTokenTransaction = getTxFromTokenTransaction;
|
|
|
138
141
|
*/
|
|
139
142
|
const getTxFromEthTransaction = (tx) => {
|
|
140
143
|
return {
|
|
141
|
-
asset:
|
|
144
|
+
asset: AssetETH,
|
|
142
145
|
from: [
|
|
143
146
|
{
|
|
144
147
|
from: tx.from,
|
|
@@ -172,7 +175,7 @@ const estimateDefaultFeesWithGasPricesAndLimits = (asset) => {
|
|
|
172
175
|
};
|
|
173
176
|
const { fast: fastGP, fastest: fastestGP, average: averageGP } = gasPrices;
|
|
174
177
|
let assetAddress;
|
|
175
|
-
if (asset && (0, xchain_util_1.assetToString)(asset) !== (0, xchain_util_1.assetToString)(
|
|
178
|
+
if (asset && (0, xchain_util_1.assetToString)(asset) !== (0, xchain_util_1.assetToString)(AssetETH)) {
|
|
176
179
|
assetAddress = (0, exports.getTokenAddress)(asset);
|
|
177
180
|
}
|
|
178
181
|
let gasLimit;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pioneer-platform/eth-network",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.30.0",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"types": "./lib/index.d.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"test": "pnpm run build && node __tests__/test-module.js",
|
|
10
10
|
"test-dev": "pnpm run build && node lib/index.js",
|
|
11
11
|
"start": "pnpm run build:live",
|
|
12
|
-
"build": "tsc -p .",
|
|
12
|
+
"build": "tsc -p . --skipLibCheck",
|
|
13
13
|
"prepublish": "pnpm run build",
|
|
14
14
|
"build:watch": "pnpm run build && onchange 'src/**/*.ts' -- pnpm run build"
|
|
15
15
|
},
|
|
@@ -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.29.0",
|
|
22
22
|
"@pioneer-platform/loggerdog": "^8.11.0",
|
|
23
|
-
"@pioneer-platform/nodes": "^8.26.
|
|
23
|
+
"@pioneer-platform/nodes": "^8.26.2",
|
|
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",
|