From 46722b32641ee54a4bf646731e45d6632a035b3b Mon Sep 17 00:00:00 2001 From: Moein zargarzadeh Date: Tue, 24 Sep 2024 11:25:29 +0330 Subject: [PATCH 1/2] add tokensMap version and contract version to info controller and update log when starting service for versions --- src/api/general.ts | 12 ++++++++++-- src/bootstrap.ts | 4 +++- src/config/rosenConfig.ts | 2 ++ src/config/tokensConfig.ts | 5 ++++- tests/config/contracts-ergo-mainnet.json | 1 + tests/config/tokens.test.json | 1 + tests/database/mockedData.ts | 7 ++++++- 7 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/api/general.ts b/src/api/general.ts index faa2045b..56e177c9 100644 --- a/src/api/general.ts +++ b/src/api/general.ts @@ -11,7 +11,11 @@ import { ERGO_CHAIN_NAME, ERGO_NATIVE_ASSET } from '../config/constants'; const logger = WinstonLogger.getInstance().getLogger(import.meta.url); interface GeneralInfo { - version: string; + versions: { + app: string; + contract: string; + tokensMap: string; + }; currentBalance: bigint; network: string; permitsPerEvent: bigint; @@ -42,7 +46,11 @@ generalRouter.get('/', async (req: Request, res: Response) => { const tokenMap = getConfig().token.tokenMap; const collateral = await Transaction.getInstance().getCollateral(); const info: GeneralInfo = { - version: packageJson.version, + versions: { + app: packageJson.version, + contract: getConfig().rosen.contractVersion, + tokensMap: getConfig().token.version, + }, currentBalance: tokenMap.wrapAmount( ERGO_NATIVE_ASSET, (await ErgoUtils.getWatcherBalance()).nanoErgs, diff --git a/src/bootstrap.ts b/src/bootstrap.ts index fd88ca05..4dd5a9bf 100644 --- a/src/bootstrap.ts +++ b/src/bootstrap.ts @@ -7,4 +7,6 @@ WinstonLogger.init(getConfig().logger.transports); const logger = WinstonLogger.getInstance().getLogger(import.meta.url); -logger.info(`Watcher Started with version ${packageJson.version}`); +logger.info(`Watcher version: ${packageJson.version}`); +logger.info(`Watcher contract version: ${getConfig().rosen.contractVersion}`); +logger.info(`Watcher tokens version: ${getConfig().token.version}`); diff --git a/src/config/rosenConfig.ts b/src/config/rosenConfig.ts index 240dcdfd..5658e1b4 100644 --- a/src/config/rosenConfig.ts +++ b/src/config/rosenConfig.ts @@ -22,6 +22,7 @@ class RosenConfig { readonly emissionNFT: string; readonly emissionAddress: string; readonly eRSN: string; + readonly contractVersion: string; constructor(network: string, networkType: string, configRoot: string) { const rosenConfigPath = this.getAddress(network, networkType, configRoot); @@ -52,6 +53,7 @@ class RosenConfig { this.emissionNFT = config.tokens.EmissionNFT; this.eRSN = config.tokens.ERSN; this.emissionAddress = config.addresses.Emission; + this.contractVersion = config.version; } } diff --git a/src/config/tokensConfig.ts b/src/config/tokensConfig.ts index f9d61665..918f4978 100644 --- a/src/config/tokensConfig.ts +++ b/src/config/tokensConfig.ts @@ -4,13 +4,16 @@ import { RosenTokens, TokenMap } from '@rosen-bridge/tokens'; class TokensConfig { readonly tokens: RosenTokens; readonly tokenMap: TokenMap; + readonly version: string; constructor(tokensPath: string) { if (!fs.existsSync(tokensPath)) { throw new Error(`tokensMap file with path ${tokensPath} doesn't exist`); } else { const tokensJson: string = fs.readFileSync(tokensPath, 'utf8'); - this.tokens = JSON.parse(tokensJson); + const tokens = JSON.parse(tokensJson); + this.tokens = tokens; + this.version = tokens.version; this.tokenMap = new TokenMap(this.tokens); } } diff --git a/tests/config/contracts-ergo-mainnet.json b/tests/config/contracts-ergo-mainnet.json index 91bc26a3..bb64a916 100644 --- a/tests/config/contracts-ergo-mainnet.json +++ b/tests/config/contracts-ergo-mainnet.json @@ -1,4 +1,5 @@ { + "version": "testVersion", "addresses": { "RWTRepo": "5qwczr7KdspMpxJYy77vzNv3a4qT2x1VuDj8u9y5ozV3AAQtESPpbsR1EMWATVDdj6jguyC8B8NmVzami197gVHH4dhLvzqTye236iqBf75rGzF6wykBFvhoR9ZAbbzo4nz9P76U66ShQiwP17LvKiQMtQbwnLjDUtb8YifJYgAU6DEDm66RMKqisuFgxJ5D4y2LxiMLyKWPaHBdccEKqDYeTwhiPqwkhhsU5MsTKkoS43jK6s7xCFtFDxYFN3WCpaP2qffQqK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yjmwyCwEurYafxqmyad9S2x9tXis1TyDo2KKG4vAWixgGfHLevhZGiPpUfFpsS23iyLxDt6diPdfDp", "WatcherPermit": "FxMs5S8B9DA3Ecw7taWSSRiaDkbYxxqsrwQKJVyJAbe7tBqLU4j3ry1En9AHn2d2XWEyj46FTHXM3RwxpLztvSJVQt76JY5jq3MF8TA9aWp2i134zDM8mm3zXH5RJXvRi7uit4QLHXhXvMp66fj9UaeK2UQSBVGXQbPKm9KkCCaVX66tLbJ3FFo58atK8VTvpFUfCPjLFn8U9sukxvfrVQwFFXSG753VLKFLzw614gmBrZFg6recogxyxuRSjCa42baii5i3cKTmwSARD38kFB1mftWGTUPRbV6kq3cz17CUtbCun6zKVFDqAMAKttEfbzknafAnudYVs1ijdc5kvAjDyWRaYVbjQt43oHhFGFpUrP9gae5HqrVpEJvcE551iV4L2yRfy35FdvPSTevkweANuZE58GA8i684FTQi7yWgRXRyaRsro4zXoXpgoizUJBCy76QUm27FN7bpHTH6GHRs3PW4x59Pu1BcdBMKz3yixyYK5eoxDau22a12bT", diff --git a/tests/config/tokens.test.json b/tests/config/tokens.test.json index c3b72d1f..0beb7641 100644 --- a/tests/config/tokens.test.json +++ b/tests/config/tokens.test.json @@ -1,4 +1,5 @@ { + "version": "testVersion", "idKeys": { "ergo": "tokenId", "cardano": "tokenId" diff --git a/tests/database/mockedData.ts b/tests/database/mockedData.ts index 25873e71..30188bb7 100644 --- a/tests/database/mockedData.ts +++ b/tests/database/mockedData.ts @@ -17,6 +17,7 @@ import { TokenEntity } from '../../src/database/entities/tokenEntity'; import { RevenueEntity } from '../../src/database/entities/revenueEntity'; import { firstPermit, secondPermit } from '../ergo/statistics/mockUtils'; import packageJson from '../../package.json' assert { type: 'json' }; +import { getConfig } from '../../src/config/config'; export const ergoBlockEntity = new BlockEntity(); ergoBlockEntity.scanner = Constants.ERGO_CHAIN_NAME; @@ -718,7 +719,11 @@ export const permitMockRWT = '8e5b02ba729ad364867619d2a8b9ff1438190c14979a12aa0a249e996194f074'; export const generalInfo = { - version: packageJson.version, + versions: { + app: packageJson.version, + contract: getConfig().rosen.contractVersion, + tokensMap: getConfig().token.version, + }, currentBalance: 1100000, network: 'ergo', permitsPerEvent: 10000, From d336cf2b4ad42301671a8ff624762f61c9a5a659 Mon Sep 17 00:00:00 2001 From: Moein zargarzadeh Date: Tue, 24 Sep 2024 11:25:42 +0330 Subject: [PATCH 2/2] add changelog --- .changeset/bright-zebras-visit.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/bright-zebras-visit.md diff --git a/.changeset/bright-zebras-visit.md b/.changeset/bright-zebras-visit.md new file mode 100644 index 00000000..44e5c17c --- /dev/null +++ b/.changeset/bright-zebras-visit.md @@ -0,0 +1,5 @@ +--- +'@rosen-bridge/watcher': major +--- + +support contract and tokensMap version and update info controller for version configs