@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
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
+
import type { EvmContext } from '../../config'
|
|
4
5
|
import type {
|
|
5
6
|
BufferTxData,
|
|
6
7
|
MemoNotSupported,
|
|
@@ -16,7 +17,6 @@ import {
|
|
|
16
17
|
} from '@ledgerhq/coin-module-framework/errors'
|
|
17
18
|
import { createStakingTransactionIntentMockData } from '@ledgerhq/coin-module-framework/test-utils'
|
|
18
19
|
import BigNumber from 'bignumber.js'
|
|
19
|
-
import { createContext, setCoinConfig } from '../config'
|
|
20
20
|
import {
|
|
21
21
|
ClaimRewardsFeesWarning,
|
|
22
22
|
ETHAddressNonEIP,
|
|
@@ -30,27 +30,28 @@ import {
|
|
|
30
30
|
RecipientIsNewAccount,
|
|
31
31
|
RedelegateDstValAddressRequired,
|
|
32
32
|
ValAddressRequired,
|
|
33
|
-
} from '
|
|
33
|
+
} from '../../errors'
|
|
34
34
|
import {
|
|
35
|
-
|
|
35
|
+
createMockEvmConfigInfo,
|
|
36
|
+
createMockEvmContext,
|
|
36
37
|
mkLedgerExplorer,
|
|
37
38
|
mkLedgerGasTracker,
|
|
38
39
|
mkLedgerNode,
|
|
39
|
-
} from '
|
|
40
|
-
import ledgerExplorer from '
|
|
41
|
-
import ledgerGasTracker from '
|
|
42
|
-
import { getNodeApi } from '
|
|
43
|
-
import { mockNodeApi } from '
|
|
44
|
-
import * as computeGasLimitModule from '
|
|
45
|
-
import { validateIntent } from '
|
|
46
|
-
|
|
47
|
-
jest.mock('
|
|
48
|
-
...jest.requireActual('
|
|
40
|
+
} from '../../fixtures/context.fixtures'
|
|
41
|
+
import ledgerExplorer from '../../network/explorer/ledger'
|
|
42
|
+
import ledgerGasTracker from '../../network/gasTracker/ledger'
|
|
43
|
+
import { getNodeApi } from '../../network/node'
|
|
44
|
+
import { mockNodeApi } from '../../network/node/node.fixtures'
|
|
45
|
+
import * as computeGasLimitModule from '../computeGasLimit'
|
|
46
|
+
import { validateIntent } from '../validateIntent'
|
|
47
|
+
|
|
48
|
+
jest.mock('../computeGasLimit', () => ({
|
|
49
|
+
...jest.requireActual('../computeGasLimit'),
|
|
49
50
|
computeEIP7623GasLimit: jest.fn().mockReturnValue(0n),
|
|
50
51
|
}))
|
|
51
52
|
|
|
52
|
-
jest.mock('
|
|
53
|
-
...jest.requireActual('
|
|
53
|
+
jest.mock('../../network/node', () => ({
|
|
54
|
+
...jest.requireActual('../../network/node'),
|
|
54
55
|
getNodeApi: jest.fn(),
|
|
55
56
|
}))
|
|
56
57
|
|
|
@@ -88,10 +89,11 @@ function eip1559Intent(
|
|
|
88
89
|
|
|
89
90
|
describe('validateIntent', () => {
|
|
90
91
|
const nodeApiMock = mockNodeApi()
|
|
92
|
+
let context: EvmContext
|
|
91
93
|
|
|
92
94
|
beforeEach(() => {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
+
context = createMockEvmContext(
|
|
96
|
+
createMockEvmConfigInfo({
|
|
95
97
|
chainId: 1,
|
|
96
98
|
node: mkLedgerNode({ explorerId: 'eth' }),
|
|
97
99
|
name: 'Ethereum',
|
|
@@ -155,7 +157,7 @@ describe('validateIntent', () => {
|
|
|
155
157
|
['does not warn', 'erc20', {}],
|
|
156
158
|
])('%s with too high fees on a %s asset', async (_s, assetType, expectedWarnings) => {
|
|
157
159
|
const res = await validateIntent(
|
|
158
|
-
|
|
160
|
+
context,
|
|
159
161
|
'ethereum',
|
|
160
162
|
eip1559Intent({
|
|
161
163
|
amount: 1n,
|
|
@@ -175,7 +177,7 @@ describe('validateIntent', () => {
|
|
|
175
177
|
describe('recipient', () => {
|
|
176
178
|
it('detects the missing recipient with an error', async () => {
|
|
177
179
|
const res = await validateIntent(
|
|
178
|
-
|
|
180
|
+
context,
|
|
179
181
|
'ethereum',
|
|
180
182
|
eip1559Intent({ amount: 1n, recipient: '' }),
|
|
181
183
|
[{ value: 50n, asset: { type: 'native' } }]
|
|
@@ -190,7 +192,7 @@ describe('validateIntent', () => {
|
|
|
190
192
|
|
|
191
193
|
it('detects the incorrect recipient not being an eth address with an error', async () => {
|
|
192
194
|
const res = await validateIntent(
|
|
193
|
-
|
|
195
|
+
context,
|
|
194
196
|
'ethereum',
|
|
195
197
|
eip1559Intent({ amount: 1n, recipient: 'invalid-address' }),
|
|
196
198
|
[{ value: 50n, asset: { type: 'native' } }]
|
|
@@ -207,7 +209,7 @@ describe('validateIntent', () => {
|
|
|
207
209
|
|
|
208
210
|
it('detects the recipient being an ICAP with an error', async () => {
|
|
209
211
|
const res = await validateIntent(
|
|
210
|
-
|
|
212
|
+
context,
|
|
211
213
|
'ethereum',
|
|
212
214
|
eip1559Intent({
|
|
213
215
|
amount: 1n,
|
|
@@ -229,7 +231,7 @@ describe('validateIntent', () => {
|
|
|
229
231
|
|
|
230
232
|
function nativeSendToRecipient(overrides = {}) {
|
|
231
233
|
return validateIntent(
|
|
232
|
-
|
|
234
|
+
context,
|
|
233
235
|
'ethereum',
|
|
234
236
|
eip1559Intent({ amount: 1n, recipient: RECIPIENT, ...overrides }),
|
|
235
237
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
@@ -318,7 +320,7 @@ describe('validateIntent', () => {
|
|
|
318
320
|
|
|
319
321
|
it('detects the recipient not being an EIP55 address with a warning', async () => {
|
|
320
322
|
const res = await validateIntent(
|
|
321
|
-
|
|
323
|
+
context,
|
|
322
324
|
'ethereum',
|
|
323
325
|
eip1559Intent({
|
|
324
326
|
amount: 1n,
|
|
@@ -338,7 +340,7 @@ describe('validateIntent', () => {
|
|
|
338
340
|
describe('amount', () => {
|
|
339
341
|
it('detects an intent for a smart contract interaction without amount-related errors', async () => {
|
|
340
342
|
const res = await validateIntent(
|
|
341
|
-
|
|
343
|
+
context,
|
|
342
344
|
'ethereum',
|
|
343
345
|
eip1559Intent({
|
|
344
346
|
amount: 0n,
|
|
@@ -357,7 +359,7 @@ describe('validateIntent', () => {
|
|
|
357
359
|
|
|
358
360
|
it('detects an intent for native asset sending without amount with an error', async () => {
|
|
359
361
|
const res = await validateIntent(
|
|
360
|
-
|
|
362
|
+
context,
|
|
361
363
|
'ethereum',
|
|
362
364
|
eip1559Intent({
|
|
363
365
|
amount: 0n,
|
|
@@ -377,7 +379,7 @@ describe('validateIntent', () => {
|
|
|
377
379
|
nodeApiMock.getTransactionCount.mockResolvedValue(10)
|
|
378
380
|
|
|
379
381
|
const res = await validateIntent(
|
|
380
|
-
|
|
382
|
+
context,
|
|
381
383
|
'ethereum',
|
|
382
384
|
eip1559Intent({
|
|
383
385
|
recipient: '0xe2ca7390e76c5A992749bB622087310d2e63ca29',
|
|
@@ -396,7 +398,7 @@ describe('validateIntent', () => {
|
|
|
396
398
|
|
|
397
399
|
it('detects native asset sending intent with an error', async () => {
|
|
398
400
|
const res = await validateIntent(
|
|
399
|
-
|
|
401
|
+
context,
|
|
400
402
|
'ethereum',
|
|
401
403
|
eip1559Intent({
|
|
402
404
|
amount: 20n,
|
|
@@ -442,7 +444,7 @@ describe('validateIntent', () => {
|
|
|
442
444
|
})
|
|
443
445
|
|
|
444
446
|
const res = await validateIntent(
|
|
445
|
-
|
|
447
|
+
context,
|
|
446
448
|
'ethereum',
|
|
447
449
|
eip1559Intent({
|
|
448
450
|
sender: 'sender-address',
|
|
@@ -474,7 +476,7 @@ describe('validateIntent', () => {
|
|
|
474
476
|
|
|
475
477
|
it('detects NotEnoughBalance when spending would dip into locked funds', async () => {
|
|
476
478
|
const res = await validateIntent(
|
|
477
|
-
|
|
479
|
+
context,
|
|
478
480
|
'ethereum',
|
|
479
481
|
eip1559Intent({
|
|
480
482
|
recipient: '0xe2ca7390e76c5A992749bB622087310d2e63ca29',
|
|
@@ -509,7 +511,7 @@ describe('validateIntent', () => {
|
|
|
509
511
|
})
|
|
510
512
|
|
|
511
513
|
const res = await validateIntent(
|
|
512
|
-
|
|
514
|
+
context,
|
|
513
515
|
'ethereum',
|
|
514
516
|
legacyIntent({
|
|
515
517
|
recipient: '0xe2ca7390e76c5A992749bB622087310d2e63ca29',
|
|
@@ -532,7 +534,7 @@ describe('validateIntent', () => {
|
|
|
532
534
|
describe('staking', () => {
|
|
533
535
|
it('detects missing validator address for delegate with an error', async () => {
|
|
534
536
|
const res = await validateIntent(
|
|
535
|
-
|
|
537
|
+
context,
|
|
536
538
|
'sei_evm',
|
|
537
539
|
createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
|
|
538
540
|
type: 'staking-legacy',
|
|
@@ -556,7 +558,7 @@ describe('validateIntent', () => {
|
|
|
556
558
|
|
|
557
559
|
it('detects missing destination validator address for redelegate with an error', async () => {
|
|
558
560
|
const res = await validateIntent(
|
|
559
|
-
|
|
561
|
+
context,
|
|
560
562
|
'sei_evm',
|
|
561
563
|
createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
|
|
562
564
|
type: 'staking-legacy',
|
|
@@ -580,7 +582,7 @@ describe('validateIntent', () => {
|
|
|
580
582
|
|
|
581
583
|
it('detects delegate total spent greater than spendable balance with an error', async () => {
|
|
582
584
|
const res = await validateIntent(
|
|
583
|
-
|
|
585
|
+
context,
|
|
584
586
|
'sei_evm',
|
|
585
587
|
createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
|
|
586
588
|
type: 'staking-legacy',
|
|
@@ -605,7 +607,7 @@ describe('validateIntent', () => {
|
|
|
605
607
|
|
|
606
608
|
it('allows undelegate when amount exceeds spendable but fees fit in spendable balance', async () => {
|
|
607
609
|
const res = await validateIntent(
|
|
608
|
-
|
|
610
|
+
context,
|
|
609
611
|
'sei_evm',
|
|
610
612
|
createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
|
|
611
613
|
type: 'staking-legacy',
|
|
@@ -627,7 +629,7 @@ describe('validateIntent', () => {
|
|
|
627
629
|
|
|
628
630
|
it('allows redelegate when amount exceeds spendable but fees fit in spendable balance', async () => {
|
|
629
631
|
const res = await validateIntent(
|
|
630
|
-
|
|
632
|
+
context,
|
|
631
633
|
'sei_evm',
|
|
632
634
|
createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
|
|
633
635
|
type: 'staking-legacy',
|
|
@@ -650,7 +652,7 @@ describe('validateIntent', () => {
|
|
|
650
652
|
|
|
651
653
|
it('detects staking fees greater than native balance with an error', async () => {
|
|
652
654
|
const res = await validateIntent(
|
|
653
|
-
|
|
655
|
+
context,
|
|
654
656
|
'sei_evm',
|
|
655
657
|
createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
|
|
656
658
|
type: 'staking-legacy',
|
|
@@ -675,7 +677,7 @@ describe('validateIntent', () => {
|
|
|
675
677
|
|
|
676
678
|
it('should return an error when not enough balance for a claim reward', async () => {
|
|
677
679
|
const res = await validateIntent(
|
|
678
|
-
|
|
680
|
+
context,
|
|
679
681
|
'sei_evm',
|
|
680
682
|
createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
|
|
681
683
|
type: 'staking-legacy',
|
|
@@ -698,7 +700,7 @@ describe('validateIntent', () => {
|
|
|
698
700
|
|
|
699
701
|
it('should return an error when no validator specified for a claim reward', async () => {
|
|
700
702
|
const res = await validateIntent(
|
|
701
|
-
|
|
703
|
+
context,
|
|
702
704
|
'sei_evm',
|
|
703
705
|
createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
|
|
704
706
|
type: 'staking-legacy',
|
|
@@ -721,7 +723,7 @@ describe('validateIntent', () => {
|
|
|
721
723
|
|
|
722
724
|
it('should return no error for a valid claim reward', async () => {
|
|
723
725
|
const res = await validateIntent(
|
|
724
|
-
|
|
726
|
+
context,
|
|
725
727
|
'sei_evm',
|
|
726
728
|
createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
|
|
727
729
|
type: 'staking-legacy',
|
|
@@ -750,7 +752,7 @@ describe('validateIntent', () => {
|
|
|
750
752
|
const balance = 1_000_000n
|
|
751
753
|
const totalFees = 100_000n // gasLimit(100_000) × gasPrice(1)
|
|
752
754
|
const res = await validateIntent(
|
|
753
|
-
|
|
755
|
+
context,
|
|
754
756
|
'unknown_chain',
|
|
755
757
|
createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
|
|
756
758
|
type: 'staking-legacy',
|
|
@@ -773,7 +775,7 @@ describe('validateIntent', () => {
|
|
|
773
775
|
const balance = 10n ** 18n
|
|
774
776
|
const fees = 2n * 10n ** 17n // > configuredReserve
|
|
775
777
|
const res = await validateIntent(
|
|
776
|
-
|
|
778
|
+
context,
|
|
777
779
|
'sei_evm',
|
|
778
780
|
createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
|
|
779
781
|
type: 'staking-legacy',
|
|
@@ -801,7 +803,7 @@ describe('validateIntent', () => {
|
|
|
801
803
|
const balance = 10n ** 18n
|
|
802
804
|
const fees = 10n ** 14n // < configuredReserve
|
|
803
805
|
const res = await validateIntent(
|
|
804
|
-
|
|
806
|
+
context,
|
|
805
807
|
'sei_evm',
|
|
806
808
|
createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
|
|
807
809
|
type: 'staking-legacy',
|
|
@@ -854,7 +856,7 @@ describe('validateIntent', () => {
|
|
|
854
856
|
},
|
|
855
857
|
])('$name', async ({ amount, native }) => {
|
|
856
858
|
const res = await validateIntent(
|
|
857
|
-
|
|
859
|
+
context,
|
|
858
860
|
'sei_evm',
|
|
859
861
|
claimRewardIntent({ amount, native }),
|
|
860
862
|
claimRewardBalances(native),
|
|
@@ -881,7 +883,7 @@ describe('validateIntent', () => {
|
|
|
881
883
|
},
|
|
882
884
|
])('$name', async ({ amount, native }) => {
|
|
883
885
|
const res = await validateIntent(
|
|
884
|
-
|
|
886
|
+
context,
|
|
885
887
|
'sei_evm',
|
|
886
888
|
claimRewardIntent({ amount, native }),
|
|
887
889
|
claimRewardBalances(native),
|
|
@@ -899,7 +901,7 @@ describe('validateIntent', () => {
|
|
|
899
901
|
])('for %s', (_s, createIntent) => {
|
|
900
902
|
it('detects missing fees with an error', async () => {
|
|
901
903
|
const res = await validateIntent(
|
|
902
|
-
|
|
904
|
+
context,
|
|
903
905
|
'ethereum',
|
|
904
906
|
createIntent({}),
|
|
905
907
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
@@ -915,7 +917,7 @@ describe('validateIntent', () => {
|
|
|
915
917
|
|
|
916
918
|
it('detects a missing gasLimit with an error', async () => {
|
|
917
919
|
const res = await validateIntent(
|
|
918
|
-
|
|
920
|
+
context,
|
|
919
921
|
'ethereum',
|
|
920
922
|
createIntent({}),
|
|
921
923
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
@@ -934,7 +936,7 @@ describe('validateIntent', () => {
|
|
|
934
936
|
|
|
935
937
|
it('detects a gasLimit = 0 with an error', async () => {
|
|
936
938
|
const res = await validateIntent(
|
|
937
|
-
|
|
939
|
+
context,
|
|
938
940
|
'ethereum',
|
|
939
941
|
createIntent({}),
|
|
940
942
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
@@ -953,7 +955,7 @@ describe('validateIntent', () => {
|
|
|
953
955
|
|
|
954
956
|
it('detects a customGasLimit = 0 with an error', async () => {
|
|
955
957
|
const res = await validateIntent(
|
|
956
|
-
|
|
958
|
+
context,
|
|
957
959
|
'ethereum',
|
|
958
960
|
createIntent({}),
|
|
959
961
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
@@ -972,7 +974,7 @@ describe('validateIntent', () => {
|
|
|
972
974
|
|
|
973
975
|
it('if the recipient has been set, detects fees being too high for the account balance with an error', async () => {
|
|
974
976
|
const notEnoughBalanceRes = await validateIntent(
|
|
975
|
-
|
|
977
|
+
context,
|
|
976
978
|
'ethereum',
|
|
977
979
|
createIntent({ recipient: 'recipient-address' }),
|
|
978
980
|
[{ value: 10n, asset: { type: 'native' } }],
|
|
@@ -987,7 +989,7 @@ describe('validateIntent', () => {
|
|
|
987
989
|
}
|
|
988
990
|
)
|
|
989
991
|
const notEnoughBalanceSponsoredRes = await validateIntent(
|
|
990
|
-
|
|
992
|
+
context,
|
|
991
993
|
'ethereum',
|
|
992
994
|
createIntent({ recipient: 'recipient-address' }),
|
|
993
995
|
[{ value: 10n, asset: { type: 'native' } }],
|
|
@@ -1003,7 +1005,7 @@ describe('validateIntent', () => {
|
|
|
1003
1005
|
}
|
|
1004
1006
|
)
|
|
1005
1007
|
const enoughBalanceRes = await validateIntent(
|
|
1006
|
-
|
|
1008
|
+
context,
|
|
1007
1009
|
'ethereum',
|
|
1008
1010
|
createIntent({ recipient: 'recipient-address' }),
|
|
1009
1011
|
[{ value: 10n, asset: { type: 'native' } }],
|
|
@@ -1039,7 +1041,7 @@ describe('validateIntent', () => {
|
|
|
1039
1041
|
// gas fee alone fits in the available balance, but the additionalFees
|
|
1040
1042
|
// (e.g. L1 data fee on L2s) push the total above the native balance.
|
|
1041
1043
|
const res = await validateIntent(
|
|
1042
|
-
|
|
1044
|
+
context,
|
|
1043
1045
|
'ethereum',
|
|
1044
1046
|
createIntent({ recipient: 'recipient-address' }),
|
|
1045
1047
|
[{ value: 10n, asset: { type: 'native' } }],
|
|
@@ -1064,7 +1066,7 @@ describe('validateIntent', () => {
|
|
|
1064
1066
|
|
|
1065
1067
|
it('if the recipient has not been set, does not detect gas being too high', async () => {
|
|
1066
1068
|
const notEnoughBalanceRes = await validateIntent(
|
|
1067
|
-
|
|
1069
|
+
context,
|
|
1068
1070
|
'ethereum',
|
|
1069
1071
|
createIntent({ recipient: '' }),
|
|
1070
1072
|
[{ value: 10n, asset: { type: 'native' } }],
|
|
@@ -1078,7 +1080,7 @@ describe('validateIntent', () => {
|
|
|
1078
1080
|
}
|
|
1079
1081
|
)
|
|
1080
1082
|
const enoughBalanceRes = await validateIntent(
|
|
1081
|
-
|
|
1083
|
+
context,
|
|
1082
1084
|
'ethereum',
|
|
1083
1085
|
createIntent({ recipient: '' }),
|
|
1084
1086
|
[{ value: 10n, asset: { type: 'native' } }],
|
|
@@ -1109,7 +1111,7 @@ describe('validateIntent', () => {
|
|
|
1109
1111
|
jest.mocked(computeGasLimitModule.computeEIP7623GasLimit).mockReturnValue(eip7623GasLimit)
|
|
1110
1112
|
|
|
1111
1113
|
const res = await validateIntent(
|
|
1112
|
-
|
|
1114
|
+
context,
|
|
1113
1115
|
'ethereum',
|
|
1114
1116
|
createIntent({}),
|
|
1115
1117
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
@@ -1133,7 +1135,7 @@ describe('validateIntent', () => {
|
|
|
1133
1135
|
jest.mocked(computeGasLimitModule.computeEIP7623GasLimit).mockReturnValue(eip7623GasLimit)
|
|
1134
1136
|
|
|
1135
1137
|
const res = await validateIntent(
|
|
1136
|
-
|
|
1138
|
+
context,
|
|
1137
1139
|
'ethereum',
|
|
1138
1140
|
createIntent({}),
|
|
1139
1141
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
@@ -1154,8 +1156,8 @@ describe('validateIntent', () => {
|
|
|
1154
1156
|
|
|
1155
1157
|
describe('calldata floor coin config', () => {
|
|
1156
1158
|
it('forwards the configured floor parameters to computeEIP7623GasLimit', async () => {
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
+
context = createMockEvmContext(
|
|
1160
|
+
createMockEvmConfigInfo({
|
|
1159
1161
|
chainId: 1,
|
|
1160
1162
|
node: mkLedgerNode({ explorerId: 'eth' }),
|
|
1161
1163
|
explorer: mkLedgerExplorer({ explorerId: 'eth' }),
|
|
@@ -1166,7 +1168,7 @@ describe('validateIntent', () => {
|
|
|
1166
1168
|
)
|
|
1167
1169
|
|
|
1168
1170
|
await validateIntent(
|
|
1169
|
-
|
|
1171
|
+
context,
|
|
1170
1172
|
'ethereum',
|
|
1171
1173
|
createIntent({}),
|
|
1172
1174
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
@@ -1182,7 +1184,7 @@ describe('validateIntent', () => {
|
|
|
1182
1184
|
|
|
1183
1185
|
it('forwards the EIP-7623 defaults when the coin config sets none', async () => {
|
|
1184
1186
|
await validateIntent(
|
|
1185
|
-
|
|
1187
|
+
context,
|
|
1186
1188
|
'ethereum',
|
|
1187
1189
|
createIntent({}),
|
|
1188
1190
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
@@ -1199,7 +1201,7 @@ describe('validateIntent', () => {
|
|
|
1199
1201
|
|
|
1200
1202
|
it('detects customGasLimit being lower than gasLimit with a warning', async () => {
|
|
1201
1203
|
const res = await validateIntent(
|
|
1202
|
-
|
|
1204
|
+
context,
|
|
1203
1205
|
'ethereum',
|
|
1204
1206
|
createIntent({}),
|
|
1205
1207
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
@@ -1224,7 +1226,7 @@ describe('validateIntent', () => {
|
|
|
1224
1226
|
describe('eip1559 specific', () => {
|
|
1225
1227
|
it('detects a maxPriorityFeePerGas = 0 with an error', async () => {
|
|
1226
1228
|
const res = await validateIntent(
|
|
1227
|
-
|
|
1229
|
+
context,
|
|
1228
1230
|
'ethereum',
|
|
1229
1231
|
eip1559Intent({}),
|
|
1230
1232
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
@@ -1243,7 +1245,7 @@ describe('validateIntent', () => {
|
|
|
1243
1245
|
|
|
1244
1246
|
it('detects maxFeePerGas being greater than max gasOptions maxFeePerGas with an error', async () => {
|
|
1245
1247
|
const res = await validateIntent(
|
|
1246
|
-
|
|
1248
|
+
context,
|
|
1247
1249
|
'ethereum',
|
|
1248
1250
|
eip1559Intent({}),
|
|
1249
1251
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
@@ -1283,7 +1285,7 @@ describe('validateIntent', () => {
|
|
|
1283
1285
|
})
|
|
1284
1286
|
|
|
1285
1287
|
const res = await validateIntent(
|
|
1286
|
-
|
|
1288
|
+
context,
|
|
1287
1289
|
'ethereum',
|
|
1288
1290
|
eip1559Intent({}),
|
|
1289
1291
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
@@ -1323,7 +1325,7 @@ describe('validateIntent', () => {
|
|
|
1323
1325
|
})
|
|
1324
1326
|
|
|
1325
1327
|
const res = await validateIntent(
|
|
1326
|
-
|
|
1328
|
+
context,
|
|
1327
1329
|
'ethereum',
|
|
1328
1330
|
eip1559Intent({}),
|
|
1329
1331
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
@@ -1363,7 +1365,7 @@ describe('validateIntent', () => {
|
|
|
1363
1365
|
})
|
|
1364
1366
|
|
|
1365
1367
|
const res = await validateIntent(
|
|
1366
|
-
|
|
1368
|
+
context,
|
|
1367
1369
|
'ethereum',
|
|
1368
1370
|
eip1559Intent({}),
|
|
1369
1371
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
@@ -1382,8 +1384,8 @@ describe('validateIntent', () => {
|
|
|
1382
1384
|
|
|
1383
1385
|
describe('minGasPrice', () => {
|
|
1384
1386
|
beforeEach(() => {
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
+
context = createMockEvmContext(
|
|
1388
|
+
createMockEvmConfigInfo({
|
|
1387
1389
|
chainId: 1,
|
|
1388
1390
|
node: mkLedgerNode({ explorerId: 'eth' }),
|
|
1389
1391
|
explorer: mkLedgerExplorer({ explorerId: 'eth' }),
|
|
@@ -1395,7 +1397,7 @@ describe('validateIntent', () => {
|
|
|
1395
1397
|
|
|
1396
1398
|
it('raises an error when maxPriorityFeePerGas is below the chain minGasPrice', async () => {
|
|
1397
1399
|
const res = await validateIntent(
|
|
1398
|
-
|
|
1400
|
+
context,
|
|
1399
1401
|
'ethereum',
|
|
1400
1402
|
eip1559Intent({}),
|
|
1401
1403
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
@@ -1414,7 +1416,7 @@ describe('validateIntent', () => {
|
|
|
1414
1416
|
|
|
1415
1417
|
it('does not raise an error when maxPriorityFeePerGas is above the chain minGasPrice', async () => {
|
|
1416
1418
|
const res = await validateIntent(
|
|
1417
|
-
|
|
1419
|
+
context,
|
|
1418
1420
|
'ethereum',
|
|
1419
1421
|
eip1559Intent({}),
|
|
1420
1422
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
@@ -1436,8 +1438,8 @@ describe('validateIntent', () => {
|
|
|
1436
1438
|
describe('legacy specific', () => {
|
|
1437
1439
|
describe('minGasPrice', () => {
|
|
1438
1440
|
beforeEach(() => {
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
+
context = createMockEvmContext(
|
|
1442
|
+
createMockEvmConfigInfo({
|
|
1441
1443
|
chainId: 1,
|
|
1442
1444
|
node: mkLedgerNode({ explorerId: 'eth' }),
|
|
1443
1445
|
explorer: mkLedgerExplorer({ explorerId: 'eth' }),
|
|
@@ -1449,7 +1451,7 @@ describe('validateIntent', () => {
|
|
|
1449
1451
|
|
|
1450
1452
|
it('raises an error when gasPrice is below the chain minGasPrice', async () => {
|
|
1451
1453
|
const res = await validateIntent(
|
|
1452
|
-
|
|
1454
|
+
context,
|
|
1453
1455
|
'ethereum',
|
|
1454
1456
|
legacyIntent({ recipient: '0xe2ca7390e76c5A992749bB622087310d2e63ca29' }),
|
|
1455
1457
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
@@ -1468,7 +1470,7 @@ describe('validateIntent', () => {
|
|
|
1468
1470
|
|
|
1469
1471
|
it('does not raise an error when gasPrice is above the chain minGasPrice', async () => {
|
|
1470
1472
|
const res = await validateIntent(
|
|
1471
|
-
|
|
1473
|
+
context,
|
|
1472
1474
|
'ethereum',
|
|
1473
1475
|
legacyIntent({ recipient: '0xe2ca7390e76c5A992749bB622087310d2e63ca29' }),
|
|
1474
1476
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
@@ -1612,7 +1614,7 @@ describe('validateIntent', () => {
|
|
|
1612
1614
|
})
|
|
1613
1615
|
|
|
1614
1616
|
const res = await validateIntent(
|
|
1615
|
-
|
|
1617
|
+
context,
|
|
1616
1618
|
'ethereum',
|
|
1617
1619
|
legacyIntent({
|
|
1618
1620
|
...amount,
|
|
@@ -1688,7 +1690,7 @@ describe('validateIntent', () => {
|
|
|
1688
1690
|
})
|
|
1689
1691
|
|
|
1690
1692
|
const res = await validateIntent(
|
|
1691
|
-
|
|
1693
|
+
context,
|
|
1692
1694
|
'ethereum',
|
|
1693
1695
|
eip1559Intent({
|
|
1694
1696
|
...amount,
|
|
@@ -1769,7 +1771,7 @@ describe('validateIntent', () => {
|
|
|
1769
1771
|
})
|
|
1770
1772
|
|
|
1771
1773
|
const res = await validateIntent(
|
|
1772
|
-
|
|
1774
|
+
context,
|
|
1773
1775
|
'ethereum',
|
|
1774
1776
|
eip1559Intent({
|
|
1775
1777
|
...amount,
|
|
@@ -1835,7 +1837,7 @@ describe('validateIntent', () => {
|
|
|
1835
1837
|
async (_s, createIntent, estimation) => {
|
|
1836
1838
|
expect(
|
|
1837
1839
|
await validateIntent(
|
|
1838
|
-
|
|
1840
|
+
context,
|
|
1839
1841
|
'ethereum',
|
|
1840
1842
|
createIntent({
|
|
1841
1843
|
amount: 2n,
|
|
@@ -13,6 +13,7 @@ import type {
|
|
|
13
13
|
TransactionIntent,
|
|
14
14
|
TransactionValidation,
|
|
15
15
|
} from '@ledgerhq/coin-module-framework/api/types'
|
|
16
|
+
import type { Logger } from '@ledgerhq/coin-module-framework/config'
|
|
16
17
|
import { formatCurrencyUnit } from '@ledgerhq/coin-module-framework/currencies/formatCurrencyUnit'
|
|
17
18
|
import {
|
|
18
19
|
AmountRequired,
|
|
@@ -37,11 +38,11 @@ import {
|
|
|
37
38
|
RedelegateDstValAddressRequired,
|
|
38
39
|
ValAddressRequired,
|
|
39
40
|
} from '../errors'
|
|
41
|
+
import { DEFAULT_GAS_LIMIT, isEthAddress, isStakingIntent } from '../logic-public'
|
|
40
42
|
import { getGasTracker } from '../network/gasTracker'
|
|
41
43
|
import { getNodeApi } from '../network/node'
|
|
42
44
|
import { STAKING_CONTRACTS } from '../staking'
|
|
43
45
|
import { isNative, TransactionTypes } from '../types'
|
|
44
|
-
import { DEFAULT_GAS_LIMIT, isEthAddress, isStakingIntent } from '../utils'
|
|
45
46
|
import {
|
|
46
47
|
getTransactionType,
|
|
47
48
|
isApiGasOptions,
|
|
@@ -124,7 +125,8 @@ async function validateNewAccountRecipient(
|
|
|
124
125
|
config: EvmConfigInfo,
|
|
125
126
|
currencyId: string,
|
|
126
127
|
intent: TransactionIntent<MemoNotSupported, BufferTxData>,
|
|
127
|
-
amount: bigint
|
|
128
|
+
amount: bigint,
|
|
129
|
+
logger: Logger
|
|
128
130
|
): Promise<Pick<TransactionValidation, 'errors' | 'warnings'>> {
|
|
129
131
|
const none = { errors: {}, warnings: {} }
|
|
130
132
|
const isPlainNativeSend =
|
|
@@ -135,7 +137,7 @@ async function validateNewAccountRecipient(
|
|
|
135
137
|
}
|
|
136
138
|
|
|
137
139
|
try {
|
|
138
|
-
const nodeApi = getNodeApi(config, currencyId)
|
|
140
|
+
const nodeApi = getNodeApi(config, currencyId, logger)
|
|
139
141
|
const [balance, nonce] = await Promise.all([
|
|
140
142
|
nodeApi.getCoinBalance(currencyId, intent.recipient),
|
|
141
143
|
nodeApi.getTransactionCount(currencyId, intent.recipient),
|
|
@@ -509,7 +511,8 @@ export async function validateIntent(
|
|
|
509
511
|
config,
|
|
510
512
|
currencyId,
|
|
511
513
|
intent,
|
|
512
|
-
amount
|
|
514
|
+
amount,
|
|
515
|
+
context.logger
|
|
513
516
|
)
|
|
514
517
|
|
|
515
518
|
const errors = {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
export {
|
|
5
|
+
DEFAULT_GAS_LIMIT,
|
|
6
|
+
DEFAULT_NONCE,
|
|
7
|
+
buildSmartContractDetails,
|
|
8
|
+
isEthAddress,
|
|
9
|
+
isHexString,
|
|
10
|
+
isSmartContractInput,
|
|
11
|
+
isStakingIntent,
|
|
12
|
+
normalizeAddress,
|
|
13
|
+
padHexString,
|
|
14
|
+
safeBigInt,
|
|
15
|
+
safeEncodeEIP55,
|
|
16
|
+
unwrapProxy,
|
|
17
|
+
} from './utils'
|
|
18
|
+
export type { ContractInteractionKind, EvmStakingIntent } from './utils'
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
buildSmartContractDetails,
|
|
6
|
-
isSmartContractInput,
|
|
7
|
-
parseDecimalIntegerPart,
|
|
8
|
-
safeEncodeEIP55,
|
|
9
|
-
} from './utils'
|
|
4
|
+
import { buildSmartContractDetails, isSmartContractInput, safeEncodeEIP55 } from '../utils'
|
|
10
5
|
|
|
11
6
|
describe('isSmartContractInput', () => {
|
|
12
7
|
it.each([
|
|
@@ -65,24 +60,3 @@ describe('buildSmartContractDetails', () => {
|
|
|
65
60
|
})
|
|
66
61
|
})
|
|
67
62
|
})
|
|
68
|
-
|
|
69
|
-
describe('parseDecimalIntegerPart', () => {
|
|
70
|
-
it.each([
|
|
71
|
-
['100', 100n],
|
|
72
|
-
['569.024692675122000000', 569n],
|
|
73
|
-
['0.019211023787000000', 0n],
|
|
74
|
-
[' 42 ', 42n],
|
|
75
|
-
['1.', 1n],
|
|
76
|
-
['1000000000000000000', 1000000000000000000n],
|
|
77
|
-
['-5.9', -5n],
|
|
78
|
-
] as const)('parseDecimalIntegerPart(%p) === %s', (input, expected) => {
|
|
79
|
-
expect(parseDecimalIntegerPart(input)).toBe(expected)
|
|
80
|
-
})
|
|
81
|
-
|
|
82
|
-
it.each(['', '.', 'not-a-number', 'abc.123'])(
|
|
83
|
-
'returns 0n when the integer part is not parseable (%p)',
|
|
84
|
-
(input) => {
|
|
85
|
-
expect(parseDecimalIntegerPart(input)).toBe(0n)
|
|
86
|
-
}
|
|
87
|
-
)
|
|
88
|
-
})
|