@ledgerhq/coin-evm 5.2.1 → 5.3.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 (268) hide show
  1. package/.oxlintrc.json +2 -12
  2. package/CHANGELOG.md +29 -0
  3. package/lib/adapters/blockOperations.d.ts +2 -2
  4. package/lib/adapters/blockOperations.d.ts.map +1 -1
  5. package/lib/adapters/blockOperations.js.map +1 -1
  6. package/lib/api/index.d.ts +1 -1
  7. package/lib/api/index.d.ts.map +1 -1
  8. package/lib/config.d.ts +1 -1
  9. package/lib/config.d.ts.map +1 -1
  10. package/lib/logic/combine.d.ts +2 -1
  11. package/lib/logic/combine.d.ts.map +1 -1
  12. package/lib/logic/combine.js.map +1 -1
  13. package/lib/logic/common.d.ts +2 -1
  14. package/lib/logic/common.d.ts.map +1 -1
  15. package/lib/logic/common.js.map +1 -1
  16. package/lib/logic/craftTransaction.d.ts +1 -1
  17. package/lib/logic/craftTransaction.d.ts.map +1 -1
  18. package/lib/logic/craftTransaction.js.map +1 -1
  19. package/lib/logic/craftTransactionData.d.ts +1 -1
  20. package/lib/logic/craftTransactionData.d.ts.map +1 -1
  21. package/lib/logic/estimateFees.d.ts +1 -1
  22. package/lib/logic/estimateFees.d.ts.map +1 -1
  23. package/lib/logic/estimateFees.js.map +1 -1
  24. package/lib/logic/getBalance.d.ts +1 -1
  25. package/lib/logic/getBalance.d.ts.map +1 -1
  26. package/lib/logic/getBalance.js +19 -13
  27. package/lib/logic/getBalance.js.map +1 -1
  28. package/lib/logic/getBlock.d.ts +1 -1
  29. package/lib/logic/getBlock.d.ts.map +1 -1
  30. package/lib/logic/getBlock.js.map +1 -1
  31. package/lib/logic/getStakes.d.ts +2 -2
  32. package/lib/logic/getStakes.d.ts.map +1 -1
  33. package/lib/logic/getStakes.js +6 -3
  34. package/lib/logic/getStakes.js.map +1 -1
  35. package/lib/logic/internalTransactionsFetcher.d.ts +1 -1
  36. package/lib/logic/internalTransactionsFetcher.d.ts.map +1 -1
  37. package/lib/logic/internalTransactionsFetcher.js.map +1 -1
  38. package/lib/logic/listOperations.d.ts.map +1 -1
  39. package/lib/logic/listOperations.js +3 -0
  40. package/lib/logic/listOperations.js.map +1 -1
  41. package/lib/logic/validateIntent.d.ts +1 -1
  42. package/lib/logic/validateIntent.d.ts.map +1 -1
  43. package/lib/logic/validateIntent.js.map +1 -1
  44. package/lib/logic.d.ts +1 -1
  45. package/lib/logic.d.ts.map +1 -1
  46. package/lib/network/explorer/etherscan.d.ts +4 -4
  47. package/lib/network/explorer/etherscan.d.ts.map +1 -1
  48. package/lib/network/explorer/etherscan.js +8 -4
  49. package/lib/network/explorer/etherscan.js.map +1 -1
  50. package/lib/network/explorer/index.d.ts +2 -2
  51. package/lib/network/explorer/index.d.ts.map +1 -1
  52. package/lib/network/explorer/index.js.map +1 -1
  53. package/lib/network/explorer/ledger.d.ts +2 -2
  54. package/lib/network/explorer/ledger.d.ts.map +1 -1
  55. package/lib/network/explorer/ledger.js.map +1 -1
  56. package/lib/network/explorer/none.d.ts +1 -1
  57. package/lib/network/explorer/none.d.ts.map +1 -1
  58. package/lib/network/explorer/none.js.map +1 -1
  59. package/lib/network/explorer/types.d.ts +1 -1
  60. package/lib/network/explorer/types.d.ts.map +1 -1
  61. package/lib/network/gasTracker/index.d.ts +2 -2
  62. package/lib/network/gasTracker/index.d.ts.map +1 -1
  63. package/lib/network/gasTracker/index.js.map +1 -1
  64. package/lib/network/gasTracker/ledger.d.ts +3 -3
  65. package/lib/network/gasTracker/ledger.d.ts.map +1 -1
  66. package/lib/network/gasTracker/ledger.js.map +1 -1
  67. package/lib/network/gasTracker/types.d.ts +2 -2
  68. package/lib/network/gasTracker/types.d.ts.map +1 -1
  69. package/lib/network/node/ledger.d.ts +2 -2
  70. package/lib/network/node/ledger.d.ts.map +1 -1
  71. package/lib/network/node/ledger.js.map +1 -1
  72. package/lib/network/node/rpc.common.d.ts +1 -1
  73. package/lib/network/node/rpc.common.d.ts.map +1 -1
  74. package/lib/network/node/rpc.common.js.map +1 -1
  75. package/lib/network/node/types.d.ts +3 -3
  76. package/lib/network/node/types.d.ts.map +1 -1
  77. package/lib/staking/fetchers.d.ts.map +1 -1
  78. package/lib/staking/fetchers.js +1 -0
  79. package/lib/staking/fetchers.js.map +1 -1
  80. package/lib/staking/validators/monad.d.ts +5 -4
  81. package/lib/staking/validators/monad.d.ts.map +1 -1
  82. package/lib/staking/validators/monad.js +42 -3
  83. package/lib/staking/validators/monad.js.map +1 -1
  84. package/lib/staking/validators/monadResolver.d.ts +2 -1
  85. package/lib/staking/validators/monadResolver.d.ts.map +1 -1
  86. package/lib/staking/validators/monadResolver.js.map +1 -1
  87. package/lib/staking/validators/somnia.d.ts.map +1 -1
  88. package/lib/staking/validators/somnia.js.map +1 -1
  89. package/lib/staking/validators/zero_gravity.d.ts.map +1 -1
  90. package/lib/staking/validators/zero_gravity.js.map +1 -1
  91. package/lib/types/assets.d.ts +1 -1
  92. package/lib/types/assets.d.ts.map +1 -1
  93. package/lib/types/staking.d.ts +3 -2
  94. package/lib/types/staking.d.ts.map +1 -1
  95. package/lib/types/transaction.d.ts +1 -1
  96. package/lib/types/transaction.d.ts.map +1 -1
  97. package/lib-es/adapters/blockOperations.d.ts +2 -2
  98. package/lib-es/adapters/blockOperations.d.ts.map +1 -1
  99. package/lib-es/adapters/blockOperations.js.map +1 -1
  100. package/lib-es/api/index.d.ts +1 -1
  101. package/lib-es/api/index.d.ts.map +1 -1
  102. package/lib-es/config.d.ts +1 -1
  103. package/lib-es/config.d.ts.map +1 -1
  104. package/lib-es/logic/combine.d.ts +2 -1
  105. package/lib-es/logic/combine.d.ts.map +1 -1
  106. package/lib-es/logic/combine.js.map +1 -1
  107. package/lib-es/logic/common.d.ts +2 -1
  108. package/lib-es/logic/common.d.ts.map +1 -1
  109. package/lib-es/logic/common.js +1 -1
  110. package/lib-es/logic/common.js.map +1 -1
  111. package/lib-es/logic/craftTransaction.d.ts +1 -1
  112. package/lib-es/logic/craftTransaction.d.ts.map +1 -1
  113. package/lib-es/logic/craftTransaction.js.map +1 -1
  114. package/lib-es/logic/craftTransactionData.d.ts +1 -1
  115. package/lib-es/logic/craftTransactionData.d.ts.map +1 -1
  116. package/lib-es/logic/estimateFees.d.ts +1 -1
  117. package/lib-es/logic/estimateFees.d.ts.map +1 -1
  118. package/lib-es/logic/estimateFees.js.map +1 -1
  119. package/lib-es/logic/getBalance.d.ts +1 -1
  120. package/lib-es/logic/getBalance.d.ts.map +1 -1
  121. package/lib-es/logic/getBalance.js +19 -13
  122. package/lib-es/logic/getBalance.js.map +1 -1
  123. package/lib-es/logic/getBlock.d.ts +1 -1
  124. package/lib-es/logic/getBlock.d.ts.map +1 -1
  125. package/lib-es/logic/getBlock.js.map +1 -1
  126. package/lib-es/logic/getStakes.d.ts +2 -2
  127. package/lib-es/logic/getStakes.d.ts.map +1 -1
  128. package/lib-es/logic/getStakes.js +6 -3
  129. package/lib-es/logic/getStakes.js.map +1 -1
  130. package/lib-es/logic/internalTransactionsFetcher.d.ts +1 -1
  131. package/lib-es/logic/internalTransactionsFetcher.d.ts.map +1 -1
  132. package/lib-es/logic/internalTransactionsFetcher.js.map +1 -1
  133. package/lib-es/logic/listOperations.d.ts.map +1 -1
  134. package/lib-es/logic/listOperations.js +3 -0
  135. package/lib-es/logic/listOperations.js.map +1 -1
  136. package/lib-es/logic/validateIntent.d.ts +1 -1
  137. package/lib-es/logic/validateIntent.d.ts.map +1 -1
  138. package/lib-es/logic/validateIntent.js.map +1 -1
  139. package/lib-es/logic.d.ts +1 -1
  140. package/lib-es/logic.d.ts.map +1 -1
  141. package/lib-es/network/explorer/etherscan.d.ts +4 -4
  142. package/lib-es/network/explorer/etherscan.d.ts.map +1 -1
  143. package/lib-es/network/explorer/etherscan.js +8 -4
  144. package/lib-es/network/explorer/etherscan.js.map +1 -1
  145. package/lib-es/network/explorer/index.d.ts +2 -2
  146. package/lib-es/network/explorer/index.d.ts.map +1 -1
  147. package/lib-es/network/explorer/index.js.map +1 -1
  148. package/lib-es/network/explorer/ledger.d.ts +2 -2
  149. package/lib-es/network/explorer/ledger.d.ts.map +1 -1
  150. package/lib-es/network/explorer/ledger.js.map +1 -1
  151. package/lib-es/network/explorer/none.d.ts +1 -1
  152. package/lib-es/network/explorer/none.d.ts.map +1 -1
  153. package/lib-es/network/explorer/none.js.map +1 -1
  154. package/lib-es/network/explorer/types.d.ts +1 -1
  155. package/lib-es/network/explorer/types.d.ts.map +1 -1
  156. package/lib-es/network/gasTracker/index.d.ts +2 -2
  157. package/lib-es/network/gasTracker/index.d.ts.map +1 -1
  158. package/lib-es/network/gasTracker/index.js.map +1 -1
  159. package/lib-es/network/gasTracker/ledger.d.ts +3 -3
  160. package/lib-es/network/gasTracker/ledger.d.ts.map +1 -1
  161. package/lib-es/network/gasTracker/ledger.js +1 -1
  162. package/lib-es/network/gasTracker/ledger.js.map +1 -1
  163. package/lib-es/network/gasTracker/types.d.ts +2 -2
  164. package/lib-es/network/gasTracker/types.d.ts.map +1 -1
  165. package/lib-es/network/node/ledger.d.ts +2 -2
  166. package/lib-es/network/node/ledger.d.ts.map +1 -1
  167. package/lib-es/network/node/ledger.js.map +1 -1
  168. package/lib-es/network/node/rpc.common.d.ts +1 -1
  169. package/lib-es/network/node/rpc.common.d.ts.map +1 -1
  170. package/lib-es/network/node/rpc.common.js +1 -1
  171. package/lib-es/network/node/rpc.common.js.map +1 -1
  172. package/lib-es/network/node/types.d.ts +3 -3
  173. package/lib-es/network/node/types.d.ts.map +1 -1
  174. package/lib-es/staking/fetchers.d.ts.map +1 -1
  175. package/lib-es/staking/fetchers.js +2 -1
  176. package/lib-es/staking/fetchers.js.map +1 -1
  177. package/lib-es/staking/validators/monad.d.ts +5 -4
  178. package/lib-es/staking/validators/monad.d.ts.map +1 -1
  179. package/lib-es/staking/validators/monad.js +40 -2
  180. package/lib-es/staking/validators/monad.js.map +1 -1
  181. package/lib-es/staking/validators/monadResolver.d.ts +2 -1
  182. package/lib-es/staking/validators/monadResolver.d.ts.map +1 -1
  183. package/lib-es/staking/validators/monadResolver.js.map +1 -1
  184. package/lib-es/staking/validators/somnia.d.ts.map +1 -1
  185. package/lib-es/staking/validators/somnia.js.map +1 -1
  186. package/lib-es/staking/validators/zero_gravity.d.ts.map +1 -1
  187. package/lib-es/staking/validators/zero_gravity.js.map +1 -1
  188. package/lib-es/types/assets.d.ts +1 -1
  189. package/lib-es/types/assets.d.ts.map +1 -1
  190. package/lib-es/types/staking.d.ts +3 -2
  191. package/lib-es/types/staking.d.ts.map +1 -1
  192. package/lib-es/types/transaction.d.ts +1 -1
  193. package/lib-es/types/transaction.d.ts.map +1 -1
  194. package/package.json +2 -2
  195. package/src/adapters/blockOperations.test.ts +2 -2
  196. package/src/adapters/blockOperations.ts +3 -2
  197. package/src/adapters/etherscan.test.ts +7 -7
  198. package/src/adapters/ledger.test.ts +2 -2
  199. package/src/api/getBlock.integ.test.ts +1 -1
  200. package/src/api/index.fantom.integ.test.ts +1 -1
  201. package/src/api/index.flare.integ.test.ts +1 -1
  202. package/src/api/index.integ.test.ts +265 -153
  203. package/src/api/index.linea.integ.test.ts +1 -1
  204. package/src/api/index.optimism.integ.test.ts +1 -1
  205. package/src/api/index.shape.integ.test.ts +1 -1
  206. package/src/api/index.ts +1 -1
  207. package/src/config.ts +1 -1
  208. package/src/fixtures/ledger.fixtures.ts +1 -1
  209. package/src/internalTxSources.test.ts +3 -6
  210. package/src/logic/combine.test.ts +2 -2
  211. package/src/logic/combine.ts +2 -1
  212. package/src/logic/common.test.ts +3 -3
  213. package/src/logic/common.ts +2 -7
  214. package/src/logic/craftTransaction.test.ts +4 -3
  215. package/src/logic/craftTransaction.ts +3 -2
  216. package/src/logic/craftTransactionData.test.ts +1 -1
  217. package/src/logic/craftTransactionData.ts +1 -1
  218. package/src/logic/estimateFees.ts +6 -3
  219. package/src/logic/getBalance.test.ts +1 -1
  220. package/src/logic/getBalance.ts +30 -24
  221. package/src/logic/getBlock.test.ts +8 -7
  222. package/src/logic/getBlock.ts +3 -2
  223. package/src/logic/getBlockInfo.test.ts +1 -3
  224. package/src/logic/getStakes.test.ts +2 -2
  225. package/src/logic/getStakes.ts +15 -6
  226. package/src/logic/internalTransactionsFetcher.test.ts +4 -6
  227. package/src/logic/internalTransactionsFetcher.ts +1 -1
  228. package/src/logic/lastBlock.test.ts +2 -1
  229. package/src/logic/listOperations.test.ts +75 -2
  230. package/src/logic/listOperations.ts +3 -0
  231. package/src/logic/validateIntent.test.ts +2 -1
  232. package/src/logic/validateIntent.ts +4 -2
  233. package/src/logic.ts +1 -1
  234. package/src/network/explorer/etherscan.test.ts +36 -1
  235. package/src/network/explorer/etherscan.ts +20 -14
  236. package/src/network/explorer/index.test.ts +1 -1
  237. package/src/network/explorer/index.ts +2 -2
  238. package/src/network/explorer/ledger.test.ts +2 -1
  239. package/src/network/explorer/ledger.ts +3 -2
  240. package/src/network/explorer/none.ts +2 -1
  241. package/src/network/explorer/types.ts +1 -1
  242. package/src/network/gasTracker/index.test.ts +1 -1
  243. package/src/network/gasTracker/index.ts +2 -2
  244. package/src/network/gasTracker/ledger.test.ts +10 -17
  245. package/src/network/gasTracker/ledger.ts +5 -7
  246. package/src/network/gasTracker/types.ts +2 -2
  247. package/src/network/node/index.memoization.test.ts +1 -1
  248. package/src/network/node/ledger.ts +6 -5
  249. package/src/network/node/rpc.common.ts +14 -14
  250. package/src/network/node/rpc.test.ts +4 -10
  251. package/src/network/node/types.ts +3 -3
  252. package/src/staking/detectOperationType.test.ts +1 -1
  253. package/src/staking/encoder.test.ts +1 -1
  254. package/src/staking/fetchers.ts +2 -1
  255. package/src/staking/operations/index.test.ts +1 -1
  256. package/src/staking/redelegations.test.ts +23 -15
  257. package/src/staking/rewards.test.ts +6 -2
  258. package/src/staking/rewardsFromReceipt.test.ts +1 -1
  259. package/src/staking/transactionData.test.ts +2 -2
  260. package/src/staking/validators/monad.test.ts +102 -1
  261. package/src/staking/validators/monad.ts +58 -5
  262. package/src/staking/validators/monadResolver.ts +2 -1
  263. package/src/staking/validators/somnia.ts +2 -1
  264. package/src/staking/validators/zero_gravity.ts +2 -1
  265. package/src/staking/validators.test.ts +7 -2
  266. package/src/types/assets.ts +1 -1
  267. package/src/types/staking.ts +4 -2
  268. package/src/types/transaction.ts +1 -1
