Skip to content

Commit

Permalink
Merge branch 'dev' into 'master'
Browse files Browse the repository at this point in the history
Merge dev into master branch

See merge request ergo/rosen-bridge/ui!397
  • Loading branch information
zargarzadehm committed Dec 25, 2024
2 parents 60a637d + 4681f15 commit 35c0cee
Show file tree
Hide file tree
Showing 201 changed files with 1,845 additions and 2,227 deletions.
File renamed without changes.
9 changes: 9 additions & 0 deletions apps/guard/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# @rosen-bridge/guard-app

## 1.9.1

### Patch Changes

- Integrated the Version component in the SideBar to display version information optimized for both desktop and mobile views.
- Updated dependencies
- @rosen-bridge/icons@1.0.0
- @rosen-bridge/ui-kit@1.7.0

## 1.9.0

### Minor Changes
Expand Down
45 changes: 22 additions & 23 deletions apps/guard/app/SideBar.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Link from 'next/link';
import { usePathname, useRouter } from 'next/navigation';
import { useMemo, useState } from 'react';

import {
BitcoinCircle,
Expand All @@ -14,6 +15,7 @@ import {
AppLogo,
NavigationBar,
NavigationButton,
Version,
} from '@rosen-bridge/ui-kit';

import packageJson from '../package.json';
Expand Down Expand Up @@ -62,28 +64,25 @@ export const SideBar = () => {

const { data: info, isLoading } = useInfo();

const versions = [
{
title: 'Guard',
value: info?.versions.app,
important: true,
},
{
title: 'UI',
value: packageJson.version,
},
{
title: 'Contract',
value: info?.versions.contract,
},
];

if (!isLoading && info?.versions.contract !== info?.versions.tokensMap) {
versions.push({
title: 'Tokens',
value: info?.versions.tokensMap,
});
}
const sub = useMemo(() => {
const result = [
{
label: 'UI',
value: packageJson.version,
},
{
label: 'Contract',
value: info?.versions.contract,
},
];
if (!isLoading && info?.versions.contract !== info?.versions.tokensMap) {
result.push({
label: 'Tokens',
value: info?.versions.tokensMap,
});
}
return result;
}, [info, isLoading]);

return (
<AppBar
Expand All @@ -97,7 +96,7 @@ export const SideBar = () => {
/>
</Link>
}
versions={versions}
versions={<Version label="Guard" value={info?.versions.app} sub={sub} />}
navigationBar={
<NavigationBar>
{routes.map((route) => (
Expand Down
6 changes: 3 additions & 3 deletions apps/guard/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rosen-bridge/guard-app",
"version": "1.9.0",
"version": "1.9.1",
"private": true,
"scripts": {
"prettify": "prettier --write . --ignore-path ../../.gitignore",
Expand All @@ -14,9 +14,9 @@
"dependencies": {
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@rosen-bridge/icons": "^0.7.0",
"@rosen-bridge/icons": "^1.0.0",
"@rosen-bridge/shared-contexts": "^0.0.2",
"@rosen-bridge/ui-kit": "^1.6.0",
"@rosen-bridge/ui-kit": "^1.7.0",
"@rosen-ui/constants": "^0.0.5",
"@rosen-ui/swr-helpers": "^0.2.0",
"@rosen-ui/utils": "^0.4.2",
Expand Down
6 changes: 6 additions & 0 deletions apps/rosen-service/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @rosen-bridge/rosen-service

## 2.2.0

### Minor Changes

- Add binance chain scanner with observation and event trigger extractors

## 2.1.0

### Minor Changes
Expand Down
10 changes: 10 additions & 0 deletions apps/rosen-service/config/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ ethereum:
rwt:
initialHeight:
rpcUrl: https://eth-mainnet.public.blastapi.io
binance:
addresses:
lock:
eventTrigger:
permit:
fraud:
tokens:
rwt:
initialHeight:
rpcUrl: https://bsc-mainnet.public.blastapi.io/
# rpcAuthToken:
postgres:
url: # postgresql://username:password@host:port/databasename
Expand Down
2 changes: 1 addition & 1 deletion apps/rosen-service/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rosen-bridge/rosen-service",
"version": "2.1.0",
"version": "2.2.0",
"private": true,
"license": "GPL-3.0",
"author": "Rosen Team",
Expand Down
24 changes: 20 additions & 4 deletions apps/rosen-service/src/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const getConfig = () => {
addresses: {
lock: nodeConfig.get<string>('cardano.addresses.lock'),
eventTrigger: nodeConfig.get<string>(
'cardano.addresses.eventTrigger',
'cardano.addresses.eventTrigger'
),
permit: nodeConfig.get<string>('cardano.addresses.permit'),
fraud: nodeConfig.get<string>('cardano.addresses.fraud'),
Expand All @@ -49,7 +49,7 @@ const getConfig = () => {
addresses: {
lock: nodeConfig.get<string>('bitcoin.addresses.lock'),
eventTrigger: nodeConfig.get<string>(
'bitcoin.addresses.eventTrigger',
'bitcoin.addresses.eventTrigger'
),
permit: nodeConfig.get<string>('bitcoin.addresses.permit'),
fraud: nodeConfig.get<string>('bitcoin.addresses.fraud'),
Expand All @@ -67,7 +67,7 @@ const getConfig = () => {
addresses: {
lock: nodeConfig.get<string>('ethereum.addresses.lock'),
eventTrigger: nodeConfig.get<string>(
'ethereum.addresses.eventTrigger',
'ethereum.addresses.eventTrigger'
),
permit: nodeConfig.get<string>('ethereum.addresses.permit'),
fraud: nodeConfig.get<string>('ethereum.addresses.fraud'),
Expand All @@ -79,6 +79,22 @@ const getConfig = () => {
rpcUrl: nodeConfig.get<string>('ethereum.rpcUrl'),
rpcAuthToken: getOptionalString('ethereum.rpcAuthToken'),
},
binance: {
addresses: {
lock: nodeConfig.get<string>('binance.addresses.lock'),
eventTrigger: nodeConfig.get<string>(
'binance.addresses.eventTrigger'
),
permit: nodeConfig.get<string>('binance.addresses.permit'),
fraud: nodeConfig.get<string>('binance.addresses.fraud'),
},
initialHeight: nodeConfig.get<number>('binance.initialHeight'),
tokens: {
rwt: nodeConfig.get<string>('binance.tokens.rwt'),
},
rpcUrl: nodeConfig.get<string>('binance.rpcUrl'),
rpcAuthToken: getOptionalString('binance.rpcAuthToken'),
},
postgres: {
url: nodeConfig.get<string>('postgres.url'),
logging: nodeConfig.get<boolean>('postgres.logging'),
Expand All @@ -98,7 +114,7 @@ const getConfig = () => {
`an error occurred reading some service configs: ${error}`,
false,
'error',
error instanceof Error ? error.stack : undefined,
error instanceof Error ? error.stack : undefined
);
}
};
Expand Down
2 changes: 2 additions & 0 deletions apps/rosen-service/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ export const ERGO_SCANNER_INTERVAL = 2 * 60 * 1000;
export const CARDANO_SCANNER_INTERVAL = 30 * 1000;
export const BITCOIN_SCANNER_INTERVAL = 10 * 60 * 1000;
export const ETHEREUM_SCANNER_INTERVAL = 60 * 1000;
export const BINANCE_SCANNER_INTERVAL = 10 * 1000;
export const ASSET_CALCULATOR_INTERVAL = 30 * 1000;

export const ERGO_SCANNER_LOGGER_NAME = 'ergo-scanner';
export const CARDANO_SCANNER_LOGGER_NAME = 'cardano-scanner';
export const BITCOIN_SCANNER_LOGGER_NAME = 'bitcoin-scanner';
export const ETHEREUM_SCANNER_LOGGER_NAME = 'ethereum-scanner';
export const BINANCE_SCANNER_LOGGER_NAME = 'binance-scanner';
15 changes: 15 additions & 0 deletions apps/rosen-service/src/event-trigger/event-trigger-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const bitcoinEventTriggerExtractorLogger =
WinstonLogger.getInstance().getLogger('bitcoin-event-trigger-extractor');
const ethereumEventTriggerExtractorLogger =
WinstonLogger.getInstance().getLogger('ethereum-event-trigger-extractor');
const binanceEventTriggerExtractorLogger =
WinstonLogger.getInstance().getLogger('binance-event-trigger-extractor');

/**
* register event trigger extractors for all chains
Expand Down Expand Up @@ -68,11 +70,23 @@ export const registerExtractors = (scanner: ErgoScanner) => {
configs.ethereum.addresses.fraud,
ethereumEventTriggerExtractorLogger,
);
const binanceEventTriggerExtractor = new EventTriggerExtractor(
'binance-extractor',
dataSource,
ErgoNetworkType.Explorer,
configs.ergo.explorerUrl,
configs.binance.addresses.eventTrigger,
configs.binance.tokens.rwt,
configs.binance.addresses.permit,
configs.binance.addresses.fraud,
binanceEventTriggerExtractorLogger,
);

scanner.registerExtractor(ergoEventTriggerExtractor);
scanner.registerExtractor(cardanoEventTriggerExtractor);
scanner.registerExtractor(bitcoinEventTriggerExtractor);
scanner.registerExtractor(ethereumEventTriggerExtractor);
scanner.registerExtractor(binanceEventTriggerExtractor);

logger.debug('event trigger extractors registered', {
scannerName: scanner.name(),
Expand All @@ -81,6 +95,7 @@ export const registerExtractors = (scanner: ErgoScanner) => {
cardanoEventTriggerExtractor.getId(),
bitcoinEventTriggerExtractor.getId(),
ethereumEventTriggerExtractor.getId(),
binanceEventTriggerExtractor.getId(),
],
});
} catch (error) {
Expand Down
41 changes: 41 additions & 0 deletions apps/rosen-service/src/observation/chains/binance.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { BinanceRpcObservationExtractor } from '@rosen-bridge/evm-observation-extractor';
import { EvmRpcScanner } from '@rosen-bridge/evm-rpc-scanner';
import WinstonLogger from '@rosen-bridge/winston-logger';

import config from '../../configs';
import dataSource from '../../data-source';
import AppError from '../../errors/AppError';
import { getRosenTokens } from '../../utils';

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

/**
* register an observation extractor for the provided scanner
* @param scanner
*/
export const registerBinanceExtractor = (scanner: EvmRpcScanner) => {
try {
const observationExtractor = new BinanceRpcObservationExtractor(
config.binance.addresses.lock,
dataSource,
getRosenTokens(),
logger
);

scanner.registerExtractor(observationExtractor);

logger.debug('binance observation extractor registered', {
scannerName: scanner.name(),
});
} catch (error) {
throw new AppError(
`cannot create or register binance observation extractor due to error: ${error}`,
false,
'error',
error instanceof Error ? error.stack : undefined,
{
scannerName: scanner.name(),
}
);
}
};
2 changes: 2 additions & 0 deletions apps/rosen-service/src/observation/observation-service.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { registerBinanceExtractor } from './chains/binance';
import { registerBitcoinExtractor } from './chains/bitcoin';
import { registerCardanoExtractor } from './chains/cardano';
import { registerErgoExtractor } from './chains/ergo';
Expand All @@ -8,6 +9,7 @@ const observationService = {
registerCardanoExtractor,
registerErgoExtractor,
registerEthereumExtractor,
registerBinanceExtractor,
};

export default observationService;
53 changes: 53 additions & 0 deletions apps/rosen-service/src/scanner/chains/binance.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { EvmRpcScanner } from '@rosen-bridge/evm-rpc-scanner';
import WinstonLogger from '@rosen-bridge/winston-logger';

import config from '../../configs';
import {
BINANCE_SCANNER_INTERVAL,
BINANCE_SCANNER_LOGGER_NAME,
SCANNER_API_TIMEOUT,
} from '../../constants';
import dataSource from '../../data-source';
import AppError from '../../errors/AppError';
import observationService from '../../observation/observation-service';
import { startScanner } from '../scanner-utils';

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

/**
* create a binance scanner, initializing it and calling its update method
* periodically
*/
export const startBinanceScanner = async () => {
try {
const scanner = new EvmRpcScanner(
'binance',
{
RpcUrl: config.binance.rpcUrl,
dataSource,
initialHeight: config.binance.initialHeight,
timeout: SCANNER_API_TIMEOUT,
},
scannerLogger,
config.binance.rpcAuthToken
);

observationService.registerBinanceExtractor(scanner);

await startScanner(scanner, import.meta.url, BINANCE_SCANNER_INTERVAL);

logger.debug('binance scanner started');

return scanner;
} catch (error) {
throw new AppError(
`cannot create or start binance scanner due to error: ${error}`,
false,
'error',
error instanceof Error ? error.stack : undefined
);
}
};
Loading

0 comments on commit 35c0cee

Please sign in to comment.