@ledgerhq/coin-evm 5.4.1 → 8.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/.oxlintrc.json +1 -1
- package/CHANGELOG.md +234 -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 -16
- 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 -16
- 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 +75 -9
- package/src/adapters/blockOperations.ts +1 -1
- package/src/adapters/etherscan.ts +1 -1
- package/src/adapters/ledger.ts +1 -1
- package/src/api/getBlock.integ.test.ts +10 -4
- package/src/api/index.arbitrum.integ.test.ts +1 -0
- package/src/api/index.arc.integ.test.ts +1 -0
- package/src/api/index.avalanche_c_chain_fuji.integ.test.ts +1 -0
- package/src/api/index.cronos.integ.test.ts +1 -0
- package/src/api/index.flare.integ.test.ts +4 -2
- package/src/api/index.linea.integ.test.ts +4 -2
- package/src/api/index.monad_testnet.integ.test.ts +95 -4
- package/src/api/index.optimism.integ.test.ts +1 -0
- package/src/api/index.rsk.integ.test.ts +1 -0
- package/src/api/index.shape.integ.test.ts +4 -2
- package/src/api/index.somnia.integ.test.ts +1 -0
- package/src/api/index.ts +2 -2
- package/src/config.ts +22 -35
- package/src/errors.ts +13 -0
- package/src/fixtures/context.fixtures.ts +9 -4
- 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 +792 -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/node.fixtures.ts +2 -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 +3 -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 +2 -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/staking/validators.test.ts +1 -0
- 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
package/src/logic/common.ts
CHANGED
|
@@ -9,16 +9,17 @@ import type {
|
|
|
9
9
|
MemoNotSupported,
|
|
10
10
|
TransactionIntent,
|
|
11
11
|
} from '@ledgerhq/coin-module-framework/api/index'
|
|
12
|
+
import type { Logger } from '@ledgerhq/coin-module-framework/config'
|
|
12
13
|
import {
|
|
13
14
|
isSendTransactionIntent,
|
|
14
15
|
isStakingTransactionIntent,
|
|
15
16
|
} from '@ledgerhq/coin-module-framework/utils'
|
|
16
17
|
import BigNumber from 'bignumber.js'
|
|
17
18
|
import { ethers } from 'ethers'
|
|
19
|
+
import { isEthAddress } from '../logic-public'
|
|
18
20
|
import { getNodeApi } from '../network/node'
|
|
19
21
|
import { buildStakingTransactionParams, prepareStakingIntent, STAKING_CONTRACTS } from '../staking'
|
|
20
22
|
import { isNative, TransactionTypes } from '../types'
|
|
21
|
-
import { isEthAddress } from '../utils'
|
|
22
23
|
import { getErc20Data } from './getErc20Data'
|
|
23
24
|
|
|
24
25
|
export function isApiGasOptions(options: unknown): options is ApiGasOptions {
|
|
@@ -155,11 +156,12 @@ export async function prepareUnsignedTxParams(
|
|
|
155
156
|
config: EvmConfigInfo,
|
|
156
157
|
currencyId: string,
|
|
157
158
|
transactionIntent: TransactionIntent<MemoNotSupported, BufferTxData>,
|
|
159
|
+
logger: Logger,
|
|
158
160
|
customFeesParameters?: FeeEstimation['parameters']
|
|
159
161
|
): Promise<TransactionLikeWithPreparedParams> {
|
|
160
162
|
const { sender, type } = transactionIntent
|
|
161
163
|
const transactionType = getTransactionType(type)
|
|
162
|
-
const node = getNodeApi(config, currencyId)
|
|
164
|
+
const node = getNodeApi(config, currencyId, logger)
|
|
163
165
|
const isSend = isSendTransactionIntent(transactionIntent)
|
|
164
166
|
|
|
165
167
|
// Prepare staking intents once (can require async on-chain lookups). See: LIVE-32750
|
|
@@ -34,6 +34,7 @@ export async function craftTransaction(
|
|
|
34
34
|
config,
|
|
35
35
|
currencyId,
|
|
36
36
|
transactionIntent,
|
|
37
|
+
context.logger,
|
|
37
38
|
customFees?.parameters
|
|
38
39
|
)
|
|
39
40
|
|
|
@@ -79,7 +80,7 @@ export async function craftTransaction(
|
|
|
79
80
|
}
|
|
80
81
|
|
|
81
82
|
if (!hasFeeData) {
|
|
82
|
-
const node = getNodeApi(config, currencyId)
|
|
83
|
+
const node = getNodeApi(config, currencyId, context.logger)
|
|
83
84
|
const feeData = await node.getFeeData(config, currencyId, {
|
|
84
85
|
type,
|
|
85
86
|
feesStrategy: customFees?.parameters?.feesStrategy as FeesStrategy | undefined,
|
|
@@ -11,15 +11,16 @@ import type {
|
|
|
11
11
|
MemoNotSupported,
|
|
12
12
|
TransactionIntent,
|
|
13
13
|
} from '@ledgerhq/coin-module-framework/api/index'
|
|
14
|
+
import type { Logger } from '@ledgerhq/coin-module-framework/config'
|
|
14
15
|
import type { TransactionLike } from 'ethers'
|
|
15
16
|
import BigNumber from 'bignumber.js'
|
|
16
17
|
import { Transaction } from 'ethers'
|
|
17
18
|
import { getAdditionalLayer2Fees } from '../logic'
|
|
19
|
+
import { isEthAddress, isStakingIntent } from '../logic-public'
|
|
18
20
|
import { getGasTracker } from '../network/gasTracker'
|
|
19
21
|
import { getNodeApi } from '../network/node'
|
|
20
22
|
import { STAKING_CONTRACTS } from '../staking'
|
|
21
23
|
import { TransactionTypes } from '../types'
|
|
22
|
-
import { isEthAddress, isStakingIntent } from '../utils'
|
|
23
24
|
import { getTransactionType, prepareUnsignedTxParams } from './common'
|
|
24
25
|
import { getNextSequence } from './getNextSequence'
|
|
25
26
|
|
|
@@ -28,7 +29,8 @@ const SEND_MAX_L1_FEE_BUFFER = new BigNumber(2)
|
|
|
28
29
|
async function computeAdditionalFees(
|
|
29
30
|
config: EvmConfigInfo,
|
|
30
31
|
currencyId: string,
|
|
31
|
-
unsignedTransaction: TransactionLike
|
|
32
|
+
unsignedTransaction: TransactionLike,
|
|
33
|
+
logger: Logger
|
|
32
34
|
): Promise<BigNumber | undefined> {
|
|
33
35
|
// Fake signature is added to get the best approximation possible for the gas on L1
|
|
34
36
|
const transaction: TransactionLike = {
|
|
@@ -44,7 +46,8 @@ async function computeAdditionalFees(
|
|
|
44
46
|
return await getAdditionalLayer2Fees(
|
|
45
47
|
config,
|
|
46
48
|
currencyId,
|
|
47
|
-
Transaction.from(transaction).serialized
|
|
49
|
+
Transaction.from(transaction).serialized,
|
|
50
|
+
logger
|
|
48
51
|
)
|
|
49
52
|
} catch {
|
|
50
53
|
return new BigNumber(0)
|
|
@@ -179,7 +182,7 @@ export async function estimateFees(
|
|
|
179
182
|
return { finalFeeData: remoteGasOptions[feesStrategy], finalGasOptions: remoteGasOptions }
|
|
180
183
|
}
|
|
181
184
|
|
|
182
|
-
const node = getNodeApi(config, currencyId)
|
|
185
|
+
const node = getNodeApi(config, currencyId, context.logger)
|
|
183
186
|
const feeData = await node.getFeeData(config, currencyId, {
|
|
184
187
|
type: txType,
|
|
185
188
|
feesStrategy,
|
|
@@ -192,7 +195,13 @@ export async function estimateFees(
|
|
|
192
195
|
// all independent network calls and sequencing them triples the latency.
|
|
193
196
|
const [{ to, data, value, gasLimit }, nonce, { finalFeeData, finalGasOptions }] =
|
|
194
197
|
await Promise.all([
|
|
195
|
-
prepareUnsignedTxParams(
|
|
198
|
+
prepareUnsignedTxParams(
|
|
199
|
+
config,
|
|
200
|
+
currencyId,
|
|
201
|
+
transactionIntent,
|
|
202
|
+
context.logger,
|
|
203
|
+
customFeesParameters
|
|
204
|
+
),
|
|
196
205
|
noncePromise,
|
|
197
206
|
feeDataPromise,
|
|
198
207
|
])
|
|
@@ -230,7 +239,12 @@ export async function estimateFees(
|
|
|
230
239
|
value,
|
|
231
240
|
chainId,
|
|
232
241
|
}
|
|
233
|
-
const rawAdditionalFees = await computeAdditionalFees(
|
|
242
|
+
const rawAdditionalFees = await computeAdditionalFees(
|
|
243
|
+
config,
|
|
244
|
+
currencyId,
|
|
245
|
+
unsignedTransaction,
|
|
246
|
+
context.logger
|
|
247
|
+
)
|
|
234
248
|
const additionalFees =
|
|
235
249
|
transactionIntent.useAllAmount && rawAdditionalFees
|
|
236
250
|
? rawAdditionalFees.multipliedBy(SEND_MAX_L1_FEE_BUFFER).integerValue(BigNumber.ROUND_CEIL)
|
package/src/logic/getBalance.ts
CHANGED
|
@@ -5,13 +5,7 @@ import type { EvmConfigInfo } from '../config'
|
|
|
5
5
|
import type { EvmContext } from '../config'
|
|
6
6
|
import type { ExplorerApi } from '../network/explorer/types'
|
|
7
7
|
import type { NodeApi } from '../network/node/types'
|
|
8
|
-
import type {
|
|
9
|
-
Balance,
|
|
10
|
-
AssetInfo,
|
|
11
|
-
BalanceOptions,
|
|
12
|
-
MemoNotSupported,
|
|
13
|
-
Operation,
|
|
14
|
-
} from '@ledgerhq/coin-module-framework/api/types'
|
|
8
|
+
import type { AssetInfo, Balance, BalanceOptions } from '@ledgerhq/coin-module-framework/api/types'
|
|
15
9
|
import { getExplorerApi } from '../network/explorer'
|
|
16
10
|
import { getNodeApi } from '../network/node'
|
|
17
11
|
import { STAKING_CONFIG } from '../staking'
|
|
@@ -33,7 +27,7 @@ export async function getBalance(
|
|
|
33
27
|
options?: BalanceOptions
|
|
34
28
|
): Promise<Balance[]> {
|
|
35
29
|
const config = await context.config(currencyId)
|
|
36
|
-
const nodeApi = getNodeApi(config, currencyId)
|
|
30
|
+
const nodeApi = getNodeApi(config, currencyId, context.logger)
|
|
37
31
|
const explorerApi = getExplorerApi(config, currencyId)
|
|
38
32
|
|
|
39
33
|
const [nativeBalance, tokensBalances] = await Promise.all([
|
|
@@ -69,27 +63,79 @@ async function getTokenBalances(
|
|
|
69
63
|
): Promise<Balance[]> {
|
|
70
64
|
const balances: Balance[] = []
|
|
71
65
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
66
|
+
// Monad's `getStakes` extracts "known" validator IDs from delegate/undelegate/withdraw calls
|
|
67
|
+
// found in the account's coin operations (`extractKnownValIds`, `staking/validators/monad.ts`).
|
|
68
|
+
// For a currency that declares an extractor, the SAME `getOperations` walk also serves as
|
|
69
|
+
// this currency's token-discovery source (its `lastTokenOperations`) — the account's history
|
|
70
|
+
// is walked once, not twice, and `discoverTokenAssets` is not called on this branch. Every
|
|
71
|
+
// other currency relies solely on the bounded `discoverTokenAssets` walk. Either way, a failed
|
|
72
|
+
// walk must not be reported as a successful empty one: the framework turns an empty token
|
|
73
|
+
// list into `{ value: 0n }` for every already-known sub-account, which would silently display
|
|
74
|
+
// a held token's balance as zero — so the explorer's own error is left to propagate, never
|
|
75
|
+
// swallowed into an empty result.
|
|
76
|
+
const extractKnownValIds = STAKING_CONFIG[currencyId]?.extractKnownValIds
|
|
77
|
+
|
|
78
|
+
let discoveredAssets: AssetInfo[]
|
|
79
|
+
let knownValidatorIds: string[] | undefined
|
|
80
|
+
|
|
81
|
+
if (extractKnownValIds) {
|
|
82
|
+
const ops = await explorerApi.getOperations(
|
|
83
|
+
config,
|
|
84
|
+
currencyId,
|
|
85
|
+
address,
|
|
86
|
+
0,
|
|
87
|
+
undefined,
|
|
88
|
+
undefined,
|
|
89
|
+
undefined,
|
|
90
|
+
undefined,
|
|
91
|
+
context.logger
|
|
92
|
+
)
|
|
93
|
+
knownValidatorIds = extractKnownValIds(currencyId, ops.lastCoinOperations)
|
|
94
|
+
|
|
95
|
+
discoveredAssets = []
|
|
96
|
+
for (const operation of ops.lastTokenOperations) {
|
|
97
|
+
if (!('assetReference' in operation.asset) || !operation.asset.assetReference) continue
|
|
98
|
+
discoveredAssets.push(operation.asset)
|
|
99
|
+
}
|
|
100
|
+
} else {
|
|
101
|
+
// Scanning from a height without the known set drops every asset last moved below it, which
|
|
102
|
+
// a consumer reads back as a zero balance on a token still held. The pair is ignored rather
|
|
103
|
+
// than half-applied: one extra full scan, no wrong balance.
|
|
104
|
+
const scanMinHeight = options?.knownAssets?.length ? options.scanAssetsMinHeight : undefined
|
|
105
|
+
|
|
106
|
+
discoveredAssets = await explorerApi.discoverTokenAssets(
|
|
107
|
+
config,
|
|
108
|
+
currencyId,
|
|
109
|
+
address,
|
|
110
|
+
scanMinHeight
|
|
111
|
+
)
|
|
112
|
+
}
|
|
77
113
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
114
|
+
// `union(knownAssets, scanned)`, deduplicated on a lower-cased reference the way
|
|
115
|
+
// `nativeContracts` is matched below: nothing makes the two sources agree on casing, and a
|
|
116
|
+
// case-sensitive key would read one contract's balance twice. The scanned form wins, so the
|
|
117
|
+
// module keeps emitting its own normalisation.
|
|
118
|
+
const knownAssetsByReference = new Map<string, AssetInfo>()
|
|
119
|
+
for (const asset of [...(options?.knownAssets ?? []), ...discoveredAssets]) {
|
|
120
|
+
if (!('assetReference' in asset) || !asset.assetReference) continue
|
|
121
|
+
knownAssetsByReference.set(asset.assetReference.toLowerCase(), asset)
|
|
122
|
+
}
|
|
82
123
|
|
|
83
124
|
// Contracts whose ERC20 balance mirrors the native balance — skip them here to avoid
|
|
84
125
|
// counting the same value twice (the native balance is already returned upstream).
|
|
85
126
|
const { nativeContracts = [] } = config
|
|
86
127
|
const nativeContractsSet = new Set(nativeContracts.map((c) => c.toLowerCase()))
|
|
87
128
|
|
|
88
|
-
// Staking and token-asset collection run in parallel;
|
|
89
|
-
//
|
|
129
|
+
// Staking and token-asset collection run in parallel; staking depends on the coin operations
|
|
130
|
+
// fetched above (Monad only), token-asset collection on the discovered/known assets union.
|
|
90
131
|
const [stakingResult, tokenAssetsResult] = await Promise.allSettled([
|
|
91
132
|
getStakes(context, currencyId, address, { knownValidatorIds }),
|
|
92
|
-
collectTokenAssets(
|
|
133
|
+
collectTokenAssets(
|
|
134
|
+
Array.from(knownAssetsByReference.values()),
|
|
135
|
+
address,
|
|
136
|
+
nativeContractsSet,
|
|
137
|
+
options
|
|
138
|
+
),
|
|
93
139
|
])
|
|
94
140
|
|
|
95
141
|
// Add staking positions to balances (with error handling)
|
|
@@ -130,12 +176,12 @@ async function getTokenBalances(
|
|
|
130
176
|
}
|
|
131
177
|
|
|
132
178
|
/**
|
|
133
|
-
* Walk
|
|
179
|
+
* Walk the discovered/known assets and build the set of contracts whose balance we need,
|
|
134
180
|
* along with their AssetInfo metadata. Contracts in `nativeContractsSet` are skipped
|
|
135
181
|
* (their balance is the native balance, returned upstream).
|
|
136
182
|
*/
|
|
137
183
|
async function collectTokenAssets(
|
|
138
|
-
|
|
184
|
+
discoveredAssets: AssetInfo[],
|
|
139
185
|
address: string,
|
|
140
186
|
nativeContractsSet: Set<string>,
|
|
141
187
|
options: BalanceOptions | undefined
|
|
@@ -143,14 +189,14 @@ async function collectTokenAssets(
|
|
|
143
189
|
const contracts = new Set<string>()
|
|
144
190
|
const assets = new Map<string, AssetInfo>()
|
|
145
191
|
|
|
146
|
-
for (const
|
|
147
|
-
if (!('assetReference' in
|
|
148
|
-
const contract =
|
|
192
|
+
for (const asset of discoveredAssets) {
|
|
193
|
+
if (!('assetReference' in asset)) continue
|
|
194
|
+
const contract = asset.assetReference
|
|
149
195
|
if (!contract) continue
|
|
150
196
|
if (nativeContractsSet.has(contract.toLowerCase())) continue
|
|
151
197
|
|
|
152
198
|
const assetInfo: AssetInfo = {
|
|
153
|
-
type:
|
|
199
|
+
type: asset.type,
|
|
154
200
|
assetReference: contract,
|
|
155
201
|
assetOwner: address,
|
|
156
202
|
}
|
package/src/logic/getBlock.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import type { EvmContext } from '../config'
|
|
5
5
|
import type { BlockReceiptInfo, PrefetchedBlockTransaction } from '../network/node/types'
|
|
6
|
+
import type { InternalTxsByHash } from './internalTransactionsFetcher'
|
|
6
7
|
import type {
|
|
7
8
|
Block,
|
|
8
9
|
BlockInfo,
|
|
@@ -15,8 +16,8 @@ import { log } from '@ledgerhq/logs'
|
|
|
15
16
|
import { rpcTransactionToBlockOperations } from '../adapters/blockOperations'
|
|
16
17
|
import { DEFAULT_INTERNAL_TX_SOURCES } from '../config'
|
|
17
18
|
import { UnsupportedRpcMethodError } from '../errors'
|
|
19
|
+
import { buildSmartContractDetails, safeEncodeEIP55 } from '../logic-public'
|
|
18
20
|
import { getNodeApi } from '../network/node'
|
|
19
|
-
import { buildSmartContractDetails, safeEncodeEIP55 } from '../utils'
|
|
20
21
|
import { createInternalTransactionsFetcher } from './internalTransactionsFetcher'
|
|
21
22
|
import { dropRootTraceDuplicates } from './rootTraceDedup'
|
|
22
23
|
|
|
@@ -30,9 +31,11 @@ export async function getBlock(
|
|
|
30
31
|
// - fetch transaction receipts in one call using eth_getBlockReceipts
|
|
31
32
|
// - if the RPC does not support prefetchTxs or eth_getBlockReceipts, fall back to fetching the transaction+receipts
|
|
32
33
|
// one by one
|
|
33
|
-
// -
|
|
34
|
+
// - unless the block is empty, fetch internal transactions (RPC trace methods or explorer,
|
|
35
|
+
// per `getBlockInternalTxsSources`) in parallel with the receipts, and merge them into the
|
|
36
|
+
// block transactions
|
|
34
37
|
const config = await context.config(currencyId)
|
|
35
|
-
const nodeApi = getNodeApi(config, currencyId)
|
|
38
|
+
const nodeApi = getNodeApi(config, currencyId, context.logger)
|
|
36
39
|
const internalTxSources = config.getBlockInternalTxsSources ?? DEFAULT_INTERNAL_TX_SOURCES
|
|
37
40
|
const fetchInternalTxs = createInternalTransactionsFetcher(
|
|
38
41
|
config,
|
|
@@ -40,10 +43,8 @@ export async function getBlock(
|
|
|
40
43
|
currencyId,
|
|
41
44
|
internalTxSources
|
|
42
45
|
)
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
fetchInternalTxs(height),
|
|
46
|
-
])
|
|
46
|
+
|
|
47
|
+
const result = await nodeApi.getBlockByHeight(currencyId, height, true)
|
|
47
48
|
|
|
48
49
|
const info: BlockInfo = {
|
|
49
50
|
height: result.height,
|
|
@@ -58,13 +59,24 @@ export async function getBlock(
|
|
|
58
59
|
}
|
|
59
60
|
}
|
|
60
61
|
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
62
|
+
const transactionHashes =
|
|
63
|
+
result.transactionHashes || result.transactions?.map((tx) => tx.hash) || []
|
|
64
|
+
|
|
65
|
+
// Internal transactions only exist inside transactions, so a block with none has nothing to
|
|
66
|
+
// merge. Skipping the fetch avoids a request for a guaranteed-empty answer — on the `explorer`
|
|
67
|
+
// source that is one metered `txlistinternal` call per empty block.
|
|
68
|
+
const [transactions, internalTxs] = await Promise.all([
|
|
69
|
+
getTransactionsFromNode(
|
|
70
|
+
currencyId,
|
|
71
|
+
transactionHashes,
|
|
72
|
+
nodeApi,
|
|
73
|
+
result.height,
|
|
74
|
+
result.transactions
|
|
75
|
+
),
|
|
76
|
+
transactionHashes.length === 0
|
|
77
|
+
? Promise.resolve<InternalTxsByHash>(new Map())
|
|
78
|
+
: fetchInternalTxs(height),
|
|
79
|
+
])
|
|
68
80
|
|
|
69
81
|
const mergedTransactions = mergeInternalTransactions(transactions, internalTxs)
|
|
70
82
|
|
|
@@ -11,7 +11,7 @@ export async function getBlockInfo(
|
|
|
11
11
|
height: number
|
|
12
12
|
): Promise<BlockInfo> {
|
|
13
13
|
const config = await context.config(currencyId)
|
|
14
|
-
const api = getNodeApi(config, currencyId)
|
|
14
|
+
const api = getNodeApi(config, currencyId, context.logger)
|
|
15
15
|
const result = await api.getBlockByHeight(currencyId, height)
|
|
16
16
|
|
|
17
17
|
const blockInfo: BlockInfo = {
|
|
@@ -10,6 +10,9 @@ export async function getNextSequence(
|
|
|
10
10
|
address: string
|
|
11
11
|
): Promise<bigint> {
|
|
12
12
|
const config = await context.config(currencyId)
|
|
13
|
-
const txCount = await getNodeApi(config, currencyId).getTransactionCount(
|
|
13
|
+
const txCount = await getNodeApi(config, currencyId, context.logger).getTransactionCount(
|
|
14
|
+
currencyId,
|
|
15
|
+
address
|
|
16
|
+
)
|
|
14
17
|
return typeof txCount === 'number' ? BigInt(txCount) : txCount
|
|
15
18
|
}
|
package/src/logic/index.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
+
// Re-export the standalone L2-fees helper (src/logic.ts) so it stays reachable
|
|
5
|
+
// from the `@ledgerhq/coin-evm/logic` entry point.
|
|
6
|
+
export * from '../logic'
|
|
4
7
|
export * from './broadcast'
|
|
5
8
|
export * from './lastBlock'
|
|
6
9
|
export * from './combine'
|
|
10
|
+
export * from './getErc20Data'
|
|
7
11
|
export * from './getBalance'
|
|
8
12
|
export * from './estimateFees'
|
|
9
13
|
export * from './listOperations'
|
package/src/logic/lastBlock.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { getNodeApi } from '../network/node'
|
|
|
7
7
|
|
|
8
8
|
export async function lastBlock(context: EvmContext, currencyId: string): Promise<BlockInfo> {
|
|
9
9
|
const config = await context.config(currencyId)
|
|
10
|
-
const api = getNodeApi(config, currencyId)
|
|
10
|
+
const api = getNodeApi(config, currencyId, context.logger)
|
|
11
11
|
const { finalizationLevel = 'latest' } = config
|
|
12
12
|
const result = await api.getBlockByHeight(currencyId, finalizationLevel)
|
|
13
13
|
|
|
@@ -8,6 +8,7 @@ import type {
|
|
|
8
8
|
Operation,
|
|
9
9
|
ListOperationsOptions,
|
|
10
10
|
} from '@ledgerhq/coin-module-framework/api/types'
|
|
11
|
+
import { InvalidParameterError } from '@ledgerhq/coin-module-framework/errors'
|
|
11
12
|
import { getExplorerApi } from '../network/explorer'
|
|
12
13
|
|
|
13
14
|
// the sort parameter has a double meaning:
|
|
@@ -47,6 +48,17 @@ export async function listOperations(
|
|
|
47
48
|
address: string,
|
|
48
49
|
options: ListOperationsOptions
|
|
49
50
|
): Promise<Page<Operation<MemoNotSupported>>> {
|
|
51
|
+
// A page of zero operations is not a page this module can serve: it carries no record to build
|
|
52
|
+
// a cursor from, so it could only be answered with the caller's own cursor -- which the
|
|
53
|
+
// response contract forbids (a truthy `next` must advance). Raised rather than clamped, because
|
|
54
|
+
// a caller asking for zero operations is a caller bug, not a preference to honour. The public
|
|
55
|
+
// HTTP schema does allow `limit: 0`, so this is reachable from outside this repository.
|
|
56
|
+
if (options.limit !== undefined && options.limit <= 0) {
|
|
57
|
+
throw new InvalidParameterError(
|
|
58
|
+
`listOperations: limit must be a positive integer, got ${options.limit}`
|
|
59
|
+
)
|
|
60
|
+
}
|
|
61
|
+
|
|
50
62
|
const config = await context.config(currencyId)
|
|
51
63
|
const explorerApi = getExplorerApi(config, currencyId)
|
|
52
64
|
const explorerOrder = options.limit === undefined ? 'desc' : (options.order ?? 'desc')
|
|
@@ -64,7 +76,8 @@ export async function listOperations(
|
|
|
64
76
|
undefined,
|
|
65
77
|
options.cursor,
|
|
66
78
|
options.limit,
|
|
67
|
-
explorerOrder
|
|
79
|
+
explorerOrder,
|
|
80
|
+
context.logger
|
|
68
81
|
)
|
|
69
82
|
|
|
70
83
|
const tokenOrNftHashes = new Set(
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import type { EvmContext } from '../../config'
|
|
5
|
+
import { Wallet } from 'ethers'
|
|
6
|
+
import {
|
|
7
|
+
createMockEvmConfigInfo,
|
|
8
|
+
createMockEvmContext,
|
|
9
|
+
mkExternalNode,
|
|
10
|
+
mkLedgerNode,
|
|
11
|
+
} from '../../fixtures/context.fixtures'
|
|
12
|
+
import broadcast from '../broadcast'
|
|
13
|
+
|
|
14
|
+
const contextForNetwork = (network: string): EvmContext => {
|
|
15
|
+
switch (network) {
|
|
16
|
+
case 'ethereum':
|
|
17
|
+
return createMockEvmContext(
|
|
18
|
+
createMockEvmConfigInfo({ chainId: 1, node: mkLedgerNode({ explorerId: 'eth' }) })
|
|
19
|
+
)
|
|
20
|
+
case 'sonic':
|
|
21
|
+
return createMockEvmContext(
|
|
22
|
+
createMockEvmConfigInfo({
|
|
23
|
+
chainId: 146,
|
|
24
|
+
node: mkExternalNode({ uri: 'https://sonic.coin.ledger.com' }),
|
|
25
|
+
})
|
|
26
|
+
)
|
|
27
|
+
default:
|
|
28
|
+
throw new Error('Unhandled currency')
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
describe('Broadcast', () => {
|
|
33
|
+
it.each([
|
|
34
|
+
['ethereum', 1],
|
|
35
|
+
['sonic', 146],
|
|
36
|
+
])('throws on insufficient funds on %s', async (network, chainId) => {
|
|
37
|
+
const wallet = Wallet.createRandom()
|
|
38
|
+
const tx = {
|
|
39
|
+
to: wallet.address,
|
|
40
|
+
value: 1n,
|
|
41
|
+
nonce: 0,
|
|
42
|
+
gasLimit: 21000n,
|
|
43
|
+
maxFeePerGas: 10000000000000n,
|
|
44
|
+
maxPriorityFeePerGas: 1000000000n,
|
|
45
|
+
chainId,
|
|
46
|
+
}
|
|
47
|
+
const signature = await wallet.signTransaction(tx)
|
|
48
|
+
|
|
49
|
+
await expect(broadcast(contextForNetwork(network), network, { signature })).rejects.toThrow(
|
|
50
|
+
/insufficient funds for gas \* price \+ value|InsufficientFunds/
|
|
51
|
+
)
|
|
52
|
+
})
|
|
53
|
+
})
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import { mockEvmContext } from '
|
|
5
|
-
import { getNodeApi } from '
|
|
6
|
-
import { mockNodeApi } from '
|
|
7
|
-
import { broadcast } from '
|
|
4
|
+
import { mockEvmContext } from '../../fixtures/context.fixtures'
|
|
5
|
+
import { getNodeApi } from '../../network/node/index'
|
|
6
|
+
import { mockNodeApi } from '../../network/node/node.fixtures'
|
|
7
|
+
import { broadcast } from '../broadcast'
|
|
8
8
|
|
|
9
|
-
jest.mock('
|
|
10
|
-
...jest.requireActual('
|
|
9
|
+
jest.mock('../../network/node/index', () => ({
|
|
10
|
+
...jest.requireActual('../../network/node/index'),
|
|
11
11
|
getNodeApi: jest.fn(),
|
|
12
12
|
}))
|
|
13
13
|
|
|
@@ -27,7 +27,7 @@ describe('broadcastLogic', () => {
|
|
|
27
27
|
signature: '0xabcdef',
|
|
28
28
|
broadcastConfig: { mevProtected: true },
|
|
29
29
|
})
|
|
30
|
-
expect(mockGetNodeApi).toHaveBeenCalledWith(expect.anything(), 'ethereum')
|
|
30
|
+
expect(mockGetNodeApi).toHaveBeenCalledWith(expect.anything(), 'ethereum', expect.any(Function))
|
|
31
31
|
expect(nodeApiMock.broadcastTransaction).toHaveBeenCalledWith('ethereum', '0xabcdef', {
|
|
32
32
|
mevProtected: true,
|
|
33
33
|
})
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import { mockEvmContext } from '
|
|
5
|
-
import { getNodeApi } from '
|
|
6
|
-
import { mockNodeApi } from '
|
|
7
|
-
import { broadcast } from '
|
|
4
|
+
import { mockEvmContext } from '../../fixtures/context.fixtures'
|
|
5
|
+
import { getNodeApi } from '../../network/node/index'
|
|
6
|
+
import { mockNodeApi } from '../../network/node/node.fixtures'
|
|
7
|
+
import { broadcast } from '../broadcast'
|
|
8
8
|
|
|
9
|
-
jest.mock('
|
|
10
|
-
...jest.requireActual('
|
|
9
|
+
jest.mock('../../network/node/index', () => ({
|
|
10
|
+
...jest.requireActual('../../network/node/index'),
|
|
11
11
|
getNodeApi: jest.fn(),
|
|
12
12
|
}))
|
|
13
13
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import { ethers, SigningKey, Wallet } from 'ethers'
|
|
5
|
-
import { combine } from '
|
|
5
|
+
import { combine } from '../combine'
|
|
6
6
|
|
|
7
7
|
describe('combine', () => {
|
|
8
8
|
const privateKey = '0xb40eddd40b507adb0df9d44fe668a12c7d43d75bb0a3fc46cdaba1fe46dede2d'
|