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

safe-global / safe-client-gateway / 13719764653

07 Mar 2025 11:30AM UTC coverage: 90.458% (-0.2%) from 90.619%
13719764653

Pull #2428

github

PooyaRaki
feat: add pgAdmin service to Docker Compose configuration
Pull Request #2428: feat: add pgAdmin service to Docker Compose configuration

3128 of 3781 branches covered (82.73%)

Branch coverage included in aggregate %.

10665 of 11467 relevant lines covered (93.01%)

506.2 hits per line

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

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

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

67
  static getAuthNonceCacheKey(nonce: string): string {
68
    return `${CacheRouter.AUTH_NONCE_KEY}_${nonce}`;
106✔
69
  }
70

71
  static getAuthNonceCacheDir(nonce: string): CacheDir {
72
    return new CacheDir(CacheRouter.getAuthNonceCacheKey(nonce), '');
106✔
73
  }
74

75
  static getBalancesCacheKey(args: {
76
    chainId: string;
77
    safeAddress: `0x${string}`;
78
  }): string {
79
    return `${args.chainId}_${CacheRouter.SAFE_BALANCES_KEY}_${args.safeAddress}`;
100✔
80
  }
81

82
  static getBalancesCacheDir(args: {
83
    chainId: string;
84
    safeAddress: `0x${string}`;
85
    trusted?: boolean;
86
    excludeSpam?: boolean;
87
  }): CacheDir {
88
    return new CacheDir(
60✔
89
      CacheRouter.getBalancesCacheKey(args),
90
      `${args.trusted}_${args.excludeSpam}`,
91
    );
92
  }
93

94
  static getZerionBalancesCacheKey(args: {
95
    chainId: string;
96
    safeAddress: `0x${string}`;
97
  }): string {
98
    return `${args.chainId}_${CacheRouter.ZERION_BALANCES_KEY}_${args.safeAddress}`;
24✔
99
  }
100

101
  static getZerionBalancesCacheDir(args: {
102
    chainId: string;
103
    safeAddress: `0x${string}`;
104
    fiatCode: string;
105
  }): CacheDir {
106
    return new CacheDir(
24✔
107
      CacheRouter.getZerionBalancesCacheKey(args),
108
      args.fiatCode,
109
    );
110
  }
111

112
  static getZerionCollectiblesCacheKey(args: {
113
    chainId: string;
114
    safeAddress: `0x${string}`;
115
  }): string {
116
    return `${args.chainId}_${CacheRouter.ZERION_COLLECTIBLES_KEY}_${args.safeAddress}`;
8✔
117
  }
118

119
  static getZerionCollectiblesCacheDir(args: {
120
    chainId: string;
121
    safeAddress: `0x${string}`;
122
    limit?: number;
123
    offset?: number;
124
  }): CacheDir {
125
    return new CacheDir(
8✔
126
      CacheRouter.getZerionCollectiblesCacheKey(args),
127
      `${args.limit}_${args.offset}`,
128
    );
129
  }
130

131
  static getRateLimitCacheKey(prefix: string): string {
132
    return `${prefix}_${CacheRouter.RATE_LIMIT_KEY}`;
154✔
133
  }
134

135
  static getSafeCacheDir(args: {
136
    chainId: string;
137
    safeAddress: `0x${string}`;
138
  }): CacheDir {
139
    return new CacheDir(CacheRouter.getSafeCacheKey(args), '');
756✔
140
  }
141

142
  static getSafeCacheKey(args: {
143
    chainId: string;
144
    safeAddress: `0x${string}`;
145
  }): string {
146
    return `${args.chainId}_${CacheRouter.SAFE_KEY}_${args.safeAddress}`;
790✔
147
  }
148

149
  static getIsSafeCacheDir(args: {
150
    chainId: string;
151
    safeAddress: `0x${string}`;
152
  }): CacheDir {
153
    return new CacheDir(CacheRouter.getIsSafeCacheKey(args), '');
68✔
154
  }
155

156
  static getIsSafeCacheKey(args: {
157
    chainId: string;
158
    safeAddress: `0x${string}`;
159
  }): string {
160
    return `${args.chainId}_${CacheRouter.SAFE_EXISTS_KEY}_${args.safeAddress}`;
72✔
161
  }
162

