@ledgerhq/coin-evm 5.3.2 → 5.3.4

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 (48) hide show
  1. package/.oxlintrc.json +2 -2
  2. package/CHANGELOG.md +13 -0
  3. package/package.json +2 -2
  4. package/src/adapters/blockOperations.test.ts +27 -29
  5. package/src/api/index.flare.integ.test.ts +1 -13
  6. package/src/api/index.integ.test.ts +86 -97
  7. package/src/fixtures/context.fixtures.ts +79 -1
  8. package/src/fixtures/ethers.fixtures.ts +26 -0
  9. package/src/logic/broadcast.integ.test.ts +6 -18
  10. package/src/logic/broadcast.test.ts +19 -31
  11. package/src/logic/broadcastSource.test.ts +6 -7
  12. package/src/logic/common.test.ts +120 -112
  13. package/src/logic/craftTransaction.test.ts +161 -199
  14. package/src/logic/craftTransactionData.test.ts +6 -6
  15. package/src/logic/estimateFees.test.ts +19 -15
  16. package/src/logic/getBalance.test.ts +15 -14
  17. package/src/logic/getBlock.test.ts +372 -382
  18. package/src/logic/getBlockInfo.test.ts +6 -6
  19. package/src/logic/getNextSequence.test.ts +5 -5
  20. package/src/logic/getStakes.test.ts +34 -34
  21. package/src/logic/internalTransactionsFetcher.test.ts +23 -19
  22. package/src/logic/lastBlock.test.ts +29 -21
  23. package/src/logic/listOperations.test.ts +43 -40
  24. package/src/logic/validateIntent.test.ts +151 -101
  25. package/src/logic.test.ts +59 -79
  26. package/src/network/explorer/etherscan.test.ts +95 -136
  27. package/src/network/explorer/index.test.ts +51 -21
  28. package/src/network/explorer/ledger.test.ts +51 -44
  29. package/src/network/gasTracker/index.test.ts +14 -8
  30. package/src/network/gasTracker/ledger.test.ts +43 -61
  31. package/src/network/node/index.memoization.test.ts +25 -31
  32. package/src/network/node/index.test.ts +14 -25
  33. package/src/network/node/ledger.test.ts +45 -60
  34. package/src/network/node/node.fixtures.ts +0 -2
  35. package/src/network/node/rpc.test.ts +204 -219
  36. package/src/staking/encoder.test.ts +13 -21
  37. package/src/staking/logic.test.ts +20 -14
  38. package/src/staking/operations/index.test.ts +28 -28
  39. package/src/staking/prepareIntents.test.ts +26 -20
  40. package/src/staking/redelegations.test.ts +27 -18
  41. package/src/staking/rewards.test.ts +23 -15
  42. package/src/staking/rewardsFromReceipt.test.ts +19 -20
  43. package/src/staking/transactionData.test.ts +22 -22
  44. package/src/staking/validators/monad.test.ts +65 -24
  45. package/src/staking/validators/somnia.test.ts +21 -13
  46. package/src/staking/validators/zero_gravity.test.ts +118 -48
  47. package/src/staking/validators.integ.test.ts +13 -25
  48. package/src/api/index.fantom.integ.test.ts +0 -103
@@ -85,22 +85,21 @@ describe('sumRewardFromReceiptLogs', () => {
85
85
  })
86
86
 
