Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Commit

Permalink
fix(keeper): Removed dependency to Keeper's API (#3129)
Browse files Browse the repository at this point in the history
  • Loading branch information
wpoulin committed Dec 12, 2023
1 parent 548efbe commit e45cb73
Showing 1 changed file with 3 additions and 20 deletions.
23 changes: 3 additions & 20 deletions src/apps/keeper/ethereum/keeper.job.contract-position-fetcher.ts
@@ -1,12 +1,12 @@
import 'moment-duration-format';

import { Inject } from '@nestjs/common';
import Axios from 'axios';
import { BigNumberish } from 'ethers';
import moment from 'moment';

import { IAppToolkit, APP_TOOLKIT } from '~app-toolkit/app-toolkit.interface';
import { PositionTemplate } from '~app-toolkit/decorators/position-template.decorator';
import { getLabelFromToken } from '~app-toolkit/helpers/presentation/image.present';
import { MetaType } from '~position/position.interface';
import { ContractPositionTemplatePositionFetcher } from '~position/template/contract-position.template.position-fetcher';
import {
Expand All @@ -16,19 +16,10 @@ import {
GetTokenBalancesParams,
GetDataPropsParams,
} from '~position/template/contract-position.template.types';
import { NETWORK_IDS } from '~types';

import { KeeperViemContractFactory } from '../contracts';
import { KeeperJobManager } from '../contracts/viem';

const KEEP3R_JOB_NAME_API = 'https://keep3r.vercel.app/api/registry';

type KeeperJobRegistryApiResponse = {
chainID: number;
address: string;
name: string;
}[];

export type KeeperJobDefinition = {
address: string;
jobAddress: string;
Expand Down Expand Up @@ -87,16 +78,8 @@ export class EthereumKeeperJobContractPositionFetcher extends ContractPositionTe
: [{ metaType: MetaType.LOCKED, address: keeperLpAddress, network: this.network }];
}

async getLabel({
definition,
}: GetDisplayPropsParams<KeeperJobManager, KeeperJobDataProps, KeeperJobDefinition>): Promise<string> {
const data = await Axios.get<KeeperJobRegistryApiResponse>(KEEP3R_JOB_NAME_API).then(v =>
Object.values(v.data).map(job => ({ ...job, address: job.address.toLowerCase() })),
);
const filteredData = data.filter(job => job.chainID === NETWORK_IDS[this.network]);
const foundJob = filteredData.find(x => x.address === definition.jobAddress);

return (foundJob && `${foundJob.name} Keep3r Job`) || 'Keep3r Job';
async getLabel({ contractPosition }: GetDisplayPropsParams<KeeperJobManager>): Promise<string> {
return getLabelFromToken(contractPosition.tokens[0]);
}

async getDataProps({
Expand Down

0 comments on commit e45cb73

Please sign in to comment.