163
  static getContractCacheDir(args: {
164
    chainId: string;
165
    contractAddress: `0x${string}`;
166
  }): CacheDir {
167
    return new CacheDir(
962✔
168
      `${args.chainId}_${CacheRouter.CONTRACT_KEY}_${args.contractAddress}`,
169
      '',
170
    );
171
  }
172

173
  static getBackboneCacheDir(chainId: string): CacheDir {
174
    return new CacheDir(`${chainId}_${CacheRouter.BACKBONE_KEY}`, '');
16✔
175
  }
176

177
  static getSingletonsCacheDir(chainId: string): CacheDir {
178
    return new CacheDir(`${chainId}_${CacheRouter.SINGLETONS_KEY}`, '');
68✔
179
  }
180

181
  static getCollectiblesCacheDir(args: {
182
    chainId: string;
183
    safeAddress: `0x${string}`;
184
    limit?: number;
185
    offset?: number;
186
    trusted?: boolean;
187
    excludeSpam?: boolean;
188
  }): CacheDir {
189
    return new CacheDir(
10✔
190
      CacheRouter.getCollectiblesKey(args),
191
      `${args.limit}_${args.offset}_${args.trusted}_${args.excludeSpam}`,
192
    );
193
  }
194

195
  static getCollectiblesKey(args: {
196
    chainId: string;
197
    safeAddress: `0x${string}`;
198
  }): string {
199
    return `${args.chainId}_${CacheRouter.SAFE_COLLECTIBLES_KEY}_${args.safeAddress}`;
52✔
200
  }
201

202
  static getDelegatesCacheKey(args: {
203
    chainId: string;
204
    safeAddress?: `0x${string}`;
205
  }): string {
206
    return `${args.chainId}_${CacheRouter.DELEGATES_KEY}_${args.safeAddress}`;
156✔
207
  }
208

209
  static getDelegatesCacheDir(args: {
210
    chainId: string;
211
    safeAddress?: `0x${string}`;
212
    delegate?: `0x${string}`;
213
    delegator?: `0x${string}`;
214
    label?: string;
215
    limit?: number;
216
    offset?: number;
217
  }): CacheDir {
218
    return new CacheDir(
150✔
219
      CacheRouter.getDelegatesCacheKey(args),
220
      `${args.delegate}_${args.delegator}_${args.label}_${args.limit}_${args.offset}`,
221
    );
222
  }
223

224
  static getFirebaseOAuth2TokenCacheDir(): CacheDir {
225
    return new CacheDir(CacheRouter.FIREBASE_OAUTH2_TOKEN_KEY, '');
4✔
226
  }
227

228
  static getTransferCacheDir(args: {
229
    chainId: string;
230
    transferId: string;
231
  }): CacheDir {
232
    return new CacheDir(
10✔
233
      `${args.chainId}_${CacheRouter.TRANSFER_KEY}_${args.transferId}`,
234
      '',
235
    );
236
  }
237

238
  static getTransfersCacheDir(args: {
239
    chainId: string;
240
    safeAddress: string;
241
    onlyErc20: boolean;
242
    onlyErc721: boolean;
243
    limit?: number;
244
    offset?: number;
245
  }): CacheDir {
246
    return new CacheDir(
118✔
247
      CacheRouter.getTransfersCacheKey(args),
248
      `${args.onlyErc20}_${args.onlyErc721}_${args.limit}_${args.offset}`,
249
    );
250
  }
251

252
  static getTransfersCacheKey(args: {
253
    chainId: string;
254
    safeAddress: string;
255
  }): string {
256
    return `${args.chainId}_${CacheRouter.TRANSFERS_KEY}_${args.safeAddress}`;
178✔
257
  }
258

259
  static getModuleTransactionCacheDir(args: {
260
    chainId: string;
261
    moduleTransactionId: string;
262
  }): CacheDir {
263
    return new CacheDir(
12✔
264
      `${args.chainId}_${CacheRouter.MODULE_TRANSACTION_KEY}_${args.moduleTransactionId}`,
265
      '',
266
    );
267
  }
268

