Skip to content

Commit 633f20b

Browse files
committed
[vyper] Use the GITHUB_TOKEN and increase timeout
1 parent b24b994 commit 633f20b

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

packages/hardhat-vyper/src/downloader.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,27 @@ import { VyperPluginError, getLogger } from "./util";
1414

1515
const log = getLogger("downloader");
1616

17+
const DOWNLOAD_TIMEOUT_MS = 30_000;
18+
1719
async function downloadFile(
1820
url: string,
1921
destinationFile: string
2022
): Promise<void> {
2123
const { download } = await import("hardhat/internal/util/download");
2224
log(`Downloading from ${url} to ${destinationFile}`);
23-
await download(url, destinationFile);
25+
26+
const headers: { [name: string]: string } = {};
27+
// If we are running in GitHub Actions we use the GitHub token as auth to
28+
// avoid hitting a rate limit.
29+
// Inspired by https://github.com/vyperlang/vvm/blob/5c37a2f4bbebc8c5f7f1dbb8ff89a4df1070ec44/vvm/install.py#L139
30+
if (process.env.GITHUB_TOKEN !== undefined) {
31+
const base64 = Buffer.from(process.env.GITHUB_TOKEN, "ascii").toString(
32+
"base64"
33+
);
34+
headers.Authorization = `Basic ${base64}`;
35+
}
36+
37+
await download(url, destinationFile, DOWNLOAD_TIMEOUT_MS, headers);
2438
}
2539

2640
type DownloadFunction = (url: string, destinationFile: string) => Promise<void>;

0 commit comments

Comments
 (0)