@ledgerhq/coin-evm 16.2.5 → 16.4.2

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.
Files changed (118) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/lib/adapters/blockscoutV2.d.ts +40 -0
  3. package/lib/adapters/blockscoutV2.d.ts.map +1 -0
  4. package/lib/adapters/blockscoutV2.js +177 -0
  5. package/lib/adapters/blockscoutV2.js.map +1 -0
  6. package/lib/adapters/index.d.ts +1 -0
  7. package/lib/adapters/index.d.ts.map +1 -1
  8. package/lib/adapters/index.js +1 -0
  9. package/lib/adapters/index.js.map +1 -1
  10. package/lib/chains.d.ts +1 -1
  11. package/lib/chains.js +1 -1
  12. package/lib/chains.js.map +1 -1
  13. package/lib/config.d.ts +51 -24
  14. package/lib/config.d.ts.map +1 -1
  15. package/lib/config.js +21 -19
  16. package/lib/config.js.map +1 -1
  17. package/lib/logic/getBlock.d.ts.map +1 -1
  18. package/lib/logic/getBlock.js +14 -1
  19. package/lib/logic/getBlock.js.map +1 -1
  20. package/lib/logic/internalTransactionsFetcher.d.ts.map +1 -1
  21. package/lib/logic/internalTransactionsFetcher.js +58 -20
  22. package/lib/logic/internalTransactionsFetcher.js.map +1 -1
  23. package/lib/network/blockscoutV2.d.ts +35 -0
  24. package/lib/network/blockscoutV2.d.ts.map +1 -0
  25. package/lib/network/blockscoutV2.js +311 -0
  26. package/lib/network/blockscoutV2.js.map +1 -0
  27. package/lib/network/explorer/etherscan.d.ts.map +1 -1
  28. package/lib/network/explorer/etherscan.js +11 -28
  29. package/lib/network/explorer/etherscan.js.map +1 -1
  30. package/lib/network/explorer/index.d.ts.map +1 -1
  31. package/lib/network/explorer/index.js +5 -0
  32. package/lib/network/explorer/index.js.map +1 -1
  33. package/lib/network/explorer/types.d.ts +6 -0
  34. package/lib/network/explorer/types.d.ts.map +1 -1
  35. package/lib/network/explorer/types.js +8 -1
  36. package/lib/network/explorer/types.js.map +1 -1
  37. package/lib/network/rewards.d.ts +11 -0
  38. package/lib/network/rewards.d.ts.map +1 -0
  39. package/lib/network/rewards.js +32 -0
  40. package/lib/network/rewards.js.map +1 -0
  41. package/lib/types/blockscoutV2.d.ts +80 -0
  42. package/lib/types/blockscoutV2.d.ts.map +1 -0
  43. package/lib/types/blockscoutV2.js +5 -0
  44. package/lib/types/blockscoutV2.js.map +1 -0
  45. package/lib/types/index.d.ts +1 -0
  46. package/lib/types/index.d.ts.map +1 -1
  47. package/lib/types/index.js +1 -0
  48. package/lib/types/index.js.map +1 -1
  49. package/lib-es/adapters/blockscoutV2.d.ts +40 -0
  50. package/lib-es/adapters/blockscoutV2.d.ts.map +1 -0
  51. package/lib-es/adapters/blockscoutV2.js +168 -0
  52. package/lib-es/adapters/blockscoutV2.js.map +1 -0
  53. package/lib-es/adapters/index.d.ts +1 -0
  54. package/lib-es/adapters/index.d.ts.map +1 -1
  55. package/lib-es/adapters/index.js +1 -0
  56. package/lib-es/adapters/index.js.map +1 -1
  57. package/lib-es/chains.d.ts +1 -1
  58. package/lib-es/chains.js +1 -1
  59. package/lib-es/chains.js.map +1 -1
  60. package/lib-es/config.d.ts +51 -24
  61. package/lib-es/config.d.ts.map +1 -1
  62. package/lib-es/config.js +21 -19
  63. package/lib-es/config.js.map +1 -1
  64. package/lib-es/logic/getBlock.d.ts.map +1 -1
  65. package/lib-es/logic/getBlock.js +14 -1
  66. package/lib-es/logic/getBlock.js.map +1 -1
  67. package/lib-es/logic/internalTransactionsFetcher.d.ts.map +1 -1
  68. package/lib-es/logic/internalTransactionsFetcher.js +59 -21
  69. package/lib-es/logic/internalTransactionsFetcher.js.map +1 -1
  70. package/lib-es/network/blockscoutV2.d.ts +35 -0
  71. package/lib-es/network/blockscoutV2.d.ts.map +1 -0
  72. package/lib-es/network/blockscoutV2.js +271 -0
  73. package/lib-es/network/blockscoutV2.js.map +1 -0
  74. package/lib-es/network/explorer/etherscan.d.ts.map +1 -1
  75. package/lib-es/network/explorer/etherscan.js +2 -19
  76. package/lib-es/network/explorer/etherscan.js.map +1 -1
  77. package/lib-es/network/explorer/index.d.ts.map +1 -1
  78. package/lib-es/network/explorer/index.js +5 -0
  79. package/lib-es/network/explorer/index.js.map +1 -1
  80. package/lib-es/network/explorer/types.d.ts +6 -0
  81. package/lib-es/network/explorer/types.d.ts.map +1 -1
  82. package/lib-es/network/explorer/types.js +6 -0
  83. package/lib-es/network/explorer/types.js.map +1 -1
  84. package/lib-es/network/rewards.d.ts +11 -0
  85. package/lib-es/network/rewards.d.ts.map +1 -0
  86. package/lib-es/network/rewards.js +29 -0
  87. package/lib-es/network/rewards.js.map +1 -0
  88. package/lib-es/types/blockscoutV2.d.ts +80 -0
  89. package/lib-es/types/blockscoutV2.d.ts.map +1 -0
  90. package/lib-es/types/blockscoutV2.js +4 -0
  91. package/lib-es/types/blockscoutV2.js.map +1 -0
  92. package/lib-es/types/index.d.ts +1 -0
  93. package/lib-es/types/index.d.ts.map +1 -1
  94. package/lib-es/types/index.js +1 -0
  95. package/lib-es/types/index.js.map +1 -1
  96. package/package.json +3 -3
  97. package/src/adapters/blockscoutV2.test.ts +296 -0
  98. package/src/adapters/blockscoutV2.ts +244 -0
  99. package/src/adapters/index.ts +1 -0
  100. package/src/api/tests/index.alpen_testnet.integ.test.ts +73 -0
  101. package/src/api/tests/index.integ.test.ts +4 -2
  102. package/src/api/tests/index.scroll.integ.test.ts +168 -0
  103. package/src/api/tests/index.shape.integ.test.ts +34 -0
  104. package/src/chains.ts +1 -1
  105. package/src/config.ts +46 -19
  106. package/src/logic/getBlock.ts +18 -1
  107. package/src/logic/internalTransactionsFetcher.ts +73 -24
  108. package/src/logic/tests/getBlock.test.ts +59 -3
  109. package/src/logic/tests/internalTransactionsFetcher.test.ts +98 -1
  110. package/src/network/blockscoutV2.ts +460 -0
  111. package/src/network/explorer/etherscan.ts +2 -29
  112. package/src/network/explorer/index.ts +5 -0
  113. package/src/network/explorer/types.ts +9 -0
  114. package/src/network/rewards.ts +47 -0
  115. package/src/network/tests/blockscoutV2.test.ts +565 -0
  116. package/src/network/tests/explorer/index.test.ts +21 -0
  117. package/src/types/blockscoutV2.ts +85 -0
  118. package/src/types/index.ts +1 -0