269
  static getModuleTransactionsCacheDir(args: {
270
    chainId: string;
271
    safeAddress: `0x${string}`;
272
    to?: string;
273
    txHash?: string;
274
    module?: string;
275
    limit?: number;
276
    offset?: number;
277
  }): CacheDir {
278
    return new CacheDir(
70✔
279
      CacheRouter.getModuleTransactionsCacheKey(args),
280
      `${args.to}_${args.module}_${args.txHash}_${args.limit}_${args.offset}`,
281
    );
282
  }
283

284
  static getModuleTransactionsCacheKey(args: {
285
    chainId: string;
286
    safeAddress: `0x${string}`;
287
  }): string {
288
    return `${args.chainId}_${CacheRouter.MODULE_TRANSACTIONS_KEY}_${args.safeAddress}`;
86✔
289
  }
290

291
  static getIncomingTransfersCacheDir(args: {
292
    chainId: string;
293
    safeAddress: string;
294
    executionDateGte?: string;
295
    executionDateLte?: string;
296
    to?: string;
297
    value?: string;
298
    tokenAddress?: string;
299
    txHash?: string;
300
    limit?: number;
301
    offset?: number;
302
  }): CacheDir {
303
    return new CacheDir(
48✔
304
      CacheRouter.getIncomingTransfersCacheKey(args),
305
      `${args.executionDateGte}_${args.executionDateLte}_${args.to}_${args.value}_${args.tokenAddress}_${args.txHash}_${args.limit}_${args.offset}`,
306
    );
307
  }
308

309
  static getIncomingTransfersCacheKey(args: {
310
    chainId: string;
311
    safeAddress: string;
312
  }): string {
313
    return `${args.chainId}_${CacheRouter.INCOMING_TRANSFERS_KEY}_${args.safeAddress}`;
78✔
314
  }
315

316
  static getIndexingCacheDir(chainId: string): CacheDir {
317
    return new CacheDir(`${chainId}_${CacheRouter.INDEXING_KEY}`, '');
12✔
318
  }
319

320
  static getMultisigTransactionsCacheDir(args: {
321
    chainId: string;
322
    safeAddress: string;
323
    ordering?: string;
324
    executed?: boolean;
325
    trusted?: boolean;
326
    executionDateGte?: string;
327
    executionDateLte?: string;
328
    to?: string;
329
    value?: string;
330
    nonce?: string;
331
    nonceGte?: number;
332
    limit?: number;
333
    offset?: number;
334
  }): CacheDir {
335
    return new CacheDir(
212✔
336
      CacheRouter.getMultisigTransactionsCacheKey(args),
337
      `${args.ordering}_${args.executed}_${args.trusted}_${args.executionDateGte}_${args.executionDateLte}_${args.to}_${args.value}_${args.nonce}_${args.nonceGte}_${args.limit}_${args.offset}`,
338
    );
339
  }
340

341
  static getMultisigTransactionsCacheKey(args: {
342
    chainId: string;
343
    safeAddress: string;
344
  }): string {
345
    return `${args.chainId}_${CacheRouter.MULTISIG_TRANSACTIONS_KEY}_${args.safeAddress}`;
314✔
346
  }
347

348
  static getMultisigTransactionCacheDir(args: {
349
    chainId: string;
350
    safeTransactionHash: string;
351
  }): CacheDir {
352
    return new CacheDir(CacheRouter.getMultisigTransactionCacheKey(args), '');
94✔
353
  }
354

355
  static getMultisigTransactionCacheKey(args: {
356
    chainId: string;
357
    safeTransactionHash: string;
358
  }): string {
359
    return `${args.chainId}_${CacheRouter.MULTISIG_TRANSACTION_KEY}_${args.safeTransactionHash}`;
156✔
360
  }
361

362
  static getCreationTransactionCacheDir(args: {
363
    chainId: string;
364
    safeAddress: `0x${string}`;
365
  }): CacheDir {
366
    return new CacheDir(
18✔
367
      `${args.chainId}_${CacheRouter.CREATION_TRANSACTION_KEY}_${args.safeAddress}`,
368
      '',
369
    );
370
  }
371

372
  static getAllTransactionsCacheDir(args: {
373
    chainId: string;
374
    safeAddress: `0x${string}`;
375
    ordering?: string;
376
    executed?: boolean;
377
    queued?: boolean;
378
    limit?: number;
379
    offset?: number;
380
  }): CacheDir {
381
    return new CacheDir(
76✔
382
      CacheRouter.getAllTransactionsKey(args),
383
      `${args.ordering}_${args.executed}_${args.queued}_${args.limit}_${args.offset}`,
384
    );
385
  }
