@ledgerhq/coin-evm 16.0.0 → 16.2.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 (92) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/lib/chains.d.ts +0 -2
  3. package/lib/chains.d.ts.map +1 -1
  4. package/lib/chains.js +0 -4
  5. package/lib/chains.js.map +1 -1
  6. package/lib/network/node/rpc.common.d.ts.map +1 -1
  7. package/lib/network/node/rpc.common.js +33 -8
  8. package/lib/network/node/rpc.common.js.map +1 -1
  9. package/lib/network/node/types.d.ts +1 -1
  10. package/lib/network/node/types.d.ts.map +1 -1
  11. package/lib/staking/fetchers.js +0 -2
  12. package/lib/staking/fetchers.js.map +1 -1
  13. package/lib/staking/unbondings.d.ts.map +1 -1
  14. package/lib/staking/unbondings.js +0 -2
  15. package/lib/staking/unbondings.js.map +1 -1
  16. package/lib/staking/validators/monad.d.ts.map +1 -1
  17. package/lib/staking/validators/monad.js +0 -2
  18. package/lib/staking/validators/monad.js.map +1 -1
  19. package/lib/staking/validators/somnia.d.ts.map +1 -1
  20. package/lib/staking/validators/somnia.js +0 -2
  21. package/lib/staking/validators/somnia.js.map +1 -1
  22. package/lib/staking/validators/zero_gravity.d.ts.map +1 -1
  23. package/lib/staking/validators/zero_gravity.js +0 -2
  24. package/lib/staking/validators/zero_gravity.js.map +1 -1
  25. package/lib/types/etherscan.d.ts +1 -1
  26. package/lib/types/etherscan.d.ts.map +1 -1
  27. package/lib-es/chains.d.ts +0 -2
  28. package/lib-es/chains.d.ts.map +1 -1
  29. package/lib-es/chains.js +0 -4
  30. package/lib-es/chains.js.map +1 -1
  31. package/lib-es/network/node/rpc.common.d.ts.map +1 -1
  32. package/lib-es/network/node/rpc.common.js +33 -8
  33. package/lib-es/network/node/rpc.common.js.map +1 -1
  34. package/lib-es/network/node/types.d.ts +1 -1
  35. package/lib-es/network/node/types.d.ts.map +1 -1
  36. package/lib-es/staking/fetchers.js +0 -2
  37. package/lib-es/staking/fetchers.js.map +1 -1
  38. package/lib-es/staking/unbondings.d.ts.map +1 -1
  39. package/lib-es/staking/unbondings.js +0 -2
  40. package/lib-es/staking/unbondings.js.map +1 -1
  41. package/lib-es/staking/validators/monad.d.ts.map +1 -1
  42. package/lib-es/staking/validators/monad.js +0 -2
  43. package/lib-es/staking/validators/monad.js.map +1 -1
  44. package/lib-es/staking/validators/somnia.d.ts.map +1 -1
  45. package/lib-es/staking/validators/somnia.js +0 -2
  46. package/lib-es/staking/validators/somnia.js.map +1 -1
  47. package/lib-es/staking/validators/zero_gravity.d.ts.map +1 -1
  48. package/lib-es/staking/validators/zero_gravity.js +0 -2
  49. package/lib-es/staking/validators/zero_gravity.js.map +1 -1
  50. package/lib-es/types/etherscan.d.ts +1 -1
  51. package/lib-es/types/etherscan.d.ts.map +1 -1
  52. package/package.json +9 -3
  53. package/src/api/tests/getBlock.integ.test.ts +1 -1
  54. package/src/api/tests/index.unichain.integ.test.ts +46 -0
  55. package/src/chains.ts +0 -4
  56. package/src/logic/tests/combine.test.ts +1 -1
  57. package/src/logic/tests/estimateFees.test.ts +1 -1
  58. package/src/logic/tests/getStakes.test.ts +0 -8
  59. package/src/network/node/rpc.common.ts +48 -8
  60. package/src/network/node/types.ts +1 -1
  61. package/src/network/tests/node/ledger.test.ts +0 -2
  62. package/src/network/tests/node/rpc.test.ts +58 -4
  63. package/src/staking/fetchers.ts +0 -2
  64. package/src/staking/unbondings.test.ts +1 -1
  65. package/src/staking/unbondings.ts +0 -2
  66. package/src/staking/validators/monad.test.ts +0 -6
  67. package/src/staking/validators/monad.ts +0 -2
  68. package/src/staking/validators/somnia.test.ts +0 -2
  69. package/src/staking/validators/somnia.ts +0 -2
  70. package/src/staking/validators/zero_gravity.test.ts +0 -2
  71. package/src/staking/validators/zero_gravity.ts +0 -2
  72. package/src/types/etherscan.ts +1 -1
  73. package/.oxlintrc.json +0 -17
  74. package/docs/abis.md +0 -20
  75. package/docs/adapters.md +0 -10
  76. package/docs/evm-family-integration-process/README.md +0 -102
  77. package/docs/getBlock-internal-txs-schema.md +0 -104
  78. package/docs/logic.md +0 -17
  79. package/docs/network/explorer/etherscan.md +0 -35
  80. package/docs/network/explorer/index.md +0 -7
  81. package/docs/network/explorer/ledger.md +0 -22
  82. package/docs/network/gasTracker/index.md +0 -8
  83. package/docs/network/gasTracker/ledger.md +0 -13
  84. package/docs/network/node/index.md +0 -10
  85. package/docs/network/node/ledger.md +0 -47
  86. package/docs/network/node/rpc.md +0 -42
  87. package/docs/types.md +0 -18
  88. package/jest.config.js +0 -15
  89. package/jest.integ.config.js +0 -8
  90. package/knip.json +0 -30
  91. package/tsconfig.build.json +0 -14
  92. package/tsconfig.json +0 -14