@@ -6,7 +6,7 @@ import network from '@ledgerhq/live-network'
6
6
  import { ethers } from 'ethers'
7
7
  import monadAbi from '../../abis/monad.abi.json'
8
8
  import { withApi } from '../../network/node/rpc.common'
9
- import { fetchMonadStakes } from './monad'
9
+ import { fetchMonadStakes, extractMonadKnownValIds } from './monad'
10
10
  import { getValidatorAddressById } from './monadResolver'
11
11
  import { clearValidatorsCache, getValidators } from './index'
12
12
 
@@ -813,5 +813,106 @@ describe('staking/validators/monad', () => {
813
813
  expect(stakes).toHaveLength(1)
814
814
  expect(callNames(callMock).filter((name) => name === 'getDelegations')).toHaveLength(1)
815
815
  })
816
+
817
+ it('surfaces withdrawal slots for a fully-undelegated validator via knownValIds', async () => {
818
+ setupRpc(
819
+ routeByName({
820
+ getDelegations: () => monadIface.encodeFunctionResult('getDelegations', [true, 0, [1n]]),
821
+ getDelegator: (valId) =>
822
+ valId === 1n
823
+ ? encodeDelegator(100n)
824
+ : monadIface.encodeFunctionResult('getDelegator', [0n, 0n, 0n, 0n, 0n, 0n, 0n]),
825
+ getValidator: () => encodeGetValidator({ stake: 0n, commission: 0n, secpPubkey: SECP }),
826
+ getEpoch: () => monadIface.encodeFunctionResult('getEpoch', [5n, false]),
827
+ getWithdrawalRequest: (valId, withdrawId) => {
828
+ if (valId === 92n && withdrawId === 0)
829
+ return monadIface.encodeFunctionResult('getWithdrawalRequest', [500n, 0n, 10n])
830
+ return monadIface.encodeFunctionResult('getWithdrawalRequest', [0n, 0n, 0n])
831
+ },
832
+ })
833
+ )
834
+
835
+ const stakes = await fetchMonadStakes(mockConfig, DELEGATOR, {} as never, 'monad', ['92'])
836
+
837
+ const withdrawal = stakes.find((s) => s.details?.validatorId === '92')
838
+ expect(withdrawal).toMatchObject({
839
+ state: 'deactivating',
840
+ amount: 500n,
841
+ details: { validatorId: '92', withdrawId: 0 },
842
+ })
843
+ })
844
+
845
+ it('deduplicates a valId that appears in both getDelegations and knownValIds', async () => {
846
+ let delegatorCallCount = 0
847
+ setupRpc(
848
+ routeByName({
849
+ getDelegations: () => monadIface.encodeFunctionResult('getDelegations', [true, 0, [7n]]),
850
+ getDelegator: (valId) => {
851
+ if (valId === 7n) delegatorCallCount++
852
+ return encodeDelegator(100n)
853
+ },
854
+ getValidator: () => encodeGetValidator({ stake: 0n, commission: 0n, secpPubkey: SECP }),
855
+ })
856
+ )
857
+
858
+ const stakes = await fetchMonadStakes(mockConfig, DELEGATOR, {} as never, 'monad', ['7'])
859
+
860
+ expect(stakes).toHaveLength(1)
861
+ expect(delegatorCallCount).toBe(1)
862
+ })
863
+ })
864
+
865
+ describe('extractMonadKnownValIds', () => {
866
+ const makeOp = (type: string, contractPayload?: string) =>
867
+ ({
868
+ type,
869
+ ...(contractPayload !== undefined ? { details: { contractPayload } } : {}),
870
+ }) as unknown as Parameters<typeof extractMonadKnownValIds>[1][number]
871
+
872
+ it('extracts a validator id from a DELEGATE op', () => {
873
+ const payload = monadIface.encodeFunctionData('delegate', [42n])
874
+ expect(extractMonadKnownValIds('monad', [makeOp('DELEGATE', payload)])).toStrictEqual(['42'])
875
+ })
876
+
877
+ it('extracts a validator id from an UNDELEGATE op', () => {
878
+ const payload = monadIface.encodeFunctionData('undelegate', [92n, 10_000_000_000n, 0n])
879
+ expect(extractMonadKnownValIds('monad', [makeOp('UNDELEGATE', payload)])).toStrictEqual([
880
+ '92',
881
+ ])
882
+ })
883
+
884
+ it('extracts a validator id from a WITHDRAW_UNBONDED op', () => {
885
+ const payload = monadIface.encodeFunctionData('withdraw', [7n, 3n])
886
+ expect(
887
+ extractMonadKnownValIds('monad', [makeOp('WITHDRAW_UNBONDED', payload)])
888
+ ).toStrictEqual(['7'])
889
+ })
890
+
891
+ it('deduplicates repeated validator ids across multiple ops', () => {
892
+ const p1 = monadIface.encodeFunctionData('undelegate', [92n, 5_000_000_000n, 0n])
893
+ const p2 = monadIface.encodeFunctionData('undelegate', [92n, 5_000_000_000n, 1n])
894
+ const result = extractMonadKnownValIds('monad', [
895
+ makeOp('UNDELEGATE', p1),
896
+ makeOp('UNDELEGATE', p2),
897
+ ])
898
+ expect(result).toStrictEqual(['92'])
899
+ })
900
+
901
+ it('ignores ops whose type is not a staking function', () => {
902
+ const result = extractMonadKnownValIds('monad', [makeOp('OUT'), makeOp('IN')])
903
+ expect(result).toStrictEqual([])
904
+ })
905
+
906
+ it('skips ops with no contractPayload without throwing', () => {
907
+ const result = extractMonadKnownValIds('monad', [makeOp('UNDELEGATE')])
908
+ expect(result).toStrictEqual([])
909
+ })
910
+
911
+ it('returns an empty array for an unknown currencyId (no ABI available)', () => {
912
+ const payload = monadIface.encodeFunctionData('undelegate', [7n, 1n, 0n])
913
+ expect(
914
+ extractMonadKnownValIds('unknown_coin', [makeOp('UNDELEGATE', payload)])
915
+ ).toStrictEqual([])
916
+ })
816
917
  })
