mirror of
https://github.com/IT4Change/gradido.git
synced 2026-02-06 09:56:05 +00:00
fix lint
This commit is contained in:
parent
1560486dd3
commit
7ef816ea80
@ -1,7 +1,7 @@
|
||||
import { BackendClient } from '../client/backend/BackendClient'
|
||||
import { HieroClient } from '../client/hiero/HieroClient'
|
||||
import { GradidoNodeClient } from '../client/GradidoNode/GradidoNodeClient'
|
||||
import { KeyPairCacheManager } from '../cache/KeyPairCacheManager'
|
||||
import { BackendClient } from '../client/backend/BackendClient'
|
||||
import { GradidoNodeClient } from '../client/GradidoNode/GradidoNodeClient'
|
||||
import { HieroClient } from '../client/hiero/HieroClient'
|
||||
|
||||
export type AppContextClients = {
|
||||
backend: BackendClient
|
||||
@ -23,4 +23,4 @@ export function createAppContext(): AppContext {
|
||||
gradidoNode: GradidoNodeClient.getInstance(),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { CONFIG } from '../config'
|
||||
import { configure, getLogger, Logger } from 'log4js'
|
||||
import { loadCryptoKeys, MemoryBlock } from 'gradido-blockchain-js'
|
||||
import { type AppContext, type AppContextClients } from './appContext'
|
||||
import { MIN_TOPIC_EXPIRE_MILLISECONDS_FOR_UPDATE } from '../config/const'
|
||||
import { configure, getLogger, Logger } from 'log4js'
|
||||
import * as v from 'valibot'
|
||||
import { CONFIG } from '../config'
|
||||
import { MIN_TOPIC_EXPIRE_MILLISECONDS_FOR_UPDATE } from '../config/const'
|
||||
import { SendToHieroContext } from '../interactions/sendToHiero/SendToHiero.context'
|
||||
import { Community, communitySchema } from '../schemas/transaction.schema'
|
||||
import { isPortOpenRetry } from '../utils/network'
|
||||
import { SendToHieroContext } from '../interactions/sendToHiero/SendToHiero.context'
|
||||
import { type AppContext, type AppContextClients } from './appContext'
|
||||
|
||||
export function loadConfig(): Logger {
|
||||
// configure log4js
|
||||
@ -29,7 +29,10 @@ export async function checkHieroAccount(logger: Logger, clients: AppContextClien
|
||||
logger.info(`Hiero Account Balance: ${balance.hbars.toString()}`)
|
||||
}
|
||||
|
||||
export async function checkHomeCommunity(appContext: AppContext, logger: Logger): Promise<Community> {
|
||||
export async function checkHomeCommunity(
|
||||
appContext: AppContext,
|
||||
logger: Logger,
|
||||
): Promise<Community> {
|
||||
const { backend, hiero } = appContext.clients
|
||||
|
||||
// wait for backend server
|
||||
@ -66,16 +69,23 @@ export async function checkHomeCommunity(appContext: AppContext, logger: Logger)
|
||||
return v.parse(communitySchema, homeCommunity)
|
||||
}
|
||||
|
||||
export async function checkGradidoNode(clients: AppContextClients, logger: Logger, homeCommunity: Community): Promise<void> {
|
||||
export async function checkGradidoNode(
|
||||
clients: AppContextClients,
|
||||
logger: Logger,
|
||||
homeCommunity: Community,
|
||||
): Promise<void> {
|
||||
// ask gradido node if community blockchain was created
|
||||
try {
|
||||
if (
|
||||
!(await clients.gradidoNode.getTransaction({ transactionId: 1, topic: homeCommunity.hieroTopicId }))
|
||||
) {
|
||||
// if not exist, create community root transaction
|
||||
await SendToHieroContext(homeCommunity)
|
||||
}
|
||||
} catch (e) {
|
||||
logger.error(`error requesting gradido node: ${e}`)
|
||||
try {
|
||||
if (
|
||||
!(await clients.gradidoNode.getTransaction({
|
||||
transactionId: 1,
|
||||
topic: homeCommunity.hieroTopicId,
|
||||
}))
|
||||
) {
|
||||
// if not exist, create community root transaction
|
||||
await SendToHieroContext(homeCommunity)
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
logger.error(`error requesting gradido node: ${e}`)
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,4 +25,4 @@ export function setupGracefulShutdown(logger: Logger, clients: AppContextClients
|
||||
async function gracefulShutdown(logger: Logger, clients: AppContextClients) {
|
||||
logger.info('graceful shutdown')
|
||||
await clients.hiero.waitForPendingPromises()
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,9 +1,14 @@
|
||||
import { Elysia } from 'elysia'
|
||||
import { createAppContext } from './bootstrap/appContext'
|
||||
import {
|
||||
checkGradidoNode,
|
||||
checkHieroAccount,
|
||||
checkHomeCommunity,
|
||||
loadConfig,
|
||||
} from './bootstrap/init'
|
||||
import { setupGracefulShutdown } from './bootstrap/shutdown'
|
||||
import { CONFIG } from './config'
|
||||
import { appRoutes } from './server'
|
||||
import { setupGracefulShutdown } from './bootstrap/shutdown'
|
||||
import { createAppContext } from './bootstrap/appContext'
|
||||
import { checkHieroAccount, checkHomeCommunity, checkGradidoNode, loadConfig } from './bootstrap/init'
|
||||
|
||||
async function main() {
|
||||
// load log4js-config, logger and gradido-blockchain-js crypto keys
|
||||
@ -20,7 +25,7 @@ async function main() {
|
||||
// ask gradido node if community blockchain was created
|
||||
// if not exist, create community root transaction
|
||||
await checkGradidoNode(appContext.clients, logger, homeCommunity)
|
||||
|
||||
|
||||
// listen for rpc request from backend (graphql replaced with elysiaJS)
|
||||
new Elysia().use(appRoutes).listen(CONFIG.DLT_CONNECTOR_PORT, () => {
|
||||
logger.info(`Server is running at http://localhost:${CONFIG.DLT_CONNECTOR_PORT}`)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user