@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.
- package/CHANGELOG.md +30 -0
- package/lib/adapters/blockscoutV2.d.ts +40 -0
- package/lib/adapters/blockscoutV2.d.ts.map +1 -0
- package/lib/adapters/blockscoutV2.js +177 -0
- package/lib/adapters/blockscoutV2.js.map +1 -0
- package/lib/adapters/index.d.ts +1 -0
- package/lib/adapters/index.d.ts.map +1 -1
- package/lib/adapters/index.js +1 -0
- package/lib/adapters/index.js.map +1 -1
- package/lib/chains.d.ts +1 -1
- package/lib/chains.js +1 -1
- package/lib/chains.js.map +1 -1
- package/lib/config.d.ts +51 -24
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +21 -19
- package/lib/config.js.map +1 -1
- package/lib/logic/getBlock.d.ts.map +1 -1
- package/lib/logic/getBlock.js +14 -1
- package/lib/logic/getBlock.js.map +1 -1
- package/lib/logic/internalTransactionsFetcher.d.ts.map +1 -1
- package/lib/logic/internalTransactionsFetcher.js +58 -20
- package/lib/logic/internalTransactionsFetcher.js.map +1 -1
- package/lib/network/blockscoutV2.d.ts +35 -0
- package/lib/network/blockscoutV2.d.ts.map +1 -0
- package/lib/network/blockscoutV2.js +311 -0
- package/lib/network/blockscoutV2.js.map +1 -0
- package/lib/network/explorer/etherscan.d.ts.map +1 -1
- package/lib/network/explorer/etherscan.js +11 -28
- package/lib/network/explorer/etherscan.js.map +1 -1
- package/lib/network/explorer/index.d.ts.map +1 -1
- package/lib/network/explorer/index.js +5 -0
- package/lib/network/explorer/index.js.map +1 -1
- package/lib/network/explorer/types.d.ts +6 -0
- package/lib/network/explorer/types.d.ts.map +1 -1
- package/lib/network/explorer/types.js +8 -1
- package/lib/network/explorer/types.js.map +1 -1
- package/lib/network/rewards.d.ts +11 -0
- package/lib/network/rewards.d.ts.map +1 -0
- package/lib/network/rewards.js +32 -0
- package/lib/network/rewards.js.map +1 -0
- package/lib/types/blockscoutV2.d.ts +80 -0
- package/lib/types/blockscoutV2.d.ts.map +1 -0
- package/lib/types/blockscoutV2.js +5 -0
- package/lib/types/blockscoutV2.js.map +1 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index.js +1 -0
- package/lib/types/index.js.map +1 -1
- package/lib-es/adapters/blockscoutV2.d.ts +40 -0
- package/lib-es/adapters/blockscoutV2.d.ts.map +1 -0
- package/lib-es/adapters/blockscoutV2.js +168 -0
- package/lib-es/adapters/blockscoutV2.js.map +1 -0
- package/lib-es/adapters/index.d.ts +1 -0
- package/lib-es/adapters/index.d.ts.map +1 -1
- package/lib-es/adapters/index.js +1 -0
- package/lib-es/adapters/index.js.map +1 -1
- package/lib-es/chains.d.ts +1 -1
- package/lib-es/chains.js +1 -1
- package/lib-es/chains.js.map +1 -1
- package/lib-es/config.d.ts +51 -24
- package/lib-es/config.d.ts.map +1 -1
- package/lib-es/config.js +21 -19
- package/lib-es/config.js.map +1 -1
- package/lib-es/logic/getBlock.d.ts.map +1 -1
- package/lib-es/logic/getBlock.js +14 -1
- package/lib-es/logic/getBlock.js.map +1 -1
- package/lib-es/logic/internalTransactionsFetcher.d.ts.map +1 -1
- package/lib-es/logic/internalTransactionsFetcher.js +59 -21
- package/lib-es/logic/internalTransactionsFetcher.js.map +1 -1
- package/lib-es/network/blockscoutV2.d.ts +35 -0
- package/lib-es/network/blockscoutV2.d.ts.map +1 -0
- package/lib-es/network/blockscoutV2.js +271 -0
- package/lib-es/network/blockscoutV2.js.map +1 -0
- package/lib-es/network/explorer/etherscan.d.ts.map +1 -1
- package/lib-es/network/explorer/etherscan.js +2 -19
- package/lib-es/network/explorer/etherscan.js.map +1 -1
- package/lib-es/network/explorer/index.d.ts.map +1 -1
- package/lib-es/network/explorer/index.js +5 -0
- package/lib-es/network/explorer/index.js.map +1 -1
- package/lib-es/network/explorer/types.d.ts +6 -0
- package/lib-es/network/explorer/types.d.ts.map +1 -1
- package/lib-es/network/explorer/types.js +6 -0
- package/lib-es/network/explorer/types.js.map +1 -1
- package/lib-es/network/rewards.d.ts +11 -0
- package/lib-es/network/rewards.d.ts.map +1 -0
- package/lib-es/network/rewards.js +29 -0
- package/lib-es/network/rewards.js.map +1 -0
- package/lib-es/types/blockscoutV2.d.ts +80 -0
- package/lib-es/types/blockscoutV2.d.ts.map +1 -0
- package/lib-es/types/blockscoutV2.js +4 -0
- package/lib-es/types/blockscoutV2.js.map +1 -0
- package/lib-es/types/index.d.ts +1 -0
- package/lib-es/types/index.d.ts.map +1 -1
- package/lib-es/types/index.js +1 -0
- package/lib-es/types/index.js.map +1 -1
- package/package.json +3 -3
- package/src/adapters/blockscoutV2.test.ts +296 -0
- package/src/adapters/blockscoutV2.ts +244 -0
- package/src/adapters/index.ts +1 -0
- package/src/api/tests/index.alpen_testnet.integ.test.ts +73 -0
- package/src/api/tests/index.integ.test.ts +4 -2
- package/src/api/tests/index.scroll.integ.test.ts +168 -0
- package/src/api/tests/index.shape.integ.test.ts +34 -0
- package/src/chains.ts +1 -1
- package/src/config.ts +46 -19
- package/src/logic/getBlock.ts +18 -1
- package/src/logic/internalTransactionsFetcher.ts +73 -24
- package/src/logic/tests/getBlock.test.ts +59 -3
- package/src/logic/tests/internalTransactionsFetcher.test.ts +98 -1
- package/src/network/blockscoutV2.ts +460 -0
- package/src/network/explorer/etherscan.ts +2 -29
- package/src/network/explorer/index.ts +5 -0
- package/src/network/explorer/types.ts +9 -0
- package/src/network/rewards.ts +47 -0
- package/src/network/tests/blockscoutV2.test.ts +565 -0
- package/src/network/tests/explorer/index.test.ts +21 -0
- package/src/types/blockscoutV2.ts +85 -0
- 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
|
+
}
|
package/src/types/index.ts
CHANGED