87
87
  describe('enrichRewardOperationsValue', () => {
88
- const rewardOp = (hash: string, sender: string): Operation<MemoNotSupported> =>
89
- ({
90
- id: `${sender}-${hash}-REWARD`,
91
- type: 'REWARD',
92
- value: 0n,
93
- senders: [sender],
94
- recipients: [MONAD_STAKING],
95
- asset: { type: 'native' as const },
96
- tx: {
97
- hash,
98
- block: { height: 0, hash: '0x', time: new Date() },
99
- fees: 0n,
100
- date: new Date(),
101
- failed: false,
102
- },
103
- }) as Operation<MemoNotSupported>
88
+ const rewardOp = (hash: string, sender: string): Operation<MemoNotSupported> => ({
89
+ id: `${sender}-${hash}-REWARD`,
90
+ type: 'REWARD',
91
+ value: 0n,
92
+ senders: [sender],
93
+ recipients: [MONAD_STAKING],
94
+ asset: { type: 'native' as const },
95
+ tx: {
96
+ hash,
97
+ block: { height: 0, hash: '0x', time: new Date() },
98
+ fees: 0n,
99
+ date: new Date(),
100
+ failed: false,
101
+ },
102
+ })
104
103
 
105
104
  it('patches the REWARD op value from the receipt logs', async () => {
106
105
  const op = rewardOp('0xabc', MONAD_DELEGATOR)
@@ -125,14 +124,14 @@ describe('enrichRewardOperationsValue', () => {
125
124
  })
126
125
 
127
126
  it('only fetches receipts for zero-value REWARD ops', async () => {
128
- const out = {
127
+ const out: Operation<MemoNotSupported> = {
129
128
  ...rewardOp('0xout', MONAD_DELEGATOR),
130
129
  type: 'OUT',
131
- } as Operation<MemoNotSupported>
132
- const nonZero = {
130
+ }
131
+ const nonZero: Operation<MemoNotSupported> = {
133
132
  ...rewardOp('0xnz', MONAD_DELEGATOR),
134
133
  value: 5n,
135
- } as Operation<MemoNotSupported>
134
+ }
136
135
  const getReceipt = jest.fn().mockResolvedValue(null)
137
136
 
138
137
  await enrichRewardOperationsValue('monad', [out, nonZero], getReceipt)
@@ -2,26 +2,26 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  import type { MemoNotSupported } from '@ledgerhq/coin-module-framework/api/index'
5
- import type { TransactionIntent, BufferTxData } from '@ledgerhq/coin-module-framework/api/types'
5
+ import type { BufferTxData } from '@ledgerhq/coin-module-framework/api/types'
6
+ import { createStakingTransactionIntentMockData } from '@ledgerhq/coin-module-framework/test-utils'
6
7
  import { ethers } from 'ethers'
7
8
  import { getStakingABI } from './abis'
8
9
  import { STAKING_CONTRACTS } from './contracts'
9
10
  import { buildStakingTransactionParams } from './transactionData'
10
11
 
11
- const delegateIntent = (
12
- fields: Partial<Record<string, unknown>>
13
- ): TransactionIntent<MemoNotSupported, BufferTxData> =>
14
- ({
15
- intentType: 'staking',
16
- type: 'staking-legacy',
17
- mode: 'delegate',
18
- amount: 1000000000000000000n,
19
- asset: { type: 'native' },
20
- recipient: '0xRecipient',
21
- sender: '0xSender',
22
- data: { type: 'buffer', value: Buffer.from([]) },
23
- ...fields,
24
- }) as unknown as TransactionIntent<MemoNotSupported, BufferTxData>
12
+ const delegateIntent = (fields: Record<string, unknown>) =>
13
+ Object.assign(
14
+ createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
15
+ type: 'staking-legacy',
16
+ mode: 'delegate',
17
+ amount: 1000000000000000000n,
18
+ asset: { type: 'native' },
19
+ recipient: '0xRecipient',
20
+ sender: '0xSender',
21
+ data: { type: 'buffer', value: Buffer.from([]) },
22
+ }),
23
+ fields
24
+ )
25
25
 
26
26
  describe('buildStakingTransactionParams', () => {
27
27
  it('encodes a Monad delegate by valId with the amount carried as msg.value', () => {
@@ -32,7 +32,7 @@ describe('buildStakingTransactionParams', () => {
32
32
 
33
33
  const { to, data, value } = buildStakingTransactionParams('monad', intent)
34
34
 
35
- const iface = new ethers.Interface(getStakingABI('monad') as ethers.InterfaceAbi)
35
+ const iface = new ethers.Interface(getStakingABI('monad') ?? [])
36
36
  expect('0x' + data.toString('hex')).toEqual(iface.encodeFunctionData('delegate', [42n]))
37
37
  expect(to).toEqual('0x0000000000000000000000000000000000001000')
38
38
  expect(value).toEqual(1000000000000000000n)
@@ -48,7 +48,7 @@ describe('buildStakingTransactionParams', () => {
48
48
 
49
49
  const { to, data, value } = buildStakingTransactionParams('monad', intent)
50
50
 
51
- const iface = new ethers.Interface(getStakingABI('monad') as ethers.InterfaceAbi)
51
+ const iface = new ethers.Interface(getStakingABI('monad') ?? [])
52
52
  expect('0x' + data.toString('hex')).toEqual(iface.encodeFunctionData('compound', [42n]))
53
53
  expect(to).toEqual('0x0000000000000000000000000000000000001000')
54
54
  expect(value).toEqual(0n)
@@ -70,7 +70,7 @@ describe('buildStakingTransactionParams', () => {
70
70
 
71
71
  const { to, data, value } = buildStakingTransactionParams('monad', intent)
72
72
 
73
- const iface = new ethers.Interface(getStakingABI('monad') as ethers.InterfaceAbi)
73
+ const iface = new ethers.Interface(getStakingABI('monad') ?? [])
74
74
  expect('0x' + data.toString('hex')).toEqual(iface.encodeFunctionData('withdraw', [42n, 7n]))
75
75
  expect(to).toEqual('0x0000000000000000000000000000000000001000')
76
76
  expect(value).toEqual(0n)
@@ -88,7 +88,7 @@ describe('buildStakingTransactionParams', () => {
88
88
 
89
89
  const { to, data, value } = buildStakingTransactionParams('sei_evm', intent)
90
90
 
91
- const iface = new ethers.Interface(getStakingABI('sei_evm') as ethers.InterfaceAbi)
91
+ const iface = new ethers.Interface(getStakingABI('sei_evm') ?? [])
92
92
  expect('0x' + data.toString('hex')).toEqual(iface.encodeFunctionData('delegate', [valAddress]))
93
93
  expect(to).toEqual('0x0000000000000000000000000000000000001005')
94
94
  expect(value).toEqual(1000000000000000000n)
@@ -124,7 +124,7 @@ describe('0G / zero_gravity delegate', () => {
124
124
 
125
125
  const { to, data, value } = buildStakingTransactionParams('zero_gravity', intent)
126
126
 
127
- const iface = new ethers.Interface(getStakingABI('zero_gravity') as ethers.InterfaceAbi)
127
+ const iface = new ethers.Interface(getStakingABI('zero_gravity') ?? [])
128
128
  expect('0x' + data.toString('hex')).toEqual(
129
129
  iface.encodeFunctionData('delegate', ['0x0000000000000000000000000000000000000002'])
130
130
  )
@@ -134,7 +134,7 @@ describe('0G / zero_gravity delegate', () => {
134
134
 
135
135
  it('throws when valAddress is missing', () => {
136
136
  expect(() => {
137
- buildStakingTransactionParams('zero_gravity', delegateIntent({}))
137
+ buildStakingTransactionParams('zero_gravity', delegateIntent({ valAddress: '' }))
138
138
  }).toThrow('0G staking requires a validator address')
139
139
  })
140
140
 
@@ -164,7 +164,7 @@ describe('0G / zero_gravity undelegate', () => {
164
164
 
165
165
  const { to, data, value } = buildStakingTransactionParams('zero_gravity', intent)
166
166
 
167
- const iface = new ethers.Interface(getStakingABI('zero_gravity') as ethers.InterfaceAbi)
167
+ const iface = new ethers.Interface(getStakingABI('zero_gravity') ?? [])
168
168
  expect('0x' + data.toString('hex')).toEqual(
169
169
  iface.encodeFunctionData('undelegate', [DELEGATOR, 1_500_000_000n])
170
170
  )
@@ -2,9 +2,17 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  import type { EvmConfigInfo } from '../../config'
5
+ import type { StakingContractConfig } from '../../types/staking'
6
+ import type { AddressLike } from 'ethers'
5
7
  import network from '@ledgerhq/live-network'
6
8
  import { ethers } from 'ethers'
7
9
  import monadAbi from '../../abis/monad.abi.json'
10
+ import {
11
+ createMockEvmConfigInfo,
12
+ mkExternalNode,
13
+ mkLedgerNode,
14
+ } from '../../fixtures/context.fixtures'
15
+ import { mkJsonRpcProvider } from '../../fixtures/ethers.fixtures'
8
16
  import { withApi } from '../../network/node/rpc.common'
9
17
  import { fetchMonadStakes, extractMonadKnownValIds } from './monad'
10
18
  import { getValidatorAddressById } from './monadResolver'
@@ -22,11 +30,12 @@ jest.mock('@ledgerhq/live-network', () => ({
22
30
  const mockedWithApi = jest.mocked(withApi)
23
31
  const mockedNetwork = jest.mocked(network)
24
32
 
25
- const mockConfig = {
33
+ const mockConfig = createMockEvmConfigInfo({
34
+ chainId: 10143,
26
35
  name: 'Monad',
27
- node: { type: 'external', uri: 'https://monad.rpc/' },
28
- } as unknown as EvmConfigInfo
29
- const ledgerConfig = { node: { type: 'ledger' } } as unknown as EvmConfigInfo
36
+ node: mkExternalNode({ uri: 'https://monad.rpc/' }),
37
+ })
38
+ const ledgerConfig = createMockEvmConfigInfo({ chainId: 10143, node: mkLedgerNode() })
30
39
 
31
40
  const monadIface = new ethers.Interface(monadAbi)
32
41
  const PRECOMPILE = '0x0000000000000000000000000000000000001000'
@@ -54,13 +63,18 @@ const encodeGetValidator = (params: {
54
63
  '0x',
55
64
  ])
56
65
 
57
- type CallHandler = (request: { to?: string; data?: string }) => Promise<string>
66
+ type CallHandler = (request: {
67
+ to?: AddressLike | null
68
+ data?: string | Uint8Array | null
69
+ }) => Promise<string>
58
70
 
59
71
  const setupRpc = (handler: CallHandler) => {
60
72
  const callMock = jest.fn(handler)
61
- mockedWithApi.mockImplementation(async (_config, _currencyId, fn) =>
62
- fn({ call: callMock } as unknown as Parameters<typeof fn>[0])
63
- )
73
+ mockedWithApi.mockImplementation(async (_config, _currencyId, fn) => {
74
+ const api = mkJsonRpcProvider()
75
+ jest.spyOn(api, 'call').mockImplementation(callMock)
76
+ return fn(api)
77
+ })
64
78
  return callMock
65
79
  }
66
80
 
@@ -81,36 +95,36 @@ const routeByName = (responses: {
81
95
  const desc = monadIface.parseTransaction({ data })
82
96
  if (!desc) throw new Error('could not parse calldata')
83
97
  if (desc.name === 'getExecutionValidatorSet') {
84
- const startIndex = desc.args[0] as bigint
98
+ const startIndex: bigint = desc.args[0]
85
99
  const out = responses.getExecutionValidatorSet?.(startIndex)
86
100
  if (out instanceof Error) throw out
87
101
  if (!out) throw new Error(`no response for getExecutionValidatorSet(${startIndex})`)
88
102
  return out
89
103
  }
90
104
  if (desc.name === 'getValidator') {
91
- const valId = desc.args[0] as bigint
105
+ const valId: bigint = desc.args[0]
92
106
  const out = responses.getValidator?.(valId)
93
107
  if (out instanceof Error) throw out
94
108
  if (!out) throw new Error(`no response for getValidator(${valId})`)
95
109
  return out
96
110
  }
97
111
  if (desc.name === 'getDelegations') {
98
- const startValId = desc.args[1] as bigint
112
+ const startValId: bigint = desc.args[1]
99
113
  const out = responses.getDelegations?.(startValId)
100
114
  if (out instanceof Error) throw out
101
115
  if (!out) throw new Error(`no response for getDelegations(${startValId})`)
102
116
  return out
103
117
  }
104
118
  if (desc.name === 'getDelegator') {
105
- const valId = desc.args[0] as bigint
119
+ const valId: bigint = desc.args[0]
106
120
  const out = responses.getDelegator?.(valId)
107
121
  if (out instanceof Error) throw out
108
122
  if (!out) throw new Error(`no response for getDelegator(${valId})`)
109
123
  return out
110
124
  }
111
125
  if (desc.name === 'getWithdrawalRequest') {
112
- const valId = desc.args[0] as bigint
113
- const withdrawId = Number(desc.args[2] as bigint)
126
+ const valId: bigint = desc.args[0]
127
+ const withdrawId = Number(desc.args[2])
114
128
  // Default unhandled slots to "free" (all-zero) so tests that don't care about
115
129
  // withdrawals aren't forced to stub all 256 slots.
116
130
  const out =
@@ -204,7 +218,8 @@ describe('staking/validators/monad', () => {
204
218
  // Repo filename is the lowercase secp hex without the `0x` prefix.
205
219
  mockedNetwork.mockResolvedValueOnce({
206
220
  data: { name: 'GalaxyDigital' },
207
- } as any)
221
+ status: 200,
222
+ })
208
223
 
209
224
  const page = await getValidators(mockConfig, 'monad')
210
225
 
@@ -441,9 +456,16 @@ describe('staking/validators/monad', () => {
441
456
  describe('fetchMonadStakes', () => {
442
457
  const DELEGATOR = '0x00000000000000000000000000000000000000aa'
443
458
  const SECP = '0x036e44a092493800e427b2b08d3427d804348b1368ecd0a6af6510ae40ce507187'
459
+ const dummyStakingConfig: StakingContractConfig = {
460
+ contractAddress: () => '',
461
+ value: () => 0n,
462
+ functions: { delegate: '', undelegate: '', getStakedBalance: '' },
463
+ resolveValidatorAddress: async () => null,
464
+ resolveOperationAmount: async () => null,
465
+ }
444
466
 
445
467
  const fetchStakes = (config: EvmConfigInfo = mockConfig) =>
446
- fetchMonadStakes(config, DELEGATOR, {} as never, 'monad')
468
+ fetchMonadStakes(config, DELEGATOR, dummyStakingConfig, 'monad')
447
469
 
448
470
  const encodeDelegator = (
449
471
  stake: bigint,
@@ -516,7 +538,8 @@ describe('staking/validators/monad', () => {
516
538
  )
517
539
  mockedNetwork.mockResolvedValueOnce({
518
540
  data: { name: 'GalaxyDigital' },
519
- } as any)
541
+ status: 200,
542
+ })
520
543
 
521
544
  const stakes = await fetchStakes()
522
545
 
@@ -832,7 +855,9 @@ describe('staking/validators/monad', () => {
832
855
  })
833
856
  )
834
857
 
835
- const stakes = await fetchMonadStakes(mockConfig, DELEGATOR, {} as never, 'monad', ['92'])
858
+ const stakes = await fetchMonadStakes(mockConfig, DELEGATOR, dummyStakingConfig, 'monad', [
859
+ '92',
860
+ ])
836
861
 
837
862
  const withdrawal = stakes.find((s) => s.details?.validatorId === '92')
838
863
  expect(withdrawal).toMatchObject({
@@ -855,7 +880,9 @@ describe('staking/validators/monad', () => {
855
880
  })
856
881
  )
857
882
 
858
- const stakes = await fetchMonadStakes(mockConfig, DELEGATOR, {} as never, 'monad', ['7'])
883
+ const stakes = await fetchMonadStakes(mockConfig, DELEGATOR, dummyStakingConfig, 'monad', [
884
+ '7',
885
+ ])
859
886
 
860
887
  expect(stakes).toHaveLength(1)
861
888
  expect(delegatorCallCount).toBe(1)
@@ -863,11 +890,25 @@ describe('staking/validators/monad', () => {
863
890
  })
864
891
 
865
892
  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]
893
+ const makeOp = (
894
+ type: string,
895
+ contractPayload?: string
896
+ ): Parameters<typeof extractMonadKnownValIds>[1][number] => ({
897
+ id: '',
898
+ type,
899
+ senders: [],
900
+ recipients: [],
901
+ value: 0n,
902
+ asset: { type: 'native' },
903
+ ...(contractPayload !== undefined ? { details: { contractPayload } } : {}),
904
+ tx: {
905
+ hash: '',
906
+ block: { height: 0, hash: '', time: new Date(0) },
907
+ fees: 0n,
908
+ date: new Date(0),
909
+ failed: false,
910
+ },
911
+ })
871
912
 
872
913
  it('extracts a validator id from a DELEGATE op', () => {
873
914
  const payload = monadIface.encodeFunctionData('delegate', [42n])
@@ -2,10 +2,18 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  import type { EvmConfigInfo } from '../../config'
5
+ import type { DeepPartialReturn } from '@ledgerhq/coin-module-framework/test/utils'
6
+ import type { TransactionRequest } from 'ethers'
5
7
  import network from '@ledgerhq/live-network'
6
8
  import { ethers } from 'ethers'
7
9
  import somniaAbi from '../../abis/somnia.abi.json'
10
+ import {
11
+ createMockEvmConfigInfo,
12
+ mkExternalNode,
13
+ mkLedgerNode,
14
+ } from '../../fixtures/context.fixtures'
8
15
  import { withApi } from '../../network/node/rpc.common'
16
+ import { STAKING_CONTRACTS } from '../contracts'
9
17
  import { clearValidatorNamesCache, fetchSomniaStakes, fetchValidatorNames } from './somnia'
10
18
  import { clearValidatorsCache, getValidators } from './index'
11
19
 
@@ -13,13 +21,14 @@ jest.mock('../../network/node/rpc.common', () => ({ __esModule: true, withApi: j
13
21
  jest.mock('@ledgerhq/live-network', () => ({ __esModule: true, default: jest.fn() }))
14
22
 
15
23
  const mockedWithApi = jest.mocked(withApi)
16
- const mockedNetwork = jest.mocked(network)
24
+ const mockedNetwork = jest.mocked<DeepPartialReturn<typeof network>>(network)
17
25
 
18
- const mockConfig = {
26
+ const mockConfig = createMockEvmConfigInfo({
27
+ chainId: 5031,
28
+ node: mkExternalNode({ uri: 'https://somnia-rpc.publicnode.com' }),
19
29
  name: 'Somnia',
20
- node: { type: 'external', uri: 'https://somnia-rpc.publicnode.com' },
21
- } as unknown as EvmConfigInfo
22
- const ledgerConfig = { node: { type: 'ledger' } } as unknown as EvmConfigInfo
30
+ })
31
+ const ledgerConfig = createMockEvmConfigInfo({ chainId: 5031, node: mkLedgerNode() })
23
32
 
24
33
  const somniaIface = new ethers.Interface(somniaAbi)
25
34
  const CONTRACT = '0xBe367d410D96E1cAeF68C0632251072CDf1b8250'
@@ -27,12 +36,12 @@ const VALIDATOR_A = ethers.getAddress('0x' + 'aa'.repeat(20))
27
36
  const VALIDATOR_B = ethers.getAddress('0x' + 'bb'.repeat(20))
28
37
  const DELEGATOR = ethers.getAddress('0x' + 'cc'.repeat(20))
29
38
 
30
- type CallHandler = (request: { to?: string; data?: string }) => Promise<string>
39
+ type CallHandler = (request: TransactionRequest) => Promise<string>
31
40
 
32
41
  const setupRpc = (handler: CallHandler) => {
33
42
  const callMock = jest.fn(handler)
34
43
  mockedWithApi.mockImplementation(async (_config, _currencyId, fn) =>
35
- fn({ call: callMock } as unknown as Parameters<typeof fn>[0])
44
+ fn(Object.assign(Object.create(null), { call: callMock }))
36
45
  )
37
46
  return callMock
38
47
  }
@@ -83,7 +92,7 @@ const routeByName = (responses: {
83
92
  return out
84
93
  }
85
94
  if (desc.name === 'getStake') {
86
- const address = desc.args[0] as string
95
+ const address = desc.args[0]
87
96
  const out = responses.getStake?.(address)
88
97
  if (out instanceof Error) throw out
89
98
  if (!out) throw new Error(`no response for getStake(${address})`)
@@ -96,7 +105,7 @@ const routeByName = (responses: {
96
105
  return out
97
106
  }
98
107
  if (desc.name === 'getDelegationInfo') {
99
- const validator = desc.args[1] as string
108
+ const validator = desc.args[1]
100
109
  const out = responses.getDelegationInfo?.(validator)
101
110
  if (out instanceof Error) throw out
102
111
  if (!out) throw new Error(`no response for getDelegationInfo(${validator})`)
@@ -197,8 +206,7 @@ describe('staking/validators/somnia', () => {
197
206
  })
198
207
 
199
208
  describe('fetchValidatorNames', () => {
200
- const mockNamesResponse = (data: unknown) =>
201
- mockedNetwork.mockResolvedValue({ data } as unknown as Awaited<ReturnType<typeof network>>)
209
+ const mockNamesResponse = (data: unknown) => mockedNetwork.mockResolvedValue({ data })
202
210
 
203
211
  it('returns a lowercased address -> name map from a valid flat map', async () => {
204
212
  mockNamesResponse({
@@ -277,7 +285,7 @@ describe('staking/validators/somnia', () => {
277
285
 
278
286
  describe('fetchSomniaStakes', () => {
279
287
  const fetchStakes = (config: EvmConfigInfo = mockConfig) =>
280
- fetchSomniaStakes(config, DELEGATOR, {} as never, 'somnia')
288
+ fetchSomniaStakes(config, DELEGATOR, STAKING_CONTRACTS['somnia'], 'somnia')
281
289
 
282
290
  const defaultStakeHandlers = (
283
291
  overrides: {
@@ -351,7 +359,7 @@ describe('staking/validators/somnia', () => {
351
359
  it('attaches the validator name from the names overlay to details.validatorName', async () => {
352
360
  mockedNetwork.mockResolvedValue({
353
361
  data: { [VALIDATOR_A.toLowerCase()]: 'Everstake' },
354
- } as unknown as Awaited<ReturnType<typeof network>>)
362
+ })
355
363
  setupRpc(defaultStakeHandlers())
356
364
 
357
365
  const stakes = await fetchStakes()