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

safe-global / safe-client-gateway / 8093846263

29 Feb 2024 09:32AM UTC coverage: 93.246% (-0.4%) from 93.665%
8093846263

push

github

web-flow
Add `trusted` query param. to `incoming-transfers` endpoint (#1214)

This adds a `trusted` query param. to the `incoming-transfers` endpoints, mirroring that of the `history` endpoint. If `true`, it filters ERC-20 transfers that are untrusted.

1661 of 1999 branches covered (83.09%)

Branch coverage included in aggregate %.

17 of 17 new or added lines in 3 files covered. (100.0%)

26 existing lines in 10 files now uncovered.

6126 of 6352 relevant lines covered (96.44%)

341.85 hits per line

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

95.0
/src/datasources/network/network.module.ts
1
import { Global, Module } from '@nestjs/common';
70✔
2
import { IConfigurationService } from '@/config/configuration.service.interface';
70✔
3
import { FetchNetworkService } from '@/datasources/network/fetch.network.service';
70✔
4
import { NetworkService } from '@/datasources/network/network.service.interface';
70✔
5
import { NetworkResponse } from '@/datasources/network/entities/network.response.entity';
6
import {
70✔
7
  NetworkRequestError,
8
  NetworkResponseError,
9
} from '@/datasources/network/entities/network.error.entity';
10

11
export type FetchClient = <T>(
12
  url: string,
13
  options: RequestInit,
14
) => Promise<NetworkResponse<T>>;
15

16
/**
17
 * Use this factory to create a {@link FetchClient} instance
18
 * that can be used to make HTTP requests.
19
 */
20
function fetchClientFactory(
21
  configurationService: IConfigurationService,
22
): FetchClient {
23
  const requestTimeout = configurationService.getOrThrow<number>(
4✔
24
    'httpClient.requestTimeout',
25
  );
26

27
  return async <T>(
4✔
28
    url: string,
29
    options: RequestInit,
30
  ): Promise<NetworkResponse<T>> => {
31
    let urlObject: URL | null = null;
8✔
32
    let response: Response | null = null;
8✔
33

34
    try {
8✔
35
      urlObject = new URL(url);
8✔
36
      response = await fetch(url, {
6✔
37
        ...options,
38
        signal: AbortSignal.timeout(requestTimeout),
39
        keepalive: true,
40
      });
41
    } catch (error) {
42
      throw new NetworkRequestError(urlObject, error);
4✔
43
    }
44

45
    // We validate data so don't need worry about casting `null` response
46
    const data = (await response.json().catch(() => null)) as T;
4✔
47

48
    if (!response.ok) {
2✔
49
      throw new NetworkResponseError(urlObject, response, data);
2✔
50
    }
51

UNCOV
52
    return {
×
53
      status: response.status,
54
      data,
55
    };
56
  };
57
}
58

59
/**
60
 * A {@link Global} Module which provides HTTP support via {@link NetworkService}
61
 * Feature Modules don't need to import this module directly in order to inject
62
 * the {@link NetworkService}.
63
 *
64
 * This module should be included in the "root" application module
65
 */
66
@Global()
67
@Module({
68
  providers: [
69
    {
70
      provide: 'FetchClient',
71
      useFactory: fetchClientFactory,
72
      inject: [IConfigurationService],
73
    },
74
    { provide: NetworkService, useClass: FetchNetworkService },
75
  ],
76
  exports: [NetworkService],
77
})
78
export class NetworkModule {}
70✔
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