Skip to content

Commit

Permalink
Merge branch 'fix-package-json-import' into 'dev'
Browse files Browse the repository at this point in the history
fix package.json import in generalInfo api

See merge request ergo/rosen-bridge/guard-service!332
  • Loading branch information
vorujack committed Mar 15, 2024
2 parents 664e513 + ddb4f60 commit 57026e2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .changeset/big-bags-double.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
6 changes: 4 additions & 2 deletions src/api/generalInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
} from './schemas';
import { rosenConfig } from '../configs/RosenConfig';
import WinstonLogger from '@rosen-bridge/winston-logger';
import packageJson from '../../package.json';
import Utils from '../utils/Utils';

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

Expand Down Expand Up @@ -79,7 +79,9 @@ const infoRoute = (server: FastifySeverInstance) => {
}

reply.status(200).send({
version: packageJson.version,
// TODO: Update dependencies like typescript and vitest
// local:ergo/rosen-bridge/guard-service#364
version: Utils.readJsonFile('./package.json').version,
health: (await (await getHealthCheck()).getOverallHealthStatus())
.status,
rsnTokenId: rosenConfig.RSN,
Expand Down
11 changes: 10 additions & 1 deletion src/utils/Utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Buffer } from 'buffer';
import Encryption from './Encryption';
import { TokenInfo } from '@rosen-chains/abstract-chain';
import { DerivationPath, ExtSecretKey, Mnemonic } from 'ergo-lib-wasm-nodejs';
import fs from 'fs';

class Utils {
/**
Expand Down Expand Up @@ -33,6 +33,15 @@ class Utils {
const secretKeyBytes = rootSecret.derive(changePath).secret_key_bytes();
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);
};
}

export default Utils;

0 comments on commit 57026e2

Please sign in to comment.