Skip to content

Commit 80e70f2

Browse files
authored
[TOOL-2764] Dashboard: Fix published contract version selector with duplicate versions (#5893)
1 parent 18ef10b commit 80e70f2

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

apps/dashboard/src/components/contract-components/fetch-contracts-with-versions.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,18 @@ export async function fetchPublishedContractVersions(
4747
),
4848
);
4949

50-
return responses.filter((r) => r.status === "fulfilled").map((r) => r.value);
50+
const publishedContracts = responses
51+
.filter((r) => r.status === "fulfilled")
52+
.map((r) => r.value);
53+
54+
// if there are two published contract with same version, keep the latest (first in list - list is already sorted) one
55+
const uniquePublishedContracts = publishedContracts.filter(
56+
(contract, idx, arr) =>
57+
// if this is the first occurrence of this version in list - keep it
58+
arr.findIndex((c) => c.version === contract.version) === idx,
59+
);
60+
61+
return uniquePublishedContracts;
5162
}
5263

5364
export async function fetchPublishedContractVersion(

0 commit comments

Comments
 (0)