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

safe-global / safe-client-gateway / 10684918840

03 Sep 2024 02:24PM UTC coverage: 46.327% (-0.005%) from 46.332%
10684918840

Pull #1892

github

hectorgomezv
Ignore non-relevant folders on coverage reports
Pull Request #1892: Fix coverage reports configuration

499 of 3099 branches covered (16.1%)

Branch coverage included in aggregate %.

4811 of 8363 relevant lines covered (57.53%)

12.24 hits per line

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

6.25
/src/routes/transactions/mappers/common/data-decoded-param.helper.ts
1
import { Injectable } from '@nestjs/common';
16✔
2
import { DataDecoded } from '@/domain/data-decoder/entities/data-decoded.entity';
3
import { Operation } from '@/domain/safe/entities/operation.entity';
16✔
4

5
@Injectable()
6
export class DataDecodedParamHelper {
16✔
7
  private readonly TRANSFER_METHOD = 'transfer';
16✔
8
  private readonly TRANSFER_FROM_METHOD = 'transferFrom';
16✔
9
  private readonly SAFE_TRANSFER_FROM_METHOD = 'safeTransferFrom';
16✔
10

11
  getFromParam(dataDecoded: DataDecoded | null, fallback: string): string {
12
    if (!dataDecoded || !dataDecoded.parameters) return fallback;
×
13

14
    switch (dataDecoded.method) {
×
15
      case this.TRANSFER_FROM_METHOD:
16
      case this.SAFE_TRANSFER_FROM_METHOD: {
17
        const value = this.getValueAtPosition(dataDecoded, 0);
×
18
        return typeof value === 'string' ? value : fallback;
×
19
      }
20
      case this.TRANSFER_METHOD:
21
      default:
22
        return fallback;
×
23
    }
24
  }
25

26
  getToParam(dataDecoded: DataDecoded | null, fallback: string): string {
27
    if (!dataDecoded || !dataDecoded.parameters) return fallback;
×
28

29
    switch (dataDecoded.method) {
×
30
      case this.TRANSFER_METHOD: {
31
        const value = this.getValueAtPosition(dataDecoded, 0);
×
32
        return typeof value === 'string' ? value : fallback;
×
33
      }
34
      case this.TRANSFER_FROM_METHOD:
35
      case this.SAFE_TRANSFER_FROM_METHOD: {
36
        const value = this.getValueAtPosition(dataDecoded, 1);
×
37
        return typeof value === 'string' ? value : fallback;
×
38
      }
39
      default:
40
        return fallback;
×
41
    }
42
  }
43

44
  getValueParam(dataDecoded: DataDecoded | null, fallback: string): string {
45
    if (!dataDecoded || !dataDecoded.parameters) return fallback;
×
46

47
    switch (dataDecoded.method) {
×
48
      case this.TRANSFER_METHOD: {
49
        const value = this.getValueAtPosition(dataDecoded, 1);
×
50
        return typeof value === 'string' ? value : fallback;
×
51
      }
52
      case this.TRANSFER_FROM_METHOD:
53
      case this.SAFE_TRANSFER_FROM_METHOD: {
54
        const value = this.getValueAtPosition(dataDecoded, 2);
×
55
        return typeof value === 'string' ? value : fallback;
×
56
      }
57
      default:
58
        return fallback;
×
59
    }
60
  }
61

62
  getValueAtPosition(
63
    dataDecoded: DataDecoded | null,
64
    position: number,
65
  ): unknown {
66
    if (!dataDecoded || !dataDecoded.parameters?.length) return null;
×
67
    return dataDecoded.parameters[position]?.value ?? null;
×
68
  }
69

70
  hasNestedDelegate(dataDecoded: DataDecoded): boolean {
71
    if (!dataDecoded.parameters) return false;
×
72
    return dataDecoded.parameters.some(
×
73
      (param) =>
74
        Array.isArray(param.valueDecoded) &&
×
75
        param.valueDecoded.some(
76
          (innerParam) => innerParam?.operation === Operation.DELEGATE,
×
77
        ),
78
    );
79
  }
80
}
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

© 2025 Coveralls, Inc