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

safe-global / safe-client-gateway / 15209145395

23 May 2025 11:08AM UTC coverage: 90.2% (+0.02%) from 90.183%
15209145395

push

github

web-flow
Revert "fix: decoder service integration (#2589) (#2593) (#2595)" (#2596)

This PR adds the decoder service integration again.
This reverts commit 0e38096a0.

3347 of 4050 branches covered (82.64%)

Branch coverage included in aggregate %.

76 of 82 new or added lines in 11 files covered. (92.68%)

2 existing lines in 2 files now uncovered.

11610 of 12532 relevant lines covered (92.64%)

552.53 hits per line

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

90.0
/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 { Page } from '@/domain/entities/page.entity';
9
import {
106✔
10
  Contract,
11
  ContractPageSchema,
12
} from '@/domain/data-decoder/v2/entities/contract.entity';
13
import { Transaction } from '@/domain/safe/entities/transaction.entity';
14
import { ILoggingService, LoggingService } from '@/logging/logging.interface';
106✔
15
import { asError } from '@/logging/utils';
106✔
16

17
@Injectable()
18
export class DataDecoderRepository implements IDataDecoderRepository {
106✔
19
  constructor(
20
    @Inject(IDataDecoderApi)
21
    private readonly dataDecoderApi: IDataDecoderApi,
1,614✔
22
    @Inject(LoggingService) private readonly loggingService: ILoggingService,
1,614✔
23
  ) {}
24

25
  public async getDecodedData(args: {
26
    chainId: string;
27
    data: `0x${string}`;
28
    to: `0x${string}`;
29
  }): Promise<DataDecoded> {
30
    const dataDecoded = await this.dataDecoderApi.getDecodedData(args);
520✔
31
    return DataDecodedSchema.parse(dataDecoded);
308✔
32
  }
33

34
  public async getContracts(args: {
35
    chainIds: Array<string>;
36
    address: `0x${string}`;
37
  }): Promise<Page<Contract>> {
38
    const contracts = await this.dataDecoderApi.getContracts(args);
×
39
    return ContractPageSchema.parse(contracts);
×
40
  }
41

42
  public async getTransactionDataDecoded(args: {
43
    chainId: string;
44
    transaction: Transaction;
45
  }): Promise<DataDecoded | null> {
46
    const data = this.getDataDecodedData(args.transaction);
524✔
47

48
    if (!data || data === '0x') {
524✔
49
      return null;
4✔
50
    }
51

52
    try {
520✔
53
      return await this.getDecodedData({
520✔
54
        chainId: args.chainId,
55
        data,
56
        to: this.getDataDecodedTo(args.transaction),
57
      });
58
    } catch (e) {
59
      this.loggingService.warn(
212✔
60
        `Error decoding transaction data: ${asError(e).message}`,
61
      );
62
      return null;
212✔
63
    }
64
  }
65

66
  private getDataDecodedData(transaction: Transaction): `0x${string}` | null {
67
    // Multisig transaction
68
    if ('data' in transaction) {
524✔
69
      return transaction.data;
518✔
70
    }
71
    // Creation
72
    if ('setupData' in transaction) {
6✔
73
      return transaction.setupData;
6✔
74
    }
75

NEW
76
    throw Error('Unrecognized transaction type');
×
77
  }
78

79
  private getDataDecodedTo(transaction: Transaction): `0x${string}` {
80
    // Multisig transaction
81
    if ('to' in transaction) {
520✔
82
      return transaction.to;
440✔
83
    }
84
    // Native transfer
85
    if ('from' in transaction) {
80✔
86
      return transaction.from;
74✔
87
    }
88
    // Creation
89
    if ('factoryAddress' in transaction) {
6✔
90
      return transaction.factoryAddress;
6✔
91
    }
92

NEW
93
    throw Error('Unrecognized transaction type');
×
94
  }
95
}
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