386

387
  static getAllTransactionsKey(args: {
388
    chainId: string;
389
    safeAddress: `0x${string}`;
390
  }): string {
391
    return `${args.chainId}_${CacheRouter.ALL_TRANSACTIONS_KEY}_${args.safeAddress}`;
150✔
392
  }
393

394
  static getTokenCacheDir(args: {
395
    chainId: string;
396
    address: string;
397
  }): CacheDir {
398
    return new CacheDir(
808✔
399
      `${args.chainId}_${CacheRouter.TOKEN_KEY}_${args.address}`,
400
      '',
401
    );
402
  }
403

404
  static getTokensCacheKey(chainId: string): string {
405
    return `${chainId}_${CacheRouter.TOKENS_KEY}`;
8✔
406
  }
407

408
  static getTokensCacheDir(args: {
409
    chainId: string;
410
    limit?: number;
411
    offset?: number;
412
  }): CacheDir {
413
    return new CacheDir(
8✔
414
      CacheRouter.getTokensCacheKey(args.chainId),
415
      `${args.limit}_${args.offset}`,
416
    );
417
  }
418

419
  static getSafesByOwnerCacheDir(args: {
420
    chainId: string;
421
    ownerAddress: `0x${string}`;
422
  }): CacheDir {
423
    return new CacheDir(
32✔
424
      `${args.chainId}_${CacheRouter.OWNERS_SAFE_KEY}_${args.ownerAddress}`,
425
      '',
426
    );
427
  }
428

429
  static getMessageByHashCacheKey(args: {
430
    chainId: string;
431
    messageHash: string;
432
  }): string {
433
    return `${args.chainId}_${CacheRouter.MESSAGE_KEY}_${args.messageHash}`;
70✔
434
  }
435

436
  static getMessageByHashCacheDir(args: {
437
    chainId: string;
438
    messageHash: string;
439
  }): CacheDir {
440
    return new CacheDir(this.getMessageByHashCacheKey(args), '');
66✔
441
  }
442

443
  static getMessagesBySafeCacheKey(args: {
444
    chainId: string;
445
    safeAddress: `0x${string}`;
446
  }): string {
447
    return `${args.chainId}_${CacheRouter.MESSAGES_KEY}_${args.safeAddress}`;
98✔
448
  }
449

450
  static getMessagesBySafeCacheDir(args: {
451
    chainId: string;
452
    safeAddress: `0x${string}`;
453
    limit?: number;
454
    offset?: number;
455
  }): CacheDir {
456
    return new CacheDir(
70✔
457
      this.getMessagesBySafeCacheKey(args),
458
      `${args.limit}_${args.offset}`,
459
    );
460
  }
461

462
  static getChainsCacheKey(): string {
463
    return CacheRouter.CHAINS_KEY;
46✔
464
  }
465

466
  static getChainsCacheDir(args: {
467
    limit?: number;
468
    offset?: number;
469
  }): CacheDir {
470
    return new CacheDir(
34✔
471
      CacheRouter.getChainsCacheKey(),
472
      `${args.limit}_${args.offset}`,
473
    );
474
  }
475

476
  static getChainCacheKey(chainId: string): string {
477
    return `${chainId}_${CacheRouter.CHAIN_KEY}`;
2,246✔
478
  }
479

480
  static getChainCacheDir(chainId: string): CacheDir {
481
    return new CacheDir(CacheRouter.getChainCacheKey(chainId), '');
2,234✔
482
  }
483

484
  static getRelayKey(args: {
485
    chainId: string;
486
    address: `0x${string}`;
487
  }): string {
488
    return `${args.chainId}_${CacheRouter.RELAY_KEY}_${args.address}`;
466✔
489
  }
490

491
  static getRelayCacheDir(args: {
492
    chainId: string;
493
    address: `0x${string}`;
494
  }): CacheDir {
495
    return new CacheDir(CacheRouter.getRelayKey(args), '');
466✔
496
  }
497

498
  static getSafeAppsKey(chainId: string): string {
499
    return `${chainId}_${CacheRouter.SAFE_APPS_KEY}`;
4✔
500
  }