817
918
  })
@@ -5,12 +5,19 @@ import type { EvmConfigInfo } from '../../config'
5
5
  import type { StakingContractConfig } from '../../types/staking'
6
6
  import type { ValidatorApi } from './types'
7
7
  import type { Cursor, Page } from '@ledgerhq/coin-module-framework/api/index'
8
- import type { AssetInfo, Stake, StakeState } from '@ledgerhq/coin-module-framework/api/types'
9
- import type { Validator } from '@ledgerhq/coin-module-framework/api/types'
8
+ import type {
9
+ AssetInfo,
10
+ MemoNotSupported,
11
+ Operation,
12
+ Stake,
13
+ StakeState,
14
+ Validator,
15
+ } from '@ledgerhq/coin-module-framework/api/types'
16
+ import type { JsonRpcProvider } from 'ethers'
10
17
  import network from '@ledgerhq/live-network'
11
18
  import { makeLRUCache } from '@ledgerhq/live-network/cache'
12
19
  import { log } from '@ledgerhq/logs'
13
- import { ethers, type JsonRpcProvider } from 'ethers'
20
+ import { ethers } from 'ethers'
14
21
  import { evmUnit } from '../../logic/evmUnit'
15
22
  import { withApi } from '../../network/node/rpc.common'
16
23
  import { isExternalNodeConfig } from '../../network/node/types'
