diff --git a/src/common/io.ts b/src/common/io.ts index c8cb721f..16dc5d89 100644 --- a/src/common/io.ts +++ b/src/common/io.ts @@ -62,6 +62,7 @@ import { AoGatewayRegistrySettings, AoGatewayVault, AoGetCostDetailsParams, + AoGetEpochResult, AoIncreaseUndernameLimitParams, AoIncreaseVaultParams, AoPaginatedAddressParams, @@ -83,6 +84,7 @@ import { getEpochDataFromGql, paginationParamsToTags, pruneTags, + removeEligibleDistributionsFromEpochData, sortAndPaginateEpochDataIntoEligibleDistributions, } from '../utils/arweave.js'; import { defaultArweave } from './arweave.js'; @@ -202,7 +204,7 @@ export class ARIOReadable implements AoARIORead { })); } - async getEpoch(epoch?: EpochInput): Promise { + async getEpoch(epoch?: EpochInput): Promise { const epochIndex = await this.computeEpochIndex(epoch); const currentIndex = await this.computeCurrentEpochIndex(); if (epochIndex !== undefined && epochIndex < currentIndex) { @@ -211,7 +213,8 @@ export class ARIOReadable implements AoARIORead { epochIndex: epochIndex, processId: this.process.processId, }); - return epochData; + + return removeEligibleDistributionsFromEpochData(epochData); } // go to the process epoch and fetch the epoch data const allTags = [ diff --git a/src/types/io.ts b/src/types/io.ts index 80ae868b..f71bf0b9 100644 --- a/src/types/io.ts +++ b/src/types/io.ts @@ -120,6 +120,15 @@ export type AoEpochDistributionRewards = { distributed?: Record; }; +export type AoGetEpochDistributionRewards = Omit< + AoEpochDistributionRewards, + 'eligible' +>; + +export type AoGetEpochDistributionData = AoEpochDistributionData & { + rewards: AoGetEpochDistributionRewards; +}; + export type AoEpochDistributionData = { rewards: AoEpochDistributionRewards; totalEligibleGateways: number; @@ -173,7 +182,6 @@ export type AoEpochData = { startTimestamp: Timestamp; endTimestamp: Timestamp; distributionTimestamp: Timestamp; - /** @deprecated - use `getDistributions` to get distribution data for a given epoch **/ distributions: AoEpochDistributionData; arnsStats: { totalReturnedNames: number; @@ -183,7 +191,11 @@ export type AoEpochData = { }; }; -export type AoEligibleReward = { +export type AoGetEpochResult = Omit & { + distributions?: AoGetEpochDistributionData; +}; + +export type AoEligibleDistribution = { type: 'operatorReward' | 'delegateReward'; recipient: WalletAddress; eligibleReward: number; @@ -604,7 +616,7 @@ export interface AoARIORead { }: { name: string; }): Promise; - getEpoch(epoch?: EpochInput): Promise; + getEpoch(epoch?: EpochInput): Promise; getCurrentEpoch(): Promise; getPrescribedObservers( epoch?: EpochInput, diff --git a/src/utils/arweave.ts b/src/utils/arweave.ts index 771fb3bc..0fb5dd94 100644 --- a/src/utils/arweave.ts +++ b/src/utils/arweave.ts @@ -20,6 +20,7 @@ import { BlockHeight } from '../types/common.js'; import { AoEligibleDistribution, AoEpochData, + AoGetEpochResult, PaginationParams, PaginationResult, } from '../types/io.js'; @@ -227,3 +228,22 @@ export function sortAndPaginateEpochDataIntoEligibleDistributions( sortBy, }; } + +export function removeEligibleDistributionsFromEpochData( + epochData?: AoEpochData, +): AoGetEpochResult | undefined { + if (epochData === undefined) { + return undefined; + } + return { + ...epochData, + distributions: { + ...epochData.distributions, + rewards: { + ...epochData.distributions.rewards, + // @ts-expect-error -- remove eligible + eligible: undefined, + }, + }, + }; +}