@ledgerhq/coin-evm 16.2.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.
@@ -662,6 +662,60 @@ describe('EVM Family', () => {
662
662
  ])
663
663
  })
664
664
 
665
+ it('does not duplicate WFLR Deposit when equivalent Transfer mint is emitted', () => {
666
+ const wflr = '0x1D80c49BbBCd1C0911346656B529DF9E5c2F783d'
667
+ const recipient = '0x000000000000000000000000bebcf96eeed98d495f45407ce7017179738e3552'
668
+ const amount = '0x000000000000000000000000000000000000000000000000000000000000002a'
669
+ const result = parseERC20TransfersFromLogs(
670
+ [
671
+ { address: wflr, topics: [WETH_DEPOSIT_TOPIC, recipient], data: amount },
672
+ {
673
+ address: wflr,
674
+ topics: [TRANSFER_TOPIC, `0x${'0'.repeat(24)}${'0'.repeat(40)}`, recipient],
675
+ data: amount,
676
+ },
677
+ ],
678
+ testLogger
679
+ )
680
+
681
+ expect(result).toEqual([
682
+ {
683
+ asset: { type: 'erc20', assetReference: wflr },
684
+ from: '0x0000000000000000000000000000000000000000',
685
+ to: '0xbeBcf96eEEd98D495F45407CE7017179738E3552',
686
+ value: '42',
687
+ },
688
+ ])
689
+ })
690
+ it('does not duplicate WETH-style Withdrawal when equivalent Transfer burn is emitted', () => {
691
+ const wrappedNative = '0x1111111111111111111111111111111111111111'
692
+ const owner = '0x000000000000000000000000bebcf96eeed98d495f45407ce7017179738e3552'
693
+ const amount = '0x000000000000000000000000000000000000000000000000000000000000002a'
694
+ const result = parseERC20TransfersFromLogs(
695
+ [
696
+ {
697
+ address: wrappedNative,
698
+ topics: ['0x7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65', owner],
699
+ data: amount,
700
+ },
701
+ {
702
+ address: wrappedNative,
703
+ topics: [TRANSFER_TOPIC, owner, `0x${'0'.repeat(64)}`],
704
+ data: amount,
705
+ },
706
+ ],
707
+ testLogger
708
+ )
709
+
710
+ expect(result).toEqual([
711
+ {
712
+ asset: { type: 'erc20', assetReference: wrappedNative },
713
+ from: '0xbeBcf96eEEd98D495F45407CE7017179738E3552',
714
+ to: '0x0000000000000000000000000000000000000000',
715
+ value: '42',
716
+ },
717
+ ])
718
+ })
665
719
  it('parses Mint as Transfer from 0x0', () => {
666
720
  const MINT_TOPIC = '0x0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d4121396885'
667
721
  const L2_BASE_TOKEN = '0x000000000000000000000000000000000000800A'
@@ -1929,8 +1983,8 @@ describe('EVM Family', () => {
1929
1983
 
1930
1984
  describe('getTokenBalance', () => {
1931
1985
  it('should call contract with normalized addresses for both account and token', async () => {
1932
- const EIP1191_TOKEN_ADDRESS = '0xaBf26902Fd7B624e0db40D31171eA9ddDf078351'
1933
- const NORMALIZED_TOKEN_ADDRESS = '0xabf26902fd7b624e0db40d31171ea9dddf078351'
1986
+ const EIP1191_ERC20_ADDRESS = '0xaBf26902Fd7B624e0db40D31171eA9ddDf078351'
1987
+ const NORMALIZED_ERC20_ADDRESS = '0xabf26902fd7b624e0db40d31171ea9dddf078351'
1934
1988
 
1935
1989
  // The balanceOf call is made via Contract.call which internally uses _perform
1936
1990
  // We need to check that the Contract is constructed with the normalized address
@@ -1938,13 +1992,13 @@ describe('EVM Family', () => {
1938
1992
  .spyOn(JsonRpcProvider.prototype, 'call')
1939
1993
  .mockResolvedValue('0x0000000000000000000000000000000000000000000000000000000000000064')
1940
1994
 
1941
- await nodeApi.getTokenBalance(EIP1191_CHECKSUMMED_ADDRESS, EIP1191_TOKEN_ADDRESS)
1995
+ await nodeApi.getTokenBalance(EIP1191_CHECKSUMMED_ADDRESS, EIP1191_ERC20_ADDRESS)
1942
1996
 
1943
1997
  // The call should be made to the normalized contract address
1944
1998
  // and the data should contain the normalized account address
1945
1999
  expect(callSpy).toHaveBeenCalledWith(
1946
2000
  expect.objectContaining({
1947
- to: NORMALIZED_TOKEN_ADDRESS,
2001
+ to: NORMALIZED_ERC20_ADDRESS,
1948
2002
  // The data contains the function selector (0x70a08231) + padded address
1949
2003
  data: expect.stringContaining(NORMALIZED_ADDRESS.slice(2)),
1950
2004
  })
package/.oxlintrc.json DELETED
@@ -1,94 +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/api/index.ts"],
10
- "rules": {
11
- "eslint/no-restricted-imports": [
12
- "warn",
13
- {
14
- "patterns": [
15
- {
16
- "regex": "^(\\.\\./)+(network)(/|\\.[cm]?[jt]s$|$)",
17
- "message": "ADR-049: api/ may only import logic/, types/, config.ts, errors.ts"
18
- }
19
- ]
20
- }
21
- ]
22
- }
23
- },
24
- {
25
- "files": [
26
- "src/network/explorer/types.ts",
27
- "src/network/node/explorerProxy.ts",
28
- "src/network/node/gethCallTracerToTraceBlockItems.ts",
29
- "src/network/node/rpc.common.ts"
30
- ],
31
- "rules": {
32
- "eslint/no-restricted-imports": [
33
- "warn",
34
- {
35
- "patterns": [
36
- {
37
- "regex": "^(\\.\\./)+(api|logic)(/|\\.[cm]?[jt]s$|$)",
38
- "message": "ADR-049: network/ may only import types/, config.ts, errors.ts"
39
- }
40
- ]
41
- }
42
- ]
43
- }
44
- },
45
- {
46
- "files": ["src/types/staking.ts"],
47
- "rules": {
48
- "eslint/no-restricted-imports": [
49
- "warn",
50
- {
51
- "patterns": [
52
- {
53
- "regex": "^(\\.\\./)+(api|logic|network|config|errors)(/|\\.[cm]?[jt]s$|$)",
54
- "message": "ADR-049: types/ may not import any other layer"
55
- }
56
- ]
57
- }
58
- ]
59
- }
60
- },
61
- {
62
- "files": ["src/config.ts"],
63
- "rules": {
64
- "eslint/no-restricted-imports": [
65
- "warn",
66
- {
67
- "patterns": [
68
- {
69
- "regex": "^\\.{1,2}/",
70
- "message": "ADR-049: config.ts and errors.ts may not import any other file"
71
- }
72
- ]
73
- }
74
- ]
75
- }
76
- },
77
- {
78
- "files": ["**/*.test.ts", "**/tests/**"],
79
- "rules": {
80
- "eslint/no-restricted-imports": "off"
81
- }
82
- },
83
- {
84
- "files": ["src/**/*.fixtures.ts", "src/**/*.test.ts"],
85
- "env": {
86
- "jest": true
87
- },
88
- "plugins": ["jest"],
89
- "rules": {
90
- "typescript/explicit-function-return-type": "off"
91
- }
92
- }
93
- ]
94
- }
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