@ledgerhq/coin-evm 16.2.4 → 16.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/CHANGELOG.md +24 -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 +1499 -0
  14. package/lib/config.d.ts.map +1 -1
  15. package/lib/config.js +968 -1
  16. package/lib/config.js.map +1 -1
  17. package/lib/logic/internalTransactionsFetcher.d.ts.map +1 -1
  18. package/lib/logic/internalTransactionsFetcher.js +13 -2
  19. package/lib/logic/internalTransactionsFetcher.js.map +1 -1
  20. package/lib/network/blockscoutV2.d.ts +35 -0
  21. package/lib/network/blockscoutV2.d.ts.map +1 -0
  22. package/lib/network/blockscoutV2.js +311 -0
  23. package/lib/network/blockscoutV2.js.map +1 -0
  24. package/lib/network/explorer/etherscan.d.ts.map +1 -1
  25. package/lib/network/explorer/etherscan.js +11 -28
  26. package/lib/network/explorer/etherscan.js.map +1 -1
  27. package/lib/network/explorer/index.d.ts.map +1 -1
  28. package/lib/network/explorer/index.js +5 -0
  29. package/lib/network/explorer/index.js.map +1 -1
  30. package/lib/network/explorer/types.d.ts +6 -0
  31. package/lib/network/explorer/types.d.ts.map +1 -1
  32. package/lib/network/explorer/types.js +8 -1
  33. package/lib/network/explorer/types.js.map +1 -1
  34. package/lib/network/rewards.d.ts +11 -0
  35. package/lib/network/rewards.d.ts.map +1 -0
  36. package/lib/network/rewards.js +32 -0
  37. package/lib/network/rewards.js.map +1 -0
  38. package/lib/types/blockscoutV2.d.ts +80 -0
  39. package/lib/types/blockscoutV2.d.ts.map +1 -0
  40. package/lib/types/blockscoutV2.js +5 -0
  41. package/lib/types/blockscoutV2.js.map +1 -0
  42. package/lib/types/index.d.ts +1 -0
  43. package/lib/types/index.d.ts.map +1 -1
  44. package/lib/types/index.js +1 -0
  45. package/lib/types/index.js.map +1 -1
  46. package/lib-es/adapters/blockscoutV2.d.ts +40 -0
  47. package/lib-es/adapters/blockscoutV2.d.ts.map +1 -0
  48. package/lib-es/adapters/blockscoutV2.js +168 -0
  49. package/lib-es/adapters/blockscoutV2.js.map +1 -0
  50. package/lib-es/adapters/index.d.ts +1 -0
  51. package/lib-es/adapters/index.d.ts.map +1 -1
  52. package/lib-es/adapters/index.js +1 -0
  53. package/lib-es/adapters/index.js.map +1 -1
  54. package/lib-es/chains.d.ts +1 -1
  55. package/lib-es/chains.js +1 -1
  56. package/lib-es/chains.js.map +1 -1
  57. package/lib-es/config.d.ts +1499 -0
  58. package/lib-es/config.d.ts.map +1 -1
  59. package/lib-es/config.js +967 -0
  60. package/lib-es/config.js.map +1 -1
  61. package/lib-es/logic/internalTransactionsFetcher.d.ts.map +1 -1
  62. package/lib-es/logic/internalTransactionsFetcher.js +14 -3
  63. package/lib-es/logic/internalTransactionsFetcher.js.map +1 -1
  64. package/lib-es/network/blockscoutV2.d.ts +35 -0
  65. package/lib-es/network/blockscoutV2.d.ts.map +1 -0
  66. package/lib-es/network/blockscoutV2.js +271 -0
  67. package/lib-es/network/blockscoutV2.js.map +1 -0
  68. package/lib-es/network/explorer/etherscan.d.ts.map +1 -1
  69. package/lib-es/network/explorer/etherscan.js +2 -19
  70. package/lib-es/network/explorer/etherscan.js.map +1 -1
  71. package/lib-es/network/explorer/index.d.ts.map +1 -1
  72. package/lib-es/network/explorer/index.js +5 -0
  73. package/lib-es/network/explorer/index.js.map +1 -1
  74. package/lib-es/network/explorer/types.d.ts +6 -0
  75. package/lib-es/network/explorer/types.d.ts.map +1 -1
  76. package/lib-es/network/explorer/types.js +6 -0
  77. package/lib-es/network/explorer/types.js.map +1 -1
  78. package/lib-es/network/rewards.d.ts +11 -0
  79. package/lib-es/network/rewards.d.ts.map +1 -0
  80. package/lib-es/network/rewards.js +29 -0
  81. package/lib-es/network/rewards.js.map +1 -0
  82. package/lib-es/types/blockscoutV2.d.ts +80 -0
  83. package/lib-es/types/blockscoutV2.d.ts.map +1 -0
  84. package/lib-es/types/blockscoutV2.js +4 -0
  85. package/lib-es/types/blockscoutV2.js.map +1 -0
  86. package/lib-es/types/index.d.ts +1 -0
  87. package/lib-es/types/index.d.ts.map +1 -1
  88. package/lib-es/types/index.js +1 -0
  89. package/lib-es/types/index.js.map +1 -1
  90. package/package.json +1 -1
  91. package/src/adapters/blockscoutV2.test.ts +296 -0
  92. package/src/adapters/blockscoutV2.ts +244 -0
  93. package/src/adapters/index.ts +1 -0
  94. package/src/api/tests/index.alpen_testnet.integ.test.ts +73 -0
  95. package/src/api/tests/index.integ.test.ts +4 -2
  96. package/src/api/tests/index.scroll.integ.test.ts +168 -0
  97. package/src/api/tests/index.shape.integ.test.ts +34 -0
  98. package/src/chains.ts +1 -1
  99. package/src/config.ts +993 -0
  100. package/src/logic/internalTransactionsFetcher.ts +20 -3
  101. package/src/logic/tests/internalTransactionsFetcher.test.ts +51 -0
  102. package/src/network/blockscoutV2.ts +460 -0
  103. package/src/network/explorer/etherscan.ts +2 -29
  104. package/src/network/explorer/index.ts +5 -0
  105. package/src/network/explorer/types.ts +9 -0
  106. package/src/network/rewards.ts +47 -0
  107. package/src/network/tests/blockscoutV2.test.ts +565 -0
  108. package/src/network/tests/explorer/index.test.ts +21 -0
  109. package/src/types/blockscoutV2.ts +85 -0
  110. package/src/types/index.ts +1 -0
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/network/explorer/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAM1C;;GAEG;AACH,eAAO,MAAM,cAAc,GAAI,QAAQ,aAAa,KAAG,WAmBtD,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/network/explorer/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAO1C;;GAEG;AACH,eAAO,MAAM,cAAc,GAAI,QAAQ,aAAa,KAAG,WAuBtD,CAAA"}
@@ -1,6 +1,7 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import { UnknownExplorer } from '../../errors';
4
+ import blockscoutV2Api from '../blockscoutV2';
4
5
  import etherscanLikeApi from './etherscan';