@@ -147,7 +147,7 @@ describe('staking/unbondings', () => {
147
147
  amount: 101000000n * USEI_TO_EVM_SCALE,
148
148
  actions: [],
149
149
  })
150
- expect(stakes[0].asset).toMatchObject({ type: 'native', name: 'Sei' })
150
+ expect(stakes[0].asset).toMatchObject({ type: 'native' })
151
151
  })
152
152
 
153
153
  it('should not expose a withdraw action nor a withdrawId', async () => {
@@ -98,8 +98,6 @@ async function fetchCosmosRestUnbondings(
98
98
  stateUpdatedAt: completionDate,
99
99
  asset: {
100
100
  type: 'native',
101
- name: evmConfig.name,
102
- unit: evmConfig.unit,
103
101
  },
104
102
  amount,
105
103
  actions: [],
@@ -519,8 +519,6 @@ describe('staking/validators/monad', () => {
519
519
  state: 'active',
520
520
  asset: {
521
521
  type: 'native',
522
- name: 'Monad',
523
- unit: { name: 'MON', code: 'MON', magnitude: 18 },
524
522
  },
525
523
  amount: 100n,
526
524
  actions: [],
@@ -751,8 +749,6 @@ describe('staking/validators/monad', () => {
751
749
  stateUpdatedAt: new Date(NOW - 2 * EPOCH_DURATION_MS),
752
750
  asset: {
753
751
  type: 'native',
754
- name: 'Monad',
755
- unit: { name: 'MON', code: 'MON', magnitude: 18 },
756
752
  },
757
753
  amount: 40n,
758
754
  actions: [],
@@ -772,8 +768,6 @@ describe('staking/validators/monad', () => {
772
768
  stateUpdatedAt: new Date(NOW + 5 * EPOCH_DURATION_MS),
773
769
  asset: {
774
770
  type: 'native',
775
- name: 'Monad',
776
- unit: { name: 'MON', code: 'MON', magnitude: 18 },
777
771
  },
778
772
  amount: 60n,
779
773
  actions: [],
@@ -348,8 +348,6 @@ const fetchStakeForValId = async (
348
348
 
349
349
  const asset: AssetInfo = {
350
350
  type: 'native',
351
- name: evmConfig.name,
352
- unit: evmConfig.unit,
353
351
  }
354
352
  const details = {
355
353
  contractAddress,
@@ -315,8 +315,6 @@ describe('staking/validators/somnia', () => {
315
315
  state: 'active',
316
316
  asset: {
317
317
  type: 'native',
318
- name: 'Somnia',
319
- unit: { name: 'SOMI', code: 'SOMI', magnitude: 18 },
320
318
  },
321
319
  amount: 100n,
322
320
  actions: [],
@@ -326,8 +326,6 @@ export const fetchSomniaStakes = async (
326
326
 
327
327
  const asset: AssetInfo = {
328
328
  type: 'native',
329
- name: evmConfig.name,
330
- unit: evmConfig.unit,
331
329
  }
332
330
  const stakes: Stake[] = []
333
331
 
@@ -408,8 +408,6 @@ describe('staking/validators/zero_gravity', () => {
408
408
  const NOW = 1_000_000_000
409
409
  const ASSET = {
410
410
  type: 'native',
411
- name: '0G',
412
- unit: { magnitude: 18, name: '0G', code: '0G' },
413
411
  }
414
412
 
415
413
  beforeEach(() => {
@@ -228,8 +228,6 @@ export const fetchZeroGravityStakes = async (
228
228
 
229
229
  const asset: AssetInfo = {
230
230
  type: 'native',
231
- name: evmConfig.name,
232
- unit: evmConfig.unit,
233
231
  }
234
232
 
235
233
  try {
@@ -28,7 +28,7 @@ export type EtherscanOperation = {
28
28
  confirmations: string
29
29
  methodId: string
30
30
  functionName: string
31
- /** L1 data/security fee in wei, as reported by OP-stack explorers (Optimism, Base, Blast, …). */
31
+ /** L1 data/security fee in wei, as reported by OP-stack explorers (Optimism, Base, …). */
32
32
  L1FeesPaid?: string
33
33
  }
34
34
 
package/.oxlintrc.json DELETED
@@ -1,17 +0,0 @@
1
- {
2
- "$schema": "../../../node_modules/oxlint/configuration_schema.json",
3
- "extends": ["../.oxlintrc.json"],
4
- "rules": {
5
- "typescript/explicit-function-return-type": "error"
6
- },
7
- "overrides": [
8
- {
9
- "files": ["src/**/*.fixtures.ts", "src/**/*.test.ts"],
10
- "env": { "jest": true },
11
- "plugins": ["jest"],
12
- "rules": {
13
- "typescript/explicit-function-return-type": "off"
14
- }
15
- }
16
- ]
17
- }
package/docs/abis.md DELETED
@@ -1,20 +0,0 @@
1
- # `abis`
2
- The contract Application Binary Interface (ABI) is the standard way to interact with smart contracts in the Ethereum ecosystem. This JSON file represents the various methods and properties of a smart contract and is essential for crafting the calldata necessary to interact with it.
3
-
4
- ## Files
5
-
6
- #### erc20.abi.json
7
- Defines the API for a fungible token (ERC20).
8
- Full definition of the interface: https://docs.openzeppelin.com/contracts/4.x/api/token/erc20
9
-
10
- #### erc721.abi.json
11
- Defines the API for a non-fungible token (NFT) (ERC721).
12
- Full definition of the interface: https://docs.openzeppelin.com/contracts/4.x/api/token/erc721
13
-
14
- #### erc1155.abi.json
15
- Defines the API for a semi-fungible token (NFT) (ERC1155).
16
- Full definition of the interface: https://docs.openzeppelin.com/contracts/4.x/api/token/erc1155
17
-
18
- #### optimismGasPriceOracle.abi.json
19
- Specifies the API for the Optimism oracle smart contract dedicated to returning the pricing of transaction data availability on the L1 (Ethereum).
20
- See documentation here: https://docs.optimism.io/builders/dapp-developers/transactions/estimates (section "Estimate the L1 data fee")
package/docs/adapters.md DELETED
@@ -1,10 +0,0 @@
1
- # `adapters`
2
- Set of functions in charge of converting a transaction format specific to a library or a backend into a Ledger Live format or vice-versa.
3
-
4
- ## Files
5
-
6
- #### etherscan.ts
7
- Functions used to convert transactions coming from the [etherscan-like explorers](https://docs.etherscan.io/api-endpoints/accounts)
8
-
9
- #### ledger.ts
10
- Functions used to convert transactions coming from the [Ledger explorers](https://explorers.api.live.ledger.com/blockchain/v4/eth/docs/#/address/Transactions%20by%20address)
@@ -1,102 +0,0 @@
1
- # EVM family integration process
2
-
3
- _How to integrate a new EVM family currency in the Ledger Live application._
4
-
5
- This document will outline the different steps needed to implement a new EVM family currency in the Ledger Live application.
6
- Depending on the specifications, some steps might not be needed for all currencies.
7
-
8
- ## Specifications
9
-
10
- Most EVM coin integrations are quite similar. The main specs will be outlined below.
11
- But each coin may have its specificities and more information can be found on the specific coin integration Jira Epic created for each integration, based on this template https://ledgerhq.atlassian.net/browse/LIVE-10187
12
-
13
- - Integration is done in Ledger Live desktop and Ledger Live mobile
14
- - Supported features:
15
- - Sending and receiving coins
16
- - Viewing transaction history
17
- - Token support, enabling interactions with the blockchain tokens
18
- - Use of public RPC node and explorer (etherscan-like). This should be specified in the corresponding Jira Epic
19
- - To find a public node, you can use https://chainlist.org/ for example
20
- - To find a public explorer, you can use https://blockscan.com/ (etherscan-like) for example
21
- - The [Ethereum embedded app](https://github.com/LedgerHQ/app-ethereum) must handle this new network
22
-
23
- ## Live codebase update
24
-
25
- Here is an example PR of an EVM currency integration: https://github.com/LedgerHQ/ledger-live/pull/4008
26
-
27
- ### Main steps
28
-
29
- _Common steps for all new EVM currency integration_
30
-
31
- 1. Add a new config entry for the new currency in the `@domain/entity-currency-crypto` registry
32
- 2. Nothing to do for the fee-estimation dummy recipient: the dead address used for fee estimation is now owned by the consumer (e.g. ledger-live-common's EVM family, `libs/ledger-live-common/src/families/evm/constants.ts`) and covers every EVM currency (only zkSync differs). `coin-evm` no longer ships a `getEvmDummyAddress` helper.
33
- 3. Add the new currency ID to the `setSupportedCurrencies` function param on each relevant project ([CLI](../../../../../apps/cli/src/live-common-setup-base.ts), [LLD](../../../../../apps/ledger-live-desktop/src/live-common-set-supported-currencies.ts), [LLM](../../../../../apps/ledger-live-mobile/src/live-common-setup.ts), [LLC test environment](../../../../../libs/ledger-live-common/src/__tests__/test-helpers/environment.ts), [web-tools](../../../../../apps/web-tools/src/live-common-setup.ts) and [account-migration tests](../../../../../libs/ledger-live-common/src/__tests__/migration/account-migration.ts))
34
- 4. Add a new feature flag config for this currency:
35
- 1. The new feature flag type in the [`CurrencyFeatures`](../../../../../libs/types-live/src/feature.ts) type under `libs/types-live/src/feature.ts`
36
- 2. The new feature flag definition with default value in the [`CURRENCY_DEFAULT_FEATURES`](../../../../../libs/ledger-live-common/src/featureFlags/defaultFeatures.ts) mapping under `libs/ledger-live-common/src/featureFlags/defaultFeatures.ts`
37
- 3. Use this new feature flag in [`useCurrenciesUnderFeatureFlag.ts`](../../../../../libs/ledger-live-common/src/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.ts)
38
- 5. Add the EVM config for RPC node and explorer under [`libs/ledger-live-common/src/families/evm/config.ts`](../../../../../libs/ledger-live-common/src/families/evm/config.ts)
39
- 6. Update snapshot files:
40
- 1. `pnpm test -- -u` from `libs/coin-framework` to update `formatCurrencyUnit.test.ts` snapshots
41
- 2. `pnpm test:playwright tests/specs/services/wallet-api.spec.ts` from `apps/ledger-live-desktop` and update `tests/fixtures/wallet-api.ts` with new currencies
42
- 7. Add the related currency icon to the [crypto-icons](https://github.com/LedgerHQ/crypto-icons) repository (see its README for instructions)
43
-
44
- ### Optional steps
45
-
46
- _Optional / extra steps that might be needed on a case-by-case basis depending on the integration_
47
-
48
- - If the related currency public explorer is not an etherscan-like, you might need to add a new implementation for this currency explorer
49
- - If needed, create a new explorer implementation of this explorer API in a new file under the [`libs/coin-modules/coin-evm/src/network/explorer`](../../src/network/explorer) folder
50
- - Add the new explorer type to:
51
- - the `getExplorerApi` function under [`libs/coin-modules/coin-evm/src/network/explorer/index.ts`](../../src/network/explorer/index.ts)
52
- - the `EthereumLikeInfo.explorer.type` type under [`libs/ledger-wallet-framework/src/types.ts`](../../../../../libs/ledger-wallet-framework/src/types.ts)
53
- - if the new explorer type follows the etherscan-like API, add it to the `isEtherscanLikeExplorerConfig` type guard under [`libs/coin-modules/coin-evm/src/network/explorer/types.ts`](../../src/network/explorer/types.ts) (this is the case for some custom made explorers that are not blockscan white label implementation, but are still compatible with the blockscan/etherscan API)
54
-
55
- ## Tokens support
56
-
57
- Here are the steps to handle the new currencies (ERC20) tokens, if relevant:
58
-
59
- - add the new tokens config to the [CAL](https://github.com/LedgerHQ/crypto-assets) (historically handled by @adrienlacombe-ledger)
60
- - after this update of the CAL, check that the tokens are present on the CDN, replacing `{chainId}` with the actual currency chain ID, specified under `ethereumLikeInfo.chainId` in the currency config (in the `@domain/entity-currency-crypto` registry) which would be `1` for ethereum mainnet for example, using https://cdn.live.ledger.com/cryptoassets/evm/{chainId}/erc20.json
61
-
62
- No change should be needed on Ledger Live side since token data is consumed from
63
- CAL/CDN during the release flow.
64
-
65
- ## Counter values support (fiat prices)
66
-
67
- To have the associated market (fiat) price supported for the network being added, some config updates are needed on the `CAL` and `countervalue service` sides.
68
-
69
- The process for this can be found here: https://ledgerhq.atlassian.net/wiki/spaces/WALLETCO/pages/4354769042/Adding+price+support+for+a+currency
70
-
71
- ## Ethereum app firmware update
72
-
73
- The new network being added needs to be handled by the [nano ethereum app](https://github.com/LedgerHQ/app-ethereum).
74
-
75
- Make sure the network being added is present under the `network_info_t` mapping in `src_common/network.c` ([here](https://github.com/LedgerHQ/app-ethereum/blob/develop/src_common/network.c) for staging and [here](https://github.com/LedgerHQ/app-ethereum/blob/master/src_common/network.c) for prod).
76
-
77
- In Ledger Live, make sure the ethereum nano app version requirements match the latest version of the ethereum app handling the network being added:
78
-
79
- - `appVersion` in `getAppQuery` under [`libs/coin-modules/coin-evm/src/specs.ts`](../../../../ledger-live-common/src/families/evm/bot/specs.ts)
80
- - `Ethereum` in `appVersionsRequired` under [`libs/ledger-live-common/src/apps/support.ts`](../../../../../libs/ledger-live-common/src/apps/support.ts)
81
- - related tests for the ethereum app version under [`libs/ledger-live-common/src/apps/support.test.ts`](../../../../../libs/ledger-live-common/src/apps/support.test.ts)
82
-
83
- ## Tests
84
-
85
- ### Bot
86
-
87
- - Make sure to fund the appropriate bot(s) with coins and tokens of the new network being added. For local portfolio bot context, see [`libs/ledger-live-common/src/bot/portfolio/README.md`](../../../../../libs/ledger-live-common/src/bot/portfolio/README.md).
88
- - Make sure to make the bot run multiple times on your PR to make sure everything works fine with the new network
89
- - If the coin related to the network you are adding is somewhat expensive, you can tailor the minimum balance needed to test this coin by updating `minBalancePerCurrencyId` under [`libs/coin-modules/coin-evm/src/specs.ts`](../../../../ledger-live-common/src/families/evm/bot/specs.ts)
90
-
91
- ### Manual testing
92
-
93
- The bare minimum to test in terms of flows is, on both LLD and LLM:
94
-
95
- - Add account
96
- - Send funds (coins) from one account to another
97
- - Add (receive) token (if supported)
98
- - Send token (if supported)
99
-
100
- ## Firebase Feature Flag config
101
-
102
- Make sure to add the newly created currency feature flag to the Firebase config
@@ -1,104 +0,0 @@
1
- # Internal transactions retrieval in getBlock
2
-
3
- This document describes how internal transactions are fetched and merged when calling `getBlock(currency, height)`.
4
-
5
- ## Flow overview
6
-
7
- ```mermaid
8
- flowchart TB
9
- subgraph entry["getBlock(currency, height)"]
10
- A[getNodeApi] --> B["createInternalTransactionsFetcher(config, nodeApi, sources, logger)"]
11
- B --> C[fetchInternalTxs]
12
- end
13
-
14
- subgraph parallel["Promise.all (parallel)"]
15
- D["nodeApi.getBlockByHeight(height, true)"]
16
- E["fetchInternalTxs(height)"]
17
- end
18
-
19
- A --> parallel
20
- C --> E
21
-
22
- subgraph sources["Ordered source list (default or getBlockInternalTxsSources)"]
23
- F["explorer → getInternalTransactionsByBlock"]
24
- G["trace_block → nodeApi.traceBlockErigon"]
25
- H["debug_traceBlockByNumber → nodeApi.traceBlockGeth"]
26
- I["empty → resolve Map()"]
27
- end
28
-
29
- E -.-> sources
30
-
31
- subgraph compose["composeInternalTxsFetcher loop"]
32
- J{source resolves?}
33
- J -->|yes| K["Map(txHash → BlockOperation[])"]
34
- J -->|SourceUnavailableError| L[skip to next source]
35
- J -->|real runtime error| M[remember errors, next source]
36
- L --> N{next source}
37
- M --> N
38
- N -->|empty, no real error| O[resolve empty Map]
39
- N -->|empty, real errors remembered| P[throw collected real errors]
40
- N -->|list exhausted| P
41
- end
42
-
43
- sources -.-> compose
44
-
45
- subgraph after["after parallel"]
46
- Q[result, internalTxs]
47
- R[getTransactionsFromNode]
48
- S[mergeInternalTransactions]
49
- T[return Block]
50
- end
51
-
52
- parallel --> Q
53
- Q --> R
54
- R --> S
55
- S --> T
56
- ```
57
-
58
- ## Default source list
59
-
60
- When `getBlockInternalTxsSources` is absent, the default is:
61
-
62
- `["explorer", "trace_block", "debug_traceBlockByNumber", "empty"]`
63
-
64
- Built via `internalTxSourcesFromList(["explorer", "trace_block", "debug_traceBlockByNumber", "empty"])` in `internalTxSources.ts`.
65
-
66
- ## Source semantics
67
-
68
- | Source | When unavailable (skipped) | When available but fails at runtime |
69
- |--------|---------------------------|-------------------------------------|
70
- | `explorer` | Explorer config is not etherscan-like | Best-effort: wrapped as `SourceUnavailableError`, fall through to node traces |
71
- | `trace_block` | `nodeApi.traceBlockErigon` is undefined | Remember error, try next source; rethrow collected errors when `empty` is reached or the list is exhausted without a later success (e.g. erigon error → geth fallback) |
72
- | `debug_traceBlockByNumber` | `nodeApi.traceBlockGeth` is undefined | Same as `trace_block`: remember and continue; rethrow collected errors only when no later source succeeds |
73
- | `empty` | N/A (terminal) | Resolves empty Map only if no real runtime errors were remembered; otherwise re-throws all collected real errors |
74
-
75
- **Behaviour-preserving rule:** structurally unsupported sources are skipped (`SourceUnavailableError`). Explorer failures are always best-effort (fall through). Runtime trace failures are remembered and the loop continues to later sources (erigon → geth); collected real errors are rethrown only when `empty` is reached with remembered errors or the list ends without a success (single error rethrown as-is, multiple as `AggregateError`). A trailing `empty` resolves only when every prior source was unavailable, not when a trace call failed at runtime.
76
-
77
- ## Paths summary
78
-
79
- | Explorer config | Primary source | Fallback |
80
- |-----------------|----------------|----------|
81
- | Etherscan-like (etherscan, blockscout, teloscan, klaytnfinder, corescan) | `getInternalTransactionsByBlock` → `txlistinternal` | `traceBlockErigon` → `traceBlockGeth` → empty (if traces unavailable) or propagate (if traces error) |
82
- | Other (ledger, none, …) | `traceBlockErigon` → `traceBlockGeth` | empty (if traces unavailable) or propagate (if traces error) |
83
-
84
- ## Data flow
85
-
86
- 1. **Explorer path**
87
- `getInternalTransactionsByBlock` → `EtherscanInternalTransaction[]` → `internalTxsToOperationsByHash` → `Map<string, BlockOperation[]>`.
88
-
89
- 2. **Node trace paths**
90
- `traceBlockErigon` / `traceBlockGeth` → RPC `trace_block` / `debug_traceBlockByNumber` → `TraceBlockItem[]` → `traceBlockItemsToOperationsByHash` → `Map<string, BlockOperation[]>`.
91
-
92
- 3. **Merge**
93
- `mergeInternalTransactions(transactions, internalTxs)` adds each `internalTxs.get(tx.hash)` as extra `operations` on the corresponding `BlockTransaction`.
94
-
95
- ## Files
96
-
97
- - **Fetcher wiring:** `libs/coin-modules/coin-evm/src/logic/internalTransactionsFetcher.ts`
98
- - **getBlock:** `libs/coin-modules/coin-evm/src/logic/getBlock.ts`
99
- - **Source list builder:** `libs/coin-modules/coin-evm/src/internalTxSources.ts`
100
- - **Config field:** `libs/coin-modules/coin-evm/src/config.ts` (`getBlockInternalTxsSources`)
101
- - **Explorer internal txs:** `libs/coin-modules/coin-evm/src/network/explorer/etherscan.ts`
102
- - **Explorer → operations:** `libs/coin-modules/coin-evm/src/adapters/etherscan.ts`
103
- - **RPC traces:** `libs/coin-modules/coin-evm/src/network/node/rpc.common.ts` (`traceBlockErigon`, `traceBlockGeth`)
104
- - **Trace → operations:** `libs/coin-modules/coin-evm/src/adapters/blockOperations.ts`
package/docs/logic.md DELETED
@@ -1,17 +0,0 @@
1
- # `logic.ts`
2
- Set of helpers for the whole coin-evm module.
3
-
4
- ## Methods
5
-
6
- #### getGasLimit
7
- Helper return the gas limit of a transaction, either customized by the user or the default one.
8
-
9
- #### getEstimatedFees
10
- Combines the gas limit and the gas price of a transaction to return the estimated maximum fee payed for its execution.
11
-
12
- #### getAdditionalLayer2Fees
13
- Some Layer 2 require additional fee in order to execute a transaction, not limiting the spending to its `gasLimit`. As of today, it's only the case for Layer 2 implementing the [OP Stack](https://stack.optimism.io/) standard and therefore behaving like Optimism.
14
- This method is responsible for providing that additional fee in an agnostic manner.
15
-
16
- #### padHexString
17
- Add necessary "0" in a hexadecimal string in order to make its character an even number, which can be necessary to some implementations. (e.g. 0x123 => 0x0123)
@@ -1,35 +0,0 @@
1
- # `etherscan.ts`
2
- Set of functions designed to retrieve transactions associated with an account through explorers that utilize the [etherscan API](https://docs.etherscan.io/api-endpoints/accounts).
3
-
4
- ### Constants
5
-
6
- #### ETHERSCAN_TIMEOUT
7
- Minimum time between two requests, allowing for retries after a failure.
8
-
9
- #### DEFAULT_RETRIES_API
10
- Number of retries when a request fails.
11
-
12
- ### Methods
13
- #### fetchWithRetries
14
- This helper function wraps the basic axios request method, incorporating handling for retries upon failure. This is particularly relevant due to a rate limit on etherscan requests without an API key, allowing only one request every 5 seconds.
15
-
16
- #### getLastCoinOperations
17
- Uses `fetchWithRetries` to retrieve coin transactions for a given address. This method does not consider any outcomes resulting from that transaction, such as internal transactions or events.
18
-
19
- #### getLastTokenOperations
20
- Uses `fetchWithRetries` to retrieve ERC20 transfer events for a specified address. These transfer events are often treated as "transactions" for simplicity, but they are essentially side effects of a coin transaction interacting with a smart contract, indicating that a particular smart contract has completed an action.
21
-
22
- #### getLastERC721Operations
23
- Uses `fetchWithRetries` to retrieve ERC721 (NFT) transfer events for a specified address. Similar to ERC20 transfer events, these are often regarded as "transactions" for simplicity, though they are actually side effects of a coin transaction interacting with a smart contract, signifying the completion of a specific smart contract transfer action.
24
-
25
- #### getLastERC1155Operations
26
- Uses `fetchWithRetries` to retrieve ERC1155 (NFT) transfer events for a specified address. Similar to ERC20 transfer events, these are often regarded as "transactions" for simplicity, though they are actually side effects of a coin transaction interacting with a smart contract, signifying the completion of a specific smart contract transfer
27
-
28
- #### getLastNftOperations
29
- A wrapper around the two NFT fetching operations.
30
-
31
- #### getLastInternalOperations
32
- Uses `fetchWithRetries` to fetch internal transactions for a specified address. These transactions are a byproduct of a coin transaction interacting with a smart contract, causing that smart contract to create transactions itself.
33
-
34
- #### getLastOperations
35
- Responsible for triggering all the other methods to fetch every type of transaction possible and return each type separately.
@@ -1,7 +0,0 @@
1
- # `index.ts`
2
-
3
- ## Methods
4
-
5
- #### getExplorerApi
6
-
7
- This method is used to determine the explorer designated for a particular currency. While some explorers may share the same API, mainly owing to compatibility with the [Etherscan API](https://docs.etherscan.io/api-endpoints/accounts), any explorer with the capability to provide the complete transaction history of an account can be included as an option.
@@ -1,22 +0,0 @@
1
- # `ledger.ts`
2
- Set of functions designed to retrieve transactions associated with an account through the [Ledger explorers](https://explorers.api.live.ledger.com/blockchain/v4/eth/docs/).
3
-
4
- ### Constants
5
-
6
- #### BATCH_SIZE
7
- Maximum number of transactions returned by a single explorer request.
8
-
9
-
10
- #### LEDGER_TIMEOUT
11
- Minimum time between two requests for retry after a failure.
12
-
13
- #### DEFAULT_RETRIES_API
14
- Number of retries when a request fails.
15
-
16
- ### Methods
17
-
18
- #### fetchPaginatedOpsWithRetries
19
- This is a general request method responsible for fetching all transactions of all types for a given address. It manages retries and pagination for a complete retrieval.
20
-
21
- #### getLastOperations
22
- This method utilizes `fetchPaginatedOpsWithRetries` to retrieve all transactions, sort them by type, and return each type separately.
@@ -1,8 +0,0 @@
1
- # `index.ts`
2
-
3
-
4
- ## Methods
5
-
6
- #### getGasTracker
7
-
8
- Method used to select the gasTracker optionnaly defined for a specific currency.
@@ -1,13 +0,0 @@
1
- # `ledger.ts`
2
-
3
- This module consists of functions responsible for retrieving data related to gas pricing using the [Ledger explorers](https://explorers.api.live.ledger.com/blockchain/v4/eth/docs/#/default/getBlockchainV4EthGastrackerBarometer).
4
-
5
- ### Constants
6
-
7
- #### explorerIdGasTrackerMap
8
- This map is utilized to associate an explorer ID/currency with a set of properties of the gas tracker linked to it, such as its compatibility with [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559) or not.
9
-
10
- ### Methods
11
-
12
- #### getGasOptions
13
- This method is responsible for providing three options for gas pricing: slow, medium, and fast.
@@ -1,10 +0,0 @@
1
- # `index.ts`
2
-
3
-
4
- ## Methods
5
-
6
- #### getNodeApi
7
-
8
- Method used to select the node defined for a specific currency. The node can be an RPC node or a simple REST API as long as it's capable of providing a given set of functionalities.
9
-
10
- Signature: `getNodeApi(config, logger)`. The `logger` (usually `context.logger`) is required; it is captured when the `NodeApi` for a given config is first built and memoized, and is used for all its logs.
@@ -1,47 +0,0 @@
1
- # `ledger.ts`
2
- Set of functions specific to Ledger nodes functionalities through the [explorers API](https://explorers.api.live.ledger.com/blockchain/v4/eth/docs/).
3
-
4
- ### Constants
5
-
6
- #### LEDGER_TIMEOUT
7
- Maximum time before a request is deemed timed out and should result in failure.
8
-
9
- #### LEDGER_TIME_BETWEEN_TRIES
10
- Minimum time between two requests for retry after a failure.
11
-
12
- #### DEFAULT_RETRIES_API
13
- Number of retries when a request fails.
14
-
15
- ### Methods
16
- #### fetchWithRetries
17
- A helper function encapsulating the basic axios request method and incorporating retry handling in case of failure.
18
-
19
- #### getTransaction
20
- Retrieves a transaction by hash and returns its block and nonce.
21
-
22
- #### getCoinBalance
23
- Provides the amount of coin for a given address in wei.
24
-
25
- #### getBatchTokenBalances
26
- Batches multiple requests for token balances into a single one.
27
-
28
- #### getTokenBalance
29
- Returns the amount of tokens for a given address based on the balanceOf method of the [ERC20 standard](https://eips.ethereum.org/EIPS/eip-20). This request will be batched with other requests made in the same synchronization.
30
-
31
- #### getTransactionCount
32
- Returns the number of transaction made by an account. This will be then used as nonce for a future transaction crafting.
33
-
34
- #### getGasEstimation
35
- Simulates a transaction to estimate the amount of gas consumed in executing the transaction on the blockchain. If the transaction is impossible (e.g. sending more than the account owns), the simulation will fail and no estimation will be returned.
36
-
37
- #### getFeeData
38
- In charge of finding the different elements for the gas pricing depending on the chain ability to use [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559) or not. If the chain supports EIP-1559, it should return a `maxPriorityFeePerGas`, a `maxFeePerGas` & a `nextBaseFee`, otherwise it should simply return a `gasPrice` value.
39
-
40
- #### broadcastTransaction
41
- Broadcasts an RLP serialized signed transaction and returns its hash to poll a node using the `getTransaction` method, determining when it has been added to a block.
42
-
43
- #### getBlockByHeight
44
- Fetches basic information from a block by its height, primarily used to obtain its creation timestamp.
45
-
46
- #### getOptimismAdditionalFees
47
- Requests an oracle smart contract to estimate the L1 fee that an account will need to pay for an optimism transaction to be included in a block. This fee is related to data availability. For more information, refer to: https://docs.optimism.io/builders/dapp-developers/transactions/estimates
@@ -1,42 +0,0 @@
1
- # `rpc.ts`
2
- Set of functions specific to interacting with an EVM RPC Node. The JSON-RPC API is documented [here](https://ethereum.org/developers/docs/apis/json-rpc).
3
-
4
- ### Constants
5
-
6
- #### RPC_TIMEOUT
7
- Minimum time between two requests for retry after a failure.
8
-
9
- #### DEFAULT_RETRIES_RPC_METHODS
10
- Number of retries when a request fails.
11
-
12
- ### Methods
13
- #### withApi
14
- A helper function encapsulating the `StaticJsonRpcProvider` object and incorporating retry handling in case of failure.
15
-
16
- #### getTransaction
17
- Retrieves a transaction by hash and returns its block and nonce.
18
-
19
- #### getCoinBalance
20
- Provides the amount of coin for a given address in wei.
21
-
22
-
23
- #### getTokenBalance
24
- Returns the amount of tokens for a given address based on the balanceOf method of the [ERC20 standard](https://eips.ethereum.org/EIPS/eip-20). This request will be batched with other requests made in the same synchronization.
25
-
26
- #### getTransactionCount
27
- Returns the number of transaction made by an account. This will be then used as nonce for a future transaction crafting.
28
-
29
- #### getGasEstimation
30
- Simulates a transaction to estimate the amount of gas consumed in executing the transaction on the blockchain. If the transaction is impossible (e.g. sending more than the account owns), the simulation will fail and no estimation will be returned.
31
-
32
- #### getFeeData
33
- In charge of finding the different elements for the gas pricing depending on the chain ability to use [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559) or not. If the chain supports EIP-1559, it should return a `maxPriorityFeePerGas`, a `maxFeePerGas` & a `nextBaseFee`, otherwise it should simply return a `gasPrice` value.
34
-
35
- #### broadcastTransaction
36
- Broadcasts an RLP serialized signed transaction and returns its hash to poll a node using the `getTransaction` method, determining when it has been added to a block.
37
-
38
- #### getBlockByHeight
39
- Fetches basic information from a block by its height, primarily used to obtain its creation timestamp.
40
-
41
- #### getOptimismAdditionalFees
42
- Requests an oracle smart contract to estimate the L1 fee that an account will need to pay for an optimism transaction to be included in a block. This fee is related to data availability. For more information, refer to: https://docs.optimism.io/builders/dapp-developers/transactions/estimates
package/docs/types.md DELETED
@@ -1,18 +0,0 @@
1
- # `types`
2
-
3
- ## Files
4
-
5
- #### editTransaction
6
- Set of types proper to the functionality of the replace by fee mechanism.
7
-
8
- #### etherscan
9
- Set of types proper to etherscan explorers. Mostly containing their own transaction format, received from their API. Also used for Blockscout explorers and any other explorer having a compatiblity layer with Etherscan.
10
-
11
- #### ledger
12
- Set of types proper to ledger explorers. Mostly containing their own transaction format, received from their API.
13
-
14
- #### signer
15
- Set of types for the abstraction added to remove the dependency of the `coin-evm` module with the `@ledgerhq/hw-app-eth` module (as a dependency, not devDependency which is necessary for some types). Mostly used in the bridge definition with the `buildSignOperation` & `makeAccountBridgeReceive` methods.
16
-
17
- #### transaction
18
- Set of types representing the `evm` family transactions, specific to Ledger Live and/or the `@ledgerhq/ledger-wallet-framework`
package/jest.config.js DELETED
@@ -1,15 +0,0 @@
1
- // SPDX-FileCopyrightText: © 2024 LEDGER SAS
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- const base = require("../jest.config.base");
5
-
6
- module.exports = {
7
- ...base,
8
- passWithNoTests: true,
9
- setupFilesAfterEnv: ["jest-expect-message", "dotenv/config"],
10
- // Imported from ledger-live with a pre-existing handle leak: some suites leave
11
- // sockets/timers behind, so jest never returns on its own in CI (the Unit Tests job
12
- // ran 36 min without finishing). forceExit ends the run once tests are done.
13
- forceExit: true,
14
- maxWorkers: 2,
15
- };
@@ -1,8 +0,0 @@
1
- // SPDX-FileCopyrightText: © 2024 LEDGER SAS
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- /** @type {import('jest').Config} */
5
- module.exports = {
6
- ...require("../jest.integ.config.base"),
7
- testTimeout: 90_000,
8
- };