Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/endpoints/dapp-config/dapp.config.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export class DappConfigController {
@ApiOperation({ summary: 'Dapp configuration', description: 'Returns configuration used in dapps' })
@ApiOkResponse({ type: DappConfig })
@ApiNotFoundResponse({ description: 'Network configuration not found' })
getDappConfiguration(): DappConfig {
const configuration = this.dappConfigService.getDappConfiguration();
async getDappConfiguration(): Promise<DappConfig | undefined> {
const configuration = await this.dappConfigService.getDappConfiguration();
if (!configuration) {
throw new NotFoundException(`Network configuration not found`);
}
Expand Down
18 changes: 17 additions & 1 deletion src/endpoints/dapp-config/dapp.config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,34 @@ import { FileUtils } from "@multiversx/sdk-nestjs-common";
import { Injectable } from "@nestjs/common";
import { ApiConfigService } from "src/common/api-config/api.config.service";
import { DappConfig } from "./entities/dapp-config";
import { GatewayService } from "src/common/gateway/gateway.service";

@Injectable()
export class DappConfigService {
private readonly dappConfig: DappConfig | undefined;

constructor(
private readonly apiConfigService: ApiConfigService,
private readonly gatewayService: GatewayService,
) {
this.dappConfig = this.getDappConfigurationRaw();
}

getDappConfiguration(): DappConfig | undefined {
async getDappConfiguration(): Promise<DappConfig | undefined> {
if (!this.dappConfig) {
return undefined;
}

const networkConfig = await this.gatewayService.getNetworkConfig();
const refreshRate = networkConfig.erd_round_duration;

if (refreshRate) {
return {
...this.dappConfig,
refreshRate,
};
}

return this.dappConfig;
}

Expand Down
3 changes: 3 additions & 0 deletions src/endpoints/dapp-config/entities/dapp-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,7 @@ export class DappConfig {

@ApiProperty({ type: String, example: '1' })
chainId: string = '';

@ApiProperty({ type: Number, example: 6000 })
refreshRate: number = 0;
}