Skip to content

Commit eb75977

Browse files
authored
Merge pull request #4 from sourcifyeth/change-vyper-version-source
Use hardhat's vyper list as version source
2 parents d80c5b1 + d9ab8d9 commit eb75977

File tree

1 file changed

+27
-14
lines changed

1 file changed

+27
-14
lines changed

app/contexts/CompilerVersionsContext.tsx

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ export interface SolidityVersion {
99
export interface VyperVersion {
1010
version: string;
1111
longVersion: string;
12-
build: string;
1312
isPrerelease: boolean;
1413
}
1514

@@ -34,7 +33,7 @@ interface CompilerVersionsContextType {
3433
const CompilerVersionsContext = createContext<CompilerVersionsContextType | undefined>(undefined);
3534

3635
const SOLC_VERSIONS_LIST_URL = "https://raw.githubusercontent.com/ethereum/solc-bin/gh-pages/bin/list.txt";
37-
const VYPER_VERSIONS_LIST_URL = "https://raw.githubusercontent.com/blockscout/solc-bin/refs/heads/main/vyper.list.json";
36+
const VYPER_VERSIONS_LIST_URL = "https://vyper-releases-mirror.hardhat.org/list.json";
3837

3938
function formatSolidityVersionName(filename: string): SolidityVersion {
4039
// Remove "soljson-v" prefix and ".js" suffix
@@ -48,11 +47,17 @@ function formatSolidityVersionName(filename: string): SolidityVersion {
4847
};
4948
}
5049

51-
interface VyperBuild {
52-
version: string;
53-
longVersion: string;
54-
build: string;
55-
prerelease?: string;
50+
function getVersionWithCommit(assetName: string): string {
51+
// Remove vyper. prefix and platform suffix (.darwin, .linux, .windows.exe)
52+
return assetName.replace(/^vyper\./, "").replace(/\.(darwin|linux|windows\.exe)$/, "");
53+
}
54+
55+
interface HardhatVyperVersion {
56+
tag_name: string;
57+
assets: {
58+
name: string;
59+
browser_download_url: string;
60+
}[];
5661
}
5762

5863
export function CompilerVersionsProvider({ children }: { children: React.ReactNode }) {
@@ -91,13 +96,21 @@ export function CompilerVersionsProvider({ children }: { children: React.ReactNo
9196
useEffect(() => {
9297
fetch(VYPER_VERSIONS_LIST_URL)
9398
.then((response) => response.json())
94-
.then((data: { builds: VyperBuild[] }) => {
95-
const allVersionsList: VyperVersion[] = data.builds.map((build) => ({
96-
version: build.version,
97-
longVersion: build.longVersion,
98-
build: build.build,
99-
isPrerelease: !!build.prerelease,
100-
}));
99+
.then((data: HardhatVyperVersion[]) => {
100+
const allVersionsList: VyperVersion[] = data
101+
.filter((release) => release.assets.length > 0)
102+
.map((release) => {
103+
const versionWithCommit = getVersionWithCommit(release.assets[0].name);
104+
const version = release.tag_name.replace(/^v/, ""); // Remove 'v' prefix
105+
// Check if tag has suffix after version (e.g., v0.4.1b1 is prerelease, v0.4.1 is not)
106+
const isPrerelease = /^v\d+\.\d+\.\d+.+/.test(release.tag_name);
107+
108+
return {
109+
version,
110+
longVersion: versionWithCommit,
111+
isPrerelease,
112+
};
113+
});
101114

102115
setVyperVersions(allVersionsList);
103116
setOfficialVyperVersions(allVersionsList.filter((version) => !version.isPrerelease));

0 commit comments

Comments
 (0)