5
6
  import ledgerExplorerApi from './ledger';
6
7
  import noExplorerAPI from './none';
@@ -18,6 +19,10 @@ export const getExplorerApi = (config) => {
18
19
  return config.explorer.noCache
19
20
  ? etherscanLikeApi.explorerApiNoCache
20
21
  : etherscanLikeApi.explorerApi;
22
+ case 'blockscout-v2':
23
+ return config.explorer.noCache
24
+ ? blockscoutV2Api.explorerApiNoCache
25
+ : blockscoutV2Api.explorerApi;
21
26
  case 'ledger':
22
27
  return ledgerExplorerApi;
23
28
  case 'none':
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/network/explorer/index.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,sCAAsC;AAItC,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,gBAAgB,MAAM,aAAa,CAAA;AAC1C,OAAO,iBAAiB,MAAM,UAAU,CAAA;AACxC,OAAO,aAAa,MAAM,QAAQ,CAAA;AAElC;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GA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CAAC,gBAAgB,CAAC,WAAW,CAAA;QAClC,KAAK,eAAe;YAClB,OAAO,MAAM,CAAC,QAAQ,CAAC,OAAO;gBAC5B,CAAC,CAAC,eAAe,CAAC,kBAAkB;gBACpC,CAAC,CAAC,eAAe,CAAC,WAAW,CAAA;QACjC,KAAK,QAAQ;YACX,OAAO,iBAAiB,CAAA;QAC1B,KAAK,MAAM;YACT,OAAO,aAAa,CAAA;QAEtB;YACE,MAAM,IAAI,eAAe,CAAC,kCAAkC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAA;IAC9E,CAAC;AACH,CAAC,CAAA"}
@@ -31,6 +31,12 @@ type ExplorerConfig = EvmConfigInfo['explorer'];
31
31
  export declare const isLedgerExplorerConfig: (explorerConfig: ExplorerConfig) => explorerConfig is ExplorerConfig & {
32
32
  type: "ledger";
33
33
  };
34
+ /**
35
+ * Type guard
36
+ */
37
+ export declare const isBlockscoutV2ExplorerConfig: (explorerConfig: ExplorerConfig) => explorerConfig is ExplorerConfig & {
38
+ type: "blockscout-v2";
39
+ };
34
40
  /**
35
41
  * Type guard
36
42
  */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/network/explorer/types.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AACjD,OAAO,KAAK,EACV,SAAS,EACT,gBAAgB,EAChB,SAAS,EACV,MAAM,2CAA2C,CAAA;AAClD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wCAAwC,CAAA;AAGpE,kFAAkF;AAClF,eAAO,MAAM,QAAQ,KAAK,CAAA;AAE1B,MAAM,MAAM,WAAW,GAAG;IACxB,aAAa,EAAE,CACb,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,WAAW,EAAE,MAAM,GAAG,SAAS,EAC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AAI,EAAE,eAAe,CAAA;CAE5D,CAAA;AAWD;;GAEG;AACH,eAAO,MAAM,6BAA6B,GACxC,gBAAgB,cAAc,KAC7B,cAAc,IAAI,cAAc,GAAG;IACpC,IAAI,EAAE,WAAW,GAAG,YAAY,GAAG,UAAU,GAAG,cAAc,GAAG,UAAU,GAAG,QAAQ,CAAA;CAIvF,CAAA"}
@@ -9,6 +9,12 @@ export const NO_TOKEN = '';
9
9
  export const isLedgerExplorerConfig = (explorerConfig) => {
10
10
  return explorerConfig?.type === 'ledger';
11
11
  };
12
+ /**
13
+ * Type guard
14
+ */
15
+ export const isBlockscoutV2ExplorerConfig = (explorerConfig) => {
16
+ return explorerConfig?.type === 'blockscout-v2';
17
+ };
12
18
  const ETHERSCAN_LIKE_EXPLORER_TYPES = new Set([
13
19
  'etherscan',
14
20
  'blockscout',
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/network/explorer/types.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,sCAAsC;AAStC,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AAEjD,kFAAkF;AAClF,MAAM,CAAC,MAAM,QAAQ,GAAG,EAAE,CAAA;AAyC1B;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,cAA8B,EACyB,EAAE;IACzD,OAAO,cAAc,EAAE,IAAI,KAAK,QAAQ,CAAA;AAC1C,CAAC,CAAA;AAED,MAAM,6BAA6B,GAAG,IAAI,GAAG,CAAS;IACpD,WAAW;IACX,YAAY;IACZ,UAAU;IACV,cAAc;IACd,UAAU;IACV,QAAQ;CACT,CAAC,CAAA;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAC3C,cAA8B,EAG9B,EAAE;IACF,MAAM,YAAY,GAAG,cAAc,EAAE,IAAI,CAAA;IACzC,OAAO,QAAQ,CAAC,YAAY,CAAC,IAAI,6BAA6B,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;AAClF,CAAC,CAAA"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/network/explorer/types.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,sCAAsC;AAStC,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AAEjD,kFAAkF;AAClF,MAAM,CAAC,MAAM,QAAQ,GAAG,EAAE,CAAA;AAyC1B;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,cAA8B,EACyB,EAAE;IACzD,OAAO,cAAc,EAAE,IAAI,KAAK,QAAQ,CAAA;AAC1C,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAC1C,cAA8B,EACgC,EAAE;IAChE,OAAO,cAAc,EAAE,IAAI,KAAK,eAAe,CAAA;AACjD,CAAC,CAAA;AAED,MAAM,6BAA6B,GAAG,IAAI,GAAG,CAAS;IACpD,WAAW;IACX,YAAY;IACZ,UAAU;IACV,cAAc;IACd,UAAU;IACV,QAAQ;CACT,CAAC,CAAA;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAC3C,cAA8B,EAG9B,EAAE;IACF,MAAM,YAAY,GAAG,cAAc,EAAE,IAAI,CAAA;IACzC,OAAO,QAAQ,CAAC,YAAY,CAAC,IAAI,6BAA6B,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;AAClF,CAAC,CAAA"}
@@ -0,0 +1,11 @@
1
+ import type { EvmConfigInfo } from '../config';
2
+ import type { MemoNotSupported, Operation } from '@ledgerhq/coin-module-framework/api/types';
3
+ import type { Logger } from '@ledgerhq/coin-module-framework/config';
4
+ /**
5
+ * Recover REWARD op amounts (claim/compound) from receipt logs — these txs send 0 native
6
+ * value, so the amount would otherwise show as 0 in history and operation details.
7
+ *
8
+ * Mutates `operations` in place.
9
+ */
10
+ export declare function enrichRewardOperations(config: EvmConfigInfo, operations: Array<Operation<MemoNotSupported>>, logger: Logger): Promise<void>;
11
+ //# sourceMappingURL=rewards.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rewards.d.ts","sourceRoot":"","sources":["../../src/network/rewards.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAC9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,2CAA2C,CAAA;AAC5F,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wCAAwC,CAAA;AAMpE;;;;;GAKG;AACH,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,aAAa,EACrB,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC,EAC9C,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CAyBf"}
@@ -0,0 +1,29 @@
1
+ // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import { RateLimitError } from '../errors';
4
+ import { enrichRewardOperationsValue } from '../staking/rewardsFromReceipt';
5
+ import { withApi } from './node/rpc.common';
6
+ import { isExternalNodeConfig } from './node/types';
7
+ /**
8
+ * Recover REWARD op amounts (claim/compound) from receipt logs — these txs send 0 native
9
+ * value, so the amount would otherwise show as 0 in history and operation details.
10
+ *
11
+ * Mutates `operations` in place.
12
+ */
13
+ export async function enrichRewardOperations(config, operations, logger) {
14
+ const node = config.node;
15
+ if (operations.some((op) => op.type === 'REWARD' && op.value === 0n) &&
16
+ isExternalNodeConfig(node)) {
17
+ try {
18
+ await withApi(config, (api) => enrichRewardOperationsValue(config.chainId, operations, (hash) => api.getTransactionReceipt(hash), logger), node);
19
+ }
20
+ catch (e) {
21
+ // Enrichment is best-effort, but a rate limit must not be downgraded into a successful
22
+ // response reporting 0-value rewards.
23
+ if (e instanceof RateLimitError)
24
+ throw e;
25
+ logger('EVM getOperations', 'reward amount enrichment failed', e);
26
+ }
27
+ }
28
+ }
29
+ //# sourceMappingURL=rewards.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rewards.js","sourceRoot":"","sources":["../../src/network/rewards.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,sCAAsC;AAKtC,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAA;AAC3E,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAC3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAEnD;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,MAAqB,EACrB,UAA8C,EAC9C,MAAc;IAEd,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAA;IACxB,IACE,UAAU,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,KAAK,QAAQ,IAAI,EAAE,CAAC,KAAK,KAAK,EAAE,CAAC;QAChE,oBAAoB,CAAC,IAAI,CAAC,EAC1B,CAAC;QACD,IAAI,CAAC;YACH,MAAM,OAAO,CACX,MAAM,EACN,CAAC,GAAG,EAAE,EAAE,CACN,2BAA2B,CACzB,MAAM,CAAC,OAAO,EACd,UAAU,EACV,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC,qBAAqB,CAAC,IAAI,CAAC,EACzC,MAAM,CACP,EACH,IAAI,CACL,CAAA;QACH,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,uFAAuF;YACvF,sCAAsC;YACtC,IAAI,CAAC,YAAY,cAAc;gBAAE,MAAM,CAAC,CAAA;YACxC,MAAM,CAAC,mBAAmB,EAAE,iCAAiC,EAAE,CAAC,CAAC,CAAA;QACnE,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,80 @@
1
+ export type BlockscoutV2Address = {
2
+ hash: string;
3
+ };
4
+ /** Item of `GET /addresses/{address}/transactions` */
5
+ export type BlockscoutV2Transaction = {
6
+ hash: string;
7
+ /** `null` while the transaction is pending */
8
+ block_number: number | null;
9
+ /** Index of the transaction in its block */
10
+ position: number | null;
11
+ timestamp: string | null;
12
+ nonce: number;
13
+ from: BlockscoutV2Address;
14
+ /** `null` for a contract creation */
15
+ to: BlockscoutV2Address | null;
16
+ created_contract: BlockscoutV2Address | null;
17
+ value: string;
18
+ /** Fee actually paid (`actual`) once mined, including the L1 data fee of rollups */
19
+ fee: {
20
+ type: 'actual' | 'maximum';
21
+ value: string;
22
+ };
23
+ gas_used: string | null;
24
+ gas_price: string | null;
25
+ gas_limit: string;
26
+ /** `null` while the transaction is pending */
27
+ status: 'ok' | 'error' | null;
28
+ raw_input: string | null;
29
+ /** Decoded method name, or the method id when it cannot be decoded */
30
+ method: string | null;
31
+ };
32
+ /** Item of `GET /addresses/{address}/token-transfers` */
33
+ export type BlockscoutV2TokenTransfer = {
34
+ transaction_hash: string;
35
+ block_hash: string;
36
+ block_number: number;
37
+ log_index: number;
38
+ timestamp: string | null;
39
+ from: BlockscoutV2Address;
40
+ to: BlockscoutV2Address;
41
+ token: {
42
+ address_hash: string;
43
+ name: string | null;
44
+ symbol: string | null;
45
+ decimals: string | null;
46
+ /** e.g. `ERC-20`, `ERC-721`, `ERC-1155` */
47
+ type: string;
48
+ };
49
+ /** Same as `token.type`. Absent before Blockscout v10 (e.g. v9.0.2 on Alpen Testnet). */
50
+ token_type?: string | undefined;
51
+ total: {
52
+ /** Amount, for ERC-20 and ERC-1155 */
53
+ value?: string | null;
54
+ /** Token id, for ERC-721 and ERC-1155 */
55
+ token_id?: string | null;
56
+ } | null;
57
+ };
58
+ /** Item of `GET /addresses/{address}/internal-transactions` */
59
+ export type BlockscoutV2InternalTransaction = {
60
+ transaction_hash: string;
61
+ block_number: number;
62
+ /** Index of the internal transaction in its transaction */
63
+ index: number;
64
+ timestamp: string | null;
65
+ from: BlockscoutV2Address;
66
+ to: BlockscoutV2Address | null;
67
+ created_contract: BlockscoutV2Address | null;
68
+ value: string;
69
+ /** Call type, e.g. `call`, `delegatecall`, `staticcall`, `create` */
70
+ type: string;
71
+ success: boolean;
72
+ error: string | null;
73
+ gas_limit: string | null;
74
+ };
75
+ /** Keyset-paginated list: `next_page_params` are the query params of the next (older) page */
76
+ export type BlockscoutV2Page<T> = {
77
+ items: T[];
78
+ next_page_params: Record<string, string | number | null> | null;
79
+ };
80
+ //# sourceMappingURL=blockscoutV2.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blockscoutV2.d.ts","sourceRoot":"","sources":["../../src/types/blockscoutV2.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,sDAAsD;AACtD,MAAM,MAAM,uBAAuB,GAAG;IACpC,IAAI,EAAE,MAAM,CAAA;IACZ,8CAA8C;IAC9C,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,4CAA4C;IAC5C,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,mBAAmB,CAAA;IACzB,qCAAqC;IACrC,EAAE,EAAE,mBAAmB,GAAG,IAAI,CAAA;IAC9B,gBAAgB,EAAE,mBAAmB,GAAG,IAAI,CAAA;IAC5C,KAAK,EAAE,MAAM,CAAA;IACb,oFAAoF;IACpF,GAAG,EAAE;QAAE,IAAI,EAAE,QAAQ,GAAG,SAAS,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAA;IAClD,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,SAAS,EAAE,MAAM,CAAA;IACjB,8CAA8C;IAC9C,MAAM,EAAE,IAAI,GAAG,OAAO,GAAG,IAAI,CAAA;IAC7B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;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AAO,CAAA;IAChB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;CACzB,CAAA;AAED,8FAA8F;AAC9F,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI;IAChC,KAAK,EAAE,CAAC,EAAE,CAAA;IACV,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC,GAAG,IAAI,CAAA;CAChE,CAAA"}
@@ -0,0 +1,4 @@
1
+ // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ export {};
4
+ //# sourceMappingURL=blockscoutV2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blockscoutV2.js","sourceRoot":"","sources":["../../src/types/blockscoutV2.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,sCAAsC"}
@@ -1,4 +1,5 @@
1
1
  export * from './assets';
2
+ export * from './blockscoutV2';
2
3
  export * from './editTransaction';
3
4
  export * from './etherscan';
4
5
  export * from './ledger';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAKA,cAAc,UAAU,CAAA;AACxB,cAAc,mBAAmB,CAAA;AACjC,cAAc,aAAa,CAAA;AAC3B,cAAc,UAAU,CAAA;AACxB,cAAc,eAAe,CAAA;AAC7B,cAAc,WAAW,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAKA,cAAc,UAAU,CAAA;AACxB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AACjC,cAAc,aAAa,CAAA;AAC3B,cAAc,UAAU,CAAA;AACxB,cAAc,eAAe,CAAA;AAC7B,cAAc,WAAW,CAAA"}
@@ -2,6 +2,7 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  /* istanbul ignore file: pure exports, bridge tested by live-common with bridge.integration.test.ts */
4
4
  export * from './assets';
5
+ export * from './blockscoutV2';
5
6
  export * from './editTransaction';
6
7
  export * from './etherscan';
7
8
  export * from './ledger';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,sCAAsC;AAEtC,sGAAsG;AAEtG,cAAc,UAAU,CAAA;AACxB,cAAc,mBAAmB,CAAA;AACjC,cAAc,aAAa,CAAA;AAC3B,cAAc,UAAU,CAAA;AACxB,cAAc,eAAe,CAAA;AAC7B,cAAc,WAAW,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,sCAAsC;AAEtC,sGAAsG;AAEtG,cAAc,UAAU,CAAA;AACxB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AACjC,cAAc,aAAa,CAAA;AAC3B,cAAc,UAAU,CAAA;AACxB,cAAc,eAAe,CAAA;AAC7B,cAAc,WAAW,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ledgerhq/coin-evm",
3
- "version": "16.2.4",
3
+ "version": "16.4.0",
4
4
  "description": "Ledger EVM Coin integration",
5
5
  "keywords": [
6
6
  "Ledger",
@@ -0,0 +1,296 @@
1
+ // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import type {
5
+ BlockscoutV2InternalTransaction,
6
+ BlockscoutV2TokenTransfer,
7
+ BlockscoutV2Transaction,
8
+ } from '../types'
9
+ import {
10
+ blockscoutV2ERC1155TransfersToOperations,
11
+ blockscoutV2ERC20TransfersToOperations,
12
+ blockscoutV2ERC721TransfersToOperations,
13
+ blockscoutV2InternalTransactionsToOperations,
14
+ blockscoutV2TransactionToOperations,
15
+ } from '../adapters'
16
+ import { CHAIN_ID } from '../config'
17
+ import { InvalidExplorerResponse } from '../errors'
18
+ import { testLogger } from '../fixtures/context.fixtures'
19
+
20
+ const address = '0x0459a84952C85c6E9345e5d22d9B110790a5e1Ba'
21
+ const other = '0x9425E212647518853a92ae7D2C1Ab09D343e70b6'
22
+ const contract = '0x5300000000000000000000000000000000000004'
23
+ const txHash = '0x43e90e6c63094c216268f02fea72f798ecbea691f208c4143d2aac322f6690ff'
24
+ const blockHash = '0x7595540cbd81adedc1137fa3cd8d64adcf18d0c2d45ee85ca7dddb89611c750c'
25
+ const date = new Date('2024-12-23T11:24:16.000Z')
26
+
27
+ const transaction: BlockscoutV2Transaction = {
28
+ hash: txHash,
29
+ block_number: 10582834,
30
+ position: 3,
31
+ timestamp: '2024-12-23T11:24:16.000000Z',
32
+ nonce: 12,
33
+ from: { hash: address.toLowerCase() },
34
+ to: { hash: other },
35
+ created_contract: null,
36
+ value: '1000',
37
+ fee: { type: 'actual', value: '6863830062607' },
38
+ gas_used: '21000',
39
+ gas_price: '40000000',
40
+ gas_limit: '21000',
41
+ status: 'ok',
42
+ raw_input: '0x',
43
+ method: null,
44
+ }
45
+
46
+ const tokenTransfer: BlockscoutV2TokenTransfer = {
47
+ transaction_hash: txHash,
48
+ block_hash: blockHash,
49
+ block_number: 10582834,
50
+ log_index: 4,
51
+ timestamp: '2024-12-23T11:24:16.000000Z',
52
+ from: { hash: other },
53
+ to: { hash: address },
54
+ token: {
55
+ address_hash: contract,
56
+ name: 'Wrapped Ether',
57
+ symbol: 'WETH',
58
+ decimals: '18',
59
+ type: 'ERC-20',
60
+ },
61
+ token_type: 'ERC-20',
62
+ total: { value: '7' },
63
+ }
64
+
65
+ const internalTransaction: BlockscoutV2InternalTransaction = {
66
+ transaction_hash: txHash,
67
+ block_number: 10582834,
68
+ index: 2,
69
+ timestamp: '2024-12-23T11:24:16.000000Z',
70
+ from: { hash: other },
71
+ to: { hash: address },
72
+ created_contract: null,
73
+ value: '9',
74
+ type: 'call',
75
+ success: true,
76
+ error: null,
77
+ gas_limit: '2300',
78
+ }
79
+
80
+ describe('blockscoutV2 adapters', () => {
81
+ describe('blockscoutV2TransactionToOperations', () => {
82
+ it('converts a native transfer, with the fee Blockscout reports', () => {
83
+ expect(
84
+ blockscoutV2TransactionToOperations(
85
+ address,
86
+ CHAIN_ID.SCROLL,
87
+ transaction,
88
+ blockHash,
89
+ testLogger
90
+ )
91
+ ).toEqual([
92
+ {
93
+ id: `${address}-${txHash}-OUT`,
94
+ type: 'OUT',
95
+ senders: [address],
96
+ recipients: [other],
97
+ value: 1000n,
98
+ asset: { type: 'native' },
99
+ tx: {
100
+ hash: txHash,
101
+ block: { height: 10582834, hash: blockHash, time: date },
102
+ fees: 6863830062607n,
103
+ date,
104
+ failed: false,
105
+ feesPayer: address,
106
+ },
107
+ details: { sequence: '12', gasPrice: '40000000', gasLimit: '21000' },
108
+ },
109
+ ])
110
+ })
111
+
112
+ it('converts a failed contract call into a FEES operation', () => {
113
+ const [operation] = blockscoutV2TransactionToOperations(
114
+ address,
115
+ CHAIN_ID.SCROLL,
116
+ { ...transaction, status: 'error', raw_input: '0xa9059cbb0000', value: '0' },
117
+ blockHash,
118
+ testLogger
119
+ )
120
+
121
+ expect(operation.type).toEqual('FEES')
122
+ expect(operation.tx.failed).toBe(true)
123
+ expect(operation.tx.fees).toEqual(6863830062607n)
124
+ })
125
+
126
+ it('reports the created contract as the recipient of a contract creation', () => {
127
+ const [operation] = blockscoutV2TransactionToOperations(
128
+ address,
129
+ CHAIN_ID.SCROLL,
130
+ { ...transaction, to: null, created_contract: { hash: contract } },
131
+ blockHash,
132
+ testLogger
133
+ )
134
+
135
+ expect(operation.recipients).toEqual([contract])
136
+ })
137
+
138
+ it.each<[string, BlockscoutV2Transaction['fee']]>([
139
+ ['empty', { type: 'actual', value: '' }],
140
+ ['non-numeric', { type: 'actual', value: '1e3' }],
141
+ ['pending', { type: 'maximum', value: '1000' }],
142
+ ])('rejects a %s fee', (_, fee) => {
143
+ expect(() =>
144
+ blockscoutV2TransactionToOperations(
145
+ address,
146
+ CHAIN_ID.SCROLL,
147
+ { ...transaction, fee },
148
+ blockHash,
149
+ testLogger
150
+ )
151
+ ).toThrow(InvalidExplorerResponse)
152
+ })
153
+
154
+ it('converts a self-send into an IN and an OUT operation', () => {
155
+ const operations = blockscoutV2TransactionToOperations(
156
+ address,
157
+ CHAIN_ID.SCROLL,
158
+ { ...transaction, to: { hash: address } },
159
+ blockHash,
160
+ testLogger
161
+ )
162
+
163
+ expect(operations.map((op) => op.type)).toEqual(['IN', 'OUT'])
164
+ })
165
+ })
166
+
167
+ describe('blockscoutV2ERC20TransfersToOperations', () => {
168
+ it('converts transfers, indexed within their transaction and without a nonce', () => {
169
+ const operations = blockscoutV2ERC20TransfersToOperations(
170
+ address,
171
+ [tokenTransfer, { ...tokenTransfer, log_index: 5, total: { value: '8' } }],
172
+ testLogger
173
+ )
174
+
175
+ expect(operations.map((op) => [op.id, op.value])).toEqual([
176
+ [`${txHash}-erc20-0-IN`, 7n],
177
+ [`${txHash}-erc20-1-IN`, 8n],
178
+ ])
179
+ expect(operations[0]).toMatchObject({
180
+ type: 'IN',
181
+ senders: [other],
182
+ recipients: [address],
183
+ asset: { type: 'erc20', assetReference: contract, assetOwner: address },
184
+ tx: { block: { height: 10582834, hash: blockHash, time: date }, fees: 0n },
185
+ })
186
+ expect(operations[0].details).not.toHaveProperty('sequence')
187
+ })
188
+ })
189
+
190
+ describe('blockscoutV2ERC721TransfersToOperations', () => {
191
+ it('converts a transfer', () => {
192
+ const [operation] = blockscoutV2ERC721TransfersToOperations(
193
+ address,
194
+ [{ ...tokenTransfer, token_type: 'ERC-721', total: { token_id: '42' } }],
195
+ testLogger
196
+ )
197
+
198
+ expect(operation).toMatchObject({
199
+ id: `${txHash}-erc721-0-NFT_IN`,
200
+ type: 'NFT_IN',
201
+ value: 1n,
202
+ asset: { type: 'erc721', assetReference: contract },
203
+ details: { tokenId: '42' },
204
+ })
205
+ })
206
+ })
207
+
208
+ describe('blockscoutV2ERC1155TransfersToOperations', () => {
209
+ it('converts a transfer', () => {
210
+ const [operation] = blockscoutV2ERC1155TransfersToOperations(
211
+ address,
212
+ [{ ...tokenTransfer, token_type: 'ERC-1155', total: { token_id: '42', value: '3' } }],
213
+ testLogger
214
+ )
215
+
216
+ expect(operation).toMatchObject({
217
+ id: `${txHash}-erc1155-0-NFT_IN`,
218
+ type: 'NFT_IN',
219
+ value: 3n,
220
+ asset: { type: 'erc1155', assetReference: contract },
221
+ details: { tokenId: '42' },
222
+ })
223
+ })
224
+ })
225
+
226
+ describe('blockscoutV2InternalTransactionsToOperations', () => {
227
+ const blockHashes = new Map([[10582834, blockHash]])
228
+
229
+ it('converts an internal transaction, with the hash of its block', () => {
230
+ expect(
231
+ blockscoutV2InternalTransactionsToOperations(
232
+ address,
233
+ [internalTransaction],
234
+ blockHashes,
235
+ testLogger
236
+ )
237
+ ).toEqual([
238
+ {
239
+ id: `${txHash}-internal-0-IN`,
240
+ type: 'IN',
241
+ senders: [other],
242
+ recipients: [address],
243
+ value: 9n,
244
+ asset: { type: 'native' },
245
+ tx: {
246
+ hash: txHash,
247
+ block: { height: 10582834, hash: blockHash, time: date },
248
+ fees: 0n,
249
+ date,
250
+ failed: false,
251
+ },
252
+ details: { internal: true },
253
+ },
254
+ ])
255
+ })
256
+
257
+ it('credits the contract an internal contract creation funds', () => {
258
+ const creation: BlockscoutV2InternalTransaction = {
259
+ ...internalTransaction,
260
+ from: { hash: other },
261
+ to: null,
262
+ created_contract: { hash: address },
263
+ type: 'create',
264
+ }
265
+
266
+ expect(
267
+ blockscoutV2InternalTransactionsToOperations(address, [creation], blockHashes, testLogger)
268
+ ).toMatchObject([{ type: 'IN', senders: [other], recipients: [address], value: 9n }])
269
+ expect(
270
+ blockscoutV2InternalTransactionsToOperations(other, [creation], blockHashes, testLogger)
271
+ ).toMatchObject([{ type: 'OUT', senders: [other], recipients: [address], value: 9n }])
272
+ })
273
+
274
+ it('drops the calls that cannot move native value', () => {
275
+ expect(
276
+ blockscoutV2InternalTransactionsToOperations(
277
+ address,
278
+ [{ ...internalTransaction, type: 'delegatecall' }],
279
+ blockHashes,
280
+ testLogger
281
+ )
282
+ ).toEqual([])
283
+ })
284
+
285
+ it('marks a failed internal transaction', () => {
286
+ const [operation] = blockscoutV2InternalTransactionsToOperations(
287
+ address,
288
+ [{ ...internalTransaction, success: false, error: 'Reverted' }],
289
+ blockHashes,
290
+ testLogger
291
+ )
292
+
293
+ expect(operation.tx.failed).toBe(true)
294
+ })
295
+ })
296
+ })