@ledgerhq/coin-evm 15.0.0 → 16.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 +40 -0
- package/lib/adapters/etherscan.d.ts.map +1 -1
- package/lib/adapters/etherscan.js +14 -0
- package/lib/adapters/etherscan.js.map +1 -1
- package/lib/adapters/ledger.d.ts.map +1 -1
- package/lib/adapters/ledger.js +2 -0
- package/lib/adapters/ledger.js.map +1 -1
- package/lib/api/index.d.ts +1 -1
- package/lib/api/index.d.ts.map +1 -1
- package/lib/api/index.js +14 -15
- package/lib/api/index.js.map +1 -1
- package/lib/chains.d.ts +7 -0
- package/lib/chains.d.ts.map +1 -1
- package/lib/chains.js +17 -1
- package/lib/chains.js.map +1 -1
- package/lib/config.d.ts +1 -1
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +2 -1
- package/lib/config.js.map +1 -1
- package/lib/errors.d.ts +11 -0
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +17 -1
- package/lib/errors.js.map +1 -1
- package/lib/logic/broadcast.d.ts +1 -1
- package/lib/logic/broadcast.d.ts.map +1 -1
- package/lib/logic/broadcast.js +2 -2
- package/lib/logic/broadcast.js.map +1 -1
- package/lib/logic/craftTransaction.d.ts +1 -1
- package/lib/logic/craftTransaction.d.ts.map +1 -1
- package/lib/logic/craftTransaction.js +3 -3
- package/lib/logic/craftTransaction.js.map +1 -1
- package/lib/logic/estimateFees.d.ts +1 -1
- package/lib/logic/estimateFees.d.ts.map +1 -1
- package/lib/logic/estimateFees.js +19 -4
- package/lib/logic/estimateFees.js.map +1 -1
- package/lib/logic/getBalance.d.ts +1 -2
- package/lib/logic/getBalance.d.ts.map +1 -1
- package/lib/logic/getBalance.js +5 -6
- package/lib/logic/getBalance.js.map +1 -1
- package/lib/logic/getBlock.d.ts +1 -1
- package/lib/logic/getBlock.d.ts.map +1 -1
- package/lib/logic/getBlock.js +23 -6
- package/lib/logic/getBlock.js.map +1 -1
- package/lib/logic/getBlockInfo.d.ts +1 -1
- package/lib/logic/getBlockInfo.d.ts.map +1 -1
- package/lib/logic/getBlockInfo.js +2 -2
- package/lib/logic/getBlockInfo.js.map +1 -1
- package/lib/logic/getNextSequence.d.ts +1 -1
- package/lib/logic/getNextSequence.d.ts.map +1 -1
- package/lib/logic/getNextSequence.js +2 -2
- package/lib/logic/getNextSequence.js.map +1 -1
- package/lib/logic/getStakes.d.ts +1 -1
- package/lib/logic/getStakes.d.ts.map +1 -1
- package/lib/logic/getStakes.js +2 -2
- package/lib/logic/getStakes.js.map +1 -1
- package/lib/logic/lastBlock.d.ts +1 -1
- package/lib/logic/lastBlock.d.ts.map +1 -1
- package/lib/logic/lastBlock.js +2 -2
- package/lib/logic/lastBlock.js.map +1 -1
- package/lib/logic/listOperations.d.ts +1 -1
- package/lib/logic/listOperations.d.ts.map +1 -1
- package/lib/logic/listOperations.js +4 -2
- package/lib/logic/listOperations.js.map +1 -1
- package/lib/logic/validateIntent.d.ts +1 -1
- package/lib/logic/validateIntent.d.ts.map +1 -1
- package/lib/logic/validateIntent.js +3 -3
- package/lib/logic/validateIntent.js.map +1 -1
- package/lib/logic.d.ts.map +1 -1
- package/lib/logic.js +5 -10
- package/lib/logic.js.map +1 -1
- package/lib/network/node/explorerProxy.d.ts.map +1 -1
- package/lib/network/node/explorerProxy.js +2 -0
- package/lib/network/node/explorerProxy.js.map +1 -1
- package/lib/network/node/ledger.d.ts.map +1 -1
- package/lib/network/node/ledger.js +2 -9
- package/lib/network/node/ledger.js.map +1 -1
- package/lib/network/node/rpc.common.d.ts.map +1 -1
- package/lib/network/node/rpc.common.js +18 -9
- package/lib/network/node/rpc.common.js.map +1 -1
- package/lib/network/node/types.d.ts +3 -1
- package/lib/network/node/types.d.ts.map +1 -1
- package/lib/network/node/types.js.map +1 -1
- package/lib/staking/detectOperationType.js +1 -1
- package/lib/staking/validators/index.d.ts +1 -1
- package/lib/staking/validators/index.d.ts.map +1 -1
- package/lib/staking/validators/index.js +2 -2
- package/lib/staking/validators/index.js.map +1 -1
- package/lib/staking/validators/monadResolver.js +1 -1
- package/lib/staking/validators/monadResolver.js.map +1 -1
- package/lib-es/adapters/etherscan.d.ts.map +1 -1
- package/lib-es/adapters/etherscan.js +14 -0
- package/lib-es/adapters/etherscan.js.map +1 -1
- package/lib-es/adapters/ledger.d.ts.map +1 -1
- package/lib-es/adapters/ledger.js +2 -0
- package/lib-es/adapters/ledger.js.map +1 -1
- package/lib-es/api/index.d.ts +1 -1
- package/lib-es/api/index.d.ts.map +1 -1
- package/lib-es/api/index.js +14 -15
- package/lib-es/api/index.js.map +1 -1
- package/lib-es/chains.d.ts +7 -0
- package/lib-es/chains.d.ts.map +1 -1
- package/lib-es/chains.js +16 -0
- package/lib-es/chains.js.map +1 -1
- package/lib-es/config.d.ts +1 -1
- package/lib-es/config.d.ts.map +1 -1
- package/lib-es/config.js +1 -1
- package/lib-es/config.js.map +1 -1
- package/lib-es/errors.d.ts +11 -0
- package/lib-es/errors.d.ts.map +1 -1
- package/lib-es/errors.js +15 -0
- package/lib-es/errors.js.map +1 -1
- package/lib-es/logic/broadcast.d.ts +1 -1
- package/lib-es/logic/broadcast.d.ts.map +1 -1
- package/lib-es/logic/broadcast.js +2 -2
- package/lib-es/logic/broadcast.js.map +1 -1
- package/lib-es/logic/craftTransaction.d.ts +1 -1
- package/lib-es/logic/craftTransaction.d.ts.map +1 -1
- package/lib-es/logic/craftTransaction.js +3 -3
- package/lib-es/logic/craftTransaction.js.map +1 -1
- package/lib-es/logic/estimateFees.d.ts +1 -1
- package/lib-es/logic/estimateFees.d.ts.map +1 -1
- package/lib-es/logic/estimateFees.js +19 -4
- package/lib-es/logic/estimateFees.js.map +1 -1
- package/lib-es/logic/getBalance.d.ts +1 -2
- package/lib-es/logic/getBalance.d.ts.map +1 -1
- package/lib-es/logic/getBalance.js +5 -6
- package/lib-es/logic/getBalance.js.map +1 -1
- package/lib-es/logic/getBlock.d.ts +1 -1
- package/lib-es/logic/getBlock.d.ts.map +1 -1
- package/lib-es/logic/getBlock.js +23 -6
- package/lib-es/logic/getBlock.js.map +1 -1
- package/lib-es/logic/getBlockInfo.d.ts +1 -1
- package/lib-es/logic/getBlockInfo.d.ts.map +1 -1
- package/lib-es/logic/getBlockInfo.js +2 -2
- package/lib-es/logic/getBlockInfo.js.map +1 -1
- package/lib-es/logic/getNextSequence.d.ts +1 -1
- package/lib-es/logic/getNextSequence.d.ts.map +1 -1
- package/lib-es/logic/getNextSequence.js +2 -2
- package/lib-es/logic/getNextSequence.js.map +1 -1
- package/lib-es/logic/getStakes.d.ts +1 -1
- package/lib-es/logic/getStakes.d.ts.map +1 -1
- package/lib-es/logic/getStakes.js +2 -2
- package/lib-es/logic/getStakes.js.map +1 -1
- package/lib-es/logic/lastBlock.d.ts +1 -1
- package/lib-es/logic/lastBlock.d.ts.map +1 -1
- package/lib-es/logic/lastBlock.js +2 -2
- package/lib-es/logic/lastBlock.js.map +1 -1
- package/lib-es/logic/listOperations.d.ts +1 -1
- package/lib-es/logic/listOperations.d.ts.map +1 -1
- package/lib-es/logic/listOperations.js +4 -2
- package/lib-es/logic/listOperations.js.map +1 -1
- package/lib-es/logic/validateIntent.d.ts +1 -1
- package/lib-es/logic/validateIntent.d.ts.map +1 -1
- package/lib-es/logic/validateIntent.js +3 -3
- package/lib-es/logic/validateIntent.js.map +1 -1
- package/lib-es/logic.d.ts.map +1 -1
- package/lib-es/logic.js +6 -11
- package/lib-es/logic.js.map +1 -1
- package/lib-es/network/node/explorerProxy.d.ts.map +1 -1
- package/lib-es/network/node/explorerProxy.js +2 -0
- package/lib-es/network/node/explorerProxy.js.map +1 -1
- package/lib-es/network/node/ledger.d.ts.map +1 -1
- package/lib-es/network/node/ledger.js +3 -10
- package/lib-es/network/node/ledger.js.map +1 -1
- package/lib-es/network/node/rpc.common.d.ts.map +1 -1
- package/lib-es/network/node/rpc.common.js +19 -10
- package/lib-es/network/node/rpc.common.js.map +1 -1
- package/lib-es/network/node/types.d.ts +3 -1
- package/lib-es/network/node/types.d.ts.map +1 -1
- package/lib-es/network/node/types.js.map +1 -1
- package/lib-es/staking/detectOperationType.js +1 -1
- package/lib-es/staking/validators/index.d.ts +1 -1
- package/lib-es/staking/validators/index.d.ts.map +1 -1
- package/lib-es/staking/validators/index.js +2 -2
- package/lib-es/staking/validators/index.js.map +1 -1
- package/lib-es/staking/validators/monadResolver.js +1 -1
- package/lib-es/staking/validators/monadResolver.js.map +1 -1
- package/package.json +2 -2
- package/src/adapters/etherscan.test.ts +57 -5
- package/src/adapters/etherscan.ts +15 -0
- package/src/adapters/ledger.test.ts +57 -9
- package/src/adapters/ledger.ts +2 -0
- package/src/api/index.ts +14 -17
- package/src/api/{getBlock.integ.test.ts → tests/getBlock.integ.test.ts} +7 -7
- package/src/api/{index.arbitrum.integ.test.ts → tests/index.arbitrum.integ.test.ts} +4 -4
- package/src/api/{index.arc.integ.test.ts → tests/index.arc.integ.test.ts} +4 -4
- package/src/api/{index.avalanche_c_chain_fuji.integ.test.ts → tests/index.avalanche_c_chain_fuji.integ.test.ts} +4 -4
- package/src/api/{index.cronos.integ.test.ts → tests/index.cronos.integ.test.ts} +4 -4
- package/src/api/{index.flare.integ.test.ts → tests/index.flare.integ.test.ts} +4 -4
- package/src/api/{index.integ.test.ts → tests/index.integ.test.ts} +8 -8
- package/src/api/{index.linea.integ.test.ts → tests/index.linea.integ.test.ts} +4 -4
- package/src/api/{index.monad_testnet.integ.test.ts → tests/index.monad_testnet.integ.test.ts} +5 -5
- package/src/api/{index.optimism.integ.test.ts → tests/index.optimism.integ.test.ts} +4 -4
- package/src/api/{index.rsk.integ.test.ts → tests/index.rsk.integ.test.ts} +4 -4
- package/src/api/{index.shape.integ.test.ts → tests/index.shape.integ.test.ts} +4 -4
- package/src/api/{index.somnia.integ.test.ts → tests/index.somnia.integ.test.ts} +4 -4
- package/src/api/{index.test.ts → tests/index.test.ts} +10 -10
- package/src/api/{index.zksync.integ.test.ts → tests/index.zksync.integ.test.ts} +3 -3
- package/src/chains.ts +17 -0
- package/src/config.ts +1 -1
- package/src/errors.ts +14 -0
- package/src/fixtures/context.fixtures.ts +2 -4
- package/src/logic/broadcast.ts +1 -2
- package/src/logic/craftTransaction.ts +2 -3
- package/src/logic/estimateFees.ts +22 -4
- package/src/logic/getBalance.ts +3 -6
- package/src/logic/getBlock.ts +39 -10
- package/src/logic/getBlockInfo.ts +2 -6
- package/src/logic/getNextSequence.ts +2 -6
- package/src/logic/getStakes.ts +1 -2
- package/src/logic/lastBlock.ts +2 -2
- package/src/logic/listOperations.ts +3 -2
- package/src/logic/tests/broadcast.integ.test.ts +1 -1
- package/src/logic/tests/broadcast.test.ts +5 -5
- package/src/logic/tests/broadcastSource.test.ts +4 -4
- package/src/logic/tests/common.test.ts +1 -1
- package/src/logic/tests/craftTransaction.test.ts +16 -21
- package/src/logic/tests/estimateFees.test.ts +40 -18
- package/src/logic/tests/getBalance.test.ts +20 -23
- package/src/logic/tests/getBlock.test.ts +159 -39
- package/src/logic/tests/getBlockInfo.test.ts +6 -6
- package/src/logic/tests/getNextSequence.test.ts +2 -2
- package/src/logic/tests/getStakes.test.ts +14 -14
- package/src/logic/tests/internalTransactionsFetcher.test.ts +1 -1
- package/src/logic/tests/lastBlock.test.ts +4 -4
- package/src/logic/tests/listOperations.test.ts +51 -55
- package/src/logic/tests/validateIntent.test.ts +39 -61
- package/src/logic/validateIntent.ts +2 -3
- package/src/logic.test.ts +24 -7
- package/src/logic.ts +6 -11
- package/src/network/node/explorerProxy.ts +2 -0
- package/src/network/node/ledger.ts +3 -10
- package/src/network/node/rpc.common.ts +23 -10
- package/src/network/node/types.ts +5 -2
- package/src/network/{explorer → tests/explorer}/etherscan.test.ts +8 -8
- package/src/network/{explorer → tests/explorer}/index.test.ts +11 -11
- package/src/network/{explorer → tests/explorer}/ledger.test.ts +11 -11
- package/src/network/{explorer → tests/explorer}/types.test.ts +1 -1
- package/src/network/{gasTracker → tests/gasTracker}/index.test.ts +3 -3
- package/src/network/{gasTracker → tests/gasTracker}/ledger.test.ts +4 -4
- package/src/network/{gasTracker → tests/gasTracker}/types.test.ts +1 -1
- package/src/network/{node → tests/node}/explorerProxy.test.ts +5 -2
- package/src/network/{node → tests/node}/gethCallTracerToTraceBlockItems.test.ts +4 -4
- package/src/network/{node → tests/node}/index.memoization.test.ts +3 -3
- package/src/network/{node → tests/node}/index.test.ts +3 -3
- package/src/network/{node → tests/node}/ledger.test.ts +9 -6
- package/src/network/{node → tests/node}/node.fixtures.ts +1 -1
- package/src/network/{node → tests/node}/rpc.errors.test.ts +1 -1
- package/src/network/{node → tests/node}/rpc.test.ts +57 -6
- package/src/network/{node → tests/node}/types.test.ts +1 -1
- package/src/network/{node → tests/node}/withNodeSources.test.ts +3 -3
- package/src/network/{withRetries.test.ts → tests/withRetries.test.ts} +2 -2
- package/src/staking/detectOperationType.ts +1 -1
- package/src/staking/redelegations.test.ts +3 -3
- package/src/staking/validators/index.ts +1 -2
- package/src/staking/validators/monadResolver.ts +1 -1
- package/src/staking/validators.integ.test.ts +1 -1
- package/src/staking/validators.test.ts +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import type { EvmConfigInfo } from '
|
|
5
|
-
import { createMockEvmContext } from '
|
|
6
|
-
import { createApi } from '
|
|
4
|
+
import type { EvmConfigInfo } from '../../config'
|
|
5
|
+
import { createMockEvmContext } from '../../fixtures/context.fixtures'
|
|
6
|
+
import { createApi } from '../index'
|
|
7
7
|
|
|
8
8
|
describe('EVM Avalanche C-Chain Fuji', () => {
|
|
9
9
|
let module: ReturnType<typeof createApi>
|
|
@@ -20,7 +20,7 @@ describe('EVM Avalanche C-Chain Fuji', () => {
|
|
|
20
20
|
},
|
|
21
21
|
}
|
|
22
22
|
beforeAll(() => {
|
|
23
|
-
module = createApi(
|
|
23
|
+
module = createApi()
|
|
24
24
|
})
|
|
25
25
|
|
|
26
26
|
describe('listOperations', () => {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import type { EvmConfigInfo } from '
|
|
5
|
-
import { createMockEvmContext } from '
|
|
6
|
-
import { createApi } from '
|
|
4
|
+
import type { EvmConfigInfo } from '../../config'
|
|
5
|
+
import { createMockEvmContext } from '../../fixtures/context.fixtures'
|
|
6
|
+
import { createApi } from '../index'
|
|
7
7
|
|
|
8
8
|
describe('EVM Cronos Network (blockscout explorer)', () => {
|
|
9
9
|
let module: ReturnType<typeof createApi>
|
|
@@ -20,7 +20,7 @@ describe('EVM Cronos Network (blockscout explorer)', () => {
|
|
|
20
20
|
},
|
|
21
21
|
}
|
|
22
22
|
beforeAll(() => {
|
|
23
|
-
module = createApi(
|
|
23
|
+
module = createApi()
|
|
24
24
|
})
|
|
25
25
|
|
|
26
26
|
describe('listOperations', () => {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import type { EvmConfigInfo } from '
|
|
5
|
-
import { createMockEvmContext } from '
|
|
6
|
-
import { createApi } from '
|
|
4
|
+
import type { EvmConfigInfo } from '../../config'
|
|
5
|
+
import { createMockEvmContext } from '../../fixtures/context.fixtures'
|
|
6
|
+
import { createApi } from '../index'
|
|
7
7
|
|
|
8
8
|
describe('Flare (external node)', () => {
|
|
9
9
|
describe('getBlock', () => {
|
|
@@ -24,7 +24,7 @@ describe('Flare (external node)', () => {
|
|
|
24
24
|
},
|
|
25
25
|
}
|
|
26
26
|
beforeAll(() => {
|
|
27
|
-
module = createApi(
|
|
27
|
+
module = createApi()
|
|
28
28
|
})
|
|
29
29
|
|
|
30
30
|
it('internal txs can be retrieved from node', async () => {
|
|
@@ -12,9 +12,9 @@ import {
|
|
|
12
12
|
mkExternalNode,
|
|
13
13
|
mkLedgerExplorer,
|
|
14
14
|
mkLedgerNode,
|
|
15
|
-
} from '
|
|
16
|
-
import { isNative } from '
|
|
17
|
-
import { createApi } from '
|
|
15
|
+
} from '../../fixtures/context.fixtures'
|
|
16
|
+
import { isNative } from '../../types/assets'
|
|
17
|
+
import { createApi } from '../index'
|
|
18
18
|
|
|
19
19
|
describe.each([
|
|
20
20
|
[
|
|
@@ -41,7 +41,7 @@ describe.each([
|
|
|
41
41
|
// carry this suite's node/explorer config — not the empty default fixture.
|
|
42
42
|
const context = createMockEvmContext(config)
|
|
43
43
|
beforeAll(() => {
|
|
44
|
-
module = createApi(
|
|
44
|
+
module = createApi()
|
|
45
45
|
})
|
|
46
46
|
|
|
47
47
|
describe('getNextSequence', () => {
|
|
@@ -341,7 +341,7 @@ describe.each([
|
|
|
341
341
|
* "To send batches over 10 items, consider using a dedicated API provider"
|
|
342
342
|
*/
|
|
343
343
|
it('returns at least 10 token balances on Optimisim', async () => {
|
|
344
|
-
const module = createApi(
|
|
344
|
+
const module = createApi()
|
|
345
345
|
const context = createMockEvmContext(
|
|
346
346
|
createMockEvmConfigInfo({
|
|
347
347
|
chainId: 10,
|
|
@@ -878,7 +878,7 @@ describe('EVM Api: external node and explorer ONLY', () => {
|
|
|
878
878
|
)
|
|
879
879
|
|
|
880
880
|
beforeAll(() => {
|
|
881
|
-
module = createApi(
|
|
881
|
+
module = createApi()
|
|
882
882
|
})
|
|
883
883
|
|
|
884
884
|
describe('getBlock', () => {
|
|
@@ -970,7 +970,7 @@ describe('EVM Api (SEI Network)', () => {
|
|
|
970
970
|
)
|
|
971
971
|
|
|
972
972
|
beforeAll(() => {
|
|
973
|
-
module = createApi(
|
|
973
|
+
module = createApi()
|
|
974
974
|
})
|
|
975
975
|
|
|
976
976
|
describe('craftTransaction', () => {
|
|
@@ -1110,7 +1110,7 @@ describe('EVM Api (Zero Gravity)', () => {
|
|
|
1110
1110
|
)
|
|
1111
1111
|
|
|
1112
1112
|
beforeAll(() => {
|
|
1113
|
-
module = createApi(
|
|
1113
|
+
module = createApi()
|
|
1114
1114
|
})
|
|
1115
1115
|
|
|
1116
1116
|
describe('listOperations', () => {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import type { EvmConfigInfo } from '
|
|
5
|
-
import { createMockEvmContext } from '
|
|
6
|
-
import { createApi } from '
|
|
4
|
+
import type { EvmConfigInfo } from '../../config'
|
|
5
|
+
import { createMockEvmContext } from '../../fixtures/context.fixtures'
|
|
6
|
+
import { createApi } from '../index'
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Integration tests for getBlock with internal transactions (etherscan/blockscout).
|
|
@@ -41,7 +41,7 @@ describe('Linea (etherscan explorer)', () => {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
beforeAll(() => {
|
|
44
|
-
module = createApi(
|
|
44
|
+
module = createApi()
|
|
45
45
|
})
|
|
46
46
|
|
|
47
47
|
it('should include internal native transfer in block transaction', async () => {
|
package/src/api/{index.monad_testnet.integ.test.ts → tests/index.monad_testnet.integ.test.ts}
RENAMED
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
createMockEvmConfigInfo,
|
|
6
6
|
createMockEvmContext,
|
|
7
7
|
testLogger,
|
|
8
|
-
} from '
|
|
9
|
-
import { getNodeApi } from '
|
|
10
|
-
import { nodeSourcesFromList } from '
|
|
11
|
-
import { createApi } from '
|
|
8
|
+
} from '../../fixtures/context.fixtures'
|
|
9
|
+
import { getNodeApi } from '../../network/node'
|
|
10
|
+
import { nodeSourcesFromList } from '../../nodeSources'
|
|
11
|
+
import { createApi } from '../index'
|
|
12
12
|
|
|
13
13
|
describe('EVM Api (Monad Testnet)', () => {
|
|
14
14
|
let module: ReturnType<typeof createApi>
|
|
@@ -23,7 +23,7 @@ describe('EVM Api (Monad Testnet)', () => {
|
|
|
23
23
|
nodeSources: nodeSourcesFromList(['explorer-proxy', 'node']),
|
|
24
24
|
})
|
|
25
25
|
beforeAll(() => {
|
|
26
|
-
module = createApi(
|
|
26
|
+
module = createApi()
|
|
27
27
|
})
|
|
28
28
|
|
|
29
29
|
describe('listOperations', () => {
|
|
@@ -1,10 +1,10 @@
|
|
|
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 { Operation } from '@ledgerhq/coin-module-framework/api/types'
|
|
6
|
-
import { createMockEvmContext } from '
|
|
7
|
-
import { createApi } from '
|
|
6
|
+
import { createMockEvmContext } from '../../fixtures/context.fixtures'
|
|
7
|
+
import { createApi } from '../index'
|
|
8
8
|
|
|
9
9
|
describe('EVM Optimism Network', () => {
|
|
10
10
|
let module: ReturnType<typeof createApi>
|
|
@@ -21,7 +21,7 @@ describe('EVM Optimism Network', () => {
|
|
|
21
21
|
},
|
|
22
22
|
}
|
|
23
23
|
beforeAll(() => {
|
|
24
|
-
module = createApi(
|
|
24
|
+
module = createApi()
|
|
25
25
|
})
|
|
26
26
|
|
|
27
27
|
describe('getBlock fee correctness', () => {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import type { EvmConfigInfo } from '
|
|
5
|
-
import { createMockEvmContext } from '
|
|
6
|
-
import { createApi } from '
|
|
4
|
+
import type { EvmConfigInfo } from '../../config'
|
|
5
|
+
import { createMockEvmContext } from '../../fixtures/context.fixtures'
|
|
6
|
+
import { createApi } from '../index'
|
|
7
7
|
|
|
8
8
|
describe('EVM RSK Network', () => {
|
|
9
9
|
let module: ReturnType<typeof createApi>
|
|
@@ -20,7 +20,7 @@ describe('EVM RSK Network', () => {
|
|
|
20
20
|
},
|
|
21
21
|
}
|
|
22
22
|
beforeAll(() => {
|
|
23
|
-
module = createApi(
|
|
23
|
+
module = createApi()
|
|
24
24
|
})
|
|
25
25
|
|
|
26
26
|
describe('getBalance with EIP-1191 checksummed address', () => {
|
|
@@ -1,10 +1,10 @@
|
|
|
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 { fail } from 'assert'
|
|
6
|
-
import { createMockEvmContext } from '
|
|
7
|
-
import { createApi } from '
|
|
6
|
+
import { createMockEvmContext } from '../../fixtures/context.fixtures'
|
|
7
|
+
import { createApi } from '../index'
|
|
8
8
|
|
|
9
9
|
describe('Shape (external node)', () => {
|
|
10
10
|
describe('getBlock', () => {
|
|
@@ -23,7 +23,7 @@ describe('Shape (external node)', () => {
|
|
|
23
23
|
},
|
|
24
24
|
supportedTokens: ['erc721', 'erc1155'],
|
|
25
25
|
}
|
|
26
|
-
const module = createApi(
|
|
26
|
+
const module = createApi()
|
|
27
27
|
|
|
28
28
|
it('should return WETH mint from Deposit log in block 26327282 (tx 0x08761e…) see BACK-10995', async () => {
|
|
29
29
|
const weth = '0x4200000000000000000000000000000000000006'
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import type { EvmConfigInfo } from '
|
|
5
|
-
import { createMockEvmContext } from '
|
|
6
|
-
import { createApi } from '
|
|
4
|
+
import type { EvmConfigInfo } from '../../config'
|
|
5
|
+
import { createMockEvmContext } from '../../fixtures/context.fixtures'
|
|
6
|
+
import { createApi } from '../index'
|
|
7
7
|
|
|
8
8
|
describe('EVM Api (Somnia)', () => {
|
|
9
9
|
let module: ReturnType<typeof createApi>
|
|
@@ -15,7 +15,7 @@ describe('EVM Api (Somnia)', () => {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
beforeAll(() => {
|
|
18
|
-
module = createApi(
|
|
18
|
+
module = createApi()
|
|
19
19
|
})
|
|
20
20
|
|
|
21
21
|
describe('listOperations', () => {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import { mockEvmContext } from '
|
|
5
|
-
import { getValidatorsPage } from '
|
|
6
|
-
import { createApi, parseCallParams } from '
|
|
4
|
+
import { mockEvmContext } from '../../fixtures/context.fixtures'
|
|
5
|
+
import { getValidatorsPage } from '../../staking/validators'
|
|
6
|
+
import { createApi, parseCallParams } from '../index'
|
|
7
7
|
|
|
8
|
-
jest.mock('
|
|
8
|
+
jest.mock('../../staking/validators', () => ({
|
|
9
9
|
getValidatorsPage: jest.fn(),
|
|
10
10
|
}))
|
|
11
11
|
|
|
@@ -54,11 +54,11 @@ describe.each([
|
|
|
54
54
|
],
|
|
55
55
|
])('coin-framework methods %s', (_s, _config, methods) => {
|
|
56
56
|
it('declares every method the chain supports', () => {
|
|
57
|
-
expect(createApi(
|
|
57
|
+
expect(createApi()).toEqual(methods)
|
|
58
58
|
})
|
|
59
59
|
|
|
60
60
|
it('omits the capabilities the chain has none of', () => {
|
|
61
|
-
const impl = createApi(
|
|
61
|
+
const impl = createApi()
|
|
62
62
|
for (const method of ['craftRawTransaction', 'register', 'getStakes', 'getRewards'] as const) {
|
|
63
63
|
expect(impl).not.toHaveProperty(method)
|
|
64
64
|
}
|
|
@@ -118,7 +118,7 @@ describe('parseCallParams', () => {
|
|
|
118
118
|
})
|
|
119
119
|
|
|
120
120
|
it('rejects invalid params as a rejected promise, not a synchronous throw', async () => {
|
|
121
|
-
const api = createApi(
|
|
121
|
+
const api = createApi()
|
|
122
122
|
await expect(api.call(mockEvmContext, {})).rejects.toThrow('Invalid EVM call params')
|
|
123
123
|
})
|
|
124
124
|
})
|
|
@@ -141,12 +141,12 @@ describe('staking support capability', () => {
|
|
|
141
141
|
}
|
|
142
142
|
mockGetValidatorsPage.mockResolvedValue(expectedPage)
|
|
143
143
|
|
|
144
|
-
const api = createApi(
|
|
144
|
+
const api = createApi()
|
|
145
145
|
|
|
146
146
|
await expect(api.getValidators(mockEvmContext)).resolves.toEqual(expectedPage)
|
|
147
|
-
expect(mockGetValidatorsPage).toHaveBeenCalledWith(mockEvmContext,
|
|
147
|
+
expect(mockGetValidatorsPage).toHaveBeenCalledWith(mockEvmContext, undefined)
|
|
148
148
|
|
|
149
149
|
await expect(api.getValidators(mockEvmContext, { cursor: '42' })).resolves.toEqual(expectedPage)
|
|
150
|
-
expect(mockGetValidatorsPage).toHaveBeenCalledWith(mockEvmContext, '
|
|
150
|
+
expect(mockGetValidatorsPage).toHaveBeenCalledWith(mockEvmContext, '42')
|
|
151
151
|
})
|
|
152
152
|
})
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import { createMockEvmContext, mkExternalNode } from '
|
|
5
|
-
import { createApi } from '
|
|
4
|
+
import { createMockEvmContext, mkExternalNode } from '../../fixtures/context.fixtures'
|
|
5
|
+
import { createApi } from '../index'
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Non regression for GET /v1/zksync/account/{address}/operations?minHeight=0&order=asc&limit=1,
|
|
@@ -18,7 +18,7 @@ describe('ZkSync (blockscout explorer)', () => {
|
|
|
18
18
|
let module: ReturnType<typeof createApi>
|
|
19
19
|
|
|
20
20
|
beforeAll(() => {
|
|
21
|
-
module = createApi(
|
|
21
|
+
module = createApi()
|
|
22
22
|
})
|
|
23
23
|
|
|
24
24
|
it('listOperations completes without timing out', async () => {
|
package/src/chains.ts
CHANGED
|
@@ -64,6 +64,7 @@ export const CHAIN_ID = {
|
|
|
64
64
|
BASE: 8453,
|
|
65
65
|
MONAD_TESTNET: 10143,
|
|
66
66
|
ZERO_GRAVITY: 16661,
|
|
67
|
+
ALPEN_TESTNET: 20310,
|
|
67
68
|
ETHERSOCIAL: 31102,
|
|
68
69
|
ADI: 36900,
|
|
69
70
|
ARBITRUM: 42161,
|
|
@@ -95,3 +96,19 @@ export const CHAIN_ID = {
|
|
|
95
96
|
} as const
|
|
96
97
|
|
|
97
98
|
export type ChainId = (typeof CHAIN_ID)[keyof typeof CHAIN_ID]
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* OP Stack chains that bill an L1 data fee on top of L2 execution gas.
|
|
102
|
+
* The fee is read from the GasPriceOracle predeploy (`getL1Fee`).
|
|
103
|
+
* @see https://docs.optimism.io/stack/transactions/fees
|
|
104
|
+
*/
|
|
105
|
+
export const OP_STACK_L1_FEE_CHAIN_IDS: readonly ChainId[] = [
|
|
106
|
+
CHAIN_ID.OPTIMISM,
|
|
107
|
+
CHAIN_ID.OPTIMISM_SEPOLIA,
|
|
108
|
+
CHAIN_ID.BASE,
|
|
109
|
+
CHAIN_ID.BASE_SEPOLIA,
|
|
110
|
+
CHAIN_ID.BLAST,
|
|
111
|
+
CHAIN_ID.BLAST_SEPOLIA,
|
|
112
|
+
CHAIN_ID.SHAPE,
|
|
113
|
+
CHAIN_ID.BOBA,
|
|
114
|
+
]
|
package/src/config.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type { InternalTxSourceList } from './internalTxSources'
|
|
|
6
6
|
import type { NodeSourceList } from './nodeSources'
|
|
7
7
|
import type { Context, CurrencyConfig } from '@ledgerhq/coin-module-framework/config'
|
|
8
8
|
|
|
9
|
-
export { CHAIN_ID } from './chains'
|
|
9
|
+
export { CHAIN_ID, OP_STACK_L1_FEE_CHAIN_IDS } from './chains'
|
|
10
10
|
export type { ChainId } from './chains'
|
|
11
11
|
|
|
12
12
|
export type { InternalTxSource, InternalTxSourceList, NonEmptySource } from './internalTxSources'
|
package/src/errors.ts
CHANGED
|
@@ -133,6 +133,20 @@ export class GasPriceTooLow extends Error {
|
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
+
/**
|
|
137
|
+
* The L1 data fee of a rollup (e.g. OP Stack `GasPriceOracle.getL1Fee`) could not be read.
|
|
138
|
+
* Raised instead of reporting a zero fee, which would under-estimate the total fee.
|
|
139
|
+
*/
|
|
140
|
+
export class L1DataFeeUnavailableError extends Error {
|
|
141
|
+
override name = 'L1DataFeeUnavailableError'
|
|
142
|
+
readonly statusCode = 503
|
|
143
|
+
constructor(message?: string, fields?: Record<string, unknown>, options?: { cause?: unknown }) {
|
|
144
|
+
super(message || 'L1 data fee is unavailable, please retry later')
|
|
145
|
+
if (fields) Object.assign(this, fields)
|
|
146
|
+
if (options?.cause !== undefined) Object.assign(this, { cause: options.cause })
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
136
150
|
export class GasEstimationError extends Error {
|
|
137
151
|
override name = 'GasEstimationError'
|
|
138
152
|
constructor(message?: string, fields?: Record<string, unknown>) {
|
|
@@ -88,14 +88,12 @@ export const createMockEvmCoinConfig = (
|
|
|
88
88
|
/**
|
|
89
89
|
* Builds a mock {@link EvmContext} for tests.
|
|
90
90
|
*
|
|
91
|
-
* The logic layer resolves its configuration through `context.config(
|
|
91
|
+
* The logic layer resolves its configuration through `context.config()`, so this
|
|
92
92
|
* accessor is the single source of config for the delegated calls. Pass an optional `config`
|
|
93
93
|
* to override what `context.config()` resolves to (merged over an `active` status default).
|
|
94
|
-
* The `currencyId` argument is accepted for signature parity but ignored — the mock always
|
|
95
|
-
* resolves the same config regardless of currency.
|
|
96
94
|
*/
|
|
97
95
|
export const createMockEvmContext = (config?: Partial<EvmConfigInfo>): EvmContext => ({
|
|
98
|
-
config: async (
|
|
96
|
+
config: async (): Promise<EvmConfigInfo> =>
|
|
99
97
|
createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode(), ...config }),
|
|
100
98
|
logger: jest.fn(),
|
|
101
99
|
})
|
package/src/logic/broadcast.ts
CHANGED
|
@@ -7,7 +7,6 @@ import { getNodeApi } from '../network/node/index'
|
|
|
7
7
|
|
|
8
8
|
export async function broadcast(
|
|
9
9
|
context: EvmContext,
|
|
10
|
-
currencyId: string,
|
|
11
10
|
{
|
|
12
11
|
signature,
|
|
13
12
|
broadcastConfig,
|
|
@@ -16,7 +15,7 @@ export async function broadcast(
|
|
|
16
15
|
broadcastConfig?: BroadcastConfig | undefined
|
|
17
16
|
}
|
|
18
17
|
): Promise<string> {
|
|
19
|
-
const config = await context.config(
|
|
18
|
+
const config = await context.config()
|
|
20
19
|
const nodeApi = getNodeApi(config, context.logger)
|
|
21
20
|
return await nodeApi.broadcastTransaction(signature, broadcastConfig)
|
|
22
21
|
}
|
|
@@ -20,7 +20,6 @@ import { isFeesStrategy } from './predicates'
|
|
|
20
20
|
|
|
21
21
|
export async function craftTransaction(
|
|
22
22
|
context: EvmContext,
|
|
23
|
-
currencyId: string,
|
|
24
23
|
{
|
|
25
24
|
transactionIntent,
|
|
26
25
|
customFees,
|
|
@@ -29,7 +28,7 @@ export async function craftTransaction(
|
|
|
29
28
|
customFees?: FeeEstimation | undefined
|
|
30
29
|
}
|
|
31
30
|
): Promise<CraftedTransaction> {
|
|
32
|
-
const config = await context.config(
|
|
31
|
+
const config = await context.config()
|
|
33
32
|
const { type, to, data, value, gasLimit } = await prepareUnsignedTxParams(
|
|
34
33
|
config,
|
|
35
34
|
transactionIntent,
|
|
@@ -48,7 +47,7 @@ export async function craftTransaction(
|
|
|
48
47
|
const nonce =
|
|
49
48
|
typeof transactionIntent.sequence === 'bigint' && transactionIntent.sequence >= 0n
|
|
50
49
|
? transactionIntent.sequence
|
|
51
|
-
: await getNextSequence(context,
|
|
50
|
+
: await getNextSequence(context, transactionIntent.sender)
|
|
52
51
|
const chainId = config.chainId
|
|
53
52
|
|
|
54
53
|
const unsignedTransaction: TransactionLike = {
|
|
@@ -14,6 +14,7 @@ import type { Logger } from '@ledgerhq/coin-module-framework/config'
|
|
|
14
14
|
import type { TransactionLike } from 'ethers'
|
|
15
15
|
import BigNumber from 'bignumber.js'
|
|
16
16
|
import { Transaction } from 'ethers'
|
|
17
|
+
import { L1DataFeeUnavailableError } from '../errors'
|
|
17
18
|
import { getAdditionalLayer2Fees } from '../logic'
|
|
18
19
|
import { isEthAddress, isStakingIntent } from '../logic-public'
|
|
19
20
|
import { getGasTracker } from '../network/gasTracker'
|
|
@@ -24,6 +25,12 @@ import { getTransactionType, prepareUnsignedTxParams } from './common'
|
|
|
24
25
|
import { getNextSequence } from './getNextSequence'
|
|
25
26
|
import { isFeesStrategy } from './predicates'
|
|
26
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Multiplier applied to the L1 data fee (`additionalFees`) of a send-max estimate only.
|
|
30
|
+
* The L1 fee follows the L1 base fee, which can rise between estimate and broadcast; for a
|
|
31
|
+
* send-max the amount is balance minus fees, so an under-estimate would make the transaction fail.
|
|
32
|
+
* Other estimates return the raw oracle value.
|
|
33
|
+
*/
|
|
27
34
|
const SEND_MAX_L1_FEE_BUFFER = new BigNumber(2)
|
|
28
35
|
|
|
29
36
|
async function computeAdditionalFees(
|
|
@@ -41,11 +48,23 @@ async function computeAdditionalFees(
|
|
|
41
48
|
},
|
|
42
49
|
}
|
|
43
50
|
|
|
51
|
+
let serialized: string
|
|
44
52
|
try {
|
|
45
|
-
|
|
53
|
+
serialized = Transaction.from(transaction).serialized
|
|
46
54
|
} catch {
|
|
47
55
|
return new BigNumber(0)
|
|
48
56
|
}
|
|
57
|
+
|
|
58
|
+
try {
|
|
59
|
+
return await getAdditionalLayer2Fees(config, serialized, logger)
|
|
60
|
+
} catch (error) {
|
|
61
|
+
const reason = error instanceof Error ? error.message : String(error)
|
|
62
|
+
throw new L1DataFeeUnavailableError(
|
|
63
|
+
`Could not get the L1 data fee for chain ${config.name}: ${reason}`,
|
|
64
|
+
{ chainId: config.chainId },
|
|
65
|
+
{ cause: error }
|
|
66
|
+
)
|
|
67
|
+
}
|
|
49
68
|
}
|
|
50
69
|
|
|
51
70
|
function toApiFeeData(feeData: FeeData): ApiFeeData {
|
|
@@ -117,7 +136,6 @@ function extractGasOptions(
|
|
|
117
136
|
|
|
118
137
|
export async function estimateFees(
|
|
119
138
|
context: EvmContext,
|
|
120
|
-
currencyId: string,
|
|
121
139
|
transactionIntent: TransactionIntent<MemoNotSupported, BufferTxData>,
|
|
122
140
|
customFeesParameters?: FeeEstimation['parameters']
|
|
123
141
|
): Promise<FeeEstimation> {
|
|
@@ -125,7 +143,7 @@ export async function estimateFees(
|
|
|
125
143
|
return { value: 0n }
|
|
126
144
|
}
|
|
127
145
|
|
|
128
|
-
const config = await context.config(
|
|
146
|
+
const config = await context.config()
|
|
129
147
|
|
|
130
148
|
// Skip fee estimation for redelegate without a destination validator — the
|
|
131
149
|
// validateStaking step in validateIntent will surface RedelegateDstValAddressRequired.
|
|
@@ -147,7 +165,7 @@ export async function estimateFees(
|
|
|
147
165
|
const noncePromise: Promise<bigint> =
|
|
148
166
|
typeof transactionIntent.sequence === 'bigint' && transactionIntent.sequence >= 0n
|
|
149
167
|
? Promise.resolve(transactionIntent.sequence)
|
|
150
|
-
: getNextSequence(context,
|
|
168
|
+
: getNextSequence(context, transactionIntent.sender)
|
|
151
169
|
|
|
152
170
|
const feeDataPromise = (async (): Promise<{
|
|
153
171
|
finalFeeData: FeeData
|
package/src/logic/getBalance.ts
CHANGED
|
@@ -16,23 +16,21 @@ export const TOKEN_BALANCE_BATCH_SIZE = 8
|
|
|
16
16
|
/**
|
|
17
17
|
* Get all assets linked to the user (native, tokens, ...)
|
|
18
18
|
* @param context - The coin-module context (config + logger)
|
|
19
|
-
* @param currencyId - The currency id we must get the balances of
|
|
20
19
|
* @param address - The user's address
|
|
21
20
|
* @returns Promise<Balance[]> - Array of balances for all assets (first element will always be the native asset)
|
|
22
21
|
*/
|
|
23
22
|
export async function getBalance(
|
|
24
23
|
context: EvmContext,
|
|
25
|
-
currencyId: string,
|
|
26
24
|
address: string,
|
|
27
25
|
options?: BalanceOptions
|
|
28
26
|
): Promise<Balance[]> {
|
|
29
|
-
const config = await context.config(
|
|
27
|
+
const config = await context.config()
|
|
30
28
|
const nodeApi = getNodeApi(config, context.logger)
|
|
31
29
|
const explorerApi = getExplorerApi(config)
|
|
32
30
|
|
|
33
31
|
const [nativeBalance, tokensBalances] = await Promise.all([
|
|
34
32
|
getNativeBalance(address, nodeApi),
|
|
35
|
-
getTokenBalances(context,
|
|
33
|
+
getTokenBalances(context, address, nodeApi, explorerApi, config, options),
|
|
36
34
|
])
|
|
37
35
|
|
|
38
36
|
return [nativeBalance].concat(tokensBalances)
|
|
@@ -50,7 +48,6 @@ async function getNativeBalance(address: string, nodeApi: NodeApi): Promise<Bala
|
|
|
50
48
|
|
|
51
49
|
async function getTokenBalances(
|
|
52
50
|
context: EvmContext,
|
|
53
|
-
currencyId: string,
|
|
54
51
|
address: string,
|
|
55
52
|
nodeApi: NodeApi,
|
|
56
53
|
explorerApi: ExplorerApi,
|
|
@@ -124,7 +121,7 @@ async function getTokenBalances(
|
|
|
124
121
|
// Staking and token-asset collection run in parallel; staking depends on the coin operations
|
|
125
122
|
// fetched above (Monad only), token-asset collection on the discovered/known assets union.
|
|
126
123
|
const [stakingResult, tokenAssetsResult] = await Promise.allSettled([
|
|
127
|
-
getStakes(context,
|
|
124
|
+
getStakes(context, address, { knownValidatorIds }),
|
|
128
125
|
collectTokenAssets(
|
|
129
126
|
Array.from(knownAssetsByReference.values()),
|
|
130
127
|
address,
|
package/src/logic/getBlock.ts
CHANGED
|
@@ -21,11 +21,7 @@ import { getNodeApi } from '../network/node'
|
|
|
21
21
|
import { createInternalTransactionsFetcher } from './internalTransactionsFetcher'
|
|
22
22
|
import { dropRootTraceDuplicates } from './rootTraceDedup'
|
|
23
23
|
|
|
24
|
-
export async function getBlock(
|
|
25
|
-
context: EvmContext,
|
|
26
|
-
currencyId: string,
|
|
27
|
-
height: number
|
|
28
|
-
): Promise<Block> {
|
|
24
|
+
export async function getBlock(context: EvmContext, height: number): Promise<Block> {
|
|
29
25
|
// Note: to use RPC calls efficiently, the strategy here is:
|
|
30
26
|
// - fetch the block + transactions in one call (using prefetchTxs=true)
|
|
31
27
|
// - fetch transaction receipts in one call using eth_getBlockReceipts
|
|
@@ -34,7 +30,7 @@ export async function getBlock(
|
|
|
34
30
|
// - unless the block is empty, fetch internal transactions (RPC trace methods or explorer,
|
|
35
31
|
// per `getBlockInternalTxsSources`) in parallel with the receipts, and merge them into the
|
|
36
32
|
// block transactions
|
|
37
|
-
const config = await context.config(
|
|
33
|
+
const config = await context.config()
|
|
38
34
|
const nodeApi = getNodeApi(config, context.logger)
|
|
39
35
|
const internalTxSources = config.getBlockInternalTxsSources ?? DEFAULT_INTERNAL_TX_SOURCES
|
|
40
36
|
const fetchInternalTxs = createInternalTransactionsFetcher(
|
|
@@ -229,7 +225,12 @@ function prefetchedTransactionToBlockTransaction(
|
|
|
229
225
|
logger
|
|
230
226
|
)
|
|
231
227
|
|
|
232
|
-
const details =
|
|
228
|
+
const details = buildTransactionDetails(
|
|
229
|
+
gasPrice,
|
|
230
|
+
tx.gasLimit,
|
|
231
|
+
tx.nonce,
|
|
232
|
+
buildSmartContractDetails(tx.to, tx.input, logger, receipt.contractAddress)
|
|
233
|
+
)
|
|
233
234
|
|
|
234
235
|
return {
|
|
235
236
|
hash: tx.hash,
|
|
@@ -237,7 +238,7 @@ function prefetchedTransactionToBlockTransaction(
|
|
|
237
238
|
operations,
|
|
238
239
|
fees,
|
|
239
240
|
feesPayer: tx.from,
|
|
240
|
-
|
|
241
|
+
details,
|
|
241
242
|
}
|
|
242
243
|
}
|
|
243
244
|
|
|
@@ -256,7 +257,12 @@ async function getTransactionFromHash(
|
|
|
256
257
|
const rawOperations = rpcTransactionToBlockOperations(txInfo, logger)
|
|
257
258
|
const operations = applyChainSpecificCorrections(chainId, rawOperations, txInfo.type, logger)
|
|
258
259
|
|
|
259
|
-
const details =
|
|
260
|
+
const details = buildTransactionDetails(
|
|
261
|
+
BigInt(txInfo.gasPrice),
|
|
262
|
+
txInfo.gasLimit,
|
|
263
|
+
txInfo.nonce,
|
|
264
|
+
buildSmartContractDetails(txInfo.to, txInfo.input, logger, txInfo.contractAddress)
|
|
265
|
+
)
|
|
260
266
|
|
|
261
267
|
return {
|
|
262
268
|
hash: txHash,
|
|
@@ -264,7 +270,30 @@ async function getTransactionFromHash(
|
|
|
264
270
|
operations,
|
|
265
271
|
fees,
|
|
266
272
|
feesPayer: txInfo.from,
|
|
267
|
-
|
|
273
|
+
details,
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Builds the transaction details. The gas and nonce keys match the ones set by
|
|
279
|
+
* {@link listOperations}, so consumers get the same keys whichever sync wrote the transaction.
|
|
280
|
+
*
|
|
281
|
+
* @param gasPrice gas price actually paid, in wei
|
|
282
|
+
* @param gasLimit gas limit set by the sender (decimal), when known
|
|
283
|
+
* @param nonce nonce of the transaction, when known
|
|
284
|
+
* @param smartContractDetails details of the contract interaction or deployment, if any
|
|
285
|
+
*/
|
|
286
|
+
function buildTransactionDetails(
|
|
287
|
+
gasPrice: bigint,
|
|
288
|
+
gasLimit: string | undefined,
|
|
289
|
+
nonce: number | undefined,
|
|
290
|
+
smartContractDetails: Record<string, unknown> | undefined
|
|
291
|
+
): Record<string, unknown> {
|
|
292
|
+
return {
|
|
293
|
+
gasPrice: gasPrice.toString(),
|
|
294
|
+
...(gasLimit !== undefined ? { gasLimit } : {}),
|
|
295
|
+
...(nonce !== undefined ? { sequence: nonce } : {}),
|
|
296
|
+
...(smartContractDetails ?? {}),
|
|
268
297
|
}
|
|
269
298
|
}
|
|
270
299
|
|