• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

safe-global / safe-client-gateway / 11340871916

15 Oct 2024 06:58AM UTC coverage: 46.83% (-45.0%) from 91.836%
11340871916

push

github

web-flow
Bump typescript from 5.6.2 to 5.6.3 (#2015)

Bumps [typescript](https://github.com/microsoft/TypeScript) from 5.6.2 to 5.6.3.
- [Release notes](https://github.com/microsoft/TypeScript/releases)
- [Changelog](https://github.com/microsoft/TypeScript/blob/main/azure-pipelines.release.yml)
- [Commits](https://github.com/microsoft/TypeScript/compare/v5.6.2...v5.6.3)

---
updated-dependencies:
- dependency-name: typescript
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

500 of 3096 branches covered (16.15%)

Branch coverage included in aggregate %.

5092 of 8845 relevant lines covered (57.57%)

12.16 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

54.96
/src/datasources/cache/cache.router.ts
1
import crypto from 'crypto';
16✔
2
import { CacheDir } from '@/datasources/cache/entities/cache-dir.entity';
16✔
3

4
export class CacheRouter {
16✔
5
  private static readonly ACCOUNT_DATA_SETTINGS_KEY = 'account_data_settings';
16✔
6
  private static readonly ACCOUNT_DATA_TYPES_KEY = 'account_data_types';
16✔
7
  private static readonly ACCOUNT_KEY = 'account';
16✔
8
  private static readonly ALL_TRANSACTIONS_KEY = 'all_transactions';
16✔
9
  private static readonly AUTH_NONCE_KEY = 'auth_nonce';
16✔
10
  private static readonly BACKBONE_KEY = 'backbone';
16✔
11
  private static readonly CHAIN_KEY = 'chain';
16✔
12
  private static readonly CHAINS_KEY = 'chains';
16✔
13
  private static readonly CONTRACT_KEY = 'contract';
16✔
14
  private static readonly COUNTERFACTUAL_SAFE_KEY = 'counterfactual_safe';
16✔
15
  private static readonly COUNTERFACTUAL_SAFES_KEY = 'counterfactual_safes';
16✔
16
  private static readonly CREATION_TRANSACTION_KEY = 'creation_transaction';
16✔
17
  private static readonly DELEGATES_KEY = 'delegates';
16✔
18
  private static readonly FIREBASE_OAUTH2_TOKEN_KEY = 'firebase_oauth2_token';
16✔
19
  private static readonly INCOMING_TRANSFERS_KEY = 'incoming_transfers';
16✔
20
  private static readonly INDEXING_KEY = 'indexing';
16✔
21
  private static readonly MESSAGE_KEY = 'message';
16✔
22
  private static readonly MESSAGES_KEY = 'messages';
16✔
23
  private static readonly MODULE_TRANSACTION_KEY = 'module_transaction';
16✔
24
  private static readonly MODULE_TRANSACTIONS_KEY = 'module_transactions';
16✔
25
  private static readonly MULTISIG_TRANSACTION_KEY = 'multisig_transaction';
16✔
26
  private static readonly MULTISIG_TRANSACTIONS_KEY = 'multisig_transactions';
16✔
27
  private static readonly NATIVE_COIN_PRICE_KEY = 'native_coin_price';
16✔
28
  private static readonly OWNERS_SAFE_KEY = 'owner_safes';
16✔
29
  private static readonly RATE_LIMIT_KEY = 'rate_limit';
16✔
30
  private static readonly RELAY_KEY = 'relay';
16✔
31
  private static readonly RPC_REQUESTS_KEY = 'rpc_requests';
16✔
32
  private static readonly SAFE_APPS_KEY = 'safe_apps';
16✔
33
  private static readonly SAFE_BALANCES_KEY = 'safe_balances';
16✔
34
  private static readonly SAFE_COLLECTIBLES_KEY = 'safe_collectibles';
16✔
35
  private static readonly SAFE_EXISTS_KEY = 'safe_exists';
16✔
36
  private static readonly SAFE_FIAT_CODES_KEY = 'safe_fiat_codes';
16✔
37
  private static readonly SAFE_KEY = 'safe';
16✔
38
  private static readonly SINGLETONS_KEY = 'singletons';
16✔
39
  private static readonly STAKING_DEDICATED_STAKING_STATS_KEY =
16✔
40
    'staking_dedicated_staking_stats';
41
  private static readonly STAKING_DEFI_VAULT_STATS_KEY =
16✔
42
    'staking_defi_vault_stats';
43
  private static readonly STAKING_DEPLOYMENTS_KEY = 'staking_deployments';
16✔
44
  private static readonly STAKING_NETWORK_STATS_KEY = 'staking_network_stats';
16✔
45
  private static readonly STAKING_POOLED_STAKING_STATS_KEY =
16✔
46
    'staking_pooled_staking_stats';
47
  private static readonly STAKING_STAKES_KEY = 'staking_stakes';
16✔
48
  private static readonly STAKING_TRANSACTION_STATUS_KEY =
16✔
49
    'staking_transaction_status';
50
  private static readonly TARGETED_MESSAGING_SUBMISSION_KEY =
16✔
51
    'targeted_messaging_submission';
52
  private static readonly TARGETED_MESSAGING_TARGETED_SAFE_KEY =
16✔
53
    'targeted_messaging_targeted_safe';
54
  private static readonly TOKEN_KEY = 'token';
16✔
55
  private static readonly TOKEN_PRICE_KEY = 'token_price';
16✔
56
  private static readonly TOKENS_KEY = 'tokens';
16✔
57
  private static readonly TRANSFER_KEY = 'transfer';
16✔
58
  private static readonly TRANSFERS_KEY = 'transfers';
16✔
59
  private static readonly UNSUPPORTED_CHAIN_EVENT = 'unsupported_chain_event';
16✔
60
  private static readonly ZERION_BALANCES_KEY = 'zerion_balances';
16✔
61
  private static readonly ZERION_COLLECTIBLES_KEY = 'zerion_collectibles';
16✔
62

63
  static getAuthNonceCacheKey(nonce: string): string {
64
    return `${CacheRouter.AUTH_NONCE_KEY}_${nonce}`;
×
65
  }
66

67
  static getAuthNonceCacheDir(nonce: string): CacheDir {
68
    return new CacheDir(CacheRouter.getAuthNonceCacheKey(nonce), '');
×
69
  }
70

71
  static getBalancesCacheKey(args: {
72
    chainId: string;
73
    safeAddress: `0x${string}`;
74
  }): string {
75
    return `${args.chainId}_${CacheRouter.SAFE_BALANCES_KEY}_${args.safeAddress}`;
28✔
76
  }
77

78
  static getBalancesCacheDir(args: {
79
    chainId: string;
80
    safeAddress: `0x${string}`;
81
    trusted?: boolean;
82
    excludeSpam?: boolean;
83
  }): CacheDir {
84
    return new CacheDir(
×
85
      CacheRouter.getBalancesCacheKey(args),
86
      `${args.trusted}_${args.excludeSpam}`,
87
    );
88
  }
89

90
  static getZerionBalancesCacheKey(args: {
91
    chainId: string;
92
    safeAddress: `0x${string}`;
93
  }): string {
94
    return `${args.chainId}_${CacheRouter.ZERION_BALANCES_KEY}_${args.safeAddress}`;
×
95
  }
96

97
  static getZerionBalancesCacheDir(args: {
98
    chainId: string;
99
    safeAddress: `0x${string}`;
100
    fiatCode: string;
101
  }): CacheDir {
102
    return new CacheDir(
×
103
      CacheRouter.getZerionBalancesCacheKey(args),
104
      args.fiatCode,
105
    );
106
  }
107

108
  static getZerionCollectiblesCacheKey(args: {
109
    chainId: string;
110
    safeAddress: `0x${string}`;
111
  }): string {
112
    return `${args.chainId}_${CacheRouter.ZERION_COLLECTIBLES_KEY}_${args.safeAddress}`;
×
113
  }
114

115
  static getZerionCollectiblesCacheDir(args: {
116
    chainId: string;
117
    safeAddress: `0x${string}`;
118
    limit?: number;
119
    offset?: number;
120
  }): CacheDir {
121
    return new CacheDir(
×
122
      CacheRouter.getZerionCollectiblesCacheKey(args),
123
      `${args.limit}_${args.offset}`,
124
    );
125
  }
126

127
  static getRateLimitCacheKey(prefix: string): string {
128
    return `${prefix}_${CacheRouter.RATE_LIMIT_KEY}`;
×
129
  }
130

131
  static getSafeCacheDir(args: {
132
    chainId: string;
133
    safeAddress: `0x${string}`;
134
  }): CacheDir {
135
    return new CacheDir(CacheRouter.getSafeCacheKey(args), '');
×
136
  }
137

138
  static getSafeCacheKey(args: {
139
    chainId: string;
140
    safeAddress: `0x${string}`;
141
  }): string {
142
    return `${args.chainId}_${CacheRouter.SAFE_KEY}_${args.safeAddress}`;
18✔
143
  }
144

145
  static getIsSafeCacheDir(args: {
146
    chainId: string;
147
    safeAddress: `0x${string}`;
148
  }): CacheDir {
149
    return new CacheDir(CacheRouter.getIsSafeCacheKey(args), '');
×
150
  }
151

152
  static getIsSafeCacheKey(args: {
153
    chainId: string;
154
    safeAddress: `0x${string}`;
155
  }): string {
156
    return `${args.chainId}_${CacheRouter.SAFE_EXISTS_KEY}_${args.safeAddress}`;
×
157
  }
158

159
  static getContractCacheDir(args: {
160
    chainId: string;
161
    contractAddress: `0x${string}`;
162
  }): CacheDir {
163
    return new CacheDir(
2✔
164
      `${args.chainId}_${CacheRouter.CONTRACT_KEY}_${args.contractAddress}`,
165
      '',
166
    );
167
  }
168

169
  static getBackboneCacheDir(chainId: string): CacheDir {
170
    return new CacheDir(`${chainId}_${CacheRouter.BACKBONE_KEY}`, '');
×
171
  }
172

173
  static getSingletonsCacheDir(chainId: string): CacheDir {
174
    return new CacheDir(`${chainId}_${CacheRouter.SINGLETONS_KEY}`, '');
×
175
  }
176

177
  static getCollectiblesCacheDir(args: {
178
    chainId: string;
179
    safeAddress: `0x${string}`;
180
    limit?: number;
181
    offset?: number;
182
    trusted?: boolean;
183
    excludeSpam?: boolean;
184
  }): CacheDir {
185
    return new CacheDir(
×
186
      CacheRouter.getCollectiblesKey(args),
187
      `${args.limit}_${args.offset}_${args.trusted}_${args.excludeSpam}`,
188
    );
189
  }
190

191
  static getCollectiblesKey(args: {
192
    chainId: string;
193
    safeAddress: `0x${string}`;
194
  }): string {
195
    return `${args.chainId}_${CacheRouter.SAFE_COLLECTIBLES_KEY}_${args.safeAddress}`;
30✔
196
  }
197

198
  static getDelegatesCacheDir(args: {
199
    chainId: string;
200
    safeAddress?: `0x${string}`;
201
    delegate?: `0x${string}`;
202
    delegator?: `0x${string}`;
203
    label?: string;
204
    limit?: number;
205
    offset?: number;
206
  }): CacheDir {
207
    return new CacheDir(
×
208
      `${args.chainId}_${CacheRouter.DELEGATES_KEY}_${args.safeAddress}`,
209
      `${args.delegate}_${args.delegator}_${args.label}_${args.limit}_${args.offset}`,
210
    );
211
  }
212

213
  static getFirebaseOAuth2TokenCacheDir(): CacheDir {
214
    return new CacheDir(CacheRouter.FIREBASE_OAUTH2_TOKEN_KEY, '');
×
215
  }
216

217
  static getTransferCacheDir(args: {
218
    chainId: string;
219
    transferId: string;
220
  }): CacheDir {
221
    return new CacheDir(
×
222
      `${args.chainId}_${CacheRouter.TRANSFER_KEY}_${args.transferId}`,
223
      '',
224
    );
225
  }
226

227
  static getTransfersCacheDir(args: {
228
    chainId: string;
229
    safeAddress: string;
230
    onlyErc20: boolean;
231
    onlyErc721: boolean;
232
    limit?: number;
233
    offset?: number;
234
  }): CacheDir {
235
    return new CacheDir(
×
236
      CacheRouter.getTransfersCacheKey(args),
237
      `${args.onlyErc20}_${args.onlyErc721}_${args.limit}_${args.offset}`,
238
    );
239
  }
240

241
  static getTransfersCacheKey(args: {
242
    chainId: string;
243
    safeAddress: string;
244
  }): string {
245
    return `${args.chainId}_${CacheRouter.TRANSFERS_KEY}_${args.safeAddress}`;
40✔
246
  }
247

248
  static getModuleTransactionCacheDir(args: {
249
    chainId: string;
250
    moduleTransactionId: string;
251
  }): CacheDir {
252
    return new CacheDir(
×
253
      `${args.chainId}_${CacheRouter.MODULE_TRANSACTION_KEY}_${args.moduleTransactionId}`,
254
      '',
255
    );
256
  }
257

258
  static getModuleTransactionsCacheDir(args: {
259
    chainId: string;
260
    safeAddress: `0x${string}`;
261
    to?: string;
262
    txHash?: string;
263
    module?: string;
264
    limit?: number;
265
    offset?: number;
266
  }): CacheDir {
267
    return new CacheDir(
×
268
      CacheRouter.getModuleTransactionsCacheKey(args),
269
      `${args.to}_${args.module}_${args.txHash}_${args.limit}_${args.offset}`,
270
    );
271
  }
272

273
  static getModuleTransactionsCacheKey(args: {
274
    chainId: string;
275
    safeAddress: `0x${string}`;
276
  }): string {
277
    return `${args.chainId}_${CacheRouter.MODULE_TRANSACTIONS_KEY}_${args.safeAddress}`;
6✔
278
  }
279

280
  static getIncomingTransfersCacheDir(args: {
281
    chainId: string;
282
    safeAddress: string;
283
    executionDateGte?: string;
284
    executionDateLte?: string;
285
    to?: string;
286
    value?: string;
287
    tokenAddress?: string;
288
    txHash?: string;
289
    limit?: number;
290
    offset?: number;
291
  }): CacheDir {
292
    return new CacheDir(
×
293
      CacheRouter.getIncomingTransfersCacheKey(args),
294
      `${args.executionDateGte}_${args.executionDateLte}_${args.to}_${args.value}_${args.tokenAddress}_${args.txHash}_${args.limit}_${args.offset}`,
295
    );
296
  }
297

298
  static getIncomingTransfersCacheKey(args: {
299
    chainId: string;
300
    safeAddress: string;
301
  }): string {
302
    return `${args.chainId}_${CacheRouter.INCOMING_TRANSFERS_KEY}_${args.safeAddress}`;
16✔
303
  }
304

305
  static getIndexingCacheDir(chainId: string): CacheDir {
306
    return new CacheDir(`${chainId}_${CacheRouter.INDEXING_KEY}`, '');
×
307
  }
308

309
  static getMultisigTransactionsCacheDir(args: {
310
    chainId: string;
311
    safeAddress: string;
312
    ordering?: string;
313
    executed?: boolean;
314
    trusted?: boolean;
315
    executionDateGte?: string;
316
    executionDateLte?: string;
317
    to?: string;
318
    value?: string;
319
    nonce?: string;
320
    nonceGte?: number;
321
    limit?: number;
322
    offset?: number;
323
  }): CacheDir {
324
    return new CacheDir(
×
325
      CacheRouter.getMultisigTransactionsCacheKey(args),
326
      `${args.ordering}_${args.executed}_${args.trusted}_${args.executionDateGte}_${args.executionDateLte}_${args.to}_${args.value}_${args.nonce}_${args.nonceGte}_${args.limit}_${args.offset}`,
327
    );
328
  }
329

330
  static getMultisigTransactionsCacheKey(args: {
331
    chainId: string;
332
    safeAddress: string;
333
  }): string {
334
    return `${args.chainId}_${CacheRouter.MULTISIG_TRANSACTIONS_KEY}_${args.safeAddress}`;
52✔
335
  }
336

337
  static getMultisigTransactionCacheDir(args: {
338
    chainId: string;
339
    safeTransactionHash: string;
340
  }): CacheDir {
341
    return new CacheDir(CacheRouter.getMultisigTransactionCacheKey(args), '');
×
342
  }
343

344
  static getMultisigTransactionCacheKey(args: {
345
    chainId: string;
346
    safeTransactionHash: string;
347
  }): string {
348
    return `${args.chainId}_${CacheRouter.MULTISIG_TRANSACTION_KEY}_${args.safeTransactionHash}`;
24✔
349
  }
350

351
  static getCreationTransactionCacheDir(args: {
352
    chainId: string;
353
    safeAddress: `0x${string}`;
354
  }): CacheDir {
355
    return new CacheDir(
×
356
      `${args.chainId}_${CacheRouter.CREATION_TRANSACTION_KEY}_${args.safeAddress}`,
357
      '',
358
    );
359
  }
360

361
  static getAllTransactionsCacheDir(args: {
362
    chainId: string;
363
    safeAddress: `0x${string}`;
364
    ordering?: string;
365
    executed?: boolean;
366
    queued?: boolean;
367
    limit?: number;
368
    offset?: number;
369
  }): CacheDir {
370
    return new CacheDir(
×
371
      CacheRouter.getAllTransactionsKey(args),
372
      `${args.ordering}_${args.executed}_${args.queued}_${args.limit}_${args.offset}`,
373
    );
374
  }
375

376
  static getAllTransactionsKey(args: {
377
    chainId: string;
378
    safeAddress: `0x${string}`;
379
  }): string {
380
    return `${args.chainId}_${CacheRouter.ALL_TRANSACTIONS_KEY}_${args.safeAddress}`;
46✔
381
  }
382

383
  static getTokenCacheDir(args: {
384
    chainId: string;
385
    address: string;
386
  }): CacheDir {
387
    return new CacheDir(
×
388
      `${args.chainId}_${CacheRouter.TOKEN_KEY}_${args.address}`,
389
      '',
390
    );
391
  }
392

393
  static getTokensCacheKey(chainId: string): string {
394
    return `${chainId}_${CacheRouter.TOKENS_KEY}`;
×
395
  }
396

397
  static getTokensCacheDir(args: {
398
    chainId: string;
399
    limit?: number;
400
    offset?: number;
401
  }): CacheDir {
402
    return new CacheDir(
×
403
      CacheRouter.getTokensCacheKey(args.chainId),
404
      `${args.limit}_${args.offset}`,
405
    );
406
  }
407

408
  static getSafesByOwnerCacheDir(args: {
409
    chainId: string;
410
    ownerAddress: `0x${string}`;
411
  }): CacheDir {
412
    return new CacheDir(
2✔
413
      `${args.chainId}_${CacheRouter.OWNERS_SAFE_KEY}_${args.ownerAddress}`,
414
      '',
415
    );
416
  }
417

418
  static getMessageByHashCacheKey(args: {
419
    chainId: string;
420
    messageHash: string;
421
  }): string {
422
    return `${args.chainId}_${CacheRouter.MESSAGE_KEY}_${args.messageHash}`;
2✔
423
  }
424

425
  static getMessageByHashCacheDir(args: {
426
    chainId: string;
427
    messageHash: string;
428
  }): CacheDir {
429
    return new CacheDir(this.getMessageByHashCacheKey(args), '');
×
430
  }
431

432
  static getMessagesBySafeCacheKey(args: {
433
    chainId: string;
434
    safeAddress: `0x${string}`;
435
  }): string {
436
    return `${args.chainId}_${CacheRouter.MESSAGES_KEY}_${args.safeAddress}`;
4✔
437
  }
438

439
  static getMessagesBySafeCacheDir(args: {
440
    chainId: string;
441
    safeAddress: `0x${string}`;
442
    limit?: number;
443
    offset?: number;
444
  }): CacheDir {
445
    return new CacheDir(
×
446
      this.getMessagesBySafeCacheKey(args),
447
      `${args.limit}_${args.offset}`,
448
    );
449
  }
450

451
  static getChainsCacheKey(): string {
452
    return CacheRouter.CHAINS_KEY;
2✔
453
  }
454

455
  static getChainsCacheDir(args: {
456
    limit?: number;
457
    offset?: number;
458
  }): CacheDir {
459
    return new CacheDir(
×
460
      CacheRouter.getChainsCacheKey(),
461
      `${args.limit}_${args.offset}`,
462
    );
463
  }
464

465
  static getChainCacheKey(chainId: string): string {
466
    return `${chainId}_${CacheRouter.CHAIN_KEY}`;
48✔
467
  }
468

469
  static getChainCacheDir(chainId: string): CacheDir {
470
    return new CacheDir(CacheRouter.getChainCacheKey(chainId), '');
46✔
471
  }
472

473
  static getRelayKey(args: {
474
    chainId: string;
475
    address: `0x${string}`;
476
  }): string {
477
    return `${args.chainId}_${CacheRouter.RELAY_KEY}_${args.address}`;
×
478
  }
479

480
  static getRelayCacheDir(args: {
481
    chainId: string;
482
    address: `0x${string}`;
483
  }): CacheDir {
484
    return new CacheDir(CacheRouter.getRelayKey(args), '');
×
485
  }
486

487
  static getSafeAppsKey(chainId: string): string {
488
    return `${chainId}_${CacheRouter.SAFE_APPS_KEY}`;
2✔
489
  }
490

491
  static getSafeAppsCacheDir(args: {
492
    chainId?: string;
493
    clientUrl?: string;
494
    onlyListed?: boolean;
495
    url?: string;
496
  }): CacheDir {
497
    return new CacheDir(
4✔
498
      `${args.chainId}_${CacheRouter.SAFE_APPS_KEY}`,
499
      `${args.clientUrl}_${args.onlyListed}_${args.url}`,
500
    );
501
  }
502

503
  static getNativeCoinPriceCacheDir(args: {
504
    nativeCoinId: string;
505
    fiatCode: string;
506
  }): CacheDir {
507
    return new CacheDir(
×
508
      `${args.nativeCoinId}_${CacheRouter.NATIVE_COIN_PRICE_KEY}_${args.fiatCode}`,
509
      '',
510
    );
511
  }
512

513
  static getTokenPriceCacheDir(args: {
514
    chainName: string;
515
    fiatCode: string;
516
    tokenAddress: string;
517
  }): CacheDir {
518
    return new CacheDir(
×
519
      `${args.chainName}_${CacheRouter.TOKEN_PRICE_KEY}_${args.tokenAddress}_${args.fiatCode}`,
520
      '',
521
    );
522
  }
523

524
  static getPriceFiatCodesCacheDir(): CacheDir {
525
    return new CacheDir(CacheRouter.SAFE_FIAT_CODES_KEY, '');
×
526
  }
527

528
  static getAccountCacheDir(address: `0x${string}`): CacheDir {
529
    return new CacheDir(`${CacheRouter.ACCOUNT_KEY}_${address}`, '');
×
530
  }
531

532
  static getAccountDataTypesCacheDir(): CacheDir {
533
    return new CacheDir(CacheRouter.ACCOUNT_DATA_TYPES_KEY, '');
×
534
  }
535

536
  static getAccountDataSettingsCacheDir(address: `0x${string}`): CacheDir {
537
    return new CacheDir(
×
538
      `${CacheRouter.ACCOUNT_DATA_SETTINGS_KEY}_${address}`,
539
      '',
540
    );
541
  }
542

543
  static getCounterfactualSafeCacheDir(
544
    chainId: string,
545
    predictedAddress: `0x${string}`,
546
  ): CacheDir {
547
    return new CacheDir(
×
548
      `${chainId}_${CacheRouter.COUNTERFACTUAL_SAFE_KEY}_${predictedAddress}`,
549
      '',
550
    );
551
  }
552

553
  static getCounterfactualSafesCacheDir(address: `0x${string}`): CacheDir {
554
    return new CacheDir(
×
555
      `${CacheRouter.COUNTERFACTUAL_SAFES_KEY}_${address}`,
556
      '',
557
    );
558
  }
559

560
  static getRpcRequestsKey(chainId: string): string {
561
    return `${chainId}_${CacheRouter.RPC_REQUESTS_KEY}`;
×
562
  }
563

564
  static getRpcRequestsCacheDir(args: {
565
    chainId: string;
566
    method: string;
567
    params: string;
568
  }): CacheDir {
569
    return new CacheDir(
×
570
      CacheRouter.getRpcRequestsKey(args.chainId),
571
      `${args.method}_${args.params}`,
572
    );
573
  }
574

575
  static getStakingDeploymentsCacheDir(): CacheDir {
576
    return new CacheDir(this.STAKING_DEPLOYMENTS_KEY, '');
×
577
  }
578

579
  static getStakingNetworkStatsCacheDir(): CacheDir {
580
    return new CacheDir(this.STAKING_NETWORK_STATS_KEY, '');
×
581
  }
582

583
  static getStakingDedicatedStakingStatsCacheDir(): CacheDir {
584
    return new CacheDir(this.STAKING_DEDICATED_STAKING_STATS_KEY, '');
×
585
  }
586

587
  static getStakingPooledStakingStatsCacheDir(pool: `0x${string}`): CacheDir {
588
    return new CacheDir(`${this.STAKING_POOLED_STAKING_STATS_KEY}_${pool}`, '');
×
589
  }
590

591
  static getStakingDefiVaultStatsCacheDir(args: {
592
    chainId: string;
593
    vault: `0x${string}`;
594
  }): CacheDir {
595
    return new CacheDir(
×
596
      `${args.chainId}_${this.STAKING_DEFI_VAULT_STATS_KEY}_${args.vault}`,
597
      '',
598
    );
599
  }
600

601
  /**
602
   * Calculated the chain/Safe-specific cache key of {@link Stake}.
603
   *
604
   * @param {string} args.chainId - Chain ID
605
   * @param {string} args.safeAddress - Safe address
606
   * @returns {string} - Cache key
607
   */
608
  static getStakingStakesCacheKey(args: {
609
    chainId: string;
610
    safeAddress: `0x${string}`;
611
  }): string {
612
    return `${args.chainId}_${CacheRouter.STAKING_STAKES_KEY}_${args.safeAddress}`;
×
613
  }
614

615
  /**
616
   * Calculate cache directory for staking stakes.
617
   *
618
   * Note: This function hashes the validators' public keys to keep the
619
   * cache field short and deterministic. Redis and other cache systems
620
   * may experience performance degradation with long fields.
621
   *
622
   * @param {string} args.chainId - Chain ID
623
   * @param {string} args.safeAddress - Safe address
624
   * @param {string} args.validatorsPublicKeys - Array of validators public keys
625
   * @returns {@link CacheDir} - Cache directory
626
   */
627
  static getStakingStakesCacheDir(args: {
628
    chainId: string;
629
    safeAddress: `0x${string}`;
630
    validatorsPublicKeys: Array<`0x${string}`>;
631
  }): CacheDir {
632
    const hash = crypto.createHash('sha256');
×
633
    hash.update(args.validatorsPublicKeys.join('_'));
×
634
    return new CacheDir(
×
635
      CacheRouter.getStakingStakesCacheKey(args),
636
      hash.digest('hex'),
637
    );
638
  }
639

640
  static getUnsupportedChainEventCacheKey(chainId: string): string {
641
    return `${chainId}_${this.UNSUPPORTED_CHAIN_EVENT}`;
×
642
  }
643

644
  static getStakingTransactionStatusCacheDir(args: {
645
    chainId: string;
646
    txHash: `0x${string}`;
647
  }): CacheDir {
648
    return new CacheDir(
×
649
      `${args.chainId}_${CacheRouter.STAKING_TRANSACTION_STATUS_KEY}_${args.txHash}`,
650
      '',
651
    );
652
  }
653

654
  static getTargetedSafeCacheKey(outreachId: number): string {
655
    return `${CacheRouter.TARGETED_MESSAGING_TARGETED_SAFE_KEY}_${outreachId}`;
×
656
  }
657

658
  static getTargetedSafeCacheDir(args: {
659
    outreachId: number;
660
    safeAddress: `0x${string}`;
661
  }): CacheDir {
662
    return new CacheDir(
×
663
      CacheRouter.getTargetedSafeCacheKey(args.outreachId),
664
      args.safeAddress,
665
    );
666
  }
667

668
  static getSubmissionCacheKey(outreachId: number): string {
669
    return `${CacheRouter.TARGETED_MESSAGING_SUBMISSION_KEY}_${outreachId}`;
×
670
  }
671

672
  static getSubmissionCacheDir(args: {
673
    outreachId: number;
674
    safeAddress: `0x${string}`;
675
    signerAddress: `0x${string}`;
676
  }): CacheDir {
677
    return new CacheDir(
×
678
      CacheRouter.getSubmissionCacheKey(args.outreachId),
679
      `${args.safeAddress}_${args.signerAddress}`,
680
    );
681
  }
682
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc