diff --git a/explorer/src/components/account/RewardsCard.tsx b/explorer/src/components/account/RewardsCard.tsx
index 39d2cb3eb5..e4d48e54bc 100644
--- a/explorer/src/components/account/RewardsCard.tsx
+++ b/explorer/src/components/account/RewardsCard.tsx
@@ -61,8 +61,8 @@ export function RewardsCard({ pubkey }: { pubkey: PublicKey }) {
);
});
-
- const { foundOldest } = rewards.data;
+ const rewardsFound = rewardsList.some((r) => r);
+ const { foundOldest, lowestFetchedEpoch, highestFetchedEpoch } = rewards.data;
const fetching = rewards.status === FetchStatus.Fetching;
return (
@@ -76,19 +76,26 @@ export function RewardsCard({ pubkey }: { pubkey: PublicKey }) {
-
-
-
-
- Epoch |
- Effective Slot |
- Reward Amount |
- Post Balance |
-
-
- {rewardsList}
-
-
+ {rewardsFound ? (
+
+
+
+
+ Epoch |
+ Effective Slot |
+ Reward Amount |
+ Post Balance |
+
+
+ {rewardsList}
+
+
+ ) : (
+
+ No rewards issued between epochs {lowestFetchedEpoch} and{" "}
+ {highestFetchedEpoch}
+
+ )}
{foundOldest ? (
diff --git a/explorer/src/providers/accounts/rewards.tsx b/explorer/src/providers/accounts/rewards.tsx
index 4b3517ad05..32fc4a0078 100644
--- a/explorer/src/providers/accounts/rewards.tsx
+++ b/explorer/src/providers/accounts/rewards.tsx
@@ -6,6 +6,11 @@ import { ActionType } from "providers/block";
import { FetchStatus } from "providers/cache";
import { reportError } from "utils/sentry";
+const REWARDS_AVAILABLE_EPOCH = new Map([
+ [Cluster.MainnetBeta, 132],
+ [Cluster.Testnet, 43],
+]);
+
const PAGE_SIZE = 15;
export type Rewards = {
@@ -17,6 +22,8 @@ export type Rewards = {
export type RewardsUpdate = {
rewards: (InflationReward | null)[];
+ highestFetchedEpoch: number;
+ lowestFetchedEpoch: number;
foundOldest?: boolean;
};
@@ -39,8 +46,9 @@ function reconcile(
return {
rewards: combined,
- highestFetchedEpoch: combined[0]?.epoch,
- lowestFetchedEpoch: combined[combined.length - 1]?.epoch,
+ highestFetchedEpoch:
+ rewards?.highestFetchedEpoch || update.highestFetchedEpoch,
+ lowestFetchedEpoch: update.lowestFetchedEpoch,
foundOldest,
};
}
@@ -84,12 +92,9 @@ async function fetchRewards(
url,
});
+ const lowestAvailableEpoch = REWARDS_AVAILABLE_EPOCH.get(cluster) || 0;
const connection = new Connection(url);
- if (!fromEpoch && highestEpoch) {
- fromEpoch = highestEpoch;
- }
-
if (!fromEpoch) {
try {
const epochInfo = await connection.getEpochInfo();
@@ -106,6 +111,10 @@ async function fetchRewards(
url,
});
}
+
+ if (highestEpoch && highestEpoch < fromEpoch) {
+ fromEpoch = highestEpoch;
+ }
}
const getInflationReward = async (epoch: number) => {
@@ -128,7 +137,7 @@ async function fetchRewards(
}
const results = await Promise.all(requests);
- fromEpoch = fromEpoch - requests.length;
+ const lowestFetchedEpoch = fromEpoch - requests.length;
dispatch({
type: ActionType.Update,
@@ -137,7 +146,9 @@ async function fetchRewards(
status: FetchStatus.Fetched,
data: {
rewards: results || [],
- foundOldest: fromEpoch <= 0,
+ foundOldest: lowestFetchedEpoch <= lowestAvailableEpoch,
+ highestFetchedEpoch: fromEpoch,
+ lowestFetchedEpoch,
},
});
}