diff --git a/apps/server/src/settings/SettingsController.ts b/apps/server/src/settings/SettingsController.ts index 38036c673..200ee5e40 100644 --- a/apps/server/src/settings/SettingsController.ts +++ b/apps/server/src/settings/SettingsController.ts @@ -16,6 +16,7 @@ export class SettingsController { defichain: { transferFee: this.configService.getOrThrow('defichain.transferFee') as `${number}`, supportedTokens: supportedDfcTokens.split(',') as Array, + network: this.configService.getOrThrow('defichain.network'), }, ethereum: { transferFee: this.configService.getOrThrow('ethereum.transferFee') as `${number}`, diff --git a/apps/server/src/settings/SettingsInterface.ts b/apps/server/src/settings/SettingsInterface.ts index d2fcfc78c..f6743c1a5 100644 --- a/apps/server/src/settings/SettingsInterface.ts +++ b/apps/server/src/settings/SettingsInterface.ts @@ -3,6 +3,7 @@ import { SupportedDFCTokenSymbols, SupportedEVMTokenSymbols } from 'src/AppConfi interface Settings { transferFee: `${number}` | number; supportedTokens: Array; + network?: string; } export interface SettingsModel { diff --git a/apps/server/test-i9n/testing/SettingsController.i9n.ts b/apps/server/test-i9n/testing/SettingsController.i9n.ts new file mode 100644 index 000000000..56e89c7f7 --- /dev/null +++ b/apps/server/test-i9n/testing/SettingsController.i9n.ts @@ -0,0 +1,54 @@ +import { PostgreSqlContainer, StartedPostgreSqlContainer } from '@birthdayresearch/sticky-testcontainers'; +import { ConfigService } from '@nestjs/config'; + +import { BridgeServerTestingApp } from './BridgeServerTestingApp'; +import { buildTestConfig, TestingModule } from './TestingModule'; + +describe.only('Settings Controller Test', () => { + let testing: BridgeServerTestingApp; + let startedPostgresContainer: StartedPostgreSqlContainer; + let config: ConfigService; + + beforeAll(async () => { + startedPostgresContainer = await new PostgreSqlContainer().start(); + + testing = new BridgeServerTestingApp( + TestingModule.register( + buildTestConfig({ + defichain: { transferFee: '0.003', supportedTokens: 'BTC,ETH' }, + ethereum: { transferFee: '0', supportedTokens: 'WBTC,ETH' }, + startedPostgresContainer, + }), + ), + ); + + const app = await testing.start(); + config = app.get(ConfigService); + }); + + afterAll(async () => { + await testing.stop(); + }); + + it('Settings service should return the correct app settings for both DeFiChain and Ethereum', async () => { + const response = await testing.inject({ + method: 'GET', + url: `/settings`, + }); + const settings = JSON.parse(response.payload); + const dfcSupportedTokens = config.get('SUPPORTED_DFC_TOKENS')?.split(','); + const evmSupportedTokens = config.get('SUPPORTED_EVM_TOKENS')?.split(','); + + expect(settings).toMatchObject({ + defichain: { + transferFee: config.get('DFC_FEE_PERCENTAGE'), + supportedTokens: dfcSupportedTokens, + network: 'Local', + }, + ethereum: { + transferFee: config.get('ETH_FEE_PERCENTAGE'), + supportedTokens: evmSupportedTokens, + }, + }); + }); +}); diff --git a/apps/server/test-i9n/testing/TestingModule.ts b/apps/server/test-i9n/testing/TestingModule.ts index 19eb5ff8a..b6547e860 100644 --- a/apps/server/test-i9n/testing/TestingModule.ts +++ b/apps/server/test-i9n/testing/TestingModule.ts @@ -46,6 +46,7 @@ export function buildTestConfig({ ethereum: { rpcUrl: startedHardhatContainer?.rpcUrl ?? '', transferFee: ethereum?.transferFee, + supportedTokens: ethereum?.supportedTokens, contracts: { bridgeProxy: { address: testnet?.bridgeContractAddress ?? '', @@ -81,6 +82,7 @@ type OptionalBuildTestConfigParams = { }; ethereum: { transferFee: string; + supportedTokens: string; }; startedHardhatContainer: StartedHardhatNetworkContainer; testnet: { diff --git a/apps/web/src/types.ts b/apps/web/src/types.ts index 722343d87..ca9720fcb 100644 --- a/apps/web/src/types.ts +++ b/apps/web/src/types.ts @@ -29,6 +29,7 @@ export interface BridgeVersion { interface Settings { transferFee: `${number}` | number; supportedTokens: string[]; + network?: string; } export interface BridgeSettings {