501

502
  static getSafeAppsCacheDir(args: {
503
    chainId?: string;
504
    clientUrl?: string;
505
    onlyListed?: boolean;
506
    url?: string;
507
  }): CacheDir {
508
    return new CacheDir(
80✔
509
      `${args.chainId}_${CacheRouter.SAFE_APPS_KEY}`,
510
      `${args.clientUrl}_${args.onlyListed}_${args.url}`,
511
    );
512
  }
513

514
  static getNativeCoinPriceCacheDir(args: {
515
    nativeCoinId: string;
516
    fiatCode: string;
517
  }): CacheDir {
518
    return new CacheDir(
42✔
519
      `${args.nativeCoinId}_${CacheRouter.NATIVE_COIN_PRICE_KEY}_${args.fiatCode}`,
520
      '',
521
    );
522
  }
523

524
  static getTokenPriceCacheDir(args: {
525
    chainName: string;
526
    fiatCode: string;
527
    tokenAddress: string;
528
  }): CacheDir {
529
    return new CacheDir(
204✔
530
      `${args.chainName}_${CacheRouter.TOKEN_PRICE_KEY}_${args.tokenAddress}_${args.fiatCode}`,
531
      '',
532
    );
533
  }
534

535
  static getPriceFiatCodesCacheDir(): CacheDir {
536
    return new CacheDir(CacheRouter.SAFE_FIAT_CODES_KEY, '');
10✔
537
  }
538

539
  static getAccountCacheDir(address: `0x${string}`): CacheDir {
540
    return new CacheDir(`${CacheRouter.ACCOUNT_KEY}_${address}`, '');
86✔
541
  }
542

543
  static getAccountDataTypesCacheDir(): CacheDir {
544
    return new CacheDir(CacheRouter.ACCOUNT_DATA_TYPES_KEY, '');
20✔
545
  }
546

547
  static getAccountDataSettingsCacheDir(address: `0x${string}`): CacheDir {
548
    return new CacheDir(
22✔
549
      `${CacheRouter.ACCOUNT_DATA_SETTINGS_KEY}_${address}`,
550
      '',
551
    );
552
  }
553

554
  static getCounterfactualSafeCacheDir(
555
    chainId: string,
556
    predictedAddress: `0x${string}`,
557
  ): CacheDir {
558
    return new CacheDir(
24✔
559
      `${chainId}_${CacheRouter.COUNTERFACTUAL_SAFE_KEY}_${predictedAddress}`,
560
      '',
561
    );
562
  }
563

564
  static getCounterfactualSafesCacheDir(address: `0x${string}`): CacheDir {
565
    return new CacheDir(
90✔
566
      `${CacheRouter.COUNTERFACTUAL_SAFES_KEY}_${address}`,
567
      '',
568
    );
569
  }
570

571
  static getRpcRequestsKey(chainId: string): string {
572
    return `${chainId}_${CacheRouter.RPC_REQUESTS_KEY}`;
16✔
573
  }
574

575
  static getRpcRequestsCacheDir(args: {
576
    chainId: string;
577
    method: string;
578
    params: string;
579
  }): CacheDir {
580
    return new CacheDir(
12✔
581
      CacheRouter.getRpcRequestsKey(args.chainId),
582
      `${args.method}_${args.params}`,
583
    );
584
  }
585

586
  static getStakingDeploymentsCacheDir(): CacheDir {
587
    return new CacheDir(this.STAKING_DEPLOYMENTS_KEY, '');
52✔
588
  }
589

590
  static getStakingNetworkStatsCacheDir(): CacheDir {
591
    return new CacheDir(this.STAKING_NETWORK_STATS_KEY, '');
22✔
592
  }
593

594
  static getStakingDedicatedStakingStatsCacheDir(): CacheDir {
595
    return new CacheDir(this.STAKING_DEDICATED_STAKING_STATS_KEY, '');
14✔
596
  }
597

598
  static getStakingPooledStakingStatsCacheDir(pool: `0x${string}`): CacheDir {
599
    return new CacheDir(`${this.STAKING_POOLED_STAKING_STATS_KEY}_${pool}`, '');
4✔
600
  }
601

