@ledgerhq/coin-evm 5.4.0 → 7.0.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 +197 -0
- package/docs/evm-family-integration-process/README.md +1 -1
- package/knip.json +2 -3
- package/lib/adapters/blockOperations.js +6 -6
- package/lib/adapters/blockOperations.js.map +1 -1
- package/lib/adapters/etherscan.js +23 -23
- package/lib/adapters/etherscan.js.map +1 -1
- package/lib/adapters/ledger.js +17 -17
- package/lib/adapters/ledger.js.map +1 -1
- package/lib/api/index.js +4 -4
- package/lib/api/index.js.map +1 -1
- package/lib/config.d.ts +21 -15
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +5 -25
- package/lib/config.js.map +1 -1
- package/lib/errors.d.ts +9 -0
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +15 -1
- package/lib/errors.js.map +1 -1
- package/lib/logic/broadcast.js +1 -1
- package/lib/logic/broadcast.js.map +1 -1
- package/lib/logic/common.d.ts +2 -1
- package/lib/logic/common.d.ts.map +1 -1
- package/lib/logic/common.js +4 -4
- package/lib/logic/common.js.map +1 -1
- package/lib/logic/craftTransaction.d.ts.map +1 -1
- package/lib/logic/craftTransaction.js +2 -2
- package/lib/logic/craftTransaction.js.map +1 -1
- package/lib/logic/estimateFees.d.ts.map +1 -1
- package/lib/logic/estimateFees.js +9 -9
- package/lib/logic/estimateFees.js.map +1 -1
- package/lib/logic/getBalance.d.ts.map +1 -1
- package/lib/logic/getBalance.js +50 -16
- package/lib/logic/getBalance.js.map +1 -1
- package/lib/logic/getBlock.d.ts.map +1 -1
- package/lib/logic/getBlock.js +19 -11
- package/lib/logic/getBlock.js.map +1 -1
- package/lib/logic/getBlockInfo.js +1 -1
- package/lib/logic/getBlockInfo.js.map +1 -1
- package/lib/logic/getNextSequence.d.ts.map +1 -1
- package/lib/logic/getNextSequence.js +1 -1
- package/lib/logic/getNextSequence.js.map +1 -1
- package/lib/logic/index.d.ts +2 -0
- package/lib/logic/index.d.ts.map +1 -1
- package/lib/logic/index.js +4 -0
- package/lib/logic/index.js.map +1 -1
- package/lib/logic/lastBlock.js +1 -1
- package/lib/logic/lastBlock.js.map +1 -1
- package/lib/logic/listOperations.d.ts.map +1 -1
- package/lib/logic/listOperations.js +10 -1
- package/lib/logic/listOperations.js.map +1 -1
- package/lib/logic/validateIntent.d.ts.map +1 -1
- package/lib/logic/validateIntent.js +12 -12
- package/lib/logic/validateIntent.js.map +1 -1
- package/lib/logic-public/index.d.ts +3 -0
- package/lib/logic-public/index.d.ts.map +1 -0
- package/lib/logic-public/index.js +19 -0
- package/lib/logic-public/index.js.map +1 -0
- package/lib/{utils.d.ts → logic-public/utils.d.ts} +0 -44
- package/lib/logic-public/utils.d.ts.map +1 -0
- package/lib/logic-public/utils.js +166 -0
- package/lib/logic-public/utils.js.map +1 -0
- package/lib/logic.d.ts +2 -1
- package/lib/logic.d.ts.map +1 -1
- package/lib/logic.js +3 -3
- package/lib/logic.js.map +1 -1
- package/lib/network/explorer/etherscan.d.ts +16 -3
- package/lib/network/explorer/etherscan.d.ts.map +1 -1
- package/lib/network/explorer/etherscan.js +61 -6
- package/lib/network/explorer/etherscan.js.map +1 -1
- package/lib/network/explorer/ledger.d.ts +50 -4
- package/lib/network/explorer/ledger.d.ts.map +1 -1
- package/lib/network/explorer/ledger.js +286 -37
- package/lib/network/explorer/ledger.js.map +1 -1
- package/lib/network/explorer/none.d.ts +1 -0
- package/lib/network/explorer/none.d.ts.map +1 -1
- package/lib/network/explorer/none.js +4 -1
- package/lib/network/explorer/none.js.map +1 -1
- package/lib/network/explorer/types.d.ts +15 -2
- package/lib/network/explorer/types.d.ts.map +1 -1
- package/lib/network/explorer/types.js.map +1 -1
- package/lib/network/index.d.ts +5 -0
- package/lib/network/index.d.ts.map +1 -0
- package/lib/network/index.js +23 -0
- package/lib/network/index.js.map +1 -0
- package/lib/network/node/explorerProxy.d.ts +27 -0
- package/lib/network/node/explorerProxy.d.ts.map +1 -0
- package/lib/network/node/explorerProxy.js +262 -0
- package/lib/network/node/explorerProxy.js.map +1 -0
- package/lib/network/node/index.d.ts +2 -1
- package/lib/network/node/index.d.ts.map +1 -1
- package/lib/network/node/index.js +11 -10
- package/lib/network/node/index.js.map +1 -1
- package/lib/network/node/ledger.js +7 -7
- package/lib/network/node/ledger.js.map +1 -1
- package/lib/network/node/rpc.common.d.ts +2 -2
- package/lib/network/node/rpc.common.js +19 -19
- package/lib/network/node/rpc.common.js.map +1 -1
- package/lib/network/node/withNodeSources.d.ts +21 -0
- package/lib/network/node/withNodeSources.d.ts.map +1 -0
- package/lib/network/node/withNodeSources.js +78 -0
- package/lib/network/node/withNodeSources.js.map +1 -0
- package/lib/nodeSources.d.ts +15 -0
- package/lib/nodeSources.d.ts.map +1 -0
- package/lib/nodeSources.js +33 -0
- package/lib/nodeSources.js.map +1 -0
- package/lib/staking/contracts.js +1 -1
- package/lib/staking/contracts.js.map +1 -1
- package/lib/staking/fetchers.js +1 -1
- package/lib/staking/fetchers.js.map +1 -1
- package/lib/staking/operations/sei.js +1 -1
- package/lib/staking/operations/sei.js.map +1 -1
- package/lib/staking/prepareIntents.js +3 -3
- package/lib/staking/prepareIntents.js.map +1 -1
- package/lib/staking/rewards.js +1 -1
- package/lib/staking/rewards.js.map +1 -1
- package/lib/staking/transactionData.js +2 -2
- package/lib/staking/transactionData.js.map +1 -1
- package/lib/staking/utils.d.ts +45 -0
- package/lib/staking/utils.d.ts.map +1 -0
- package/lib/{utils.js → staking/utils.js} +5 -164
- package/lib/staking/utils.js.map +1 -0
- package/lib/staking/validators/sei.js +1 -1
- package/lib/staking/validators/sei.js.map +1 -1
- package/lib/types/staking.d.ts +2 -2
- package/lib-es/adapters/blockOperations.js +1 -1
- package/lib-es/adapters/blockOperations.js.map +1 -1
- package/lib-es/adapters/etherscan.js +1 -1
- package/lib-es/adapters/etherscan.js.map +1 -1
- package/lib-es/adapters/ledger.js +1 -1
- package/lib-es/adapters/ledger.js.map +1 -1
- package/lib-es/api/index.js +2 -2
- package/lib-es/api/index.js.map +1 -1
- package/lib-es/config.d.ts +21 -15
- package/lib-es/config.d.ts.map +1 -1
- package/lib-es/config.js +1 -21
- package/lib-es/config.js.map +1 -1
- package/lib-es/errors.d.ts +9 -0
- package/lib-es/errors.d.ts.map +1 -1
- package/lib-es/errors.js +13 -0
- package/lib-es/errors.js.map +1 -1
- package/lib-es/logic/broadcast.js +1 -1
- package/lib-es/logic/broadcast.js.map +1 -1
- package/lib-es/logic/common.d.ts +2 -1
- package/lib-es/logic/common.d.ts.map +1 -1
- package/lib-es/logic/common.js +3 -3
- package/lib-es/logic/common.js.map +1 -1
- package/lib-es/logic/craftTransaction.d.ts.map +1 -1
- package/lib-es/logic/craftTransaction.js +2 -2
- package/lib-es/logic/craftTransaction.js.map +1 -1
- package/lib-es/logic/estimateFees.d.ts.map +1 -1
- package/lib-es/logic/estimateFees.js +6 -6
- package/lib-es/logic/estimateFees.js.map +1 -1
- package/lib-es/logic/getBalance.d.ts.map +1 -1
- package/lib-es/logic/getBalance.js +50 -16
- package/lib-es/logic/getBalance.js.map +1 -1
- package/lib-es/logic/getBlock.d.ts.map +1 -1
- package/lib-es/logic/getBlock.js +16 -8
- package/lib-es/logic/getBlock.js.map +1 -1
- package/lib-es/logic/getBlockInfo.js +1 -1
- package/lib-es/logic/getBlockInfo.js.map +1 -1
- package/lib-es/logic/getNextSequence.d.ts.map +1 -1
- package/lib-es/logic/getNextSequence.js +1 -1
- package/lib-es/logic/getNextSequence.js.map +1 -1
- package/lib-es/logic/index.d.ts +2 -0
- package/lib-es/logic/index.d.ts.map +1 -1
- package/lib-es/logic/index.js +4 -0
- package/lib-es/logic/index.js.map +1 -1
- package/lib-es/logic/lastBlock.js +1 -1
- package/lib-es/logic/lastBlock.js.map +1 -1
- package/lib-es/logic/listOperations.d.ts.map +1 -1
- package/lib-es/logic/listOperations.js +10 -1
- package/lib-es/logic/listOperations.js.map +1 -1
- package/lib-es/logic/validateIntent.d.ts.map +1 -1
- package/lib-es/logic/validateIntent.js +4 -4
- package/lib-es/logic/validateIntent.js.map +1 -1
- package/lib-es/logic-public/index.d.ts +3 -0
- package/lib-es/logic-public/index.d.ts.map +1 -0
- package/lib-es/logic-public/index.js +4 -0
- package/lib-es/logic-public/index.js.map +1 -0
- package/lib-es/{utils.d.ts → logic-public/utils.d.ts} +0 -44
- package/lib-es/logic-public/utils.d.ts.map +1 -0
- package/lib-es/logic-public/utils.js +150 -0
- package/lib-es/logic-public/utils.js.map +1 -0
- package/lib-es/logic.d.ts +2 -1
- package/lib-es/logic.d.ts.map +1 -1
- package/lib-es/logic.js +3 -3
- package/lib-es/logic.js.map +1 -1
- package/lib-es/network/explorer/etherscan.d.ts +16 -3
- package/lib-es/network/explorer/etherscan.d.ts.map +1 -1
- package/lib-es/network/explorer/etherscan.js +60 -5
- package/lib-es/network/explorer/etherscan.js.map +1 -1
- package/lib-es/network/explorer/ledger.d.ts +50 -4
- package/lib-es/network/explorer/ledger.d.ts.map +1 -1
- package/lib-es/network/explorer/ledger.js +283 -37
- package/lib-es/network/explorer/ledger.js.map +1 -1
- package/lib-es/network/explorer/none.d.ts +1 -0
- package/lib-es/network/explorer/none.d.ts.map +1 -1
- package/lib-es/network/explorer/none.js +2 -0
- package/lib-es/network/explorer/none.js.map +1 -1
- package/lib-es/network/explorer/types.d.ts +15 -2
- package/lib-es/network/explorer/types.d.ts.map +1 -1
- package/lib-es/network/explorer/types.js.map +1 -1
- package/lib-es/network/index.d.ts +5 -0
- package/lib-es/network/index.d.ts.map +1 -0
- package/lib-es/network/index.js +7 -0
- package/lib-es/network/index.js.map +1 -0
- package/lib-es/network/node/explorerProxy.d.ts +27 -0
- package/lib-es/network/node/explorerProxy.d.ts.map +1 -0
- package/lib-es/network/node/explorerProxy.js +254 -0
- package/lib-es/network/node/explorerProxy.js.map +1 -0
- package/lib-es/network/node/index.d.ts +2 -1
- package/lib-es/network/node/index.d.ts.map +1 -1
- package/lib-es/network/node/index.js +11 -10
- package/lib-es/network/node/index.js.map +1 -1
- package/lib-es/network/node/ledger.js +1 -1
- package/lib-es/network/node/ledger.js.map +1 -1
- package/lib-es/network/node/rpc.common.d.ts +2 -2
- package/lib-es/network/node/rpc.common.js +3 -3
- package/lib-es/network/node/rpc.common.js.map +1 -1
- package/lib-es/network/node/withNodeSources.d.ts +21 -0
- package/lib-es/network/node/withNodeSources.d.ts.map +1 -0
- package/lib-es/network/node/withNodeSources.js +74 -0
- package/lib-es/network/node/withNodeSources.js.map +1 -0
- package/lib-es/nodeSources.d.ts +15 -0
- package/lib-es/nodeSources.d.ts.map +1 -0
- package/lib-es/nodeSources.js +28 -0
- package/lib-es/nodeSources.js.map +1 -0
- package/lib-es/staking/contracts.js +1 -1
- package/lib-es/staking/contracts.js.map +1 -1
- package/lib-es/staking/fetchers.js +1 -1
- package/lib-es/staking/fetchers.js.map +1 -1
- package/lib-es/staking/operations/sei.js +1 -1
- package/lib-es/staking/operations/sei.js.map +1 -1
- package/lib-es/staking/prepareIntents.js +1 -1
- package/lib-es/staking/prepareIntents.js.map +1 -1
- package/lib-es/staking/rewards.js +1 -1
- package/lib-es/staking/rewards.js.map +1 -1
- package/lib-es/staking/transactionData.js +1 -1
- package/lib-es/staking/transactionData.js.map +1 -1
- package/lib-es/staking/utils.d.ts +45 -0
- package/lib-es/staking/utils.d.ts.map +1 -0
- package/lib-es/{utils.js → staking/utils.js} +1 -147
- package/lib-es/staking/utils.js.map +1 -0
- package/lib-es/staking/validators/sei.js +1 -1
- package/lib-es/staking/validators/sei.js.map +1 -1
- package/lib-es/types/staking.d.ts +2 -2
- package/package.json +72 -7
- package/src/adapters/blockOperations.ts +1 -1
- package/src/adapters/etherscan.ts +1 -1
- package/src/adapters/ledger.ts +1 -1
- package/src/api/{index.arc_testnet.integ.test.ts → index.arc.integ.test.ts} +15 -12
- package/src/api/index.monad_testnet.integ.test.ts +95 -4
- package/src/api/index.ts +2 -2
- package/src/config.ts +22 -34
- package/src/errors.ts +13 -0
- package/src/fixtures/context.fixtures.ts +6 -1
- package/src/logic/broadcast.ts +1 -1
- package/src/logic/common.ts +4 -2
- package/src/logic/craftTransaction.ts +2 -1
- package/src/logic/estimateFees.ts +20 -6
- package/src/logic/getBalance.ts +72 -26
- package/src/logic/getBlock.ts +26 -14
- package/src/logic/getBlockInfo.ts +1 -1
- package/src/logic/getNextSequence.ts +4 -1
- package/src/logic/index.ts +4 -0
- package/src/logic/lastBlock.ts +1 -1
- package/src/logic/listOperations.ts +14 -1
- package/src/logic/tests/broadcast.integ.test.ts +53 -0
- package/src/logic/{broadcast.test.ts → tests/broadcast.test.ts} +7 -7
- package/src/logic/{broadcastSource.test.ts → tests/broadcastSource.test.ts} +6 -6
- package/src/logic/{combine.test.ts → tests/combine.test.ts} +1 -1
- package/src/logic/{common.test.ts → tests/common.test.ts} +45 -21
- package/src/logic/{computeGasLimit.test.ts → tests/computeGasLimit.test.ts} +2 -2
- package/src/logic/{craftTransaction.test.ts → tests/craftTransaction.test.ts} +7 -7
- package/src/logic/{craftTransactionData.test.ts → tests/craftTransactionData.test.ts} +4 -4
- package/src/logic/{estimateFees.test.ts → tests/estimateFees.test.ts} +12 -12
- package/src/logic/tests/getBalance.test.ts +602 -0
- package/src/logic/{getBlock.test.ts → tests/getBlock.test.ts} +182 -89
- package/src/logic/{getBlockInfo.test.ts → tests/getBlockInfo.test.ts} +8 -8
- package/src/logic/{getErc20Data.test.ts → tests/getErc20Data.test.ts} +1 -1
- package/src/logic/{getNextSequence.test.ts → tests/getNextSequence.test.ts} +7 -7
- package/src/logic/{getStakes.test.ts → tests/getStakes.test.ts} +13 -13
- package/src/logic/{internalTransactionsFetcher.test.ts → tests/internalTransactionsFetcher.test.ts} +8 -8
- package/src/logic/{lastBlock.test.ts → tests/lastBlock.test.ts} +7 -7
- package/src/logic/{listOperations.test.ts → tests/listOperations.test.ts} +125 -6
- package/src/logic/{validateAddress.test.ts → tests/validateAddress.test.ts} +1 -1
- package/src/logic/{validateIntent.test.ts → tests/validateIntent.test.ts} +80 -78
- package/src/logic/validateIntent.ts +7 -4
- package/src/logic-public/index.ts +18 -0
- package/src/{utils.test.ts → logic-public/tests/utils.test.ts} +1 -27
- package/src/logic-public/utils.ts +184 -0
- package/src/logic.test.ts +5 -59
- package/src/logic.ts +5 -3
- package/src/network/explorer/etherscan.test.ts +403 -195
- package/src/network/explorer/etherscan.ts +99 -10
- package/src/network/explorer/index.test.ts +27 -0
- package/src/network/explorer/ledger.test.ts +791 -62
- package/src/network/explorer/ledger.ts +426 -54
- package/src/network/explorer/none.ts +3 -0
- package/src/network/explorer/types.ts +29 -5
- package/src/network/index.ts +7 -0
- package/src/network/node/explorerProxy.test.ts +673 -0
- package/src/network/node/explorerProxy.ts +308 -0
- package/src/network/node/index.memoization.test.ts +22 -10
- package/src/network/node/index.test.ts +6 -3
- package/src/network/node/index.ts +11 -7
- package/src/network/node/ledger.ts +1 -1
- package/src/network/node/rpc.common.ts +3 -3
- package/src/network/node/rpc.test.ts +66 -105
- package/src/network/node/withNodeSources.test.ts +240 -0
- package/src/network/node/withNodeSources.ts +95 -0
- package/src/nodeSources.ts +38 -0
- package/src/staking/contracts.ts +1 -1
- package/src/staking/encoder.test.ts +1 -1
- package/src/staking/fetchers.ts +1 -1
- package/src/staking/operations/sei.ts +1 -1
- package/src/staking/prepareIntents.ts +1 -1
- package/src/staking/redelegations.test.ts +1 -1
- package/src/staking/rewards.test.ts +1 -1
- package/src/staking/rewards.ts +1 -1
- package/src/staking/transactionData.ts +1 -1
- package/src/staking/unbondings.test.ts +1 -1
- package/src/staking/utils.test.ts +25 -0
- package/src/{utils.ts → staking/utils.ts} +2 -182
- package/src/staking/validators/sei.ts +1 -1
- package/src/types/staking.ts +2 -2
- package/lib/constants.d.ts +0 -2
- package/lib/constants.d.ts.map +0 -1
- package/lib/constants.js +0 -11
- package/lib/constants.js.map +0 -1
- package/lib/utils.d.ts.map +0 -1
- package/lib/utils.js.map +0 -1
- package/lib-es/constants.d.ts +0 -2
- package/lib-es/constants.d.ts.map +0 -1
- package/lib-es/constants.js +0 -7
- package/lib-es/constants.js.map +0 -1
- package/lib-es/utils.d.ts.map +0 -1
- package/lib-es/utils.js.map +0 -1
- package/src/constants.ts +0 -9
- package/src/logic/broadcast.integ.test.ts +0 -46
- package/src/logic/getBalance.test.ts +0 -362
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import type { BlockByHeightResult, NodeApi, TransactionInfo } from './types'
|
|
5
|
+
import type { Logger } from '@ledgerhq/coin-module-framework/config'
|
|
6
|
+
import axios from 'axios'
|
|
7
|
+
import { isSmartContractInput, safeEncodeEIP55 } from '../../logic-public'
|
|
8
|
+
import { ETHERSCAN_TIMEOUT } from '../explorer/etherscan'
|
|
9
|
+
import { withRetries } from '../withRetries'
|
|
10
|
+
import { parseERC20TransfersFromLogs } from './rpc.common'
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Parses a 0x-prefixed hexadecimal integer string into bigint.
|
|
14
|
+
* Returns null for absent values, decimal-only strings (e.g. "10"), or any malformed input.
|
|
15
|
+
* Requiring the 0x prefix prevents decimal strings from silently passing validation with an
|
|
16
|
+
* unintended value (BigInt("10") = 10, not hex 16).
|
|
17
|
+
*/
|
|
18
|
+
function parseHexBigInt(v: unknown): bigint | null {
|
|
19
|
+
if (typeof v !== 'string' || !/^0x/i.test(v)) return null
|
|
20
|
+
try {
|
|
21
|
+
return BigInt(v)
|
|
22
|
+
} catch {
|
|
23
|
+
return null
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Parses a block number from a string that may be hex-encoded ("0xe1c1d3") or decimal
|
|
29
|
+
* ("14817811"). Both encodings appear in Etherscan-like API responses depending on the
|
|
30
|
+
* implementation. Returns null for absent or non-integer values.
|
|
31
|
+
*
|
|
32
|
+
* Unlike parseHexBigInt, the 0x prefix is optional here because we compare the parsed
|
|
33
|
+
* number to the requested height — there is no risk of misinterpreting the value.
|
|
34
|
+
*/
|
|
35
|
+
function parseBlockNumber(v: unknown): number | null {
|
|
36
|
+
if (typeof v !== 'string' || !v) return null
|
|
37
|
+
try {
|
|
38
|
+
return Number(BigInt(v))
|
|
39
|
+
} catch {
|
|
40
|
+
return null
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async function proxyRequest<T>(
|
|
45
|
+
explorerUri: string,
|
|
46
|
+
params: Record<string, string>,
|
|
47
|
+
parse: (result: unknown) => T | null,
|
|
48
|
+
logger: Logger,
|
|
49
|
+
retries = 0
|
|
50
|
+
): Promise<T | null> {
|
|
51
|
+
try {
|
|
52
|
+
const { data } = await withRetries(
|
|
53
|
+
() => axios.get(explorerUri, { params: { module: 'proxy', ...params }, timeout: 10000 }),
|
|
54
|
+
retries,
|
|
55
|
+
ETHERSCAN_TIMEOUT
|
|
56
|
+
)
|
|
57
|
+
const result = data?.result
|
|
58
|
+
if (result === null || result === undefined) return null
|
|
59
|
+
return parse(result)
|
|
60
|
+
} catch (e) {
|
|
61
|
+
logger('warn', 'EVM: explorer proxy request failed', {
|
|
62
|
+
action: params.action,
|
|
63
|
+
explorerUri,
|
|
64
|
+
error: String(e),
|
|
65
|
+
})
|
|
66
|
+
return null
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Fetches a block from the Etherscan-like explorer proxy endpoint (`module=proxy&action=eth_getBlockByNumber`).
|
|
72
|
+
* The explorer's backing node is typically an archive node and has blocks that a pruned RPC node
|
|
73
|
+
* does not. Returns null on network error, missing result, empty/zero block hash, or missing
|
|
74
|
+
* required metadata (timestamp, parentHash).
|
|
75
|
+
*
|
|
76
|
+
* Always populates `BlockByHeightResult.transactionHashes` (never `transactions`) so that
|
|
77
|
+
* callers fall into the individual-`getTransaction` path — which is itself wrapped by the
|
|
78
|
+
* source list — rather than the `eth_getBlockReceipts` optimisation path that still hits the
|
|
79
|
+
* (pruned) primary node.
|
|
80
|
+
*/
|
|
81
|
+
export async function getBlockFromExplorerProxy(
|
|
82
|
+
explorerUri: string,
|
|
83
|
+
height: number,
|
|
84
|
+
retries = 0,
|
|
85
|
+
logger: Logger = () => undefined
|
|
86
|
+
): Promise<BlockByHeightResult | null> {
|
|
87
|
+
const hexHeight = '0x' + height.toString(16)
|
|
88
|
+
return proxyRequest(
|
|
89
|
+
explorerUri,
|
|
90
|
+
{ action: 'eth_getBlockByNumber', tag: hexHeight, boolean: 'false' },
|
|
91
|
+
(result) => {
|
|
92
|
+
const block = result as Record<string, unknown>
|
|
93
|
+
if (!block || typeof block !== 'object') return null
|
|
94
|
+
|
|
95
|
+
const hash = block.hash
|
|
96
|
+
if (typeof hash !== 'string' || !hash || /^0x0+$/.test(hash)) return null
|
|
97
|
+
|
|
98
|
+
if (typeof block.timestamp !== 'string' || typeof block.parentHash !== 'string') return null
|
|
99
|
+
|
|
100
|
+
const blockNumber = parseBlockNumber(block.number)
|
|
101
|
+
if (blockNumber === null || blockNumber !== height) return null
|
|
102
|
+
const blockHeight = height
|
|
103
|
+
|
|
104
|
+
const timestampBig = parseHexBigInt(block.timestamp)
|
|
105
|
+
if (timestampBig === null) return null
|
|
106
|
+
const timestamp = Number(timestampBig) * 1000
|
|
107
|
+
|
|
108
|
+
const parentHash = block.parentHash
|
|
109
|
+
|
|
110
|
+
const out: BlockByHeightResult = { hash, height: blockHeight, timestamp, parentHash }
|
|
111
|
+
|
|
112
|
+
// JSON-RPC block payloads always include transactions; reject an incomplete response.
|
|
113
|
+
const txsField = block.transactions
|
|
114
|
+
if (!Array.isArray(txsField)) return null
|
|
115
|
+
const hashes: string[] = []
|
|
116
|
+
for (const t of txsField) {
|
|
117
|
+
if (typeof t !== 'string' || !/^0x/i.test(t)) return null
|
|
118
|
+
hashes.push(t)
|
|
119
|
+
}
|
|
120
|
+
if (hashes.length > 0) out.transactionHashes = hashes
|
|
121
|
+
|
|
122
|
+
return out
|
|
123
|
+
},
|
|
124
|
+
logger,
|
|
125
|
+
retries
|
|
126
|
+
)
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Fetches transaction data from the Etherscan-like explorer proxy using
|
|
131
|
+
* `eth_getTransactionByHash` and `eth_getTransactionReceipt` in parallel.
|
|
132
|
+
* Returns null if either call fails or the transaction is not found.
|
|
133
|
+
*/
|
|
134
|
+
export async function getTransactionFromExplorerProxy(
|
|
135
|
+
explorerUri: string,
|
|
136
|
+
hash: string,
|
|
137
|
+
retries = 0,
|
|
138
|
+
logger: Logger = () => undefined
|
|
139
|
+
): Promise<TransactionInfo | null> {
|
|
140
|
+
const [tx, receipt] = await Promise.all([
|
|
141
|
+
proxyRequest(
|
|
142
|
+
explorerUri,
|
|
143
|
+
{ action: 'eth_getTransactionByHash', txhash: hash },
|
|
144
|
+
(r) => {
|
|
145
|
+
const t = r as Record<string, unknown>
|
|
146
|
+
if (!t || typeof t.hash !== 'string') return null
|
|
147
|
+
if (t.hash.toLowerCase() !== hash.toLowerCase()) return null
|
|
148
|
+
return t
|
|
149
|
+
},
|
|
150
|
+
logger,
|
|
151
|
+
retries
|
|
152
|
+
),
|
|
153
|
+
proxyRequest(
|
|
154
|
+
explorerUri,
|
|
155
|
+
{ action: 'eth_getTransactionReceipt', txhash: hash },
|
|
156
|
+
(r) => {
|
|
157
|
+
const rec = r as Record<string, unknown>
|
|
158
|
+
if (!rec || typeof rec.transactionHash !== 'string') return null
|
|
159
|
+
if (rec.transactionHash.toLowerCase() !== hash.toLowerCase()) return null
|
|
160
|
+
return rec
|
|
161
|
+
},
|
|
162
|
+
logger,
|
|
163
|
+
retries
|
|
164
|
+
),
|
|
165
|
+
])
|
|
166
|
+
|
|
167
|
+
if (!tx || !receipt) return null
|
|
168
|
+
|
|
169
|
+
try {
|
|
170
|
+
// Required quantities: must be present as a valid 0x-prefixed hex string — absent or
|
|
171
|
+
// malformed values both produce null and reject the source.
|
|
172
|
+
const gasUsedBig = parseHexBigInt(receipt.gasUsed)
|
|
173
|
+
if (gasUsedBig === null) return null
|
|
174
|
+
|
|
175
|
+
const nonceBig = parseHexBigInt(tx.nonce)
|
|
176
|
+
if (nonceBig === null) return null
|
|
177
|
+
|
|
178
|
+
const valueBig = parseHexBigInt(tx.value)
|
|
179
|
+
if (valueBig === null) return null
|
|
180
|
+
|
|
181
|
+
// Optional quantities: fall through the chain or default when a field is malformed.
|
|
182
|
+
const gasPriceBig =
|
|
183
|
+
parseHexBigInt(receipt.effectiveGasPrice) ??
|
|
184
|
+
parseHexBigInt(receipt.gasPrice) ??
|
|
185
|
+
parseHexBigInt(tx.gasPrice) ??
|
|
186
|
+
0n
|
|
187
|
+
const statusBig = parseHexBigInt(receipt.status)
|
|
188
|
+
const blockNumberBig = parseHexBigInt(tx.blockNumber)
|
|
189
|
+
const txTypeBig = parseHexBigInt(receipt.type) ?? parseHexBigInt(tx.type)
|
|
190
|
+
// OP-stack chains include l1Fee in the receipt; preserve it so fee calculations in
|
|
191
|
+
// getBlock are correct when the proxy is used on those chains.
|
|
192
|
+
const l1FeeBig = parseHexBigInt(receipt.l1Fee)
|
|
193
|
+
|
|
194
|
+
// logs must be an array — a missing or non-array field would silently omit all
|
|
195
|
+
// ERC20 transfers, which is worse than failing the source.
|
|
196
|
+
if (!Array.isArray(receipt.logs)) return null
|
|
197
|
+
const logs: { address: string; topics: string[]; data: string }[] = []
|
|
198
|
+
for (const l of receipt.logs) {
|
|
199
|
+
if (!l || typeof l !== 'object') return null
|
|
200
|
+
const entry = l as Record<string, unknown>
|
|
201
|
+
if (typeof entry.address !== 'string') return null
|
|
202
|
+
if (typeof entry.data !== 'string') return null
|
|
203
|
+
if (
|
|
204
|
+
!Array.isArray(entry.topics) ||
|
|
205
|
+
!entry.topics.every((t): t is string => typeof t === 'string')
|
|
206
|
+
)
|
|
207
|
+
return null
|
|
208
|
+
logs.push({ address: entry.address, topics: entry.topics, data: entry.data })
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
const txHash = typeof tx.hash === 'string' ? tx.hash : hash
|
|
212
|
+
const blockHash = typeof tx.blockHash === 'string' ? tx.blockHash : undefined
|
|
213
|
+
|
|
214
|
+
// from is always present on a valid transaction; reject the source if it is absent.
|
|
215
|
+
if (typeof tx.from !== 'string' || !/^0x[0-9a-fA-F]{40}$/.test(tx.from)) return null
|
|
216
|
+
const from = safeEncodeEIP55(tx.from)
|
|
217
|
+
|
|
218
|
+
// to is null for contract-creation transactions, otherwise a 20-byte address string.
|
|
219
|
+
// Any other type (e.g. a number) is a malformed response — reject the source.
|
|
220
|
+
const toField = tx.to
|
|
221
|
+
if (
|
|
222
|
+
toField !== null &&
|
|
223
|
+
toField !== undefined &&
|
|
224
|
+
(typeof toField !== 'string' || !/^0x[0-9a-fA-F]{40}$/.test(toField))
|
|
225
|
+
)
|
|
226
|
+
return null
|
|
227
|
+
const to = typeof toField === 'string' ? safeEncodeEIP55(toField) : undefined
|
|
228
|
+
const input = typeof tx.input === 'string' ? tx.input : undefined
|
|
229
|
+
const contractAddress =
|
|
230
|
+
typeof receipt.contractAddress === 'string' && receipt.contractAddress
|
|
231
|
+
? receipt.contractAddress
|
|
232
|
+
: undefined
|
|
233
|
+
|
|
234
|
+
return {
|
|
235
|
+
hash: txHash,
|
|
236
|
+
blockHeight: blockNumberBig !== null ? Number(blockNumberBig) : undefined,
|
|
237
|
+
blockHash,
|
|
238
|
+
nonce: Number(nonceBig),
|
|
239
|
+
gasUsed: gasUsedBig.toString(),
|
|
240
|
+
gasPrice: gasPriceBig.toString(),
|
|
241
|
+
status: statusBig !== null ? Number(statusBig) : null,
|
|
242
|
+
value: valueBig.toString(),
|
|
243
|
+
from,
|
|
244
|
+
to,
|
|
245
|
+
...(txTypeBig !== null ? { type: Number(txTypeBig) } : {}),
|
|
246
|
+
...(l1FeeBig !== null ? { l1Fee: l1FeeBig.toString() } : {}),
|
|
247
|
+
...(input && isSmartContractInput(input) ? { input } : {}),
|
|
248
|
+
...(contractAddress ? { contractAddress } : {}),
|
|
249
|
+
erc20Transfers: parseERC20TransfersFromLogs(logs),
|
|
250
|
+
}
|
|
251
|
+
} catch (e) {
|
|
252
|
+
logger('warn', 'EVM: explorer proxy returned malformed transaction payload', {
|
|
253
|
+
hash,
|
|
254
|
+
error: String(e),
|
|
255
|
+
})
|
|
256
|
+
return null
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/** Rejects immediately — satisfies NodeApi for methods not provided by the explorer proxy. */
|
|
261
|
+
function notSupported(method: string): Promise<never> {
|
|
262
|
+
return Promise.reject(new Error(`EVM ${method}: not supported by explorer proxy`))
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Full {@link NodeApi} implementation backed by the Etherscan-like explorer proxy.
|
|
267
|
+
* Only {@link NodeApi.getBlockByHeight} and {@link NodeApi.getTransaction} are supported;
|
|
268
|
+
* every other method rejects immediately with a "not supported" error.
|
|
269
|
+
*/
|
|
270
|
+
export function createExplorerProxyNodeApi(
|
|
271
|
+
explorerUri: string,
|
|
272
|
+
explorerRetries: number,
|
|
273
|
+
logger: Logger
|
|
274
|
+
): NodeApi {
|
|
275
|
+
return {
|
|
276
|
+
call: (_c, _p) => notSupported('call'),
|
|
277
|
+
getCoinBalance: (_c, _a) => notSupported('getCoinBalance'),
|
|
278
|
+
getTokenBalance: (_c, _a, _ca) => notSupported('getTokenBalance'),
|
|
279
|
+
getTokenAllowance: (_c, _o, _ca, _s) => notSupported('getTokenAllowance'),
|
|
280
|
+
getTransactionCount: (_c, _a) => notSupported('getTransactionCount'),
|
|
281
|
+
getGasEstimation: (_c, _a, _t) => notSupported('getGasEstimation'),
|
|
282
|
+
getFeeData: (_cfg, _c, _t) => notSupported('getFeeData'),
|
|
283
|
+
broadcastTransaction: (_c, _tx) => notSupported('broadcastTransaction'),
|
|
284
|
+
getOptimismAdditionalFees: (_c, _t) => notSupported('getOptimismAdditionalFees'),
|
|
285
|
+
getScrollAdditionalFees: (_c, _t) => notSupported('getScrollAdditionalFees'),
|
|
286
|
+
getBlockByHeight: async (_c, height) => {
|
|
287
|
+
if (typeof height !== 'number')
|
|
288
|
+
throw new Error('EVM getBlockByHeight: explorer proxy only supports numeric heights')
|
|
289
|
+
const result = await getBlockFromExplorerProxy(explorerUri, height, explorerRetries, logger)
|
|
290
|
+
if (!result)
|
|
291
|
+
throw new Error(
|
|
292
|
+
`EVM getBlockByHeight: explorer proxy returned no result for block ${height}`
|
|
293
|
+
)
|
|
294
|
+
return result
|
|
295
|
+
},
|
|
296
|
+
getTransaction: async (_c, hash) => {
|
|
297
|
+
const result = await getTransactionFromExplorerProxy(
|
|
298
|
+
explorerUri,
|
|
299
|
+
hash,
|
|
300
|
+
explorerRetries,
|
|
301
|
+
logger
|
|
302
|
+
)
|
|
303
|
+
if (!result)
|
|
304
|
+
throw new Error(`EVM getTransaction: explorer proxy returned no result for tx ${hash}`)
|
|
305
|
+
return result
|
|
306
|
+
},
|
|
307
|
+
}
|
|
308
|
+
}
|
|
@@ -1,31 +1,39 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
createMockEvmConfigInfo,
|
|
6
|
+
mkExternalNode,
|
|
7
|
+
testLogger,
|
|
8
|
+
} from '../../fixtures/context.fixtures'
|
|
5
9
|
import { getNodeApi } from './index'
|
|
6
10
|
|
|
7
11
|
describe('getNodeApi memoization', () => {
|
|
8
12
|
it('should return the same NodeApi instance for same currency and retries (memoization)', () => {
|
|
9
13
|
const config = createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode() })
|
|
10
|
-
expect(getNodeApi(config, 'ethereum')).toBe(
|
|
14
|
+
expect(getNodeApi(config, 'ethereum', testLogger)).toBe(
|
|
15
|
+
getNodeApi(config, 'ethereum', testLogger)
|
|
16
|
+
)
|
|
11
17
|
})
|
|
12
18
|
|
|
13
19
|
it('should return cached NodeApi on subsequent calls (createNodeApi called once)', () => {
|
|
14
20
|
const config = createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode() })
|
|
15
|
-
const cachedInstance = getNodeApi(config, 'cached_value_test')
|
|
21
|
+
const cachedInstance = getNodeApi(config, 'cached_value_test', testLogger)
|
|
16
22
|
|
|
17
|
-
expect(getNodeApi(config, 'cached_value_test')).toBe(cachedInstance)
|
|
18
|
-
expect(getNodeApi(config, 'cached_value_test')).toBe(cachedInstance)
|
|
23
|
+
expect(getNodeApi(config, 'cached_value_test', testLogger)).toBe(cachedInstance)
|
|
24
|
+
expect(getNodeApi(config, 'cached_value_test', testLogger)).toBe(cachedInstance)
|
|
19
25
|
})
|
|
20
26
|
|
|
21
27
|
it('should return different NodeApi instances for different retries', () => {
|
|
22
28
|
const node1 = getNodeApi(
|
|
23
29
|
createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode({ uri: 'u', retries: 2 }) }),
|
|
24
|
-
'ethereum'
|
|
30
|
+
'ethereum',
|
|
31
|
+
testLogger
|
|
25
32
|
)
|
|
26
33
|
const node2 = getNodeApi(
|
|
27
34
|
createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode({ uri: 'u', retries: 5 }) }),
|
|
28
|
-
'ethereum'
|
|
35
|
+
'ethereum',
|
|
36
|
+
testLogger
|
|
29
37
|
)
|
|
30
38
|
expect(node1).not.toBe(node2)
|
|
31
39
|
})
|
|
@@ -33,11 +41,13 @@ describe('getNodeApi memoization', () => {
|
|
|
33
41
|
it('should return different NodeApi instances for different uris', () => {
|
|
34
42
|
const node1 = getNodeApi(
|
|
35
43
|
createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode({ uri: 'u1' }) }),
|
|
36
|
-
'ethereum'
|
|
44
|
+
'ethereum',
|
|
45
|
+
testLogger
|
|
37
46
|
)
|
|
38
47
|
const node2 = getNodeApi(
|
|
39
48
|
createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode({ uri: 'u2' }) }),
|
|
40
|
-
'ethereum'
|
|
49
|
+
'ethereum',
|
|
50
|
+
testLogger
|
|
41
51
|
)
|
|
42
52
|
|
|
43
53
|
expect(node1).not.toBe(node2)
|
|
@@ -46,6 +56,8 @@ describe('getNodeApi memoization', () => {
|
|
|
46
56
|
it('should return different NodeApi instances for different currencies', () => {
|
|
47
57
|
const conf = createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode({ uri: 'u1' }) })
|
|
48
58
|
|
|
49
|
-
expect(getNodeApi(conf, 'ethereum1')).not.toBe(
|
|
59
|
+
expect(getNodeApi(conf, 'ethereum1', testLogger)).not.toBe(
|
|
60
|
+
getNodeApi(conf, 'ethereum2', testLogger)
|
|
61
|
+
)
|
|
50
62
|
})
|
|
51
63
|
})
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
createMockEvmConfigInfo,
|
|
7
7
|
mkExternalNode,
|
|
8
8
|
mkLedgerNode,
|
|
9
|
+
testLogger,
|
|
9
10
|
} from '../../fixtures/context.fixtures'
|
|
10
11
|
import { getNodeApi } from './index'
|
|
11
12
|
|
|
@@ -15,13 +16,14 @@ describe('EVM Family', () => {
|
|
|
15
16
|
it('should throw when requesting a non existing node type', () => {
|
|
16
17
|
const config = createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode() })
|
|
17
18
|
Object.assign(config, { node: { type: 'anything', uri: 'notworking' } })
|
|
18
|
-
expect(() => getNodeApi(config, 'not-existing')).toThrow(UnknownNode)
|
|
19
|
+
expect(() => getNodeApi(config, 'not-existing', testLogger)).toThrow(UnknownNode)
|
|
19
20
|
})
|
|
20
21
|
|
|
21
22
|
it('should return the rpc api', () => {
|
|
22
23
|
const node = getNodeApi(
|
|
23
24
|
createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode({ uri: 'working' }) }),
|
|
24
|
-
'external'
|
|
25
|
+
'external',
|
|
26
|
+
testLogger
|
|
25
27
|
)
|
|
26
28
|
|
|
27
29
|
expect(node).toEqual(
|
|
@@ -42,7 +44,8 @@ describe('EVM Family', () => {
|
|
|
42
44
|
it('should return the ledger api', () => {
|
|
43
45
|
const node = getNodeApi(
|
|
44
46
|
createMockEvmConfigInfo({ chainId: 1, node: mkLedgerNode({ explorerId: 'eth' }) }),
|
|
45
|
-
'ledger-supported'
|
|
47
|
+
'ledger-supported',
|
|
48
|
+
testLogger
|
|
46
49
|
)
|
|
47
50
|
|
|
48
51
|
expect(node).toEqual(
|
|
@@ -3,15 +3,16 @@
|
|
|
3
3
|
|
|
4
4
|
import type { EvmConfigInfo } from '../../config'
|
|
5
5
|
import type { NodeApi } from './types'
|
|
6
|
+
import type { Logger } from '@ledgerhq/coin-module-framework/config'
|
|
6
7
|
import { DEFAULT_LEDGER_EXPLORER_URI } from '../../config'
|
|
7
8
|
import { UnknownNode } from '../../errors'
|
|
8
9
|
import { createLedgerNodeApi } from './ledger'
|
|
9
10
|
import { createNodeApi } from './rpc'
|
|
11
|
+
import { withNodeSources } from './withNodeSources'
|
|
10
12
|
|
|
11
13
|
/**
|
|
12
14
|
* Memoized NodeApi instances for both ledger and external nodes.
|
|
13
|
-
* Key
|
|
14
|
-
* The explorer settings are in the key because the ledger api captures them at creation.
|
|
15
|
+
* Key includes all config dimensions that affect the API instance's behavior.
|
|
15
16
|
* Unbounded growth is acceptable: the number of entries is at most (currencies × distinct
|
|
16
17
|
* node configs). In practice there are few EVM chains and config is static per currency,
|
|
17
18
|
* so the cache stays small.
|
|
@@ -22,12 +23,13 @@ function cacheKey(
|
|
|
22
23
|
currencyId: string,
|
|
23
24
|
node: { type: string; [key: string]: unknown },
|
|
24
25
|
explorerUri: string,
|
|
25
|
-
clientVersion: string
|
|
26
|
+
clientVersion: string,
|
|
27
|
+
nodeSources: string
|
|
26
28
|
): string {
|
|
27
|
-
return `${currencyId}:${JSON.stringify(node)}:${explorerUri}:${clientVersion}`
|
|
29
|
+
return `${currencyId}:${JSON.stringify(node)}:${explorerUri}:${clientVersion}:${nodeSources}`
|
|
28
30
|
}
|
|
29
31
|
|
|
30
|
-
export const getNodeApi = (config: EvmConfigInfo, currencyId: string): NodeApi => {
|
|
32
|
+
export const getNodeApi = (config: EvmConfigInfo, currencyId: string, logger: Logger): NodeApi => {
|
|
31
33
|
const node = config?.node
|
|
32
34
|
const type = node?.type
|
|
33
35
|
|
|
@@ -37,13 +39,15 @@ export const getNodeApi = (config: EvmConfigInfo, currencyId: string): NodeApi =
|
|
|
37
39
|
|
|
38
40
|
const explorerUri = config.ledgerExplorerUri ?? DEFAULT_LEDGER_EXPLORER_URI
|
|
39
41
|
const clientVersion = config.ledgerClientVersion ?? ''
|
|
40
|
-
const
|
|
42
|
+
const nodeSources = JSON.stringify(config.nodeSources ?? ['node'])
|
|
43
|
+
const key = cacheKey(currencyId, node, explorerUri, clientVersion, nodeSources)
|
|
41
44
|
let api = nodeApiCache.get(key)
|
|
42
45
|
if (api === undefined) {
|
|
43
|
-
|
|
46
|
+
const raw =
|
|
44
47
|
type === 'ledger'
|
|
45
48
|
? createLedgerNodeApi({ ...node, explorerUri, clientVersion })
|
|
46
49
|
: createNodeApi(config, node)
|
|
50
|
+
api = withNodeSources(raw, config, logger)
|
|
47
51
|
nodeApiCache.set(key, api)
|
|
48
52
|
}
|
|
49
53
|
return api
|
|
@@ -14,7 +14,7 @@ import { ethers } from 'ethers'
|
|
|
14
14
|
import ERC20Abi from '../../abis/erc20.abi.json'
|
|
15
15
|
import OptimismGasPriceOracleAbi from '../../abis/optimismGasPriceOracle.abi.json'
|
|
16
16
|
import { GasEstimationError } from '../../errors'
|
|
17
|
-
import { normalizeAddress, padHexString, safeEncodeEIP55 } from '../../
|
|
17
|
+
import { normalizeAddress, padHexString, safeEncodeEIP55 } from '../../logic-public'
|
|
18
18
|
import { getGasOptions } from '../gasTracker/ledger'
|
|
19
19
|
import { withRetries } from '../withRetries'
|
|
20
20
|
|
|
@@ -24,7 +24,7 @@ import ERC20Abi from '../../abis/erc20.abi.json'
|
|
|
24
24
|
import OptimismGasPriceOracleAbi from '../../abis/optimismGasPriceOracle.abi.json'
|
|
25
25
|
import ScrollGasPriceOracleAbi from '../../abis/scrollGasPriceOracle.abi.json'
|
|
26
26
|
import { GasEstimationError, InsufficientFunds, UnsupportedRpcMethodError } from '../../errors'
|
|
27
|
-
import { isSmartContractInput, safeEncodeEIP55, normalizeAddress } from '../../
|
|
27
|
+
import { isSmartContractInput, safeEncodeEIP55, normalizeAddress } from '../../logic-public'
|
|
28
28
|
import { withRetries } from '../withRetries'
|
|
29
29
|
import { gethCallTracerToTraceBlockItems } from './gethCallTracerToTraceBlockItems'
|
|
30
30
|
import {
|
|
@@ -180,8 +180,8 @@ function providerCacheKey(currencyId: string, uri: string): string {
|
|
|
180
180
|
* Intended for test teardown (afterAll) so that ethers' background polling
|
|
181
181
|
* timers are stopped and Jest can exit cleanly.
|
|
182
182
|
*
|
|
183
|
-
* @internal — Test-only not
|
|
184
|
-
*
|
|
183
|
+
* @internal — Test-only; not part of the package's public entry points. Consume via a
|
|
184
|
+
* relative import within the package's own tests only.
|
|
185
185
|
*/
|
|
186
186
|
export function destroyAllRpcProviders(): void {
|
|
187
187
|
for (const [key, provider] of Object.entries(PROVIDERS_BY_RPC)) {
|