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

decentraland / transactions-server / 11861532026

15 Nov 2024 06:29PM UTC coverage: 64.629% (-9.6%) from 74.198%
11861532026

push

github

web-flow
Merge pull request #120 from decentraland/fix/update-tests

fix: Update tests

95 of 135 branches covered (70.37%)

Branch coverage included in aggregate %.

20 of 23 new or added lines in 4 files covered. (86.96%)

62 existing lines in 9 files now uncovered.

349 of 552 relevant lines covered (63.22%)

3.5 hits per line

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

0.0
/src/components.ts
1
import path from 'path'
×
2
import { createDotEnvConfigComponent } from '@well-known-components/env-config-provider'
×
3
import {
×
4
  createServerComponent,
5
  createStatusCheckComponent,
6
} from '@well-known-components/http-server'
7
import { createTracerComponent } from '@well-known-components/tracer-component'
×
8
import { createLogComponent } from '@well-known-components/logger'
×
9
import { createMetricsComponent } from '@well-known-components/metrics'
×
10
import { createSubgraphComponent } from '@well-known-components/thegraph-component'
×
11
import { createHttpTracerComponent } from '@well-known-components/http-tracer-component'
×
12
import {
×
13
  instrumentHttpServerWithRequestLogger,
14
  Verbosity,
15
} from '@well-known-components/http-requests-logger-component'
16
import { createPgComponent } from '@well-known-components/pg-component'
×
17
import { createContractsComponent } from './ports/contracts/component'
×
18
import { createFetchComponent } from './ports/fetcher'
×
19
import { createFeaturesComponent } from './ports/features'
×
20
import { createTransactionComponent } from './ports/transaction/component'
×
21
import { metricDeclarations } from './metrics'
×
22
import { AppComponents, GlobalContext } from './types'
23
import { createBiconomyComponent } from './ports/biconomy'
×
24
import { createGelatoComponent } from './ports/gelato'
×
25

26
export async function initComponents(): Promise<AppComponents> {
×
27
  // default config from process.env + .env file
28
  const config = await createDotEnvConfigComponent(
×
29
    { path: ['.env.defaults', '.env'] },
30
    process.env
31
  )
32

33
  const cors = {
×
34
    origin: (await config.requireString('CORS_ORIGIN'))
35
      .split(';')
36
      .map((origin) => new RegExp(origin)),
×
37
    method: await config.getString('CORS_METHOD'),
38
  }
39

40
  const tracer = createTracerComponent()
×
41

42
  const logs = await createLogComponent({ config, tracer })
×
43
  const server = await createServerComponent<GlobalContext>(
×
44
    { config, logs },
45
    { cors, compression: {} }
46
  )
47
  createHttpTracerComponent({ server, tracer })
×
48
  instrumentHttpServerWithRequestLogger(
×
49
    { server, logger: logs },
50
    { verbosity: Verbosity.INFO }
51
  )
52
  const statusChecks = await createStatusCheckComponent({ config, server })
×
53
  const fetcher = await createFetchComponent({ tracer })
×
54
  const features = await createFeaturesComponent(
×
55
    {
56
      config,
57
      logs,
58
      fetch: fetcher,
59
    },
60
    await config.requireString('TRANSACTIONS_SERVER_URL')
61
  )
62
  const metrics = await createMetricsComponent(metricDeclarations, {
×
63
    server,
64
    config,
65
  })
66

67
  let databaseUrl: string | undefined = await config.getString(
×
68
    'PG_COMPONENT_PSQL_CONNECTION_STRING'
69
  )
70

71
  if (!databaseUrl) {
×
72
    const dbUser = await config.requireString('PG_COMPONENT_PSQL_USER')
×
73
    const dbDatabaseName = await config.requireString(
×
74
      'PG_COMPONENT_PSQL_DATABASE'
75
    )
76
    const dbPort = await config.requireString('PG_COMPONENT_PSQL_PORT')
×
77
    const dbHost = await config.requireString('PG_COMPONENT_PSQL_HOST')
×
78
    const dbPassword = await config.requireString('PG_COMPONENT_PSQL_PASSWORD')
×
79
    databaseUrl = `postgres://${dbUser}:${dbPassword}@${dbHost}:${dbPort}/${dbDatabaseName}`
×
80
  }
81

82
  const pg = await createPgComponent(
×
83
    { logs, config, metrics },
84
    {
85
      migration: {
86
        databaseUrl,
87
        dir: path.resolve(__dirname, 'migrations'),
88
        migrationsTable: 'pgmigrations',
89
        ignorePattern: '.*\\.map',
90
        direction: 'up',
91
      },
92
    }
93
  )
94
  const collectionsSubgraph = await createSubgraphComponent(
×
95
    { config, logs, fetch: fetcher, metrics },
96
    await config.requireString('COLLECTIONS_SUBGRAPH_URL')
97
  )
98

NEW
99
  const contracts = await createContractsComponent({
×
100
    config,
101
    fetcher,
102
    collectionsSubgraph,
103
  })
104

NEW
105
  const biconomy = await createBiconomyComponent({
×
106
    logs,
107
    config,
108
    fetcher,
109
    metrics,
110
  })
NEW
111
  const gelato = await createGelatoComponent({ logs, config, fetcher, metrics })
×
112

113
  const transaction = createTransactionComponent({
×
114
    config,
115
    features,
116
    fetcher,
117
    logs,
118
    pg,
119
    biconomy,
120
    gelato,
121
    contracts,
122
    metrics,
123
  })
124
  const globalLogger = logs.getLogger('transactions-server')
×
125

126
  return {
×
127
    config,
128
    logs,
129
    globalLogger,
130
    fetcher,
131
    features,
132
    metrics,
133
    server,
134
    pg,
135
    biconomy,
136
    gelato,
137
    transaction,
138
    contracts,
139
    collectionsSubgraph,
140
    statusChecks,
141
  }
142
}
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