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

decentraland / transactions-server / 11860032260

15 Nov 2024 04:39PM UTC coverage: 74.198% (+3.4%) from 70.825%
11860032260

push

github

web-flow
Merge pull request #119 from decentraland/feat/implement-gelatto

feat: Implement Gelato

95 of 131 branches covered (72.52%)

Branch coverage included in aggregate %.

171 of 186 new or added lines in 20 files covered. (91.94%)

5 existing lines in 3 files now uncovered.

414 of 555 relevant lines covered (74.59%)

4.47 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'
NEW
23
import { createBiconomyComponent } from './ports/biconomy'
×
NEW
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

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

NEW
105
  const biconomy = createBiconomyComponent({ logs, config, fetcher, metrics })
×
NEW
106
  const gelato = createGelatoComponent({ logs, config, fetcher, metrics })
×
107

UNCOV
108
  const transaction = createTransactionComponent({
×
109
    config,
110
    features,
111
    fetcher,
112
    logs,
113
    pg,
114
    biconomy,
115
    gelato,
116
    contracts,
117
    metrics,
118
  })
119
  const globalLogger = logs.getLogger('transactions-server')
×
120

121
  return {
×
122
    config,
123
    logs,
124
    globalLogger,
125
    fetcher,
126
    features,
127
    metrics,
128
    server,
129
    pg,
130
    biconomy,
131
    gelato,
132
    transaction,
133
    contracts,
134
    collectionsSubgraph,
135
    statusChecks,
136
  }
137
}
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