@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
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'
|
|
@@ -8,16 +8,20 @@ import {
|
|
|
8
8
|
createStakingTransactionIntentMockData,
|
|
9
9
|
} from '@ledgerhq/coin-module-framework/test-utils'
|
|
10
10
|
import { BigNumber } from 'bignumber.js'
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
import {
|
|
17
|
-
import
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
import {
|
|
12
|
+
createMockEvmConfigInfo,
|
|
13
|
+
mkExternalNode,
|
|
14
|
+
testLogger,
|
|
15
|
+
} from '../../fixtures/context.fixtures'
|
|
16
|
+
import { getNodeApi } from '../../network/node'
|
|
17
|
+
import { mockNodeApi } from '../../network/node/node.fixtures'
|
|
18
|
+
import { buildStakingTransactionParams } from '../../staking'
|
|
19
|
+
import { USEI_TO_EVM_SCALE } from '../../staking/utils'
|
|
20
|
+
import { getCallData, prepareUnsignedTxParams } from '../common'
|
|
21
|
+
import * as getErc20DataModule from '../getErc20Data'
|
|
22
|
+
|
|
23
|
+
jest.mock('../getErc20Data', () => {
|
|
24
|
+
const actual = jest.requireActual('../getErc20Data')
|
|
21
25
|
return {
|
|
22
26
|
getErc20Data: jest.fn((recipient: string, amount: bigint) =>
|
|
23
27
|
actual.getErc20Data(recipient, amount)
|
|
@@ -25,13 +29,13 @@ jest.mock('./getErc20Data', () => {
|
|
|
25
29
|
}
|
|
26
30
|
})
|
|
27
31
|
|
|
28
|
-
jest.mock('
|
|
29
|
-
...jest.requireActual('
|
|
32
|
+
jest.mock('../../network/node', () => ({
|
|
33
|
+
...jest.requireActual('../../network/node'),
|
|
30
34
|
getNodeApi: jest.fn(),
|
|
31
35
|
}))
|
|
32
36
|
|
|
33
|
-
jest.mock('
|
|
34
|
-
...jest.requireActual('
|
|
37
|
+
jest.mock('../../staking', () => ({
|
|
38
|
+
...jest.requireActual('../../staking'),
|
|
35
39
|
buildStakingTransactionParams: jest.fn(),
|
|
36
40
|
prepareStakingIntent: jest.fn((_config, _currencyId, intent) => Promise.resolve(intent)),
|
|
37
41
|
}))
|
|
@@ -198,7 +202,8 @@ describe('common', () => {
|
|
|
198
202
|
const result = await prepareUnsignedTxParams(
|
|
199
203
|
testConfig,
|
|
200
204
|
'sei_evm',
|
|
201
|
-
makeStakingIntent(spendableBalance)
|
|
205
|
+
makeStakingIntent(spendableBalance),
|
|
206
|
+
testLogger
|
|
202
207
|
)
|
|
203
208
|
|
|
204
209
|
expect(nodeApiMock.getGasEstimation).toHaveBeenCalledTimes(2)
|
|
@@ -229,7 +234,12 @@ describe('common', () => {
|
|
|
229
234
|
.mockRejectedValueOnce(GAS_ESTIMATION_ERROR)
|
|
230
235
|
.mockResolvedValueOnce(new BigNumber(70_000))
|
|
231
236
|
|
|
232
|
-
const result = await prepareUnsignedTxParams(
|
|
237
|
+
const result = await prepareUnsignedTxParams(
|
|
238
|
+
testConfig,
|
|
239
|
+
'sei_evm',
|
|
240
|
+
makeStakingIntent(0n),
|
|
241
|
+
testLogger
|
|
242
|
+
)
|
|
233
243
|
|
|
234
244
|
expect(nodeApiMock.getGasEstimation).toHaveBeenCalledTimes(2)
|
|
235
245
|
expect(nodeApiMock.getGasEstimation).toHaveBeenNthCalledWith(2, 'sei_evm', '0xSender', {
|
|
@@ -249,7 +259,12 @@ describe('common', () => {
|
|
|
249
259
|
|
|
250
260
|
nodeApiMock.getGasEstimation.mockRejectedValue(GAS_ESTIMATION_ERROR)
|
|
251
261
|
|
|
252
|
-
const result = await prepareUnsignedTxParams(
|
|
262
|
+
const result = await prepareUnsignedTxParams(
|
|
263
|
+
testConfig,
|
|
264
|
+
'sei_evm',
|
|
265
|
+
makeStakingIntent(0n),
|
|
266
|
+
testLogger
|
|
267
|
+
)
|
|
253
268
|
|
|
254
269
|
expect(nodeApiMock.getGasEstimation).toHaveBeenCalledTimes(2)
|
|
255
270
|
expect(result.gasLimit).toEqual(new BigNumber(0))
|
|
@@ -274,7 +289,12 @@ describe('common', () => {
|
|
|
274
289
|
.mockRejectedValueOnce(GAS_ESTIMATION_ERROR)
|
|
275
290
|
.mockResolvedValueOnce(new BigNumber(1_412_179))
|
|
276
291
|
|
|
277
|
-
const result = await prepareUnsignedTxParams(
|
|
292
|
+
const result = await prepareUnsignedTxParams(
|
|
293
|
+
testConfig,
|
|
294
|
+
'sei_evm',
|
|
295
|
+
makeStakingIntent(0n),
|
|
296
|
+
testLogger
|
|
297
|
+
)
|
|
278
298
|
|
|
279
299
|
expect(nodeApiMock.getGasEstimation).toHaveBeenCalledTimes(2)
|
|
280
300
|
// Retry rebuilds BOTH calldata and value from the min unit (USEI_TO_EVM_SCALE), so the
|
|
@@ -310,7 +330,8 @@ describe('common', () => {
|
|
|
310
330
|
valAddress: '0xVaultAddress',
|
|
311
331
|
feesStrategy: 'medium',
|
|
312
332
|
data: { type: 'buffer', value: Buffer.from([]) },
|
|
313
|
-
})
|
|
333
|
+
}),
|
|
334
|
+
testLogger
|
|
314
335
|
)
|
|
315
336
|
|
|
316
337
|
// 237279 × 1.2 = 284734.8 → ceil → 284735
|
|
@@ -338,7 +359,8 @@ describe('common', () => {
|
|
|
338
359
|
valAddress: '0xVaultAddress',
|
|
339
360
|
feesStrategy: 'medium',
|
|
340
361
|
data: { type: 'buffer', value: Buffer.from([]) },
|
|
341
|
-
})
|
|
362
|
+
}),
|
|
363
|
+
testLogger
|
|
342
364
|
)
|
|
343
365
|
|
|
344
366
|
expect(result.gasLimit).toEqual(new BigNumber(284_735))
|
|
@@ -365,6 +387,7 @@ describe('common', () => {
|
|
|
365
387
|
feesStrategy: 'medium',
|
|
366
388
|
data: { type: 'buffer', value: Buffer.from([]) },
|
|
367
389
|
}),
|
|
390
|
+
testLogger,
|
|
368
391
|
{ gasLimit: 300_000n }
|
|
369
392
|
)
|
|
370
393
|
|
|
@@ -385,7 +408,8 @@ describe('common', () => {
|
|
|
385
408
|
recipient: '0x7b2C7232f9E38F30E2868f0E5Bf311Cd83554b5A',
|
|
386
409
|
sender: '0xSender',
|
|
387
410
|
data: { type: 'buffer', value: Buffer.from([]) },
|
|
388
|
-
})
|
|
411
|
+
}),
|
|
412
|
+
testLogger
|
|
389
413
|
)
|
|
390
414
|
|
|
391
415
|
expect(nodeApiMock.getGasEstimation).toHaveBeenCalledTimes(1)
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import { DEFAULT_GAS_LIMIT } from '
|
|
4
|
+
import { DEFAULT_GAS_LIMIT } from '../../logic-public'
|
|
5
5
|
import {
|
|
6
6
|
computeEIP7623GasLimit,
|
|
7
7
|
DEFAULT_CALLDATA_FLOOR_GAS_PER_TOKEN,
|
|
8
8
|
DEFAULT_CALLDATA_FLOOR_ZERO_BYTE_TOKENS,
|
|
9
|
-
} from '
|
|
9
|
+
} from '../computeGasLimit'
|
|
10
10
|
|
|
11
11
|
const EIP_7623 = {
|
|
12
12
|
gasPerToken: DEFAULT_CALLDATA_FLOOR_GAS_PER_TOKEN,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import type { EvmConfigInfo } from '
|
|
4
|
+
import type { EvmConfigInfo } from '../../config'
|
|
5
5
|
import type { BufferTxData, MemoNotSupported } from '@ledgerhq/coin-module-framework/api/types'
|
|
6
6
|
import {
|
|
7
7
|
createSendTransactionIntentMockData,
|
|
@@ -9,13 +9,13 @@ import {
|
|
|
9
9
|
} from '@ledgerhq/coin-module-framework/test-utils'
|
|
10
10
|
import BigNumber from 'bignumber.js'
|
|
11
11
|
import { ethers } from 'ethers'
|
|
12
|
-
import { createMockEvmContext, mkExternalNode, mkLedgerNode } from '
|
|
13
|
-
import { getNodeApi } from '
|
|
14
|
-
import { mockNodeApi } from '
|
|
15
|
-
import { craftTransaction } from '
|
|
12
|
+
import { createMockEvmContext, mkExternalNode, mkLedgerNode } from '../../fixtures/context.fixtures'
|
|
13
|
+
import { getNodeApi } from '../../network/node'
|
|
14
|
+
import { mockNodeApi } from '../../network/node/node.fixtures'
|
|
15
|
+
import { craftTransaction } from '../craftTransaction'
|
|
16
16
|
|
|
17
|
-
jest.mock('
|
|
18
|
-
...jest.requireActual('
|
|
17
|
+
jest.mock('../../network/node', () => ({
|
|
18
|
+
...jest.requireActual('../../network/node'),
|
|
19
19
|
getNodeApi: jest.fn(),
|
|
20
20
|
}))
|
|
21
21
|
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
|
|
4
4
|
import type { MemoNotSupported, BufferTxData } from '@ledgerhq/coin-module-framework/api/types'
|
|
5
5
|
import { createSendTransactionIntentMockData } from '@ledgerhq/coin-module-framework/test-utils'
|
|
6
|
-
import * as commonModule from '
|
|
7
|
-
import { craftTransactionData } from '
|
|
6
|
+
import * as commonModule from '../common'
|
|
7
|
+
import { craftTransactionData } from '../craftTransactionData'
|
|
8
8
|
|
|
9
|
-
jest.mock('
|
|
10
|
-
const originalModule = jest.requireActual('
|
|
9
|
+
jest.mock('../common', () => {
|
|
10
|
+
const originalModule = jest.requireActual('../common')
|
|
11
11
|
return {
|
|
12
12
|
...originalModule,
|
|
13
13
|
getCallData: jest.fn(),
|