Skip to content

Commit

Permalink
MEX-404: update week timekeeping contract handler to return staking sc
Browse files Browse the repository at this point in the history
Signed-off-by: Claudiu Lataretu <[email protected]>
  • Loading branch information
claudiulataretu committed Oct 10, 2023
1 parent 1e69156 commit 854ce03
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -57,13 +61,18 @@ export class WeekTimekeepingAbiService
return response.firstValue.valueOf().toNumber();
}

private getContractHandler(
private async getContractHandler(
contractAddress: string,
): Promise<SmartContract> {
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);
}
}
2 changes: 2 additions & 0 deletions src/submodules/week-timekeeping/week-timekeeping.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ 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: [
MXCommunicationModule,
ContextModule,
forwardRef(() => FarmModuleV2),
forwardRef(() => FeesCollectorModule),
RemoteConfigModule,
],
providers: [
ApiConfigService,
Expand Down

0 comments on commit 854ce03

Please sign in to comment.