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

safe-global / safe-client-gateway / 15776490844

20 Jun 2025 10:04AM UTC coverage: 90.189% (-0.03%) from 90.22%
15776490844

push

github

dsh
fix: test

3369 of 4077 branches covered (82.63%)

Branch coverage included in aggregate %.

11643 of 12568 relevant lines covered (92.64%)

585.57 hits per line

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

94.59
/src/domain/data-decoder/v2/data-decoder.repository.ts
1
import { Inject, Injectable } from '@nestjs/common';
106✔
2
import {
106✔
3
  DataDecoded,
4
  DataDecodedSchema,
5
} from '@/domain/data-decoder/v2/entities/data-decoded.entity';
6
import { IDataDecoderRepository } from '@/domain/data-decoder/v2/data-decoder.repository.interface';
7
import { IDataDecoderApi } from '@/domain/interfaces/data-decoder-api.interface';
106✔
8
import { Transaction } from '@/domain/safe/entities/transaction.entity';
9
import { ILoggingService, LoggingService } from '@/logging/logging.interface';
106✔
10
import { asError } from '@/logging/utils';
106✔
11

12
@Injectable()
13
export class DataDecoderRepository implements IDataDecoderRepository {
106✔
14
  constructor(
15
    @Inject(IDataDecoderApi)
16
    private readonly dataDecoderApi: IDataDecoderApi,
1,764✔
17
    @Inject(LoggingService) private readonly loggingService: ILoggingService,
1,764✔
18
  ) {}
19

20
  public async getDecodedData(args: {
21
    chainId: string;
22
    data: `0x${string}`;
23
    to: `0x${string}`;
24
  }): Promise<DataDecoded> {
25
    const dataDecoded = await this.dataDecoderApi.getDecodedData(args);
520✔
26
    return DataDecodedSchema.parse(dataDecoded);
308✔
27
  }
28

29
  public async getTransactionDataDecoded(args: {
30
    chainId: string;
31
    transaction: Transaction;
32
  }): Promise<DataDecoded | null> {
33
    const data = this.getDataDecodedData(args.transaction);
524✔
34

35
    if (!data || data === '0x') {
524✔
36
      return null;
4✔
37
    }
38

39
    try {
520✔
40
      return await this.getDecodedData({
520✔
41
        chainId: args.chainId,
42
        data,
43
        to: this.getDataDecodedTo(args.transaction),
44
      });
45
    } catch (e) {
46
      this.loggingService.warn(
212✔
47
        `Error decoding transaction data: ${asError(e).message}`,
48
      );
49
      return null;
212✔
50
    }
51
  }
52

53
  private getDataDecodedData(transaction: Transaction): `0x${string}` | null {
54
    // Multisig transaction
55
    if ('data' in transaction) {
524✔
56
      return transaction.data;
518✔
57
    }
58
    // Creation
59
    if ('setupData' in transaction) {
6✔
60
      return transaction.setupData;
6✔
61
    }
62

63
    throw Error('Unrecognized transaction type');
×
64
  }
65

66
  private getDataDecodedTo(transaction: Transaction): `0x${string}` {
67
    // Multisig transaction
68
    if ('to' in transaction) {
520✔
69
      return transaction.to;
440✔
70
    }
71
    // Native transfer
72
    if ('from' in transaction) {
80✔
73
      return transaction.from;
74✔
74
    }
75
    // Creation
76
    if ('factoryAddress' in transaction) {
6✔
77
      return transaction.factoryAddress;
6✔
78
    }
79

80
    throw Error('Unrecognized transaction type');
×
81
  }
82
}
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