602
  static getStakingDefiVaultStatsCacheDir(args: {
603
    chainId: string;
604
    vault: `0x${string}`;
605
  }): CacheDir {
606
    return new CacheDir(
6✔
607
      `${args.chainId}_${this.STAKING_DEFI_VAULT_STATS_KEY}_${args.vault}`,
608
      '',
609
    );
610
  }
611

612
  /**
613
   * Calculated the chain/Safe-specific cache key of {@link Stake}.
614
   *
615
   * @param {string} args.chainId - Chain ID
616
   * @param {string} args.safeAddress - Safe address
617
   * @returns {string} - Cache key
618
   */
619
  static getStakingStakesCacheKey(args: {
620
    chainId: string;
621
    safeAddress: `0x${string}`;
622
  }): string {
623
    return `${args.chainId}_${CacheRouter.STAKING_STAKES_KEY}_${args.safeAddress}`;
56✔
624
  }
625

626
  /**
627
   * Calculate cache directory for staking stakes.
628
   *
629
   * Note: This function hashes the validators' public keys to keep the
630
   * cache field short and deterministic. Redis and other cache systems
631
   * may experience performance degradation with long fields.
632
   *
633
   * @param {string} args.chainId - Chain ID
634
   * @param {string} args.safeAddress - Safe address
635
   * @param {string} args.validatorsPublicKeys - Array of validators public keys
636
   * @returns {@link CacheDir} - Cache directory
637
   */
638
  static getStakingStakesCacheDir(args: {
639
    chainId: string;
640
    safeAddress: `0x${string}`;
641
    validatorsPublicKeys: Array<`0x${string}`>;
642
  }): CacheDir {
643
    const hash = crypto.createHash('sha256');
22✔
644
    hash.update(args.validatorsPublicKeys.join('_'));
22✔
645
    return new CacheDir(
22✔
646
      CacheRouter.getStakingStakesCacheKey(args),
647
      hash.digest('hex'),
648
    );
649
  }
650

651
  static getUnsupportedChainEventCacheKey(chainId: string): string {
652
    return `${chainId}_${this.UNSUPPORTED_CHAIN_EVENT}`;
72✔
653
  }
654

655
  static getStakingTransactionStatusCacheDir(args: {
656
    chainId: string;
657
    txHash: `0x${string}`;
658
  }): CacheDir {
659
    return new CacheDir(
8✔
660
      `${args.chainId}_${CacheRouter.STAKING_TRANSACTION_STATUS_KEY}_${args.txHash}`,
661
      '',
662
    );
663
  }
664

665
  static getTargetedSafeCacheKey(outreachId: number): string {
666
    return `${CacheRouter.TARGETED_MESSAGING_TARGETED_SAFE_KEY}_${outreachId}`;
52✔
667
  }
668

669
  static getTargetedSafeCacheDir(args: {
670
    outreachId: number;
671
    safeAddress: `0x${string}`;
672
  }): CacheDir {
673
    return new CacheDir(
18✔
674
      CacheRouter.getTargetedSafeCacheKey(args.outreachId),
675
      args.safeAddress,
676
    );
677
  }
678

679
  static getSubmissionCacheKey(outreachId: number): string {
680
    return `${CacheRouter.TARGETED_MESSAGING_SUBMISSION_KEY}_${outreachId}`;
20✔
681
  }
682

683
  static getSubmissionCacheDir(args: {
684
    outreachId: number;
685
    safeAddress: `0x${string}`;
686
    signerAddress: `0x${string}`;
687
  }): CacheDir {
688
    return new CacheDir(
12✔
689
      CacheRouter.getSubmissionCacheKey(args.outreachId),
690
      `${args.safeAddress}_${args.signerAddress}`,
691
    );
692
  }
693

694
  static getOutreachesCacheDir(): CacheDir {
695
    return new CacheDir(CacheRouter.TARGETED_MESSAGING_OUTREACHES, '');
×
696
  }
697

698
  static getOutreachFileProcessorCacheKey(): string {
699
    return CacheRouter.TARGETED_MESSAGING_OUTREACH_FILE_PROCESSOR_LOCK;
66✔
700
  }
701

702
  static getOutreachFileProcessorCacheDir(): CacheDir {
703
    return new CacheDir(CacheRouter.getOutreachFileProcessorCacheKey(), '');
42✔
704
  }
705
}
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