Skip to content

Commit

Permalink
Merge branch '255-add-contract-tokens-version' into 'dev'
Browse files Browse the repository at this point in the history
add tokensMap version and contract version to info controller and update log...

Closes #255

See merge request ergo/rosen-bridge/watcher!302
  • Loading branch information
vorujack committed Sep 24, 2024
2 parents a673947 + d336cf2 commit d02303c
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/bright-zebras-visit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rosen-bridge/watcher': major
---

support contract and tokensMap version and update info controller for version configs
12 changes: 10 additions & 2 deletions src/api/general.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion src/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
2 changes: 2 additions & 0 deletions src/config/rosenConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
}

Expand Down
5 changes: 4 additions & 1 deletion src/config/tokensConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
1 change: 1 addition & 0 deletions tests/config/contracts-ergo-mainnet.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"version": "testVersion",
"addresses": {
"RWTRepo": "5qwczr7KdspMpxJYy77vzNv3a4qT2x1VuDj8u9y5ozV3AAQtESPpbsR1EMWATVDdj6jguyC8B8NmVzami197gVHH4dhLvzqTye236iqBf75rGzF6wykBFvhoR9ZAbbzo4nz9P76U66ShQiwP17LvKiQMtQbwnLjDUtb8YifJYgAU6DEDm66RMKqisuFgxJ5D4y2LxiMLyKWPaHBdccEKqDYeTwhiPqwkhhsU5MsTKkoS43jK6s7xCFtFDxYFN3WCpaP2qffQqKvdFxaPp91UwHSBLzfRQsjq5hiMj7XnqKR2yUKdgEaY5VHLGY4opjgqnzPVBH28U3K6xpMxNgtg2W3siLLXqehST1YbAAx5rqyWg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3Ecw7taWSSRiaDkbYxxqsrwQKJVyJAbe7tBqLU4j3ry1En9AHn2d2XWEyj46FTHXM3RwxpLztvSJVQt76JY5jq3MF8TA9aWp2i134zDM8mm3zXH5RJXvRi7uit4QLHXhXvMp66fj9UaeK2UQSBVGXQbPKm9KkCCaVX66tLbJ3FFo58atK8VTvpFUfCPjLFn8U9sukxvfrVQwFFXSG753VLKFLzw614gmBrZFg6recogxyxuRSjCa42baii5i3cKTmwSARD38kFB1mftWGTUPRbV6kq3cz17CUtbCun6zKVFDqAMAKttEfbzknafAnudYVs1ijdc5kvAjDyWRaYVbjQt43oHhFGFpUrP9gae5HqrVpEJvcE551iV4L2yRfy35FdvPSTevkweANuZE58GA8i684FTQi7yWgRXRyaRsro4zXoXpgoizUJBCy76QUm27FN7bpHTH6GHRs3PW4x59Pu1BcdBMKz3yixyYK5eoxDau22a12bT",
Expand Down
1 change: 1 addition & 0 deletions tests/config/tokens.test.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"version": "testVersion",
"idKeys": {
"ergo": "tokenId",
"cardano": "tokenId"
Expand Down
7 changes: 6 additions & 1 deletion tests/database/mockedData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit d02303c

Please sign in to comment.