@@ -13,6 +13,7 @@ import (
1313 "kubecloud/internal/core/services"
1414 "kubecloud/internal/core/workers"
1515 grid "kubecloud/internal/infrastructure/grid"
16+ "kubecloud/internal/infrastructure/gridclient"
1617 "kubecloud/internal/infrastructure/kyc"
1718 "kubecloud/internal/infrastructure/logger"
1819 "kubecloud/internal/infrastructure/mailservice"
@@ -22,7 +23,6 @@ import (
2223 "kubecloud/internal/infrastructure/notification"
2324 "kubecloud/internal/infrastructure/persistence"
2425 "kubecloud/internal/infrastructure/realtime"
25- "kubecloud/internal/infrastructure/substrate"
2626 "kubecloud/internal/infrastructure/telemetry"
2727
2828 sdktrace "go.opentelemetry.io/otel/sdk/trace"
@@ -87,10 +87,9 @@ type appCommunication struct {
8787
8888// appInfrastructure contains grid and blockchain related services
8989type appInfrastructure struct {
90- gridClient deployer. TFPluginClient
90+ gridClient gridclient. GridClient
9191 firesquidClient graphql.GraphQl
9292 graphql graphql.GraphQl
93- substrateClient substrate.Substrate
9493}
9594
9695func createAppDependencies (ctx context.Context , config cfg.Configuration ) (appDependencies , error ) {
@@ -269,24 +268,22 @@ func createAppCommunication(config cfg.Configuration, db models.DB, ewfEngine *e
269268}
270269
271270func createAppInfrastructure (config cfg.Configuration , tp * sdktrace.TracerProvider ) (appInfrastructure , error ) {
272- pluginOpts := []deployer.PluginOpt {
273- deployer .WithNetwork (config .SystemAccount .Network ),
274- deployer .WithDisableSentry (),
271+
272+ clientOpts := []gridclient.ClientOpts {
273+ gridclient .WithTracerProvider (tp ),
274+ gridclient .WithNetwork (config .SystemAccount .Network ),
275275 }
276276 if config .Debug {
277- pluginOpts = append (pluginOpts , deployer . WithLogs ())
277+ clientOpts = append (clientOpts , gridclient . WithDebug ())
278278 }
279-
280- if tp != nil {
281- pluginOpts = append (pluginOpts , deployer .WithTraceProvider (tp ))
279+ if config .DisableSentry {
280+ clientOpts = append (clientOpts , gridclient .WithDisableSentry ())
282281 }
283282
284- gridClient , err := deployer .NewTFPluginClient (
285- config .SystemAccount .Mnemonic ,
286- pluginOpts ... ,
287- )
283+ gridClient , err := gridclient .NewGridClient (config .SystemAccount .Mnemonic , clientOpts ... )
284+
288285 if err != nil {
289- return appInfrastructure {}, fmt .Errorf ("failed to create TF grid client: %w" , err )
286+ return appInfrastructure {}, fmt .Errorf ("failed to create grid client: %w" , err )
290287 }
291288
292289 fireSquidClient , err := graphql .NewGraphQl (grid .FireSquidURLs [config .SystemAccount .Network ]... )
@@ -300,19 +297,10 @@ func createAppInfrastructure(config cfg.Configuration, tp *sdktrace.TracerProvid
300297 return appInfrastructure {}, fmt .Errorf ("failed to connect to TF graphql: %w" , err )
301298 }
302299
303- tfChainClient , err := substrate .NewTFChainClient (
304- config .SystemAccount .Network , config .SystemAccount .Mnemonic ,
305- config .TermsANDConditions .DocumentLink , config .TermsANDConditions .DocumentHash ,
306- )
307- if err != nil {
308- return appInfrastructure {}, fmt .Errorf ("failed to create tf chain client: %w" , err )
309- }
310-
311300 return appInfrastructure {
312301 gridClient : gridClient ,
313302 graphql : graphQl ,
314303 firesquidClient : fireSquidClient ,
315- substrateClient : tfChainClient ,
316304 }, nil
317305}
318306
@@ -332,27 +320,24 @@ func (app *App) createHandlers() appHandlers {
332320 // Services
333321 userService := services .NewUserService (
334322 app .core .appCtx , userRepo , voucherRepo , pendingRecordRepo ,
335- app .infra .substrateClient , app .core .ewfEngine ,
323+ app .infra .gridClient , app .core .ewfEngine ,
336324 app .security .kycClient , app .core .metrics , app .config .MailSender .TimeoutMin ,
337325 app .config .Admins ,
338326 )
339327
340328 statsService := services .NewStatsService (
341- userRepo , clusterRepo , app .infra .gridClient .GridProxyClient ,
342- app .infra .substrateClient , app .config .SystemAccount .Mnemonic ,
329+ userRepo , clusterRepo , app .infra .gridClient , app .config .SystemAccount .Mnemonic ,
343330 )
344331
345332 notificationAPIService := services .NewNotificationService (notificationRepo )
346333
347334 nodeService := services .NewNodeService (
348335 userNodesRepo , userRepo , app .core .appCtx , app .core .ewfEngine ,
349- app .infra .gridClient , app . infra . substrateClient ,
336+ app .infra .gridClient ,
350337 )
351338
352339 invoiceService := services .NewInvoiceService (
353- invoiceRepo , userRepo , userNodesRepo ,
354- app .infra .firesquidClient , app .infra .graphql , app .infra .substrateClient ,
355- app .config .Invoice ,
340+ invoiceRepo , userRepo , app .config .Invoice ,
356341 )
357342
358343 deploymentService := services .NewDeploymentService (
@@ -362,7 +347,7 @@ func (app *App) createHandlers() appHandlers {
362347
363348 adminService := services .NewAdminService (
364349 app .core .appCtx , userRepo , userNodesRepo , pendingRecordRepo , voucherRepo ,
365- transactionRepo , app .infra .substrateClient , app .core .ewfEngine , app .communication .mailService , app .communication .notificationDispatcher , ewfRepo ,
350+ transactionRepo , app .infra .gridClient , app .core .ewfEngine , app .communication .mailService , app .communication .notificationDispatcher , ewfRepo ,
366351 )
367352
368353 settingsService := services .NewSettingsService (settingsRepo )
@@ -406,7 +391,7 @@ func (app *App) createWorkers() workers.Workers {
406391 app .core .appCtx , userRepo , userNodesRepo , invoiceRepo , clusterRepo , pendingRecordRepo ,
407392 app .communication .mailService , app .infra .gridClient , app .core .ewfEngine ,
408393 app .communication .notificationDispatcher , app .infra .graphql , app .infra .firesquidClient ,
409- app .infra . substrateClient , app . config .Invoice , app .config .SystemAccount .Mnemonic ,
394+ app .config .Invoice , app .config .SystemAccount .Mnemonic ,
410395 app .config .Currency , app .config .ClusterHealthCheckIntervalInHours ,
411396 app .config .NodeHealthCheck .ReservedNodeHealthCheckIntervalInHours , app .config .NodeHealthCheck .ReservedNodeHealthCheckTimeoutInMinutes , app .config .NodeHealthCheck .ReservedNodeHealthCheckWorkersNum , app .config .MonitorBalanceIntervalInMinutes , app .config .NotifyAdminsForPendingRecordsInHours , app .config .UsersBalanceCheckIntervalInHours , app .config .CheckUserDebtIntervalInHours ,
412397 )
0 commit comments