Skip to content

Commit

Permalink
enhance the process of reading JSON files to align with the node upgr…
Browse files Browse the repository at this point in the history
…ade to 20.
  • Loading branch information
zargarzadehm committed Dec 16, 2024
1 parent 48fe876 commit 4b58607
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 18 deletions.
6 changes: 2 additions & 4 deletions src/api/generalInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import { rosenConfig } from '../configs/RosenConfig';
import { DefaultLoggerFactory } from '@rosen-bridge/abstract-logger';
import { getTokenData } from '../utils/getTokenData';
import GuardsErgoConfigs from '../configs/GuardsErgoConfigs';
import Utils from '../utils/Utils';
import Configs from '../configs/Configs';
import packageJson from '../../package.json' assert { type: 'json' };

const logger = DefaultLoggerFactory.getInstance().getLogger(import.meta.url);

Expand Down Expand Up @@ -85,10 +85,8 @@ const infoRoute = (server: FastifySeverInstance) => {
const trialErrors = await healthCheck.getTrialErrors();

reply.status(200).send({
// TODO: Update dependencies like typescript and vitest
// local:ergo/rosen-bridge/guard-service#364
versions: {
app: Utils.readJsonFile('./package.json').version,
app: packageJson.version,
contract: rosenConfig.contractVersion,
tokensMap: Configs.tokensVersion,
},
Expand Down
6 changes: 2 additions & 4 deletions src/bootstrap.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'reflect-metadata';
import Configs from './configs/Configs';
import packageJson from '../package.json' assert { type: 'json' };
import WinstonLogger from '@rosen-bridge/winston-logger';
import Utils from './utils/Utils';
import { rosenConfig } from './configs/RosenConfig';
import { DefaultLoggerFactory } from '@rosen-bridge/abstract-logger';

Expand All @@ -10,8 +10,6 @@ DefaultLoggerFactory.init(winston);

const logger = DefaultLoggerFactory.getInstance().getLogger(import.meta.url);

const version = Utils.readJsonFile('./package.json').version;

logger.info(`Guard version: ${version}`);
logger.info(`Guard version: ${packageJson.version}`);
logger.info(`Guard contract version: ${rosenConfig.contractVersion}`);
logger.info(`Guard tokens version: ${Configs.tokensVersion}`);
10 changes: 0 additions & 10 deletions src/utils/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { blake2b } from 'blakejs';
import { Buffer } from 'buffer';
import Encryption from './Encryption';
import { DerivationPath, ExtSecretKey, Mnemonic } from 'ergo-lib-wasm-nodejs';
import fs from 'fs';

class Utils {
/**
Expand Down Expand Up @@ -36,15 +35,6 @@ class Utils {
return Buffer.from(secretKeyBytes).toString('hex');
};

/**
* read jsonFile
* @param filePath string
*/
static readJsonFile = (filePath: string): any => {
const jsonData = fs.readFileSync(filePath, 'utf8');
return JSON.parse(jsonData);
};

/**
* returns the decoded bigint input
* @param num
Expand Down

0 comments on commit 4b58607

Please sign in to comment.