diff --git a/apps/dashboard/src/components/contract-components/fetch-contracts-with-versions.ts b/apps/dashboard/src/components/contract-components/fetch-contracts-with-versions.ts index 3a166d1be5f..15c046af9ce 100644 --- a/apps/dashboard/src/components/contract-components/fetch-contracts-with-versions.ts +++ b/apps/dashboard/src/components/contract-components/fetch-contracts-with-versions.ts @@ -47,7 +47,18 @@ export async function fetchPublishedContractVersions( ), ); - return responses.filter((r) => r.status === "fulfilled").map((r) => r.value); + const publishedContracts = responses + .filter((r) => r.status === "fulfilled") + .map((r) => r.value); + + // if there are two published contract with same version, keep the latest (first in list - list is already sorted) one + const uniquePublishedContracts = publishedContracts.filter( + (contract, idx, arr) => + // if this is the first occurrence of this version in list - keep it + arr.findIndex((c) => c.version === contract.version) === idx, + ); + + return uniquePublishedContracts; } export async function fetchPublishedContractVersion(