@@ -369,11 +376,47 @@ const fetchStakeForValId = async (
369
376
  return stakes
370
377
  }
371
378
 
379
+ export const extractMonadKnownValIds = (
380
+ currencyId: string,
381
+ ops: Array<Operation<MemoNotSupported>>
382
+ ): string[] => {
383
+ const fnNames: Record<string, string> = {
384
+ DELEGATE: 'delegate',
385
+ UNDELEGATE: 'undelegate',
386
+ WITHDRAW_UNBONDED: 'withdraw',
387
+ }
388
+
389
+ const abi = getStakingABI(currencyId)
390
+ if (!abi) return []
391
+
392
+ const iface = new ethers.Interface(abi as ethers.InterfaceAbi)
393
+ const valIds = new Set<string>()
394
+
395
+ for (const op of ops) {
396
+ const fnName = fnNames[op.type]
397
+ if (!fnName) continue
398
+ const payload = op.details?.contractPayload
399
+ if (!payload || typeof payload !== 'string') continue
400
+ try {
401
+ const d = iface.decodeFunctionData(fnName, payload)
402
+ if (typeof d[0] === 'bigint') valIds.add(d[0].toString())
403
+ } catch (err) {
404
+ log('coin-evm/staking', 'extractMonadKnownValIds: failed to decode payload', {
405
+ type: op.type,
406
+ error: err instanceof Error ? err.message : String(err),
407
+ })
408
+ }
409
+ }
410
+
411
+ return [...valIds]
412
+ }
413
+
372
414
  export const fetchMonadStakes = async (
373
415
  evmConfig: EvmConfigInfo,
374
416
  address: string,
375
417
  _config: StakingContractConfig,
376
- currencyId: string
418
+ currencyId: string,
419
+ knownValIds?: string[]
377
420
  ): Promise<Stake[]> => {
378
421
  const ctx = resolveContext(evmConfig, currencyId)
379
422
  if (!ctx) return []
@@ -384,7 +427,17 @@ export const fetchMonadStakes = async (
384
427
  currencyId,
385
428
  async (provider) => {
386
429
  const iface = new ethers.Interface(ctx.abi)
387
- const valIds = await fetchDelegatedValIds(provider, iface, ctx.contractAddress, address)
430
+ const fromDelegations = await fetchDelegatedValIds(
431
+ provider,
432
+ iface,
433
+ ctx.contractAddress,
434
+ address
435
+ )
436
+ const valIdSet = new Set(fromDelegations)
437
+ for (const id of knownValIds ?? []) {
438
+ if (/^\d+$/.test(id)) valIdSet.add(BigInt(id))
439
+ }
440
+ const valIds = [...valIdSet]
388
441
  if (valIds.length === 0) return []
389
442
 
390
443
  const currentEpoch = await callGetEpoch(provider, iface, ctx.contractAddress)
@@ -2,8 +2,9 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  import type { EvmConfigInfo } from '../../config'
5
+ import type { JsonRpcProvider } from 'ethers'
5
6
  import { log } from '@ledgerhq/logs'
6
- import { ethers, type JsonRpcProvider } from 'ethers'
7
+ import { ethers } from 'ethers'
7
8
  import { withApi } from '../../network/node/rpc.common'
8
9
  import { isExternalNodeConfig } from '../../network/node/types'
9
10
  import { getStakingABI } from '../abis'
@@ -6,10 +6,11 @@ import type { StakingContractConfig } from '../../types/staking'
6
6
  import type { ValidatorApi } from './types'
7
7
  import type { Page } from '@ledgerhq/coin-module-framework/api/index'
8
8
  import type { AssetInfo, Stake, Validator } from '@ledgerhq/coin-module-framework/api/types'
9
+ import type { JsonRpcProvider } from 'ethers'
9
10
  import network from '@ledgerhq/live-network'
10
11
  import { makeLRUCache } from '@ledgerhq/live-network/cache'
11
12
  import { log } from '@ledgerhq/logs'
12
- import { ethers, type JsonRpcProvider } from 'ethers'
13
+ import { ethers } from 'ethers'
13
14
  import { evmUnit } from '../../logic/evmUnit'
14
15
  import { withApi } from '../../network/node/rpc.common'
15
16
  import { isExternalNodeConfig } from '../../network/node/types'
@@ -6,9 +6,10 @@ import type { StakingContractConfig } from '../../types/staking'
6
6
  import type { ValidatorApi } from './types'
7
7
  import type { Page } from '@ledgerhq/coin-module-framework/api/index'
8
8
  import type { AssetInfo, Stake, Validator } from '@ledgerhq/coin-module-framework/api/types'
9
+ import type { JsonRpcProvider } from 'ethers'
9
10
  import network from '@ledgerhq/live-network'
10
11
  import { log } from '@ledgerhq/logs'
11
- import { ethers, type JsonRpcProvider } from 'ethers'
12
+ import { ethers } from 'ethers'
12
13
  import { evmUnit } from '../../logic/evmUnit'
13
14
  import { withApi } from '../../network/node/rpc.common'
14
15
  import { isExternalNodeConfig } from '../../network/node/types'
@@ -1,6 +1,7 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
+ import type { EvmConfigInfo } from '../config'
4
5
  import network from '@ledgerhq/live-network'
5
6
  import {
6
7
  clearValidatorsCache,
@@ -22,9 +23,13 @@ jest.mock('@ledgerhq/live-network', () => ({
22
23
 
23
24
  const mockedNetwork = jest.mocked(network)
24
25
 
25
- const mockConfig = {
26
+ const mockConfig: EvmConfigInfo = {
27
+ status: { type: 'active' },
28
+ chainId: 1,
29
+ name: 'Test EVM',
26
30
  node: { type: 'external', uri: 'https://sei-evm.coin.ledger.com' },
27
- } as unknown as import('../config').EvmConfigInfo
31
+ explorer: { type: 'none' },
32
+ }
28
33
 
29
34
  const cosmosValidatorsPayload = {
30
35
  status: 200,
@@ -1,7 +1,7 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import { AssetInfo } from '@ledgerhq/coin-module-framework/api/types'
4
+ import type { AssetInfo } from '@ledgerhq/coin-module-framework/api/types'
5
5
 
6
6
  export function isNative(asset: AssetInfo): asset is { type: 'native' } {
7
7
  return asset.type === 'native'
@@ -2,7 +2,7 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  import type { EvmConfigInfo } from '../config'
5
- import type { Stake } from '@ledgerhq/coin-module-framework/api/types'
5
+ import type { MemoNotSupported, Operation, Stake } from '@ledgerhq/coin-module-framework/api/types'
6
6
  import type BigNumber from 'bignumber.js'
7
7
 
8
8
  export type EvmStakingOperationType =
@@ -223,7 +223,8 @@ export type StakingFetcher = (
223
223
  evmConfig: EvmConfigInfo,
224
224
  address: string,
225
225
  config: StakingContractConfig,
226
- currencyId: string
226
+ currencyId: string,
227
+ knownValIds?: string[]
227
228
  ) => Promise<Stake[]>
228
229
 
229
230
  /**
@@ -231,6 +232,7 @@ export type StakingFetcher = (
231
232
  */
232
233
  export type StakingStrategy = {
233
234
  fetcher: StakingFetcher
235
+ extractKnownValIds?: (currencyId: string, ops: Array<Operation<MemoNotSupported>>) => string[]
234
236
  }
235
237
 
236
238
  /**
@@ -1,7 +1,7 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import BigNumber from 'bignumber.js'
4
+ import type BigNumber from 'bignumber.js'
5
5
 
6
6
  export type FeeHistory = {
7
7
  baseFeePerGas: string[]