@@ -11,6 +11,7 @@ import {
11
11
  mkLedgerExplorer,
12
12
  testLogger,
13
13
  } from '../../../fixtures/context.fixtures'
14
+ import blockscoutV2Api from '../../blockscoutV2'
14
15
  import etherscanLikeApi from '../../explorer/etherscan'
15
16
  import { getExplorerApi } from '../../explorer/index'
16
17
  import ledgerExplorerApi from '../../explorer/ledger'
@@ -49,6 +50,18 @@ const configFor = (chainName: string): EvmConfigInfo => {
49
50
  node,
50
51
  explorer: { type: 'blockscout', uri: 'working', noCache: true },
51
52
  })
53
+ case 'blockscout-v2-coin':
54
+ return createMockEvmConfigInfo({
55
+ chainId: 1,
56
+ node,
57
+ explorer: { type: 'blockscout-v2', uri: 'working' },
58
+ })
59
+ case 'blockscout-v2-coin-no-cache':
60
+ return createMockEvmConfigInfo({
61
+ chainId: 1,
62
+ node,
63
+ explorer: { type: 'blockscout-v2', uri: 'working', noCache: true },
64
+ })
52
65
  case 'ledger-coin':
53
66
  return createMockEvmConfigInfo({
54
67
  chainId: 1,
@@ -93,6 +106,13 @@ describe('EVM Family', () => {
93
106
  expect(explorerB).toBe(etherscanLikeApi.explorerApiNoCache)
94
107
  })
95
108
 
109
+ it('should return the blockscout v2 api', () => {
110
+ expect(getExplorerApi(configFor('blockscout-v2-coin'))).toBe(blockscoutV2Api.explorerApi)
111
+ expect(getExplorerApi(configFor('blockscout-v2-coin-no-cache'))).toBe(
112
+ blockscoutV2Api.explorerApiNoCache
113
+ )
114
+ })
115
+
96
116
  it('should return the ledger api', () => {
97
117
  const explorerA = getExplorerApi(configFor('ledger-coin'))
98
118
 
@@ -107,6 +127,7 @@ describe('EVM Family', () => {
107
127
 
108
128
  it.each([
109
129
  ['etherscan', 'etherscan-coin'],
130
+ ['blockscout-v2', 'blockscout-v2-coin'],
110
131
  ['ledger', 'ledger-coin'],
111
132
  ['none', 'none-coin'],
112
133
  ])('%s arm exposes discoverTokenAssets', (_type, chainName) => {
@@ -0,0 +1,85 @@
1
+ // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ // Blockscout v2 REST API (`/api/v2`) response types. Only the fields the adapters read are declared.
5
+
6
+ export type BlockscoutV2Address = {
7
+ hash: string
8
+ }
9
+
10
+ /** Item of `GET /addresses/{address}/transactions` */
11
+ export type BlockscoutV2Transaction = {
12
+ hash: string
13
+ /** `null` while the transaction is pending */
14
+ block_number: number | null
15
+ /** Index of the transaction in its block */
16
+ position: number | null
17
+ timestamp: string | null
18
+ nonce: number
19
+ from: BlockscoutV2Address
20
+ /** `null` for a contract creation */
21
+ to: BlockscoutV2Address | null
22
+ created_contract: BlockscoutV2Address | null
23
+ value: string
24
+ /** Fee actually paid (`actual`) once mined, including the L1 data fee of rollups */
25
+ fee: { type: 'actual' | 'maximum'; value: string }
26
+ gas_used: string | null
27
+ gas_price: string | null
28
+ gas_limit: string
29
+ /** `null` while the transaction is pending */
30
+ status: 'ok' | 'error' | null
31
+ raw_input: string | null
32
+ /** Decoded method name, or the method id when it cannot be decoded */
33
+ method: string | null
34
+ }
35
+
36
+ /** Item of `GET /addresses/{address}/token-transfers` */
37
+ export type BlockscoutV2TokenTransfer = {
38
+ transaction_hash: string
39
+ block_hash: string
40
+ block_number: number
41
+ log_index: number
42
+ timestamp: string | null
43
+ from: BlockscoutV2Address
44
+ to: BlockscoutV2Address
45
+ token: {
46
+ address_hash: string
47
+ name: string | null
48
+ symbol: string | null
49
+ decimals: string | null
50
+ /** e.g. `ERC-20`, `ERC-721`, `ERC-1155` */
51
+ type: string
52
+ }
53
+ /** Same as `token.type`. Absent before Blockscout v10 (e.g. v9.0.2 on Alpen Testnet). */
54
+ token_type?: string | undefined
55
+ total: {
56
+ /** Amount, for ERC-20 and ERC-1155 */
57
+ value?: string | null
58
+ /** Token id, for ERC-721 and ERC-1155 */
59
+ token_id?: string | null
60
+ } | null
61
+ }
62
+
63
+ /** Item of `GET /addresses/{address}/internal-transactions` */
64
+ export type BlockscoutV2InternalTransaction = {
65
+ transaction_hash: string
66
+ block_number: number
67
+ /** Index of the internal transaction in its transaction */
68
+ index: number
69
+ timestamp: string | null
70
+ from: BlockscoutV2Address
71
+ to: BlockscoutV2Address | null
72
+ created_contract: BlockscoutV2Address | null
73
+ value: string
74
+ /** Call type, e.g. `call`, `delegatecall`, `staticcall`, `create` */
75
+ type: string
76
+ success: boolean
77
+ error: string | null
78
+ gas_limit: string | null
79
+ }
80
+
81
+ /** Keyset-paginated list: `next_page_params` are the query params of the next (older) page */
82
+ export type BlockscoutV2Page<T> = {
83
+ items: T[]
84
+ next_page_params: Record<string, string | number | null> | null
85
+ }
@@ -4,6 +4,7 @@
4
4
  /* istanbul ignore file: pure exports, bridge tested by live-common with bridge.integration.test.ts */
5
5
 
6
6
  export * from './assets'
7
+ export * from './blockscoutV2'
7
8
  export * from './editTransaction'
8
9
  export * from './etherscan'
9
10
  export * from './ledger'