From 854ce03fdf99c12db71f99c3736e8aba5306835a Mon Sep 17 00:00:00 2001 From: Claudiu Lataretu Date: Tue, 10 Oct 2023 23:48:45 +0300 Subject: [PATCH] MEX-404: update week timekeeping contract handler to return staking sc Signed-off-by: Claudiu Lataretu --- .../services/week-timekeeping.abi.service.ts | 13 +++++++++++-- .../week-timekeeping/week-timekeeping.module.ts | 2 ++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/submodules/week-timekeeping/services/week-timekeeping.abi.service.ts b/src/submodules/week-timekeeping/services/week-timekeeping.abi.service.ts index adfb6fea3..1a20d4ea4 100644 --- a/src/submodules/week-timekeeping/services/week-timekeeping.abi.service.ts +++ b/src/submodules/week-timekeeping/services/week-timekeeping.abi.service.ts @@ -7,13 +7,17 @@ import { IWeekTimekeepingAbiService } from '../interfaces'; import { ErrorLoggerAsync } from '@multiversx/sdk-nestjs-common'; import { GetOrSetCache } from 'src/helpers/decorators/caching.decorator'; import { CacheTtlInfo } from 'src/services/caching/cache.ttl.info'; +import { RemoteConfigGetterService } from 'src/modules/remote-config/remote-config.getter.service'; @Injectable() export class WeekTimekeepingAbiService extends GenericAbiService implements IWeekTimekeepingAbiService { - constructor(protected readonly mxProxy: MXProxyService) { + constructor( + protected readonly mxProxy: MXProxyService, + private readonly remoteConfig: RemoteConfigGetterService, + ) { super(mxProxy); } @@ -57,13 +61,18 @@ export class WeekTimekeepingAbiService return response.firstValue.valueOf().toNumber(); } - private getContractHandler( + private async getContractHandler( contractAddress: string, ): Promise { if (scAddress.feesCollector === contractAddress) { return this.mxProxy.getFeesCollectorContract(); } + const stakingAddresses = await this.remoteConfig.getStakingAddresses(); + if (stakingAddresses.includes(contractAddress)) { + return this.mxProxy.getStakingSmartContract(contractAddress); + } + return this.mxProxy.getFarmSmartContract(contractAddress); } } diff --git a/src/submodules/week-timekeeping/week-timekeeping.module.ts b/src/submodules/week-timekeeping/week-timekeeping.module.ts index 1e799b3a4..f6d39b9c7 100644 --- a/src/submodules/week-timekeeping/week-timekeeping.module.ts +++ b/src/submodules/week-timekeeping/week-timekeeping.module.ts @@ -7,6 +7,7 @@ import { WeekTimekeepingResolver } from './week-timekeeping.resolver'; import { FarmModuleV2 } from 'src/modules/farm/v2/farm.v2.module'; import { FeesCollectorModule } from 'src/modules/fees-collector/fees-collector.module'; import { ContextModule } from 'src/services/context/context.module'; +import { RemoteConfigModule } from 'src/modules/remote-config/remote-config.module'; @Module({ imports: [ @@ -14,6 +15,7 @@ import { ContextModule } from 'src/services/context/context.module'; ContextModule, forwardRef(() => FarmModuleV2), forwardRef(() => FeesCollectorModule), + RemoteConfigModule, ], providers: [ ApiConfigService,